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 
15 namespace mrpt {
16 namespace opengl {
17 
18  // This must be added to any CSerializable derived class:
19  DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE(CBox,CRenderizableDisplayList, OPENGL_IMPEXP)
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  */
54  void render_dl() const MRPT_OVERRIDE;
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. */
84  CBox();
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  };
93  DEFINE_SERIALIZABLE_POST_CUSTOM_BASE_LINKAGE(CBox,CRenderizableDisplayList, OPENGL_IMPEXP)
94 }
95 }
96 #endif
mrpt::opengl::CBox::enableBoxBorder
void enableBoxBorder(bool drawBorder=true)
Definition: CBox.h:71
mrpt::opengl::CBox::~CBox
virtual ~CBox()
Destructor
Definition: CBox.h:90
mrpt::opengl::CBox::getLineWidth
float getLineWidth() const
Definition: CBox.h:66
CRenderizableDisplayList.h
mrpt::opengl::CBox::isWireframe
bool isWireframe() const
Definition: CBox.h:69
mrpt::opengl::CBox
A solid or wireframe box in 3D, defined by 6 rectangular faces parallel to the planes X,...
Definition: CBox.h:37
mrpt::opengl::CRenderizableDisplayList
A renderizable object suitable for rendering with OpenGL's display lists.
Definition: CRenderizableDisplayList.h:36
mrpt::opengl::CRenderizableDisplayList::notifyChange
EIGEN_STRONG_INLINE void notifyChange() const
Must be called to notify that the object has changed (so, the display list must be updated)
Definition: CRenderizableDisplayList.h:49
mrpt::opengl::CBox::isBoxBorderEnabled
bool isBoxBorderEnabled() const
Definition: CBox.h:72
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CParticleFilter.h:16
mrpt::opengl::CBox::m_draw_border
bool m_draw_border
Draw line borders to solid box with the given linewidth (default: true)
Definition: CBox.h:44
mrpt::opengl::CBox::getBoxCorners
void getBoxCorners(mrpt::math::TPoint3D &corner1, mrpt::math::TPoint3D &corner2) const
Definition: CBox.h:79
lightweight_geom_data.h
mrpt::opengl::CBox::m_solidborder_color
mrpt::utils::TColor m_solidborder_color
Color of the solid box borders.
Definition: CBox.h:45
mrpt::opengl::CBox::m_corner_min
mrpt::math::TPoint3D m_corner_min
Definition: CBox.h:41
mrpt::opengl::CBox::m_lineWidth
float m_lineWidth
For wireframe only.
Definition: CBox.h:43
DEFINE_SERIALIZABLE_POST_CUSTOM_BASE_LINKAGE
#define DEFINE_SERIALIZABLE_POST_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)
Definition: CSerializable.h:174
mrpt::opengl::CBox::setBoxBorderColor
void setBoxBorderColor(const mrpt::utils::TColor &c)
Definition: CBox.h:74
mrpt::math::TPoint3D
Lightweight 3D point.
Definition: lightweight_geom_data.h:229
DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE
#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...
Definition: CSerializable.h:170
mrpt::opengl::CBox::getBoxBorderColor
mrpt::utils::TColor getBoxBorderColor() const
Definition: CBox.h:75
mrpt::utils::TColor
A RGB color - 8bit.
Definition: TColor.h:25
DEFINE_SERIALIZABLE
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
Definition: CSerializable.h:147
mrpt::math::traceRay
bool BASE_IMPEXP traceRay(const vector< TPolygonWithPlane > &vec, const mrpt::poses::CPose3D &pose, double &dist)
Fast ray tracing method using polygons' properties.
mrpt::opengl::CBox::m_wireframe
bool m_wireframe
true: wireframe, false: solid
Definition: CBox.h:42
MRPT_OVERRIDE
#define MRPT_OVERRIDE
C++11 "override" for virtuals:
Definition: mrpt_macros.h:28
mrpt::opengl::CBox::setWireframe
void setWireframe(bool is_wireframe=true)
Definition: CBox.h:68



Page generated by Doxygen 1.8.16 for MRPT 1.4.0 SVN: at Mon Oct 14 22:32:58 UTC 2019