9 #ifndef opengl_graph_tools_impl_H
10 #define opengl_graph_tools_impl_H
25 template<
class GRAPH_T>
37 typedef typename GRAPH_T::constraint_t constraint_t;
39 const bool is_3D_graph = constraint_t::is_3D();
45 const bool show_ID_labels = 0!=extra_params.
getWithDefaultVal(
"show_ID_labels", 0);
46 const bool show_ground_grid = 0!=extra_params.
getWithDefaultVal(
"show_ground_grid", 1);
48 const bool show_node_corners = 0!=extra_params.
getWithDefaultVal(
"show_node_corners", 1);
49 const bool show_edge_rel_poses = 0!=extra_params.
getWithDefaultVal(
"show_edge_rel_poses", 0);
50 const double nodes_point_size = extra_params.
getWithDefaultVal(
"nodes_point_size", 0.);
51 const double nodes_corner_scale = extra_params.
getWithDefaultVal(
"nodes_corner_scale", 0.7);
52 const double nodes_edges_corner_scale = extra_params.
getWithDefaultVal(
"nodes_edges_corner_scale", 0.4);
53 const unsigned int nodes_point_color = extra_params.
getWithDefaultVal(
"nodes_point_color", (
unsigned int)0xA0A0A0);
54 const unsigned int edge_color = extra_params.
getWithDefaultVal(
"edge_color", (
unsigned int)0x400000FF);
55 const unsigned int edge_rel_poses_color = extra_params.
getWithDefaultVal(
"edge_rel_poses_color", (
unsigned int)0x40FF8000);
58 if (show_ground_grid) {
63 itNod =
g.nodes.begin();
66 const CPose3D
p = CPose3D(itNod->second);
78 const double grid_frequency = 5.0;
79 CGridPlaneXYPtr grid =
CGridPlaneXY::Create(BB_min.x, BB_max.
x, BB_min.y, BB_max.
y, BB_min.z, grid_frequency);
80 grid->setColor(0.3,0.3,0.3);
85 if (nodes_point_size>0) {
88 pnts->setPointSize(nodes_point_size);
92 itNod =
g.nodes.begin();
96 const CPose3D
p = CPose3D(itNod->second);
97 pnts->insertPoint(
p.x(),
p.y(),
p.z());
101 pnts->enablePointSmooth();
107 if (show_node_corners || show_ID_labels) {
109 itNod =
g.nodes.begin();
110 itNod!=
g.nodes.end();
112 const CPose3D
p = CPose3D(itNod->second);
113 CSetOfObjectsPtr gl_corner = show_node_corners ?
118 gl_corner->setPose(
p);
121 gl_corner->setName(
format(
"%u",
static_cast<unsigned int>(itNod->first)));
122 gl_corner->enableShowName();
124 ret->insert(gl_corner);
128 if (show_edge_rel_poses) {
129 const TColor col8bit(edge_rel_poses_color& 0xffffff, edge_rel_poses_color >> 24);
136 g.edges_store_inverse_poses ? itEd->first.second : itEd->first.first;
140 if (itNod!=
g.nodes.end()) {
141 const CPose3D pSource = CPose3D(itNod->second);
144 gl_rel_edge->setPose(pSource);
146 const typename GRAPH_T::constraint_no_pdf_t & edge_pose = itEd->second.getPoseMean();
149 mrpt::opengl::CSetOfObjectsPtr gl_edge_corner =
154 gl_edge_corner->setPose(edge_pose);
155 gl_rel_edge->insert(gl_edge_corner);
157 mrpt::opengl::CSimpleLinePtr gl_line =
159 gl_line->setColor_u8(col8bit);
160 gl_line->setLineWidth(edge_width);
161 gl_rel_edge->insert(gl_line);
163 ret->insert(gl_rel_edge);
170 const TColor col8bit(edge_color & 0xffffff, edge_color >> 24);
172 gl_edges->setColor_u8(col8bit);
173 gl_edges->setLineWidth(edge_width);
179 const TNodeID id1 = itEd->first.first;
180 const TNodeID id2 = itEd->first.second;
185 if (itNod1!=
g.nodes.end() && itNod2!=
g.nodes.end()) {
186 const CPose3D p1 = CPose3D(itNod1->second);
187 const CPose3D p2 = CPose3D(itNod2->second);
191 ret->insert(gl_edges);
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.
const Scalar * const_iterator
CSetOfObjectsPtr 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.
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).
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.
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...