00001 // Wild Magic Source Code 00002 // David Eberly 00003 // http://www.geometrictools.com 00004 // Copyright (c) 1998-2007 00005 // 00006 // This library is free software; you can redistribute it and/or modify it 00007 // under the terms of the GNU Lesser General Public License as published by 00008 // the Free Software Foundation; either version 2.1 of the License, or (at 00009 // your option) any later version. The license is available for reading at 00010 // either of the locations: 00011 // http://www.gnu.org/copyleft/lgpl.html 00012 // http://www.geometrictools.com/License/WildMagicLicense.pdf 00013 // The license applies to versions 0 through 4 of Wild Magic. 00014 // 00015 // Version: 4.0.0 (2006/06/28) 00016 00017 #ifndef WM4VEMANIFOLDMESH_H 00018 #define WM4VEMANIFOLDMESH_H 00019 00020 #include "Wm4FoundationLIB.h" 00021 #include "Wm4System.h" 00022 00023 namespace Wm4 00024 { 00025 00026 class WM4_FOUNDATION_ITEM VEManifoldMesh 00027 { 00028 public: 00029 // vertex data types 00030 class Vertex; 00031 typedef Vertex* VPtr; 00032 typedef const Vertex* VCPtr; 00033 typedef VPtr (*VCreator)(int); 00034 typedef std::map<int,Vertex*> VMap; 00035 typedef VMap::iterator VMapIterator; 00036 typedef VMap::const_iterator VMapCIterator; 00037 00038 // edge data types 00039 class Edge; 00040 typedef Edge* EPtr; 00041 typedef const Edge* ECPtr; 00042 typedef EPtr (*ECreator)(int,int); 00043 typedef std::map<std::pair<int,int>,Edge*> EMap; 00044 typedef EMap::iterator EMapIterator; 00045 typedef EMap::const_iterator EMapCIterator; 00046 00047 // vertex object 00048 class WM4_FOUNDATION_ITEM Vertex 00049 { 00050 public: 00051 Vertex (int iV); 00052 virtual ~Vertex (); 00053 00054 int V; 00055 EPtr E[2]; 00056 }; 00057 00058 // edge object 00059 class WM4_FOUNDATION_ITEM Edge 00060 { 00061 public: 00062 Edge (int iV0, int iV1); 00063 virtual ~Edge (); 00064 00065 // vertices, listed as a directed edge <V[0],V[1]> 00066 int V[2]; 00067 00068 // adjacent edges 00069 // E[0] points to edge sharing V[0] 00070 // E[1] points to edge sharing V[1] 00071 EPtr E[2]; 00072 }; 00073 00074 00075 // construction and destruction 00076 VEManifoldMesh (VCreator oVCreator = 0, ECreator oECreator = 0); 00077 virtual ~VEManifoldMesh (); 00078 00079 // member access 00080 const VMap& GetVertices () const; 00081 const EMap& GetEdges () const; 00082 00083 // mesh manipulation 00084 EPtr InsertEdge (int iV0, int iV1); 00085 bool RemoveEdge (int iV0, int iV1); 00086 00087 // manifold mesh is closed if each vertex is shared twice 00088 bool IsClosed () const; 00089 00090 void Print (const char* acFilename); 00091 00092 protected: 00093 // vertices 00094 static VPtr CreateVertex (int iV0); 00095 VCreator m_oVCreator; 00096 VMap m_kVMap; 00097 00098 // edges 00099 static EPtr CreateEdge (int iV0, int iV1); 00100 ECreator m_oECreator; 00101 EMap m_kEMap; 00102 }; 00103 00104 } 00105 00106 #include "Wm4VEManifoldMesh.inl" 00107 00108 #endif