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-2018, 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::graphs::TNodeID from_in, mrpt::graphs::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_(out_edge);
83  out_edge->copyFrom(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  edge.copyFrom(in_edge);
96 }
97 
98 template <class GRAPH_T>
100 {
101  ASSERT_(out_edge);
102  edge.inverse(*out_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::graphs::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 } // namespace detail
133 } // namespace graphs
134 } // namespace mrpt
135 
136 #endif /* end of include guard: THYPOTHESIS_IMPL_H */
mrpt::graphs::detail::THypothesis::setEdge
void setEdge(const constraint_t &edge)
Setter method for the underlying edge.
Definition: THypothesis_impl.h:93
mrpt::graphs::detail::THypothesis::getInverseEdge
constraint_t getInverseEdge() const
Definition: THypothesis_impl.h:106
mrpt::graphs::detail::THypothesis::hasEnds
bool hasEnds(const mrpt::graphs::TNodeID from, const mrpt::graphs::TNodeID to) const
Check if the start, end nodes are the ones given.
Definition: THypothesis_impl.h:73
mrpt::graphs::TNodeID
uint64_t TNodeID
A generic numeric type for unique IDs of nodes or entities.
Definition: TNodeID.h:17
mrpt::graphs::detail::THypothesis
An edge hypothesis between two nodeIDs.
Definition: THypothesis.h:37
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
ASSERT_
#define ASSERT_(f)
Defines an assertion mechanism.
Definition: exceptions.h:113
mrpt::graphs::detail::THypothesis::getAsString
std::string getAsString(bool oneline=true) const
Return a string representation of the object at hand.
Definition: THypothesis_impl.h:31
mrpt::graphs::detail::THypothesis::sameEndsWith
bool sameEndsWith(const self_t &other) const
Compare the start and end nodes of two hypothesis.
Definition: THypothesis_impl.h:67
mrpt::graphs::detail::THypothesis::id
size_t id
ID of the current hypothesis.
Definition: THypothesis.h:89
mrpt::graphs::detail::THypothesis::~THypothesis
~THypothesis()
Destructor.
Definition: THypothesis_impl.h:26
mrpt::graphs::detail::THypothesis::operator<
bool operator<(const self_t &other) const
Handy operator for using THypothesis in std::set.
Definition: THypothesis_impl.h:128
mrpt::graphs::detail::THypothesis::THypothesis
THypothesis()
Constructor.
Definition: THypothesis_impl.h:21
mrpt::graphs::detail::THypothesis::to
mrpt::graphs::TNodeID to
Ending node of the hypothesis.
Definition: THypothesis.h:93
mrpt::graphs::detail::THypothesis::from
mrpt::graphs::TNodeID from
Starting node of the hypothesis.
Definition: THypothesis.h:91
ASSERTMSG_
#define ASSERTMSG_(f, __ERROR_MSG)
Defines an assertion mechanism.
Definition: exceptions.h:101
mrpt::graphs::detail::THypothesis::inverseHypothesis
void inverseHypothesis()
Reverse the hypothesis.
Definition: THypothesis_impl.h:115
mrpt::graphs::detail::THypothesis::getEdge
constraint_t getEdge() const
Definition: THypothesis_impl.h:87
string
GLsizei const GLchar ** string
Definition: glext.h:4101
mrpt::graphs::detail::THypothesis::constraint_t
typename GRAPH_T::constraint_t constraint_t
Handy typedefs.
Definition: THypothesis.h:42



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST