Main MRPT website > C++ reference for MRPT 1.4.0
CBox.h
Go to the documentation of this file.
1/* +---------------------------------------------------------------------------+
2 | Mobile Robot Programming Toolkit (MRPT) |
3 | http://www.mrpt.org/ |
4 | |
5 | Copyright (c) 2005-2016, Individual contributors, see AUTHORS file |
6 | See: http://www.mrpt.org/Authors - All rights reserved. |
7 | Released under BSD License. See details in http://www.mrpt.org/License |
8 +---------------------------------------------------------------------------+ */
9#ifndef opengl_CBox_H
10#define opengl_CBox_H
11
14
15namespace mrpt {
16namespace opengl {
17
18 // This must be added to any CSerializable derived class:
20
21 /** A solid or wireframe box in 3D, defined by 6 rectangular faces parallel to the planes X, Y and Z (note that the object can be translated and rotated afterwards as any other CRenderizable object using the "object pose" in the base class).
22 * Three drawing modes are possible:
23 * - Wireframe: setWireframe(true). Used color is the CRenderizable color
24 * - Solid box: setWireframe(false). Used color is the CRenderizable color
25 * - Solid box with border: setWireframe(false) + enableBoxBorder(true). Solid color is the CRenderizable color, border line can be set with setBoxBorderColor().
26 *
27 * \sa opengl::COpenGLScene,opengl::CRenderizable
28 *
29 * <div align="center">
30 * <table border="0" cellspan="4" cellspacing="4" style="border-width: 1px; border-style: solid;">
31 * <tr> <td> mrpt::opengl::CBox </td> <td> \image html preview_CBox.png </td> </tr>
32 * </table>
33 * </div>
34 *
35 * \ingroup mrpt_opengl_grp
36 */
39
40 protected:
41 mrpt::math::TPoint3D m_corner_min,m_corner_max; //!< Corners coordinates
42 bool m_wireframe; //!< true: wireframe, false: solid
43 float m_lineWidth; //!< For wireframe only.
44 bool m_draw_border; //!< Draw line borders to solid box with the given linewidth (default: true)
45 mrpt::utils::TColor m_solidborder_color; //!< Color of the solid box borders.
46
47 public:
48 /** Constructor returning a smart pointer to the newly created object. */
49 static CBoxPtr Create(const mrpt::math::TPoint3D &corner1, const mrpt::math::TPoint3D &corner2, bool is_wireframe = false, float lineWidth = 1.0 );
50
51 /** Render
52 * \sa mrpt::opengl::CRenderizable
53 */
55
56 /** Evaluates the bounding box of this object (including possible children) in the coordinate frame of the object parent. */
57 void getBoundingBox(mrpt::math::TPoint3D &bb_min, mrpt::math::TPoint3D &bb_max) const MRPT_OVERRIDE;
58
59 /**
60 * Ray tracing.
61 * \sa mrpt::opengl::CRenderizable
62 */
63 bool traceRay(const mrpt::poses::CPose3D &o,double &dist) const MRPT_OVERRIDE;
64
65 inline void setLineWidth(float width) { m_lineWidth = width; CRenderizableDisplayList::notifyChange(); }
66 inline float getLineWidth() const { return m_lineWidth; }
67
68 inline void setWireframe(bool is_wireframe=true) { m_wireframe = is_wireframe; CRenderizableDisplayList::notifyChange(); }
69 inline bool isWireframe() const { return m_wireframe; }
70
71 inline void enableBoxBorder(bool drawBorder=true) {m_draw_border = drawBorder; CRenderizableDisplayList::notifyChange(); }
72 inline bool isBoxBorderEnabled() const { return m_draw_border; }
73
74 inline void setBoxBorderColor(const mrpt::utils::TColor &c) { m_solidborder_color=c; CRenderizableDisplayList::notifyChange(); }
75 inline mrpt::utils::TColor getBoxBorderColor() const { return m_solidborder_color; }
76
77 /** Set the position and size of the box, from two corners in 3D */
78 void setBoxCorners(const mrpt::math::TPoint3D &corner1, const mrpt::math::TPoint3D &corner2);
79 void getBoxCorners(mrpt::math::TPoint3D &corner1, mrpt::math::TPoint3D &corner2) const { corner1= m_corner_min; corner2 = m_corner_max; }
80
81
82 private:
83 /** Basic empty constructor. Set all parameters to default. */
85
86 /** Constructor with all the parameters */
87 CBox(const mrpt::math::TPoint3D &corner1, const mrpt::math::TPoint3D &corner2, bool is_wireframe = false, float lineWidth = 1.0);
88
89 /** Destructor */
90 virtual ~CBox() { }
91
92 };
94}
95}
96#endif
#define DEFINE_SERIALIZABLE_POST_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
#define DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)
This declaration must be inserted in all CSerializable classes definition, before the class declarati...
A solid or wireframe box in 3D, defined by 6 rectangular faces parallel to the planes X,...
Definition CBox.h:37
bool m_wireframe
true: wireframe, false: solid
Definition CBox.h:42
bool isWireframe() const
Definition CBox.h:69
bool isBoxBorderEnabled() const
Definition CBox.h:72
void setBoxCorners(const mrpt::math::TPoint3D &corner1, const mrpt::math::TPoint3D &corner2)
Set the position and size of the box, from two corners in 3D.
bool m_draw_border
Draw line borders to solid box with the given linewidth (default: true)
Definition CBox.h:44
CBox(const mrpt::math::TPoint3D &corner1, const mrpt::math::TPoint3D &corner2, bool is_wireframe=false, float lineWidth=1.0)
Constructor with all the parameters
mrpt::utils::TColor m_solidborder_color
Color of the solid box borders.
Definition CBox.h:45
float getLineWidth() const
Definition CBox.h:66
mrpt::math::TPoint3D m_corner_max
Corners coordinates.
Definition CBox.h:41
float m_lineWidth
For wireframe only.
Definition CBox.h:43
CBox()
Basic empty constructor.
void setWireframe(bool is_wireframe=true)
Definition CBox.h:68
void enableBoxBorder(bool drawBorder=true)
Definition CBox.h:71
static CBoxPtr Create(const mrpt::math::TPoint3D &corner1, const mrpt::math::TPoint3D &corner2, bool is_wireframe=false, float lineWidth=1.0)
Constructor returning a smart pointer to the newly created object.
void render_dl() const MRPT_OVERRIDE
Render.
mrpt::utils::TColor getBoxBorderColor() const
Definition CBox.h:75
void setBoxBorderColor(const mrpt::utils::TColor &c)
Definition CBox.h:74
void getBoxCorners(mrpt::math::TPoint3D &corner1, mrpt::math::TPoint3D &corner2) const
Definition CBox.h:79
virtual ~CBox()
Destructor
Definition CBox.h:90
A renderizable object suitable for rendering with OpenGL's display lists.
EIGEN_STRONG_INLINE void notifyChange() const
Must be called to notify that the object has changed (so, the display list must be updated)
#define MRPT_OVERRIDE
C++11 "override" for virtuals:
Definition mrpt_macros.h:28
struct OPENGL_IMPEXP CBoxPtr
Definition CBox.h:19
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Lightweight 3D point.
A RGB color - 8bit.
Definition TColor.h:26



Page generated by Doxygen 1.9.7 for MRPT 1.4.0 SVN: at Tue Jun 27 17:12:06 UTC 2023