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://www.mrpt.org/                                |
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                   * \ingroup mrpt_opengl_grp
00052                   */
00053                 class OPENGL_IMPEXP CSphere : public CRenderizableDisplayList
00054                 {
00055                         DEFINE_SERIALIZABLE( CSphere )
00056 
00057                 protected:
00058                         float                   m_radius;
00059                         int                             m_nDivsLongitude,m_nDivsLatitude;
00060                         bool                    m_keepRadiusIndependentEyeDistance;
00061 
00062                 public:
00063                         void setRadius(float r) { m_radius=r; CRenderizableDisplayList::notifyChange(); }
00064                         float getRadius() const {return m_radius; }
00065 
00066                         void setNumberDivsLongitude(int N) { m_nDivsLongitude=N; CRenderizableDisplayList::notifyChange(); }
00067                         void setNumberDivsLatitude(int N) { m_nDivsLatitude=N;  CRenderizableDisplayList::notifyChange();}
00068                         void enableRadiusIndependentOfEyeDistance(bool v=true)  { m_keepRadiusIndependentEyeDistance=v; CRenderizableDisplayList::notifyChange(); }
00069 
00070                         /** \sa CRenderizableDisplayList */
00071                         virtual bool should_skip_display_list_cache() const { return m_keepRadiusIndependentEyeDistance; }
00072 
00073                         /** Class factory  */
00074                         static CSpherePtr Create(
00075                                 float                           radius,
00076                                 int                                     nDivsLongitude = 20,
00077                                 int                                     nDivsLatitude = 20 )
00078                         {
00079                                 return CSpherePtr( new CSphere(radius,nDivsLongitude,nDivsLatitude) );
00080                         }
00081 
00082                         /** Render */
00083                         void  render_dl() const;
00084 
00085                         /** Ray tracing
00086                           */
00087                         virtual bool traceRay(const mrpt::poses::CPose3D &o,double &dist) const;
00088 
00089                 private:
00090                         /** Constructor
00091                           */
00092                         CSphere(
00093                                 float                           radius = 1.0f,
00094                                 int                                     nDivsLongitude = 20,
00095                                 int                                     nDivsLatitude = 20
00096                                 ) :
00097                                 m_radius(radius),
00098                                 m_nDivsLongitude(nDivsLongitude),
00099                                 m_nDivsLatitude(nDivsLatitude),
00100                                 m_keepRadiusIndependentEyeDistance(false)
00101                         {
00102                         }
00103 
00104                         /** Private, virtual destructor: only can be deleted from smart pointers */
00105                         virtual ~CSphere() { }
00106                 };
00107 
00108         } // end namespace
00109 
00110 } // End of namespace
00111 
00112 #endif



Page generated by Doxygen 1.7.5 for MRPT 0.9.5 SVN: at Thu Oct 13 21:25:36 UTC 2011