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