TAPs 0.7.7.3
TAPsAdvSimConstraints.hpp
Go to the documentation of this file.
00001 /******************************************************************************
00002 TAPsAdvSimConstraints.hpp
00003 ******************************************************************************/
00007 /******************************************************************************
00008 SUKITTI PUNAK   (03/16/2011)
00009 UPDATE          (03/31/2011)
00010 ******************************************************************************/
00011 #ifndef TAPs_ADV_SIM_CONSTRAINTS_HPP
00012 #define TAPs_ADV_SIM_CONSTRAINTS_HPP
00013 
00014 #include <TAPs/Model/TAPsModelElasticRod.hpp>
00015 
00016 BEGIN_NAMESPACE_TAPs
00017 //=============================================================================
00018 
00019 
00020 //-----------------------------------------------------------------------------
00024 template <typename T>
00025 class AdvSimConstraint_ConstrainedPoint {
00026 public:
00028     AdvSimConstraint_ConstrainedPoint ();
00029 
00031     AdvSimConstraint_ConstrainedPoint ( AdvSimConstraint_ConstrainedPoint<T> const &orig );
00032 
00034     AdvSimConstraint_ConstrainedPoint<T> & operator= ( AdvSimConstraint_ConstrainedPoint<T> const &orig );
00035 
00036     // Destructor
00037     ~AdvSimConstraint_ConstrainedPoint ();
00038 
00040     std::string StrInfo () const;
00041 
00042     int         PointID;            
00043     Vector3<T>  HomePosition;       
00044     Vector3<T>  TargetPosition;     
00045 };
00046 //-----------------------------------------------------------------------------
00047 
00048 
00049 //-----------------------------------------------------------------------------
00053 template <typename T>
00054 class AdvSimConstraint_GroupOfConstrainedPoints {
00055 public:
00057     AdvSimConstraint_GroupOfConstrainedPoints ();
00058 
00060     AdvSimConstraint_GroupOfConstrainedPoints ( AdvSimConstraint_GroupOfConstrainedPoints<T> const &orig );
00061 
00063     AdvSimConstraint_GroupOfConstrainedPoints<T> & operator= ( AdvSimConstraint_GroupOfConstrainedPoints<T> const &orig );
00064 
00065     // Destructor
00066     ~AdvSimConstraint_GroupOfConstrainedPoints ();
00067 
00069     std::string StrInfo () const;
00070 
00072     void AddConstrainedPoint ( AdvSimConstraint_ConstrainedPoint<T> & CPt = AdvSimConstraint_ConstrainedPoint<T>() )
00073     {
00074         ListOfConstrainedPoints.push_back( CPt );
00075     }
00076 
00078     AdvSimConstraint_ConstrainedPoint<T> & ConstrainedPoint ( unsigned int i ) const
00079     {
00080         assert( i < ListOfConstrainedPoints.size() );
00081         return ListOfConstrainedPoints[i];
00082     }
00083 
00085     AdvSimConstraint_ConstrainedPoint<T> & ConstrainedPoint ( unsigned int i )
00086     {
00087         assert( i < ListOfConstrainedPoints.size() );
00088         return ListOfConstrainedPoints[i];
00089     }
00090 
00091     std::vector< AdvSimConstraint_ConstrainedPoint<T> > ListOfConstrainedPoints;    
00092     int     ModelID;    
00093     T       Ratio;      
00094 
00095 
00096 #if defined(__gl_h_) || defined(__GL_H__)
00097 public:
00099     virtual void Draw ( Vector3<T> & color = Vector3<T>(1,0,0), T PtSize = 20 ) const;
00100 #endif
00101 };
00102 //-----------------------------------------------------------------------------
00103 
00104 
00105 //-----------------------------------------------------------------------------
00109 template <typename T>
00110 class AdvSimConstraint_ConstrainedER {
00111 public:
00113     AdvSimConstraint_ConstrainedER () : pModelER( NULL ) {}
00114 
00116     ~AdvSimConstraint_ConstrainedER () {}
00117 
00118     ModelElasticRod<T> * pModelER;                  
00119     std::vector< unsigned int > ListOfCPtsGrpIDs;   
00120     //std::vector< T >          ListOfRatios;       //!< the ratio of the enforcement; 0 means the suture points strictly follow the constrained points
00121 };
00122 //-----------------------------------------------------------------------------
00123 
00124 
00125 //=============================================================================
00126 template <typename T>
00127 class AdvSimConstraints {
00128 //=============================================================================
00129 public:
00130 
00131     typedef std::vector< AdvSimConstraint_ConstrainedPoint<T> >         VectorOfCPts;
00132     typedef std::vector< AdvSimConstraint_GroupOfConstrainedPoints<T> > VectorOfCPtGroups;
00133 
00134     typedef std::vector< AdvSimConstraint_ConstrainedER<T> >    VectorOfConstrainedERs;
00135 
00136     // Member Functions -------------------------------------------------------
00138     friend std::ostream & operator<< ( std::ostream &output, AdvSimConstraints<T> const &obj )
00139     {
00140         output << obj.StrInfo();
00141         return output;
00142     }
00143 
00144     //-------------------------------------------------------------------------
00146     AdvSimConstraints ();
00147 
00149     //AdvSimConstraints ( AdvSimConstraints<T> const &orig );
00150 
00152     ~AdvSimConstraints ();
00153     //-------------------------------------------------------------------------
00155     std::string StrInfo () const;
00156     //-------------------------------------------------------------------------
00158     //AdvSimConstraints<T> & operator= ( AdvSimConstraints<T> const &orig );
00159 
00160     //-------------------------------------------------------------------------
00161     // Get/Set Functions
00162 
00164     const VectorOfCPtGroups & RefToListOfConstrainedPtGrps () const { return m_ListOfConstrainedPtGrps; }
00166     VectorOfCPtGroups   & RefToListOfConstrainedPtGrps ()           { return m_ListOfConstrainedPtGrps; }
00167 
00169     AdvSimConstraint_GroupOfConstrainedPoints<T> & RefToConstrainedPtGrp ( unsigned int i ) const
00170     {
00171         assert( i < m_ListOfConstrainedPtGrps.size() );
00172         return m_ListOfConstrainedPtGrps[i];
00173     }
00174 
00176     AdvSimConstraint_GroupOfConstrainedPoints<T> & RefToConstrainedPtGrp ( unsigned int i )
00177     {
00178         assert( i < m_ListOfConstrainedPtGrps.size() );
00179         return m_ListOfConstrainedPtGrps[i];
00180     }
00181 
00185     unsigned int AddConstrainedPointGroup ( AdvSimConstraint_GroupOfConstrainedPoints<T> & CPtsGrp = AdvSimConstraint_GroupOfConstrainedPoints<T>() )
00186     {
00187         m_ListOfConstrainedPtGrps.push_back( CPtsGrp );
00188         return m_ListOfConstrainedPtGrps.size() - 1;
00189     }
00190 
00191     //-------------------------------------------------------------------------
00192     // ModelElasticRod
00193 
00197     unsigned int AddConstrainedModelER (
00198         ModelElasticRod<T> & ModelER    
00199     );
00200 
00202     void AssociateCPtsGrpWithModelER (
00203         unsigned int CPtsGrp_ID,    
00204         unsigned int ModelER_ID     
00205     );
00206 
00207     //-------------------------------------------------------------------------
00208     // Functions for Advanced Simulation
00209 
00211     inline void EnforceAllConstrainedModels_A ();
00213     inline void EnforceAllConstrainedModels_B ();
00215     inline void EnforceAllConstrainedModels_B__ByForce ( Vector3<T> & Force = Vector3<T>(1,1,1) );
00216 
00218     inline void EnforceAllConstrainedModelERs_A ();
00220     inline void EnforceAllConstrainedModelERs_B ();
00222     inline void EnforceAllConstrainedModelERs_B__ByForce ( Vector3<T> & Force = Vector3<T>(1,1,1) );
00223 
00224 
00226     void ClearAllConstraints ();
00227 
00228     // Data Members -----------------------------------------------------------
00229 //=============================================================================
00230 protected:
00231     // Member Functions -------------------------------------------------------
00232 
00234     inline void EnforceConstrainedModelER_A (
00235         AdvSimConstraint_ConstrainedER<T> & ConstrainedER   
00236     );
00237 
00239     inline void EnforceConstraints_A (
00240         ModelElasticRod<T> * pER,   
00241         int groupID     
00242     );
00244     inline void EnforceConstraints_B (
00245         ModelElasticRod<T> * pER,   
00246         int groupID     
00247     );
00249     inline void EnforceConstraints_B__ByForce (
00250         ModelElasticRod<T> * pER,   
00251         int groupID,                
00252         Vector3<T> & Force          
00253     );
00254 
00256     inline void EnforceConstraints_A__NotForMultiGrp (
00257         ModelElasticRod<T> * pER,   
00258         int groupID     
00259     );
00261     inline void EnforceConstraints_B__NotForMultiGrp (
00262         ModelElasticRod<T> * pER,   
00263         int groupID     
00264     );
00265 
00267     void ClearAllConstriantsOnERatID ( unsigned int ERid );
00268 
00269     // Data Members -----------------------------------------------------------
00270     VectorOfCPtGroups       m_ListOfConstrainedPtGrps;  
00271     VectorOfConstrainedERs  m_ListOfConstrainedERs;     
00272 //=============================================================================
00273 private:
00274     // Member Functions -------------------------------------------------------
00275     // Data Members -----------------------------------------------------------
00276 //=============================================================================
00277 
00278 #if defined(__gl_h_) || defined(__GL_H__)
00279 public:
00281     virtual void Draw ( Vector3<T> & color = Vector3<T>(1,0,0), T PtSize = 20 ) const;
00282 #endif
00283 
00284 //=============================================================================
00285 }; // END CLASS AdvSimConstraints
00286 //=============================================================================
00287 END_NAMESPACE_TAPs
00288 //-----------------------------------------------------------------------------
00290 #include "TAPsAdvSimConstraints.cpp"
00291 
00293 // Include definition if TAPs_USE_EXPORT is not defined
00294 //#if !defined( TAPs_USE_EXPORT )
00295 //  #include "TAPsAdvSimConstraints.cpp"
00296 //#endif
00297 //-----------------------------------------------------------------------------
00298 #endif
00299 //34567890123456789012345678901234567890123456789012345678901234567890123456789
00300 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines