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



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020