TAPs 0.7.7.3
TAPsSimPropForMultiPartMeshModel_HalfEdge.hpp
Go to the documentation of this file.
00001 /******************************************************************************
00002 TAPsSimPropForMultiPartMeshModel_HalfEdge.hpp
00003 
00004 SimPropForMultiPartMeshModel_HalfEdge class (hpp file).
00005 
00006 SUKITTI PUNAK   (07/28/2008)
00007 UPDATE          (10/07/2009)
00008 ******************************************************************************/
00009 #ifndef TAPs_SIM_PROP_FOR_MULTI_PART_MESH_MODEL_HALF_EDGE_HPP
00010 #define TAPs_SIM_PROP_FOR_MULTI_PART_MESH_MODEL_HALF_EDGE_HPP
00011 
00012 #include "TAPsSimPropForMultiPartMeshModel.hpp"
00013 
00014 #include "TAPsHEVertexPtrWithExtraInfo.hpp"
00015 #include "../../Simulation/TAPsListOfODESolvers.hpp"
00016 
00017 BEGIN_NAMESPACE_TAPs
00018 //=============================================================================
00019 template <typename T>
00020 class SimPropForMultiPartMeshModel_HalfEdge : public /*virtual*/ SimPropForMultiPartMeshModel<T> {
00021 //=============================================================================
00022     // Member Functions -------------------------------------------------------
00024     friend std::ostream & operator<< ( 
00025         std::ostream &output, SimPropForMultiPartMeshModel_HalfEdge<T> const &obj )
00026     {
00027         output << obj.StrInfo();
00028         return output;
00029     }
00030 
00031 //=============================================================================
00032 public:
00033     // Member Functions -------------------------------------------------------
00034 
00036     SimPropForMultiPartMeshModel_HalfEdge ( 
00037         T massOfPoint       = 1,            
00038         T springStiffness   = 1,            
00039         T springDamper      = 1,            
00040         TAPs::Enum::ModelType modelType = TAPs::Enum::MODEL_DEFORM, 
00041         T predefinedTimeStep    = 0.01,     
00042         int numSimSubSteps      = 10,       
00043         bool enableColDet       = true,     
00044         bool enableSimulation   = true      
00045     );
00046 
00048     //SimPropForMultiPartMeshModel_HalfEdge ( SimPropForMultiPartMeshModel_HalfEdge<T> const &obj );
00049 
00051     ~SimPropForMultiPartMeshModel_HalfEdge ();
00052 
00054     //inline SimPropForMultiPartMeshModel_HalfEdge<T> & operator= ( 
00055     //  SimPropForMultiPartMeshModel_HalfEdge<T> const &obj );
00056 
00058     virtual std::string StrInfo () const;
00059 
00060     // Get number of states
00061     int Size () const   { return m_iStateSize; }
00062 
00064     std::vector< HEVertexPtrWithExtraInfo<T> * > const &    GetVertexList () const  { return m_HEVertexPtrList; }
00065     std::vector< HEVertexPtrWithExtraInfo<T> * > &          GetVertexList ()        { return m_HEVertexPtrList; }
00066 
00068     std::vector< SpringRef<T> * > const &   GetSpringList () const  { return m_vpSpringRef; }
00069     std::vector< SpringRef<T> * > &         GetSpringList ()        { return m_vpSpringRef; }
00070 
00071     //===============================================================
00072     // For simulation by ODE solver
00073     //---------------------------------------------------------------
00075     void ClearAllForces ();
00077     bool SetODESolver ( TAPs::Enum::ODESolver solverMethod );
00079     void AdvSim ( T tCurrent, T tNext );
00081     void AdvSim ( T tCurrent )
00082     { AdvSim( tCurrent, tCurrent +  GetPredefinedTimeStep() ); }
00083     //---------------------------------------------------------------
00084 
00086     void UpdateStateToArray ()
00087     {
00088         if ( GetModelType() == TAPs::Enum::MODEL_DEFORM ) {
00089             StateToArray( &(*xEnd)[0] );
00090         }
00091     }
00092 
00093     // CUDA ---------------------------------------------------------
00094 #ifdef  TAPs_USE_CUDA
00095 
00096     bool CUDA_Initialize ();
00097     void CUDA_Cleanup ();
00098     void CUDA_CopyVertexToMem ();
00099     void CUDA_CopyMemToVertex ();
00100 #endif//TAPs_USE_CUDA
00101     // CUDA ---------------------------------------------------------
00102 
00103     // Data Members -----------------------------------------------------------
00104 //=============================================================================
00105 protected:
00106     // Member Functions -------------------------------------------------------
00107 
00108     //===============================================================
00109     // For simulation by ODE solver
00110     //---------------------------------------------------------------
00111     // REMARK:  DxDt has to be static so that it can be passed to 
00112     // ODESolver Fn.
00113     // But we don't want StateToArray and ArrayToState be static.
00114     // Therefore, we need to pass userData, i.e. this pointer
00115     // as a void pointer.
00116     static bool DxDt (  
00117         T                       dt,         // i/p: time step
00118         Simulation::VectorSet<T> &  x,      // i/p: array  x = {pos, vel}
00119         Simulation::VectorSet<T> &  xdot,   // o/p: array xdot = {vel, accel}
00120         void *                  userData    // o/p: array of user data
00121     );
00122     //---------------------------------------------------------------
00123     void StateToArray ( T *dst );           // copy states to dst array
00124     void ArrayToState ( T *src );           // copy src array to states
00125     void DdtStateToArray ( T *xdot, T dt ); // copy d/dt states to dst (xdot) array
00126     //---------------------------------------------------------------
00127 
00129     //void Clear ();
00130 
00131     // Data Members -----------------------------------------------------------
00132 
00134     //-----------------------------------------------------
00135     std::vector< SpringRef<T> * >                   m_vpSpringRef;      
00136     std::vector< HEVertexPtrWithExtraInfo<T> * >    m_HEVertexPtrList;  
00137 
00138 #ifdef  TAPs_USE_CUDA
00139     float *             m_cudaVertexList;       
00140     //unsigned int * 
00141 #endif//TAPs_USE_CUDA
00142 
00143     //===============================================================
00144     // For simulation by ODE solver
00145     //---------------------------------------------------------------
00146     TAPs::Simulation::ODESolver<T> *    m_prODESolver;  
00147     Simulation::VectorSet<T> *          x0;             
00148     Simulation::VectorSet<T> *          xEnd;           
00149     Simulation::VectorSet<T>            xData_1;        
00150     Simulation::VectorSet<T>            xData_2;        
00151     int m_iStateSize;       
00152     int m_iLimitStepCount;  
00153     //---------------------------------------------------------------
00154 
00155 //=============================================================================
00156 private:
00157     // Member Functions -------------------------------------------------------
00158     // Data Members -----------------------------------------------------------
00159 //=============================================================================
00160 }; // END CLASS SimPropForMultiPartMeshModel_HalfEdge
00161 //=============================================================================
00162 //-----------------------------------------------------------------------------
00166 typedef SimPropForMultiPartMeshModel_HalfEdge<int>    SimPropForMultiPartMeshModel_HalfEdgei;
00167 typedef SimPropForMultiPartMeshModel_HalfEdge<float>  SimPropForMultiPartMeshModel_HalfEdgef;
00168 typedef SimPropForMultiPartMeshModel_HalfEdge<double> SimPropForMultiPartMeshModel_HalfEdged;
00169 //=============================================================================
00170 END_NAMESPACE_TAPs
00171 //-----------------------------------------------------------------------------
00172 // Include definition if TAPs_USE_EXPORT is not defined
00173 // If the class is template, use this
00174 //#if !defined( TAPs_USE_EXPORT )
00175     #include "TAPsSimPropForMultiPartMeshModel_HalfEdge.cpp"
00176 //#endif
00177 
00178 // If the class is NOT template, use this
00179 //#if !defined( TAPs_USE_EXPORT )
00180 //  #include "TAPsSimPropForMultiPartMeshModel_HalfEdge.cpp"
00181 //#endif
00182 //-----------------------------------------------------------------------------
00183 #endif
00184 //34567890123456789012345678901234567890123456789012345678901234567890123456789
00185 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines