Main MRPT website > C++ reference for MRPT 1.5.6
CSphere.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_CSphere_H
10 #define opengl_CSphere_H
11 
13 
14 namespace mrpt
15 {
16  namespace opengl
17  {
18 
19 
20  // This must be added to any CSerializable derived class:
21  DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE( CSphere, CRenderizableDisplayList, OPENGL_IMPEXP )
22 
23  /** A solid or wire-frame sphere.
24  * \sa opengl::COpenGLScene
25  *
26  * <div align="center">
27  * <table border="0" cellspan="4" cellspacing="4" style="border-width: 1px; border-style: solid;">
28  * <tr> <td> mrpt::opengl::CSphere </td> <td> \image html preview_CSphere.png </td> </tr>
29  * </table>
30  * </div>
31  *
32  * \ingroup mrpt_opengl_grp
33  */
35  {
37 
38  protected:
39  float m_radius;
40  int m_nDivsLongitude,m_nDivsLatitude;
41  bool m_keepRadiusIndependentEyeDistance;
42 
43  public:
44  void setRadius(float r) { m_radius=r; CRenderizableDisplayList::notifyChange(); }
45  float getRadius() const {return m_radius; }
46 
47  void setNumberDivsLongitude(int N) { m_nDivsLongitude=N; CRenderizableDisplayList::notifyChange(); }
49  void enableRadiusIndependentOfEyeDistance(bool v=true) { m_keepRadiusIndependentEyeDistance=v; CRenderizableDisplayList::notifyChange(); }
50 
51  /** \sa CRenderizableDisplayList */
52  bool should_skip_display_list_cache() const MRPT_OVERRIDE { return m_keepRadiusIndependentEyeDistance; }
53 
54  /** Class factory */
55  static CSpherePtr Create(
56  float radius,
57  int nDivsLongitude = 20,
58  int nDivsLatitude = 20 );
59 
60  /** Render */
61  void render_dl() const MRPT_OVERRIDE;
62 
63  /** Evaluates the bounding box of this object (including possible children) in the coordinate frame of the object parent. */
64  void getBoundingBox(mrpt::math::TPoint3D &bb_min, mrpt::math::TPoint3D &bb_max) const MRPT_OVERRIDE;
65 
66  /** Ray tracing
67  */
68  bool traceRay(const mrpt::poses::CPose3D &o,double &dist) const MRPT_OVERRIDE;
69 
70  private:
71  /** Constructor
72  */
74  float radius = 1.0f,
75  int nDivsLongitude = 20,
76  int nDivsLatitude = 20
77  ) :
78  m_radius(radius),
79  m_nDivsLongitude(nDivsLongitude),
80  m_nDivsLatitude(nDivsLatitude),
81  m_keepRadiusIndependentEyeDistance(false)
82  {
83  }
84 
85  /** Private, virtual destructor: only can be deleted from smart pointers */
86  virtual ~CSphere() { }
87  };
88  DEFINE_SERIALIZABLE_POST_CUSTOM_BASE_LINKAGE( CSphere, CRenderizableDisplayList, OPENGL_IMPEXP )
89 
90  } // end namespace
91 
92 } // End of namespace
93 
94 #endif
const GLdouble * v
Definition: glew.h:1296
#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' properties.
Definition: geometry.cpp:1996
EIGEN_STRONG_INLINE void notifyChange() const
Must be called to notify that the object has changed (so, the display list must be updated) ...
A renderizable object suitable for rendering with OpenGL's display lists.
void setNumberDivsLongitude(int N)
Definition: CSphere.h:47
virtual ~CSphere()
Private, virtual destructor: only can be deleted from smart pointers.
Definition: CSphere.h:86
void setNumberDivsLatitude(int N)
Definition: CSphere.h:48
#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...
bool should_skip_display_list_cache() const MRPT_OVERRIDE
Definition: CSphere.h:52
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
void enableRadiusIndependentOfEyeDistance(bool v=true)
Definition: CSphere.h:49
A solid or wire-frame sphere.
Definition: CSphere.h:34
GLdouble GLdouble GLdouble r
Definition: glew.h:1311
#define DEFINE_SERIALIZABLE_POST_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)
float getRadius() const
Definition: CSphere.h:45
GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble f
Definition: glew.h:5092



Page generated by Doxygen 1.8.6 for MRPT 1.5.6 Git: 4c65e84 Tue Apr 24 08:18:17 2018 +0200 at mar abr 24 08:26:17 CEST 2018