Fixed calling of the various insert_ members

This commit is contained in:
Efi Fogel 2012-12-21 00:20:41 +02:00
parent ddcce2767c
commit dda664ecf9
1 changed files with 297 additions and 417 deletions

View File

@ -43,25 +43,18 @@ namespace CGAL {
/*! \struct Integer_hash_function /*! \struct Integer_hash_function
* An auxiliary hash functor for integers. * An auxiliary hash functor for integers.
*/ */
struct Integer_hash_function struct Integer_hash_function {
{
typedef std::size_t result_type; typedef std::size_t result_type;
std::size_t operator() (unsigned int i) const std::size_t operator()(unsigned int i) const { return i; }
{
return i;
}
}; };
/*! \class Arr_construction_sl_visitor /*! \class Arr_construction_sl_visitor
* A sweep-line visitor for constructing an arrangement embedded on a surface. * A sweep-line visitor for constructing an arrangement embedded on a surface.
*/ */
template <class Helper_> template <class Helper_>
class Arr_construction_sl_visitor : class Arr_construction_sl_visitor : public Helper_::Base_visitor {
public Helper_::Base_visitor
{
public: public:
typedef Helper_ Helper; typedef Helper_ Helper;
typedef typename Helper::Traits_2 Traits_2; typedef typename Helper::Traits_2 Traits_2;
@ -74,7 +67,6 @@ public:
typedef typename Traits_2::Point_2 Point_2; typedef typename Traits_2::Point_2 Point_2;
protected: protected:
typedef typename Arrangement_2::Topology_traits Topology_traits; typedef typename Arrangement_2::Topology_traits Topology_traits;
typedef typename Arrangement_2::Vertex_handle Vertex_handle; typedef typename Arrangement_2::Vertex_handle Vertex_handle;
typedef typename Arrangement_2::Halfedge_handle Halfedge_handle; typedef typename Arrangement_2::Halfedge_handle Halfedge_handle;
@ -92,21 +84,18 @@ protected:
Integer_hash_function> Iso_vertices_map; Integer_hash_function> Iso_vertices_map;
protected: protected:
Helper m_helper; // The helper class. Helper m_helper; // The helper class.
Arrangement_2* m_arr; // The arrangement we construct. Arrangement_2* m_arr; // The arrangement we construct.
Topology_traits* m_top_traits; // The topology-traits class. Topology_traits* m_top_traits; // The topology-traits class.
Arr_accessor<Arrangement_2> Arr_accessor<Arrangement_2> m_arr_access; // An arrangement accessor.
m_arr_access; // An arrangement accessor.
unsigned int m_sc_counter; // Counter for subcurves that may unsigned int m_sc_counter; // Counter for subcurves that may
// represent a hole (the upper // represent a hole (the upper
// subcurves that emarge from event // subcurves that emarge from event
// points with only right curves). // points with only right curves).
std::vector<Halfedge_handle> std::vector<Halfedge_handle> m_sc_he_table; // A table that maps a subcurve
m_sc_he_table; // A table that maps a subcurve
// index to its halfedge handle, // index to its halfedge handle,
// directed from right to left. // directed from right to left.
@ -120,7 +109,6 @@ protected:
const Vertex_handle m_invalid_vertex; // An invalid vertex handle. const Vertex_handle m_invalid_vertex; // An invalid vertex handle.
public: public:
/*! Constructor. */ /*! Constructor. */
Arr_construction_sl_visitor(Arrangement_2* arr) : Arr_construction_sl_visitor(Arrangement_2* arr) :
m_helper(arr), m_helper(arr),
@ -135,8 +123,7 @@ public:
} }
/*! Destructor. */ /*! Destructor. */
virtual ~Arr_construction_sl_visitor() virtual ~Arr_construction_sl_visitor() {}
{}
/// \name Sweep-line notifications. /// \name Sweep-line notifications.
//@{ //@{
@ -235,7 +222,6 @@ public:
} }
private: private:
/// \name Auxiliary functions. /// \name Auxiliary functions.
//@{ //@{
@ -278,8 +264,6 @@ void Arr_construction_sl_visitor<Hlpr>::before_sweep ()
{ {
// We just have to notify the helper that the sweep process now starts. // We just have to notify the helper that the sweep process now starts.
m_helper.before_sweep(); m_helper.before_sweep();
return;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -291,10 +275,9 @@ void Arr_construction_sl_visitor<Hlpr>::before_handle_event (Event* event)
{ {
// We just have to notify the helper class on the event. // We just have to notify the helper class on the event.
m_helper.before_handle_event(event); m_helper.before_handle_event(event);
#if 0 #if CGAL_ARR_CONSTRUCTION_SL_VISITOR_VERBOSE
std::cout << "CGAL_CSLV before_handle_event" << std::endl; std::cout << "CGAL_CSLV before_handle_event" << std::endl;
#endif #endif
return;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -302,16 +285,16 @@ void Arr_construction_sl_visitor<Hlpr>::before_handle_event (Event* event)
// event. // event.
// //
template <class Hlpr> template <class Hlpr>
bool Arr_construction_sl_visitor<Hlpr>::after_handle_event bool Arr_construction_sl_visitor<Hlpr>::
(Event* event, Status_line_iterator iter, bool /* flag */) after_handle_event(Event* event, Status_line_iterator iter, bool /* flag */)
{ {
#if CGAL_ARR_CONSTRUCTION_SL_VISITOR_VERBOSE #if CGAL_ARR_CONSTRUCTION_SL_VISITOR_VERBOSE
std::cout << std::endl << "CGAL_CSLV after_handle_event: " << event << std::endl; std::cout << std::endl << "CGAL_CSLV after_handle_event: " << event
<< std::endl;
#endif #endif
// Check if the event represents an isolated vertex. // Check if the event represents an isolated vertex.
if (!event->has_left_curves() && !event->has_right_curves()) if (!event->has_left_curves() && !event->has_right_curves()) {
{
// There are no incident subcurves, so this event is an isolated vertex. // There are no incident subcurves, so this event is an isolated vertex.
// We map the current index to this vertex, and add this index to the // We map the current index to this vertex, and add this index to the
// indices list of the curve the vertex "sees" from below. // indices list of the curve the vertex "sees" from below.
@ -321,15 +304,13 @@ bool Arr_construction_sl_visitor<Hlpr>::after_handle_event
m_iso_verts_map[m_sc_counter] = v; m_iso_verts_map[m_sc_counter] = v;
_map_new_halfedge(m_sc_counter, Halfedge_handle()); _map_new_halfedge(m_sc_counter, Halfedge_handle());
if (iter != this->status_line_end()) if (iter != this->status_line_end()) {
{
// The isolated vertex "sees" the subcurve of the given position from // The isolated vertex "sees" the subcurve of the given position from
// below. // below.
Subcurve* sc_above = *iter; Subcurve* sc_above = *iter;
sc_above->add_halfedge_index(m_sc_counter); sc_above->add_halfedge_index(m_sc_counter);
} }
else else {
{
// The vertex is not located below any valid curve, so we use the helper // 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. // class to mark that this index should belong to the current top face.
#if CGAL_ARR_CONSTRUCTION_SL_VISITOR_VERBOSE #if CGAL_ARR_CONSTRUCTION_SL_VISITOR_VERBOSE
@ -364,8 +345,7 @@ bool Arr_construction_sl_visitor<Hlpr>::after_handle_event
} }
// Check if the event has only incident subcurves from its right. // Check if the event has only incident subcurves from its right.
if (!event->has_left_curves()) if (!event->has_left_curves()) {
{
CGAL_assertion(event->has_right_curves()); CGAL_assertion(event->has_right_curves());
// In case of a finite event that has no incident left curves, it is // In case of a finite event that has no incident left curves, it is
@ -375,14 +355,12 @@ bool Arr_construction_sl_visitor<Hlpr>::after_handle_event
m_sc_counter++; m_sc_counter++;
(*(event->right_curves_rbegin()))->set_index(m_sc_counter); (*(event->right_curves_rbegin()))->set_index(m_sc_counter);
if (iter != this->status_line_end()) if (iter != this->status_line_end()) {
{
// The vertex "sees" the subcurve of the given position from below. // The vertex "sees" the subcurve of the given position from below.
Subcurve *sc_above = *iter; Subcurve *sc_above = *iter;
sc_above->add_halfedge_index(m_sc_counter); sc_above->add_halfedge_index(m_sc_counter);
} }
else else {
{
// The vertex is not located below any valid curve, so we use the helper // 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. // class to mark that this index should belong to the current top face.
#if CGAL_ARR_CONSTRUCTION_SL_VISITOR_VERBOSE #if CGAL_ARR_CONSTRUCTION_SL_VISITOR_VERBOSE
@ -403,8 +381,7 @@ bool Arr_construction_sl_visitor<Hlpr>::after_handle_event
} }
// In case there are no right subcurves, the event can be deallocated. // In case there are no right subcurves, the event can be deallocated.
if(event->number_of_right_curves() == 0) if (event->number_of_right_curves() == 0) {
{
// Inform the helper class that the event will soon be deallocated. // Inform the helper class that the event will soon be deallocated.
m_helper.before_deallocate_event(event); m_helper.before_deallocate_event(event);
return (true); return (true);
@ -479,68 +456,31 @@ add_subcurve (const X_monotone_curve_2& cv, Subcurve* sc)
} }
#endif #endif
// Check if the previous event on the curve is not in the arrangement yet. // Check whether the previous event on the curve is not in the arrangement yet.
if (he_left == invalid_he) if (he_left == invalid_he) {
{
// We do not have a handle from the previous insert.
if (he_right != invalid_he)
{
// We have a handle from the current event, representing the right end
// of the subcurve - use it to insert the subcurve.
#if CGAL_ARR_CONSTRUCTION_SL_VISITOR_VERBOSE
std::cout << "CGAL_CSLV call insert_from_right_vertex" << std::endl;
#endif
res = this->insert_from_right_vertex(cv, he_right, sc);
}
else
{
// We do not have handles for any of the curve end, so we insert it in
// the interior of a face.
#if CGAL_ARR_CONSTRUCTION_SL_VISITOR_VERBOSE
std::cout << "CGAL_CSLV call insert_in_face_interior" << std::endl;
#endif
Vertex_handle v_left = last_event->vertex_handle(); Vertex_handle v_left = last_event->vertex_handle();
// Check whether the vertex to be associated with the left end of
// the curve has already been created.
if ((v_left != m_invalid_vertex) && (v_left->degree() > 0)) { if ((v_left != m_invalid_vertex) && (v_left->degree() > 0)) {
// The left vertex, v_left, is a boundary vertex, which already has // The left vertex v is a boundary vertex which already has some
// some incident halfedges. We look for the predecessor halfedge and // incident halfedges. We look for the predecessor halfedge and
// insert the curve from this left vertex. // insert the curve between two existing vertices.
Arr_parameter_space bx = last_event->parameter_space_in_x(); Arr_parameter_space bx = last_event->parameter_space_in_x();
Arr_parameter_space by = last_event->parameter_space_in_y(); Arr_parameter_space by = last_event->parameter_space_in_y();
CGAL_assertion((bx != ARR_INTERIOR) || (by != ARR_INTERIOR)); CGAL_assertion((bx != ARR_INTERIOR) || (by != ARR_INTERIOR));
Halfedge_handle l_prev = Halfedge_handle he_left = Halfedge_handle
(m_top_traits->locate_around_boundary_vertex(&(*v_left), _curve(cv), (m_top_traits->locate_around_boundary_vertex(&(*v_left), _curve(cv),
ARR_MIN_END, bx, by)); ARR_MIN_END, bx, by));
res = this->insert_from_left_vertex(cv, l_prev, sc); }
} }
else { else {
Event* curr_event = this->current_event(); // The previous event on the curve is already in the arrangement.
Vertex_handle v_right = curr_event->vertex_handle(); // Therefore, we use it to insert the subcurve.
if ((v_right != m_invalid_vertex) && (v_right->degree() > 0)) {
// The right vertex v_right is a boundary vertex which already has
// some incident halfedges. We look for the predecessor halfedge and
// insert the curve from this right vertex.
Arr_parameter_space bx = curr_event->parameter_space_in_x();
Arr_parameter_space by = curr_event->parameter_space_in_y();
CGAL_assertion((bx != ARR_INTERIOR) || (by != ARR_INTERIOR));
Halfedge_handle r_prev = Halfedge_handle
(m_top_traits->locate_around_boundary_vertex(&(*v_right), _curve(cv),
ARR_MAX_END, bx, by));
res = this->insert_from_right_vertex (cv, r_prev, sc);
}
else
res = this->insert_in_face_interior(cv, sc);
}
}
}
else
{
// The previous event on the curve is already in the arrangement,
// therefore we use it to insert the subcurve.
// First, we skip some halfedges around the left vertex to get the true // First, we skip some halfedges around the left vertex to get the true
// predecessor halfedge for the insertion. // predecessor halfedge for the insertion.
for (int i = 0; i < jump; i++) { for (int i = 0; i < jump; i++)
he_left = (he_left->next())->twin(); he_left = (he_left->next())->twin();
}
#if CGAL_ARR_CONSTRUCTION_SL_VISITOR_VERBOSE #if CGAL_ARR_CONSTRUCTION_SL_VISITOR_VERBOSE
if (jump != 0) { if (jump != 0) {
std::cout << "CGAL_CSLV JUMP: " << jump << std::endl; std::cout << "CGAL_CSLV JUMP: " << jump << std::endl;
@ -553,35 +493,44 @@ add_subcurve (const X_monotone_curve_2& cv, Subcurve* sc)
std::cout << "he_leftfac : " << &(*he_left->face()) << std::endl; std::cout << "he_leftfac : " << &(*he_left->face()) << std::endl;
} }
#endif #endif
}
if (he_right != invalid_he) // Check whether the current event is already in the arrangement
{ if (he_right == invalid_he) {
CGAL_assertion (he_left->face() == he_right->face()); // We do not have handles for any of the curve end, so we insert it in
// the interior of a face.
Event* curr_event = this->current_event();
Vertex_handle v_right = curr_event->vertex_handle();
if ((v_right != m_invalid_vertex) && (v_right->degree() > 0)) {
// The left vertex v is a boundary vertex which already has some
// incident halfedges. We look for the predecessor halfedge and
// insert the curve from this right vertex.
Arr_parameter_space bx = curr_event->parameter_space_in_x();
Arr_parameter_space by = curr_event->parameter_space_in_y();
CGAL_assertion((bx != ARR_INTERIOR) || (by != ARR_INTERIOR));
he_right = Halfedge_handle
(m_top_traits->locate_around_boundary_vertex(&(*v_right), _curve(cv),
ARR_MAX_END, bx, by));
}
}
// We also have a handle for the current event, representing the right // Check whether the verteices to be associated with the left end and
// vertex of the subcurve. We insert the subcurve using the two // the right end of the curve have already been created.
// predecessor halfedges.
bool dummy; bool dummy;
res = (he_left != invalid_he) ?
((he_right != invalid_he) ?
this->insert_at_vertices(cv, he_right, he_left, sc, dummy) :
this->insert_from_left_vertex(cv, he_left, sc)) :
((he_right != invalid_he) ?
this->insert_from_right_vertex(cv, he_right, sc) :
this->insert_in_face_interior(cv, sc));
#if CGAL_ARR_CONSTRUCTION_SL_VISITOR_VERBOSE #if CGAL_ARR_CONSTRUCTION_SL_VISITOR_VERBOSE
std::cout << "CGAL_CSLV call insert_at_vertices" << std::endl; std::cout << "CGAL_CSLV res: " << &(*res) << " with face " << &(*res->face())
#endif << " is " << res->direction() << std::endl;
res = this->insert_at_vertices (cv, he_right, he_left, sc, dummy); std::cout << "CGAL_CSLV twi: " << &(*res->twin()) << " with face "
} << &(*res->twin()->face()) << " is " << res->twin()->direction()
else << std::endl;
{
// We only have a handle for the predecessor halfedge of the left end
// of the subcurve - use it to insert the subcurve.
#if CGAL_ARR_CONSTRUCTION_SL_VISITOR_VERBOSE
std::cout << "CGAL_CSLV call insert_from_left_vertex" << std::endl;
#endif
res = this->insert_from_left_vertex (cv, he_left, sc);
}
}
#if CGAL_ARR_CONSTRUCTION_SL_VISITOR_VERBOSE
std::cout << "CGAL_CSLV res: " << &(*res) << " with face " << &(*res->face()) << " is " << res->direction() << std::endl;
std::cout << "CGAL_CSLV twi: " << &(*res->twin()) << " with face " << &(*res->twin()->face()) << " is " << res->twin()->direction() << std::endl;
#endif #endif
// Make sure that res is a halfedge that is always directed from left to // Make sure that res is a halfedge that is always directed from left to
@ -605,8 +554,7 @@ add_subcurve (const X_monotone_curve_2& cv, Subcurve* sc)
} }
// If sc has valid index, insert its index to m_sc_he_table. // If sc has valid index, insert its index to m_sc_he_table.
if(sc->has_valid_index()) if (sc->has_valid_index()) {
{
CGAL_assertion(res->twin()->direction() == ARR_RIGHT_TO_LEFT); CGAL_assertion(res->twin()->direction() == ARR_RIGHT_TO_LEFT);
_map_new_halfedge(sc->index(), res->twin()); _map_new_halfedge(sc->index(), res->twin());
} }
@ -620,16 +568,13 @@ add_subcurve (const X_monotone_curve_2& cv, Subcurve* sc)
// In case the event has no more right subcurves associated with it, we can // In case the event has no more right subcurves associated with it, we can
// deallocate it. Note that we inform the helper class before deallocating // deallocate it. Note that we inform the helper class before deallocating
// the event. // the event.
if (last_event->dec_right_curves_counter() == 0) if (last_event->dec_right_curves_counter() == 0) {
{
m_helper.before_deallocate_event(last_event); m_helper.before_deallocate_event(last_event);
this->deallocate_event(last_event); this->deallocate_event(last_event);
} }
// Clear the list of indices of the subcurve. // Clear the list of indices of the subcurve.
sc->clear_halfedge_indices(); sc->clear_halfedge_indices();
return;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -644,8 +589,6 @@ insert_in_face_interior (const X_monotone_curve_2& cv, Subcurve* sc)
std::cout << "CGAL_CSLV insert_in_face_interior\ncurve: " << cv << std::endl; std::cout << "CGAL_CSLV insert_in_face_interior\ncurve: " << cv << std::endl;
#endif #endif
// Check if the vertex to be associated with the left end of the curve has
// already been created.
Event* last_event = last_event_on_subcurve(sc); Event* last_event = last_event_on_subcurve(sc);
Vertex_handle v1 = last_event->vertex_handle(); Vertex_handle v1 = last_event->vertex_handle();
CGAL_assertion((v1 == m_invalid_vertex) || (v1->degree() == 0)); CGAL_assertion((v1 == m_invalid_vertex) || (v1->degree() == 0));
@ -654,8 +597,6 @@ insert_in_face_interior (const X_monotone_curve_2& cv, Subcurve* sc)
// Create the vertex to be associated with the left end of the curve. // Create the vertex to be associated with the left end of the curve.
v1 = m_arr_access.create_vertex(_point(last_event->point())); v1 = m_arr_access.create_vertex(_point(last_event->point()));
// Check if the vertex to be associated with the right end of the curve has
// already been created.
Event* curr_event = this->current_event(); Event* curr_event = this->current_event();
Vertex_handle v2 = curr_event->vertex_handle(); Vertex_handle v2 = curr_event->vertex_handle();
CGAL_assertion((v2 == m_invalid_vertex) || (v2->degree() == 0)); CGAL_assertion((v2 == m_invalid_vertex) || (v2->degree() == 0));
@ -672,8 +613,7 @@ insert_in_face_interior (const X_monotone_curve_2& cv, Subcurve* sc)
// Map the new halfedge to the indices list of all subcurves that lie // Map the new halfedge to the indices list of all subcurves that lie
// below it. // below it.
if (sc->has_halfedge_indices()) if (sc->has_halfedge_indices()) {
{
CGAL_assertion(res->twin()->direction() == ARR_RIGHT_TO_LEFT); CGAL_assertion(res->twin()->direction() == ARR_RIGHT_TO_LEFT);
Indices_list& list_ref = m_he_indices_table[res->twin()]; Indices_list& list_ref = m_he_indices_table[res->twin()];
list_ref.clear(); list_ref.clear();
@ -691,14 +631,13 @@ insert_in_face_interior (const X_monotone_curve_2& cv, Subcurve* sc)
// //
template <class Hlpr> template <class Hlpr>
typename Arr_construction_sl_visitor<Hlpr>::Halfedge_handle typename Arr_construction_sl_visitor<Hlpr>::Halfedge_handle
Arr_construction_sl_visitor<Hlpr>::insert_at_vertices Arr_construction_sl_visitor<Hlpr>::
(const X_monotone_curve_2& cv, insert_at_vertices(const X_monotone_curve_2& cv,
Halfedge_handle prev1, Halfedge_handle prev1,
Halfedge_handle prev2, Halfedge_handle prev2,
Subcurve* sc, Subcurve* sc,
bool& new_face_created) bool& new_face_created)
{ {
#if CGAL_ARR_CONSTRUCTION_SL_VISITOR_VERBOSE #if CGAL_ARR_CONSTRUCTION_SL_VISITOR_VERBOSE
std::cout << "CGAL_CSLV insert_at_vertices:\ncurve:" << cv << std::endl; std::cout << "CGAL_CSLV insert_at_vertices:\ncurve:" << cv << std::endl;
if (!prev1->is_fictitious()) { if (!prev1->is_fictitious()) {
@ -730,8 +669,7 @@ Arr_construction_sl_visitor<Hlpr>::insert_at_vertices
std::pair< bool, bool > update(false, false); std::pair< bool, bool > update(false, false);
#if 0 #if 0
if ((prev1->is_on_inner_ccb() && prev1->is_on_inner_ccb() && if ((prev1->is_on_inner_ccb() && prev1->is_on_inner_ccb() &&
prev1->inner_ccb() == prev2->inner_ccb()) prev1->inner_ccb() == prev2->inner_ccb()) ||
||
(!prev1->is_on_inner_ccb() && prev1->is_on_inner_ccb())) { (!prev1->is_on_inner_ccb() && prev1->is_on_inner_ccb())) {
#else #else
// TODO improve this code! // TODO improve this code!
@ -754,15 +692,12 @@ Arr_construction_sl_visitor<Hlpr>::insert_at_vertices
if (found1 && found2) { if (found1 && found2) {
#endif #endif
update = update =
m_top_traits->face_update_upon_edge_insertion( m_top_traits->face_update_upon_edge_insertion(&(*prev1), &(*prev2), cv);
&(*prev1), &(*prev2), cv
);
} }
const bool swap_preds = update.second; const bool swap_preds = update.second;
// TODO propagate update.first to _insert_at_vertices! // TODO propagate update.first to _insert_at_vertices!
#else #else
const bool swap_preds = const bool swap_preds = m_helper.swap_predecessors(this->current_event());
m_helper.swap_predecessors (this->current_event());
#endif #endif
// Comment: In some topologies swap_preds is always false, // Comment: In some topologies swap_preds is always false,
@ -782,27 +717,29 @@ Arr_construction_sl_visitor<Hlpr>::insert_at_vertices
#if 1 #if 1
res = (swap_preds) ? res = (swap_preds) ?
// if swapping prev2 will become outer of new split face (it it exists) // if swapping prev2 will become outer of new split face (it it exists)
m_arr_access.insert_at_vertices_ex (prev2, _curve(cv), ARR_LEFT_TO_RIGHT, prev1->next(), m_arr_access.insert_at_vertices_ex(prev2, _curve(cv), ARR_LEFT_TO_RIGHT,
new_face_created, check_swapped_predecessors, false) : prev1->next(), new_face_created,
check_swapped_predecessors, false) :
// usually prev1 is outer of new split face (it it exists) // usually prev1 is outer of new split face (it it exists)
// order is determined by top-traits helper! // order is determined by top-traits helper!
// "false" disallows swapping of prev1/preve2! ... // "false" disallows swapping of prev1/preve2! ...
m_arr_access.insert_at_vertices_ex (prev1, _curve(cv), ARR_RIGHT_TO_LEFT, prev2->next(), m_arr_access.insert_at_vertices_ex(prev1, _curve(cv), ARR_RIGHT_TO_LEFT,
new_face_created, check_swapped_predecessors, false); prev2->next(), new_face_created,
check_swapped_predecessors, false);
// ... thus the value should now have changed // ... thus the value should now have changed
CGAL_assertion(!check_swapped_predecessors); CGAL_assertion(!check_swapped_predecessors);
#else #else
res = m_arr_access.insert_at_vertices_ex (prev1, _curve(cv), ARR_RIGHT_TO_LEFT, prev2->next(), res = m_arr_access.insert_at_vertices_ex(prev1, _curve(cv), ARR_RIGHT_TO_LEFT,
new_face_created, check_swapped_predecessors); prev2->next(), new_face_created,
check_swapped_predecessors);
if (check_swapped_predecessors) if (check_swapped_predecessors)
res = res->twin(); res = res->twin();
#endif #endif
// Map the new halfedge to the indices list of all subcurves that lie // Map the new halfedge to the indices list of all subcurves that lie
// below it. // below it.
if (sc->has_halfedge_indices()) if (sc->has_halfedge_indices()) {
{
Halfedge_handle he = res; Halfedge_handle he = res;
if (swap_preds) if (swap_preds)
@ -820,8 +757,7 @@ Arr_construction_sl_visitor<Hlpr>::insert_at_vertices
// face (if one is created). // face (if one is created).
m_helper.add_subcurve(res, sc); m_helper.add_subcurve(res, sc);
if (new_face_created) if (new_face_created) {
{
// TODO EBEB 2012-10-17 needs a tests for outer-outer insertion // TODO EBEB 2012-10-17 needs a tests for outer-outer insertion
// In case a new face has been created (pointed by the new halfedge // In case a new face has been created (pointed by the new halfedge
// we obtained), we have to examine the holes and isolated vertices // we obtained), we have to examine the holes and isolated vertices
@ -839,8 +775,8 @@ Arr_construction_sl_visitor<Hlpr>::insert_at_vertices
// //
template <class Hlpr> template <class Hlpr>
typename Arr_construction_sl_visitor<Hlpr>::Halfedge_handle typename Arr_construction_sl_visitor<Hlpr>::Halfedge_handle
Arr_construction_sl_visitor<Hlpr>::insert_from_right_vertex Arr_construction_sl_visitor<Hlpr>::
(const X_monotone_curve_2& cv, insert_from_right_vertex(const X_monotone_curve_2& cv,
Halfedge_handle prev, Halfedge_handle prev,
Subcurve* sc) Subcurve* sc)
{ {
@ -855,33 +791,13 @@ Arr_construction_sl_visitor<Hlpr>::insert_from_right_vertex
std::cout << "prevfac : " << &(*prev->face()) << std::endl; std::cout << "prevfac : " << &(*prev->face()) << std::endl;
#endif #endif
// Check if the vertex to be associated with the left end of the curve has
// already been created.
Event* last_event = last_event_on_subcurve(sc); Event* last_event = last_event_on_subcurve(sc);
Vertex_handle v = last_event->vertex_handle(); Vertex_handle v = last_event->vertex_handle();
CGAL_assertion((v == m_invalid_vertex) || (v->degree() == 0));
if (v == m_invalid_vertex)
{
// Create the vertex to be associated with the left end of the curve. // Create the vertex to be associated with the left end of the curve.
if (v == m_invalid_vertex)
v = m_arr_access.create_vertex(_point(last_event->point())); v = m_arr_access.create_vertex(_point(last_event->point()));
}
else if (v->degree() > 0)
{
// In this case the left vertex v is a boundary vertex which already has
// some incident halfedges. We look for the predecessor halfedge and
// and insert the curve between two existing vertices.
Arr_parameter_space bx = last_event->parameter_space_in_x();
Arr_parameter_space by = last_event->parameter_space_in_y();
CGAL_assertion (bx != ARR_INTERIOR || by != ARR_INTERIOR);
Halfedge_handle l_prev = Halfedge_handle
(m_top_traits->locate_around_boundary_vertex (&(*v), _curve(cv),
ARR_MIN_END, bx, by));
bool dummy;
return (this->insert_at_vertices (cv, prev, l_prev, sc, dummy));
}
// Insert the curve given its left vertex and the predecessor around the // Insert the curve given its left vertex and the predecessor around the
// right vertex. // right vertex.
@ -890,8 +806,7 @@ Arr_construction_sl_visitor<Hlpr>::insert_from_right_vertex
// Map the new halfedge to the indices list of all subcurves that lie // Map the new halfedge to the indices list of all subcurves that lie
// below it. // below it.
if (sc->has_halfedge_indices()) if (sc->has_halfedge_indices()) {
{
CGAL_assertion(res->direction() == ARR_RIGHT_TO_LEFT); CGAL_assertion(res->direction() == ARR_RIGHT_TO_LEFT);
Indices_list& list_ref = m_he_indices_table[res]; Indices_list& list_ref = m_he_indices_table[res];
list_ref.clear(); list_ref.clear();
@ -925,34 +840,13 @@ insert_from_left_vertex (const X_monotone_curve_2& cv,
std::cout << "prevfac : " << &(*prev->face()) << std::endl; std::cout << "prevfac : " << &(*prev->face()) << std::endl;
#endif #endif
// Check if the vertex to be associated with the right end of the curve has
// already been created.
Event* curr_event = this->current_event(); Event* curr_event = this->current_event();
Vertex_handle v = curr_event->vertex_handle(); Vertex_handle v = curr_event->vertex_handle();
CGAL_assertion((v == m_invalid_vertex) || (v->degree() == 0));
if (v == m_invalid_vertex)
{
// Create the vertex to be associated with the right end of the curve. // Create the vertex to be associated with the right end of the curve.
if (v == m_invalid_vertex)
v = m_arr_access.create_vertex(_point(curr_event->point())); v = m_arr_access.create_vertex(_point(curr_event->point()));
}
else if (v->degree() > 0)
{
// In this case the left vertex v is a boundary vertex which already has
// some incident halfedges. We look for the predecessor halfedge and
// and insert the curve from this right vertex.
Arr_parameter_space bx = curr_event->parameter_space_in_x();
Arr_parameter_space by = curr_event->parameter_space_in_y();
CGAL_assertion (bx != ARR_INTERIOR || by != ARR_INTERIOR);
Halfedge_handle r_prev = Halfedge_handle
(m_top_traits->locate_around_boundary_vertex (&(*v), _curve(cv),
ARR_MAX_END, bx, by)
);
bool dummy;
return (this->insert_at_vertices (cv, r_prev, prev, sc, dummy));
}
// Insert the curve given its right vertex and the predecessor around the // Insert the curve given its right vertex and the predecessor around the
// left vertex. // left vertex.
@ -961,8 +855,7 @@ insert_from_left_vertex (const X_monotone_curve_2& cv,
// Map the new halfedge to the indices list of all subcurves that lie // Map the new halfedge to the indices list of all subcurves that lie
// below it. // below it.
if (sc->has_halfedge_indices()) if (sc->has_halfedge_indices()) {
{
CGAL_assertion(res->twin()->direction() == ARR_RIGHT_TO_LEFT); CGAL_assertion(res->twin()->direction() == ARR_RIGHT_TO_LEFT);
Indices_list& list_ref = m_he_indices_table[res->twin()]; Indices_list& list_ref = m_he_indices_table[res->twin()];
list_ref.clear(); list_ref.clear();
@ -990,16 +883,14 @@ insert_isolated_vertex (const Point_2& pt,
// Insert the isolated vertex in the interior of the current top face, as // Insert the isolated vertex in the interior of the current top face, as
// given by the helper class. // given by the helper class.
return (m_arr->insert_in_face_interior (_point(pt), return (m_arr->insert_in_face_interior(_point(pt), m_helper.top_face()));
m_helper.top_face()));
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Reloacte holes and isolated vertices inside a newly created face. // Reloacte holes and isolated vertices inside a newly created face.
// //
template <class Hlpr> template <class Hlpr>
void Arr_construction_sl_visitor<Hlpr>:: void Arr_construction_sl_visitor<Hlpr>::relocate_in_new_face(Halfedge_handle he)
relocate_in_new_face (Halfedge_handle he)
{ {
#if 0 #if 0
std::cout << "CGAL_CSLV relocate" << std::endl; std::cout << "CGAL_CSLV relocate" << std::endl;
@ -1016,11 +907,9 @@ relocate_in_new_face (Halfedge_handle he)
const Halfedge_handle invalid_he; const Halfedge_handle invalid_he;
Vertex_handle v; Vertex_handle v;
do do {
{
// We are interested only in halfedges directed from right to left. // We are interested only in halfedges directed from right to left.
if (curr_he->direction() == ARR_LEFT_TO_RIGHT) if (curr_he->direction() == ARR_LEFT_TO_RIGHT) {
{
curr_he = curr_he->next(); curr_he = curr_he->next();
continue; continue;
} }
@ -1030,8 +919,7 @@ relocate_in_new_face (Halfedge_handle he)
const Indices_list& indices_list = const_he_indices_table[curr_he]; const Indices_list& indices_list = const_he_indices_table[curr_he];
typename Indices_list::const_iterator itr; typename Indices_list::const_iterator itr;
for (itr = indices_list.begin(); itr != indices_list.end(); ++itr) for (itr = indices_list.begin(); itr != indices_list.end(); ++itr) {
{
#if CGAL_ARR_CONSTRUCTION_SL_VISITOR_VERBOSE #if CGAL_ARR_CONSTRUCTION_SL_VISITOR_VERBOSE
std::cout << "itr: " << *itr << std::endl; std::cout << "itr: " << *itr << std::endl;
std::cout << "m_sc_counter: " << m_sc_counter << std::endl; std::cout << "m_sc_counter: " << m_sc_counter << std::endl;
@ -1049,22 +937,17 @@ relocate_in_new_face (Halfedge_handle he)
Halfedge_handle he_on_face = m_sc_he_table[*itr]; Halfedge_handle he_on_face = m_sc_he_table[*itr];
if(he_on_face == invalid_he) if (he_on_face == invalid_he) {
{
// If the halfedge handle is invalis, then we have an index for an // If the halfedge handle is invalis, then we have an index for an
// isolated vertex. Move this vertex to the new face, if necessary. // isolated vertex. Move this vertex to the new face, if necessary.
v = m_iso_verts_map[*itr]; v = m_iso_verts_map[*itr];
CGAL_assertion(v != m_invalid_vertex); CGAL_assertion(v != m_invalid_vertex);
if (v->face() != new_face) if (v->face() != new_face) {
{ m_arr_access.move_isolated_vertex(v->face(), new_face, v);
m_arr_access.move_isolated_vertex (v->face(),
new_face,
v);
} }
} }
else else {
{
// If necessary, move the hole that the halfedge belongs to into the // If necessary, move the hole that the halfedge belongs to into the
// new face. // new face.
if (he_on_face->twin()->face() != new_face && if (he_on_face->twin()->face() != new_face &&
@ -1086,8 +969,6 @@ relocate_in_new_face (Halfedge_handle he)
curr_he = curr_he->next(); curr_he = curr_he->next();
} while(curr_he != he); } while(curr_he != he);
return;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -1108,7 +989,6 @@ _map_new_halfedge (unsigned int i, Halfedge_handle he)
// Map the index to the given halfedge handle. // Map the index to the given halfedge handle.
m_sc_he_table[i] = he; m_sc_he_table[i] = he;
return;
} }
} //namespace CGAL } //namespace CGAL