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::graphs::detail
15 {
16 template <class GRAPH_T>
17 THypothesis<GRAPH_T>::THypothesis() : is_valid(true), goodness(0)
18 {
19 }
20 
21 template <class GRAPH_T>
23 {
24 }
25 
26 template <class GRAPH_T>
27 std::string THypothesis<GRAPH_T>::getAsString(bool oneline /*=true*/) const
28 {
29  std::string str;
30  this->getAsString(&str, oneline);
31  return str;
32 }
33 
34 template <class GRAPH_T>
36  std::string* str, bool oneline /*=true*/) const
37 {
38  ASSERTMSG_(str, "Given string pointer is not valid");
39 
40  using namespace std;
41 
42  stringstream ss;
43  if (!oneline)
44  { // multiline report
45  ss << "Hypothesis #" << id << endl;
46  ss << from << " => " << to << endl;
47  ss << edge << endl;
48  }
49  else
50  {
51  ss << "Hypothesis #" << id << "| ";
52  ss << from << " => " << to << "| ";
53  ss << edge.getMeanVal().asString();
54  ss << "|goodness: " << goodness;
55  ss << "|valid: " << is_valid;
56  }
57 
58  *str = ss.str();
59 }
60 
61 // TODO - test these
62 template <class GRAPH_T>
64 {
65  return (this->from == other.from && this->to == other.to);
66 }
67 
68 template <class GRAPH_T>
70  mrpt::graphs::TNodeID from_in, mrpt::graphs::TNodeID to_in) const
71 {
72  return (this->from == from_in && this->to == to_in);
73 }
74 
75 template <class GRAPH_T>
77 {
78  ASSERT_(out_edge);
79  out_edge->copyFrom(edge);
80 }
81 
82 template <class GRAPH_T>
83 typename GRAPH_T::constraint_t THypothesis<GRAPH_T>::getEdge() const
84 {
85  return this->edge;
86 }
87 
88 template <class GRAPH_T>
90 {
91  edge.copyFrom(in_edge);
92 }
93 
94 template <class GRAPH_T>
96 {
97  ASSERT_(out_edge);
98  edge.inverse(*out_edge);
99 }
100 
101 template <class GRAPH_T>
102 typename GRAPH_T::constraint_t THypothesis<GRAPH_T>::getInverseEdge() const
103 {
104  constraint_t inverse_edge;
105  this->getInverseEdge(&inverse_edge);
106 
107  return inverse_edge;
108 }
109 
110 template <class GRAPH_T>
112 {
113  // inverse the start/end nodes
114  mrpt::graphs::TNodeID tmp = from;
115  from = to;
116  to = tmp;
117 
118  // inverse the edge
119  constraint_t edge_tmp = this->getInverseEdge();
120  this->edge.copyFrom(edge_tmp);
121 }
122 
123 template <class GRAPH_T>
124 bool THypothesis<GRAPH_T>::operator<(const self_t& other) const
125 {
126  return this->id < other.id;
127 }
128 } // namespace mrpt
129 
130 #endif /* end of include guard: THYPOTHESIS_IMPL_H */
131 
132 
void inverseHypothesis()
Reverse the hypothesis.
STL namespace.
typename GRAPH_T::constraint_t constraint_t
Handy typedefs.
Definition: THypothesis.h:38
#define ASSERT_(f)
Defines an assertion mechanism.
Definition: exceptions.h:113
Internal functions for MRPT.
mrpt::graphs::TNodeID from
Starting node of the hypothesis.
Definition: THypothesis.h:87
bool operator<(const self_t &other) const
Handy operator for using THypothesis in std::set.
#define ASSERTMSG_(f, __ERROR_MSG)
Defines an assertion mechanism.
Definition: exceptions.h:101
bool hasEnds(const mrpt::graphs::TNodeID from, const mrpt::graphs::TNodeID to) const
Check if the start, end nodes are the ones given.
GLsizei const GLchar ** string
Definition: glext.h:4101
mrpt::graphs::TNodeID to
Ending node of the hypothesis.
Definition: THypothesis.h:89
void setEdge(const constraint_t &edge)
Setter method for the underlying edge.
uint64_t TNodeID
A generic numeric type for unique IDs of nodes or entities.
Definition: TNodeID.h:16
size_t id
ID of the current hypothesis.
Definition: THypothesis.h:85
An edge hypothesis between two nodeIDs.
Definition: THypothesis.h:33
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: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020