TAPs 0.7.7.3
TAPsVertexRings2.hpp
Go to the documentation of this file.
00001 /******************************************************************************
00002 TAPsVertexRings.hpp
00003 
00004 VertexRings class is a class for generic 3D vertex rings.
00005 
00006 Definition:
00007 ===========
00008 The data structure is similar to the data structure for sparse matrices:
00009     std::vector<int> m_viRingLayers contains the size of each ring:
00010         +-+-+-+-+ ... +-+-+
00011         |0|a|b|c| ... |k|n|
00012         +-+-+-+-+ ... +-+-+
00013         where a   is the number of vertices in the zeroth ring,
00014               b-a is the number of vertices in the first ring,
00015               c-b is the number of vertices in the second ring and so on,
00016               n-k is the number of vertices in the last ring.
00017         The number of rings is m_viRingLayers.size()-2.
00018     std::vector<int> m_viRingVertices contains the list of vertices:
00019         +-+-+-+-+ ... +-+
00020         |i|j|k|l| ... |m|
00021         +-+-+-+-+ ... +-+
00022         where each character represents the vertex number in a mesh model.
00023     Need to known the number of vertices and pointers to the first vertex ring 
00024     of each vertex.
00025     e.g. in class XPolygonalModel has this vertex ring property (data member)
00026          std::vector<int> * m_pviVertexRing1List;   // neighbor vertices in ring 1
00027 
00028 SUKITTI PUNAK   (11/18/2004)
00029 UPDATE          (11/18/2004)
00030 ******************************************************************************/
00031 #ifndef TAPs_VERTEX_RINGS_HPP
00032 #define TAPs_VERTEX_RINGS_HPP
00033 
00034 #include "../Core/TAPsStdLib.hpp"
00035 #include <vector>
00036 
00037 BEGIN_NAMESPACE_TAPs
00038 //=============================================================================
00039 class VertexRings {
00040 //=============================================================================
00041 protected:
00042     int *   m_paiRingLayers;        // contains the size of each layer
00043     int     m_iSizeOfRingLayers;    // size of ring layers
00044     int *   m_paiRingVertices;      // contains the list of ring vertices
00045     int     m_iSizeOfRingVertices;  // size of ring vertices
00046     int *   m_paiVertexNo;          // contains the current step (size must be m_iNoVertices)
00047     int     m_iNoVertices;          // Number of Vertices
00048     int     m_iCurruntStep;         // [0,std::numeric_limits<int>::max()] 
00049                                     // then will be reset to zero and 
00050                                     // m_paiVertexNo will be reset to zeroes.
00051 
00052     // This pointer points to the first vertex ring of each vertex, must be known 
00053     // in advanced in order to use this VertexRings operations
00054     // e.g. in class XPolygonalModel has this vertex ring property (data member)
00055     //   std::vector<int> * m_pviVertexRing1List;   // neighbor vertices in ring 1
00056     std::vector<int> const * m_pviVertexRing1List;
00057 //=============================================================================
00058 public:
00059     //-------------------------------------------------------------------------
00060     // Output Operator <<
00061     friend std::ostream & operator<< ( std::ostream &output, VertexRings const &vr )
00062     {
00063         //------------------------------------------------------------
00064         // Display Vertex Rings
00065         output  << "VertexRings";
00066         //------------------------------------------------------------
00067         // Display Face Ring
00068         for ( int i = 0; i < static_cast<int>(vr.m_viRingLayers.size())-1; ++i ) {
00069             output << "\n  Ring#" << i << ":";
00070             for ( int j = vr.m_viRingLayers[i]; j < vr.m_viRingLayers[i+1]; ++j ) {
00071                 output << " " << vr.m_viRingVertices[j];
00072             }
00073         }
00074         return output;
00075     }
00076     //-------------------------------------------------------------------------
00077     // Constructors
00078     VertexRings ( std::vector<int> const * const pviVertexRing1List = NULL );   // default constructor
00079     virtual ~VertexRings ();    // destructor
00080     //-------------------------------------------------------------------------
00081     // Get/Set Fn(s)
00082     inline void SetExternalVertexRingInfo ( std::vector<int> * pviVertexRing1List )
00083         { m_pviVertexRing1List = pviVertexRing1List; }
00084     inline std::vector<int> & GetRingLayers()   { return m_viRingLayers; };
00085     inline std::vector<int> & GetRingVertices() { return m_viRingVertices; };
00086     inline int GetNoRings () const  { return static_cast<int>(m_viRingLayers.size())-2; }
00087     //void SetRingLayers ( std::vector<int> faceRing )      { m_viFaceRing = faceRing; }
00088     inline int GetSizeOfRingNo ( int i ) const 
00089         { return m_viRingLayers[i]-m_viRingLayers[i-1]; }
00090     //==========================================================================
00091     // OPERATIONS
00092     //-------------------------------------------------------------------------
00093     // Set vertex#i to the list of zeroth ring
00094     inline bool SetVertex ( int i );
00095     //-------------------------------------------------------------------------
00096     // Set vertices to the list of zeroth ring
00097         // v[] is the list of vertices to be set
00098         // size is the size of the list
00099     inline bool SetVertices ( int v[], int size );
00100     //-------------------------------------------------------------------------
00101     // Add vertex#i to the list of zeroth ring
00102     //inline bool AddVertex ( int i );
00103     //-------------------------------------------------------------------------
00104     // Add vertices to the list of zeroth ring
00105         // v[] is the list of vertices to be added
00106         // size is the size of the list
00107     //inline bool AddVertices ( int v[], int size );
00108     //-------------------------------------------------------------------------
00109     // Increase one layer
00110     inline bool IncreaseOneLayer ();
00111     //-------------------------------------------------------------------------
00112     // Decrease one layer
00113     inline bool DecreaseOneLayer ();
00114     //-------------------------------------------------------------------------
00115     // Assignment Operator
00116 private:
00117     inline VertexRings & operator= ( VertexRings const &vr ) {}
00118     //-------------------------------------------------------------------------
00119 }; // END CLASS VertexRings
00120 //=============================================================================
00121 END_NAMESPACE_TAPs
00122 //-----------------------------------------------------------------------------
00123 // Include definition if TAPs_USE_EXPORT is not defined
00124 #if !defined( TAPs_USE_EXPORT )
00125     #include "TAPsVertexRings.cpp"
00126 #endif
00127 //-----------------------------------------------------------------------------
00128 #endif
00129 //345678901234567890123456789012345678901234567890123456789012345678901234567890
00130 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines