TAPs 0.7.7.3
TAPsAdvSimSupport_DS.hpp
Go to the documentation of this file.
00001 /******************************************************************************
00002 TAPsAdvSimSupport_DS.hpp
00003 ******************************************************************************/
00045 /******************************************************************************
00046 SUKITTI PUNAK   (09/29/2008)
00047 UPDATE          (08/01/2010)
00048 ******************************************************************************/
00049 #ifndef TAPs_ADV_SIM_SUPPORT_DS_HPP
00050 #define TAPs_ADV_SIM_SUPPORT_DS_HPP
00051 
00052 #include <TAPs/Core/TAPsLib.hpp>
00053 
00054 BEGIN_NAMESPACE_TAPs
00055 //=============================================================================
00056 //typedef unsigned int t_TAPsAdvSimID;  //!< typedef for advanced simulation ID (currently used with CUDA only)
00057 //=============================================================================
00058 
00059 
00060 END_NAMESPACE_TAPs
00061 
00062 #include "TAPsListOfAdvSimConsts.hpp"
00063 #include <TAPs/GeometricDataStructure/HalfEdge/TAPsHalfEdgeDataStructure.hpp>
00064 
00065 //#include <TAPs/Support/TAPsAdvSimConstraint.hpp>
00066 #include "AdvSimConstraints/TAPsAdvSimConstraint_HEVertexVsHEVertex.hpp"
00067 #include "AdvSimConstraints/TAPsAdvSimConstraint_ERSutureVsHEVertex.hpp"
00068 
00069 #include <TAPs/OpenGLModel/TAPsModelSuture.hpp>
00070 #include <TAPs/ModelSpecific/TAPsModelForSurgery.hpp>
00071 #include <TAPs/Model/TAPsModelElasticRod.hpp>
00072 #include <TAPs/Model/TAPsModelDefBasedOnFEMTet.hpp>
00073 #include <TAPs/Model/TAPsModelDefBasedOnFEMHex.hpp>
00074 
00075 
00076 BEGIN_NAMESPACE_TAPs
00077 //=============================================================================
00078 template <typename T, typename DATA = unsigned char>
00079 class AdvSimSupport_DS {
00080 //=============================================================================
00081 public:
00082     //=========================================================================
00083     typedef unsigned int    AdvSimID_ERSuture;  
00084     typedef unsigned int    AdvSimID_Model;     
00085     enum ModelType {
00086         MODEL_BASED_ON_MSS,
00087         MODEL_BASED_ON_ER,
00088         MODEL_BASED_ON_FEM,
00089         MODEL_TYPE_UNDEFINED
00090     };
00091     //=========================================================================
00092 
00093     // Member Functions -------------------------------------------------------
00095     friend std::ostream & operator<< ( std::ostream &output, AdvSimSupport_DS<T,DATA> const &obj )
00096     {
00097         output << obj.StrInfo();
00098         return output;
00099     }
00100     //-------------------------------------------------------------------------
00102     AdvSimSupport_DS ();
00104     ~AdvSimSupport_DS ();
00105     //-------------------------------------------------------------------------
00107     std::string StrInfo () const;
00108     //-------------------------------------------------------------------------
00109 
00113     //static int AddModel ( OpenGL::ModelSuture<T> * pModel );
00117     int AddModel ( ModelElasticRod<T> * pModel );
00121     //static int AddModel ( ModelForSurgery<T> * pModel );
00125     int AddModel( ModelDefBasedOnFEM<T,DATA> * pModel );
00126 
00128     void AddVertexConnectionModelAndModel ( 
00129         unsigned int modelA,                        
00130         HEVertex<T> * pVertexA,                     
00131         enum Enum::AddOn::SimConstraints flagsA,    
00132         unsigned int modelB,                        
00133         HEVertex<T> * pVertexB,                     
00134         enum Enum::AddOn::SimConstraints flagsB,    
00135         T forceRatio,           
00136         T forceScaleForModelA,  
00137         T forceScaleForModelB,  
00138         T forceThresholdForModelA = 1.0,    
00139         T forceThresholdForModelB = 1.0     
00140     );
00141 
00143     void AddVertexConnectionERSutureAndModel ( 
00144         unsigned int sutureID,                          
00145         unsigned int vertexIDSuture,                    
00146         //DS::SimulationFlags * simFlagsSuture,         //!< simulation flags of suture
00147         //Vector3<T> * vertexSuture,                        //!< vertex of suture
00148         enum Enum::AddOn::SimConstraints flagsSuture,   
00149         unsigned int modelID,                           
00150         HEVertex<T> * pVvertexModel,                    
00151         enum Enum::AddOn::SimConstraints flagsModel,    
00152         T forceRatio,           
00153         T forceScaleForSuture,  
00154         T forceScaleForModel,   
00155         T forceThresholdForSuture = 1.0,    
00156         T forceThresholdForModel = 1.0      
00157     );
00158 
00159     //-------------------------------------------------------------------------
00160 
00162     inline void EnforceAllConstraints ();
00164     inline void EnforceAllConstraintsOfTwoModels ( int modelA, int modelB );
00166     inline void EnforceAllConstraintsOfERSutureAndModel ( int suture, int model );
00168     inline void EnforceTheConstraintNumberOfTwoModels (
00169         int modelA,                         
00170         Matrix4x4<T> const & TrxModelA,     
00171         Matrix4x4<T> const & InvTrxModelA,  
00172         int modelB,                         
00173         Matrix4x4<T> const & TrxModelB,     
00174         Matrix4x4<T> const & InvTrxModelB,  
00175         unsigned int constraintNumber       
00176     );
00178     inline void EnforceTheConstraintNumberOfERSutureAndModel (
00179         int suture,                         
00180         int model,                          
00181         Matrix4x4<T> const & TrxModel,      
00182         Matrix4x4<T> const & InvTrxModel,   
00183         unsigned int constraintNumber       
00184     );
00185 
00187     void EnforceAllConsistentPositions ();
00189     inline void EnforceAllConsistentPositionsOfTwoModels ( int modelA, int modelB );
00191     inline void EnforceAllConsistentPositionsOfERSutureAndModel ( int suture, int model );
00192 
00194     inline void ClearAllConstraints ();
00196     inline void ClearAllConstraintsOfTwoModels ( int modelA, int modelB );
00198     inline void ClearAllConstraintsOfERSutureAndModel ( int suture, int model );
00200     inline void ClearTheConstraintNumberOfTwoModels ( int modelA, int modelB, unsigned int constraintNumber );
00202     inline void ClearTheConstraintNumberOfERSutureAndModel ( int suture, int model, unsigned int constraintNumber );
00203 
00204     //-------------------------------------------------------------------------
00205 
00207     unsigned int GetNumOfSutureModelsBasedOnMSS ()          { return static_cast<unsigned int>( m_ListOfSutureModelsBasedOnMSS.size() ); }
00209     unsigned int GetNumOfSutureModelsBasedOnER ()           { return static_cast<unsigned int>( m_ListOfSutureModelsBasedOnER.size() ); }
00211     unsigned int GetNumOfModelsForSurgeryBasedOnMSS ()      { return static_cast<unsigned int>( m_ListOfModelsForSurgeryBasedOnMSS.size() ); }
00213     unsigned int GetNumOfSubModelsForSurgeryBasedOnMSS ()   { return static_cast<unsigned int>( m_ListOfHETriMeshOneModelMultiParts.size() ); }
00215     unsigned int GetNumOfModelsForSurgeryBasedOnFEM ()      { return static_cast<unsigned int>( m_ListOfModelsForSurgeryBasedOnFEM.size() ); }
00216 
00218     std::vector< OpenGL::ModelSuture<T> * > &       GetListOfSutureModelsBasedOnMSS ()      { return m_ListOfSutureModelsBasedOnMSS; }
00220     std::vector< ModelElasticRod<T> * > &           GetListOfSutureModelsBasedOnER ()       { return m_ListOfSutureModelsBasedOnER; }
00222     std::vector< ModelForSurgery<T> * > &           GetListOfModelsForSurgeryBasedOnMSS ()  { return m_ListOfModelsForSurgeryBasedOnMSS; }
00224     std::vector< ModelDefBasedOnFEM<T,DATA> * > &   GetListOfModelsForSurgeryBasedOnFEM ()  { return m_ListOfModelsForSurgeryBasedOnFEM; }
00225 
00227     inline std::vector< AdvSimConstraint_HEVertexVsHEVertex<T> * > &    RefToInteractionModelVsModel (
00228         unsigned int modelA, unsigned int modelB )
00229     {
00230         return m_ListOfInteractionModelVsModel[modelA][modelB];
00231     }
00232 
00234     inline std::vector< AdvSimConstraint_ERSutureVsHEVertex<T> * > &    RefToInteractionERBasedSutureVsModel ( 
00235         unsigned int sutureNo )
00236     { return m_ListOfInteractionERSutureVsModel[sutureNo]; }
00237 
00238     //-------------------------------------------------------------------------
00243     void AdvSimAllModels (
00244         T timestep,                                 
00245         bool bEnforceAllConstraints = true,         
00246         bool bEnforceAllConsistentPositions = true  
00247     );
00248 
00253     inline void AdvSimSutureModelBasedOnMSS ( unsigned int sutureID, T timestep );
00258     inline void AdvSimSutureModelBasedOnER ( unsigned int sutureID, T timestep );
00263     inline void AdvSimModelForSurgeryBasedOnMSS ( unsigned int modelID, T timestep );
00268     inline void AdvSimModelForSurgeryBasedOnFEM ( unsigned int modelID, T timestep );
00269 
00270     // Data Members -----------------------------------------------------------
00271 //=============================================================================
00272 protected:
00273     // Member Functions -------------------------------------------------------
00274 
00275 
00276     // Data Members -----------------------------------------------------------
00277 
00278     typedef std::list< PointForce<T> * >    ListOfPointForces;
00279 
00280     // SEMI-EXCLUSIVELY FOR MODELS VS MODELS INTERACTIONS.
00281     // This three std::vector must be managed together! 
00282     // ALSO m_ModelType AND m_ModelLocation ARE USED FOR INTERACTION WITH SUTURES!
00283     std::vector< ModelType >    m_ModelType;        
00284     std::vector< unsigned int > m_ModelLocation;    
00285     std::vector< std::vector< std::vector< AdvSimConstraint_HEVertexVsHEVertex<T> * > > >   m_ListOfInteractionModelVsModel;
00286 
00287     ListOfPointForces   m_ListOfPointForces;    
00288 
00290 
00291     // SEMI-EXCLUSIVELY FOR ER-BASED-SUTURES VS MODELS INTERACTIONS.
00292     std::vector< std::vector< std::vector< AdvSimConstraint_ERSutureVsHEVertex<T> * > > >   m_ListOfInteractionERSutureVsModel; 
00293 
00294     // List of models
00295     std::vector< OpenGL::ModelSuture<T> * > m_ListOfSutureModelsBasedOnMSS;     
00296     std::vector< ModelElasticRod<T> * >     m_ListOfSutureModelsBasedOnER;      
00297     std::vector< ModelForSurgery<T> * >     m_ListOfModelsForSurgeryBasedOnMSS; 
00298     std::vector< OpenGL::HETriMeshOneModelMultiParts<T> * > m_ListOfHETriMeshOneModelMultiParts;    
00299     std::vector< ModelDefBasedOnFEM<T,DATA> * > m_ListOfModelsForSurgeryBasedOnFEM; 
00300 //=============================================================================
00301 private:
00302     // Member Functions -------------------------------------------------------
00303 
00305     int AddModel ();
00306 
00308     int AddERBasedSuture ();
00309 
00310     // Data Members -----------------------------------------------------------
00311 //=============================================================================
00312 
00313 #if defined(__gl_h_) || defined(__GL_H__)
00314 public:
00316     void DrawAllModels ();
00318     void DrawAddedInteractions ();
00319 private:
00321     void DrawAddedInteractionsBetweenTwoModels ( int modelA, int modelB );
00323     void DrawAddedInteractionsBetweenERSutureAndModel ( int suture, int model );
00324 #endif
00325 
00326 //=============================================================================
00327 }; // END CLASS AdvSimSupport_DS
00328 //=============================================================================
00329 END_NAMESPACE_TAPs
00330 //-----------------------------------------------------------------------------
00331 // Include definition if TAPs_USE_EXPORT is not defined
00332 //#if !defined( TAPs_USE_EXPORT )
00333     #include "TAPsAdvSimSupport_DS.cpp"
00334 //#endif
00335 //-----------------------------------------------------------------------------
00336 #endif//TAPs_ADV_SIM_SUPPORT_HPP_DS
00337 //34567890123456789012345678901234567890123456789012345678901234567890123456789
00338 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines