TAPs 0.7.7.3
TAPsHEFace.hpp
Go to the documentation of this file.
00001 /******************************************************************************
00002 TAPsHEFace.hpp
00003 
00004 HE <==> Half-Edge
00005 HEFace class is a class for 3D half-edge Face.
00006 It contains:
00007   - normal
00008   - vertex loop
00009   - texture coordinates for the vertex loop
00010   - incident half-edge
00011 It should contain a set of pointers to its vertices in CCW order.
00012 Example:
00013            2-------1
00014             \       \
00015              \       \
00016               \       0
00017                \     /
00018                 \   /
00019                  \ /
00020                   3
00021 
00022 Not supposed to be a parent class.
00023 Support only manifold objects.
00024 
00025 SUKITTI PUNAK   (04/04/2005)
00026 UPDATE          (10/26/2010)
00027 ******************************************************************************/
00028 #ifndef TAPs_HE_FACE_HPP
00029 #define TAPs_HE_FACE_HPP
00030 
00031 #include <vector>
00032 #include "../../Core/TAPsLib.hpp"
00033 
00034 template <typename T> class HEHalfEdge;
00035 template <typename T> class HEVertex;
00036 
00037 BEGIN_NAMESPACE_TAPs
00038 //=============================================================================
00039 template <typename T>
00040 class HEFace {
00041 //=============================================================================
00042 protected:
00043     Vector3<T>      m_vNormal;              
00044     HEHalfEdge<T>  *nIncidentHalfEdge;      
00045     HEFace<T> *nPrev;   
00046     HEFace<T> *nNext;   
00047 
00048 #ifdef  TAPs_SUPPORT_ASE_FORMAT
00049     unsigned char   m_iSubmatID;            
00050 #endif//TAPs_SUPPORT_ASE_FORMAT
00051 
00052 #ifdef  TAPs_ENABLE_FACE_VERTEX_COLOR
00053     std::vector<int> m_sviVertexColorList;  
00054 #endif//TAPs_ENABLE_FACE_VERTEX_COLOR
00055 
00056 #ifdef  TAPs_ENABLE_FACE_VERTEX_TEXTURE_COORDINATES
00057     std::vector<int> m_sviVertexTextureList;    
00058 #else //TAPs_ENABLE_FACE_VERTEX_TEXTURE_COORDINATES
00059     std::vector<T>  m_2DTexCoordsVector;        
00060 #endif//TAPs_ENABLE_FACE_VERTEX_TEXTURE_COORDINATES
00061 
00062 //=============================================================================
00063 public:
00064     //-------------------------------------------------------------------------
00065     // Output Operator <<
00066     friend std::ostream & operator<< ( std::ostream &output, HEFace<T> const &f )
00067     {
00068         output  << "HEFace<" << typeid(T).name() << "> has ";
00069 //              << f.m_ptrVertexLoopVector.size() << " vertices:";
00070         //------------------------------------------------------------
00071         // Output vertex loop
00072 //      for ( int i = 0; i < f.m_ptrVertexLoopVector.size(); ++i )
00073 //      {
00074 //          output << "  " << *(f.m_ptrVertexLoopVector[i]);
00075 //      }
00076         //------------------------------------------------------------
00077         // Output normal
00078         output << "  with Normal:" << f.m_vNormal;
00079         //------------------------------------------------------------
00080         // Output texture coordinates
00081         #ifdef  TAPs_ENABLE_FACE_VERTEX_TEXTURE_COORDINATES
00082             output << "\n  it has m_sviVertexTextureList of size " << f.m_sviVertexTextureList.size();
00083         #else //TAPs_ENABLE_FACE_VERTEX_TEXTURE_COORDINATES
00084             output << "\n  and 2-D Texture Coordinates (" 
00085                    << static_cast<int>(f.m_2DTexCoordsVector.size()) << "):";
00086             for ( int i = 0; i < static_cast<int>(f.m_2DTexCoordsVector.size()); ++i )
00087             {
00088                 output << "  " << f.m_2DTexCoordsVector[i];
00089             }
00090         #endif//TAPs_ENABLE_FACE_VERTEX_TEXTURE_COORDINATES
00091         //------------------------------------------------------------
00092         // Output incident half-edge
00093         output << "\n  and Incident half-edge:" << f.nIncidentHalfEdge;
00094         return output;
00095     }
00096     //-------------------------------------------------------------------------
00097     // Constructors and destructor
00098 
00100     HEFace ( Vector3<T> normal = Vector3<T>() );
00102     HEFace ( HEHalfEdge<T> * const incidentHalfEdge );
00104     HEFace ( HEFace<T> const &he );
00106     virtual ~HEFace ();
00107 
00108     //-------------------------------------------------------------------------
00109     // Fn(s) for Normal
00110 
00112     inline void SetNormal( Vector3<T> normal )  { m_vNormal = normal; }
00114     inline void SetNormal( T x, T y, T z )  { m_vNormal.SetXYZ( x, y, z ); }
00116     inline Vector3<T> const & GetNormal() const { return m_vNormal; }
00117 
00118     //-------------------------------------------------------------------------
00119     // Member Access for Texture Coordinates
00120     inline int  GetNoTexCoords() const;
00121     inline int  GetNumTexCoords() const     { return GetNoTexCoords(); }
00122     inline T    GetTexCoordNoS( int i ) const;
00123     inline T    GetTexCoordNoT( int i ) const;
00124     inline void GetTexCoordNoS( int i, T &s ) const;
00125     inline void GetTexCoordNoT( int i, T &t ) const;
00126     inline void SetTexCoordNoS( int i, T s );
00127     inline void SetTexCoordNoT( int i, T t );
00128     inline void GetTexCoordNo( int i, T &s, T &t ) const;
00129     inline void SetTexCoordNo( int i, T s, T t );
00130     inline T    GetTexCoordHalfNo( int i ) const;
00131     inline void GetTexCoordHalfNo( int i, T &v ) const;
00132     inline void SetTexCoordHalfNo( int i, T v );
00133     inline void InsertTexCoordNo( int i, T s, T t );
00134     inline void AppendTexCoord( T s, T t );
00135     inline void RemoveTexCoordNo( int i );
00136     //-------------------------------------------------------------------------
00137 #ifdef  TAPs_SUPPORT_ASE_FORMAT
00138 
00139     inline void          SetMaterialID ( unsigned char id ) { m_iSubmatID = id; }
00141     inline unsigned char GetMaterialID () const             { return m_iSubmatID; }
00142 #endif//TAPs_SUPPORT_ASE_FORMAT
00143 
00144 #ifdef  TAPs_ENABLE_FACE_VERTEX_COLOR
00145     inline void InitVertexColorList( int i );
00146     inline int  GetVertexColorNo( int i ) const;
00147     inline void SetVertexColorNo( int i, int vNo );
00148 #endif//TAPs_ENABLE_FACE_VERTEX_COLOR
00149 
00150 #ifdef  TAPs_ENABLE_FACE_VERTEX_TEXTURE_COORDINATES
00151     inline void InitVertexTextureList( int i );
00152     inline int  GetVertexTextureNo( int i ) const;
00153     inline void SetVertexTextureNo( int i, int vNo );
00154 #endif//TAPs_ENABLE_FACE_VERTEX_TEXTURE_COORDINATES
00155 
00156     //-------------------------------------------------------------------------
00157     // Member Access for Incident Half-Edge
00158     inline void IncidentHalfEdge( HEHalfEdge<T> * const incidentHalfEdge )
00159     { nIncidentHalfEdge = incidentHalfEdge; }
00160     inline HEHalfEdge<T> * IncidentHalfEdge() const
00161     { return nIncidentHalfEdge; }
00162     //-------------------------------------------------------------------------
00163     // Operations
00164 
00166     inline HEFace<T> * Prev () const { return nPrev; }
00168     inline HEFace<T> * Next () const { return nNext; }
00170     inline void Prev ( HEFace<T> * const v ) { nPrev = v; }
00172     inline void Next ( HEFace<T> * const v ) { nNext = v; }
00173 
00175     HEFace<T> * Insert ( HEFace<T> * const n );
00177     HEFace<T> * Remove ();
00179     inline void Delete ();
00181     HEFace<T> * Splice ( HEFace<T> * const n );
00182 
00183     //-------------------------------------------------------------------------
00184     // Data Conversion(s) / Operation(s)
00185 
00187     int CountNumberOfVertices () const;
00189     std::vector< HEVertex<T> * const >          GetPtrsToVertices ();
00191     std::vector< HEVertex<T> const * const >    GetPtrsToVertices () const;
00193     std::vector< HEVertex<T> * const >          GetPtrsToVerticesAndNumberOfVertices ( int & numberOfVertices );
00195     std::vector< HEVertex<T> const * const >    GetPtrsToVerticesAndNumberOfVertices ( int & numberOfVertices ) const;
00197     std::vector< HEVertex<T> * const >          GetPtrsToVertices ( int i );
00199     std::vector< HEVertex<T> const * const >    GetPtrsToVertices ( int i ) const;
00201     std::vector< Vector3<T> >   GetCopyOfVertexPositions () const;
00203     std::vector< Vector3<T> >   GetCopyOfVertexPositions ( int i ) const;
00204 
00205     //-------------------------------------------------------------------------
00206 }; // END CLASS HEFace
00207 //=============================================================================
00208 END_NAMESPACE_TAPs
00209 //-----------------------------------------------------------------------------
00210 // Include definition if TAPs_USE_EXPORT is not defined
00211 //#if !defined( TAPs_USE_EXPORT )
00212     #include "TAPsHEFace.cpp"
00213 //#endif
00214 //-----------------------------------------------------------------------------
00215 #endif
00216 //345678901234567890123456789012345678901234567890123456789012345678901234567890
00217 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines