TAPs 0.7.7.3
TAPsCDFnsForInteractionPointGroup.cpp
Go to the documentation of this file.
00001 /******************************************************************************
00002 TAPsCDFnsForInteractionPointGroup.cpp
00003 SUKITTI PUNAK   (08/27/2010)
00004 UPDATE          (09/07/2010)
00005 ******************************************************************************/
00006 #include "TAPsCDFnsForInteractionPointGroup.hpp"
00007 // Using Inclusion Model (i.e. definitions are included in declarations)
00008 //                       (this name.cpp is included in name.hpp)
00009 // Each friend is defined directly inside its declaration.
00010 
00011 #ifdef  TAPs_INTERACTION_POINT_GROUP_HPP
00012 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00013 
00014 BEGIN_NAMESPACE_TAPs__CD__Fn
00015 //=============================================================================
00016 //-----------------------------------------------------------------------------
00017 
00018 
00019 
00020 
00021 #ifdef  TAPs_BOUNDING_VOLUME_HPP
00022 //=============================================================================
00023 //-----------------------------------------------------------------------------
00024 template <typename T>
00025 bool CD_IPGroup_with_BoundingVolume (
00026     InteractionPointGroup<T> * const    pIPG,           
00027     BoundingVolume<T> * const   pBV,                    
00028     std::vector< PointForce<T> > & ListOfPointForces,   
00029     TransformationSupport<T> * const pTrx_BV            
00030 )
00031 {
00032     //---------------------------------------------------------------
00033     // For transforming the BV to world space
00034     TransformationSupport<T> BV_Trx;
00035     // pTrx_BV, if the extra transformation support is provided
00036     if ( pTrx_BV ) {
00037         BV_Trx.RefToMatrixTransform() *= pTrx_BV->GetMatrixTransform();
00038     }
00039     // BV's transformation support
00040     BV_Trx.RefToMatrixTransform() *= pBV->GetTransform().GetMatrixTransform();
00041 
00042     //---------------------------------------------------------------
00043     // CD with BV
00044     Vector3<T> Dist;
00045     std::vector< InteractionPoint<T> >::iterator pt = pIPG->GetTheSetOfInteractionPoints().begin();
00046     int countPF = 0;
00047     int i = 0;
00048     while ( pt != pIPG->GetTheSetOfInteractionPoints().end() ) {
00049         bool bCD = pBV->TestPointLocation( pt->GetPosition(), &BV_Trx, &Dist );
00050         if ( bCD ) {
00051             Vector3<T> Pos = pIPG->GetTheSetOfInteractionPoints()[i].GetPosition();
00052             Vector3<T> Force = Dist;
00053             ListOfPointForces.push_back( PointForce<T>( Pos, Force ) );
00054             ++countPF;
00055         }
00056         ++pt;
00057         ++i;
00058     }
00059 
00060     if ( countPF > 0 ) {
00061         //
00062         // CR can be implemented here!
00063         //
00064         return true;
00065     }
00066     return false;
00067 }
00068 // END: CD_IPGroup_with_BoundingVolume(...)
00069 //-----------------------------------------------------------------------------
00070 //=============================================================================
00071 #endif//TAPs_BOUNDING_VOLUME_HPP
00072 
00073 
00074 
00075 
00076 #ifdef  TAPs_MULTI_BOUNDING_VOLUME_HPP
00077 //=============================================================================
00078 //-----------------------------------------------------------------------------
00079 template <typename T>
00080 bool CD_IPGroup_with_MultiBoundingVolume (
00081     InteractionPointGroup<T> * const    pIPG,           
00082     MultiBoundingVolume<T> * const  pMBV,               
00083     std::vector< PointForce<T> > & ListOfPointForces,   
00084     TransformationSupport<T> * const pTrx_MBV           
00085 )
00086 {
00087     //ListOfPointForces.clear();
00088 
00089     //---------------------------------------------------------------
00090     // For transforming the MBV to world space
00091     TransformationSupport<T> MBV_Trx;
00092     // pTrx_MBV, if the extra transformation support is provided
00093     if ( pTrx_MBV ) {
00094         MBV_Trx.RefToMatrixTransform() *= pTrx_MBV->GetMatrixTransform();
00095     }
00096     // MBV's transformation support
00097     MBV_Trx.RefToMatrixTransform() *= pMBV->GetTransform().GetMatrixTransform();
00098 
00099     //---------------------------------------------------------------
00100     // Traverse the list of bounding volumes
00101     std::vector< BoundingVolume<T> * >::iterator pos = const_cast< MultiBoundingVolume<T> * >( pMBV )->GetBoundingVolumeList().begin();
00102 
00103     int countPF = 0;
00104     while ( pos != pMBV->GetBoundingVolumeList().end() ) {
00105 
00106         Vector3<T> Dist;
00107         std::vector< InteractionPoint<T> >::iterator pt = pIPG->GetTheSetOfInteractionPoints().begin();
00108         int i = 0;
00109         while ( pt != pIPG->GetTheSetOfInteractionPoints().end() ) {
00110             bool bCD = (*pos)->TestSphereLocation( pt->GetPosition(), pt->GetRadius(), &MBV_Trx, &Dist );
00111             if ( bCD ) {
00112                 Vector3<T> Pos = pIPG->GetTheSetOfInteractionPoints()[i].GetPosition();
00113                 Vector3<T> Force = Dist;
00114                 ListOfPointForces.push_back( PointForce<T>( Pos, Force ) );
00115                 ++countPF;
00116             }
00117             ++pt;
00118             ++i;
00119         }
00120         ++pos;  // next bounding volume
00121     }
00122 
00123     if ( countPF > 0 ) {
00124         //
00125         // CR can be implemented here!
00126         //
00127         return true;
00128     }
00129     return false;
00130 }
00131 // END: CD_IPGroup_with_MultiBoundingVolume(...)
00132 //-----------------------------------------------------------------------------
00133 //=============================================================================
00134 #endif//TAPs_MULTI_BOUNDING_VOLUME_HPP
00135 
00136 
00137 
00138 
00139 #ifdef  TAPs_MODEL_DEF_BASED_ON_FEM_HPP
00140 //=============================================================================
00141 //-----------------------------------------------------------------------------
00142 template <typename T, typename DATA>
00143 bool CD_IPGroup_with_ModelDefBasedOnFEM (
00144     InteractionPointGroup<T> * const    pIPG,           
00145     ModelDefBasedOnFEM<T,DATA> * const  pDMFEM,         
00146     std::vector< PointForce<T> > & ListOfPointForces    
00147 )
00148 {
00149     //if ( !pDMFEM->PtrToBVHTreeOfSurfaceMesh() )   return false;
00150     //return pDMFEM->PtrToBVHTreeOfSurfaceMesh()->TestOverlapWithTillLeafNodes( pIPG, ListOfPointForces );
00151     return pDMFEM->PtrToBVHTreeOfSurfaceMesh()->TestOverlapWith( pIPG, ListOfPointForces );
00152 }
00153 // END: CD_IPGroup_with_ModelDefBasedOnFEM(...)
00154 //-----------------------------------------------------------------------------
00155 //=============================================================================
00156 #endif//TAPs_MODEL_DEF_BASED_ON_FEM_HPP
00157 
00158 
00159 
00160 
00161 //-----------------------------------------------------------------------------
00162 //=============================================================================
00163 END_NAMESPACE_TAPs__CD__Fn
00164 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00165 #endif//TAPs_INTERACTION_POINT_GROUP_HPP
00166 //34567890123456789012345678901234567890123456789012345678901234567890123456789
00167 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines