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