Main MRPT website > C++ reference for MRPT 1.5.7
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;
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
void setRadius(float r)
Definition: CSphere.h:44
#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&#39; properties.
Definition: geometry.cpp:1989
EIGEN_STRONG_INLINE void notifyChange() const
Must be called to notify that the object has changed (so, the display list must be updated) ...
float getRadius() const
Definition: CSphere.h:45
A renderizable object suitable for rendering with OpenGL&#39;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 m_keepRadiusIndependentEyeDistance
Definition: CSphere.h:41
bool should_skip_display_list_cache() const MRPT_OVERRIDE
Definition: CSphere.h:52
const GLdouble * v
Definition: glext.h:3603
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...
GLdouble GLdouble GLdouble r
Definition: glext.h:3618
void enableRadiusIndependentOfEyeDistance(bool v=true)
Definition: CSphere.h:49
A solid or wire-frame sphere.
Definition: CSphere.h:34
#define DEFINE_SERIALIZABLE_POST_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)



Page generated by Doxygen 1.8.14 for MRPT 1.5.7 Git: 5902e14cc Wed Apr 24 15:04:01 2019 +0200 at lun oct 28 01:39:17 CET 2019