Builder.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 #ifndef MESH_BUILDER_H
00024 #define MESH_BUILDER_H
00025
00026 #include <set>
00027 #include <vector>
00028
00029 #include "MeshKernel.h"
00030 #include <Base/Vector3D.h>
00031
00032 namespace Base {
00033 class SequencerLauncher;
00034 }
00035
00036 namespace MeshCore
00037 {
00038 class MeshKernel;
00039 class MeshPoint;
00040 class MeshGeomFacet;
00041
00059 class MeshExport MeshBuilder
00060 {
00061 private:
00064 class Edge
00065 {
00066 public:
00067 unsigned long pt1, pt2, facetIdx;
00068
00069 Edge (unsigned long p1, unsigned long p2, unsigned long idx)
00070 {
00071 facetIdx = idx;
00072 if (p1 > p2)
00073 {
00074 pt1 = p2;
00075 pt2 = p1;
00076 }
00077 else
00078 {
00079 pt1 = p1;
00080 pt2 = p2;
00081 }
00082 }
00083
00084 bool operator < (const Edge &e) const
00085 {
00086 return (pt1 == e.pt1) ? (pt2 < e.pt2) : (pt1 < e.pt1);
00087 }
00088
00089 bool operator > (const Edge &e) const
00090 {
00091 return (pt1 == e.pt1) ? (pt2 > e.pt2) : (pt1 > e.pt1);
00092 }
00093
00094 bool operator == (const Edge &e) const
00095 {
00096 return (pt1 == e.pt1) && (pt2 == e.pt2);
00097 }
00098 };
00100
00101 MeshKernel& _meshKernel;
00102 std::set<MeshPoint> _points;
00103 Base::SequencerLauncher* _seq;
00104
00105
00106 typedef std::pair<std::set<MeshPoint>::iterator, bool> MeshPointIterator;
00107 std::vector<MeshPointIterator> _pointsIterator;
00108 unsigned long _ptIdx;
00109
00110 void SetNeighbourhood ();
00111
00112 void RemoveUnreferencedPoints();
00113
00114 public:
00115 MeshBuilder(MeshKernel &rclM);
00116 ~MeshBuilder(void);
00117
00121 void SetTolerance(float);
00122
00131 void Initialize (unsigned long ctFacets, bool deletion = true);
00132
00139 void AddFacet (const MeshGeomFacet& facet, bool takeFlag = false, bool takeProperty = false);
00142 void AddFacet (const Base::Vector3f& pt1, const Base::Vector3f& pt2, const Base::Vector3f& pt3, const Base::Vector3f& normal, unsigned char flag = 0, unsigned long prop = 0);
00149 void AddFacet (Base::Vector3f* facetPoints, unsigned char flag = 0, unsigned long prop = 0);
00150
00159 void Finish (bool freeMemory=false);
00160
00161 friend class MeshKernel;
00162
00163 private:
00164 float _fSaveTolerance;
00165 };
00166
00167 }
00168
00169 #endif