00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 #ifndef X3D_OCTREE_H
00019 #define X3D_OCTREE_H
00020 
00021 #include "octree_instanciation.h"
00022 
00023 
00024 
00025 namespace animal
00026 {
00027 namespace octree
00028 {
00029 
00030 enum { OCTREE_DM_NOTHING=0, OCTREE_DM_VERTICES=1, OCTREE_DM_FRAMES=2 };
00031         
00032         class Octree : 
00033             public TempOctree
00034         {
00035             public:
00036                 Octree( Vec3d bboxMin, Vec3d bboxMax, MFVec3f *points, MFVec3f normals, unsigned int nMaxPointsPerCell = 1 );
00037                 ~Octree( );
00038 
00039                 
00040                 
00041                 unsigned int getNMaxPointsPerCell();
00047                 void setNMaxPointsPerCell( unsigned int n );
00048 
00049                 
00053                 void setPositionMethod( int m );
00054                 int getPositionMethod() const;
00055                 
00056                 
00057                 
00061                 void subdivideDeformed( Cell *cell );
00062                 
00063                 
00067                 void subdivideRecDeformed( Cell *cell );
00068 
00069                                     
00073                 void simplify( Cell *cell );
00074 
00075                 
00079                 static void updateFrame( Cell *cell );
00080                 static void updateFrames( Cell *cell );
00081                 void updateFrames( ConstrainedVertex* vertex, Cell *cell, unsigned int vPos );
00082                 void updateCellFrames( Cell *cell );
00083                 
00084                 
00085                 void movedRecLeaves( Cell *cell );
00086                 static void moved( Cell *cell );
00087                 
00088                 void structureChangedRecLeaves( Cell *cell );
00089                 static void structureChanged( Cell *cell );
00090                 
00091                 
00095                 static void updateVertexInformationsRec( Cell *cell );
00096                 static void updateVertexInformationsRecLeaves( Cell *cell );
00097                 static void updateVertexInformations( Cell *cell );
00098                 
00099                 void updateCellsData( Cell *cell );
00100                 
00101                 static void updateInfluenceMapsRecLeaves( Cell *cell );
00102                 static void updateInfluenceMaps( Cell *cell );
00103                 
00104                 
00105                 
00106                 void directManipulation( SFVec3fCellConstrained* vertex, Vec3d newPosition );
00107                 
00108 
00109                 std::vector<Vec3d> getNormals() const;
00110                 OctreeDataPoints& getMeshVertices();
00111 
00112                 
00113 
00114                 void setFreeFrames( bool );
00115                 bool haveFreeFrames( ) const { return _freeFrames; };
00116                 
00117                 
00118                 
00119                 
00120                 void setDMMethod( int method );
00121 
00122             private:
00123                 int createOctree( Cell *cell, std::deque<SFVec3f*> pointsIn );
00124                 
00125                 int createOctree( Cell *cell );
00126                 
00127                 unsigned int _nMaxPointsPerCell;
00128 
00129                 void updateHierarchy( Cell *cell );             
00130                 
00131                 int _optionPositionMethod;
00132                 
00133                 bool isLeaf( Cell *cell ) { return cell->isLeaf(); };
00134                 
00135                 
00136 
00137                 bool _freeFrames;
00138                 
00139                 int _DMMethod;
00140                 
00141                 
00142 
00143             public:
00144                                 
00145 
00146         };
00147         
00148 static inline bool isLeaf( Cell *cell ) { return cell->isLeaf(); };
00149 
00153 Cell* getVertexFreeCell( Cell* cStart, const ConstrainedVertex* cv );
00154 
00155 
00156 
00157 }
00158 }
00159 
00160 
00161                 
00162 #endif
00163  
00164