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 */
const_iterator
const Scalar * const_iterator
Definition: eigen_plugins.h:27
CWindowManager.h
mrpt::graphslam::detail::CEdgeCounter::CEdgeCounter
CEdgeCounter()
Constructor class.
Definition: CEdgeCounter.cpp:16
mrpt::graphslam::detail::CEdgeCounter::m_name_to_text_index
std::map< std::string, int > m_name_to_text_index
Definition: CEdgeCounter.h:170
mrpt::graphslam::detail::CEdgeCounter::cbegin
const_iterator cbegin() const
Definition: CEdgeCounter.h:145
mrpt::graphslam::detail::CEdgeCounter::dumpToConsole
void dumpToConsole() const
Dump a report of the registered, so far, edges to the console.
Definition: CEdgeCounter.cpp:221
mrpt::graphslam::detail::CEdgeCounter::getAsString
std::string getAsString() const
Return a detailed report of the registered, so far, edges in a string representation.
Definition: CEdgeCounter.cpp:253
mrpt::graphslam::detail::CEdgeCounter::m_text_index_loop_closures
int m_text_index_loop_closures
Definition: CEdgeCounter.h:178
mrpt::graphslam::detail::CEdgeCounter::m_name_to_edges_num
std::map< std::string, int > m_name_to_edges_num
Map edge name <=> num of edges.
Definition: CEdgeCounter.h:164
mrpt::graphslam::detail::CEdgeCounter::cend
const_iterator cend() const
Definition: CEdgeCounter.h:147
mrpt::graphslam::detail::CEdgeCounter::m_has_read_textmessage_params
bool m_has_read_textmessage_params
Definition: CEdgeCounter.h:172
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
CDisplayWindow3D.h
mrpt::graphslam::CWindowManager
Class acts as a container for storing pointers to mrpt::gui::CDisplayWindow3D, mrpt::graphslam::CWind...
Definition: CWindowManager.h:30
mrpt::graphslam::detail::CEdgeCounter::addEdge
void addEdge(const std::string &name, bool is_loop_closure=false, bool is_new=false)
Increment the number of edges for the specified type.
Definition: CEdgeCounter.cpp:134
name
GLuint const GLchar * name
Definition: glext.h:4054
mrpt::graphslam::detail::CEdgeCounter::updateTextMessages
void updateTextMessages() const
Update the given CDisplayWindow3D with the edges registered so far.
Definition: CEdgeCounter.cpp:321
mrpt::graphslam::detail::CEdgeCounter::m_offset_y_total_edges
int m_offset_y_total_edges
Definition: CEdgeCounter.h:177
mrpt::graphslam::detail::CEdgeCounter::m_text_index_total_edges
int m_text_index_total_edges
Definition: CEdgeCounter.h:178
mrpt::graphslam::detail::CEdgeCounter::m_name_to_offset_y
std::map< std::string, double > m_name_to_offset_y
Definition: CEdgeCounter.h:169
mrpt::graphslam::detail::CEdgeCounter::initCEdgeCounter
void initCEdgeCounter()
Initialization method to be called from the various Constructors.
Definition: CEdgeCounter.cpp:18
mrpt::graphslam::detail::CEdgeCounter::setEdgesManually
void setEdgesManually(const std::string &name, int num_of_edges)
Set number of a specific edge type manually.
Definition: CEdgeCounter.cpp:113
mrpt::graphslam::detail::CEdgeCounter::m_unique_edges
int m_unique_edges
Definition: CEdgeCounter.h:166
mrpt::graphslam::detail::CEdgeCounter::m_display_total_edges
bool m_display_total_edges
Definition: CEdgeCounter.h:175
mrpt::graphslam::detail::CEdgeCounter::m_display_loop_closures
bool m_display_loop_closures
Definition: CEdgeCounter.h:176
mrpt::graphslam::detail::CEdgeCounter::iterator
std::map< std::string, int >::iterator iterator
Definition: CEdgeCounter.h:35
mrpt::graphslam::detail::CEdgeCounter::end
iterator end()
Definition: CEdgeCounter.h:146
mrpt::graphslam::detail::CEdgeCounter::getNumForEdgeType
int getNumForEdgeType(const std::string &name) const
Return the number of edges for the specified type.
Definition: CEdgeCounter.cpp:85
mrpt::graphslam::detail::CEdgeCounter::m_num_loop_closures
int m_num_loop_closures
Definition: CEdgeCounter.h:165
mrpt::graphslam::detail::CEdgeCounter::begin
iterator begin()
Instance Iterators.
Definition: CEdgeCounter.h:144
mrpt::graphslam::detail::CEdgeCounter::getLoopClosureEdges
int getLoopClosureEdges() const
Returns the edges that form loop closures in the current graph.
Definition: CEdgeCounter.cpp:62
mrpt::graphslam::detail::CEdgeCounter::const_iterator
std::map< std::string, int >::const_iterator const_iterator
Definition: CEdgeCounter.h:36
mrpt::graphslam::detail::CEdgeCounter::m_win
mrpt::gui::CDisplayWindow3D * m_win
Definition: CEdgeCounter.h:157
mrpt::graphslam::detail::CEdgeCounter::addEdgeType
void addEdgeType(const std::string &name)
Explicitly register a new edge type.
Definition: CEdgeCounter.cpp:191
mrpt::graphslam::detail::CEdgeCounter::m_offset_y_loop_closures
int m_offset_y_loop_closures
Definition: CEdgeCounter.h:177
mrpt::graphslam::detail::CEdgeCounter::getTotalNumOfEdges
int getTotalNumOfEdges() const
Return the total amount of registered edges.
Definition: CEdgeCounter.cpp:63
mrpt::graphslam::detail::CEdgeCounter::setRemovedEdges
void setRemovedEdges(int removed_edges)
State how many of the existing edges have been removed.
Definition: CEdgeCounter.cpp:52
mrpt::graphslam::detail::CEdgeCounter::setWindowManagerPtr
void setWindowManagerPtr(mrpt::graphslam::CWindowManager *win_manager)
Provide the instance with a CWindowManager.
Definition: CEdgeCounter.cpp:39
mrpt::graphslam::detail::CEdgeCounter::setLoopClosureEdgesManually
void setLoopClosureEdgesManually(int num_loop_closures)
Method for manually setting the number of loop closures registered so far.
Definition: CEdgeCounter.cpp:57
string
GLsizei const GLchar ** string
Definition: glext.h:4101
mrpt::graphslam::detail::CEdgeCounter::m_win_manager
mrpt::graphslam::CWindowManager * m_win_manager
Definition: CEdgeCounter.h:158
iterator
Scalar * iterator
Definition: eigen_plugins.h:26
mrpt::graphslam::detail::CEdgeCounter::clearAllEdges
void clearAllEdges()
Reset the state of the CEdgeCounter instance.
Definition: CEdgeCounter.cpp:208
mrpt::gui::CDisplayWindow3D
A graphical user interface (GUI) for efficiently rendering 3D scenes in real-time.
Definition: CDisplayWindow3D.h:117
mrpt::graphslam::detail::CEdgeCounter::setTextMessageParams
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 ...
Definition: CEdgeCounter.cpp:263
mrpt::graphslam::detail::CEdgeCounter
Generic class for tracking the total number of edges for different tpes of edges and for storing visu...
Definition: CEdgeCounter.h:32
mrpt::graphslam::detail::CEdgeCounter::~CEdgeCounter
~CEdgeCounter()
Destructor class.
Definition: CEdgeCounter.cpp:17



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST