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