Main MRPT website > C++ reference
MRPT logo

CSphere.h

Go to the documentation of this file.
00001 /* +---------------------------------------------------------------------------+
00002    |          The Mobile Robot Programming Toolkit (MRPT) C++ library          |
00003    |                                                                           |
00004    |                   http://mrpt.sourceforge.net/                            |
00005    |                                                                           |
00006    |   Copyright (C) 2005-2011  University of Malaga                           |
00007    |                                                                           |
00008    |    This software was written by the Machine Perception and Intelligent    |
00009    |      Robotics Lab, University of Malaga (Spain).                          |
00010    |    Contact: Jose-Luis Blanco  <jlblanco@ctima.uma.es>                     |
00011    |                                                                           |
00012    |  This file is part of the MRPT project.                                   |
00013    |                                                                           |
00014    |     MRPT is free software: you can redistribute it and/or modify          |
00015    |     it under the terms of the GNU General Public License as published by  |
00016    |     the Free Software Foundation, either version 3 of the License, or     |
00017    |     (at your option) any later version.                                   |
00018    |                                                                           |
00019    |   MRPT is distributed in the hope that it will be useful,                 |
00020    |     but WITHOUT ANY WARRANTY; without even the implied warranty of        |
00021    |     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         |
00022    |     GNU General Public License for more details.                          |
00023    |                                                                           |
00024    |     You should have received a copy of the GNU General Public License     |
00025    |     along with MRPT.  If not, see <http://www.gnu.org/licenses/>.         |
00026    |                                                                           |
00027    +---------------------------------------------------------------------------+ */
00028 #ifndef opengl_CSphere_H
00029 #define opengl_CSphere_H
00030 
00031 #include <mrpt/opengl/CRenderizableDisplayList.h>
00032 
00033 namespace mrpt
00034 {
00035         namespace opengl
00036         {
00037                 class OPENGL_IMPEXP CSphere;
00038 
00039                 // This must be added to any CSerializable derived class:
00040                 DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE( CSphere, CRenderizableDisplayList, OPENGL_IMPEXP )
00041 
00042                 /** A solid or wire-frame sphere.
00043                   *  \sa opengl::COpenGLScene
00044                   *  
00045                   *  <div align="center">
00046                   *  <table border="0" cellspan="4" cellspacing="4" style="border-width: 1px; border-style: solid;">
00047                   *   <tr> <td> mrpt::opengl::CSphere </td> <td> \image html preview_CSphere.png </td> </tr>
00048                   *  </table>
00049                   *  </div>
00050                   *  
00051                   */
00052                 class OPENGL_IMPEXP CSphere : public CRenderizableDisplayList
00053                 {
00054                         DEFINE_SERIALIZABLE( CSphere )
00055 
00056                 protected:
00057                         float                   m_radius;
00058                         int                             m_nDivsLongitude,m_nDivsLatitude;
00059                         bool                    m_keepRadiusIndependentEyeDistance;
00060 
00061                 public:
00062                         void setRadius(float r) { m_radius=r; CRenderizableDisplayList::notifyChange(); }
00063                         float getRadius() const {return m_radius; }
00064 
00065                         void setNumberDivsLongitude(int N) { m_nDivsLongitude=N; CRenderizableDisplayList::notifyChange(); }
00066                         void setNumberDivsLatitude(int N) { m_nDivsLatitude=N;  CRenderizableDisplayList::notifyChange();}
00067                         void enableRadiusIndependentOfEyeDistance(bool v=true)  { m_keepRadiusIndependentEyeDistance=v; CRenderizableDisplayList::notifyChange(); }
00068 
00069                         /** \sa CRenderizableDisplayList */
00070                         virtual bool should_skip_display_list_cache() const { return m_keepRadiusIndependentEyeDistance; }
00071 
00072                         /** Class factory  */
00073                         static CSpherePtr Create(
00074                                 float                           radius,
00075                                 int                                     nDivsLongitude = 20,
00076                                 int                                     nDivsLatitude = 20 )
00077                         {
00078                                 return CSpherePtr( new CSphere(radius,nDivsLongitude,nDivsLatitude) );
00079                         }
00080 
00081                         /** Render */
00082                         void  render_dl() const;
00083 
00084                         /** Ray tracing
00085                           */
00086                         virtual bool traceRay(const mrpt::poses::CPose3D &o,double &dist) const;
00087 
00088                 private:
00089                         /** Constructor
00090                           */
00091                         CSphere(
00092                                 float                           radius = 1.0f,
00093                                 int                                     nDivsLongitude = 20,
00094                                 int                                     nDivsLatitude = 20
00095                                 ) :
00096                                 m_radius(radius),
00097                                 m_nDivsLongitude(nDivsLongitude),
00098                                 m_nDivsLatitude(nDivsLatitude),
00099                                 m_keepRadiusIndependentEyeDistance(false)
00100                         {
00101                         }
00102 
00103                         /** Private, virtual destructor: only can be deleted from smart pointers */
00104                         virtual ~CSphere() { }
00105                 };
00106 
00107         } // end namespace
00108 
00109 } // End of namespace
00110 
00111 #endif



Page generated by Doxygen 1.7.3 for MRPT 0.9.4 SVN: at Sat Mar 26 06:16:28 UTC 2011