1 #ifndef CVISUALIZER_IMPL_H
2 #define CVISUALIZER_IMPL_H
4 namespace mrpt {
namespace graphs {
namespace detail {
8 template<
class CPOSE,
class MAPS_IMPLEMENTATION,
class NODE_ANNOTATIONS,
class EDGE_ANNOTATIONS>
17 template<
class CPOSE,
class MAPS_IMPLEMENTATION,
class NODE_ANNOTATIONS,
class EDGE_ANNOTATIONS>
23 template<
class CPOSE,
class MAPS_IMPLEMENTATION,
class NODE_ANNOTATIONS,
class EDGE_ANNOTATIONS>
26 mrpt::opengl::CSetOfObjectsPtr&
object,
35 "show_ground_grid", 1);
39 "show_node_corners", 1);
41 "show_edge_rel_poses", 0);
43 "nodes_point_size", 0.);
46 if (show_ground_grid) {
47 this->drawGroundGrid(
object, &viz_params);
50 if (nodes_point_size > 0) {
51 this->drawNodePoints(
object, &viz_params);
54 if (show_node_corners || show_ID_labels) {
55 this->drawNodeCorners(
object, &viz_params);
58 if (show_edge_rel_poses) {
59 this->drawEdgeRelPoses(
object, &viz_params);
63 this->drawEdges(
object, &viz_params);
68 template<
class CPOSE,
class MAPS_IMPLEMENTATION,
class NODE_ANNOTATIONS,
class EDGE_ANNOTATIONS>
74 ASSERTMSG_(viz_params,
"Pointer to viz_params was not provided.");
80 n_it = m_graph.nodes.begin();
81 n_it!=m_graph.nodes.end();
95 const double grid_frequency = 5.0;
99 BB_min.z, grid_frequency);
100 grid->setColor(0.3,0.3,0.3);
101 object->insert(grid);
105 template<
class CPOSE,
class MAPS_IMPLEMENTATION,
class NODE_ANNOTATIONS,
class EDGE_ANNOTATIONS>
109 ASSERTMSG_(viz_params,
"Pointer to viz_params was not provided.");
115 "nodes_point_size", 0.);
117 "nodes_point_color", (
unsigned int)0xA0A0A0);
121 pnts->setPointSize(nodes_point_size);
125 n_it = m_graph.nodes.begin();
126 n_it!=m_graph.nodes.end();
130 pnts->insertPoint(
p.x(),
p.y(),
p.z());
134 pnts->enablePointSmooth();
135 object->insert(pnts);
140 template<
class CPOSE,
class MAPS_IMPLEMENTATION,
class NODE_ANNOTATIONS,
class EDGE_ANNOTATIONS>
148 ASSERTMSG_(viz_params,
"Pointer to viz_params was not provided.");
151 "show_node_corners", 1);
153 "show_ID_labels", 0);
155 "nodes_corner_scale", 0.7);
158 n_it = m_graph.nodes.begin();
159 n_it!=m_graph.nodes.end();
164 CSetOfObjectsPtr gl_corner = show_node_corners ?
169 gl_corner->setPose(
p);
170 if (show_ID_labels) {
171 gl_corner->setName(
format(
"%u",
static_cast<unsigned int>(n_it->first)));
172 gl_corner->enableShowName();
174 object->insert(gl_corner);
179 template<
class CPOSE,
class MAPS_IMPLEMENTATION,
class NODE_ANNOTATIONS,
class EDGE_ANNOTATIONS>
185 ASSERTMSG_(viz_params,
"Pointer to viz_params was not provided.");
188 "nodes_edges_corner_scale", 0.4);
190 "edge_rel_poses_color", (
unsigned int)0x40FF8000);
191 const TColor col8bit(edge_rel_poses_color& 0xffffff, edge_rel_poses_color >> 24);
196 edge_it!=m_graph.end();
200 m_graph.edges_store_inverse_poses ? edge_it->first.second : edge_it->first.first;
204 if (n_it!=m_graph.nodes.end()) {
208 gl_rel_edge->setPose(pSource);
213 mrpt::opengl::CSetOfObjectsPtr gl_edge_corner =
218 gl_edge_corner->setPose(edge_pose);
219 gl_rel_edge->insert(gl_edge_corner);
221 mrpt::opengl::CSimpleLinePtr gl_line =
224 edge_pose_pt.
x(), edge_pose_pt.
y(), edge_pose_pt.z());
226 gl_line->setColor_u8(col8bit);
227 gl_line->setLineWidth(edge_width);
228 gl_rel_edge->insert(gl_line);
230 object->insert(gl_rel_edge);
235 template<
class CPOSE,
class MAPS_IMPLEMENTATION,
class NODE_ANNOTATIONS,
class EDGE_ANNOTATIONS>
237 drawEdges(mrpt::opengl::CSetOfObjectsPtr&
object,
241 ASSERTMSG_(viz_params,
"Pointer to viz_params was not provided.");
245 "edge_color", (
unsigned int)0x400000FF);
249 const TColor col8bit(edge_color & 0xffffff, edge_color >> 24);
251 gl_edges->setColor_u8(col8bit);
252 gl_edges->setLineWidth(edge_width);
256 edge_it = m_graph.begin();
257 edge_it!=m_graph.end();
259 const TNodeID id1 = edge_it->first.first;
260 const TNodeID id2 = edge_it->first.second;
265 if (n_it1!=m_graph.nodes.end() && n_it2!=m_graph.nodes.end()) {
268 gl_edges->appendLine(
273 object->insert(gl_edges);
edges_map_t::const_iterator const_iterator
A directed graph of pose constraints, with edges being the relative poses between pairs of nodes iden...
CPOSE::type_value constraint_no_pdf_t
The type of edges or their means if they are PDFs (that is, a simple "edge" value)
CPOSE constraint_t
The type of PDF poses in the contraints (edges) (=CPOSE template argument)
CVisualizer(const GRAPH_T &graph_in)
Constructor.
virtual void drawEdges(mrpt::opengl::CSetOfObjectsPtr &object, const mrpt::utils::TParametersDouble *viz_params=NULL) const
virtual void drawGroundGrid(mrpt::opengl::CSetOfObjectsPtr &object, const mrpt::utils::TParametersDouble *viz_params=NULL) const
virtual void drawNodePoints(mrpt::opengl::CSetOfObjectsPtr &object, const mrpt::utils::TParametersDouble *viz_params=NULL) const
virtual ~CVisualizer()
Destructor.
virtual void drawEdgeRelPoses(mrpt::opengl::CSetOfObjectsPtr &object, const mrpt::utils::TParametersDouble *viz_params=NULL) const
virtual void getAs3DObject(mrpt::opengl::CSetOfObjectsPtr &object, mrpt::utils::TParametersDouble viz_params) const
Common visualization stuff for all derived classes.
virtual void drawNodeCorners(mrpt::opengl::CSetOfObjectsPtr &object, const mrpt::utils::TParametersDouble *viz_params=NULL) const
static CGridPlaneXYPtr Create()
static CPointCloudPtr Create()
static CSetOfLinesPtr Create()
static CSetOfObjectsPtr Create()
static CSimpleLinePtr Create()
A class used to store a 3D point.
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
double x() const
Common members of all points & poses classes.
uint64_t TNodeID
The type for node IDs in graphs of different types.
#define ASSERTMSG_(f, __ERROR_MSG)
CSetOfObjectsPtr OPENGL_IMPEXP CornerXYZSimple(float scale=1.0, float lineWidth=1.0)
Returns three arrows representing a X,Y,Z 3D corner (just thick lines instead of complex arrows for f...
CSetOfObjectsPtr OPENGL_IMPEXP CornerXYSimple(float scale=1.0, float lineWidth=1.0)
Returns two arrows representing a X,Y 2D corner (just thick lines, fast to render).
The namespace for 3D scene representation and rendering.
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values,...
void keep_max(T &var, const K test_val)
If the second argument is above the first one, set the first argument to this higher value.
void keep_min(T &var, const K test_val)
If the second argument is below the first one, set the first argument to this lower value.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
std::string BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
double z
X,Y,Z coordinates.
A RGB color - floats in the range [0,1].
T getWithDefaultVal(const std::string &s, const T &defaultVal) const
A const version of the [] operator and with a default value in case the parameter is not set (for usa...