Main MRPT website > C++ reference for MRPT 1.5.6
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-2017, 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
A solid or wireframe box in 3D, defined by 6 rectangular faces parallel to the planes X...
Definition: CBox.h:37
mrpt::utils::TColor getBoxBorderColor() const
Definition: CBox.h:75
bool isBoxBorderEnabled() const
Definition: CBox.h:72
#define MRPT_OVERRIDE
C++11 "override" for virtuals:
bool BASE_IMPEXP traceRay(const std::vector< TPolygonWithPlane > &vec, const mrpt::poses::CPose3D &pose, double &dist)
Fast ray tracing method using polygons&#39; properties.
Definition: geometry.cpp:1996
bool isWireframe() const
Definition: CBox.h:69
mrpt::utils::TColor m_solidborder_color
Color of the solid box borders.
Definition: CBox.h:45
bool m_wireframe
true: wireframe, false: solid
Definition: CBox.h:42
bool m_draw_border
Draw line borders to solid box with the given linewidth (default: true)
Definition: CBox.h:44
EIGEN_STRONG_INLINE void notifyChange() const
Must be called to notify that the object has changed (so, the display list must be updated) ...
float m_lineWidth
For wireframe only.
Definition: CBox.h:43
GLenum GLsizei width
Definition: glext.h:3513
A renderizable object suitable for rendering with OpenGL&#39;s display lists.
void getBoxCorners(mrpt::math::TPoint3D &corner1, mrpt::math::TPoint3D &corner2) const
Definition: CBox.h:79
#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...
void setWireframe(bool is_wireframe=true)
Definition: CBox.h:68
const GLubyte * c
Definition: glext.h:5590
A RGB color - 8bit.
Definition: TColor.h:26
void enableBoxBorder(bool drawBorder=true)
Definition: CBox.h:71
void setBoxBorderColor(const mrpt::utils::TColor &c)
Definition: CBox.h:74
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
mrpt::math::TPoint3D m_corner_min
Definition: CBox.h:41
virtual ~CBox()
Destructor.
Definition: CBox.h:90
float getLineWidth() const
Definition: CBox.h:66
Lightweight 3D point.
#define DEFINE_SERIALIZABLE_POST_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)



Page generated by Doxygen 1.8.14 for MRPT 1.5.6 Git: 4c65e8431 Tue Apr 24 08:18:17 2018 +0200 at lun oct 28 01:35:26 CET 2019