9 #ifndef opengl_graph_tools_impl_H
10 #define opengl_graph_tools_impl_H
25 template<
class GRAPH_T>
38 typedef typename GRAPH_T::constraint_t constraint_t;
40 const bool is_3D_graph = constraint_t::is_3D();
44 const bool show_ID_labels = 0!=extra_params.
getWithDefaultVal(
"show_ID_labels", 0);
45 const bool show_ground_grid = 0!=extra_params.
getWithDefaultVal(
"show_ground_grid", 1);
47 const bool show_node_corners = 0!=extra_params.
getWithDefaultVal(
"show_node_corners", 1);
48 const bool show_edge_rel_poses = 0!=extra_params.
getWithDefaultVal(
"show_edge_rel_poses", 0);
49 const double nodes_point_size = extra_params.
getWithDefaultVal(
"nodes_point_size", 0. );
50 const double nodes_corner_scale = extra_params.
getWithDefaultVal(
"nodes_corner_scale", 0.7 );
51 const double nodes_edges_corner_scale = extra_params.
getWithDefaultVal(
"nodes_edges_corner_scale", 0.4 );
52 const unsigned int nodes_point_color = extra_params.
getWithDefaultVal(
"nodes_point_color", (
unsigned int)0xA0A0A0 );
53 const unsigned int edge_color = extra_params.
getWithDefaultVal(
"edge_color", (
unsigned int)0x400000FF );
54 const unsigned int edge_rel_poses_color = extra_params.
getWithDefaultVal(
"edge_rel_poses_color", (
unsigned int)0x40FF8000 );
60 TPoint3D BB_min(-10.,-10.,0.), BB_max(10.,10.,0.);
76 const double grid_frequency = 5.0;
77 CGridPlaneXYPtr grid =
CGridPlaneXY::Create(BB_min.x, BB_max.
x, BB_min.y, BB_max.
y, BB_min.z, grid_frequency);
78 grid->setColor(0.3,0.3,0.3);
83 if (nodes_point_size!=0)
89 pnts->setPointSize(nodes_point_size);
95 pnts->insertPoint(p.
x(),p.
y(), p.z() );
98 pnts->enablePointSmooth();
104 if (show_node_corners || show_ID_labels)
109 CSetOfObjectsPtr gl_corner = show_node_corners ?
112 gl_corner->setPose( p );
115 gl_corner->setName(
format(
"%u",static_cast<unsigned int>(itNod->first) ));
116 gl_corner->enableShowName();
118 ret->insert( gl_corner );
122 if (show_edge_rel_poses)
124 const TColor col8bit(edge_rel_poses_color & 0xffffff, edge_rel_poses_color >> 24);
129 const TNodeID node_id_start = g.edges_store_inverse_poses ? itEd->first.second : itEd->first.first;
133 if (itNod!=g.nodes.end())
138 gl_rel_edge->setPose(pSource);
140 const typename GRAPH_T::constraint_no_pdf_t & edge_pose = itEd->second.getPoseMean();
143 mrpt::opengl::CSetOfObjectsPtr gl_edge_corner =
146 gl_edge_corner->setPose(edge_pose);
147 gl_rel_edge->insert(gl_edge_corner);
150 gl_line->setColor_u8( col8bit );
151 gl_line->setLineWidth(edge_width);
152 gl_rel_edge->insert(gl_line);
154 ret->insert( gl_rel_edge );
162 const TColor col8bit(edge_color & 0xffffff, edge_color >> 24);
164 gl_edges->setColor_u8( col8bit );
165 gl_edges->setLineWidth( edge_width );
169 const TNodeID id1 = itEd->first.first;
170 const TNodeID id2 = itEd->first.second;
175 if (itNod1!=g.nodes.end() && itNod2!=g.nodes.end())
182 ret->insert( gl_edges );
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...
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...
std::string BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
uint64_t TNodeID
The type for node IDs in graphs of different types.
const Scalar * const_iterator
double z
X,Y,Z coordinates.
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...
static CSetOfLinesPtr Create()
double x() const
Common members of all points & poses classes.
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...
A class used to store a 3D point.
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...
static CGridPlaneXYPtr Create()
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
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...
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
static CSimpleLinePtr Create()
Lightweight 3D pose (three spatial coordinates, plus three angular coordinates).
A RGB color - floats in the range [0,1].
static CPointCloudPtr Create()
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...
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).
static CSetOfObjectsPtr Create()