Main MRPT website > C++ reference for MRPT 1.9.9
THypothesis_impl.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #ifndef THYPOTHESIS_IMPL_H
10 #define THYPOTHESIS_IMPL_H
11 
12 // implementation file for the THypothesis struct template
13 
14 namespace mrpt
15 {
16 namespace graphs
17 {
18 namespace detail
19 {
20 template <class GRAPH_T>
21 THypothesis<GRAPH_T>::THypothesis() : is_valid(true), goodness(0)
22 {
23 }
24 
25 template <class GRAPH_T>
27 {
28 }
29 
30 template <class GRAPH_T>
31 std::string THypothesis<GRAPH_T>::getAsString(bool oneline /*=true*/) const
32 {
33  std::string str;
34  this->getAsString(&str, oneline);
35  return str;
36 }
37 
38 template <class GRAPH_T>
40  std::string* str, bool oneline /*=true*/) const
41 {
42  ASSERTMSG_(str, "Given string pointer is not valid");
43 
44  using namespace std;
45 
46  stringstream ss;
47  if (!oneline)
48  { // multiline report
49  ss << "Hypothesis #" << id << endl;
50  ss << from << " => " << to << endl;
51  ss << edge << endl;
52  }
53  else
54  {
55  ss << "Hypothesis #" << id << "| ";
56  ss << from << " => " << to << "| ";
57  ss << edge.getMeanVal().asString();
58  ss << "|goodness: " << goodness;
59  ss << "|valid: " << is_valid;
60  }
61 
62  *str = ss.str();
63 }
64 
65 // TODO - test these
66 template <class GRAPH_T>
68 {
69  return (this->from == other.from && this->to == other.to);
70 }
71 
72 template <class GRAPH_T>
74  mrpt::utils::TNodeID from_in, mrpt::utils::TNodeID to_in) const
75 {
76  return (this->from == from_in && this->to == to_in);
77 }
78 
79 template <class GRAPH_T>
81 {
82  ASSERT_(edge);
83  edge->copyFrom(this->edge);
84 }
85 
86 template <class GRAPH_T>
87 typename GRAPH_T::constraint_t THypothesis<GRAPH_T>::getEdge() const
88 {
89  return this->edge;
90 }
91 
92 template <class GRAPH_T>
94 {
95  this->edge.copyFrom(edge);
96 }
97 
98 template <class GRAPH_T>
100 {
101  ASSERT_(edge);
102  this->edge.inverse(*edge);
103 }
104 
105 template <class GRAPH_T>
106 typename GRAPH_T::constraint_t THypothesis<GRAPH_T>::getInverseEdge() const
107 {
108  constraint_t inverse_edge;
109  this->getInverseEdge(&inverse_edge);
110 
111  return inverse_edge;
112 }
113 
114 template <class GRAPH_T>
116 {
117  // inverse the start/end nodes
118  mrpt::utils::TNodeID tmp = from;
119  from = to;
120  to = tmp;
121 
122  // inverse the edge
123  constraint_t edge_tmp = this->getInverseEdge();
124  this->edge.copyFrom(edge_tmp);
125 }
126 
127 template <class GRAPH_T>
128 bool THypothesis<GRAPH_T>::operator<(const self_t& other) const
129 {
130  return this->id < other.id;
131 }
132 }
133 }
134 } // end of namespaces
135 
136 #endif /* end of include guard: THYPOTHESIS_IMPL_H */
void inverseHypothesis()
Reverse the hypothesis.
GRAPH_T::constraint_t constraint_t
Handy typedefs.
Definition: THypothesis.h:42
STL namespace.
mrpt::utils::TNodeID from
Starting node of the hypothesis.
Definition: THypothesis.h:91
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:4101
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:93
void setEdge(const constraint_t &edge)
Setter method for the underlying edge.
#define ASSERT_(f)
size_t id
ID of the current hypothesis.
Definition: THypothesis.h:89
An edge hypothesis between two nodeIDs.
Definition: THypothesis.h:37
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.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019