DiscreteIntersection.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_DISCRETEINTERSECTION_H
00026 #define SOFA_COMPONENT_COLLISION_DISCRETEINTERSECTION_H
00027 
00028 #include <sofa/core/componentmodel/collision/Intersection.h>
00029 #include <sofa/helper/FnDispatcher.h>
00030 #include <sofa/component/collision/SphereModel.h>
00031 #include <sofa/component/collision/PointModel.h>
00032 #include <sofa/component/collision/LineModel.h>
00033 #include <sofa/component/collision/TriangleModel.h>
00034 #include <sofa/component/collision/CubeModel.h>
00035 #include <sofa/component/collision/RayModel.h>
00036 #include <sofa/component/collision/SphereTreeModel.h>
00037 #include <sofa/component/collision/DistanceGridCollisionModel.h>
00038 #include <sofa/component/collision/TetrahedronModel.h>
00039 
00040 namespace sofa
00041 {
00042 
00043 namespace component
00044 {
00045 
00046 namespace collision
00047 {
00048 class DiscreteIntersection : public core::componentmodel::collision::Intersection
00049 {
00050 public:
00051     DiscreteIntersection();
00052 
00055     virtual core::componentmodel::collision::ElementIntersector* findIntersector(core::CollisionModel* object1, core::CollisionModel* object2, bool& swapModels);
00056 
00057 protected:
00058     core::componentmodel::collision::IntersectorMap intersectors;
00059 
00060 public:
00061     template<class Model1, class Model2>
00062     sofa::core::componentmodel::collision::TDetectionOutputVector<Model1,Model2>* createOutputVector(Model1*, Model2*)
00063     {
00064         return new sofa::core::componentmodel::collision::TDetectionOutputVector<Model1,Model2>;
00065     }
00066 
00067     template<class Model1, class Model2>
00068     sofa::core::componentmodel::collision::TDetectionOutputVector<Model1,Model2>* getOutputVector(Model1*, Model2*, sofa::core::componentmodel::collision::DetectionOutputVector* contacts)
00069     {
00070         return static_cast<sofa::core::componentmodel::collision::TDetectionOutputVector<Model1,Model2>*>(contacts);
00071     }
00072 
00073     typedef sofa::helper::vector<sofa::core::componentmodel::collision::DetectionOutput> OutputVector;
00074 
00075     int beginIntersection(sofa::core::CollisionModel* /*model1*/, sofa::core::CollisionModel* /*model2*/, OutputVector* /*contacts*/)
00076     {
00077         return 0;
00078     }
00079 
00080     int endIntersection(sofa::core::CollisionModel* /*model1*/, sofa::core::CollisionModel* /*model2*/, OutputVector* /*contacts*/)
00081     {
00082         return 0;
00083     }
00084 
00085     bool testIntersection(Cube&, Cube&);
00086 
00087     template<class Sphere>
00088     bool testIntersection(Sphere&, Sphere&);
00089     template<class Sphere>
00090     bool testIntersection(Sphere&, Cube&);
00091     template<class Sphere>
00092     bool testIntersection(Ray&, Sphere&);
00093     template<class Sphere>
00094     bool testIntersection(Sphere&, Triangle&);
00095     //bool testIntersection(Triangle&, Triangle&);
00096     bool testIntersection(Triangle&, Line&);
00097     bool testIntersection(Ray&, Triangle&);
00098     bool testIntersection(Ray&, Tetrahedron&);
00099     bool testIntersection(Tetrahedron&, Point&);
00100     bool testIntersection(RigidDistanceGridCollisionElement&, RigidDistanceGridCollisionElement&);
00101     bool testIntersection(RigidDistanceGridCollisionElement&, Point&);
00102     template<class Sphere>
00103     bool testIntersection(RigidDistanceGridCollisionElement&, Sphere&);
00104     bool testIntersection(RigidDistanceGridCollisionElement&, Triangle&);
00105     bool testIntersection(Ray&, RigidDistanceGridCollisionElement&);
00106     bool testIntersection(FFDDistanceGridCollisionElement&, RigidDistanceGridCollisionElement&);
00107     bool testIntersection(FFDDistanceGridCollisionElement&, FFDDistanceGridCollisionElement&);
00108     bool testIntersection(FFDDistanceGridCollisionElement&, Point&);
00109     template<class Sphere>
00110     bool testIntersection(FFDDistanceGridCollisionElement&, Sphere&);
00111     bool testIntersection(FFDDistanceGridCollisionElement&, Triangle&);
00112     bool testIntersection(Ray&, FFDDistanceGridCollisionElement&);
00113     
00114     int computeIntersection(Cube&, Cube&, OutputVector*);
00115     template<class Sphere>
00116     int computeIntersection(Sphere&, Sphere&, OutputVector*);
00117     template<class Sphere>
00118     int computeIntersection(Sphere&, Cube&, OutputVector*);
00119     template<class Sphere>
00120     int computeIntersection(Ray&, Sphere&, OutputVector*);
00121     template<class Sphere>
00122     int computeIntersection(Sphere&, Triangle&, OutputVector*);
00123     //int computeIntersection(Triangle&, Triangle&, OutputVector*);
00124     int computeIntersection(Triangle&, Line&, OutputVector*);
00125     int computeIntersection(Ray&, Triangle&, OutputVector*);
00126     int computeIntersection(Ray&, Tetrahedron&, OutputVector*);
00127     int computeIntersection(Tetrahedron&, Point&, OutputVector*);
00128     int computeIntersection(RigidDistanceGridCollisionElement&, RigidDistanceGridCollisionElement&, OutputVector*);
00129     int computeIntersection(RigidDistanceGridCollisionElement&, Point&, OutputVector*);
00130     template<class Sphere>
00131     int computeIntersection(RigidDistanceGridCollisionElement&, Sphere&, OutputVector*);
00132     int computeIntersection(RigidDistanceGridCollisionElement&, Triangle&, OutputVector*);
00133     int computeIntersection(Ray&, RigidDistanceGridCollisionElement&, OutputVector*);
00134     int computeIntersection(FFDDistanceGridCollisionElement&, RigidDistanceGridCollisionElement&, OutputVector*);
00135     int computeIntersection(FFDDistanceGridCollisionElement&, FFDDistanceGridCollisionElement&, OutputVector*);
00136     int computeIntersection(FFDDistanceGridCollisionElement&, Point&, OutputVector*);
00137     template<class Sphere>
00138     int computeIntersection(FFDDistanceGridCollisionElement&, Sphere&, OutputVector*);
00139     int computeIntersection(FFDDistanceGridCollisionElement&, Triangle&, OutputVector*);
00140     int computeIntersection(Ray&, FFDDistanceGridCollisionElement&, OutputVector*);
00141 
00142 };
00143 
00144 } // namespace collision
00145 
00146 } // namespace component
00147 
00148 } // namespace sofa
00149 
00150 #endif

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