9 #ifndef opengl_graph_tools_impl_H
10 #define opengl_graph_tools_impl_H
25 template <
class GRAPH_T>
36 typedef typename GRAPH_T::constraint_t constraint_t;
38 const bool is_3D_graph = constraint_t::is_3D();
44 const bool show_ID_labels =
46 const bool show_ground_grid =
48 const bool show_edges =
50 const bool show_node_corners =
52 const bool show_edge_rel_poses =
54 const double nodes_point_size =
56 const double nodes_corner_scale =
58 const double nodes_edges_corner_scale =
61 "nodes_point_color", (
unsigned int)0xA0A0A0);
62 const unsigned int edge_color =
65 "edge_rel_poses_color", (
unsigned int)0x40FF8000);
75 itNod !=
g.nodes.end(); ++itNod)
77 const CPose3D
p = CPose3D(
90 const double grid_frequency = 5.0;
92 BB_min.x, BB_max.
x, BB_min.y, BB_max.
y, BB_min.z, grid_frequency);
93 grid->setColor(0.3, 0.3, 0.3);
98 if (nodes_point_size > 0)
102 pnts->setPointSize(nodes_point_size);
107 itNod !=
g.nodes.end(); ++itNod)
109 const CPose3D
p = CPose3D(
111 pnts->insertPoint(
p.x(),
p.y(),
p.z());
114 pnts->enablePointSmooth();
120 if (show_node_corners || show_ID_labels)
124 itNod !=
g.nodes.end(); ++itNod)
126 const CPose3D
p = CPose3D(
132 nodes_corner_scale, 1.0 )
134 nodes_corner_scale, 1.0 ))
135 : mrpt::make_aligned_shared<CSetOfObjects>();
136 gl_corner->setPose(
p);
140 format(
"%u",
static_cast<unsigned int>(itNod->first)));
141 gl_corner->enableShowName();
143 ret->insert(gl_corner);
147 if (show_edge_rel_poses)
150 edge_rel_poses_color & 0xffffff, edge_rel_poses_color >> 24);
156 const TNodeID node_id_start =
g.edges_store_inverse_poses
162 g.nodes.find(node_id_start);
163 if (itNod !=
g.nodes.end())
165 const CPose3D pSource = CPose3D(itNod->second);
169 mrpt::make_aligned_shared<mrpt::opengl::CSetOfObjects>();
170 gl_rel_edge->setPose(pSource);
172 const typename GRAPH_T::constraint_no_pdf_t& edge_pose =
173 itEd->second.getPoseMean();
180 nodes_edges_corner_scale, 1.0 )
182 nodes_edges_corner_scale, 1.0 ));
184 gl_edge_corner->setPose(edge_pose);
185 gl_rel_edge->insert(gl_edge_corner);
188 mrpt::make_aligned_shared<mrpt::opengl::CSimpleLine>(
189 0, 0, 0, edge_pose_pt.
x(), edge_pose_pt.
y(),
191 gl_line->setColor_u8(col8bit);
192 gl_line->setLineWidth(edge_width);
193 gl_rel_edge->insert(gl_line);
195 ret->insert(gl_rel_edge);
203 const TColor col8bit(edge_color & 0xffffff, edge_color >> 24);
205 gl_edges->setColor_u8(col8bit);
206 gl_edges->setLineWidth(edge_width);
211 const TNodeID id1 = itEd->first.first;
212 const TNodeID id2 = itEd->first.second;
219 if (itNod1 !=
g.nodes.end() && itNod2 !=
g.nodes.end())
221 const CPose3D p1 = CPose3D(itNod1->second);
222 const CPose3D p2 = CPose3D(itNod2->second);
223 gl_edges->appendLine(
228 ret->insert(gl_edges);
std::shared_ptr< CGridPlaneXY > Ptr
std::shared_ptr< CPointCloud > Ptr
std::shared_ptr< CSetOfLines > Ptr
std::shared_ptr< CSetOfObjects > Ptr
std::shared_ptr< CSimpleLine > Ptr
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.
const Scalar * const_iterator
CSetOfObjects::Ptr graph_visualize(const GRAPH_T &g, const mrpt::utils::TParametersDouble &extra_params=mrpt::utils::TParametersDouble())
Returns an opengl objects representation of an arbitrary graph, as a network of 3D pose frames.
uint64_t TNodeID
The type for node IDs in graphs of different types.
CSetOfObjects::Ptr CornerXYSimple(float scale=1.0, float lineWidth=1.0)
Returns two arrows representing a X,Y 2D corner (just thick lines, fast to render).
CSetOfObjects::Ptr 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...
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 format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
double x
X,Y,Z coordinates.
Lightweight 3D pose (three spatial coordinates, plus three angular 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...