Wm4ETManifoldMesh.h

Go to the documentation of this file.
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 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     // edge data types
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     // triangle data types
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     // edge object
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     // triangle object
00060     class WM4_FOUNDATION_ITEM Triangle
00061     {
00062     public:
00063         Triangle (int iV0, int iV1, int iV2);
00064         virtual ~Triangle ();
00065 
00066         // vertices, listed in counterclockwise order (V[0],V[1],V[2])
00067         int V[3];
00068 
00069         // adjacent edges
00070         // E[0] points to edge (V[0],V[1])
00071         // E[1] points to edge (V[1],V[2])
00072         // E[2] points to edge (V[2],V[0])
00073         EPtr E[3];
00074 
00075         // adjacent triangles
00076         //   T[0] points to triangle sharing edge E[0]
00077         //   T[1] points to triangle sharing edge E[1]
00078         //   T[2] points to triangle sharing edge E[2]
00079         TPtr T[3];
00080     };
00081 
00082 
00083     // construction and destruction
00084     ETManifoldMesh (ECreator oECreator = 0, TCreator oTCreator = 0);
00085     virtual ~ETManifoldMesh ();
00086 
00087     // member access
00088     const EMap& GetEdges () const;
00089     const TMap& GetTriangles () const;
00090 
00091     // mesh manipulation
00092     TPtr InsertTriangle (int iV0, int iV1, int iV2);
00093     bool RemoveTriangle (int iV0, int iV1, int iV2);
00094 
00095     // manifold mesh is closed if each edge is shared twice
00096     bool IsClosed () const;
00097 
00098     void Print (const char* acFilename);
00099 
00100 protected:
00101     // edges
00102     static EPtr CreateEdge (int iV0, int iV1);
00103     ECreator m_oECreator;
00104     EMap m_kEMap;
00105 
00106     // triangles
00107     static TPtr CreateTriangle (int iV0, int iV1, int iV2);
00108     TCreator m_oTCreator;
00109     TMap m_kTMap;
00110 };
00111 
00112 } //namespace Wm4
00113 
00114 #include "Wm4ETManifoldMesh.inl"
00115 
00116 #endif

Generated on Wed Nov 23 19:01:03 2011 for FreeCAD by  doxygen 1.6.1