TAPs 0.7.7.3
TAPsHEVertex.hpp
Go to the documentation of this file.
00001 /******************************************************************************
00002 TAPsHEVertex.hpp
00003 ******************************************************************************/
00020 /******************************************************************************
00021 SUKITTI PUNAK   (04/04/2005)
00022 UPDATE          (12/03/2010)
00023 ******************************************************************************/
00024 #ifndef TAPs_HE_VERTEX_HPP
00025 #define TAPs_HE_VERTEX_HPP
00026 
00027 #include "../../Core/TAPsLib.hpp"
00028 #include "../../DataStructure/TAPsFlag.hpp"
00029 #ifdef  TAPs_ADD_DEFORMABLE_MODEL_BASED_ON_FEM
00030     #include "../../GeometricDataStructure/TAPsBaseBarycentricCoordsForVertexRef.hpp"
00031 #endif//TAPs_ADD_DEFORMABLE_MODEL_BASED_ON_FEM
00032 
00033 #include <vector>
00034 
00035 template <typename T> class HEHalfEdge;
00036 
00037 BEGIN_NAMESPACE_TAPs
00038 //=============================================================================
00039 template <typename T>
00040 class HEVertex {
00041 //=============================================================================
00042 protected:
00043 
00044 #ifdef  TAPs_USE_DATA_POOL
00045     T * m_paPosition;   
00046     T * m_paNormal;     
00047 #else //TAPs_USE_DATA_POOL
00048 
00049 //public:
00050 //  int         Counter1;           //!< use for averaging position
00051 //protected:
00052 //  Vector3<T>  m_vPosition_2;      //!< 2nd position used, for example, storing old position
00053 
00054     Vector3<T>  m_vPosition;        
00055     Vector3<T>  m_vNormal;          
00056 
00057 #ifdef  TAPs_ADD_STORED_POSITION
00058     Vector3<T>  m_vStoredPosition;      
00059 #endif//TAPs_ADD_STORED_POSITION
00060 
00061 
00062 #endif//TAPs_USE_DATA_POOL
00063 
00064 #ifdef  TAPs_ADD_DEFORMABLE_MODEL_BASED_ON_FEM
00065     unsigned int    m_id;           
00066     bool            m_bMarked;      
00067     BaseBarycentricCoordsForVertexRef<T> *  m_pBarycentric; 
00068 #endif//TAPs_ADD_DEFORMABLE_MODEL_BASED_ON_FEM
00069 
00070     HEHalfEdge<T> * nIncidentHalfEdge;  
00071     HEVertex<T> *   nPrev;      
00072     HEVertex<T> *   nNext;      
00073 
00074 #ifdef  TAPs_ADVANCED_SIMULATION
00075 public:
00076     DS::SimulationFlags     SimFlags;   
00077 #endif//TAPs_ADVANCED_SIMULATION
00078 
00079 //=============================================================================
00080 public:
00081     //-------------------------------------------------------------------------
00082     // Output Operator <<
00083     friend std::ostream & operator<< ( std::ostream &output, HEVertex<T> const &v )
00084     {
00085         output  << "HEVertex<" << typeid(T).name() << ">( "
00086                 << " with Position:" << v.GetPosition()
00087                 << " Normal:" << v.GetNormal()
00088                 << " and Incident Edge:" << v.nIncidentHalfEdge;
00089 
00090         #ifdef  TAPs_ADD_DEFORMABLE_MODEL_BASED_ON_FEM
00091         if ( v.m_pBarycentric ) {
00092             output << "\nBarycentric: " << v.m_pBarycentric << "\t" << *(v.m_pBarycentric) << "\n";
00093         }
00094         #endif//TAPs_ADD_DEFORMABLE_MODEL_BASED_ON_FEM
00095 
00096         return output;
00097     }
00098     //-------------------------------------------------------------------------
00100     HEVertex ( T x, T y, T z, 
00101                T u, T v, T w,
00102            #ifdef  TAPs_USE_DATA_POOL
00103                T * pPosition,   T * pNormal,
00104            #endif//TAPs_USE_DATA_POOL
00105                HEHalfEdge<T> * const incidentHalfEdge = NULL
00106              );
00108     HEVertex ( Vector3<T> position, Vector3<T> normal,
00109            #ifdef  TAPs_USE_DATA_POOL
00110                 T * pPosition,  T * pNormal,
00111            #endif//TAPs_USE_DATA_POOL
00112                HEHalfEdge<T> * const incidentHalfEdge = NULL
00113              );
00115     HEVertex ( Vector3<T> position,
00116            #ifdef  TAPs_USE_DATA_POOL
00117                 T * pPosition,  T * pNormal,
00118            #endif//TAPs_USE_DATA_POOL
00119                HEHalfEdge<T> * const incidentHalfEdge = NULL
00120              );
00122     HEVertex ( T position[3],
00123            #ifdef  TAPs_USE_DATA_POOL
00124                 T * pPosition,  T * pNormal,
00125            #endif//TAPs_USE_DATA_POOL
00126                HEHalfEdge<T> * const incidentHalfEdge = NULL
00127              );
00129     HEVertex ( T position[3], T normal[3],
00130            #ifdef  TAPs_USE_DATA_POOL
00131                 T * pPosition,  T * pNormal,
00132            #endif//TAPs_USE_DATA_POOL
00133                HEHalfEdge<T> * const incidentHalfEdge = NULL
00134              );
00135 private:
00137     HEVertex ( HEVertex<T> const &v );  
00138 
00139     static unsigned int g_Total;    
00140 public:
00142     virtual ~HEVertex ();
00143     //-------------------------------------------------------------------------
00144     // Get/Set Fn(s)
00145 #ifdef  TAPs_USE_DATA_POOL
00146 
00147     inline void SetPosition( Vector3<T> const & position )
00148     { m_paPosition[0] = position[0];  m_paPosition[1] = position[1];  m_paPosition[2] = position[2]; }
00149     inline void SetPosition( T x, T y, T z )
00150     { m_paPosition[0] = x; m_paPosition[1] = y; m_paPosition[2] = z; }
00151     inline Vector3<T> GetPosition() const
00152     { return Vector3<T>( m_paPosition[0], m_paPosition[1], m_paPosition[2] ); }
00153     inline T * GetProtectedPosition()   { return m_paPosition; }
00154 
00155     inline void SetNormal( Vector3<T> const & normal )
00156     { m_paNormal[0] = normal[0]; m_paNormal[1] = normal[1]; m_paNormal[2] = normal[2]; }
00157     inline void SetNormal( T x, T y, T z )
00158     { m_paNormal[0] = x; m_paNormal[1] = y; m_paNormal[2] = z; }
00159     inline Vector3<T> GetNormal() const
00160     { return Vector3<T>( m_paNormal[0], m_paNormal[1], m_paNormal[2] ); }
00161     inline T * GetPtrToNormal()     { return m_paNormal; }
00162 
00163     //inline Vector3<T> const & RefToPosition () const  { return *m_paPosition; }
00164     //inline Vector3<T>     & RefToPosition ()          { return *m_paPosition; }
00165 
00166 #else //TAPs_USE_DATA_POOL
00167 
00168     //inline void SetPosition_2 ( Vector3<T> const & position_2 )   { m_vPosition_2 = position_2; }
00169     //inline void SetPosition_2 ( T x, T y, T z )                   { m_vPosition_2.SetXYZ( x, y, z ); }
00170     //inline Vector3<T> const & GetPosition_2 () const      { return m_vPosition_2; }
00171     //inline Vector3<T>     & GetProtectedPosition_2 ()     { return m_vPosition_2; }
00172 
00173     inline void SetPosition ( Vector3<T> const & position ) { m_vPosition = position; }
00174     inline void SetPosition ( T x, T y, T z )               { m_vPosition.SetXYZ( x, y, z ); }
00175     inline Vector3<T> const & GetPosition () const          { return m_vPosition; }
00176     inline Vector3<T>       & GetProtectedPosition ()       { return m_vPosition; }
00177 
00178     inline void SetNormal ( Vector3<T> const & normal ) { m_vNormal = normal; }
00179     inline void SetNormal ( T x, T y, T z )             { m_vNormal.SetXYZ( x, y, z ); }
00180     inline Vector3<T> const & GetNormal () const        { return m_vNormal; }
00181     inline Vector3<T>       & GetProtectedNormal ()     { return m_vNormal; }
00182 
00183     inline Vector3<T> const & RefToPosition () const    { return m_vPosition; }
00184     inline Vector3<T>       & RefToPosition ()          { return m_vPosition; }
00185 
00186     #ifdef  TAPs_ADD_STORED_POSITION
00187     inline Vector3<T> const & RefToStoredPosition () const  { return m_vStoredPosition; }
00188     inline Vector3<T>       & RefToStoredPosition ()            { return m_vStoredPosition; }
00189     #endif//TAPs_ADD_STORED_POSITION
00190 
00191 
00192 #endif//TAPs_USE_DATA_POOL
00193     //-------------------------------------------------------------------------
00194     // Get/Set Fn(s)
00195     inline HEHalfEdge<T> * IncidentHalfEdge() const
00196     { return nIncidentHalfEdge; }
00197     inline void IncidentHalfEdge( HEHalfEdge<T> * const incidentHalfEdge )
00198     { nIncidentHalfEdge = incidentHalfEdge; }
00199 
00200 #ifdef  TAPs_ADD_DEFORMABLE_MODEL_BASED_ON_FEM
00201 
00202     inline unsigned int GetID () const  { return m_id; }
00204     inline void SetID ( unsigned int id )   { m_id = id; }
00206     inline unsigned int GetMarkedStatus () const    { return m_bMarked; }
00208     inline void SetMarkedStatus ( bool b )  { m_bMarked = b; }
00210     inline BaseBarycentricCoordsForVertexRef<T> * GetBarycentricPtr ()  { return m_pBarycentric; }
00212     inline void SetBarycentricPtr ( BaseBarycentricCoordsForVertexRef<T> * ptr )    { m_pBarycentric = ptr; }
00213 #endif//TAPs_ADD_DEFORMABLE_MODEL_BASED_ON_FEM
00214 
00216     static inline unsigned int GetTotal ()  { return g_Total; }
00217 
00218     //-------------------------------------------------------------------------
00219     // Position Member Access i.e. return x, y, or z of this vertex position
00220     inline T & operator[] ( int i );
00221     inline T const & operator[] ( int i ) const;
00222     //-------------------------------------------------------------------------
00223     // Operations
00224 
00226     inline HEVertex<T> * Prev () const { return nPrev; }
00228     inline HEVertex<T> * Next () const { return nNext; }
00230     inline void Prev ( HEVertex<T> * const v ) { nPrev = v; }
00232     inline void Next ( HEVertex<T> * const v ) { nNext = v; }
00233 
00235     HEVertex<T> * Insert ( HEVertex<T> * const n );
00237     HEVertex<T> * Remove ();
00239     inline void   Delete ();
00241     HEVertex<T> * Splice ( HEVertex<T> * const n );
00242 
00243     //-------------------------------------------------------------------------
00245     std::vector< HEVertex<T> * >    FindTheFirstRingOfVertices ();
00246     //-------------------------------------------------------------------------
00247 
00248 #if defined(__gl_h_) || defined(__GL_H__)
00249 public:
00251     virtual void Draw () const;
00252 
00253     #ifdef  TAPs_ADD_STORED_POSITION
00254 
00255     virtual void DrawStoredPosition () const;
00256     #endif//TAPs_ADD_STORED_POSITION
00257 
00258 #endif
00259 
00260 }; // END CLASS HEVertex
00261 //=============================================================================
00262 END_NAMESPACE_TAPs
00263 //-----------------------------------------------------------------------------
00264 // Include definition if TAPs_USE_EXPORT is not defined
00265 //#if !defined( TAPs_USE_EXPORT )
00266     #include "TAPsHEVertex.cpp"
00267 //#endif
00268 //-----------------------------------------------------------------------------
00269 #endif
00270 //34567890123456789012345678901234567890123456789012345678901234567890123456789
00271 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines