From 6778770a267b2bb6a31fdfecf01b853b7bf9b25e Mon Sep 17 00:00:00 2001 From: Eric Berberich Date: Fri, 10 Oct 2014 16:27:39 +0200 Subject: [PATCH] use boundary touching curve + rename --- .../Arr_spherical_construction_helper.h | 47 ++++++++++--------- .../Arr_unb_planar_insertion_helper.h | 33 ++++++------- .../Arr_unb_planar_overlay_helper.h | 29 ++++++------ .../CGAL/Sweep_line_2/Sweep_line_event.h | 29 +++++++----- 4 files changed, 73 insertions(+), 65 deletions(-) diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_spherical_construction_helper.h b/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_spherical_construction_helper.h index 4a8e3ea368b..dffb004f86d 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_spherical_construction_helper.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_spherical_construction_helper.h @@ -1,4 +1,4 @@ -// Copyright (c) 2007,2009,2010,2011 Tel-Aviv University (Israel). +// Copyright (c) 2007,2009,2010,2011,2014 Tel-Aviv University (Israel). // All rights reserved. // // This file is part of CGAL (www.cgal.org). @@ -18,6 +18,7 @@ // // Author(s) : Ron Wein // Efi Fogel +// Eric Berberich #ifndef CGAL_ARR_SPHERICAL_CONSTRUCTION_HELPER_H #define CGAL_ARR_SPHERICAL_CONSTRUCTION_HELPER_H @@ -133,6 +134,7 @@ public: { // If we insert an edge whose right end lies on the north pole, we have // to flip the order of predecessor halfegdes. + // TODO what about the corner? return (event->parameter_space_in_x() == ARR_INTERIOR && event->parameter_space_in_y() == ARR_TOP_BOUNDARY); } @@ -165,29 +167,26 @@ before_handle_event(Event* event) if (event->is_isolated()) return; - if (ps_y == ARR_BOTTOM_BOUNDARY) { - // Process a non-isolated event on the bottom contracted boundary: + // Comment: In the sweep-line event order the events of poles belong to the left and right + // boundary. However, here the vertices of the poles are identified by the + // event's trais to belong to the bottom and top boundary. - // The event has only one right curve, as there is exactly one curve - // incident to an event with boundary conditions. - CGAL_assertion(event->number_of_left_curves() == 0); - CGAL_assertion(event->number_of_right_curves() == 1); + if (ps_y == ARR_BOTTOM_BOUNDARY /* subsumes LEFT-BOTTOM and RIGHT-BOTTOM corner */) { + // Process a non-isolated event on the bottom contracted boundary. // If a vertex on the south pole does not exists, create one. DVertex* dv = m_top_traits->south_pole(); - Vertex_handle v = (dv) ? Vertex_handle(dv) : - m_arr_access.create_boundary_vertex(event->point(), ps_x, ps_y); + Vertex_handle v = + (dv) ? Vertex_handle(dv) : m_arr_access.create_boundary_vertex(event->point(), ps_x, ps_y); event->set_vertex_handle(v); return; } - if (ps_y == ARR_TOP_BOUNDARY) { - // Process a non-isolated event on the top contracted boundary: - - // The event has only one left curve, as there is exactly one curve - // incident to an event with boundary conditions - CGAL_assertion(event->number_of_left_curves() == 1); - CGAL_assertion(event->number_of_right_curves() == 0); + if (ps_y == ARR_TOP_BOUNDARY /* subsumes LEFT-TOP and RIGHT-TOP corner */) { + // Process a non-isolated event on the top contracted boundary. + // The process is more complicated than for the bottom boundary, + // as the touching the top boundary influences the list of + // halfedges seen in the reference face DVertex* dv = m_top_traits->north_pole(); if (dv) { @@ -212,6 +211,7 @@ before_handle_event(Event* event) splice_indices_list(prev->next()); return; } + // else // If a vertex on the north pole does not exists, create one. Vertex_handle v = @@ -230,26 +230,29 @@ before_handle_event(Event* event) } if (ps_x == ARR_LEFT_BOUNDARY) { - CGAL_assertion(event->number_of_left_curves() + event->number_of_right_curves() >= 1); + // Process a non-isolated event on the left identified boundary. + // It might be the end of a vertical curve. // If a vertex on the line of discontinuity does not exists, create one. DVertex* dv = m_top_traits->discontinuity_vertex(event->point()); - Vertex_handle v = (dv) ? Vertex_handle(dv) : - m_arr_access.create_boundary_vertex(event->point(), ps_x, ps_y); + Vertex_handle v = + (dv) ? Vertex_handle(dv) : m_arr_access.create_boundary_vertex(event->point(), ps_x, ps_y); event->set_vertex_handle(v); return; } if (ps_x == ARR_RIGHT_BOUNDARY) { - CGAL_assertion(event->number_of_left_curves() + event->number_of_right_curves() >= 1); + // Process a non-isolated event on the right identified boundary. + // Note: cannnot be vertical, only curves approaching the right side are possible. // If a vertex on the line of discontinuity does not exists, create one. DVertex* dv = m_top_traits->discontinuity_vertex(event->point()); - Vertex_handle v = (dv) ? Vertex_handle(dv) : - m_arr_access.create_boundary_vertex(event->point(), ps_x, ps_y); + Vertex_handle v = + (dv) ? Vertex_handle(dv) : m_arr_access.create_boundary_vertex(event->point(), ps_x, ps_y); event->set_vertex_handle(v); return; } + } } // namespace CGAL diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_unb_planar_insertion_helper.h b/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_unb_planar_insertion_helper.h index d944c406329..a96d8cad609 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_unb_planar_insertion_helper.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_unb_planar_insertion_helper.h @@ -14,7 +14,7 @@ // // $URL$ // $Id$ -// +// // // Author(s) : Baruch Zukerman // Ron Wein @@ -37,7 +37,7 @@ namespace CGAL { * for an Arrangement_on_surface_2 instantiated with a topology-traits class * for unbounded curves in the plane. */ -template +template class Arr_unb_planar_insertion_helper : public Arr_unb_planar_construction_helper @@ -74,9 +74,9 @@ protected: typedef typename Base::Topology_traits Topology_traits; typedef typename Base::Vertex_handle Vertex_handle; typedef typename Base::Halfedge_handle Halfedge_handle; - + public: - + /*! Constructor. */ Arr_unb_planar_insertion_helper (Arrangement_2 *arr) : Base (arr) @@ -106,16 +106,16 @@ public: //----------------------------------------------------------------------------- // A notification issued before the sweep process starts. // -template +template void Arr_unb_planar_insertion_helper::before_sweep () { // Obtain the four fictitious vertices that form the "corners" of the // fictitious face in the DCEL. Vertex_handle v_bl = Vertex_handle (this->m_top_traits->bottom_left_vertex()); - Vertex_handle v_tl = + Vertex_handle v_tl = Vertex_handle (this->m_top_traits->top_left_vertex()); - Vertex_handle v_br = + Vertex_handle v_br = Vertex_handle (this->m_top_traits->bottom_right_vertex()); // Get the fictitous halfedges incident to these vertices, and lying on @@ -126,7 +126,7 @@ void Arr_unb_planar_insertion_helper::before_sweep () // ^ // x | m_rh // m_lh | x - // v + // v // v_bl (.)----->x (.) v_br // m_bh // @@ -134,9 +134,9 @@ void Arr_unb_planar_insertion_helper::before_sweep () if (this->m_lh->source()->parameter_space_in_x() != ARR_LEFT_BOUNDARY) this->m_lh = this->m_lh->next()->twin(); - + this->m_bh = this->m_lh->next(); - + this->m_th = v_tl->incident_halfedges(); if (this->m_th->source()->parameter_space_in_x() == ARR_LEFT_BOUNDARY) this->m_th = this->m_th->next()->twin(); @@ -171,16 +171,17 @@ void Arr_unb_planar_insertion_helper::before_sweep () // A notification invoked before the sweep-line starts handling the given // event. // -template +template void Arr_unb_planar_insertion_helper:: before_handle_event (Event* event) { if (event->is_closed()) return; - // In case the event lies at inifinity, check whether its incident curve + // In case the event lies at infinity, check whether its incident curve // is already in the arrangement. - if (event->curve().halfedge_handle() == Halfedge_handle()) + Arr_curve_end ce; + if (event->boundary_touching_curve(ce).halfedge_handle() == Halfedge_handle()) { // The curve is not in the arrangement, use the base construction helper // to handle the event: @@ -191,7 +192,7 @@ before_handle_event (Event* event) // The curve is already in the arrangement, but has an infinite end, // so we have to update the fictitious halfedges. const Arr_parameter_space ps_x = event->parameter_space_in_x(); - + if (ps_x == ARR_LEFT_BOUNDARY) { // The event lies on the left fictitious halfedge. @@ -206,7 +207,7 @@ before_handle_event (Event* event) else { const Arr_parameter_space ps_y = event->parameter_space_in_y(); - + if (ps_y == ARR_BOTTOM_BOUNDARY) { // The event lies on the bottom fictitious halfedge. @@ -220,7 +221,7 @@ before_handle_event (Event* event) this->m_prev_plus_inf_y_event = NULL; } } - + return; } diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_unb_planar_overlay_helper.h b/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_unb_planar_overlay_helper.h index ccbc7870cd3..36f0763a9b3 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_unb_planar_overlay_helper.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_unb_planar_overlay_helper.h @@ -14,7 +14,7 @@ // // $URL$ // $Id$ -// +// // // Author(s) : Baruch Zukerman // Ron Wein @@ -46,7 +46,7 @@ class Arr_unb_planar_overlay_helper { public: - typedef Traits_ Traits_2; + typedef Traits_ Traits_2; typedef Arrangement_ Arrangement_2; typedef Event_ Event; typedef Subcurve_ Subcurve; @@ -83,7 +83,7 @@ protected: Halfedge_handle_red m_red_th; // Red top fictitious halfedge. Halfedge_handle_blue m_blue_th; // Blue top fictitious halfedge. - Vertex_handle_red v_red_tl; // Red top-left fictitious vertex. + Vertex_handle_red v_red_tl; // Red top-left fictitious vertex. Vertex_handle_blue v_blue_tl; // Blue top-left fictitious vertex. public: @@ -104,7 +104,7 @@ public: /*! * A notification invoked before the sweep-line starts handling the given * event. - */ + */ void before_handle_event (Event* e); //@} @@ -139,24 +139,24 @@ void Arr_unb_planar_overlay_helper::before_sweep () // vertices in both red and blue arrangements. If there are no vertices // at x = -oo, we take the halfedge incident to the top-left vertex that // lies on the top edge of the fictitious face. - Vertex_handle_red v_red_bl = + Vertex_handle_red v_red_bl = Vertex_handle_red (m_red_top_traits->bottom_left_vertex()); m_red_th = v_red_bl->incident_halfedges(); if (m_red_th->source()->parameter_space_in_x() != ARR_LEFT_BOUNDARY) m_red_th = m_red_th->next()->twin(); - + if (m_red_th->source() == v_red_tl) m_red_th = m_red_th->prev(); - Vertex_handle_blue v_blue_bl = + Vertex_handle_blue v_blue_bl = Vertex_handle_blue (m_blue_top_traits->bottom_left_vertex()); - + m_blue_th = v_blue_bl->incident_halfedges(); if (m_blue_th->source()->parameter_space_in_x() != ARR_LEFT_BOUNDARY) m_blue_th = m_blue_th->next()->twin(); - + if (m_blue_th->source() == v_blue_tl) m_blue_th = m_blue_th->prev(); @@ -174,7 +174,7 @@ before_handle_event (Event* e) // Nothing to do in case the event represents a valid point. if (e->is_closed()) return; - + // In case the event occurs on the left edge of the fictitious face (x = -oo) // or on its top edge (finite x and y = +oo), update the fictitious top // halfedges. @@ -182,7 +182,8 @@ before_handle_event (Event* e) (e->parameter_space_in_x() == ARR_INTERIOR && e->parameter_space_in_y() == ARR_TOP_BOUNDARY)) { - switch (e->curve().color()) + Arr_curve_end ce; + switch (e->boundary_touching_curve(ce).color()) { case (Traits_2::RED) : // Update the red top fictitious halfedge. @@ -190,18 +191,18 @@ before_handle_event (Event* e) if (m_red_th->source() == v_red_tl) m_red_th = m_red_th->prev(); break; - + case (Traits_2::BLUE) : // Update the blue top fictitious halfedge. m_blue_th = m_blue_th->twin()->next()->twin(); if (m_blue_th->source() == v_blue_tl) m_blue_th = m_blue_th->prev(); break; - + case Traits_2::RB_OVERLAP : // Update both red and blue top fictitious halfedges. m_red_th = m_red_th->twin()->next()->twin(); - if (m_red_th->source() == v_red_tl) + if (m_red_th->source() == v_red_tl) m_red_th = m_red_th->prev(); m_blue_th = m_blue_th->twin()->next()->twin(); diff --git a/Arrangement_on_surface_2/include/CGAL/Sweep_line_2/Sweep_line_event.h b/Arrangement_on_surface_2/include/CGAL/Sweep_line_2/Sweep_line_event.h index 640e115b67f..b4f45c1dc3d 100644 --- a/Arrangement_on_surface_2/include/CGAL/Sweep_line_2/Sweep_line_event.h +++ b/Arrangement_on_surface_2/include/CGAL/Sweep_line_2/Sweep_line_event.h @@ -138,50 +138,53 @@ public: } /*! Add a subcurve to the container of left curves. */ - void add_curve_to_left(Subcurve* curve) + void add_curve_to_left(Subcurve* sc) { // Look for the subcurve. Subcurve_iterator iter; //std::cout << "add_curve_to_left, curve: "; - //curve->Print(); + //sc->Print(); for (iter = m_leftCurves.begin(); iter != m_leftCurves.end(); ++iter) { //std::cout << "add_curve_to_left, iter: "; //(*iter)->Print(); // Do nothing if the curve exists. - if ((curve == *iter) || (*iter)->is_inner_node(curve)) { + if ((sc == *iter) || (*iter)->is_inner_node(sc)) { //std::cout << "add_curve_to_left, curve exists" << std::endl; return; } // Replace the existing curve in case of overlap. // EBEB 2011-10-27: Fixed to detect overlaps correctly - if (curve != *iter && curve->has_common_leaf(*iter)) { + if (sc != *iter && sc->has_common_leaf(*iter)) { //std::cout << "add_curve_to_left, curve overlaps" << std::endl; - *iter = curve; + *iter = sc; return; } } // The curve does not exist - insert it to the container. - m_leftCurves.push_back(curve); + m_leftCurves.push_back(sc); // std::cout << "add_curve_to_left, pushed back" << std::endl; //this->Print(); } /*! Add a subcurve to the container of left curves (without checks). */ - void push_back_curve_to_left(Subcurve* curve) - { m_leftCurves.push_back(curve); } + void push_back_curve_to_left(Subcurve* sc) + { + m_leftCurves.push_back(sc); + } + /*! Add a subcurve to the container of right curves. */ std::pair - add_curve_to_right(Subcurve* curve, const Traits_2* tr) + add_curve_to_right(Subcurve* sc) { if (m_rightCurves.empty()) { - m_rightCurves.push_back(curve); + m_rightCurves.push_back(sc); return (std::make_pair(false, m_rightCurves.begin())); } @@ -196,11 +199,11 @@ public: Comparison_result res; while ((res = tr->compare_y_at_x_right_2_object() - (curve->last_curve(), (*iter)->last_curve(), m_point)) == LARGER) + (sc->last_curve(), (*iter)->last_curve(), m_point)) == LARGER) { ++iter; if (iter == m_rightCurves.end()) { - m_rightCurves.insert(iter, curve); + m_rightCurves.insert(iter, sc); return std::make_pair(false, --iter); } } @@ -210,7 +213,7 @@ public: return std::make_pair(true, iter); } - m_rightCurves.insert(iter, curve); + m_rightCurves.insert(iter, sc); return std::make_pair(false, --iter); }