21 #ifndef EMODNET_QMGC_TIN_CREATION_GREEDY_INSERTION_H 22 #define EMODNET_QMGC_TIN_CREATION_GREEDY_INSERTION_H 24 #include "tin_creator.h" 25 #include "tin_creation_cgal_types.h" 26 #include <CGAL/Triangulation_face_base_2.h> 27 #include <CGAL/Triangulation_face_base_with_info_2.h> 29 #include <boost/heap/fibonacci_heap.hpp> 30 #include "tin_creation_utils.h" 42 GIHeapNode() : error(0.0), candidate(Point_3(.0,.0,.0)) {}
43 GIHeapNode(
const FT& e,
const Point_3& c ) : error(e), candidate(c) {}
54 return n1.error < n2.error;
58 typedef boost::heap::fibonacci_heap<GIHeapNode, boost::heap::compare<CompareGIHeapNodes>> GIHeap ;
59 typedef typename GIHeap::handle_type GIHeapNodeHandle ;
67 GIFaceInfo() : m_pointsInFacePtrs(), m_heapNodeHandle(), m_hasHeapNodeHandle(
false) {}
70 void setHeapNodeHandle( GIHeapNodeHandle h ) { m_heapNodeHandle = h; m_hasHeapNodeHandle = true ; }
71 void addPointPtr(std::shared_ptr<Point_3> pp) {m_pointsInFacePtrs.push_back(pp);}
72 std::vector<std::shared_ptr<Point_3>> getPtsSharedPtrs() {
return m_pointsInFacePtrs; } ;
73 size_t getNumPtsInFace() {
return m_pointsInFacePtrs.size(); }
74 bool hasHeapNodeHandle() {
return m_hasHeapNodeHandle; }
75 GIHeapNodeHandle getHeapNodeHandle() {
return m_heapNodeHandle ; }
79 m_pointsInFacePtrs.clear();
80 m_heapNodeHandle = GIHeapNodeHandle();
81 m_hasHeapNodeHandle =
false;
84 std::vector<std::shared_ptr<Point_3>> m_pointsInFacePtrs;
85 GIHeapNodeHandle m_heapNodeHandle ;
86 bool m_hasHeapNodeHandle ;
101 typedef CGAL::Triangulation_vertex_base_2<Gt> Vb;
102 typedef CGAL::Triangulation_face_base_with_info_2<GIFaceInfo, Gt> Fb;
103 typedef CGAL::Triangulation_data_structure_2<Vb, Fb> Tds;
104 typedef CGAL::Delaunay_triangulation_2<Gt, Tds> DT;
105 typedef DT::Face_handle FaceHandle;
106 typedef DT::Vertex_handle VertexHandle;
107 typedef DT::Face_circulator FaceCirculator;
108 typedef Gt::Rp::Triangle_3 Triangle_3;
109 typedef Gt::Rp::Vector_3 Vector_3;
110 typedef Gt::Rp::Segment_3 Segment_3;
111 typedef Gt::Rp::Line_3 Line_3;
113 typedef Gt::Rp::Intersect_3 Intersect_3;
116 enum ErrorType { ErrorHeight=0, Error3D } ;
127 int initGridSamples = -1,
128 int errorType = ErrorHeight)
129 : m_initGridSamples(initGridSamples)
130 , m_errorType(errorType)
132 m_approxTolPerZoom = std::vector<FT>{rootApproxTolerance};
143 int initGridSamples = -1,
144 int errorType = ErrorHeight)
145 : m_initGridSamples(initGridSamples)
146 , m_errorType(errorType)
147 , m_approxTolPerZoom(approxTolPerZoom)
157 Polyhedron create(
const std::vector<Point_3>& dataPts,
158 const bool& constrainEasternVertices,
159 const bool& constrainWesternVertices,
160 const bool& constrainNorthernVertices,
161 const bool& constrainSouthernVertices);
165 FT m_scaledSqApproxTol ;
166 std::vector<Point_3> m_dataPts ;
170 int m_initGridSamples;
171 std::vector<FT> m_approxTolPerZoom;
175 void initialize(
const bool& constrainEasternVertices,
176 const bool& constrainWesternVertices,
177 const bool& constrainNorthernVertices,
178 const bool& constrainSouthernVertices);
182 FT error(
const Point_3& p,
const Triangle_3&t)
const;
186 FT errorHeight(
const Point_3& p,
const Triangle_3&t)
const;
190 FT error3D(
const Point_3& p,
const Triangle_3&t)
const;
194 FT eval(
const Point_3& p,
const Triangle_3&t)
const;
197 void insert(
const Point_3& p);
204 void computeErrorAndUpdateHeap(FaceHandle fh);
209 #endif //EMODNET_QMGC_TIN_CREATION_GREEDY_INSERTION_H T standardHandlingOfThresholdPerZoom(const std::vector< T > &thresholdsPerZoom, const unsigned int &zoom, const bool &downScale=true)
Definition: tin_creation_utils.h:43
This namespace contains all the types/classes/functions required to create a TIN out of a regularly g...
Comparison operator (less than) for GIHeapNodes.
Definition: tin_creation_greedy_insertion_strategy.h:50
Creates a TIN using the Greedy Insertion method.
Definition: tin_creation_greedy_insertion_strategy.h:97
TinCreationGreedyInsertionStrategy(const std::vector< FT > &approxTolPerZoom, int initGridSamples=-1, int errorType=ErrorHeight)
Definition: tin_creation_greedy_insertion_strategy.h:142
TinCreationGreedyInsertionStrategy(double rootApproxTolerance, int initGridSamples=-1, int errorType=ErrorHeight)
Types of errors to use.
Definition: tin_creation_greedy_insertion_strategy.h:126
The information to be maintained in the heap structure.
Definition: tin_creation_greedy_insertion_strategy.h:38
Defines the interphase of a TIN creation algorithm.
Definition: tin_creator.h:37
Additional information associated to a face in a Delaunay triangulation required by the Greedy Insert...
Definition: tin_creation_greedy_insertion_strategy.h:65
void setParamsForZoom(const unsigned int &zoom)
Adapts the parameters of the algorithm for the desired zoom level.
Definition: tin_creation_greedy_insertion_strategy.h:152