MRPT  1.9.9
CBox.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2019, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #pragma once
10 
11 #include <mrpt/math/TPoint3D.h>
13 
14 namespace mrpt::opengl
15 {
16 /** A solid or wireframe box in 3D, defined by 6 rectangular faces parallel to
17  *the planes X, Y and Z (note that the object can be translated and rotated
18  *afterwards as any other CRenderizable object using the "object pose" in the
19  *base class).
20  * Three drawing modes are possible:
21  * - Wireframe: setWireframe(true). Used color is the CRenderizable color
22  * - Solid box: setWireframe(false). Used color is the CRenderizable color
23  * - Solid box with border: setWireframe(false) + enableBoxBorder(true). Solid
24  *color is the CRenderizable color, border line can be set with
25  *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;
31  *border-style: solid;">
32  * <tr> <td> mrpt::opengl::CBox </td> <td> \image html preview_CBox.png </td>
33  *</tr>
34  * </table>
35  * </div>
36  *
37  * \ingroup mrpt_opengl_grp
38  */
40 {
42 
43  protected:
44  /** Corners coordinates */
46  /** true: wireframe, false: solid */
47  bool m_wireframe{false};
48  /** For wireframe only. */
49  float m_lineWidth{1};
50  /** Draw line borders to solid box with the given linewidth (default: true)
51  */
52  bool m_draw_border{false};
53  /** Color of the solid box borders. */
55 
56  public:
57  /** Render
58  * \sa mrpt::opengl::CRenderizable
59  */
60  void render_dl() const override;
61 
62  /** Evaluates the bounding box of this object (including possible children)
63  * in the coordinate frame of the object parent. */
64  void getBoundingBox(
66  mrpt::math::TPoint3D& bb_max) const override;
67 
68  /**
69  * Ray tracing.
70  * \sa mrpt::opengl::CRenderizable
71  */
72  bool traceRay(const mrpt::poses::CPose3D& o, double& dist) const override;
73 
74  inline void setLineWidth(float width)
75  {
78  }
79  inline float getLineWidth() const { return m_lineWidth; }
80  inline void setWireframe(bool is_wireframe = true)
81  {
82  m_wireframe = is_wireframe;
84  }
85  inline bool isWireframe() const { return m_wireframe; }
86  inline void enableBoxBorder(bool drawBorder = true)
87  {
88  m_draw_border = drawBorder;
90  }
91  inline bool isBoxBorderEnabled() const { return m_draw_border; }
93  {
96  }
98  {
99  return m_solidborder_color;
100  }
101 
102  /** Set the position and size of the box, from two corners in 3D */
103  void setBoxCorners(
104  const mrpt::math::TPoint3D& corner1,
105  const mrpt::math::TPoint3D& corner2);
107  mrpt::math::TPoint3D& corner1, mrpt::math::TPoint3D& corner2) const
108  {
109  corner1 = m_corner_min;
110  corner2 = m_corner_max;
111  }
112 
113  /** Basic empty constructor. Set all parameters to default. */
114  CBox();
115 
116  /** Constructor with all the parameters */
117  CBox(
118  const mrpt::math::TPoint3D& corner1,
119  const mrpt::math::TPoint3D& corner2, bool is_wireframe = false,
120  float lineWidth = 1.0);
121 
122  /** Destructor */
123  ~CBox() override = default;
124 
125  private:
126 };
127 } // namespace mrpt::opengl
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:239
A solid or wireframe box in 3D, defined by 6 rectangular faces parallel to the planes X...
Definition: CBox.h:39
void notifyChange() const
Must be called to notify that the object has changed (so, the display list must be updated) ...
void setLineWidth(float width)
Definition: CBox.h:74
bool isBoxBorderEnabled() const
Definition: CBox.h:91
mrpt::math::TPoint3D m_corner_max
Definition: CBox.h:45
bool isWireframe() const
Definition: CBox.h:85
CBox()
Basic empty constructor.
Definition: CBox.cpp:27
void render_dl() const override
Render.
Definition: CBox.cpp:49
bool m_wireframe
true: wireframe, false: solid
Definition: CBox.h:47
bool m_draw_border
Draw line borders to solid box with the given linewidth (default: true)
Definition: CBox.h:52
void setBoxBorderColor(const mrpt::img::TColor &c)
Definition: CBox.h:92
float m_lineWidth
For wireframe only.
Definition: CBox.h:49
GLenum GLsizei width
Definition: glext.h:3535
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:255
void getBoxCorners(mrpt::math::TPoint3D &corner1, mrpt::math::TPoint3D &corner2) const
Definition: CBox.h:106
~CBox() override=default
Destructor.
void setWireframe(bool is_wireframe=true)
Definition: CBox.h:80
const GLubyte * c
Definition: glext.h:6406
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:262
void enableBoxBorder(bool drawBorder=true)
Definition: CBox.h:86
#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:84
mrpt::math::TPoint3D m_corner_min
Corners coordinates.
Definition: CBox.h:45
mrpt::img::TColor m_solidborder_color
Color of the solid box borders.
Definition: CBox.h:54
The namespace for 3D scene representation and rendering.
Definition: CGlCanvasBase.h:15
const auto bb_max
const auto bb_min
float getLineWidth() const
Definition: CBox.h:79
A RGB color - 8bit.
Definition: TColor.h:20
mrpt::img::TColor getBoxBorderColor() const
Definition: CBox.h:97
Lightweight 3D point.
Definition: TPoint3D.h:90



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 8fe78517f Sun Jul 14 19:43:28 2019 +0200 at lun oct 28 02:10:00 CET 2019