From d746caac34ff4eb43d6baff652e244e95f26c402 Mon Sep 17 00:00:00 2001 From: Eric Berberich Date: Sun, 18 Nov 2007 16:44:09 +0000 Subject: [PATCH] fix: conditions on *itr to skip its further processing (after RW's observation) --- .../Arr_construction_sl_visitor.h | 76 ++++++++++++++----- 1 file changed, 58 insertions(+), 18 deletions(-) diff --git a/Arrangement_on_surface_2/include/CGAL/Sweep_line_2/Arr_construction_sl_visitor.h b/Arrangement_on_surface_2/include/CGAL/Sweep_line_2/Arr_construction_sl_visitor.h index 65a28fd935d..30bc1ea7f1f 100644 --- a/Arrangement_on_surface_2/include/CGAL/Sweep_line_2/Arr_construction_sl_visitor.h +++ b/Arrangement_on_surface_2/include/CGAL/Sweep_line_2/Arr_construction_sl_visitor.h @@ -96,6 +96,8 @@ protected: // subcurves that emarge from event // points with only right curves). + Halfedge_handle m_last_he; // the last halfedge at the top + std::vector m_sc_he_table; // A table that maps a subcurve // index to its halfedge handle, @@ -286,7 +288,7 @@ void Arr_construction_sl_visitor::before_handle_event (Event* event) { // We just have to notify the helper class on the event. m_helper.before_handle_event (event); - + m_last_he = Halfedge_handle(); return; } @@ -335,22 +337,39 @@ bool Arr_construction_sl_visitor::after_handle_event // In case of a finite event that has no incident left curves, it is // associated with a point that may be the leftmost one in a hole. - // We give index to the topmost subcurve from the right, and add this - // vertex indices list of the curve the event "sees" from below. - m_sc_counter++; - (*(event->right_curves_rbegin()))->set_index (m_sc_counter); + // The last inserted halfedge belongs to this event. We have to check + // whether it really can pose a hole, i.e., whether the inserted halfedge + // is on an inner ccb. - if (iter != this->status_line_end()) + std::cout << "m_sc_counter++: " << (m_sc_counter + 1) << std::endl; + + const Halfedge_handle invalid_he; + //CGAL_assertion(m_last_he->direction() == CGAL::RIGHT_TO_LEFT); + if (m_last_he != invalid_he && m_last_he->is_on_inner_ccb()) { - // The vertex "sees" the subcurve of the given position from below. - Subcurve *sc_above = *iter; - sc_above->add_halfedge_index(m_sc_counter); - } - else - { - // The vertex is not located below any valid curve, so we use the helper - // class to mark that this index should belong to the current top face. - m_helper.add_subcurve_in_top_face (m_sc_counter); + // We give index to the topmost subcurve from the right, and add this + // vertex indices list of the curve the event "sees" from below. + m_sc_counter++; + (*(event->right_curves_rbegin()))->set_index (m_sc_counter); + + if (iter != this->status_line_end()) + { + // The vertex "sees" the subcurve of the given position from below. + Subcurve *sc_above = *iter; + sc_above->add_halfedge_index(m_sc_counter); + } + else + { + // The vertex is not located below any valid curve, + // so we use the helper class to mark that this index + // should belong to the current top face. + m_helper.add_subcurve_in_top_face (m_sc_counter); + } + } else { + if (m_last_he != invalid_he) { + std::cout << "Valid, but not inner: " + << m_last_he->curve() << std::endl; + } } } @@ -397,6 +416,8 @@ template void Arr_construction_sl_visitor::add_subcurve (const X_monotone_curve_2& cv, Subcurve* sc) { + std::cout << "Add subcurve: " << cv << std::endl; + // Obtain all information to perform the insertion of the subcurve into // the arrangement. Event *last_event = last_event_on_subcurve(sc); @@ -456,14 +477,31 @@ void Arr_construction_sl_visitor::add_subcurve if (res->direction() != LEFT_TO_RIGHT) res = res->twin(); + std::cout << "resI: " << res->is_on_inner_ccb() << std::endl; + std::cout << "resTI: " << res->twin()->is_on_inner_ccb() << std::endl; + + if (res->is_on_inner_ccb()) { + std::cout << "resF: " << &(*res->inner_ccb()->face()) << std::endl; + } else { + std::cout << "resF: " << &(*res->outer_ccb()->face()) << std::endl; + } + + if (res->twin()->is_on_inner_ccb()) { + std::cout << "res->twinF: " << &(*res->twin()->inner_ccb()->face()) << std::endl; + } else { + std::cout << "res->twinF: " << &(*res->twin()->outer_ccb()->face()) << std::endl; + } + + m_last_he = res; + // Update the last event with the inserted halfegde (if necessary) // and check if we have to update the auxiliary information on the location // of holes. if (last_event->number_of_left_curves() == 0 && last_event->is_curve_largest((Subcurve*)sc)) { - if (last_event->vertex_handle() == m_invalid_vertex) - last_event->set_halfedge_handle(res->twin()); + if (last_event->vertex_handle() == m_invalid_vertex) + last_event->set_halfedge_handle(res->twin()); // If sc has valid index, insert its index to m_sc_he_table. if(sc->has_valid_index()) @@ -856,7 +894,7 @@ void Arr_construction_sl_visitor::relocate_in_new_face continue; Halfedge_handle he_on_face = m_sc_he_table[*itr]; - + if(he_on_face == invalid_he) { // If the halfedge handle is invalis, then we have an index for an @@ -904,6 +942,8 @@ void Arr_construction_sl_visitor::_map_new_halfedge (unsigned int i, Halfedge_handle he) { CGAL_assertion (i != 0); + + std::cout << "Assign " << i << " to " << he->curve() << std::endl; if(i >= m_sc_he_table.size()) // Resize the index table if we reached it capacity.