Main MRPT website > C++ reference for MRPT 1.9.9
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 {
17 namespace opengl
18 {
19 /** A solid or wireframe box in 3D, defined by 6 rectangular faces parallel to
20  *the planes X, Y and Z (note that the object can be translated and rotated
21  *afterwards as any other CRenderizable object using the "object pose" in the
22  *base class).
23  * Three drawing modes are possible:
24  * - Wireframe: setWireframe(true). Used color is the CRenderizable color
25  * - Solid box: setWireframe(false). Used color is the CRenderizable color
26  * - Solid box with border: setWireframe(false) + enableBoxBorder(true). Solid
27  *color is the CRenderizable color, border line can be set with
28  *setBoxBorderColor().
29  *
30  * \sa opengl::COpenGLScene,opengl::CRenderizable
31  *
32  * <div align="center">
33  * <table border="0" cellspan="4" cellspacing="4" style="border-width: 1px;
34  *border-style: solid;">
35  * <tr> <td> mrpt::opengl::CBox </td> <td> \image html preview_CBox.png </td>
36  *</tr>
37  * </table>
38  * </div>
39  *
40  * \ingroup mrpt_opengl_grp
41  */
43 {
45 
46  protected:
47  /** Corners coordinates */
49  /** true: wireframe, false: solid */
51  /** For wireframe only. */
52  float m_lineWidth;
53  /** Draw line borders to solid box with the given linewidth (default: true)
54  */
56  /** Color of the solid box borders. */
58 
59  public:
60  /** Constructor returning a smart pointer to the newly created object. */
61  static CBox::Ptr Create(
62  const mrpt::math::TPoint3D& corner1,
63  const mrpt::math::TPoint3D& corner2, bool is_wireframe = false,
64  float lineWidth = 1.0);
65 
66  /** Render
67  * \sa mrpt::opengl::CRenderizable
68  */
69  void render_dl() const override;
70 
71  /** Evaluates the bounding box of this object (including possible children)
72  * in the coordinate frame of the object parent. */
73  void getBoundingBox(
74  mrpt::math::TPoint3D& bb_min,
75  mrpt::math::TPoint3D& bb_max) const override;
76 
77  /**
78  * Ray tracing.
79  * \sa mrpt::opengl::CRenderizable
80  */
81  bool traceRay(const mrpt::poses::CPose3D& o, double& dist) const override;
82 
83  inline void setLineWidth(float width)
84  {
87  }
88  inline float getLineWidth() const { return m_lineWidth; }
89  inline void setWireframe(bool is_wireframe = true)
90  {
91  m_wireframe = is_wireframe;
93  }
94  inline bool isWireframe() const { return m_wireframe; }
95  inline void enableBoxBorder(bool drawBorder = true)
96  {
97  m_draw_border = drawBorder;
99  }
100  inline bool isBoxBorderEnabled() const { return m_draw_border; }
102  {
105  }
107  {
108  return m_solidborder_color;
109  }
110 
111  /** Set the position and size of the box, from two corners in 3D */
112  void setBoxCorners(
113  const mrpt::math::TPoint3D& corner1,
114  const mrpt::math::TPoint3D& corner2);
116  mrpt::math::TPoint3D& corner1, mrpt::math::TPoint3D& corner2) const
117  {
118  corner1 = m_corner_min;
119  corner2 = m_corner_max;
120  }
121 
122  /** Basic empty constructor. Set all parameters to default. */
123  CBox();
124 
125  /** Constructor with all the parameters */
126  CBox(
127  const mrpt::math::TPoint3D& corner1,
128  const mrpt::math::TPoint3D& corner2, bool is_wireframe = false,
129  float lineWidth = 1.0);
130 
131  /** Destructor */
132  virtual ~CBox() {}
133  private:
134 };
135 }
136 }
137 #endif
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.
Definition: CBox.cpp:253
A solid or wireframe box in 3D, defined by 6 rectangular faces parallel to the planes X...
Definition: CBox.h:42
mrpt::utils::TColor getBoxBorderColor() const
Definition: CBox.h:106
void setLineWidth(float width)
Definition: CBox.h:83
bool isBoxBorderEnabled() const
Definition: CBox.h:100
mrpt::math::TPoint3D m_corner_max
Definition: CBox.h:48
bool isWireframe() const
Definition: CBox.h:94
CBox()
Basic empty constructor.
Definition: CBox.cpp:26
void render_dl() const override
Render.
Definition: CBox.cpp:50
mrpt::utils::TColor m_solidborder_color
Color of the solid box borders.
Definition: CBox.h:57
bool m_wireframe
true: wireframe, false: solid
Definition: CBox.h:50
bool m_draw_border
Draw line borders to solid box with the given linewidth (default: true)
Definition: CBox.h:55
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:52
GLenum GLsizei width
Definition: glext.h:3531
A renderizable object suitable for rendering with OpenGL&#39;s display lists.
bool traceRay(const mrpt::poses::CPose3D &o, double &dist) const override
Ray tracing.
Definition: CBox.cpp:269
void getBoxCorners(mrpt::math::TPoint3D &corner1, mrpt::math::TPoint3D &corner2) const
Definition: CBox.h:115
void setWireframe(bool is_wireframe=true)
Definition: CBox.h:89
const GLubyte * c
Definition: glext.h:6313
A RGB color - 8bit.
Definition: TColor.h:25
void getBoundingBox(mrpt::math::TPoint3D &bb_min, mrpt::math::TPoint3D &bb_max) const override
Evaluates the bounding box of this object (including possible children) in the coordinate frame of th...
Definition: CBox.cpp:276
void enableBoxBorder(bool drawBorder=true)
Definition: CBox.h:95
void setBoxBorderColor(const mrpt::utils::TColor &c)
Definition: CBox.h:101
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...
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:88
mrpt::math::TPoint3D m_corner_min
Corners coordinates.
Definition: CBox.h:48
virtual ~CBox()
Destructor.
Definition: CBox.h:132
float getLineWidth() const
Definition: CBox.h:88
Lightweight 3D point.
static Ptr Create(Args &&... args)
Definition: CBox.h:44
std::shared_ptr< CBox > Ptr
Definition: CBox.h:44



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019