00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #pragma once
00016 #ifndef VHACD_ICHULL_H
00017 #define VHACD_ICHULL_H
00018 #include "vhacdManifoldMesh.h"
00019 #include "vhacdVector.h"
00020
00021 namespace VHACD {
00023 enum ICHullError {
00024 ICHullErrorOK = 0,
00025 ICHullErrorCoplanarPoints,
00026 ICHullErrorNoVolume,
00027 ICHullErrorInconsistent,
00028 ICHullErrorNotEnoughPoints
00029 };
00030 class ICHull {
00031 public:
00032 static const double sc_eps;
00034 bool IsFlat() { return m_isFlat; }
00036 TMMesh& GetMesh() { return m_mesh; }
00038 bool AddPoint(const Vec3<double>& point) { return AddPoints(&point, 1); }
00040 bool AddPoint(const Vec3<double>& point, int32_t id);
00042 bool AddPoints(const Vec3<double>* points, size_t nPoints);
00044 ICHullError Process();
00046 ICHullError Process(const uint32_t nPointsCH, const double minVolume = 0.0);
00048 bool IsInside(const Vec3<double>& pt0, const double eps = 0.0);
00050 const ICHull& operator=(ICHull& rhs);
00051
00053 ICHull();
00055 ~ICHull(void){};
00056
00057 private:
00059 ICHullError DoubleTriangle();
00061 CircularListElement<TMMTriangle>* MakeFace(CircularListElement<TMMVertex>* v0,
00062 CircularListElement<TMMVertex>* v1,
00063 CircularListElement<TMMVertex>* v2,
00064 CircularListElement<TMMTriangle>* fold);
00066 CircularListElement<TMMTriangle>* MakeConeFace(CircularListElement<TMMEdge>* e, CircularListElement<TMMVertex>* v);
00068 bool ProcessPoint();
00070 bool ComputePointVolume(double& totalVolume, bool markVisibleFaces);
00072 bool FindMaxVolumePoint(const double minVolume = 0.0);
00074 bool CleanEdges();
00076 bool CleanVertices(uint32_t& addedPoints);
00078 bool CleanTriangles();
00080 bool CleanUp(uint32_t& addedPoints);
00082 bool MakeCCW(CircularListElement<TMMTriangle>* f,
00083 CircularListElement<TMMEdge>* e,
00084 CircularListElement<TMMVertex>* v);
00085 void Clear();
00086
00087 private:
00088 static const int32_t sc_dummyIndex;
00089 TMMesh m_mesh;
00090 SArray<CircularListElement<TMMEdge>*> m_edgesToDelete;
00091 SArray<CircularListElement<TMMEdge>*> m_edgesToUpdate;
00092 SArray<CircularListElement<TMMTriangle>*> m_trianglesToDelete;
00093 Vec3<double> m_normal;
00094 bool m_isFlat;
00095 ICHull(const ICHull& rhs);
00096 };
00097 }
00098 #endif // VHACD_ICHULL_H