MRPT  1.9.9
THypothesis_impl.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2019, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #pragma once
10 
11 // implementation file for the THypothesis struct template
12 
13 namespace mrpt::graphs::detail
14 {
15 template <class GRAPH_T>
17 
18 template <class GRAPH_T>
20 
21 template <class GRAPH_T>
22 std::string THypothesis<GRAPH_T>::getAsString(bool oneline /*=true*/) const
23 {
24  std::string str;
25  this->getAsString(&str, oneline);
26  return str;
27 }
28 
29 template <class GRAPH_T>
31  std::string* str, bool oneline /*=true*/) const
32 {
33  ASSERTMSG_(str, "Given string pointer is not valid");
34 
35  using namespace std;
36 
37  stringstream ss;
38  if (!oneline)
39  { // multiline report
40  ss << "Hypothesis #" << id << endl;
41  ss << from << " => " << to << endl;
42  ss << edge << endl;
43  }
44  else
45  {
46  ss << "Hypothesis #" << id << "| ";
47  ss << from << " => " << to << "| ";
48  ss << edge.getMeanVal().asString();
49  ss << "|goodness: " << goodness;
50  ss << "|valid: " << is_valid;
51  }
52 
53  *str = ss.str();
54 }
55 
56 // TODO - test these
57 template <class GRAPH_T>
59 {
60  return (this->from == other.from && this->to == other.to);
61 }
62 
63 template <class GRAPH_T>
65  mrpt::graphs::TNodeID from_in, mrpt::graphs::TNodeID to_in) const
66 {
67  return (this->from == from_in && this->to == to_in);
68 }
69 
70 template <class GRAPH_T>
72 {
73  ASSERT_(out_edge);
74  out_edge->copyFrom(edge);
75 }
76 
77 template <class GRAPH_T>
78 typename GRAPH_T::constraint_t THypothesis<GRAPH_T>::getEdge() const
79 {
80  return this->edge;
81 }
82 
83 template <class GRAPH_T>
85 {
86  edge.copyFrom(in_edge);
87 }
88 
89 template <class GRAPH_T>
91 {
92  ASSERT_(out_edge);
93  edge.inverse(*out_edge);
94 }
95 
96 template <class GRAPH_T>
97 typename GRAPH_T::constraint_t THypothesis<GRAPH_T>::getInverseEdge() const
98 {
99  constraint_t inverse_edge;
100  this->getInverseEdge(&inverse_edge);
101 
102  return inverse_edge;
103 }
104 
105 template <class GRAPH_T>
107 {
108  // inverse the start/end nodes
109  mrpt::graphs::TNodeID tmp = from;
110  from = to;
111  to = tmp;
112 
113  // inverse the edge
114  constraint_t edge_tmp = this->getInverseEdge();
115  this->edge.copyFrom(edge_tmp);
116 }
117 
118 template <class GRAPH_T>
119 bool THypothesis<GRAPH_T>::operator<(const self_t& other) const
120 {
121  return this->id < other.id;
122 }
123 } // namespace mrpt::graphs::detail
void inverseHypothesis()
Reverse the hypothesis.
STL namespace.
typename GRAPH_T::constraint_t constraint_t
Handy typedefs.
Definition: THypothesis.h:37
#define ASSERT_(f)
Defines an assertion mechanism.
Definition: exceptions.h:120
Internal functions for MRPT.
mrpt::graphs::TNodeID from
Starting node of the hypothesis.
Definition: THypothesis.h:86
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:108
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:4116
mrpt::graphs::TNodeID to
Ending node of the hypothesis.
Definition: THypothesis.h:88
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
constraint_t getInverseEdge() const
size_t id
ID of the current hypothesis.
Definition: THypothesis.h:84
An edge hypothesis between two nodeIDs.
Definition: THypothesis.h:32
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: 0cbd40372 Sun Nov 17 09:43:05 2019 +0100 at dom nov 17 09:45:09 CET 2019