mirror of https://github.com/CGAL/cgal
Fixed do_intersect() and cleaned up
This commit is contained in:
parent
b871b81d57
commit
5b6df813f5
|
|
@ -40,7 +40,6 @@ class Arr_do_intersect_overlay_ss_visitor :
|
|||
OverlayHelper, OverlayTraits,
|
||||
typename Default::Get<Visitor_,
|
||||
Arr_do_intersect_overlay_ss_visitor<OverlayHelper, OverlayTraits, Visitor_> >::type> {
|
||||
|
||||
private:
|
||||
using Overlay_helper = OverlayHelper;
|
||||
using Overlay_traits = OverlayTraits;
|
||||
|
|
@ -61,6 +60,7 @@ public:
|
|||
using Status_line_iterator = typename Base::Status_line_iterator;
|
||||
using X_monotone_curve_2 = typename Base::X_monotone_curve_2;
|
||||
using Point_2 = typename Base::Point_2;
|
||||
using Multiplicity = typename Base::Multiplicity;
|
||||
|
||||
/*! Constructor */
|
||||
Arr_do_intersect_overlay_ss_visitor(const Arrangement_red_2* red_arr,
|
||||
|
|
@ -90,11 +90,15 @@ public:
|
|||
void update_event(Event* e, Subcurve* sc) { return Base::update_event(e, sc); }
|
||||
|
||||
/*! Update an event that corresponds to an intersection between curves */
|
||||
void update_event(Event*, Subcurve*, Subcurve*, bool is_new) { m_found_x = true; }
|
||||
void update_event(Event* e, Subcurve* sc1, Subcurve* sc2, bool is_new, Multiplicity multiplicity) {
|
||||
if ((multiplicity % 2) == 1) m_found_x = true;
|
||||
Base::update_event(e, sc1, sc2, is_new, multiplicity);
|
||||
}
|
||||
|
||||
bool after_handle_event(Event* e, Status_line_iterator iter, bool flag) {
|
||||
auto res = Base::after_handle_event(e, iter, flag);
|
||||
if (m_found_x) this->surface_sweep()->stop_sweep();
|
||||
return Base::after_handle_event(e, iter, flag);
|
||||
return res;
|
||||
}
|
||||
|
||||
/*! Getter */
|
||||
|
|
|
|||
|
|
@ -8,9 +8,9 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
|
||||
//
|
||||
//
|
||||
// Author(s): Baruch Zukerman <baruchzu@post.tau.ac.il>
|
||||
// Ron Wein <wein@post.tau.ac.il>
|
||||
// Efi Fogel <efif@post.tau.ac.il>
|
||||
// Author(s) : Baruch Zukerman <baruchzu@post.tau.ac.il>
|
||||
// Ron Wein <wein@post.tau.ac.il>
|
||||
// Efi Fogel <efif@post.tau.ac.il>
|
||||
|
||||
#ifndef CGAL_ARR_NO_INTERSECTION_INSERTION_SS_VISITOR_H
|
||||
#define CGAL_ARR_NO_INTERSECTION_INSERTION_SS_VISITOR_H
|
||||
|
|
@ -42,35 +42,33 @@ class Arr_no_intersection_insertion_ss_visitor :
|
|||
public Arr_construction_ss_visitor<
|
||||
Helper_,
|
||||
typename Default::Get<Visitor_, Arr_no_intersection_insertion_ss_visitor<
|
||||
Helper_, Visitor_> >::type>
|
||||
{
|
||||
Helper_, Visitor_> >::type> {
|
||||
public:
|
||||
typedef Helper_ Helper;
|
||||
using Helper = Helper_;
|
||||
|
||||
typedef typename Helper::Geometry_traits_2 Geometry_traits_2;
|
||||
typedef typename Helper::Event Event;
|
||||
typedef typename Helper::Subcurve Subcurve;
|
||||
using Geometry_traits_2 = typename Helper::Geometry_traits_2;
|
||||
using Event = typename Helper::Event;
|
||||
using Subcurve = typename Helper::Subcurve;
|
||||
|
||||
private:
|
||||
typedef Geometry_traits_2 Gt2;
|
||||
typedef Arr_no_intersection_insertion_ss_visitor<Helper, Visitor_>
|
||||
Self;
|
||||
typedef typename Default::Get<Visitor_, Self>::type Visitor;
|
||||
typedef Arr_construction_ss_visitor<Helper, Visitor> Base;
|
||||
using Gt2 = Geometry_traits_2;
|
||||
using Self = Arr_no_intersection_insertion_ss_visitor<Helper, Visitor_>;
|
||||
using Visitor = typename Default::Get<Visitor_, Self>::type;
|
||||
using Base = Arr_construction_ss_visitor<Helper, Visitor>;
|
||||
|
||||
public:
|
||||
typedef typename Gt2::X_monotone_curve_2 X_monotone_curve_2;
|
||||
typedef typename Gt2::Point_2 Point_2;
|
||||
using X_monotone_curve_2 = typename Gt2::X_monotone_curve_2;
|
||||
using Point_2 = typename Gt2::Point_2;
|
||||
using Multiplicity = typename Gt2::Multiplicity;
|
||||
|
||||
protected:
|
||||
typedef typename Subcurve::Status_line_iterator Status_line_iterator;
|
||||
typedef typename Base::Event_subcurve_reverse_iterator
|
||||
Event_subcurve_reverse_iterator;
|
||||
using Status_line_iterator = typename Subcurve::Status_line_iterator;
|
||||
using Event_subcurve_reverse_iterator = typename Base::Event_subcurve_reverse_iterator;
|
||||
|
||||
typedef typename Helper::Arrangement_2 Arrangement_2;
|
||||
typedef typename Arrangement_2::Vertex_handle Vertex_handle;
|
||||
typedef typename Arrangement_2::Halfedge_handle Halfedge_handle;
|
||||
typedef typename Arrangement_2::Face_handle Face_handle;
|
||||
using Arrangement_2 = typename Helper::Arrangement_2;
|
||||
using Vertex_handle = typename Arrangement_2::Vertex_handle;
|
||||
using Halfedge_handle = typename Arrangement_2::Halfedge_handle;
|
||||
using Face_handle = typename Arrangement_2::Face_handle;
|
||||
|
||||
public:
|
||||
/*! Constructor. */
|
||||
|
|
@ -103,13 +101,12 @@ public:
|
|||
{}
|
||||
|
||||
void update_event(Event* /* e */, Subcurve* /* sc1 */, Subcurve* /* sc2 */,
|
||||
bool /* is_new */)
|
||||
bool /* is_new */, Multiplicity /* multiplicity */)
|
||||
{}
|
||||
|
||||
void update_event(Event* /* e */, Subcurve* /* sc1 */) {}
|
||||
|
||||
void update_event(Event* e, const Point_2& pt, bool /* is_new */)
|
||||
{
|
||||
void update_event(Event* e, const Point_2& pt, bool /* is_new */) {
|
||||
Vertex_handle invalid_v;
|
||||
if (e->point().vertex_handle() == invalid_v)
|
||||
e->point().set_vertex_handle(pt.vertex_handle());
|
||||
|
|
@ -241,8 +238,7 @@ void Arr_no_intersection_insertion_ss_visitor<Hlpr, Vis>::before_sweep()
|
|||
//
|
||||
template <typename Hlpr, typename Vis>
|
||||
void Arr_no_intersection_insertion_ss_visitor<Hlpr, Vis>::
|
||||
before_handle_event(Event* event)
|
||||
{
|
||||
before_handle_event(Event* event) {
|
||||
// First we notify the helper class on the event.
|
||||
this->m_helper.before_handle_event(event);
|
||||
|
||||
|
|
@ -330,8 +326,7 @@ before_handle_event(Event* event)
|
|||
//
|
||||
template <typename Hlpr, typename Vis>
|
||||
bool Arr_no_intersection_insertion_ss_visitor<Hlpr, Vis>::
|
||||
add_subcurve_(const X_monotone_curve_2& cv, Subcurve* sc)
|
||||
{
|
||||
add_subcurve_(const X_monotone_curve_2& cv, Subcurve* sc) {
|
||||
const Halfedge_handle invalid_he;
|
||||
if (cv.halfedge_handle() != invalid_he) return false;
|
||||
// Insert the curve into the arrangement
|
||||
|
|
@ -344,8 +339,7 @@ add_subcurve_(const X_monotone_curve_2& cv, Subcurve* sc)
|
|||
//
|
||||
template <typename Hlpr, typename Vis>
|
||||
void Arr_no_intersection_insertion_ss_visitor<Hlpr, Vis>::
|
||||
add_subcurve(const X_monotone_curve_2& cv, Subcurve* sc)
|
||||
{
|
||||
add_subcurve(const X_monotone_curve_2& cv, Subcurve* sc) {
|
||||
if (add_subcurve_(cv, sc)) return;
|
||||
|
||||
Halfedge_handle next_ccw_he =
|
||||
|
|
@ -359,8 +353,7 @@ add_subcurve(const X_monotone_curve_2& cv, Subcurve* sc)
|
|||
template <typename Hlpr, typename Vis>
|
||||
typename Arr_no_intersection_insertion_ss_visitor<Hlpr, Vis>::Halfedge_handle
|
||||
Arr_no_intersection_insertion_ss_visitor<Hlpr, Vis>::
|
||||
insert_in_face_interior(const X_monotone_curve_2& cv, Subcurve* sc)
|
||||
{
|
||||
insert_in_face_interior(const X_monotone_curve_2& cv, Subcurve* sc) {
|
||||
Event* last_event = this->last_event_on_subcurve(sc);
|
||||
Vertex_handle last_v = last_event->point().vertex_handle();
|
||||
Vertex_handle curr_v = this->current_event()->point().vertex_handle();
|
||||
|
|
@ -385,8 +378,7 @@ template <typename Hlpr, typename Vis>
|
|||
typename Arr_no_intersection_insertion_ss_visitor<Hlpr, Vis>::Halfedge_handle
|
||||
Arr_no_intersection_insertion_ss_visitor<Hlpr, Vis>::
|
||||
insert_from_left_vertex(const X_monotone_curve_2& cv, Halfedge_handle he,
|
||||
Subcurve* sc)
|
||||
{
|
||||
Subcurve* sc) {
|
||||
Vertex_handle curr_v = this->current_event()->point().vertex_handle();
|
||||
if (curr_v != Vertex_handle())
|
||||
return (this->m_arr->insert_at_vertices(cv.base(), he, curr_v));
|
||||
|
|
@ -400,8 +392,7 @@ template <typename Hlpr, typename Vis>
|
|||
typename Arr_no_intersection_insertion_ss_visitor<Hlpr, Vis>::Halfedge_handle
|
||||
Arr_no_intersection_insertion_ss_visitor<Hlpr, Vis>::
|
||||
insert_from_right_vertex(const X_monotone_curve_2& cv, Halfedge_handle he,
|
||||
Subcurve* sc)
|
||||
{
|
||||
Subcurve* sc) {
|
||||
Event* last_event = this->last_event_on_subcurve(sc);
|
||||
Vertex_handle last_v = last_event->point().vertex_handle();
|
||||
if (last_v != Vertex_handle())
|
||||
|
|
@ -426,8 +417,7 @@ insert_at_vertices(const X_monotone_curve_2& cv,
|
|||
template <typename Hlpr, typename Vis>
|
||||
typename Arr_no_intersection_insertion_ss_visitor<Hlpr, Vis>::Vertex_handle
|
||||
Arr_no_intersection_insertion_ss_visitor<Hlpr, Vis>::
|
||||
insert_isolated_vertex(const Point_2& pt, Status_line_iterator iter)
|
||||
{
|
||||
insert_isolated_vertex(const Point_2& pt, Status_line_iterator iter) {
|
||||
// If the isolated vertex is already at the arrangement, return:
|
||||
if (pt.vertex_handle() != Vertex_handle()) return Vertex_handle();
|
||||
|
||||
|
|
@ -443,8 +433,7 @@ insert_isolated_vertex(const Point_2& pt, Status_line_iterator iter)
|
|||
template <typename Hlpr, typename Vis>
|
||||
typename Arr_no_intersection_insertion_ss_visitor<Hlpr, Vis>::Halfedge_handle
|
||||
Arr_no_intersection_insertion_ss_visitor<Hlpr, Vis>::
|
||||
_insert_in_face_interior(const X_monotone_curve_2& cv, Subcurve* sc)
|
||||
{
|
||||
_insert_in_face_interior(const X_monotone_curve_2& cv, Subcurve* sc) {
|
||||
// Check if the vertex to be associated with the left end of the curve has
|
||||
// already been created.
|
||||
Event* last_event = this->last_event_on_subcurve(sc);
|
||||
|
|
@ -514,8 +503,7 @@ template <typename Hlpr, typename Vis>
|
|||
typename Arr_no_intersection_insertion_ss_visitor<Hlpr, Vis>::Halfedge_handle
|
||||
Arr_no_intersection_insertion_ss_visitor<Hlpr, Vis>::
|
||||
_insert_from_left_vertex(const X_monotone_curve_2& cv,
|
||||
Halfedge_handle prev, Subcurve* sc)
|
||||
{
|
||||
Halfedge_handle prev, Subcurve* sc) {
|
||||
// Check if the vertex to be associated with the right end of the curve has
|
||||
// already been created.
|
||||
Event* curr_event = this->current_event();
|
||||
|
|
@ -551,8 +539,7 @@ template <typename Hlpr, typename Vis>
|
|||
typename Arr_no_intersection_insertion_ss_visitor<Hlpr, Vis>::Halfedge_handle
|
||||
Arr_no_intersection_insertion_ss_visitor<Hlpr, Vis>::
|
||||
_insert_from_right_vertex(const X_monotone_curve_2& cv, Halfedge_handle prev,
|
||||
Subcurve* sc)
|
||||
{
|
||||
Subcurve* sc) {
|
||||
// Check if the vertex to be associated with the left end of the curve has
|
||||
// already been created.
|
||||
Event* last_event = this->last_event_on_subcurve(sc);
|
||||
|
|
@ -589,8 +576,7 @@ typename Arr_no_intersection_insertion_ss_visitor<Hlpr, Vis>::Halfedge_handle
|
|||
Arr_no_intersection_insertion_ss_visitor<Hlpr, Vis>::
|
||||
_insert_at_vertices(const X_monotone_curve_2& cv,
|
||||
Halfedge_handle prev1, Halfedge_handle prev2,
|
||||
Subcurve* sc, bool& new_face_created)
|
||||
{
|
||||
Subcurve* sc, bool& new_face_created) {
|
||||
// Perform the insertion.
|
||||
new_face_created = false;
|
||||
bool swapped_predecessors = false;
|
||||
|
|
@ -632,8 +618,7 @@ _insert_at_vertices(const X_monotone_curve_2& cv,
|
|||
template <typename Hlpr, typename Vis>
|
||||
typename Arr_no_intersection_insertion_ss_visitor<Hlpr, Vis>::Face_handle
|
||||
Arr_no_intersection_insertion_ss_visitor<Hlpr, Vis>::
|
||||
_ray_shoot_up(Status_line_iterator iter)
|
||||
{
|
||||
_ray_shoot_up(Status_line_iterator iter) {
|
||||
// Go up the status line and try to locate a curve which is associated
|
||||
// with a valid arrangement halfedge.
|
||||
const Halfedge_handle invalid_he;
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@ private:
|
|||
public:
|
||||
using X_monotone_curve_2 = typename Gt2::X_monotone_curve_2;
|
||||
using Point_2 = typename Gt2::Point_2;
|
||||
using Multiplicity = typename Gt2::Multiplicity;
|
||||
|
||||
// The input arrangements (the "red" and the "blue" one):
|
||||
using Halfedge_handle_red = typename Ar2::Halfedge_const_handle;
|
||||
|
|
@ -182,7 +183,8 @@ public:
|
|||
void update_event(Event* /* e */,
|
||||
Subcurve* /* c1 */,
|
||||
Subcurve* /* c2 */,
|
||||
bool CGAL_assertion_code(is_new))
|
||||
bool CGAL_assertion_code(is_new),
|
||||
Multiplicity /* multiplicity */)
|
||||
{ CGAL_assertion(is_new == true); }
|
||||
|
||||
/*! Update an event. */
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ public:
|
|||
using Status_line_iterator = typename Base::Status_line_iterator;
|
||||
using X_monotone_curve_2 = typename Base::X_monotone_curve_2;
|
||||
using Point_2 = typename Base::Point_2;
|
||||
using Multiplicity = typename Base::Multiplicity;
|
||||
|
||||
Gps_do_intersect_agg_op_visitor(Arr* arr, Edges_hash* hash,
|
||||
std::vector<Vertex_handle>* vertices_vec) :
|
||||
|
|
@ -57,22 +58,26 @@ public:
|
|||
|
||||
/*! Update an event that corresponds to a curve endpoint. */
|
||||
void update_event(Event* e, const Point_2& end_point, const X_monotone_curve_2& cv, Arr_curve_end cv_end, bool is_new)
|
||||
{ return Base::update_event(e, end_point, cv, cv_end, is_new); }
|
||||
{ Base::update_event(e, end_point, cv, cv_end, is_new); }
|
||||
|
||||
/*! Update an event that corresponds to a curve endpoint */
|
||||
void update_event(Event* e, const X_monotone_curve_2& cv, Arr_curve_end cv_end, bool is_new )
|
||||
{ return Base::update_event(e, cv, cv_end, is_new); }
|
||||
{ Base::update_event(e, cv, cv_end, is_new); }
|
||||
|
||||
/*! Update an event that corresponds to a curve endpoint */
|
||||
void update_event(Event* e, const Point_2& p, bool is_new)
|
||||
{ return Base::update_event(e, p, is_new); }
|
||||
{ Base::update_event(e, p, is_new); }
|
||||
|
||||
/*! Update an event that corresponds to an intersection */
|
||||
void update_event(Event* e, Subcurve* sc) { return Base::update_event(e, sc); }
|
||||
void update_event(Event* e, Subcurve* sc) { Base::update_event(e, sc); }
|
||||
|
||||
/*! Update an event that corresponds to an intersection between curves */
|
||||
void update_event(Event*, Subcurve*, Subcurve*, bool is_new) { m_found_x = true; }
|
||||
void update_event(Event* e, Subcurve* sc1, Subcurve* sc2, bool is_new, Multiplicity multiplicity) {
|
||||
if ((multiplicity % 2) == 1) m_found_x = true;
|
||||
Base::update_event(e, sc1, sc2, is_new, multiplicity);
|
||||
}
|
||||
|
||||
//!
|
||||
bool after_handle_event(Event* e, Status_line_iterator iter, bool flag) {
|
||||
auto res = Base::after_handle_event(e, iter, flag);
|
||||
if (m_found_x) this->surface_sweep()->stop_sweep();
|
||||
|
|
|
|||
|
|
@ -539,9 +539,10 @@ public:
|
|||
|
||||
_remove_redundant_edges(arr_vec[0].first);
|
||||
_reset_faces(arr_vec[0].first);
|
||||
return (_is_empty(arr_vec[0].first));
|
||||
return ! _is_empty(arr_vec[0].first);
|
||||
}
|
||||
|
||||
//!
|
||||
template <typename InputIterator1, typename InputIterator2>
|
||||
bool do_intersect(InputIterator1 begin1, InputIterator1 end1,
|
||||
InputIterator2 begin2, InputIterator2 end2,
|
||||
|
|
@ -550,6 +551,7 @@ public:
|
|||
return other._do_intersect(begin1, end1, begin2, end2, k);
|
||||
}
|
||||
|
||||
//!
|
||||
template <typename InputIterator1, typename InputIterator2>
|
||||
bool _do_intersect(InputIterator1 begin1, InputIterator1 end1,
|
||||
InputIterator2 begin2, InputIterator2 end2,
|
||||
|
|
@ -558,13 +560,13 @@ public:
|
|||
arr_vec[0].first = this->m_arr;
|
||||
std::size_t i = 1;
|
||||
|
||||
for (InputIterator1 itr1 = begin1; itr1 != end1; ++itr1, ++i) {
|
||||
for (auto itr1 = begin1; itr1 != end1; ++itr1, ++i) {
|
||||
ValidationPolicy::is_valid(*itr1, *m_traits);
|
||||
arr_vec[i].first = new Aos_2(m_traits);
|
||||
_insert(*itr1, *(arr_vec[i].first));
|
||||
}
|
||||
|
||||
for (InputIterator2 itr2 = begin2; itr2 != end2; ++itr2, ++i) {
|
||||
for (auto itr2 = begin2; itr2 != end2; ++itr2, ++i) {
|
||||
ValidationPolicy::is_valid(*itr2,*m_traits);
|
||||
arr_vec[i].first = new Aos_2(m_traits);
|
||||
_insert(*itr2, *(arr_vec[i].first));
|
||||
|
|
@ -586,7 +588,7 @@ public:
|
|||
|
||||
_remove_redundant_edges(arr_vec[0].first);
|
||||
_reset_faces(arr_vec[0].first);
|
||||
return (_is_empty(arr_vec[0].first));
|
||||
return ! _is_empty(arr_vec[0].first);
|
||||
}
|
||||
|
||||
// joins a range of polygons
|
||||
|
|
@ -705,7 +707,6 @@ public:
|
|||
// the result arrangement is at index 0
|
||||
this->m_arr = arr_vec[0].first;
|
||||
delete arr_vec[0].second;
|
||||
std::cout << "XXXX 1 no. faces: " << m_arr->number_of_faces() << "\n";
|
||||
}
|
||||
|
||||
// intersects a range of polygons with holes
|
||||
|
|
@ -728,7 +729,6 @@ public:
|
|||
// the result arrangement is at index 0
|
||||
this->m_arr = arr_vec[0].first;
|
||||
delete arr_vec[0].second;
|
||||
std::cout << "XXXX 2 no. edges: " << m_arr->number_of_edges() << "\n";
|
||||
}
|
||||
|
||||
template <typename InputIterator1, typename InputIterator2>
|
||||
|
|
@ -1267,9 +1267,9 @@ protected:
|
|||
std::vector<Arr_entry>& arr_vec,
|
||||
std::size_t k, Merge merge_func) {
|
||||
static int indent = 0;
|
||||
std::cout << std::setw(indent) << "" << "D&C [" << lower << "," << upper << "," << k << "]\n";
|
||||
// std::cout << std::setw(indent) << "" << "D&C [" << lower << "," << upper << "," << k << "]\n";
|
||||
if ((upper - lower) < k) {
|
||||
std::cout << std::setw(indent) << "" << "Merging [" << lower << "," << upper << "," << 1 << "]\n";
|
||||
// std::cout << std::setw(indent) << "" << "Merging [" << lower << "," << upper << "," << 1 << "]\n";
|
||||
_build_sorted_vertices_vectors(lower, upper, arr_vec);
|
||||
merge_func(lower, upper, 1, arr_vec);
|
||||
return;
|
||||
|
|
@ -1286,7 +1286,7 @@ protected:
|
|||
indent += 2;
|
||||
_divide_and_conquer(curr_lower, upper, arr_vec, k, merge_func);
|
||||
indent -= 2;
|
||||
std::cout << std::setw(indent) << "" << "Merging [" << lower << "," << curr_lower << "," << sub_size << "]\n";
|
||||
// std::cout << std::setw(indent) << "" << "Merging [" << lower << "," << curr_lower << "," << sub_size << "]\n";
|
||||
merge_func(lower, curr_lower, sub_size, arr_vec);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,95 @@
|
|||
#include <iostream>
|
||||
|
||||
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
|
||||
#include <CGAL/Boolean_set_operations_2.h>
|
||||
#include <CGAL/Arr_circle_segment_traits_2.h>
|
||||
#include <CGAL/General_polygon_2.h>
|
||||
#include <CGAL/Boolean_set_operations_2.h>
|
||||
// #include <CGAL/draw_arrangement_2.h>
|
||||
|
||||
using Kernel = CGAL::Exact_predicates_exact_constructions_kernel;
|
||||
using Point_2 = Kernel::Point_2;
|
||||
using Polygon_2 = CGAL::Polygon_2<Kernel>;
|
||||
using Circle_2 = Kernel::Circle_2;
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
Kernel kernel;
|
||||
auto ctr_circle = kernel.construct_circle_2_object();
|
||||
auto circle1 = ctr_circle(Point_2(0, 1), 1);
|
||||
auto circle2 = ctr_circle(Point_2(0, -1), 1);
|
||||
auto circle3 = ctr_circle(Point_2(0, 2), 4);
|
||||
|
||||
// 1. Circular arcs and linear segments
|
||||
using Circle_segment_arr_traits_2 = CGAL::Arr_circle_segment_traits_2<Kernel>;
|
||||
using Circle_segment_xcv_2 = Circle_segment_arr_traits_2::X_monotone_curve_2;
|
||||
using Circle_segment_pnt_2 = Circle_segment_arr_traits_2::Point_2;
|
||||
using Circle_segment_gps_traits_2 = CGAL::Gps_traits_2<Circle_segment_arr_traits_2>;
|
||||
using Circle_segment_polygon = Circle_segment_gps_traits_2::General_polygon_2;
|
||||
using Circle_segment_polygon_with_holes = Circle_segment_gps_traits_2::General_polygon_with_holes_2;
|
||||
|
||||
Circle_segment_arr_traits_2 circle_segment_traits;
|
||||
|
||||
Circle_segment_pnt_2 cs_pnt11(1, 1);
|
||||
Circle_segment_pnt_2 cs_pnt12(-1, 1);
|
||||
Circle_segment_xcv_2 xcv11(circle1, cs_pnt11, cs_pnt12, CGAL::COUNTERCLOCKWISE);
|
||||
Circle_segment_xcv_2 xcv12(circle1, cs_pnt12, cs_pnt11, CGAL::COUNTERCLOCKWISE);
|
||||
Circle_segment_polygon pgn1;
|
||||
pgn1.push_back(xcv11);
|
||||
pgn1.push_back(xcv12);
|
||||
|
||||
Circle_segment_pnt_2 cs_pnt21(1, -1);
|
||||
Circle_segment_pnt_2 cs_pnt22(-1, -1);
|
||||
Circle_segment_xcv_2 xcv21(circle2, cs_pnt21, cs_pnt22, CGAL::COUNTERCLOCKWISE);
|
||||
Circle_segment_xcv_2 xcv22(circle2, cs_pnt22, cs_pnt21, CGAL::COUNTERCLOCKWISE);
|
||||
Circle_segment_polygon pgn2;
|
||||
pgn2.push_back(xcv21);
|
||||
pgn2.push_back(xcv22);
|
||||
|
||||
Circle_segment_pnt_2 cs_pnt31(2, 2);
|
||||
Circle_segment_pnt_2 cs_pnt32(-2, 2);
|
||||
Circle_segment_xcv_2 xcv31(circle3, cs_pnt31, cs_pnt32, CGAL::COUNTERCLOCKWISE);
|
||||
Circle_segment_xcv_2 xcv32(circle3, cs_pnt32, cs_pnt31, CGAL::COUNTERCLOCKWISE);
|
||||
Circle_segment_polygon pgn3;
|
||||
pgn3.push_back(xcv31);
|
||||
pgn3.push_back(xcv32);
|
||||
|
||||
// 1.1.
|
||||
auto do_intersect = CGAL::do_intersect(pgn1, pgn2);
|
||||
if (do_intersect) {
|
||||
std::cerr << "The circles intersect (case 1)\n" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
// 1.2.
|
||||
std::vector<Circle_segment_polygon> pgns1 = { pgn1, pgn2 };
|
||||
do_intersect = CGAL::do_intersect(pgns1.begin(), pgns1.end());
|
||||
if (do_intersect) {
|
||||
std::cerr << "The circles intersect (case 2)\n" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
// 2.1.
|
||||
do_intersect = CGAL::do_intersect(pgn1, pgn3);
|
||||
if (! do_intersect) {
|
||||
std::cerr << "The circles do not intersect (case 1)\n" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
// 2.2.
|
||||
std::vector<Circle_segment_polygon> pgns2 = { pgn1, pgn3 };
|
||||
do_intersect = CGAL::do_intersect(pgns2.begin(), pgns2.end());
|
||||
if (! do_intersect) {
|
||||
std::cerr << "The circles do not intersect (case 2)\n" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
// using Circle_segment_arr = CGAL::Arrangement_2<Circle_segment_arr_traits_2>;
|
||||
// Circle_segment_arr arr;
|
||||
// CGAL::insert_non_intersecting_curve(arr, xcv11);
|
||||
// CGAL::insert_non_intersecting_curve(arr, xcv12);
|
||||
// CGAL::insert_non_intersecting_curve(arr, xcv21);
|
||||
// CGAL::insert_non_intersecting_curve(arr, xcv22);
|
||||
// CGAL::draw(arr);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -7,8 +7,8 @@
|
|||
// $Id$
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
|
||||
//
|
||||
// Author(s) : Baruch Zukerman <baruchzu@post.tau.ac.il>
|
||||
// Efi Fogel <efif@post.tau.ac.il>
|
||||
// Author(s) : Baruch Zukerman <baruchzu@post.tau.ac.il>
|
||||
// Efi Fogel <efif@post.tau.ac.il>
|
||||
|
||||
#ifndef CGAL_SURFACE_SWEEP_2_DEFAULT_VISITOR_BASE_H
|
||||
#define CGAL_SURFACE_SWEEP_2_DEFAULT_VISITOR_BASE_H
|
||||
|
|
@ -50,28 +50,27 @@ template <typename GeometryTraits_2, typename Event_, typename Subcurve_,
|
|||
typename Allocator_, typename Visitor_>
|
||||
class Default_visitor_base {
|
||||
public:
|
||||
typedef GeometryTraits_2 Geometry_traits_2;
|
||||
typedef Event_ Event;
|
||||
typedef Subcurve_ Subcurve;
|
||||
typedef Allocator_ Allocator;
|
||||
typedef Visitor_ Visitor;
|
||||
using Geometry_traits_2 = GeometryTraits_2;
|
||||
using Event = Event_;
|
||||
using Subcurve = Subcurve_;
|
||||
using Allocator = Allocator_;
|
||||
using Visitor = Visitor_;
|
||||
|
||||
private:
|
||||
typedef Geometry_traits_2 Gt2;
|
||||
typedef Default_visitor_base<Gt2, Event, Subcurve, Allocator, Visitor>
|
||||
Self;
|
||||
using Gt2 = Geometry_traits_2;
|
||||
using Self = Default_visitor_base<Gt2, Event, Subcurve, Allocator, Visitor>;
|
||||
|
||||
public:
|
||||
typedef typename Subcurve::Status_line_iterator Status_line_iterator;
|
||||
using Status_line_iterator = typename Subcurve::Status_line_iterator;
|
||||
|
||||
typedef typename Gt2::X_monotone_curve_2 X_monotone_curve_2;
|
||||
typedef typename Gt2::Point_2 Point_2;
|
||||
using X_monotone_curve_2 = typename Gt2::X_monotone_curve_2;
|
||||
using Point_2 = typename Gt2::Point_2;
|
||||
using Multiplicity = typename Gt2::Multiplicity;
|
||||
|
||||
typedef typename Event::Subcurve_iterator Event_subcurve_iterator;
|
||||
typedef typename Event::Subcurve_reverse_iterator
|
||||
Event_subcurve_reverse_iterator;
|
||||
using Event_subcurve_iterator = typename Event::Subcurve_iterator;
|
||||
using Event_subcurve_reverse_iterator = typename Event::Subcurve_reverse_iterator;
|
||||
|
||||
typedef No_intersection_surface_sweep_2<Visitor> Surface_sweep_2;
|
||||
using Surface_sweep_2 = No_intersection_surface_sweep_2<Visitor>;
|
||||
|
||||
protected:
|
||||
// Data members:
|
||||
|
|
@ -134,7 +133,8 @@ public:
|
|||
void update_event(Event* /* e */,
|
||||
Subcurve* /* sc1 */,
|
||||
Subcurve* /* sc2 */,
|
||||
bool /* is_new */)
|
||||
bool /* is_new */,
|
||||
Multiplicity /* multiplicity */)
|
||||
{}
|
||||
|
||||
/*! Update the event. */
|
||||
|
|
|
|||
|
|
@ -7,9 +7,9 @@
|
|||
// $Id$
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
|
||||
//
|
||||
// Author(s) : Baruch Zukerman <baruchzu@post.tau.ac.il>
|
||||
// Ron Wein <wein@post.tau.ac.il>
|
||||
// Efi Fogel <efif@post.tau.ac.il>
|
||||
// Author(s) : Baruch Zukerman <baruchzu@post.tau.ac.il>
|
||||
// Ron Wein <wein@post.tau.ac.il>
|
||||
// Efi Fogel <efif@post.tau.ac.il>
|
||||
|
||||
#ifndef CGAL_SURFACE_SWEEP_2_DO_INTERIOR_INTERSECT_VISITORS_H
|
||||
#define CGAL_SURFACE_SWEEP_2_DO_INTERIOR_INTERSECT_VISITORS_H
|
||||
|
|
@ -39,27 +39,27 @@ template <typename GeometryTraits_2,
|
|||
class Do_interior_intersect_visitor :
|
||||
public Default_visitor<Do_interior_intersect_visitor<GeometryTraits_2,
|
||||
Allocator_>,
|
||||
GeometryTraits_2, Allocator_>
|
||||
{
|
||||
GeometryTraits_2, Allocator_> {
|
||||
public:
|
||||
typedef GeometryTraits_2 Geometry_traits_2;
|
||||
typedef Allocator_ Allocator;
|
||||
using Geometry_traits_2 = GeometryTraits_2;
|
||||
using Allocator = Allocator_;
|
||||
|
||||
private:
|
||||
typedef Geometry_traits_2 Gt2;
|
||||
typedef Do_interior_intersect_visitor<Gt2, Allocator> Self;
|
||||
typedef Default_visitor<Self, Gt2, Allocator> Base;
|
||||
using Gt2 = Geometry_traits_2;
|
||||
using Self = Do_interior_intersect_visitor<Gt2, Allocator>;
|
||||
using Base = Default_visitor<Self, Gt2, Allocator>;
|
||||
|
||||
public:
|
||||
typedef typename Base::Event Event;
|
||||
typedef typename Base::Subcurve Subcurve;
|
||||
using Event = typename Base::Event;
|
||||
using Subcurve = typename Base::Subcurve;
|
||||
|
||||
typedef typename Subcurve::Status_line_iterator Status_line_iterator;
|
||||
using Status_line_iterator = typename Subcurve::Status_line_iterator;
|
||||
|
||||
typedef typename Gt2::X_monotone_curve_2 X_monotone_curve_2;
|
||||
typedef typename Gt2::Point_2 Point_2;
|
||||
using X_monotone_curve_2 = typename Gt2::X_monotone_curve_2;
|
||||
using Point_2 = typename Gt2::Point_2;
|
||||
using Multiplicity = typename Gt2::Multiplicity;
|
||||
|
||||
typedef typename Base::Surface_sweep_2 Surface_sweep_2;
|
||||
using Surface_sweep_2 = typename Base::Surface_sweep_2;
|
||||
|
||||
protected:
|
||||
// Data members:
|
||||
|
|
@ -69,8 +69,7 @@ public:
|
|||
Do_interior_intersect_visitor() : m_found_x(false) {}
|
||||
|
||||
template <typename CurveIterator>
|
||||
void sweep(CurveIterator begin, CurveIterator end)
|
||||
{
|
||||
void sweep(CurveIterator begin, CurveIterator end) {
|
||||
std::vector<X_monotone_curve_2> curves_vec;
|
||||
std::vector<Point_2> points_vec;
|
||||
|
||||
|
|
@ -89,7 +88,8 @@ public:
|
|||
void update_event(Event* /* e */,
|
||||
Subcurve* /* sc1 */,
|
||||
Subcurve* /* sc2 */,
|
||||
bool /* is_new */)
|
||||
bool /* is_new */,
|
||||
Multiplicity multiplicity = 0)
|
||||
{ m_found_x = true; }
|
||||
|
||||
void update_event(Event* /* e */,
|
||||
|
|
@ -115,8 +115,7 @@ public:
|
|||
{}
|
||||
|
||||
template <typename XCurveIterator>
|
||||
void sweep_xcurves(XCurveIterator begin, XCurveIterator end)
|
||||
{
|
||||
void sweep_xcurves(XCurveIterator begin, XCurveIterator end) {
|
||||
// Perform the sweep.
|
||||
Surface_sweep_2* sl = this->surface_sweep();
|
||||
sl->sweep(begin, end);
|
||||
|
|
@ -129,8 +128,7 @@ public:
|
|||
|
||||
bool after_handle_event(Event* /* event */,
|
||||
Status_line_iterator /* iter */,
|
||||
bool /* flag */)
|
||||
{
|
||||
bool /* flag */) {
|
||||
if (m_found_x) {
|
||||
Surface_sweep_2* sl = this->surface_sweep();
|
||||
sl->stop_sweep();
|
||||
|
|
|
|||
|
|
@ -7,9 +7,9 @@
|
|||
// $Id$
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
|
||||
//
|
||||
// Author(s) : Baruch Zukerman <baruchzu@post.tau.ac.il>
|
||||
// Efi Fogel <efif@post.tau.ac.il>
|
||||
// (based on old version by Tali Zvi)
|
||||
// Author(s) : Baruch Zukerman <baruchzu@post.tau.ac.il>
|
||||
// Efi Fogel <efif@post.tau.ac.il>
|
||||
// (based on a previous version developed by Tali Zvi)
|
||||
|
||||
#ifndef CGAL_SURFACE_SWEEP_2_IMPL_H
|
||||
#define CGAL_SURFACE_SWEEP_2_IMPL_H
|
||||
|
|
@ -33,8 +33,7 @@ namespace Surface_sweep_2 {
|
|||
// Initialize the data structures for the sweep-line algorithm.
|
||||
//
|
||||
template <typename Vis>
|
||||
void Surface_sweep_2<Vis>::_init_structures()
|
||||
{
|
||||
void Surface_sweep_2<Vis>::_init_structures() {
|
||||
// Initialize the structures maintained by the base sweep-line class.
|
||||
Base::_init_structures();
|
||||
}
|
||||
|
|
@ -43,8 +42,7 @@ void Surface_sweep_2<Vis>::_init_structures()
|
|||
// Complete the sweep (complete the data structures).
|
||||
//
|
||||
template <typename Vis>
|
||||
void Surface_sweep_2<Vis>::_complete_sweep()
|
||||
{
|
||||
void Surface_sweep_2<Vis>::_complete_sweep() {
|
||||
CGAL_SS_PRINT_START_EOL("completing the sweep");
|
||||
|
||||
// Complete the sweep process using base sweep-line class.
|
||||
|
|
@ -68,8 +66,7 @@ void Surface_sweep_2<Vis>::_complete_sweep()
|
|||
// Handle the subcurves to the left of the current event point.
|
||||
//
|
||||
template <typename Vis>
|
||||
void Surface_sweep_2<Vis>::_handle_left_curves()
|
||||
{
|
||||
void Surface_sweep_2<Vis>::_handle_left_curves() {
|
||||
CGAL_SS_PRINT_START("handling left curves at (");
|
||||
CGAL_SS_DEBUG(this->PrintEvent(this->m_currentEvent));
|
||||
CGAL_SS_PRINT_TEXT(")");
|
||||
|
|
@ -189,14 +186,12 @@ void Surface_sweep_2<Vis>::_handle_left_curves()
|
|||
// and with a left end not being the current event
|
||||
//
|
||||
template <typename Vis>
|
||||
void Surface_sweep_2<Vis>::_clip_non_active_curve_at_current_event(Subcurve* subcurve)
|
||||
{
|
||||
void Surface_sweep_2<Vis>::_clip_non_active_curve_at_current_event(Subcurve* subcurve) {
|
||||
// ignore active curve (will be split at intersection point)
|
||||
if (subcurve->hint() != this->m_statusLine.end() &&
|
||||
subcurve->hint() != Status_line_iterator() ) return;
|
||||
|
||||
if (!subcurve->is_start_point(this->m_currentEvent))
|
||||
{
|
||||
if (! subcurve->is_start_point(this->m_currentEvent)) {
|
||||
CGAL_SS_PRINT_TEXT("Splitting ");
|
||||
CGAL_SS_PRINT_CURVE(subcurve);
|
||||
CGAL_SS_PRINT_EOL();
|
||||
|
|
@ -215,13 +210,11 @@ void Surface_sweep_2<Vis>::_clip_non_active_curve_at_current_event(Subcurve* sub
|
|||
// Handle the overlaps between subcurves to the right of the current event point.
|
||||
//
|
||||
template <typename Vis>
|
||||
void Surface_sweep_2<Vis>::_handle_overlaps_in_right_curves()
|
||||
{
|
||||
const std::vector< std::pair<Subcurve*, Subcurve*> >& subcurve_pairs
|
||||
= this->m_currentEvent->overlaps_on_right;
|
||||
void Surface_sweep_2<Vis>::_handle_overlaps_in_right_curves() {
|
||||
const std::vector< std::pair<Subcurve*, Subcurve*> >& subcurve_pairs =
|
||||
this->m_currentEvent->overlaps_on_right;
|
||||
|
||||
if (!subcurve_pairs.empty())
|
||||
{
|
||||
if (!subcurve_pairs.empty()) {
|
||||
// handling overlaps on the right of the current event.
|
||||
// Only one curve from the overlapping curve is currently
|
||||
// in the right curves of the event. Other curve overlapping
|
||||
|
|
@ -240,11 +233,10 @@ void Surface_sweep_2<Vis>::_handle_overlaps_in_right_curves()
|
|||
// in the following map having a curve on the right of the event
|
||||
// as key, we get all the curves that overlap with that curve
|
||||
// on the right of the event
|
||||
typedef std::map<Subcurve*, std::vector<Subcurve*> > Subcurve_map;
|
||||
typedef std::map<Subcurve*, std::vector<Subcurve*>> Subcurve_map;
|
||||
Subcurve_map tests_per_subcurve_on_right;
|
||||
|
||||
for (std::size_t i=0; i<nb_p; ++i)
|
||||
{
|
||||
for (std::size_t i = 0; i < nb_p; ++i) {
|
||||
CGAL_SS_PRINT_TEXT("(");
|
||||
CGAL_SS_PRINT(subcurve_pairs[i].first);
|
||||
CGAL_SS_PRINT_TEXT(",");
|
||||
|
|
@ -254,13 +246,10 @@ void Surface_sweep_2<Vis>::_handle_overlaps_in_right_curves()
|
|||
tests_per_subcurve_on_right[subcurve_pairs[i].first].push_back(subcurve_pairs[i].second);
|
||||
}
|
||||
|
||||
for(typename Subcurve_map::iterator it = tests_per_subcurve_on_right.begin(),
|
||||
end = tests_per_subcurve_on_right.end(); it!=end; ++it)
|
||||
{
|
||||
for (auto it = tests_per_subcurve_on_right.begin(), end = tests_per_subcurve_on_right.end(); it != end; ++it) {
|
||||
std::size_t nbc = it->second.size();
|
||||
// remove possible duplicates
|
||||
if (nbc>1)
|
||||
{
|
||||
if (nbc > 1) {
|
||||
std::sort(it->second.begin(), it->second.end());
|
||||
typename std::vector<Subcurve*>::iterator last =
|
||||
std::unique(it->second.begin(), it->second.end());
|
||||
|
|
@ -277,8 +266,7 @@ void Surface_sweep_2<Vis>::_handle_overlaps_in_right_curves()
|
|||
else{
|
||||
// get the curve just after the key in the sorted set of curves on the right as it might be replaced
|
||||
Subcurve_iterator next_after = this->m_currentEvent->get_curve_after_on_right(it->first);
|
||||
for (std::size_t i=0; i<nbc; ++i)
|
||||
{
|
||||
for (std::size_t i = 0; i < nbc; ++i) {
|
||||
_intersect(it->second[i], *std::prev(next_after), this->m_currentEvent);
|
||||
CGAL_assertion(it->second.size()==nbc); // make sure the container was not updated
|
||||
}
|
||||
|
|
@ -289,27 +277,19 @@ void Surface_sweep_2<Vis>::_handle_overlaps_in_right_curves()
|
|||
}
|
||||
|
||||
// split curves not already split. TODO: this should be done above?
|
||||
for (Event_subcurve_iterator subcurve_it = this->m_currentEvent->right_curves_begin();
|
||||
subcurve_it != this->m_currentEvent->right_curves_end();
|
||||
++subcurve_it)
|
||||
{
|
||||
for (auto subcurve_it = this->m_currentEvent->right_curves_begin();
|
||||
subcurve_it != this->m_currentEvent->right_curves_end(); ++subcurve_it)
|
||||
_clip_non_active_curve_at_current_event(*subcurve_it);
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Handle the subcurves to the right of the current event point.
|
||||
//
|
||||
template <typename Vis>
|
||||
void Surface_sweep_2<Vis>::_handle_right_curves()
|
||||
{
|
||||
|
||||
for(Event_subcurve_iterator sc_it = this->m_currentEvent->right_curves_begin(),
|
||||
sc_it_end = this->m_currentEvent->right_curves_end();
|
||||
sc_it!=sc_it_end; ++sc_it)
|
||||
{
|
||||
void Surface_sweep_2<Vis>::_handle_right_curves() {
|
||||
for (auto sc_it = this->m_currentEvent->right_curves_begin(), sc_it_end = this->m_currentEvent->right_curves_end();
|
||||
sc_it != sc_it_end; ++sc_it)
|
||||
(*sc_it)->reset_left_event();
|
||||
}
|
||||
|
||||
CGAL_SS_PRINT_START("handling right curves at (");
|
||||
CGAL_SS_DEBUG(this->PrintEvent(this->m_currentEvent));
|
||||
|
|
@ -329,15 +309,11 @@ void Surface_sweep_2<Vis>::_handle_right_curves()
|
|||
// - We also check to see if the two intersect again to the right of the
|
||||
// point.
|
||||
|
||||
Event_subcurve_iterator currentOne =
|
||||
this->m_currentEvent->right_curves_begin();
|
||||
Event_subcurve_iterator rightCurveEnd =
|
||||
this->m_currentEvent->right_curves_end();
|
||||
Event_subcurve_iterator currentOne = this->m_currentEvent->right_curves_begin();
|
||||
Event_subcurve_iterator rightCurveEnd = this->m_currentEvent->right_curves_end();
|
||||
|
||||
CGAL_SS_PRINT_INSERT(*currentOne);
|
||||
Status_line_iterator slIter =
|
||||
this->m_statusLine.insert_before(this->m_status_line_insert_hint,
|
||||
*currentOne);
|
||||
Status_line_iterator slIter = this->m_statusLine.insert_before(this->m_status_line_insert_hint, *currentOne);
|
||||
Subcurve* sc = *currentOne;
|
||||
sc->set_hint(slIter);
|
||||
|
||||
|
|
@ -352,8 +328,7 @@ void Surface_sweep_2<Vis>::_handle_right_curves()
|
|||
++currentOne;
|
||||
while (currentOne != rightCurveEnd) {
|
||||
CGAL_SS_PRINT_INSERT(*currentOne);
|
||||
slIter = this->m_statusLine.insert_before(this->m_status_line_insert_hint,
|
||||
*currentOne);
|
||||
slIter = this->m_statusLine.insert_before(this->m_status_line_insert_hint, *currentOne);
|
||||
|
||||
Subcurve* sc = *currentOne;
|
||||
sc->set_hint(slIter);
|
||||
|
|
@ -390,12 +365,8 @@ bool Surface_sweep_2<Vis>::_add_curve_to_right(Event* event, Subcurve* curve)
|
|||
CGAL_SS_PRINT_CURVE(curve);
|
||||
CGAL_SS_PRINT_EOL();
|
||||
|
||||
Event_subcurve_iterator iter;
|
||||
for (iter = event->right_curves_begin(); iter != event->right_curves_end();
|
||||
++iter)
|
||||
{
|
||||
if (*iter == curve)
|
||||
{
|
||||
for (auto iter = event->right_curves_begin(); iter != event->right_curves_end(); ++iter) {
|
||||
if (*iter == curve) {
|
||||
CGAL_SS_PRINT_END_EOL("adding a Curve to the right (curve exists)");
|
||||
return false;
|
||||
}
|
||||
|
|
@ -405,8 +376,7 @@ bool Surface_sweep_2<Vis>::_add_curve_to_right(Event* event, Subcurve* curve)
|
|||
if ((*iter)->are_all_leaves_contained(curve)) {
|
||||
CGAL_SS_PRINT_END_EOL("adding a Curve to the right (containing curve exists)");
|
||||
|
||||
if ( (*iter)->right_event() != curve->right_event() )
|
||||
{
|
||||
if ((*iter)->right_event() != curve->right_event()) {
|
||||
CGAL_assertion( this->m_queueEventLess((*iter)->right_event(), curve->right_event()) == SMALLER ); // subcurve has to end before
|
||||
_add_curve_to_right( (*iter)->right_event(), curve); // WARNING recursive
|
||||
}
|
||||
|
|
@ -417,8 +387,7 @@ bool Surface_sweep_2<Vis>::_add_curve_to_right(Event* event, Subcurve* curve)
|
|||
}
|
||||
|
||||
if (curve->are_all_leaves_contained(*iter)) {
|
||||
if ( (*iter)->right_event() != curve->right_event() )
|
||||
{
|
||||
if ( (*iter)->right_event() != curve->right_event()) {
|
||||
CGAL_assertion(this->m_queueEventLess(curve->right_event(), (*iter)->right_event()) == SMALLER); // subcurve has to end before
|
||||
_add_curve_to_right( curve->right_event(), *iter); // WARNING recursive
|
||||
}
|
||||
|
|
@ -426,8 +395,7 @@ bool Surface_sweep_2<Vis>::_add_curve_to_right(Event* event, Subcurve* curve)
|
|||
(*iter)->right_event()->remove_curve_from_left(*iter);
|
||||
|
||||
*iter = curve; // replace the current curve with the new one.
|
||||
CGAL_SS_PRINT_END_EOL
|
||||
("replacing a Curve to the right (curve partially overlaps)");
|
||||
CGAL_SS_PRINT_END_EOL("replacing a Curve to the right (curve partially overlaps)");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -443,11 +411,10 @@ bool Surface_sweep_2<Vis>::_add_curve_to_right(Event* event, Subcurve* curve)
|
|||
}
|
||||
|
||||
// a new overlap needs to be computed
|
||||
if (event!=this->m_currentEvent)
|
||||
if (event != this->m_currentEvent)
|
||||
event->overlaps_on_right.push_back(
|
||||
std::make_pair(static_cast<Subcurve*>(*(pair_res.second)),
|
||||
static_cast<Subcurve*>(curve))
|
||||
);
|
||||
static_cast<Subcurve*>(curve)));
|
||||
else
|
||||
_intersect(static_cast<Subcurve*>(curve),
|
||||
static_cast<Subcurve*>(*(pair_res.second)),
|
||||
|
|
@ -467,8 +434,7 @@ bool Surface_sweep_2<Vis>::_add_curve_to_right(Event* event, Subcurve* curve)
|
|||
//
|
||||
template <typename Vis>
|
||||
void Surface_sweep_2<Vis>::_remove_curve_from_status_line(Subcurve* leftCurve,
|
||||
bool remove_for_good)
|
||||
{
|
||||
bool remove_for_good) {
|
||||
CGAL_SS_PRINT_START("removing a curve from the status line, ");
|
||||
CGAL_SS_PRINT_CURVE(leftCurve);
|
||||
CGAL_SS_PRINT_EOL();
|
||||
|
|
@ -513,8 +479,7 @@ void Surface_sweep_2<Vis>::_remove_curve_from_status_line(Subcurve* leftCurve,
|
|||
//
|
||||
template <typename Vis>
|
||||
void Surface_sweep_2<Vis>::_intersect(Subcurve* c1, Subcurve* c2,
|
||||
Event* event_for_overlap)
|
||||
{
|
||||
Event* event_for_overlap) {
|
||||
CGAL_SS_PRINT_START("computing intersection of ");
|
||||
CGAL_SS_PRINT_CURVE(c1);
|
||||
CGAL_SS_PRINT_TEXT(" and ");
|
||||
|
|
@ -538,8 +503,7 @@ void Surface_sweep_2<Vis>::_intersect(Subcurve* c1, Subcurve* c2,
|
|||
Subcurve_vector all_leaves_diff;
|
||||
Subcurve* first_parent = nullptr;
|
||||
if ((c1->originating_subcurve1() != nullptr) ||
|
||||
(c2->originating_subcurve2() != nullptr))
|
||||
{
|
||||
(c2->originating_subcurve2() != nullptr)) {
|
||||
// get the subcurve leaves of c1 and of c2. Then extract from the smallest
|
||||
// set the subcurves leaves that are not in the other one. If empty, it
|
||||
// means that a subcurves is completely contained in another one.
|
||||
|
|
@ -628,9 +592,7 @@ void Surface_sweep_2<Vis>::_intersect(Subcurve* c1, Subcurve* c2,
|
|||
CGAL_SS_PRINT_CURVE(first_parent);
|
||||
CGAL_SS_PRINT_EOL();
|
||||
X_monotone_curve_2 xc = first_parent->last_curve();
|
||||
for (auto sc_it = all_leaves_diff.begin();
|
||||
sc_it != all_leaves_diff.end(); ++sc_it)
|
||||
{
|
||||
for (auto sc_it = all_leaves_diff.begin(); sc_it != all_leaves_diff.end(); ++sc_it) {
|
||||
CGAL_SS_PRINT_TEXT("Inter with curve: ");
|
||||
CGAL_SS_PRINT_CURVE((*sc_it));
|
||||
CGAL_SS_PRINT_EOL();
|
||||
|
|
@ -681,12 +643,10 @@ void Surface_sweep_2<Vis>::_intersect(Subcurve* c1, Subcurve* c2,
|
|||
if ((ps_x1 == ps_x2) && (ps_y1 == ps_y2) &&
|
||||
((ps_x1 != ARR_INTERIOR) || (ps_y1 != ARR_INTERIOR)) &&
|
||||
this->m_traits->is_closed_2_object()(c1->last_curve(), ARR_MIN_END) &&
|
||||
this->m_traits->is_closed_2_object()(c2->last_curve(), ARR_MIN_END))
|
||||
{
|
||||
this->m_traits->is_closed_2_object()(c2->last_curve(), ARR_MIN_END)) {
|
||||
if ((std::get_if<Intersection_point>(&(*vi)) != nullptr) &&
|
||||
this->m_traits->equal_2_object()(ctr_min(c1->last_curve()),
|
||||
ctr_min(c2->last_curve())))
|
||||
{
|
||||
ctr_min(c2->last_curve()))) {
|
||||
CGAL_SS_PRINT_TEXT("Skipping common left endpoint on boundary ...");
|
||||
CGAL_SS_PRINT_EOL();
|
||||
++vi;
|
||||
|
|
@ -719,12 +679,10 @@ void Surface_sweep_2<Vis>::_intersect(Subcurve* c1, Subcurve* c2,
|
|||
if ((ps_x1 == ps_x2) && (ps_y1 == ps_y2) &&
|
||||
((ps_x1 != ARR_INTERIOR) || (ps_y2 != ARR_INTERIOR)) &&
|
||||
this->m_traits->is_closed_2_object()(c1->last_curve(), ARR_MAX_END) &&
|
||||
this->m_traits->is_closed_2_object()(c2->last_curve(), ARR_MAX_END))
|
||||
{
|
||||
this->m_traits->is_closed_2_object()(c2->last_curve(), ARR_MAX_END)) {
|
||||
if (this->m_traits->equal_2_object()
|
||||
(this->m_traits->construct_max_vertex_2_object()(c1->last_curve()),
|
||||
this->m_traits->construct_max_vertex_2_object()(c2->last_curve())))
|
||||
{
|
||||
this->m_traits->construct_max_vertex_2_object()(c2->last_curve()))) {
|
||||
vector_inserter vi_last = vi_end;
|
||||
|
||||
--vi_last;
|
||||
|
|
@ -791,8 +749,7 @@ template <typename Vis>
|
|||
void Surface_sweep_2<Vis>::_create_intersection_point(const Point_2& xp,
|
||||
Multiplicity multiplicity,
|
||||
Subcurve*& c1,
|
||||
Subcurve*& c2)
|
||||
{
|
||||
Subcurve*& c2) {
|
||||
CGAL_SS_PRINT_START_EOL("creating an intersection point between");
|
||||
CGAL_SS_PRINT_CURVE(c1);
|
||||
CGAL_SS_PRINT_EOL();
|
||||
|
|
@ -814,7 +771,7 @@ void Surface_sweep_2<Vis>::_create_intersection_point(const Point_2& xp,
|
|||
|
||||
e->set_intersection();
|
||||
|
||||
this->m_visitor->update_event(e, c1, c2, true);
|
||||
this->m_visitor->update_event(e, c1, c2, true, multiplicity);
|
||||
e->push_back_curve_to_left(c1);
|
||||
e->push_back_curve_to_left(c2);
|
||||
|
||||
|
|
@ -858,7 +815,7 @@ void Surface_sweep_2<Vis>::_create_intersection_point(const Point_2& xp,
|
|||
_add_curve_to_right(e, c1);
|
||||
_add_curve_to_right(e, c2);
|
||||
e->set_intersection();
|
||||
this->m_visitor->update_event(e, c1, c2, false);
|
||||
this->m_visitor->update_event(e, c1, c2, false, multiplicity);
|
||||
|
||||
if (multiplicity == 0) {
|
||||
if (e->is_right_curve_bigger(c1, c2, this->m_traits)) std::swap(c1, c2);
|
||||
|
|
@ -895,8 +852,7 @@ _create_overlapping_curve(const X_monotone_curve_2& overlap_cv,
|
|||
Subcurve*& c1 , Subcurve*& c2,
|
||||
const Subcurve_vector& all_leaves_diff,
|
||||
Subcurve* first_parent,
|
||||
Event* event_on_overlap)
|
||||
{
|
||||
Event* event_on_overlap) {
|
||||
// An overlap occurs:
|
||||
CGAL_SS_PRINT_START_EOL("creating an overlapping curve");
|
||||
|
||||
|
|
@ -935,14 +891,12 @@ _create_overlapping_curve(const X_monotone_curve_2& overlap_cv,
|
|||
if ((ps_x_r != ARR_INTERIOR) || (ps_y_r != ARR_INTERIOR)) {
|
||||
// CGAL_assertion(c1->right_event() == c2->right_event());
|
||||
// right_event = c1->right_event();
|
||||
right_event = this->_push_event(overlap_cv, ARR_MAX_END, Event::DEFAULT,
|
||||
ps_x_r, ps_y_r).first;
|
||||
right_event = this->_push_event(overlap_cv, ARR_MAX_END, Event::DEFAULT, ps_x_r, ps_y_r).first;
|
||||
}
|
||||
else {
|
||||
auto max_vertex = this->m_traits->construct_max_vertex_2_object();
|
||||
auto right_end = max_vertex(overlap_cv);
|
||||
right_event = this->_push_event(right_end, Event::DEFAULT, ARR_INTERIOR,
|
||||
ARR_INTERIOR).first;
|
||||
right_event = this->_push_event(right_end, Event::DEFAULT, ARR_INTERIOR, ARR_INTERIOR).first;
|
||||
}
|
||||
|
||||
if (!c1->is_start_point(left_event)) {
|
||||
|
|
@ -968,12 +922,9 @@ _create_overlapping_curve(const X_monotone_curve_2& overlap_cv,
|
|||
|
||||
// Allocate the new Subcurve for the overlap
|
||||
Subcurve* overlap_sc=nullptr;
|
||||
if (all_leaves_diff.empty())
|
||||
{
|
||||
if (all_leaves_diff.empty()) {
|
||||
// first check that an equivalent curve is not already in left_event
|
||||
for (Subcurve_iterator iter = left_event->right_curves_begin();
|
||||
iter != left_event->right_curves_end(); ++iter)
|
||||
{
|
||||
for (auto iter = left_event->right_curves_begin(); iter != left_event->right_curves_end(); ++iter) {
|
||||
if ((*iter)->has_same_leaves(c1, c2)) {
|
||||
CGAL_SS_PRINT_TEXT("Reuse overlapping curve ");
|
||||
CGAL_SS_PRINT_CURVE(*iter);
|
||||
|
|
@ -983,8 +934,7 @@ _create_overlapping_curve(const X_monotone_curve_2& overlap_cv,
|
|||
}
|
||||
}
|
||||
|
||||
if (overlap_sc==nullptr)
|
||||
{
|
||||
if (overlap_sc == nullptr) {
|
||||
CGAL_SS_PRINT_TEXT("Allocate a new subcurve for the overlap (no common subcurves)");
|
||||
CGAL_SS_PRINT_EOL();
|
||||
// no duplicate only one curve is needed
|
||||
|
|
@ -1005,10 +955,7 @@ _create_overlapping_curve(const X_monotone_curve_2& overlap_cv,
|
|||
CGAL_SS_PRINT_EOL();
|
||||
|
||||
// create an overlapping curve per subcurve in second_parent that is not in first_parent
|
||||
for (typename std::vector<Subcurve*>::const_iterator sc_it = all_leaves_diff.begin();
|
||||
sc_it != all_leaves_diff.end();
|
||||
++sc_it)
|
||||
{
|
||||
for (auto sc_it = all_leaves_diff.begin(); sc_it != all_leaves_diff.end(); ++sc_it) {
|
||||
overlap_sc = this->m_subCurveAlloc.allocate(1);
|
||||
std::allocator_traits<Subcurve_alloc>::construct(this->m_subCurveAlloc,overlap_sc, this->m_masterSubcurve);
|
||||
overlap_sc->set_hint(this->m_statusLine.end());
|
||||
|
|
@ -1063,8 +1010,7 @@ _create_overlapping_curve(const X_monotone_curve_2& overlap_cv,
|
|||
// or updated.
|
||||
//
|
||||
template <typename Vis>
|
||||
void Surface_sweep_2<Vis>::_add_curve(Event* e, Subcurve* sc, Attribute type)
|
||||
{
|
||||
void Surface_sweep_2<Vis>::_add_curve(Event* e, Subcurve* sc, Attribute type) {
|
||||
if (sc == nullptr) return;
|
||||
|
||||
if (type == Event::LEFT_END) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue