MRPT  2.0.3
CEdgeCounter.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #pragma once
11 
13 
14 #include "CWindowManager.h"
15 
16 #include <map>
17 #include <string>
18 
20 {
21 /**\brief Generic class for tracking the total number of edges for different
22  * tpes of edges and for storing visualization-related information for each
23  * type
24  *
25  * \ingroup mrpt_graphslam_grp
26  */
28 {
29  public:
30  using iterator = std::map<std::string, int>::iterator;
31  using const_iterator = std::map<std::string, int>::const_iterator;
32 
33  CEdgeCounter();
34  ~CEdgeCounter() = default;
35  /**\brief Provide the instance with a CWindowManager.
36  */
38  /**\brief State how many of the existing edges have been removed.
39  *
40  * Method is to be called after CNetworkOfPoses::collapseDuplicatedEdges
41  * method has been executed.
42  */
43  void setRemovedEdges(int removed_edges);
44  /**\brief Method for manually setting the number of loop closures
45  * registered so far.
46  */
47  void setLoopClosureEdgesManually(int num_loop_closures);
48  /**\brief Returns the edges that form loop closures in the current graph.
49  */
50  int getLoopClosureEdges() const;
51  /**\brief Return the total amount of registered edges.
52  * \sa getNumForEdgeType, getLoopClosureEdges
53  */
54  int getTotalNumOfEdges() const;
55  /**\brief Return the total amount of registered edges.
56  *
57  * \sa getNumForEdgeType, getLoopClosureEdges
58  */
59  void getTotalNumOfEdges(int* total_num_edges) const;
60  /**\brief Return the number of edges for the specified type.
61  *
62  * \exception std::exception If edge is not found
63  * \sa getTotalNumOfEdges
64  */
65  int getNumForEdgeType(const std::string& name) const;
66  /** Return the number of edges for the specified type.
67  *
68  * \exception std::exception If edge is not found
69  * \sa getTotalNumOfEdges
70  */
71  void getNumForEdgeType(const std::string& name, int* total_num);
72  /**\brief Set number of a specific edge type manually.
73  *
74  * Handy for not having to call addEdge multiple times in a row.
75  *
76  * \sa addEdge
77  */
78  void setEdgesManually(const std::string& name, int num_of_edges);
79  /**\brief Increment the number of edges for the specified type.
80  *
81  * \exception std::exception If edge exists and \b is_new is True
82  *
83  * \sa setEdgesManually
84  */
85  void addEdge(
86  const std::string& name, bool is_loop_closure = false,
87  bool is_new = false);
88  /**\brief Explicitly register a new edge type.
89  */
90  void addEdgeType(const std::string& name);
91  /**\brief Reset the state of the CEdgeCounter instance.
92  */
93  void clearAllEdges();
94  /**\brief Dump a report of the registered, so far, edges to the console.
95  *
96  * \sa getAsString
97  */
98  void dumpToConsole() const;
99  /**\brief Fill the provided string with a detailed report of the
100  * registered, so far, edges.
101  */
102  void getAsString(std::string* str_out) const;
103  /**\brief Return a detailed report of the registered, so far, edges in a
104  * string representation.
105  */
106  std::string getAsString() const;
107 
108  // VISUALIZATION RELATED METHODS
109  // ////////////////////////////
110 
111  /**\brief Add the textMessage parameters to the object
112  * All the names in the given std::maps have to be already
113  * specified and added in the object via addEdge with is_new=true or
114  * addEdgeType
115  *
116  * \exception std::exception If a name in the provided std::map doesn't
117  * already exist
118  */
120  const std::map<std::string, double>& name_to_offset_y,
121  const std::map<std::string, int>& name_to_text_index);
122 
123  /**\brief Handle the extra visualization parameters for the total number of
124  * edges and for loop closures and then passes execution to the other
125  * setTextMessageParams function.
126  */
128  const std::map<std::string, double>& name_to_offset_y,
129  const std::map<std::string, int>& name_to_text_index,
130  double offset_y_total_edges, int text_index_total_edges,
131  double offset_y_loop_closures, int text_index_loop_closures);
132 
133  /**\brief Instance Iterators */
134  inline iterator begin() { return m_name_to_edges_num.begin(); }
135  inline const_iterator cbegin() const
136  {
137  return m_name_to_edges_num.cbegin();
138  }
139  inline iterator end() { return m_name_to_edges_num.end(); }
140  inline const_iterator cend() const { return m_name_to_edges_num.cend(); }
141 
142  private:
143  /**\brief Update the given CDisplayWindow3D with the edges registered so
144  * far.
145  */
146  void updateTextMessages() const;
147 
150 
151  /**\brief Map edge name <=> num of edges
152  *
153  * Tracking number of edges
154  */
155  std::map<std::string, int> m_name_to_edges_num;
157  int m_unique_edges = 0;
158 
159  // visualization std::maps
160  std::map<std::string, double> m_name_to_offset_y;
161  std::map<std::string, int> m_name_to_text_index;
162 
164 
165  // specifics to loop closures, total edges
166  bool m_display_total_edges = false;
172 };
173 } // namespace mrpt::graphslam::detail
CWindowManager.h
mrpt::graphslam::detail::CEdgeCounter::CEdgeCounter
CEdgeCounter()
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:161
mrpt::graphslam::detail::CEdgeCounter::cbegin
const_iterator cbegin() const
Definition: CEdgeCounter.h:135
mrpt::graphslam::detail::CEdgeCounter::dumpToConsole
void dumpToConsole() const
Dump a report of the registered, so far, edges to the console.
Definition: CEdgeCounter.cpp:191
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:221
mrpt::graphslam::detail::CEdgeCounter::m_text_index_loop_closures
int m_text_index_loop_closures
Definition: CEdgeCounter.h:171
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:155
mrpt::graphslam::detail::CEdgeCounter::cend
const_iterator cend() const
Definition: CEdgeCounter.h:140
mrpt::graphslam::detail::CEdgeCounter::m_has_read_textmessage_params
bool m_has_read_textmessage_params
Definition: CEdgeCounter.h:163
CDisplayWindow3D.h
mrpt::graphslam::CWindowManager
Class acts as a container for storing pointers to mrpt::gui::CDisplayWindow3D, mrpt::graphslam::CWind...
Definition: CWindowManager.h:27
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:107
mrpt::graphslam::detail::CEdgeCounter::updateTextMessages
void updateTextMessages() const
Update the given CDisplayWindow3D with the edges registered so far.
Definition: CEdgeCounter.cpp:286
mrpt::graphslam::detail::CEdgeCounter::m_offset_y_total_edges
int m_offset_y_total_edges
Definition: CEdgeCounter.h:168
mrpt::graphslam::detail::CEdgeCounter::m_text_index_total_edges
int m_text_index_total_edges
Definition: CEdgeCounter.h:170
mrpt::graphslam::detail::CEdgeCounter::m_name_to_offset_y
std::map< std::string, double > m_name_to_offset_y
Definition: CEdgeCounter.h:160
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:87
mrpt::graphslam::detail::CEdgeCounter::m_unique_edges
int m_unique_edges
Definition: CEdgeCounter.h:157
mrpt::graphslam::detail::CEdgeCounter::m_display_total_edges
bool m_display_total_edges
Definition: CEdgeCounter.h:166
mrpt::graphslam::detail::CEdgeCounter::m_display_loop_closures
bool m_display_loop_closures
Definition: CEdgeCounter.h:167
mrpt::graphslam::detail::CEdgeCounter::iterator
std::map< std::string, int >::iterator iterator
Definition: CEdgeCounter.h:30
mrpt::graphslam::detail::CEdgeCounter::end
iterator end()
Definition: CEdgeCounter.h:139
mrpt::graphslam::detail::CEdgeCounter::getNumForEdgeType
int getNumForEdgeType(const std::string &name) const
Return the number of edges for the specified type.
Definition: CEdgeCounter.cpp:61
mrpt::graphslam::detail::CEdgeCounter::m_num_loop_closures
int m_num_loop_closures
Definition: CEdgeCounter.h:156
mrpt::graphslam::detail::CEdgeCounter::begin
iterator begin()
Instance Iterators.
Definition: CEdgeCounter.h:134
mrpt::graphslam::detail::CEdgeCounter::getLoopClosureEdges
int getLoopClosureEdges() const
Returns the edges that form loop closures in the current graph.
Definition: CEdgeCounter.cpp:40
mrpt::graphslam::detail::CEdgeCounter::const_iterator
std::map< std::string, int >::const_iterator const_iterator
Definition: CEdgeCounter.h:31
mrpt::graphslam::detail::CEdgeCounter::m_win
mrpt::gui::CDisplayWindow3D * m_win
Definition: CEdgeCounter.h:148
mrpt::graphslam::detail
Internal auxiliary classes.
Definition: levmarq_impl.h:19
mrpt::graphslam::detail::CEdgeCounter::addEdgeType
void addEdgeType(const std::string &name)
Explicitly register a new edge type.
Definition: CEdgeCounter.cpp:163
mrpt::graphslam::detail::CEdgeCounter::m_offset_y_loop_closures
int m_offset_y_loop_closures
Definition: CEdgeCounter.h:169
mrpt::graphslam::detail::CEdgeCounter::getTotalNumOfEdges
int getTotalNumOfEdges() const
Return the total amount of registered edges.
Definition: CEdgeCounter.cpp:41
mrpt::graphslam::detail::CEdgeCounter::~CEdgeCounter
~CEdgeCounter()=default
mrpt::graphslam::detail::CEdgeCounter::setRemovedEdges
void setRemovedEdges(int removed_edges)
State how many of the existing edges have been removed.
Definition: CEdgeCounter.cpp:30
mrpt::graphslam::detail::CEdgeCounter::setWindowManagerPtr
void setWindowManagerPtr(mrpt::graphslam::CWindowManager *win_manager)
Provide the instance with a CWindowManager.
Definition: CEdgeCounter.cpp:17
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:35
mrpt::graphslam::detail::CEdgeCounter::m_win_manager
mrpt::graphslam::CWindowManager * m_win_manager
Definition: CEdgeCounter.h:149
mrpt::graphslam::detail::CEdgeCounter::clearAllEdges
void clearAllEdges()
Reset the state of the CEdgeCounter instance.
Definition: CEdgeCounter.cpp:178
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:231
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:27



Page generated by Doxygen 1.8.17 for MRPT 2.0.3 at Fri May 29 13:06:46 UTC 2020