Main MRPT website > C++ reference for MRPT 1.9.9
CEdgeCounter.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 
10 #ifndef CEDGECOUNTER_H
11 #define CEDGECOUNTER_H
12 
14 
15 #include "CWindowManager.h"
16 
17 #include <string>
18 #include <map>
19 
20 namespace mrpt
21 {
22 namespace graphslam
23 {
24 namespace detail
25 {
26 /**\brief Generic class for tracking the total number of edges for different
27  * tpes of edges and for storing visualization-related information for each
28  * type
29  *
30  * \ingroup mrpt_graphslam_grp
31  */
33 {
34  public:
37 
38  /**\brief Constructor class
39  */
40  CEdgeCounter();
41  /**\brief Destructor class
42  */
43  ~CEdgeCounter();
44  /**\brief Provide the instance with a CWindowManager.
45  */
47  /**\brief State how many of the existing edges have been removed.
48  *
49  * Method is to be called after CNetworkOfPoses::collapseDuplicatedEdges
50  * method has been executed.
51  */
52  void setRemovedEdges(int removed_edges);
53  /**\brief Method for manually setting the number of loop closures
54  * registered so far.
55  */
56  void setLoopClosureEdgesManually(int num_loop_closures);
57  /**\brief Returns the edges that form loop closures in the current graph.
58  */
59  int getLoopClosureEdges() const;
60  /**\brief Return the total amount of registered edges.
61  * \sa getNumForEdgeType, getLoopClosureEdges
62  */
63  int getTotalNumOfEdges() const;
64  /**\brief Return the total amount of registered edges.
65  *
66  * \sa getNumForEdgeType, getLoopClosureEdges
67  */
68  void getTotalNumOfEdges(int* total_num_edges) const;
69  /**\brief Return the number of edges for the specified type.
70  *
71  * \exception std::exception If edge is not found
72  * \sa getTotalNumOfEdges
73  */
74  int getNumForEdgeType(const std::string& name) const;
75  /** Return the number of edges for the specified type.
76  *
77  * \exception std::exception If edge is not found
78  * \sa getTotalNumOfEdges
79  */
80  void getNumForEdgeType(const std::string& name, int* total_num);
81  /**\brief Set number of a specific edge type manually.
82  *
83  * Handy for not having to call addEdge multiple times in a row.
84  *
85  * \sa addEdge
86  */
87  void setEdgesManually(const std::string& name, int num_of_edges);
88  /**\brief Increment the number of edges for the specified type.
89  *
90  * \exception std::exception If edge exists and \b is_new is True
91  *
92  * \sa setEdgesManually
93  */
94  void addEdge(
95  const std::string& name, bool is_loop_closure = false,
96  bool is_new = false);
97  /**\brief Explicitly register a new edge type.
98  */
99  void addEdgeType(const std::string& name);
100  /**\brief Reset the state of the CEdgeCounter instance.
101  */
102  void clearAllEdges();
103  /**\brief Dump a report of the registered, so far, edges to the console.
104  *
105  * \sa getAsString
106  */
107  void dumpToConsole() const;
108  /**\brief Fill the provided string with a detailed report of the
109  * registered, so far, edges.
110  */
111  void getAsString(std::string* str_out) const;
112  /**\brief Return a detailed report of the registered, so far, edges in a
113  * string representation.
114  */
115  std::string getAsString() const;
116 
117  // VISUALIZATION RELATED METHODS
118  // ////////////////////////////
119 
120  /**\brief Add the textMessage parameters to the object
121  * All the names in the given std::maps have to be already
122  * specified and added in the object via addEdge with is_new=true or
123  * addEdgeType
124  *
125  * \exception std::exception If a name in the provided std::map doesn't
126  * already exist
127  */
129  const std::map<std::string, double>& name_to_offset_y,
130  const std::map<std::string, int>& name_to_text_index);
131 
132  /**\brief Handle the extra visualization parameters for the total number of
133  * edges and for loop closures and then passes execution to the other
134  * setTextMessageParams function.
135  */
137  const std::map<std::string, double>& name_to_offset_y,
138  const std::map<std::string, int>& name_to_text_index,
139  const double& offset_y_total_edges, const int& text_index_total_edges,
140  const double& offset_y_loop_closures,
141  const int& text_index_loop_closures);
142 
143  /**\brief Instance Iterators */
144  inline iterator begin() { return m_name_to_edges_num.begin(); }
145  inline const_iterator cbegin() const { return m_name_to_edges_num.cbegin(); }
146  inline iterator end() { return m_name_to_edges_num.end(); }
147  inline const_iterator cend() const { return m_name_to_edges_num.cend(); }
148  private:
149  /**\brief Initialization method to be called from the various Constructors.
150  */
151  void initCEdgeCounter();
152  /**\brief Update the given CDisplayWindow3D with the edges registered so
153  * far.
154  */
155  void updateTextMessages() const;
156 
159 
160  /**\brief Map edge name <=> num of edges
161  *
162  * Tracking number of edges
163  */
164  std::map<std::string, int> m_name_to_edges_num;
167 
168  // visualization std::maps
169  std::map<std::string, double> m_name_to_offset_y;
170  std::map<std::string, int> m_name_to_text_index;
171 
173 
174  // specifics to loop closures, total edges
176  m_display_loop_closures; // whether to show them at all
179 };
180 }
181 }
182 } // END OF NAMESPACES
183 
184 #endif /* end of include guard: CEDGECOUNTER_H */
Scalar * iterator
Definition: eigen_plugins.h:26
int getNumForEdgeType(const std::string &name) const
Return the number of edges for the specified type.
void addEdgeType(const std::string &name)
Explicitly register a new edge type.
iterator begin()
Instance Iterators.
Definition: CEdgeCounter.h:144
mrpt::gui::CDisplayWindow3D * m_win
Definition: CEdgeCounter.h:157
std::map< std::string, int >::const_iterator const_iterator
Definition: CEdgeCounter.h:36
std::map< std::string, double > m_name_to_offset_y
Definition: CEdgeCounter.h:169
mrpt::graphslam::CWindowManager * m_win_manager
Definition: CEdgeCounter.h:158
void setLoopClosureEdgesManually(int num_loop_closures)
Method for manually setting the number of loop closures registered so far.
int getLoopClosureEdges() const
Returns the edges that form loop closures in the current graph.
void setRemovedEdges(int removed_edges)
State how many of the existing edges have been removed.
void setWindowManagerPtr(mrpt::graphslam::CWindowManager *win_manager)
Provide the instance with a CWindowManager.
Generic class for tracking the total number of edges for different tpes of edges and for storing visu...
Definition: CEdgeCounter.h:32
int getTotalNumOfEdges() const
Return the total amount of registered edges.
GLsizei const GLchar ** string
Definition: glext.h:4101
void clearAllEdges()
Reset the state of the CEdgeCounter instance.
std::map< std::string, int > m_name_to_edges_num
Map edge name <=> num of edges.
Definition: CEdgeCounter.h:164
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
std::map< std::string, int > m_name_to_text_index
Definition: CEdgeCounter.h:170
void dumpToConsole() const
Dump a report of the registered, so far, edges to the console.
void setTextMessageParams(const std::map< std::string, double > &name_to_offset_y, const std::map< std::string, int > &name_to_text_index)
Add the textMessage parameters to the object All the names in the given std::maps have to be already ...
void setEdgesManually(const std::string &name, int num_of_edges)
Set number of a specific edge type manually.
void initCEdgeCounter()
Initialization method to be called from the various Constructors.
GLuint const GLchar * name
Definition: glext.h:4054
void updateTextMessages() const
Update the given CDisplayWindow3D with the edges registered so far.
std::string getAsString() const
Return a detailed report of the registered, so far, edges in a string representation.
void addEdge(const std::string &name, bool is_loop_closure=false, bool is_new=false)
Increment the number of edges for the specified type.
std::map< std::string, int >::iterator iterator
Definition: CEdgeCounter.h:35
const Scalar * const_iterator
Definition: eigen_plugins.h:27
Class acts as a container for storing pointers to mrpt::gui::CDisplayWindow3D, mrpt::graphslam::CWind...
A graphical user interface (GUI) for efficiently rendering 3D scenes in real-time.



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at lun oct 28 00:14:14 CET 2019