Triangulation.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
00018
00019
00020
00021
00022
00023
00024 #ifndef MESH_TRIANGULATION_H
00025 #define MESH_TRIANGULATION_H
00026
00027 #include "Elements.h"
00028 #include <Base/Vector3D.h>
00029
00030 namespace MeshCore
00031 {
00032 class MeshKernel;
00033
00034 class MeshExport AbstractPolygonTriangulator
00035 {
00036 public:
00037 AbstractPolygonTriangulator();
00038 virtual ~AbstractPolygonTriangulator();
00039
00041 void SetPolygon(const std::vector<Base::Vector3f>& raclPoints);
00045 std::vector<Base::Vector3f> GetPolygon() const;
00052 std::vector<Base::Vector3f> AddedPoints() const;
00056 Base::Matrix4D GetTransformToFitPlane() const;
00060 std::vector<Base::Vector3f> ProjectToFitPlane();
00064 bool TriangulatePolygon();
00068 virtual void ProjectOntoSurface(const std::vector<Base::Vector3f>&);
00070 const std::vector<MeshGeomFacet>& GetTriangles() const { return _triangles;}
00072 const std::vector<MeshFacet>& GetFacets() const { return _facets;}
00074 float GetLength() const;
00079 std::vector<unsigned long> GetInfo() const;
00080 void Discard();
00081
00082 protected:
00086 virtual bool Triangulate() = 0;
00087 void Done();
00088
00089 protected:
00090 bool _discard;
00091 Base::Matrix4D _inverse;
00092 std::vector<Base::Vector3f> _points;
00093 std::vector<Base::Vector3f> _newpoints;
00094 std::vector<MeshGeomFacet> _triangles;
00095 std::vector<MeshFacet> _facets;
00096 std::vector<unsigned long> _info;
00097 };
00098
00103 class MeshExport EarClippingTriangulator : public AbstractPolygonTriangulator
00104 {
00105 public:
00106 EarClippingTriangulator();
00107 ~EarClippingTriangulator();
00108
00109 protected:
00110 bool Triangulate();
00111
00112 private:
00122 class Triangulate
00123 {
00124 public:
00125
00126
00127 static bool Process(const std::vector<Base::Vector3f> &contour,
00128 std::vector<unsigned long> &result);
00129
00130
00131 static float Area(const std::vector<Base::Vector3f> &contour);
00132
00133
00134
00135 static bool InsideTriangle(float Ax, float Ay, float Bx, float By,
00136 float Cx, float Cy, float Px, float Py);
00137
00138 static bool _invert;
00139 private:
00140 static bool Snip(const std::vector<Base::Vector3f> &contour,
00141 int u,int v,int w,int n,int *V);
00142 };
00143 };
00144
00145 class MeshExport QuasiDelaunayTriangulator : public EarClippingTriangulator
00146 {
00147 public:
00148 QuasiDelaunayTriangulator();
00149 ~QuasiDelaunayTriangulator();
00150
00151 protected:
00152 bool Triangulate();
00153 };
00154
00155 class MeshExport DelaunayTriangulator : public AbstractPolygonTriangulator
00156 {
00157 public:
00158 DelaunayTriangulator();
00159 ~DelaunayTriangulator();
00160
00161 protected:
00162 bool Triangulate();
00163 };
00164
00165 class MeshExport FlatTriangulator : public AbstractPolygonTriangulator
00166 {
00167 public:
00168 FlatTriangulator();
00169 ~FlatTriangulator();
00170
00171 void ProjectOntoSurface(const std::vector<Base::Vector3f>&);
00172
00173 protected:
00174 bool Triangulate();
00175 };
00176
00177 class MeshExport ConstraintDelaunayTriangulator : public AbstractPolygonTriangulator
00178 {
00179 public:
00180 ConstraintDelaunayTriangulator(float area);
00181 ~ConstraintDelaunayTriangulator();
00182
00183 protected:
00184 bool Triangulate();
00185
00186 private:
00187 float fMaxArea;
00188 };
00189
00190 class MeshExport Triangulator : public AbstractPolygonTriangulator
00191 {
00192 public:
00193 Triangulator(const MeshKernel&);
00194 ~Triangulator();
00195
00196 protected:
00197 bool Triangulate();
00198
00199 const MeshKernel& _kernel;
00200 };
00201
00202 }
00203
00204
00205 #endif // MESH_TRIANGULATION_H