TriangleOctreeModel.h

Go to the documentation of this file.
00001 /******************************************************************************
00002 *       SOFA, Simulation Open-Framework Architecture, version 1.0 beta 3      *
00003 *                (c) 2006-2008 MGH, INRIA, USTL, UJF, CNRS                    *
00004 *                                                                             *
00005 * This library is free software; you can redistribute it and/or modify it     *
00006 * under the terms of the GNU Lesser General Public License as published by    *
00007 * the Free Software Foundation; either version 2.1 of the License, or (at     *
00008 * your option) any later version.                                             *
00009 *                                                                             *
00010 * This library is distributed in the hope that it will be useful, but WITHOUT *
00011 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or       *
00012 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
00013 * for more details.                                                           *
00014 *                                                                             *
00015 * You should have received a copy of the GNU Lesser General Public License    *
00016 * along with this library; if not, write to the Free Software Foundation,     *
00017 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.          *
00018 *******************************************************************************
00019 *                               SOFA :: Modules                               *
00020 *                                                                             *
00021 * Authors: The SOFA Team and external contributors (see Authors.txt)          *
00022 *                                                                             *
00023 * Contact information: contact@sofa-framework.org                             *
00024 ******************************************************************************/
00025 #ifndef SOFA_COMPONENT_COLLISION_TRIANGLEOCTREEMDEL_H
00026 #define SOFA_COMPONENT_COLLISION_TRIANGLEOCTREEMDEL_H
00027 
00028 #include <sofa/core/CollisionModel.h>
00029 #include <sofa/component/MechanicalObject.h>
00030 #include <sofa/core/componentmodel/topology/BaseMeshTopology.h>
00031 #include <sofa/defaulttype/Vec3Types.h>
00032 #include <sofa/component/collision/TriangleModel.h>
00033 #include <sofa/component/collision/TriangleOctree.h>
00034 
00035 
00036 namespace sofa
00037 {
00038 
00039   namespace component
00040   {
00041 
00042     namespace collision 
00043     {
00044 
00045       using namespace sofa::defaulttype;
00046 
00047       class TriangleOctree;
00048       class TriangleModel;
00049 
00050       class TriangleOctreeModel:public  TriangleModel
00051       {
00052       public:
00053     TriangleOctreeModel();
00054     /*the triangles assiciated to a point*/
00055     vector<vector<int> > pTri;
00056     /*the normals for each point*/
00057     vector<Vector3> pNorms;
00058         /*the size of the octree cube*/
00059     int cubeSize;
00060     /*the first node of the octree*/
00061     TriangleOctree *octreeRoot;
00062     //vector < Vector4 > octreeVec;
00063     void    draw();
00064     virtual void computeBoundingTree(int maxDepth=0);
00065     virtual void computeContinuousBoundingTree(double dt, int maxDepth=0);
00066     /*init the octree creation*/
00067     void buildOctree ();
00068     protected:
00069     /*used to add a triangle  to the octree*/
00070     int fillOctree (int t, int d = 0, Vector3 v = Vector3 (0, 0, 0));
00071       };
00072       /*class used to manage the Bounding Box for each triangle*/
00073       class TriangleAABB
00074       {
00075 
00076 
00077 
00078     double bb[6];
00079 
00080     double m_size;
00081           public:
00082     double *getAABB ()
00083     {
00084       return bb;
00085     }
00086     double size ()
00087     {
00088       return m_size;
00089     }
00090     TriangleAABB (Triangle & t);
00091       };
00092 
00093     }               // namespace collision
00094 
00095   }             // namespace component
00096 
00097 }               // namespace sofa
00098 
00099 #endif

Generated on Sun Nov 23 02:37:12 2008 for Sofa by  doxygen 1.5.7.1