HLShape.h

Go to the documentation of this file.
00001 
00002 //    Copyright 2004, SenseGraphics AB
00003 //
00004 //    This file is part of H3D API.
00005 //
00006 //    H3D API is free software; you can redistribute it and/or modify
00007 //    it under the terms of the GNU General Public License as published by
00008 //    the Free Software Foundation; either version 2 of the License, or
00009 //    (at your option) any later version.
00010 //
00011 //    H3D API is distributed in the hope that it will be useful,
00012 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //    GNU General Public License for more details.
00015 //
00016 //    You should have received a copy of the GNU General Public License
00017 //    along with H3D API; if not, write to the Free Software
00018 //    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 //
00020 //    A commercial license is also available. Please contact us at 
00021 //    www.sensegraphics.com for more information.
00022 //
00023 //
00027 //
00029 #ifndef __HLSHAPE_H__
00030 #define __HLSHAPE_H__
00031 
00032 #include "HLObject.h"
00033 #include "H3DTypes.h"
00034 #include "Bound.h"
00035 #include <map>
00036 #include <map>
00037 #include <vector>
00038 
00039 namespace H3D {
00040 
00041   class HLHapticsDevice;
00042   class X3DGeometryNode;
00047   class H3DAPI_API HLShape: public HLObject {
00048   protected:
00049     typedef std::map< std::pair< X3DGeometryNode *, HLHapticsDevice * >,
00050                       unsigned int > ShapeIdMap;
00051 
00060     static ShapeIdMap shape_id_db ;
00061 
00062 #ifdef HAVE_OPENHAPTICS
00063     typedef std::multimap< HLuint, HLShape * > HLShapeMap; 
00065     static HLShapeMap hl_shape_map;
00066 
00068     std::vector< HLuint > shape_ids;
00069 #endif
00070   public:
00073     virtual void hlRender( HLHapticsDevice *hd ) = 0;
00074 #ifdef HAVE_OPENHAPTICS
00075 
00076     virtual ~HLShape();
00077     
00079     HLuint getShapeId( HLHapticsDevice *hd );
00080 
00082     inline static HLShape *getHLShape( HLuint id ) {
00083       HLShapeMap::iterator i = hl_shape_map.find( id );
00084       if( i == hl_shape_map.end() ) return NULL;
00085       else return (*i).second;
00086     }
00087 #endif
00090     inline static void resetShapeIdDB() {
00091       shape_id_db.clear();
00092     }
00093 
00099     inline static unsigned int getFreeShapeIdIndex( X3DGeometryNode *geom,
00100                                                     HLHapticsDevice *hd ) {
00101       ShapeIdMap::iterator i = shape_id_db.find( std::make_pair( geom, hd ) );
00102       if( i != shape_id_db.end() ) {
00103         (*i).second++;
00104         return (*i).second;
00105       } else {
00106         shape_id_db.insert( i, std::make_pair( std::make_pair( geom, 
00107                                                                hd ), 0 ) );
00108         return 0;
00109       }
00110     }
00111 
00117     virtual bool closeEnoughToBound( const Vec3f &p, 
00118                                      const Vec3f &previous_p, 
00119                                      const Matrix4f &m,
00120                                      X3DGeometryNode *geom );
00121 
00122   };
00123 }
00124 
00125 #endif

Generated on Thu Aug 24 12:38:33 2006 for H3D API by  doxygen 1.4.5