00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00020 #ifndef SHUTIL_SHMESH_HPP
00021 #define SHUTIL_SHMESH_HPP
00022
00023 #include <list>
00024 #include <map>
00025 #include <set>
00026
00027 #include "sh.hpp"
00028
00029 namespace ShUtil {
00030
00063 template<typename VertexType, typename FaceType, typename EdgeType>
00064 struct ShMeshType {
00065 typedef VertexType Vertex;
00066 typedef FaceType Face;
00067 typedef EdgeType Edge;
00068 };
00069
00070 template<typename M>
00071 struct ShMeshVertex {
00072 typedef typename M::Edge Edge;
00073 Edge *edge;
00074
00076 ShMeshVertex();
00077
00079 ShMeshVertex(const ShMeshVertex<M> &other);
00080 };
00081
00082 template<typename M>
00083 struct ShMeshFace {
00084 typedef typename M::Edge Edge;
00085 Edge *edge;
00086
00088 ShMeshFace();
00089
00091 ShMeshFace(const ShMeshFace<M> &other);
00092 };
00093
00094
00095 template<typename M>
00096 struct ShMeshEdge {
00097 typedef typename M::Vertex Vertex;
00098 typedef typename M::Face Face;
00099 typedef typename M::Edge Edge;
00100 Vertex *start;
00101 Vertex *end;
00102 Face *face;
00103 Edge *sym;
00104 Edge *next;
00105 Edge *prev;
00106
00108 ShMeshEdge();
00109
00111 ShMeshEdge(const ShMeshEdge<M> &other);
00112
00115 void setLinks(Vertex *s, Vertex *e, Face *f,
00116 Edge *next, Edge *prev, Edge *sym);
00117
00119 void setNext(Edge *n);
00120
00122 void setPrev(Edge *p);
00123
00125 void setSym(Edge *s);
00126 };
00127
00128
00130 template<typename M>
00131 class ShMesh {
00132 public:
00133 typedef M MeshType;
00134 typedef typename M::Vertex Vertex;
00135 typedef typename M::Edge Edge;
00136 typedef typename M::Face Face;
00137
00138 typedef std::set<Vertex*> VertexSet;
00139 typedef std::set<Edge*> EdgeSet;
00140 typedef std::set<Face*> FaceSet;
00141 typedef std::list<Vertex*> VertexList;
00142
00144 ShMesh();
00145
00148 ShMesh(const ShMesh<M>& other);
00149
00151 ~ShMesh();
00152
00154 ShMesh<M>& operator=(const ShMesh<M>& other);
00155
00157 void clear();
00158
00164 Face* addFace(const VertexList &vl);
00165
00169 void removeFace(Face *f);
00170
00175 template<typename VertLess>
00176 void mergeVertices();
00177
00185 void mergeEdges();
00186
00189 bool earTriangulate();
00190
00191 VertexSet verts;
00192 EdgeSet edges;
00193 FaceSet faces;
00194
00195 protected:
00196 typedef std::map<Vertex*, Vertex*> VertexMap;
00197 typedef std::map<Edge*, Edge*> EdgeMap;
00198 typedef std::map<Face*, Face*> FaceMap;
00199
00200
00201
00202
00203
00204
00205
00206
00207 typedef std::multimap<Vertex*, Edge*> IncidenceMap;
00208 typedef typename IncidenceMap::value_type Incidence;
00209 typedef typename IncidenceMap::iterator IncidenceIterator;
00210 typedef std::pair<typename IncidenceMap::iterator,
00211 typename IncidenceMap::iterator> IncidenceRange;
00212
00213 IncidenceMap m_incidences;
00214
00222 void removeHalfEdge(Edge *e);
00223
00225 void insertHalfEdge(Edge *e);
00226 };
00227
00228
00229 }
00230
00231 #include "ShMeshImpl.hpp"
00232
00233 #endif