diff --git a/Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_insertion_ss_visitor.h b/Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_insertion_ss_visitor.h index 6782f6c02b6..a9ab34bd676 100644 --- a/Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_insertion_ss_visitor.h +++ b/Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_insertion_ss_visitor.h @@ -67,6 +67,36 @@ private: X_monotone_curve_2 sub_cv1; // Auxiliary variables X_monotone_curve_2 sub_cv2; // (used for splitting curves). + + // update halfedge pointing to events, case with overlaps + template + void update_incident_halfedge_after_split(Subcurve_* sc, + Halfedge_handle he, + Halfedge_handle new_he, + Tag_true) + { + std::vector leaves; + sc->all_leaves( std::back_inserter(leaves) ); + for(Subcurve* ssc : leaves) + { + Event* last_event_on_ssc = ssc->last_event(); + if (last_event_on_ssc->halfedge_handle() == he) + last_event_on_ssc->set_halfedge_handle(new_he->next()); + } + } + + // update halfedge pointing to events, case without overlaps + template + void update_incident_halfedge_after_split(Subcurve_* sc, + Halfedge_handle he, + Halfedge_handle new_he, + Tag_false) + { + Event* last_event_on_sc = sc->last_event(); + if (last_event_on_sc->halfedge_handle() == he) + last_event_on_sc->set_halfedge_handle(new_he->next()); + } + public: /*! A notification invoked when a new subcurve is created. */ void add_subcurve(const X_monotone_curve_2& cv, Subcurve* sc); @@ -132,9 +162,8 @@ Arr_insertion_ss_visitor::split_edge(Halfedge_handle he, Subcurve* sc Halfedge_handle new_he = this->m_arr_access.split_edge_ex(he, pt.base(), sub_cv1.base(), sub_cv2.base()); - Event* last_event_on_sc = sc->last_event(); - if (last_event_on_sc->halfedge_handle() == he) - last_event_on_sc->set_halfedge_handle(new_he->next()); + // update the halfedge incident to events on the left of the split + update_incident_halfedge_after_split(sc, he, new_he, typename Subcurve::Handle_overlaps()); return new_he; } diff --git a/Surface_sweep_2/include/CGAL/Surface_sweep_2/Default_subcurve.h b/Surface_sweep_2/include/CGAL/Surface_sweep_2/Default_subcurve.h index 1112d578cd4..dd8215e67a1 100644 --- a/Surface_sweep_2/include/CGAL/Surface_sweep_2/Default_subcurve.h +++ b/Surface_sweep_2/include/CGAL/Surface_sweep_2/Default_subcurve.h @@ -70,6 +70,7 @@ public: typedef GeometryTraits_2 Geometry_traits_2; typedef Subcurve_ Subcurve; typedef Event_ Event; + typedef Tag_true Handle_overlaps; private: typedef Geometry_traits_2 Gt2; diff --git a/Surface_sweep_2/include/CGAL/Surface_sweep_2/No_overlap_subcurve.h b/Surface_sweep_2/include/CGAL/Surface_sweep_2/No_overlap_subcurve.h index bef25a3d9b9..1fd3601f077 100644 --- a/Surface_sweep_2/include/CGAL/Surface_sweep_2/No_overlap_subcurve.h +++ b/Surface_sweep_2/include/CGAL/Surface_sweep_2/No_overlap_subcurve.h @@ -63,6 +63,7 @@ public: typedef Subcurve_ Subcurve; typedef Event_ Event; typedef Allocator_ Allocator; + typedef Tag_false Handle_overlaps; private: typedef Geometry_traits_2 Gt2;