00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef __HALF_EDGE_H__
00013 #define __HALF_EDGE_H__
00014
00015 #include "Mesh.h"
00016 #include <map>
00017 #include <set>
00018 #include <queue>
00019
00020 class HalfEdgeMesh : public Mesh
00021 {
00022 public:
00023 HalfEdgeMesh();
00024 ~HalfEdgeMesh();
00025
00027 virtual bool addTriangle(const Vector3<float> &v1, const Vector3<float> &v2, const Vector3<float> & v3);
00028
00029
00030 virtual float area() const;
00031
00032 virtual float volume() const;
00033
00034 virtual int genus() const;
00035
00036 virtual float curvature(const unsigned int vertexIndex, const Vector3<float>& n);
00037
00038
00039
00040
00041 virtual void calculateFaceNormals();
00042
00043 virtual void calculateVertexNormals();
00044
00045 virtual void draw();
00046
00047
00048 void validate();
00049
00050
00051 void mergeAllBoundaries();
00052
00053 protected:
00054
00056 const static unsigned int BORDER;
00058 const static unsigned int UNINITIALIZED;
00059
00060 struct HalfEdge
00061 {
00062 HalfEdge() : vert(UNINITIALIZED), face(UNINITIALIZED), next(UNINITIALIZED), prev(UNINITIALIZED), pair(UNINITIALIZED) { }
00063 unsigned int vert;
00064 unsigned int face;
00065 unsigned int next;
00066 unsigned int prev;
00067 unsigned int pair;
00068 };
00069
00070 struct Vertex
00071 {
00072 Vertex() : edge(UNINITIALIZED) { }
00073 Vector3<float> vec;
00074 Vector3<float> v_normal;
00075 unsigned int edge;
00076 };
00077
00078 struct Face
00079 {
00080 Face() : edge(UNINITIALIZED) { }
00081 unsigned int edge;
00082 Vector3<float> normal;
00083 };
00084
00085 std::vector<HalfEdge> mEdges;
00086 std::vector<Vertex> mVerts;
00087 std::vector<Face> mFaces;
00088 std::vector<float> mCurvature;
00089
00090 std::map<Vector3<float>, unsigned int> mUniqueVerts;
00091
00093 virtual bool addVertex(const Vector3<float>& v, unsigned int &indx);
00094
00095 bool addHalfEdgePair(unsigned int v1, unsigned int v2, unsigned int &indx1, unsigned int &indx2);
00096
00097
00098
00099 void mergeBoundaryEdge(unsigned int indx);
00100
00101
00102
00103 virtual bool findNeighbourTriangles(const unsigned int vertexIndex, std::vector<unsigned int>& foundTriangles) const;
00104
00105 };
00106
00107 #endif