TAPs 0.7.7.3
TAPsXPolygonalModel.hpp
Go to the documentation of this file.
00001 /******************************************************************************
00002 XPolygonalModel.hpp
00003 
00004 (X <==> Extra)
00005 A (Generic) Polygonal Model contains:
00006     char *      m_pcObjectName;     // object name
00007     int         m_iNoVertices;  // # of vertices
00008     int         m_iNoFaces;     // # of faces
00009     int         m_iNoTexCoords; // # of texture coordinates
00010     Vertex<T> * m_prXVertex;        // Vertex pointers
00011     Face<T> *   m_prFace;           // Face pointers
00012     std::vector<int> *  m_pviVertexRing1List;   // neighbor vertices in ring 1
00013 
00014 Each property should be set explicitly except the following:
00015   - m_pcObjectName (is for identification, not important)
00016   - m_iNoTexCoords (must be set if use with texture)
00017 The normal of each m_prXVertex and m_prFace can be calculated by provided fns.
00018 Each m_pviVertexRing1List can also be calculated by provided fns.
00019 
00020 SUKITTI PUNAK   (11/01/2004)
00021 UPDATE          (02/12/2006)
00022 ******************************************************************************/
00023 #ifndef TAPs_XPOLYGONAL_MODEL_HPP
00024 #define TAPs_XPOLYGONAL_MODEL_HPP
00025 
00026 #include "TAPsOpenGLMeshModel.hpp"
00027 #include "../GeometricDataStructure/TAPsXVertex.hpp"
00028 #include "../GeometricDataStructure/TAPsFace.hpp"
00029 
00030 BEGIN_NAMESPACE_TAPs__OpenGL
00031 //=============================================================================
00032 template <typename T>
00033 class XPolygonalModel : public /*virtual*/ OpenGLMeshModel<T> {
00034     //-------------------------------------------------------------------------
00035     // (Friend Fn) put it through ostream
00036     friend std::ostream & operator<< ( std::ostream &output, XPolygonalModel<T> const &o )
00037     {
00038         output  << "\n======================\n"
00039                 <<   "TAPs::XPolygonalModel<"
00040                 << typeid(T).name() << "> Class:\n"
00041                 <<   "======================\n";
00042         //----------------------------------------------------------------
00043         // Vertices Node
00044         output  << "\n\nVertices " << o.m_iNoVertices << "\n{";
00045         for ( int i = 0; i < o.m_iNoVertices; ++i ) {
00046             output << "\n  #" << i << "\t" << o.m_prXVertex[i];
00047         }
00048         output  << "\n}";
00049         //----------------------------------------------------------------
00050         // Neighbor vertex ring#1
00051         if ( o.m_pviVertexRing1List ) {
00052             std::vector<int>::const_iterator iterator;
00053             output  << "\n\nVertexRing1 " << o.m_iNoVertices << "\n{";
00054             for ( int i = 0; i < o.m_iNoVertices; ++i ) {
00055                 output << "\n  #" << i;
00056                 for (   iterator = o.m_pviVertexRing1List[i].begin(); 
00057                         iterator != o.m_pviVertexRing1List[i].end();
00058                         ++iterator )
00059                 {
00060                     output << "\t" << *iterator;
00061                 }
00062             }
00063             output  << "\n}";
00064         }
00065         //----------------------------------------------------------------
00066         // Faces Node
00067         output  << "\n\nFaces " << o.m_iNoFaces  << "\n{";
00068         for ( int i = 0; i < o.m_iNoFaces; ++i ) {
00069             output << "\n  #" << i << "\t" << o.m_prFace[i];
00070         }
00071         output  << "\n}";
00072         return output;
00073     }
00074 //-----------------------------------------------------------------------------
00075 // Member Functions ------------------------------------------------------------
00076 public:
00077     //-------------------------------------------------------------------------
00078     // default constructor
00079     XPolygonalModel ();
00080     //-------------------------------------------------------------------------
00081     // destructor
00082     virtual ~XPolygonalModel ();
00083     //-------------------------------------------------------------------------
00084     // Virtual Fns from Model class
00085     virtual void Initialize ();
00086     virtual T GetMaxHalfLength () const;    // get half length
00087     virtual void ApplyAndResetTransform ();
00088     //-------------------------------------------------------------------------
00089     // Determine and sort the face ring of each vertex
00090     void DetermineAndSortRings();
00091     //-------------------------------------------------------------------------
00092     // Calculate and set the normals
00093     virtual void CalAndSetNormals();
00094 protected:
00095     //-------------------------------------------------------------------------
00096     // Helper Fn(s)
00097     virtual inline void CalAndSetFaceNormalsNotNormalized ();
00098     virtual inline void NormalizeFaceNormals ();
00099     virtual inline void DetermineFaceRings ();
00100     virtual inline void CalAndSetVertexNormals ();
00101     //-------------------------------------------------------------------------
00102     // Virtual Fns from Collision Detection from ColDetSupport class
00103     virtual void CalBoundingAABB ();
00104     virtual void CalBoundingEllipsoid ();
00105     virtual void CalBoundingSphere ();
00106     //-------------------------------------------------------------------------
00107 public:
00108     //-------------------------------------------------------------------------
00109     // Get/Set Fn(s)
00110     inline XVertex<T> * const GetVertexList() const { return m_prXVertex; }
00111     inline Face<T> * const GetFaceList() const { return m_prFace; }
00112     inline void SetVertexList( XVertex<T> *p )  { m_prXVertex = p; }
00113     inline void SetFaceList( Face<T> *p )       { m_prFace = p; }
00114     //-------------------------------------------------------------------------
00115     // New/Delete Fn(s)
00116     inline void NewVertexListByNoVertices ();
00117     inline void NewFaceListByNoFaces ();
00118 //-----------------------------------------------------------------------------
00119 // Data Members  ---------------------------------------------------------------
00120 protected:
00121     XVertex<T> *    m_prXVertex;        // XVertex pointers
00122     Face<T> *       m_prFace;           // Face pointers
00123     std::vector<int> *  m_pviVertexRing1List;   // neighbor vertices in ring 1
00124     //std::vector<int> *    m_pviVertexRing2List;   // neighbor vertices in ring 2
00125 }; // CLASS END: XPolygonalModel ***********************************************
00126 //=============================================================================
00127 END_NAMESPACE_TAPs__OpenGL
00128 //-----------------------------------------------------------------------------
00129 // Include definition if TAPs_USE_EXPORT is not defined
00130 //#if !defined( TAPs_USE_EXPORT )
00131     #include "TAPsXPolygonalModel.cpp"
00132 //#endif
00133 //-----------------------------------------------------------------------------
00134 #endif
00135 //345678901234567890123456789012345678901234567890123456789012345678901234567890
00136 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines