Main MRPT website > C++ reference for MRPT 1.5.7
THypothesis_impl.h
Go to the documentation of this file.
1 #ifndef THYPOTHESIS_IMPL_H
2 #define THYPOTHESIS_IMPL_H
3 
4 // implementation file for the THypothesis struct template
5 
6 namespace mrpt { namespace graphs { namespace detail {
7 
8 template<class GRAPH_T>
10  is_valid(true),
11  goodness(0) {}
12 
13 template<class GRAPH_T>
15 
16 
17 template<class GRAPH_T>
19  bool oneline/*=true*/) const {
20  std::string str;
21  this->getAsString(&str, oneline);
22  return str;
23 }
24 
25 template<class GRAPH_T>
27  std::string* str,
28  bool oneline/*=true*/) const {
29  ASSERTMSG_(str, "Given string pointer is not valid");
30 
31  using namespace std;
32 
33  stringstream ss;
34  if (!oneline) { // multiline report
35  ss << "Hypothesis #" << id << endl;
36  ss << from << " => " << to << endl;
37  ss << edge << endl;
38  }
39  else {
40  ss << "Hypothesis #" << id << "| ";
41  ss << from << " => " << to << "| ";
42  ss << edge.getMeanVal().asString();
43  ss << "|goodness: " << goodness;
44  ss << "|valid: " << is_valid;
45  }
46 
47  *str = ss.str();
48 }
49 
50 // TODO - test these
51 template<class GRAPH_T>
53  const self_t& other) const {
54  return (this->from == other.from && this->to == other.to);
55 }
56 
57 template<class GRAPH_T>
59  mrpt::utils::TNodeID from_in,
60  mrpt::utils::TNodeID to_in) const {
61  return (this->from == from_in && this->to == to_in);
62 }
63 
64 template<class GRAPH_T>
66  ASSERT_(edge);
67  edge->copyFrom(this->edge);
68 }
69 
70 template<class GRAPH_T>
71 typename GRAPH_T::constraint_t
73 
74  return this->edge;
75 }
76 
77 template<class GRAPH_T>
79  this->edge.copyFrom(edge);
80 }
81 
82 template<class GRAPH_T>
84  ASSERT_(edge);
85  this->edge.inverse(*edge);
86 }
87 
88 template<class GRAPH_T>
89 typename GRAPH_T::constraint_t
91  constraint_t inverse_edge;
92  this->getInverseEdge(&inverse_edge);
93 
94  return inverse_edge;
95 }
96 
97 template<class GRAPH_T>
99  // inverse the start/end nodes
100  mrpt::utils::TNodeID tmp = from;
101  from = to;
102  to = tmp;
103 
104  // inverse the edge
105  constraint_t edge_tmp = this->getInverseEdge();
106  this->edge.copyFrom(edge_tmp);
107 }
108 
109 template<class GRAPH_T>
110 bool THypothesis<GRAPH_T>::operator<(const self_t& other) const {
111  return this->id < other.id;
112 }
113 
114 
115 } } } // end of namespaces
116 
117 #endif /* end of include guard: THYPOTHESIS_IMPL_H */
void inverseHypothesis()
Reverse the hypothesis.
GRAPH_T::constraint_t constraint_t
Handy typedefs.
Definition: THypothesis.h:37
STL namespace.
mrpt::utils::TNodeID from
Starting node of the hypothesis.
Definition: THypothesis.h:85
uint64_t TNodeID
The type for node IDs in graphs of different types.
bool operator<(const self_t &other) const
Handy operator for using THypothesis in std::set.
GLsizei const GLchar ** string
Definition: glext.h:3919
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
mrpt::utils::TNodeID to
Ending node of the hypothesis.
Definition: THypothesis.h:87
void setEdge(const constraint_t &edge)
Setter method for the underlying edge.
#define ASSERT_(f)
constraint_t getInverseEdge() const
size_t id
ID of the current hypothesis.
Definition: THypothesis.h:83
An edge hypothesis between two nodeIDs.
Definition: THypothesis.h:33
bool hasEnds(const mrpt::utils::TNodeID from, const mrpt::utils::TNodeID to) const
Check if the start, end nodes are the ones given.
#define ASSERTMSG_(f, __ERROR_MSG)
bool sameEndsWith(const self_t &other) const
Compare the start and end nodes of two hypothesis.
std::string getAsString(bool oneline=true) const
Return a string representation of the object at hand.



Page generated by Doxygen 1.8.14 for MRPT 1.5.7 Git: 5902e14cc Wed Apr 24 15:04:01 2019 +0200 at lun oct 28 01:39:17 CET 2019