![]() |
TAPs 0.7.7.3
|
00001 /****************************************************************************** 00002 TAPsColDetFns.hpp 00003 ******************************************************************************/ 00045 /****************************************************************************** 00046 SUKITTI PUNAK (07/09/2008) 00047 UPDATE (07/10/2010) 00048 ******************************************************************************/ 00049 #ifndef TAPs_COLLISION_DETECTION_FNS_HPP 00050 #define TAPs_COLLISION_DETECTION_FNS_HPP 00051 00052 //#define TAPs_DEBUG_CD_WITH_HETRI 00053 #ifdef TAPs_DEBUG_CD_WITH_HETRI 00054 #endif//TAPs_DEBUG_CD_WITH_HETRI 00055 00056 #include "../Core/TAPsStdLib.hpp" 00057 #include "../Core/TAPsCGMath.hpp" 00058 //#include "../OpenGLModelFromFile/TAPsReadModels.hpp" 00059 //#include "../Support/TAPsTransformationSupport.hpp" 00060 00061 //#include "TAPsCDLib.hpp" 00062 00063 // The included files listed below are expected to be included somewhere before 00064 // this file. If a file is not included, then functions that need the objects 00065 // defined in the file will be excluded from the compilation. 00066 00067 //#include "../OpenGLModel/TAPsModelStrand.hpp" 00068 //#include "../OpenGLModel/TAPsModelSuture.hpp" 00069 //#include "../OpenGLModel/TAPsDeformMesh.hpp" 00070 //#include "../Model/TAPsModelElasticRod.hpp" 00071 00072 00073 #include "CDSupport/TAPsCDFnsGlobalStuff.hpp" 00074 00075 #include "TAPsColDetFns_NEW.hpp" 00076 00077 00078 BEGIN_NAMESPACE_TAPs__CD__Fn 00079 //============================================================================= 00080 00081 00082 // CD(R) for Strand with MBV 00083 //----------------------------------------------------------------------------- 00084 #if ( defined TAPs_STRAND_MODEL_HPP && defined TAPs_MULTI_BOUNDING_VOLUME_HPP ) 00085 00092 template <typename T> 00093 bool CDR_Strand_vs_MBV ( 00094 TAPs::OpenGL::ModelStrand<T> * pStrandObj, 00095 TAPs::MultiBoundingVolume<T> const * const pMBVObj, 00096 TAPs::TransformationSupport<T> const * const pTransform 00097 ); 00098 00099 namespace Private { 00101 template <typename T> 00102 bool CD ( 00103 TAPs::OpenGL::ModelStrand<T> * pStrandObj, 00104 TAPs::BVHTree<T> const * const pObjBVH, 00105 TAPs::TransformationSupport<T> const * const pTransform, 00106 std::vector< BVHNode< T > * > * listOfSutureCollidedNodes, 00107 std::vector< BVHNode< T > * > * listOfObjectCollidedNodes 00108 ); 00109 00111 template <typename T> 00112 bool CR ( 00113 TAPs::OpenGL::ModelStrand<T> * pStrandObj, 00114 TAPs::BVHTree<T> const * const pObjBVH, 00115 TAPs::TransformationSupport<T> const * const pTransform, 00116 std::vector< BVHNode< T > * > * listOfSutureCollidedNodes, 00117 std::vector< BVHNode< T > * > * listOfObjectCollidedNodes 00118 ); 00119 } // END: namespace Private 00120 00122 template <typename T> 00123 bool CDR ( 00124 TAPs::OpenGL::ModelStrand<T> * pStrandObj, 00125 TAPs::BVHTree<T> const * const pObjBVH, 00126 TAPs::TransformationSupport<T> const * const pTransform 00127 ) 00128 { 00129 std::vector< BVHNode< T > * > listOfSutureCollidedNodes; 00130 std::vector< BVHNode< T > * > listOfObjectCollidedNodes; 00131 if ( !Private::CD( pStrandObj, pObjBVH, pTransform, &listOfSutureCollidedNodes, &listOfObjectCollidedNodes ) ) { 00132 return false; 00133 } 00134 return Private::CR( pStrandObj, pObjBVH, pTransform, &listOfSutureCollidedNodes, &listOfObjectCollidedNodes ); 00135 } 00136 #endif//#if ( defined TAPs_STRAND_MODEL_HPP && defined TAPs_MULTI_BOUNDING_VOLUME_HPP ) 00137 //----------------------------------------------------------------------------- 00138 00139 00140 // CD(R) for Suture with MBV 00141 //----------------------------------------------------------------------------- 00142 #if ( defined TAPs_SUTURE_MODEL_HPP && defined TAPs_MULTI_BOUNDING_VOLUME_HPP ) 00143 00150 template <typename T> 00151 bool CDR_Suture_vs_MBV ( 00152 TAPs::OpenGL::ModelSuture<T> * pSutureObj, 00153 TAPs::MultiBoundingVolume<T> const * const pMBVObj, 00154 TAPs::TransformationSupport<T> const * const pTransform 00155 ); 00156 #endif//#if ( defined TAPs_SUTURE_MODEL_HPP && defined TAPs_MULTI_BOUNDING_VOLUME_HPP ) 00157 //----------------------------------------------------------------------------- 00158 00159 00160 // CD(R) for Strand and Suture with DeformMesh 00161 //----------------------------------------------------------------------------- 00162 #if ( defined TAPs_STRAND_MODEL_HPP && defined TAPs_DEFORM_MESH_HPP ) 00163 00170 template <typename T> 00171 bool CDR_Strand_vs_DeformMesh ( 00172 TAPs::OpenGL::ModelStrand<T> * pStrandObj, 00173 TAPs::DeformMesh<T> const * const pDeformMeshObj 00174 ); 00175 #endif//#if ( defined TAPs_STRAND_MODEL_HPP && defined TAPs_DEFORM_MESH_HPP ) 00176 00177 #if ( defined TAPs_SUTURE_MODEL_HPP && defined TAPs_DEFORM_MESH_HPP ) 00178 00185 template <typename T> 00186 bool CDR_Suture_vs_DeformMesh ( 00187 TAPs::OpenGL::ModelSuture<T> * pSutureObj, 00188 TAPs::DeformMesh<T> const * const pDeformMeshObj 00189 ); 00190 #endif//#if ( defined TAPs_SUTURE_MODEL_HPP && defined TAPs_DEFORM_MESH_HPP ) 00191 //----------------------------------------------------------------------------- 00192 00193 00194 // CD(R) for DeformMesh with MBV 00195 //----------------------------------------------------------------------------- 00196 #if ( defined TAPs_DEFORM_MESH_HPP && defined TAPs_MULTI_BOUNDING_VOLUME_HPP ) 00197 00204 template <typename T> 00205 bool CDR_DeformMesh_vs_MBV ( 00206 TAPs::DeformMesh<T> * pDeformMeshObj, 00207 TAPs::MultiBoundingVolume<T> const * const pMBVObj, 00208 TAPs::TransformationSupport<T> const * const pTransform 00209 ); 00210 #endif//#if ( defined TAPs_DEFORM_MESH_HPP && defined TAPs_MULTI_BOUNDING_VOLUME_HPP ) 00211 //----------------------------------------------------------------------------- 00212 00213 00214 // CD(R) for Polygonal Mesh Model with an implicit object 00215 //----------------------------------------------------------------------------- 00216 #ifdef TAPs_IMPLICIT_OBJECT_HPP 00217 #endif//TAPs_IMPLICIT_OBJECT_HPP 00218 //----------------------------------------------------------------------------- 00219 00220 00221 // CD(R) for Polygonal Mesh Model with BV 00222 //----------------------------------------------------------------------------- 00223 #ifdef TAPs_BOUNDING_VOLUME_HPP 00224 00232 //template <typename T> 00233 //bool CDR_PolygonalMesh_vs_BV ( 00234 // TAPs::OpenGL::PolygonalModel<T> * pPolygonalMeshObj, //!< a PolygonalModel object 00235 // TAPs::BoundingVolume<T> const * const pBVObj //!< a bounding volume object 00236 //); 00237 00246 //template <typename T> 00247 //bool CDR_PolygonalMesh_vs_BV ( 00248 // TAPs::OpenGL::XPolygonalModel<T> * pPolygonalMeshObj, //!< an XPolygonalModel object 00249 // TAPs::BoundingVolume<T> const * const pBVObj //!< a bounding volume object 00250 //); 00251 00260 template <typename T> 00261 bool CDR_PolygonalMesh_vs_BV ( 00262 TAPs::OpenGL::HalfEdgeModel<T> * pPolygonalMeshObj, 00263 TAPs::BoundingVolume<T> const * const pBVObj 00264 ); 00265 00274 template <typename T> 00275 bool CDR_PolygonalMesh_vs_BV ( 00276 TAPs::OpenGL::HETriMeshOneModelMultiParts<T> * pPolygonalMeshObj, 00277 TAPs::BoundingVolume<T> const * const pBVObj 00278 , TAPs::Vector3<T> * totalForce = NULL 00279 , T gain = 1.0 00280 ); 00281 00282 #endif//TAPs_BOUNDING_VOLUME_HPP 00283 //----------------------------------------------------------------------------- 00284 00285 00286 // CD(R) for Polygonal Mesh Model with a Line Segment 00287 //----------------------------------------------------------------------------- 00295 //template <typename T> 00296 //bool CD_PolygonalMesh_vs_LineSegment ( 00297 // TAPs::OpenGL::PolygonalModel<T> * pPolygonalMeshObj, //!< a PolygonalModel object 00298 // TAPs::Vector3<T> const * const ptA, //!< the starting point of a line segment 00299 // TAPs::Vector3<T> const * const ptB, //!< the ending point of a line segment 00300 // std::vector< TAPs::Vector3<T> > * listOfIntersectedPoints, //!< O/P: list of intersected points 00301 // std::vector< TAPs::Face<T>* > * listOfIntersectedFaces, //!< O/P: list of intersected faces 00302 // std::vector< TAPs::Vertex<T>* > * listOfClosestVertices //!< O/P: list of closest vertices 00303 //); 00304 00312 //template <typename T> 00313 //bool CD_PolygonalMesh_vs_LineSegment ( 00314 // TAPs::OpenGL::XPolygonalModel<T> * pPolygonalMeshObj, //!< an XPolygonalModel object 00315 // TAPs::Vector3<T> const * const ptA, //!< the starting point of a line segment 00316 // TAPs::Vector3<T> const * const ptB, //!< the ending point of a line segment 00317 // std::vector< TAPs::Vector3<T> > * listOfIntersectedPoints, //!< O/P: list of intersected points 00318 // std::vector< TAPs::Face<T>* > * listOfIntersectedFaces, //!< O/P: list of intersected faces 00319 // std::vector< TAPs::XVertex<T>* > * listOfClosestVertices //!< O/P: list of closest vertices 00320 //); 00321 00329 template <typename T> 00330 bool CD_PolygonalMesh_vs_LineSegment ( 00331 TAPs::OpenGL::HalfEdgeModel<T> * pPolygonalMeshObj, 00332 TAPs::Vector3<T> const * const ptA, 00333 TAPs::Vector3<T> const * const ptB, 00334 std::vector< TAPs::Vector3<T> > * listOfIntersectedPoints, 00335 std::vector< TAPs::HEFace<T>* > * listOfIntersectedFaces, 00336 std::vector< TAPs::HEVertex<T>* > * listOfClosestVertices 00337 ); 00338 00349 template <typename T> 00350 bool CD_PolygonalMesh_vs_LineSegment ( 00351 TAPs::OpenGL::HalfEdgeModel<T> * pPolygonalMeshObj, 00352 TAPs::Vector3<T> const * const ptA, 00353 TAPs::Vector3<T> const * const ptB, 00354 std::vector< TAPs::Vector3<T> > * listOfIntersectedPoints, 00355 std::vector< TAPs::HEFace<T>* > * listOfIntersectedFaces, 00356 std::vector< TAPs::HEVertex<T>* > * listOfClosestVertices, 00357 std::vector< T > * listOfRatios, 00358 std::vector< T > * listOfIntersectionAngles 00359 ); 00360 //----------------------------------------------------------------------------- 00361 00362 00363 // CD(R) for Polygonal Mesh Model with MBV 00364 //----------------------------------------------------------------------------- 00365 #ifdef TAPs_MULTI_BOUNDING_VOLUME_HPP 00366 00374 //template <typename T> 00375 //bool CDR_PolygonalMesh_vs_MBV ( 00376 // TAPs::OpenGL::PolygonalModel<T> * pPolygonalMeshObj, //!< a PolygonalModel object 00377 // TAPs::MultiBoundingVolume<T> const * const pMBVObj //!< a multi bounding volume object 00378 //); 00379 //template <typename T> 00380 //bool CDR_PolygonalMesh_vs_MBV ( 00381 // TAPs::OpenGL::XPolygonalModel<T> * pPolygonalMeshObj, //!< an XPolygonalModel object 00382 // TAPs::MultiBoundingVolume<T> const * const pMBVObj //!< a multi bounding volume object 00383 //); 00384 template <typename T> 00385 bool CDR_PolygonalMesh_vs_MBV ( 00386 TAPs::OpenGL::HalfEdgeModel<T> * pPolygonalMeshObj, 00387 TAPs::MultiBoundingVolume<T> const * const pMBVObj 00388 ); 00389 template <typename T> 00390 bool CDR_PolygonalMesh_vs_MBV ( 00391 TAPs::OpenGL::HETriMeshOneModelMultiParts<T> * pPolygonalMeshObj, 00392 TAPs::MultiBoundingVolume<T> const * const pMBVObj 00393 , TAPs::Vector3<T> * totalForce = NULL 00394 , T gain = 1.0 00395 ); 00396 00405 template <typename T> 00406 bool CDRigid_PolygonalMesh_vs_MBV ( 00407 TAPs::OpenGL::HalfEdgeModel<T> * pPolygonalMeshObj, 00408 TAPs::MultiBoundingVolume<T> const * const pMBVObj 00409 ); 00410 template <typename T> 00411 bool CDRigid_PolygonalMesh_vs_MBV ( 00412 TAPs::OpenGL::HETriMeshOneModelMultiParts<T> * pPolygonalMeshObj, 00413 TAPs::MultiBoundingVolume<T> const * const pMBVObj 00414 , TAPs::Vector3<T> * totalForce = NULL 00415 , T gain = 1.0 00416 ); 00417 00418 #endif//TAPs_MULTI_BOUNDING_VOLUME_HPP 00419 //----------------------------------------------------------------------------- 00420 00421 00422 // CD(R) for a Deformable Polygonal Mesh Model with a Rigid Polygonal Mesh Model 00423 //----------------------------------------------------------------------------- 00432 template <typename T> 00433 bool CDR_DeformPolygonalMesh_vs_RigidPolygonalMesh ( 00434 TAPs::OpenGL::HalfEdgeModel<T> * pDefPolyMesh, 00435 TAPs::OpenGL::HalfEdgeModel<T> const * const pRigidPolyMesh 00436 ); 00437 //----------------------------------------------------------------------------- 00438 00439 00440 // CD(R) for a Deformable Polygonal Mesh Model with another Deformable Polygonal Mesh Model 00441 //----------------------------------------------------------------------------- 00450 //template <typename T> 00451 //bool CDR_DeformPolygonalMesh_vs_DeformPolygonalMesh ( 00452 // TAPs::OpenGL::HalfEdgeModel<T> * const pDefPolyMesh_1, //!< the 1st deformable polygonal mesh model 00453 // TAPs::OpenGL::HalfEdgeModel<T> * const pDefPolyMesh_2, //!< the 2nd deformable polygonal mesh model 00454 // T deformRatio = 0.5 //!< deformation ratio (must be between [0-1]) where 0 means the model is 100% deformed while the other model is 0% deformed 00455 //); 00456 //----------------------------------------------------------------------------- 00457 00458 00459 // CD(R) for Deformable Multi Mesh Model with a Rigid Polygonal Mesh Model 00460 //----------------------------------------------------------------------------- 00461 //----------------------------------------------------------------------------- 00462 00463 00464 // CD(R) for a Deformable Polygonal Mesh Model with another Deformable Polygonal Mesh Model 00465 //----------------------------------------------------------------------------- 00466 //----------------------------------------------------------------------------- 00467 00468 00469 // CD(R) for a Deformable Multi Mesh Model with another Deformable Multi Mesh Model 00470 //----------------------------------------------------------------------------- 00471 //----------------------------------------------------------------------------- 00472 00473 00474 // CD for a Polygonal Mesh Model with another Polygonal Mesh Model 00475 //----------------------------------------------------------------------------- 00483 //template <typename T> 00484 //bool CD_PolygonalMesh_vs_PolygonalMesh ( 00485 // TAPs::OpenGL::HalfEdgeModel<T> const * const pPolyMesh_1, //!< the 1st PolygonalModel object 00486 // TAPs::OpenGL::HalfEdgeModel<T> const * const pPolyMesh_2, //!< the 2nd PolygonalModel object 00487 // Vector3<T> & returnVec // ... 00488 //); 00489 //----------------------------------------------------------------------------- 00490 00491 00492 00493 00494 //============================================================================= 00495 END_NAMESPACE_TAPs__CD__Fn 00496 //----------------------------------------------------------------------------- 00497 #include "TAPsColDetFns.cpp" 00498 //----------------------------------------------------------------------------- 00499 #endif 00500 //34567890123456789012345678901234567890123456789012345678901234567890123456789 00501 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----