TAPs 0.7.7.3
TAPsParticleRef.hpp
Go to the documentation of this file.
00001 /******************************************************************************
00002 TAPsParticleRef.hpp
00003 ******************************************************************************/
00008 /******************************************************************************
00009 SUKITTI PUNAK   (02/24/2006)
00010 UPDATE          (10/08/2010)
00011 ******************************************************************************/
00012 #ifndef TAPs_PARTICLE_REF_HPP
00013 #define TAPs_PARTICLE_REF_HPP
00014 
00015 #include "TAPsParticleBase.hpp"
00016 #include "../GeometricDataStructure/TAPsXVertex.hpp"
00017 #include "../GeometricDataStructure/HalfEdge/TAPsHalfEdgeDataStructure.hpp"
00018 #include <list>
00019 //#include "../Core/TAPsLib.hpp"
00020 
00021 BEGIN_NAMESPACE_TAPs
00022 //=============================================================================
00023 template <typename T>
00024 class ParticleRef : public /*virtual*/ ParticleBase<T> {
00025 //=============================================================================
00026     //-------------------------------------------------------------------------
00027     // Friend Function
00028     friend std::ostream & operator<< ( std::ostream &output, ParticleRef<T> const &P )
00029     {
00030         return output << P.StrInfo();
00031     }
00032 //-----------------------------------------------------------------------------
00033 protected:
00034     // Data Members     ========================================================
00035 #ifdef  TAPs_USE_DATA_POOL
00036     T *             m_refPosit;     // reference to position vector of vertex
00037 #else //TAPs_USE_DATA_POOL
00038     Vector3<T> *    m_refPosit;     // reference to position vector of vertex
00039 #endif//TAPs_USE_DATA_POOL
00040     //-------------------------------------------------------------------------
00041 public:
00042     // Member Functions     ====================================================
00043 
00045     ParticleRef ( 
00046     #ifdef  TAPs_USE_DATA_POOL
00047         T *             ptrPos,             
00048     #else //TAPs_USE_DATA_POOL
00049         Vector3<T> &    vPosition,          
00050     #endif//TAPs_USE_DATA_POOL
00051         bool            fixed = false       
00052     );
00053 
00055     ParticleRef ( 
00056         T                   mass,           
00057     #ifdef  TAPs_USE_DATA_POOL
00058         T *                 ptrPos,         
00059     #else //TAPs_USE_DATA_POOL
00060         Vector3<T> &        vPosition,      
00061     #endif//TAPs_USE_DATA_POOL
00062         Vector3<T> const &  vVelocity,      
00063         Vector3<T> const &  vAcceleration,  
00064         Vector3<T> const &  vForce,         
00065         bool                fixed = false   
00066     );
00067 
00069     ~ParticleRef ();
00070 
00072     //inline ParticleRef<T> & operator= ( ParticleRef<T> const &obj );
00073 
00075     virtual std::string StrInfo () const;
00076 
00077     //-------------------------------------------------------------------------
00078     // Get/Set Functions
00079 
00080 
00081     // Virtual Functions:
00082     // Overrided from ParticleBase<T>
00083 private:
00084     inline virtual Vector3<T> const & RefToNormal () const  { return CGMath<T>::TempVector3; }
00085     inline virtual Vector3<T>       & RefToNormal ()        { return CGMath<T>::TempVector3; }
00086     inline virtual Vector3<T> const & GetNormal () const    { return CGMath<T>::TempVector3; }
00087     inline virtual void SetNormal ( Vector3<T> const & )    {};
00088     inline virtual void SetNormal ( T x, T y, T z )         {};
00089     inline virtual Vector3<T> const & RefToPosition () const    { return CGMath<T>::TempVector3; }
00090     inline virtual Vector3<T>       & RefToPosition ()          { return CGMath<T>::TempVector3; }
00091 
00092 public:
00093 #ifdef  TAPs_USE_DATA_POOL
00094     inline void                 SetRefPosition ( T * ptrPos );
00095     inline Vector3<T> const &   GetPosition () const;               // Overrided from ParticleBase<T>
00096     inline void                 SetPosition ( Vector3<T> const & ); // Overrided from ParticleBase<T>
00097     inline void                 SetPosition ( T x, T y, T z );      // Overrided from ParticleBase<T>
00098 #else //TAPs_USE_DATA_POOL
00099     inline void                 SetRefPosition ( Vector3<T> * ptrPos );
00100     inline Vector3<T> const &   GetPosition () const;               // Overrided from ParticleBase<T>
00101     inline void                 SetPosition ( Vector3<T> const & ); // Overrided from ParticleBase<T>
00102     inline void                 SetPosition ( T x, T y, T z );      // Overrided from ParticleBase<T>
00103 #endif//TAPs_USE_DATA_POOL
00104 
00105     //-------------------------------------------------------------------------
00106     //==========================================================================
00107     // Create Spring Connections for Mesh (Vertex, XVertex, HalfEdge)
00108     //-------------------------------------------------------------------------
00109     // All O/P pointers must be null pointers!
00110     // To avoid memory leak, the O/P pointers must be "delete []" by user.
00111     //--------------------------------------------
00112     // Create Spring Connections for Mesh Vertex
00113     static void ParticlesCreation ( 
00114         Vertex<T> *      meshVertex, // I/P: Mesh Vertex
00115         int *            vertexNo,   // O/P: vertex# associates Mesh Vertex w/ particle#
00116         ParticleRef<T> * particleNo, // O/P: particle#
00117         T                mass = 1    // I/P: mass for each particle
00118     );
00119     //--------------------------------------------
00120     // Create Spring Connections for Mesh Vertex
00121     static void ParticlesCreation ( 
00122         XVertex<T> *     meshVertex, // I/P: Mesh XVertex
00123         int *            vertexNo,   // O/P: vertex# associates Mesh XVertex w/ particle#
00124         ParticleRef<T> * particleNo, // O/P: particle#
00125         T                mass = 1    // I/P: mass for each particle
00126     );
00127     //--------------------------------------------
00128     // Create Spring Connections for Mesh Vertex
00129     static void ParticlesCreation ( 
00130         HEVertexList<T> * meshVertex, // I/P: Mesh HEVertex
00131         std::list<int>  & vertexNo,   // O/P: vertex# associates Mesh HEVertex w/ particle#
00132         ParticleRef<T> *  particleNo, // O/P: particle#
00133         T                 mass = 1    // I/P: mass for each particle
00134     );
00135     //-------------------------------------------------------------------------
00136 private:
00137     // Member Functions -------------------------------------------------------
00138     // Prohibited Functions ===================================================
00139     // Since a ParticleRef refers to a position vector, therefore
00140     // Copy Constructor and Assignment Operator are prohibited!
00141     ParticleRef<T> const & operator= ( ParticleRef<T> const &S )    // assignment operator
00142     {
00143         std::cerr << "ParticleRef<T> operator= must not be used!\n";
00144         exit( 1 );
00145     }
00146     // Data Members -----------------------------------------------------------
00147     //-------------------------------------------------------------------------
00148 }; // END CLASS ParticleRef
00149 //=============================================================================
00150 END_NAMESPACE_TAPs
00151 //-----------------------------------------------------------------------------
00152 // Include definition if TAPs_USE_EXPORT is not defined
00153 //#if !defined( TAPs_USE_EXPORT )
00154     #include "TAPsParticleRef.cpp"
00155 //#endif
00156 //-----------------------------------------------------------------------------
00157 #endif
00158 //345678901234567890123456789012345678901234567890123456789012345678901234567890
00159 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines