Main MRPT website > C++ reference
MRPT logo
CBox.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | The Mobile Robot Programming Toolkit (MRPT) C++ library |
3  | |
4  | http://www.mrpt.org/ |
5  | |
6  | Copyright (C) 2005-2012 University of Malaga |
7  | |
8  | This software was written by the Machine Perception and Intelligent |
9  | Robotics Lab, University of Malaga (Spain). |
10  | Contact: Jose-Luis Blanco <jlblanco@ctima.uma.es> |
11  | |
12  | This file is part of the MRPT project. |
13  | |
14  | MRPT is free software: you can redistribute it and/or modify |
15  | it under the terms of the GNU General Public License as published by |
16  | the Free Software Foundation, either version 3 of the License, or |
17  | (at your option) any later version. |
18  | |
19  | MRPT is distributed in the hope that it will be useful, |
20  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
21  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22  | GNU General Public License for more details. |
23  | |
24  | You should have received a copy of the GNU General Public License |
25  | along with MRPT. If not, see <http://www.gnu.org/licenses/>. |
26  | |
27  +---------------------------------------------------------------------------+ */
28 #ifndef opengl_CBox_H
29 #define opengl_CBox_H
30 
33 
34 namespace mrpt {
35 namespace opengl {
36 
37  // This must be added to any CSerializable derived class:
39 
40  /** 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).
41  *
42  * \sa opengl::COpenGLScene,opengl::CRenderizable
43  *
44  * <div align="center">
45  * <table border="0" cellspan="4" cellspacing="4" style="border-width: 1px; border-style: solid;">
46  * <tr> <td> mrpt::opengl::CBox </td> <td> \image html preview_CBox.png </td> </tr>
47  * </table>
48  * </div>
49  *
50  * \ingroup mrpt_opengl_grp
51  */
54 
55  protected:
56  mrpt::math::TPoint3D m_corner_min,m_corner_max; //!< Corners coordinates
57  bool m_wireframe; //!< true: wireframe, false: solid
58  float m_lineWidth; //!< For wireframe only.
59 
60  public:
61  /** Constructor returning a smart pointer to the newly created object. */
62  static CBoxPtr Create(const mrpt::math::TPoint3D &corner1, const mrpt::math::TPoint3D &corner2, bool is_wireframe = false, float lineWidth = 1.0 )
63  {
64  return CBoxPtr(new CBox(corner1,corner2,is_wireframe,lineWidth));
65  }
66 
67  /** Render
68  * \sa mrpt::opengl::CRenderizable
69  */
70  void render_dl() const;
71 
72  /**
73  * Ray tracing.
74  * \sa mrpt::opengl::CRenderizable
75  */
76  virtual bool traceRay(const mrpt::poses::CPose3D &o,double &dist) const;
77 
78  inline void setLineWidth(float width) { m_lineWidth = width; CRenderizableDisplayList::notifyChange(); }
79  inline float getLineWidth() const { return m_lineWidth; }
80 
81  inline void setWireframe(bool is_wireframe=true) { m_wireframe = is_wireframe; CRenderizableDisplayList::notifyChange(); }
82  inline bool isWireframe() const { return m_wireframe; }
83 
84  /** Set the position and size of the box, from two corners in 3D */
85  void setBoxCorners(const mrpt::math::TPoint3D &corner1, const mrpt::math::TPoint3D &corner2);
86  void getBoxCorners(mrpt::math::TPoint3D &corner1, mrpt::math::TPoint3D &corner2) const { corner1= m_corner_min; corner2 = m_corner_max; }
87 
88 
89  private:
90  /** Basic empty constructor. Set all parameters to default. */
91  CBox():m_corner_min(-1,-1,-1),m_corner_max(1,1,1),m_wireframe(false),m_lineWidth(1) { }
92 
93  /** Constructor with all the parameters */
94  CBox(const mrpt::math::TPoint3D &corner1, const mrpt::math::TPoint3D &corner2, bool is_wireframe = false, float lineWidth = 1.0) :
95  m_wireframe(is_wireframe) , m_lineWidth( lineWidth )
96  {
97  setBoxCorners(corner1,corner2);
98  }
99 
100  /** Destructor */
101  virtual ~CBox() { }
102 
103  };
104 }
105 }
106 #endif



Page generated by Doxygen 1.8.3 for MRPT 0.9.6 SVN: at Fri Feb 15 22:05:02 EST 2013