From 8cf9a96b459f5ee235ebcb577adfbc106acfc5bf Mon Sep 17 00:00:00 2001 From: Panagiotis Cheilaris Date: Mon, 17 Feb 2014 14:45:09 +0100 Subject: [PATCH] pointers for insert point on segment functions Introduce pointers for functions that insert a point on a segment. For L2, to keep the same functionality as before, the pointers point to insert_exact_point_on_segment and insert_point_on_segment functions. Classes derived from Segment_Delaunay_graph_2 can change the pointers to point to more specialized functions. For example, the Linf implementation will point to different specialized function defined in the Linf class. --- .../include/CGAL/Segment_Delaunay_graph_2.h | 30 +++++++++++++++++-- .../Segment_Delaunay_graph_2_impl.h | 10 +++++-- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2.h b/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2.h index a0f732fcde2..b70161586b0 100644 --- a/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2.h +++ b/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2.h @@ -309,12 +309,35 @@ protected: CGAL_SEGMENT_DELAUNAY_GRAPH_2_NS::Internal::Which_list::List List; + +protected: + // types for insert on segment functions + typedef Vertex_triple (Self::*Insert_on_Type)( + const Storage_site_2& ss, const Site_2& t, + Vertex_handle v, const Tag_true&); + Insert_on_Type insert_point_on_segment_ptr; + + typedef Vertex_triple (Self::*Insert_Exact_on_Type)( + const Storage_site_2& ss, const Site_2& t, + Vertex_handle v); + Insert_Exact_on_Type insert_exact_point_on_segment_ptr; + +private: + // CREATION helper + void setup_insert_on_pointers_l2(void) { + insert_point_on_segment_ptr = &Self::insert_point_on_segment; + insert_exact_point_on_segment_ptr = &Self::insert_exact_point_on_segment; + } + public: // CREATION //--------- Segment_Delaunay_graph_2(const Geom_traits& gt = Geom_traits(), const Storage_traits& st = Storage_traits()) - : DG(gt), st_(st) {} + : DG(gt), st_(st) + { + setup_insert_on_pointers_l2(); + } template< class Input_iterator > Segment_Delaunay_graph_2(Input_iterator first, Input_iterator beyond, @@ -322,6 +345,7 @@ public: const Storage_traits& st = Storage_traits()) : DG(gt), st_(st) { + setup_insert_on_pointers_l2(); insert(first, beyond); } @@ -1061,11 +1085,11 @@ protected: Vertex_handle insert_point2(const Storage_site_2& ss, const Site_2& t, Vertex_handle vnear); - Triple + Vertex_triple insert_point_on_segment(const Storage_site_2& ss, const Site_2& t, Vertex_handle v, const Tag_true&); - Triple + Vertex_triple insert_exact_point_on_segment(const Storage_site_2& ss, const Site_2& t, Vertex_handle v); diff --git a/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2/Segment_Delaunay_graph_2_impl.h b/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2/Segment_Delaunay_graph_2_impl.h index 776095e003e..80bc825aed3 100644 --- a/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2/Segment_Delaunay_graph_2_impl.h +++ b/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2/Segment_Delaunay_graph_2_impl.h @@ -338,7 +338,8 @@ insert_point(const Storage_site_2& ss, const Site_2& t, if ( at_res == AT2::INTERIOR ) { CGAL_assertion( t.is_input() ); - Vertex_triple vt = insert_exact_point_on_segment(ss, t, vnearest); + Vertex_triple vt = (this->*insert_exact_point_on_segment_ptr)( + ss, t, vnearest); return vt.first; } else { // the point to be inserted does not belong to the interior of a @@ -931,7 +932,7 @@ insert_intersecting_segment_with_tag(const Storage_site_2& ss, return v; } - Vertex_triple vt = insert_point_on_segment(ss, t, v, tag); + Vertex_triple vt = (this->*insert_point_on_segment_ptr)(ss, t, v, tag); Vertex_handle vsx = vt.first; @@ -2778,6 +2779,11 @@ void Segment_Delaunay_graph_2:: copy(Segment_Delaunay_graph_2& other) { + // copy the insert_on method pointers + insert_point_on_segment_ptr = other.insert_point_on_segment_ptr; + insert_exact_point_on_segment_ptr = + other.insert_exact_point_on_segment_ptr; + // first copy the point container pc_ = other.pc_;