Main MRPT website > C++ reference
MRPT logo
CSphere.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_CSphere_H
29 #define opengl_CSphere_H
30 
32 
33 namespace mrpt
34 {
35  namespace opengl
36  {
38 
39  // This must be added to any CSerializable derived class:
41 
42  /** A solid or wire-frame sphere.
43  * \sa opengl::COpenGLScene
44  *
45  * <div align="center">
46  * <table border="0" cellspan="4" cellspacing="4" style="border-width: 1px; border-style: solid;">
47  * <tr> <td> mrpt::opengl::CSphere </td> <td> \image html preview_CSphere.png </td> </tr>
48  * </table>
49  * </div>
50  *
51  * \ingroup mrpt_opengl_grp
52  */
54  {
56 
57  protected:
58  float m_radius;
59  int m_nDivsLongitude,m_nDivsLatitude;
60  bool m_keepRadiusIndependentEyeDistance;
61 
62  public:
63  void setRadius(float r) { m_radius=r; CRenderizableDisplayList::notifyChange(); }
64  float getRadius() const {return m_radius; }
65 
66  void setNumberDivsLongitude(int N) { m_nDivsLongitude=N; CRenderizableDisplayList::notifyChange(); }
68  void enableRadiusIndependentOfEyeDistance(bool v=true) { m_keepRadiusIndependentEyeDistance=v; CRenderizableDisplayList::notifyChange(); }
69 
70  /** \sa CRenderizableDisplayList */
71  virtual bool should_skip_display_list_cache() const { return m_keepRadiusIndependentEyeDistance; }
72 
73  /** Class factory */
74  static CSpherePtr Create(
75  float radius,
76  int nDivsLongitude = 20,
77  int nDivsLatitude = 20 )
78  {
79  return CSpherePtr( new CSphere(radius,nDivsLongitude,nDivsLatitude) );
80  }
81 
82  /** Render */
83  void render_dl() const;
84 
85  /** Ray tracing
86  */
87  virtual bool traceRay(const mrpt::poses::CPose3D &o,double &dist) const;
88 
89  private:
90  /** Constructor
91  */
93  float radius = 1.0f,
94  int nDivsLongitude = 20,
95  int nDivsLatitude = 20
96  ) :
97  m_radius(radius),
98  m_nDivsLongitude(nDivsLongitude),
99  m_nDivsLatitude(nDivsLatitude),
100  m_keepRadiusIndependentEyeDistance(false)
101  {
102  }
103 
104  /** Private, virtual destructor: only can be deleted from smart pointers */
105  virtual ~CSphere() { }
106  };
107 
108  } // end namespace
109 
110 } // End of namespace
111 
112 #endif



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