TAPs 0.7.7.3
TAPsHalfEdgeTrigonalModel.hpp
Go to the documentation of this file.
00001 /******************************************************************************
00002 TAPsHalfEdgeTrigonalModel.hpp
00003 
00004 --------------------------------------------------------------------------
00005 From HalfEdgeModel class:
00006 =========================
00007 A Polygonal Model based on half-edge data structure contains:
00008     HEVertexList<T> *m_listVertex;      // HEVertex in a list
00009     HEFaceList<T>   *m_listFace;        // HEFace in a list
00010     HEFaceList<T>   *m_listHoleFace;    // Hole HEFace in a list
00011 
00012     A hole face represents a hole in the surface.
00013 --------------------------------------------------------------------------
00014 
00015 HalfEdgeTrigonalModel, a subclass of HalfEdgeModel, is for a triangular mesh.
00016 
00017 SUKITTI PUNAK   (06/15/2006)
00018 UPDATE          (06/15/2006)
00019 ******************************************************************************/
00020 #ifndef TAPs_HALF_EDGE_TRIGONAL_MODEL_HPP
00021 #define TAPs_HALF_EDGE_TRIGONAL_MODEL_HPP
00022 
00023 #include "TAPsHalfEdgeModel.hpp"
00024 
00025 /*==============================================================================
00026 Half-Edge Data Structure:
00027 =========================
00028 HEVertex class is a class for 3D half-edge vertex.
00029   - position
00030   - normal
00031   - incident half-edge
00032 HEFace class is a class for 3D half-edge Face.
00033   - normal
00034   - vertex loop (in CCW order)
00035   - texture coordinates for the vertex loop
00036   - incident half-edge
00037 HEHalfEdge class is a class for 3D half-edge.
00038   - originating vertex
00039   - incident face
00040   - pair of this half-edge
00041   - next half-edge (CCW)
00042   - previous half-edge (CW)
00043                                                       *
00044                                                       *
00045                           E2                          *
00046              V3 <--------------------- V2             *
00047               \                        /\             *
00048                \                      /               *
00049              E3 \         F0      E1 /                *
00050                  \                  /                 *
00051                   \                /                  *
00052                   _\/     E0      /                   *
00053                     V0 --------> V1                   *
00054                                                       *
00055                                                       *
00056                          |                            *
00057                    \_    |    _/                      *
00058                      \_  |  _/                        *
00059                        \ | /                          *
00060                 -------- V --------                   *
00061                       _/ | \_                         *
00062                     _/   |   \_                       *
00063                    /     |     \                      *
00064                          |                            *
00065                                                       *
00066                                                       *
00067 ==============================================================================*/
00068 
00069 
00070 BEGIN_NAMESPACE_TAPs__OpenGL
00071 //=============================================================================
00072 template <typename T>
00073 class HalfEdgeTrigonalModel : public /*virtual*/ HalfEdgeModel<T> {
00074     //-------------------------------------------------------------------------
00075     // (Friend Fn) put it through ostream
00076     friend std::ostream & operator<< ( std::ostream &output, HalfEdgeTrigonalModel<T> const &o )
00077     {
00078         output  << "\n===========================\n"
00079                 <<   "TAPs::HalfEdgeTrigonalModel<"
00080                 << typeid(T).name() << "> Class:\n"
00081                 <<   "===========================\n";
00082         //----------------------------------------------------------------
00083         if ( o.GetName() != NULL ) {
00084             output << "Name: " << o.GetName() << "\n";
00085         }
00086         //----------------------------------------------------------------
00087         // Vertex Nodes
00088         output  << "Vertices " << o.m_listVertex->Size() << "\n";
00089         /*
00090         int i;
00091         i = 0;
00092         HEVertex<T> *vertex = o.m_listVertex->Head();
00093         output << "\n{";
00094         while ( vertex ) {
00095             output << "\n  #" << ++i << "\t" << *vertex;
00096             vertex = vertex->Next();
00097         }
00098         output  << "\n}";
00099         //*/
00100         //----------------------------------------------------------------
00101         // Face Nodes
00102         output  << "Faces " << o.m_listFace->Size() << "\n";
00103         /*
00104         i = 0;
00105         HEFace<T> *face = o.m_listFace->Head();
00106         output << "\n{";
00107         while ( face ) {
00108             output << "\n  #" << ++i << "\t" << *face;
00109             face = face->Next();
00110         }
00111         output  << "\n}";
00112         //*/
00113         //----------------------------------------------------------------
00114         // Hole Face Nodes
00115         output  << "Hole Faces " << o.m_listHoleFace->Size() << "\n";
00116         /*
00117         i = 0;
00118         face = o.m_listHoleFace->Head();
00119         output << "\n{";
00120         while ( face ) {
00121             output << "\n  #" << ++i << "\t" << *face;
00122             face = face->Next();
00123         }
00124         output  << "\n}";
00125         //*/
00126         //----------------------------------------------------------------
00127         return output;
00128     }
00129 //-----------------------------------------------------------------------------
00130 // Member Functions ------------------------------------------------------------
00131 public:
00132     //-------------------------------------------------------------------------
00133     // default constructor
00134     HalfEdgeTrigonalModel ();
00135     //-------------------------------------------------------------------------
00136     // destructor
00137     virtual ~HalfEdgeTrigonalModel ();
00138     //-------------------------------------------------------------------------
00139     // Virtual Fns from Model class
00140     virtual void Initialize ();
00141 //  virtual T GetMaxHalfLength () const;    // get half length
00142 //  virtual void TransformByTranslationRatationAndScale ();
00143     //-------------------------------------------------------------------------
00144     // Calculate and set the normals
00145     virtual void CalAndSetNormals();
00146 protected:
00147     //-------------------------------------------------------------------------
00148     // Helper Fn(s)
00149     virtual inline void CalAndSetFaceNormalsNotNormalized ();
00150     virtual inline void NormalizeFaceNormals ();
00151     //virtual inline void DetermineFaceRings ();
00152     virtual inline void CalAndSetVertexNormals ();
00153     //-------------------------------------------------------------------------
00154     // Virtual Fns from Collision Detection from ColDetSupport class <-----
00155     // OpenGLModel class
00156 //  virtual void CalBoundingAABB ();        // AABB for the whole object
00157 //  virtual void CalBoundingEllipsoid ();   // Ellipsoid for the whole object
00158 //  virtual void CalBoundingSphere ();      // Sphere for the whole object
00159 public:
00160     virtual void BuildBVHTree ( TAPs::Enum::CD treeType ); // Create BVHTree
00161     //-------------------------------------------------------------------------
00162 public:
00163     //-------------------------------------------------------------------------
00164     // Get/Set Fn(s)
00165 //  inline HEVertexList<T> * const GetVertexList() const { return m_listVertex; }
00166 //  inline HEFaceList<T>   * const GetFaceList()   const { return m_listFace; }
00167 //  inline HEFaceList<T>   * const GetHoleFaceList()   const { return m_listHoleFace; }
00168 //  inline void SetVertexList( HEVertexList<T> *p ) { m_listVertex = p; }
00169 //  inline void SetFaceList  ( HEFaceList<T>   *p ) { m_listFace   = p; }
00170 //  inline void SetHoleFaceList  ( HEFaceList<T>   *p ) { m_listHoleFace   = p; }
00171     //-------------------------------------------------------------------------
00172     // Get/Set Vertex
00173 //  void AddVertex ();
00174     //void DelVertex ();
00175     //-------------------------------------------------------------------------
00176     // Get/Set Face
00177 //  void AddFace ();
00178     //void DelFace ();
00179     //-------------------------------------------------------------------------
00180     // Get/Set HalfEdge
00181 //  void AddHalfEdge ();
00182     //void DelHalfEdge ();
00183     //-------------------------------------------------------------------------
00184 //-----------------------------------------------------------------------------
00185 // Data Members  ---------------------------------------------------------------
00186 protected:
00187     //----------------------------------------------------------------
00188     // Geometric Surface Data
00189 //  HEVertexList<T> * m_listVertex;     // HEVertex in a list
00190 //  HEFaceList<T>   * m_listFace;       // HEFace in a list
00191 //  HEFaceList<T>   * m_listHoleFace;   // Hole HEFace in a list
00192     //----------------------------------------------------------------
00193     // For Fast Access (e.g. for OpenGL Drawing)
00194 //  std::vector< Vector3<T> * > m_vListOfVertexPositions;
00195 //  std::vector< Vector3<T> * > m_vListOfVertexNormals;
00196 public:
00197 //  std::vector< Vector3<T> * > &   GetListOfVertexPositions ()
00198 //      { return m_vListOfVertexPositions; }
00199 //  std::vector< Vector3<T> * > &   GetListOfVertexNormals () 
00200 //      { return m_vListOfVertexNormals; }
00201 //  void SetListOfVertexPositionsAndNormals ();
00202 //-----------------------------------------------------------------------------
00203 }; // CLASS END: HalfEdgeTrigonalModel *****************************************
00204 //=============================================================================
00205 END_NAMESPACE_TAPs__OpenGL
00206 //-----------------------------------------------------------------------------
00207 // Include definition if TAPs_USE_EXPORT is not defined
00208 //#if !defined( TAPs_USE_EXPORT )
00209     #include "TAPsHalfEdgeTrigonalModel.cpp"
00210 //#endif
00211 //-----------------------------------------------------------------------------
00212 #endif
00213 //345678901234567890123456789012345678901234567890123456789012345678901234567890
00214 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines