Wm4ETManifoldMesh.h
Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 #ifndef WM4ETMANIFOLDMESH_H
00018 #define WM4ETMANIFOLDMESH_H
00019 
00020 #include "Wm4FoundationLIB.h"
00021 #include "Wm4EdgeKey.h"
00022 #include "Wm4TriangleKey.h"
00023 
00024 namespace Wm4
00025 {
00026 
00027 class WM4_FOUNDATION_ITEM ETManifoldMesh
00028 {
00029 public:
00030     
00031     class Edge;
00032     typedef Edge* EPtr;
00033     typedef const Edge* ECPtr;
00034     typedef EPtr (*ECreator)(int,int);
00035     typedef std::map<EdgeKey,Edge*> EMap;
00036     typedef EMap::iterator EMapIterator;
00037     typedef EMap::const_iterator EMapCIterator;
00038 
00039     
00040     class Triangle;
00041     typedef Triangle* TPtr;
00042     typedef const Triangle* TCPtr;
00043     typedef TPtr (*TCreator)(int,int,int);
00044     typedef std::map<TriangleKey,Triangle*> TMap;
00045     typedef TMap::iterator TMapIterator;
00046     typedef TMap::const_iterator TMapCIterator;
00047 
00048     
00049     class WM4_FOUNDATION_ITEM Edge
00050     {
00051     public:
00052         Edge (int iV0, int iV1);
00053         virtual ~Edge ();
00054 
00055         int V[2];
00056         TPtr T[2];
00057     };
00058 
00059     
00060     class WM4_FOUNDATION_ITEM Triangle
00061     {
00062     public:
00063         Triangle (int iV0, int iV1, int iV2);
00064         virtual ~Triangle ();
00065 
00066         
00067         int V[3];
00068 
00069         
00070         
00071         
00072         
00073         EPtr E[3];
00074 
00075         
00076         
00077         
00078         
00079         TPtr T[3];
00080     };
00081 
00082 
00083     
00084     ETManifoldMesh (ECreator oECreator = 0, TCreator oTCreator = 0);
00085     virtual ~ETManifoldMesh ();
00086 
00087     
00088     const EMap& GetEdges () const;
00089     const TMap& GetTriangles () const;
00090 
00091     
00092     TPtr InsertTriangle (int iV0, int iV1, int iV2);
00093     bool RemoveTriangle (int iV0, int iV1, int iV2);
00094 
00095     
00096     bool IsClosed () const;
00097 
00098     void Print (const char* acFilename);
00099 
00100 protected:
00101     
00102     static EPtr CreateEdge (int iV0, int iV1);
00103     ECreator m_oECreator;
00104     EMap m_kEMap;
00105 
00106     
00107     static TPtr CreateTriangle (int iV0, int iV1, int iV2);
00108     TCreator m_oTCreator;
00109     TMap m_kTMap;
00110 };
00111 
00112 } 
00113 
00114 #include "Wm4ETManifoldMesh.inl"
00115 
00116 #endif