00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
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* , sofa::core::CollisionModel* , OutputVector* )
00076 {
00077 return 0;
00078 }
00079
00080 int endIntersection(sofa::core::CollisionModel* , sofa::core::CollisionModel* , OutputVector* )
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
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
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 }
00145
00146 }
00147
00148 }
00149
00150 #endif