diff --git a/.travis.yml b/.travis.yml index 7b3d75ae95a..0d1b110e6bd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,99 +1,99 @@ -language: cpp -dist: trusty -sudo: required -env: - matrix: - - PACKAGE='CHECK' - - PACKAGE='AABB_tree Advancing_front_surface_reconstruction Algebraic_foundations ' - - PACKAGE='Algebraic_kernel_d Algebraic_kernel_for_circles Algebraic_kernel_for_spheres ' - - PACKAGE='Alpha_shapes_2 Alpha_shapes_3 Apollonius_graph_2 ' - - PACKAGE='Arithmetic_kernel Arrangement_on_surface_2 Barycentric_coordinates_2 ' - - PACKAGE='BGL Boolean_set_operations_2 Bounding_volumes ' - - PACKAGE='Box_intersection_d Cartesian_kernel CGAL_Core ' - - PACKAGE='CGAL_ImageIO CGAL_ipelets Circular_kernel_2 ' - - PACKAGE='Circular_kernel_3 Circulator Classification ' - - PACKAGE='Combinatorial_map Cone_spanners_2 Convex_decomposition_3 ' - - PACKAGE='Convex_hull_2 Convex_hull_3 Convex_hull_d ' - - PACKAGE='Distance_2 Distance_3 Envelope_2 ' - - PACKAGE='Envelope_3 Filtered_kernel Generalized_map ' - - PACKAGE='Generator Geomview GraphicsView ' - - PACKAGE='HalfedgeDS Hash_map Homogeneous_kernel ' - - PACKAGE='Inscribed_areas Installation Interpolation ' - - PACKAGE='Intersections_2 Intersections_3 Interval_skip_list ' - - PACKAGE='Interval_support Inventor Jet_fitting_3 ' - - PACKAGE='Kernel_23 Kernel_d Kinetic_data_structures ' - - PACKAGE='Kinetic_framework LEDA Linear_cell_complex ' - - PACKAGE='MacOSX Maintenance Matrix_search ' - - PACKAGE='Mesh_2 Mesh_3 Mesher_level ' - - PACKAGE='Minkowski_sum_2 Minkowski_sum_3 Modifier ' - - PACKAGE='Modular_arithmetic Nef_2 Nef_3 ' - - PACKAGE='Nef_S2 NewKernel_d Number_types ' - - PACKAGE='OpenNL Operations_on_polyhedra Optimal_transportation_reconstruction_2 ' - - PACKAGE='Optimisation_basic Partition_2 Periodic_2_triangulation_2 ' - - PACKAGE='Periodic_3_triangulation_3 Point_set_2 Point_set_3 ' - - PACKAGE='Point_set_processing_3 Point_set_shape_detection_3 Poisson_surface_reconstruction_3 ' - - PACKAGE='Polygon Polygon_mesh_processing Polyhedron ' - - PACKAGE='Polyhedron_IO Polyline_simplification_2 Polynomial ' - - PACKAGE='Polytope_distance_d Principal_component_analysis Principal_component_analysis_LGPL ' - - PACKAGE='Profiling_tools Property_map QP_solver ' - - PACKAGE='Random_numbers Ridges_3 Scale_space_reconstruction_3 ' - - PACKAGE='Scripts SearchStructures Segment_Delaunay_graph_2 ' - - PACKAGE='Segment_Delaunay_graph_Linf_2 Set_movable_separability_2 Skin_surface_3 ' - - PACKAGE='Snap_rounding_2 Solver_interface Spatial_searching ' - - PACKAGE='Spatial_sorting STL_Extension Straight_skeleton_2 ' - - PACKAGE='Stream_lines_2 Stream_support Subdivision_method_3 ' - - PACKAGE='Surface_mesh Surface_mesh_deformation Surface_mesh_parameterization ' - - PACKAGE='Surface_mesh_segmentation Surface_mesh_shortest_path Surface_mesh_simplification ' - - PACKAGE='Surface_mesh_skeletonization Surface_mesher Sweep_line_2 ' - - PACKAGE='TDS_2 TDS_3 Testsuite ' - - PACKAGE='Three Triangulation Triangulation_2 ' - - PACKAGE='Triangulation_3 Union_find Visibility_2 ' - - PACKAGE='Voronoi_diagram_2 wininst ' - - PACKAGE='Polyhedron_demo' -compiler: +language: cpp +dist: trusty +sudo: required +env: + matrix: + - PACKAGE='CHECK' + - PACKAGE='AABB_tree Advancing_front_surface_reconstruction Algebraic_foundations ' + - PACKAGE='Algebraic_kernel_d Algebraic_kernel_for_circles Algebraic_kernel_for_spheres ' + - PACKAGE='Alpha_shapes_2 Alpha_shapes_3 Apollonius_graph_2 ' + - PACKAGE='Arithmetic_kernel Arrangement_on_surface_2 Barycentric_coordinates_2 ' + - PACKAGE='BGL Boolean_set_operations_2 Bounding_volumes ' + - PACKAGE='Box_intersection_d Cartesian_kernel CGAL_Core ' + - PACKAGE='CGAL_ImageIO CGAL_ipelets Circular_kernel_2 ' + - PACKAGE='Circular_kernel_3 Circulator Classification ' + - PACKAGE='Combinatorial_map Cone_spanners_2 Convex_decomposition_3 ' + - PACKAGE='Convex_hull_2 Convex_hull_3 Convex_hull_d ' + - PACKAGE='Distance_2 Distance_3 Envelope_2 ' + - PACKAGE='Envelope_3 Filtered_kernel Generalized_map ' + - PACKAGE='Generator Geomview GraphicsView ' + - PACKAGE='HalfedgeDS Hash_map Homogeneous_kernel ' + - PACKAGE='Inscribed_areas Installation Interpolation ' + - PACKAGE='Intersections_2 Intersections_3 Interval_skip_list ' + - PACKAGE='Interval_support Inventor Jet_fitting_3 ' + - PACKAGE='Kernel_23 Kernel_d Kinetic_data_structures ' + - PACKAGE='Kinetic_framework LEDA Linear_cell_complex ' + - PACKAGE='MacOSX Maintenance Matrix_search ' + - PACKAGE='Mesh_2 Mesh_3 Mesher_level ' + - PACKAGE='Minkowski_sum_2 Minkowski_sum_3 Modifier ' + - PACKAGE='Modular_arithmetic Nef_2 Nef_3 ' + - PACKAGE='Nef_S2 NewKernel_d Number_types ' + - PACKAGE='OpenNL Operations_on_polyhedra Optimal_transportation_reconstruction_2 ' + - PACKAGE='Optimisation_basic Partition_2 Periodic_2_triangulation_2 ' + - PACKAGE='Periodic_3_triangulation_3 Point_set_2 Point_set_3 ' + - PACKAGE='Point_set_processing_3 Point_set_shape_detection_3 Poisson_surface_reconstruction_3 ' + - PACKAGE='Polygon Polygon_mesh_processing Polyhedron ' + - PACKAGE='Polyhedron_IO Polyline_simplification_2 Polynomial ' + - PACKAGE='Polytope_distance_d Principal_component_analysis Principal_component_analysis_LGPL ' + - PACKAGE='Profiling_tools Property_map QP_solver ' + - PACKAGE='Random_numbers Ridges_3 Scale_space_reconstruction_3 ' + - PACKAGE='Scripts SearchStructures Segment_Delaunay_graph_2 ' + - PACKAGE='Segment_Delaunay_graph_Linf_2 Set_movable_separability_2 Skin_surface_3 ' + - PACKAGE='Snap_rounding_2 Solver_interface Spatial_searching ' + - PACKAGE='Spatial_sorting STL_Extension Straight_skeleton_2 ' + - PACKAGE='Stream_lines_2 Stream_support Subdivision_method_3 ' + - PACKAGE='Surface_mesh Surface_mesh_deformation Surface_mesh_parameterization ' + - PACKAGE='Surface_mesh_segmentation Surface_mesh_shortest_path Surface_mesh_simplification ' + - PACKAGE='Surface_mesh_skeletonization Surface_mesher Sweep_line_2 ' + - PACKAGE='TDS_2 TDS_3 Testsuite ' + - PACKAGE='Three Triangulation Triangulation_2 ' + - PACKAGE='Triangulation_3 Union_find Visibility_2 ' + - PACKAGE='Voronoi_diagram_2 wininst ' + - PACKAGE='Polyhedron_demo' +compiler: - clang-3.6 - - gcc -install: + - gcc +install: - if [[ "$CXX" = "clang++" ]]; then export CXX=clang++-3.6 CC=clang-3.6; fi -before_script: -- mkdir -p build -- cd build -- cmake -DCGAL_HEADER_ONLY=ON -DQt5_DIR="/opt/qt55/lib/cmake/Qt5" -DQt5Svg_DIR="/opt/qt55/lib/cmake/Qt5Svg" -DQt5OpenGL_DIR="/opt/qt55/lib/cmake/Qt5OpenGL" -DWITH_demos:BOOL=TRUE -DWITH_examples:BOOL=true -DWITH_tests:BOOL=TRUE -DCMAKE_CXX_FLAGS_RELEASE=-DCGAL_NDEBUG .. -- make -- cd .. -script: +before_script: +- mkdir -p build +- cd build +- cmake -DCGAL_HEADER_ONLY=ON -DQt5_DIR="/opt/qt55/lib/cmake/Qt5" -DQt5Svg_DIR="/opt/qt55/lib/cmake/Qt5Svg" -DQt5OpenGL_DIR="/opt/qt55/lib/cmake/Qt5OpenGL" -DWITH_demos:BOOL=TRUE -DWITH_examples:BOOL=true -DWITH_tests:BOOL=TRUE -DCMAKE_CXX_FLAGS_RELEASE=-DCGAL_NDEBUG .. +- make +- cd .. +script: - cd ./.travis - bash -x -e ./build_package.sh $PACKAGE -addons: +addons: apt: sources: - - sourceline: 'ppa:ppsspp/cmake' + - sourceline: 'ppa:ppsspp/cmake' - sourceline: 'ppa:hedges/qt5.5' packages: - clang-3.6 - zsh - - cmake - - libboost1.55-dev - - libboost-system1.55-dev - - libboost-program-options1.55-dev - - libboost-thread1.55-dev - - libgmp-dev - - libmpfr-dev - - zlib1g-dev - - libeigen3-dev # too old + - cmake + - libboost1.55-dev + - libboost-system1.55-dev + - libboost-program-options1.55-dev + - libboost-thread1.55-dev + - libgmp-dev + - libmpfr-dev + - zlib1g-dev + - libeigen3-dev # too old - qt55base - - qt55script + - qt55script - qt55svg - qt55tools - qt55graphicaleffects - + - mesa-common-dev - libglu1-mesa-dev - # Not allowed (yet) - # - geomview - # - libglew1.5-dev - # - libipe-dev - # - libmpfi-dev + # Not allowed (yet) + # - geomview + # - libglew1.5-dev + # - libipe-dev + # - libmpfi-dev notifications: email: on_success: change # default: always diff --git a/.travis/packages.txt b/.travis/packages.txt index 938e6693a65..86ccf973d17 100644 --- a/.travis/packages.txt +++ b/.travis/packages.txt @@ -1,134 +1,134 @@ -AABB_tree -Advancing_front_surface_reconstruction -Algebraic_foundations -Algebraic_kernel_d -Algebraic_kernel_for_circles -Algebraic_kernel_for_spheres -Alpha_shapes_2 -Alpha_shapes_3 -Apollonius_graph_2 -Arithmetic_kernel -Arrangement_on_surface_2 -Barycentric_coordinates_2 -BGL -Boolean_set_operations_2 -Bounding_volumes -Box_intersection_d -Cartesian_kernel -CGAL_Core -CGAL_ImageIO -CGAL_ipelets -Circular_kernel_2 -Circular_kernel_3 -Circulator -Classification -Combinatorial_map -Cone_spanners_2 -Convex_decomposition_3 -Convex_hull_2 -Convex_hull_3 -Convex_hull_d -Distance_2 -Distance_3 -Envelope_2 -Envelope_3 -Filtered_kernel -Generalized_map -Generator -Geomview -GraphicsView -HalfedgeDS -Hash_map -Homogeneous_kernel -Inscribed_areas -Installation -Interpolation -Intersections_2 -Intersections_3 -Interval_skip_list -Interval_support -Inventor -Jet_fitting_3 -Kernel_23 -Kernel_d -Kinetic_data_structures -Kinetic_framework -LEDA -Linear_cell_complex -MacOSX -Maintenance -Matrix_search -Mesh_2 -Mesh_3 -Mesher_level -Minkowski_sum_2 -Minkowski_sum_3 -Modifier -Modular_arithmetic -Nef_2 -Nef_3 -Nef_S2 -NewKernel_d -Number_types -OpenNL -Operations_on_polyhedra -Optimal_transportation_reconstruction_2 -Optimisation_basic -Partition_2 -Periodic_2_triangulation_2 -Periodic_3_triangulation_3 -Point_set_2 -Point_set_3 -Point_set_processing_3 -Point_set_shape_detection_3 -Poisson_surface_reconstruction_3 -Polygon -Polygon_mesh_processing -Polyhedron -Polyhedron_IO -Polyline_simplification_2 -Polynomial -Polytope_distance_d -Principal_component_analysis -Principal_component_analysis_LGPL -Profiling_tools -Property_map -QP_solver -Random_numbers -Ridges_3 -Scale_space_reconstruction_3 -Scripts -SearchStructures -Segment_Delaunay_graph_2 -Segment_Delaunay_graph_Linf_2 -Set_movable_separability_2 -Skin_surface_3 -Snap_rounding_2 -Solver_interface -Spatial_searching -Spatial_sorting -STL_Extension -Straight_skeleton_2 -Stream_lines_2 -Stream_support -Subdivision_method_3 -Surface_mesh -Surface_mesh_deformation -Surface_mesh_parameterization -Surface_mesh_segmentation -Surface_mesh_shortest_path -Surface_mesh_simplification -Surface_mesh_skeletonization -Surface_mesher -Sweep_line_2 -TDS_2 -TDS_3 -Testsuite -Three -Triangulation -Triangulation_2 -Triangulation_3 -Union_find -Visibility_2 -Voronoi_diagram_2 -wininst +AABB_tree +Advancing_front_surface_reconstruction +Algebraic_foundations +Algebraic_kernel_d +Algebraic_kernel_for_circles +Algebraic_kernel_for_spheres +Alpha_shapes_2 +Alpha_shapes_3 +Apollonius_graph_2 +Arithmetic_kernel +Arrangement_on_surface_2 +Barycentric_coordinates_2 +BGL +Boolean_set_operations_2 +Bounding_volumes +Box_intersection_d +Cartesian_kernel +CGAL_Core +CGAL_ImageIO +CGAL_ipelets +Circular_kernel_2 +Circular_kernel_3 +Circulator +Classification +Combinatorial_map +Cone_spanners_2 +Convex_decomposition_3 +Convex_hull_2 +Convex_hull_3 +Convex_hull_d +Distance_2 +Distance_3 +Envelope_2 +Envelope_3 +Filtered_kernel +Generalized_map +Generator +Geomview +GraphicsView +HalfedgeDS +Hash_map +Homogeneous_kernel +Inscribed_areas +Installation +Interpolation +Intersections_2 +Intersections_3 +Interval_skip_list +Interval_support +Inventor +Jet_fitting_3 +Kernel_23 +Kernel_d +Kinetic_data_structures +Kinetic_framework +LEDA +Linear_cell_complex +MacOSX +Maintenance +Matrix_search +Mesh_2 +Mesh_3 +Mesher_level +Minkowski_sum_2 +Minkowski_sum_3 +Modifier +Modular_arithmetic +Nef_2 +Nef_3 +Nef_S2 +NewKernel_d +Number_types +OpenNL +Operations_on_polyhedra +Optimal_transportation_reconstruction_2 +Optimisation_basic +Partition_2 +Periodic_2_triangulation_2 +Periodic_3_triangulation_3 +Point_set_2 +Point_set_3 +Point_set_processing_3 +Point_set_shape_detection_3 +Poisson_surface_reconstruction_3 +Polygon +Polygon_mesh_processing +Polyhedron +Polyhedron_IO +Polyline_simplification_2 +Polynomial +Polytope_distance_d +Principal_component_analysis +Principal_component_analysis_LGPL +Profiling_tools +Property_map +QP_solver +Random_numbers +Ridges_3 +Scale_space_reconstruction_3 +Scripts +SearchStructures +Segment_Delaunay_graph_2 +Segment_Delaunay_graph_Linf_2 +Set_movable_separability_2 +Skin_surface_3 +Snap_rounding_2 +Solver_interface +Spatial_searching +Spatial_sorting +STL_Extension +Straight_skeleton_2 +Stream_lines_2 +Stream_support +Subdivision_method_3 +Surface_mesh +Surface_mesh_deformation +Surface_mesh_parameterization +Surface_mesh_segmentation +Surface_mesh_shortest_path +Surface_mesh_simplification +Surface_mesh_skeletonization +Surface_mesher +Sweep_line_2 +TDS_2 +TDS_3 +Testsuite +Three +Triangulation +Triangulation_2 +Triangulation_3 +Union_find +Visibility_2 +Voronoi_diagram_2 +wininst diff --git a/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/aggregated_insertion.cpp b/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/aggregated_insertion.cpp index 738eb505ee0..c2df07a93c8 100644 --- a/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/aggregated_insertion.cpp +++ b/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/aggregated_insertion.cpp @@ -17,21 +17,21 @@ typedef CGAL::Arrangement_2 Arrangement_2; int main () { // Construct the arrangement of five intersecting segments. - Arrangement_2 arr; - std::list segments; + Arrangement_2 arr; + std::list segments; - segments.push_back (Segment_2 (Point_2(1, 0), Point_2(2, 4))); - segments.push_back (Segment_2 (Point_2(5, 0), Point_2(5, 5))); - segments.push_back (Segment_2 (Point_2(1, 0), Point_2(5, 3))); - segments.push_back (Segment_2 (Point_2(0, 2), Point_2(6, 0))); - segments.push_back (Segment_2 (Point_2(3, 0), Point_2(5, 5))); + segments.push_back(Segment_2(Point_2(1, 0), Point_2(2, 4))); + segments.push_back(Segment_2(Point_2(5, 0), Point_2(5, 5))); + segments.push_back(Segment_2(Point_2(1, 0), Point_2(5, 3))); + segments.push_back(Segment_2(Point_2(0, 2), Point_2(6, 0))); + segments.push_back(Segment_2(Point_2(3, 0), Point_2(5, 5))); - insert (arr, segments.begin(), segments.end()); + insert(arr, segments.begin(), segments.end()); // Print the size of the arrangement. std::cout << "The arrangement size:" << std::endl << " V = " << arr.number_of_vertices() - << ", E = " << arr.number_of_edges() + << ", E = " << arr.number_of_edges() << ", F = " << arr.number_of_faces() << std::endl; return 0; diff --git a/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/algebraic_segments.cpp b/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/algebraic_segments.cpp index e68c2870739..11ac25e3382 100644 --- a/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/algebraic_segments.cpp +++ b/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/algebraic_segments.cpp @@ -5,8 +5,8 @@ #if (!CGAL_USE_CORE) && (!CGAL_USE_LEDA) && (!(CGAL_USE_GMP && CGAL_USE_MPFI)) int main () { - std::cout << "Sorry, this example needs CORE, LEDA, or GMP+MPFI ..." - << std::endl; + std::cout << "Sorry, this example needs CORE, LEDA, or GMP+MPFI ..." + << std::endl; return 0; } #else @@ -32,7 +32,7 @@ typedef Arr_traits_2::Polynomial_2 Polynomial_2; typedef Arr_traits_2::Algebraic_real_1 Algebraic_real_1; typedef Arr_traits_2::X_monotone_curve_2 X_monotone_curve_2; typedef Arr_traits_2::Point_2 Point_2; - + int main() { @@ -46,7 +46,7 @@ int main() { = arr_traits.construct_point_2_object(); Arr_traits_2::Make_x_monotone_2 make_x_monotone = arr_traits.make_x_monotone_2_object(); - + Arrangement_2 arr(&arr_traits); std::vector segs; @@ -80,7 +80,7 @@ int main() { // Construct a vertical cusp x^2-y^3=0 Curve_2 cv2 = construct_curve(CGAL::ipower(x,2)-CGAL::ipower(y,3)); - // Construct a segment containing the cusp point. + // Construct a segment containing the cusp point. // This adds to X_monotone_curve_2 objects to the vector, // because the cusp is a critical point Point_2 p21 = construct_point(Algebraic_real_1(-2),cv2,0); @@ -121,9 +121,9 @@ int main() { // Print the arrangement size. std::cout << "The arrangement size:" << std::endl << " V = " << arr.number_of_vertices() - << ", E = " << arr.number_of_edges() + << ", E = " << arr.number_of_edges() << ", F = " << arr.number_of_faces() << std::endl; - + return 0; } diff --git a/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/batched_point_location.cpp b/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/batched_point_location.cpp index 0da49fe117b..09905656857 100644 --- a/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/batched_point_location.cpp +++ b/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/batched_point_location.cpp @@ -1,8 +1,7 @@ //! \file examples/Arrangement_on_surface_2/batched_point_location.cpp // Answering a batched point-location query. -#include -#include +#include #include #include #include @@ -10,46 +9,48 @@ #include "point_location_utils.h" -typedef CGAL::MP_Float Number_type; -typedef CGAL::Cartesian Kernel; -typedef CGAL::Arr_segment_traits_2 Traits_2; -typedef Traits_2::Point_2 Point_2; -typedef CGAL::Arrangement_2 Arrangement_2; -typedef CGAL::Arr_point_location_result Point_location_result; -typedef std::pair Query_result; +typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; +typedef CGAL::Arr_segment_traits_2 Traits; +typedef Traits::Point_2 Point; +typedef CGAL::Arrangement_2 Arrangement; +typedef CGAL::Arr_point_location_result Point_location_result; +typedef std::pair Query_result; -typedef Arrangement_2::Vertex_const_handle Vertex_const_handle; -typedef Arrangement_2::Halfedge_const_handle Halfedge_const_handle; -typedef Arrangement_2::Face_const_handle Face_const_handle; +typedef Arrangement::Vertex_const_handle Vertex_const_handle; +typedef Arrangement::Halfedge_const_handle Halfedge_const_handle; +typedef Arrangement::Face_const_handle Face_const_handle; -int main () +int main() { // Construct the arrangement. - Arrangement_2 arr; + Arrangement arr; construct_segments_arr(arr); // Perform a batched point-location query. - std::list points; - points.push_back(Point_2(1, 4)); - points.push_back(Point_2(4, 3)); - points.push_back(Point_2(6, 3)); - points.push_back(Point_2(3, 2)); - points.push_back(Point_2(5, 2)); - points.push_back(Point_2(1, 0)); - std::list results; + std::list points; + points.push_back(Point(1, 4)); + points.push_back(Point(4, 3)); + points.push_back(Point(6, 3)); + points.push_back(Point(3, 2)); + points.push_back(Point(5, 2)); + points.push_back(Point(1, 0)); + std::list results; locate(arr, points.begin(), points.end(), std::back_inserter(results)); // Print the results. std::list::const_iterator it; for (it = results.begin(); it != results.end(); ++it) { std::cout << "The point (" << it->first << ") is located "; - if (const Face_const_handle* f = boost::get(&(it->second))) // inside a face + if (const Face_const_handle* f = + boost::get(&(it->second))) // inside a face std::cout << "inside " << (((*f)->is_unbounded()) ? "the unbounded" : "a bounded") << " face." << std::endl; - else if (const Halfedge_const_handle* e = boost::get(&(it->second))) // on an edge + else if (const Halfedge_const_handle* e = + boost::get(&(it->second))) // on an edge std::cout << "on an edge: " << (*e)->curve() << std::endl; - else if (const Vertex_const_handle* v = boost::get(&(it->second))) // on a vertex + else if (const Vertex_const_handle* v = + boost::get(&(it->second))) // on a vertex std::cout << "on " << (((*v)->is_isolated()) ? "an isolated" : "a") << " vertex: " << (*v)->point() << std::endl; diff --git a/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/bounded_planar_vertical_decomposition.cpp b/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/bounded_planar_vertical_decomposition.cpp index e3f8cf06d05..a28f94b838b 100644 --- a/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/bounded_planar_vertical_decomposition.cpp +++ b/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/bounded_planar_vertical_decomposition.cpp @@ -1,15 +1,13 @@ //! \file examples/Arrangement_on_surface_2/vertical_decomposition.cpp // Performing vertical decomposition of an arrangement. -#include -#include +#include #include #include #include #include -typedef CGAL::MP_Float Number_type; -typedef CGAL::Cartesian Kernel; +typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; typedef CGAL::Arr_segment_traits_2 Traits_2; typedef Traits_2::Point_2 Point_2; typedef Traits_2::X_monotone_curve_2 Segment_2; @@ -24,7 +22,7 @@ typedef std::list Vert_decomp_list; int main() { // Construct the arrangement. - Arrangement_2 arr; + Arrangement_2 arr; insert_non_intersecting_curve(arr, Segment_2(Point_2(1, 1), Point_2(3, 0))); insert_non_intersecting_curve(arr, Segment_2(Point_2(1, 1), Point_2(2, 2))); diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_batched_point_location.h b/Arrangement_on_surface_2/include/CGAL/Arr_batched_point_location.h index d978f22eb5e..b842d1f0ba9 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_batched_point_location.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_batched_point_location.h @@ -25,9 +25,12 @@ #include - #include -#include +#include +#include +#include +#include +#include #include #include @@ -35,15 +38,16 @@ namespace CGAL { -/*! - * Issue a batched point-location query on an arrangement given an input +namespace Ss2 = Surface_sweep_2; + +/*! Issue a batched point-location query on an arrangement given an input * range of points. * \param arr The arrangement. * \param points_begin An iterator for the range of query points. * \param points_end A past-the-end iterator for the range of query points. * \param oi Output: An output iterator for the query results. * \pre The value-type of PointsIterator is Arrangement::Point_2, - * and the value-type of OutputIterator is is pair, + * and the value-type of OutputIterator is is pair, * where Result is either * (i) Object or * (ii) boost::optional >. * It represents the arrangement feature containing the point. */ -template +template OutputIterator -locate(const Arrangement_on_surface_2& arr, +locate(const Arrangement_on_surface_2& arr, PointsIterator points_begin, PointsIterator points_end, OutputIterator oi) { + typedef GeometryTraits_2 Gt2; + typedef TopologyTraits Tt; + typedef OutputIterator Output_iterator; + // Arrangement types: - typedef Arrangement_on_surface_2 Arr; - typedef typename TopTraits::template - Sweep_line_batched_point_location_visitor - Bpl_visitor; + typedef Arrangement_on_surface_2 Arr; + typedef typename Arr::Halfedge_const_handle Halfedge_const_handle; + typedef typename Arr::Vertex_const_iterator Vertex_const_iterator; + typedef typename Arr::Edge_const_iterator Edge_const_iterator; + typedef typename Arr::Vertex_const_handle Vertex_const_handle; + typedef typename Arr::Halfedge_const_handle Halfedge_const_handle; + typedef typename Arr::Allocator Allocator; - typedef typename Arr::Halfedge_const_handle Halfedge_const_handle; - typedef typename Arr::Vertex_const_iterator Vertex_const_iterator; - typedef typename Arr::Edge_const_iterator Edge_const_iterator; - typedef typename Arr::Vertex_const_handle Vertex_const_handle; - typedef typename Arr::Halfedge_const_handle Halfedge_const_handle; - - typedef typename Bpl_visitor::Traits_2 Bpl_traits_2; - typedef typename Bpl_traits_2::X_monotone_curve_2 Bpl_x_monotone_curve_2; - typedef typename Bpl_traits_2::Point_2 Bpl_point_2; + // Surface sweep types + typedef Arr_batched_point_location_traits_2 Bgt2; + typedef Ss2::No_overlap_event Bpl_event; + typedef Ss2::No_overlap_subcurve + Bpl_curve; + typedef typename Tt::template Batched_point_location_helper + Bpl_helper; + typedef Arr_batched_pl_ss_visitor + Bpl_visitor; + typedef typename Bgt2::X_monotone_curve_2 Bpl_x_monotone_curve_2; + typedef typename Bgt2::Point_2 Bpl_point_2; // Go over all arrangement edges and collect their associated x-monotone // curves. To each curve we attach a halfedge handle going from right to // left. - std::vector xcurves_vec(arr.number_of_edges()); - Edge_const_iterator eit; - unsigned int i = 0; + std::vector xcurves_vec(arr.number_of_edges()); + Edge_const_iterator eit; + std::size_t i(0); for (eit = arr.edges_begin(); eit != arr.edges_end(); ++eit) { // Associate each x-monotone curve with the halfedge that represent it // that is directed from right to left. @@ -90,8 +104,8 @@ locate(const Arrangement_on_surface_2& arr, // Go over all isolated vertices and collect their points. To each point // we attach its vertex handle. - std::vector iso_pts_vec(arr.number_of_isolated_vertices()); - Vertex_const_iterator vit; + std::vector iso_pts_vec(arr.number_of_isolated_vertices()); + Vertex_const_iterator vit; i = 0; for (vit = arr.vertices_begin(); vit != arr.vertices_end(); ++vit) { if (vit->is_isolated()) { @@ -99,39 +113,36 @@ locate(const Arrangement_on_surface_2& arr, iso_pts_vec[i++] = Bpl_point_2(vit->point(), iso_v); } } - + // Obtain a extended traits-class object. - GeomTraits* geom_traits = const_cast(arr.geometry_traits()); + const Gt2* geom_traits = arr.geometry_traits(); /* We would like to avoid copy construction of the geometry traits class. * Copy construction is undesired, because it may results with data * duplication or even data loss. * - * If the type Bpl_traits_2 is the same as the type - * GeomTraits, use a reference to GeomTraits to avoid constructing a new one. - * Otherwise, instantiate a local variable of the former and provide - * the later as a single parameter to the constructor. - * + * If the type Bgt2 is the same as the type Gt2, use a reference to Gt2 + * to avoid constructing a new one. Otherwise, instantiate a local variable + * of the former and provide the later as a single parameter to the + * constructor. + * * Use the form 'A a(*b);' and not ''A a = b;' to handle the case where A has * only an implicit constructor, (which takes *b as a parameter). */ - typename boost::mpl::if_, - const Bpl_traits_2&, Bpl_traits_2>::type + typename boost::mpl::if_, const Bgt2&, Bgt2>::type ex_traits(*geom_traits); // Define the sweep-line visitor and perform the sweep. - Bpl_visitor visitor(&arr, oi); - Basic_sweep_line_2 - sweep_line(&ex_traits, &visitor); - sweep_line.sweep(xcurves_vec.begin(), xcurves_vec.end(), // Curves. - iso_pts_vec.begin(), iso_pts_vec.end(), // Action points. - points_begin, points_end); // Query points. + Bpl_visitor visitor(&arr, oi); + Ss2::No_intersection_surface_sweep_2 + surface_sweep(&ex_traits, &visitor); + surface_sweep.sweep(xcurves_vec.begin(), xcurves_vec.end(), // Curves. + iso_pts_vec.begin(), iso_pts_vec.end(), // Action points. + points_begin, points_end); // Query points. return oi; } -} //namespace CGAL +} // namespace CGAL #endif diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_bounded_planar_topology_traits_2.h b/Arrangement_on_surface_2/include/CGAL/Arr_bounded_planar_topology_traits_2.h index d470a6a5631..db406ce7471 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_bounded_planar_topology_traits_2.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_bounded_planar_topology_traits_2.h @@ -26,8 +26,8 @@ #include - /*! \file + * * Definition of the Arr_bounded_planar_topology_traits_2 class. */ @@ -40,56 +40,61 @@ #include #include #include + namespace CGAL { // Forward declaration: -template +template class Arrangement_on_surface_2; /*! \class Arr_bounded_planar_topology_traits_2 + * * A topology-traits class that encapsulates the embedding of 2D arrangements * of bounded curves on the plane. */ -template > +template > class Arr_bounded_planar_topology_traits_2 : - public Arr_planar_topology_traits_base_2 + public Arr_planar_topology_traits_base_2 { +public: + typedef GeometryTraits_2 Geometry_traits_2; + typedef Dcel_ Dcel; + private: - typedef Arr_planar_topology_traits_base_2 Base; + typedef Geometry_traits_2 Gt2; + typedef Arr_planar_topology_traits_base_2 Base; public: ///! \name The geometry-traits types. //@{ - typedef GeomTraits_ Geometry_traits_2; - typedef typename Base::Point_2 Point_2; - typedef typename Base::X_monotone_curve_2 X_monotone_curve_2; + typedef typename Base::Point_2 Point_2; + typedef typename Base::X_monotone_curve_2 X_monotone_curve_2; //@} ///! \name The DCEL types. //@{ - typedef Dcel_ Dcel; - typedef typename Base::Size Size; - typedef typename Base::Vertex Vertex; - typedef typename Base::Halfedge Halfedge; - typedef typename Base::Face Face; - typedef typename Base::Outer_ccb Outer_ccb; - typedef typename Base::Inner_ccb Inner_ccb; - typedef typename Base::Isolated_vertex Isolated_vertex; + typedef typename Base::Size Size; + typedef typename Base::Vertex Vertex; + typedef typename Base::Halfedge Halfedge; + typedef typename Base::Face Face; + typedef typename Base::Outer_ccb Outer_ccb; + typedef typename Base::Inner_ccb Inner_ccb; + typedef typename Base::Isolated_vertex Isolated_vertex; //@} //! \name Arrangement types //!@{ - typedef Arr_bounded_planar_topology_traits_2 Self; - typedef Arr_traits_basic_adaptor_2 Traits_adaptor_2; + typedef Arr_bounded_planar_topology_traits_2 Self; + typedef Arr_traits_basic_adaptor_2 Gt_adaptor_2; //!@} ///! \name The side tags //@{ - typedef typename Traits_adaptor_2::Left_side_category Left_side_category; - typedef typename Traits_adaptor_2::Bottom_side_category Bottom_side_category; - typedef typename Traits_adaptor_2::Top_side_category Top_side_category; - typedef typename Traits_adaptor_2::Right_side_category Right_side_category; + typedef typename Gt_adaptor_2::Left_side_category Left_side_category; + typedef typename Gt_adaptor_2::Bottom_side_category Bottom_side_category; + typedef typename Gt_adaptor_2::Top_side_category Top_side_category; + typedef typename Gt_adaptor_2::Right_side_category Right_side_category; BOOST_MPL_ASSERT ((boost::is_same< Left_side_category, Arr_oblivious_side_tag >)); @@ -105,7 +110,7 @@ public: * An auxiliary structure for rebinding the topology traits with a new * geometry-traits class and a new DCEL class. */ - template + template struct rebind { typedef Arr_bounded_planar_topology_traits_2 other; }; @@ -129,7 +134,7 @@ public: {} /*! Constructor from a geometry-traits object. */ - Arr_bounded_planar_topology_traits_2(const Geometry_traits_2* traits) : + Arr_bounded_planar_topology_traits_2(const Gt2* traits) : Base(traits), unb_face(NULL) {} @@ -191,189 +196,160 @@ public: //@} private: - /// \name Auxiliary type definitions. //@{ - typedef Arrangement_on_surface_2 Arr; + typedef Arrangement_on_surface_2 Arr; - // Type definition for the constuction sweep-line visitor. - typedef Arr_construction_subcurve CSubcurve; - typedef Arr_construction_event - CEvent; - typedef Arr_bounded_planar_construction_helper CHelper; +public: + // The following definitions of helper functions use a C++11 features called + // alias template. This feature can be mimiked by non C++11 support simply by + // defining a type that inherits from the template we need to alias. However, + // the non-C++11 code requires the (re)definition of all constructors of the + // derived class. +#if defined(CGAL_CFG_NO_CPP0X_TEMPLATE_ALIASES) + // Type definition for the construction surface-sweep visitor. + template + struct Construction_helper : + public Arr_bounded_planar_construction_helper + { + typedef Arr_bounded_planar_construction_helper + Base; + Construction_helper(Arr* arr) : Base(arr) {} + }; - // Type definition for the basic insertion sweep-line visitor. - typedef Arr_basic_insertion_traits_2 BInsTraits; - typedef Arr_construction_subcurve BISubcurve; - typedef Arr_construction_event - BIEvent; - typedef Arr_bounded_planar_insertion_helper BIHelper; + // Type definition for the no-intersection construction surface-sweep visitor. + template + struct No_intersection_construction_helper : + public Arr_bounded_planar_construction_helper + { + typedef Arr_bounded_planar_construction_helper + Base; + No_intersection_construction_helper(Arr* arr) : Base(arr) {} + }; - // Type definition for the insertion sweep-line visitor. - typedef Arr_insertion_traits_2 InsTraits; - typedef Arr_construction_subcurve ISubcurve; - typedef Arr_construction_event - IEvent; - typedef Arr_bounded_planar_insertion_helper IHelper; + // Type definition for the insertion surface-sweep visitor. + typedef Arr_insertion_traits_2 I_traits; + template + struct Insertion_helper : + public Arr_bounded_planar_insertion_helper + { + typedef Arr_bounded_planar_insertion_helper + Base; + Insertion_helper(Arr* arr) : Base(arr) {} + }; - // Type definition for the batched point-location sweep-line visitor. - typedef Arr_batched_point_location_traits_2 BplTraits; - typedef Arr_bounded_planar_batched_pl_helper BplHelper; + // Type definition for the no-intersection insertion surface-sweep visitor. + typedef Arr_basic_insertion_traits_2 Nxi_traits; + template + struct No_intersection_insertion_helper : + public Arr_bounded_planar_insertion_helper + { + typedef Arr_bounded_planar_insertion_helper + Base; + No_intersection_insertion_helper(Arr* arr) : Base(arr) {} + }; + + // Type definition for the batched point-location surface-sweep visitor. + typedef Arr_batched_point_location_traits_2 Bpl_traits; + template + struct Batched_point_location_helper : + public Arr_bounded_planar_batched_pl_helper + { + typedef Arr_bounded_planar_batched_pl_helper + Base; + Batched_point_location_helper(const Arr* arr) : Base(arr) {} + }; // Type definition for the vertical decomposition sweep-line visitor. - typedef Arr_batched_point_location_traits_2 VdTraits; - typedef Arr_bounded_planar_vert_decomp_helper VdHelper; - - // Type definition for the overlay sweep-line visitor. - template - struct _Overlay_helper : public Arr_bounded_planar_overlay_helper - , - Arr>, - Arr_overlay_subcurve > + typedef Arr_batched_point_location_traits_2 Vd_traits; + template + struct Vertical_decomposition_helper : + public Arr_bounded_planar_vert_decomp_helper { - typedef Arr_bounded_planar_overlay_helper - , - Arr>, - Arr_overlay_subcurve > Base; - - typedef typename Base::Traits_2 Traits_2; - typedef typename Base::Arrangement_red_2 Arrangement_red_2; - typedef typename Base::Arrangement_blue_2 Arrangement_blue_2; - typedef typename Base::Arrangement_2 Arrangement_2; - typedef typename Base::Event Event; - typedef typename Base::Subcurve Subcurve; - typedef typename Base::Construction_helper Construction_helper; - - _Overlay_helper(const ArrangementA_* arr_a, const ArrangementB_* arr_b) : - Base(arr_a, arr_b) - {} + typedef Arr_bounded_planar_vert_decomp_helper + Base; + Vertical_decomposition_helper(const Arr* arr) : Base(arr) {} }; + + // Type definition for the overlay surface-sweep visitor. + template + struct Overlay_helper : + public Arr_bounded_planar_overlay_helper + { + typedef Arr_bounded_planar_overlay_helper + Base; + Overlay_helper(const ArrA* arr_a, const ArrB* arr_b) : Base(arr_a, arr_b) {} + }; +#else + // Type definition for the construction surface-sweep visitor. + template + using Construction_helper = + Arr_bounded_planar_construction_helper; + + // Type definition for the no-intersection construction surface-sweep visitor. + template + using No_intersection_construction_helper = + Arr_bounded_planar_construction_helper; + + // Type definition for the insertion surface-sweep visitor. + typedef Arr_insertion_traits_2 I_traits; + template + using Insertion_helper = + Arr_bounded_planar_insertion_helper; + + // Type definition for the no-intersection insertion surface-sweep visitor. + typedef Arr_basic_insertion_traits_2 Nxi_traits; + template + using No_intersection_insertion_helper = + Arr_bounded_planar_insertion_helper; + + // Type definition for the batched point-location surface-sweep visitor. + typedef Arr_batched_point_location_traits_2 Bpl_traits; + template + using Batched_point_location_helper = + Arr_bounded_planar_batched_pl_helper; + + // Type definition for the vertical decomposition sweep-line visitor. + typedef Arr_batched_point_location_traits_2 Vd_traits; + template + using Vertical_decomposition_helper = + Arr_bounded_planar_vert_decomp_helper; + + // Type definition for the overlay surface-sweep visitor. + template + using Overlay_helper = + Arr_bounded_planar_overlay_helper; +#endif //@} public: - ///! \name Visitor types. //@{ - typedef Arr_construction_sl_visitor - Sweep_line_construction_visitor; - - typedef Arr_insertion_sl_visitor - Sweep_line_insertion_visitor; - - typedef Sweep_line_construction_visitor - Sweep_line_non_intersecting_construction_visitor; - - typedef Arr_basic_insertion_sl_visitor - Sweep_line_non_intersecting_insertion_visitor; - - template - struct Sweep_line_batched_point_location_visitor : - public Arr_batched_pl_sl_visitor - { - typedef OutputIterator_ Output_iterator; - - typedef Arr_batched_pl_sl_visitor Base; - typedef typename Base::Traits_2 Traits_2; - typedef typename Base::Event Event; - typedef typename Base::Subcurve Subcurve; - - Sweep_line_batched_point_location_visitor(const Arr* arr, - Output_iterator& oi) : - Base(arr, oi) - {} - }; - - template - struct Sweep_line_vertical_decomposition_visitor : - public Arr_vert_decomp_sl_visitor - { - typedef OutputIterator_ Output_iterator; - - typedef Arr_vert_decomp_sl_visitor Base; - typedef typename Base::Traits_2 Traits_2; - typedef typename Base::Event Event; - typedef typename Base::Subcurve Subcurve; - - Sweep_line_vertical_decomposition_visitor(const Arr* arr, - Output_iterator* oi) : - Base(arr, oi) - {} - }; - - template - struct Sweep_line_overlay_visitor : - public Arr_overlay_sl_visitor < - _Overlay_helper< - Arr_overlay_traits_2< Arr_traits_basic_adaptor_2, - ArrangementA_, - ArrangementB_>, - ArrangementA_, - ArrangementB_>, - OverlayTraits_> - { - typedef ArrangementA_ ArrangementA_2; - typedef ArrangementB_ ArrangementB_2; - typedef Arr Arrangement_result_2; - typedef OverlayTraits_ Overlay_traits; - - typedef Arr_overlay_traits_2< - Arr_traits_basic_adaptor_2, - ArrangementA_2, - ArrangementB_2> Geom_ovl_traits_2; - - typedef _Overlay_helper - Ovl_helper; - - typedef Arr_overlay_sl_visitor - Base; - - typedef typename Base::Traits_2 Traits_2; - typedef typename Base::Event Event; - typedef typename Base::Subcurve Subcurve; - - Sweep_line_overlay_visitor (const ArrangementA_2* arrA, - const ArrangementB_2* arrB, - Arrangement_result_2* arr_res, - Overlay_traits* overlay_tr) : - Base (arrA, arrB, arr_res, overlay_tr) - {} - }; - typedef Arr_inc_insertion_zone_visitor - Zone_insertion_visitor; + Zone_insertion_visitor; typedef Arr_walk_along_line_point_location - Default_point_location_strategy; + Default_point_location_strategy; typedef Arr_walk_along_line_point_location - Default_vertical_ray_shooting_strategy; + Default_vertical_ray_shooting_strategy; //@} ///! \name Topology-traits methods. //@{ - /*! - * Initialize an empty DCEL structure. + /*! Initialize an empty DCEL structure. */ void init_dcel(); - /*! - * Make the necessary updates after the DCEL structure have been updated. + /*! Make the necessary updates after the DCEL structure have been updated. */ void dcel_updated(); - /*! - * Check if the given vertex is associated with the given curve end. + /*! Check if the given vertex is associated with the given curve end. * \param v The vertex. * \param cv The x-monotone curve. * \param ind The curve end. @@ -405,8 +381,7 @@ public: } } - /*! - * Given a curve end with boundary conditions and a face that contains the + /*! Given a curve end with boundary conditions and a face that contains the * interior of the curve, find a place for a boundary vertex that will * represent the curve end along the face boundary. * \param f The face. @@ -428,8 +403,7 @@ public: return Object(); } - /*! - * Locate the predecessor halfedge for the given curve around a given + /*! Locate the predecessor halfedge for the given curve around a given * vertex with boundary conditions. * \param v The vertex. * \param cv The x-monotone curve. @@ -451,8 +425,7 @@ public: return NULL; } - /*! - * Locate a DCEL feature that contains the given curve end. + /*! Locate a DCEL feature that contains the given curve end. * \param cv The x-monotone curve. * \param ind The curve end. * \param ps_x The boundary condition of the curve end in x. @@ -470,8 +443,7 @@ public: return Object(); } - /*! - * Split a fictitious edge using the given vertex. + /*! Split a fictitious edge using the given vertex. * \param e The edge to split (one of the pair of halfedges). * \param v The split vertex. * \pre e is a fictitious halfedge. @@ -485,24 +457,21 @@ public: return NULL; } - /*! - * Determine whether the given face is unbounded. + /*! Determine whether the given face is unbounded. * \param f The face. * \return Whether f is unbounded. * There is only one unbounded face in the arrangement: */ bool is_unbounded(const Face* f) const { return (f == unb_face); } - /*! - * Determine whether the given boundary vertex is redundant. + /*! Determine whether the given boundary vertex is redundant. * \param v The vertex. * \return Whether v is redundant, and should be erased. * There are no redundant vertices. */ bool is_redundant(const Vertex*) const { return false; } - /*! - * Erase the given redundant vertex by merging a fictitious edge. + /*! Erase the given redundant vertex by merging a fictitious edge. * The function does not free the vertex v itself. * \param v The vertex. * \pre v is a redundant vertex. @@ -537,25 +506,19 @@ public: //@{ /*! This function is used by the "walk" point-location strategy. */ - const Face* initial_face() const - { - return (unb_face); - } + const Face* initial_face() const { return (unb_face); } /*! Get the unbounded face (const version). */ - const Face* unbounded_face() const - { return (unb_face); } + const Face* unbounded_face() const { return (unb_face); } /*! Get the unbounded face (non-const version). */ - Face* unbounded_face() - { return (unb_face); } + Face* unbounded_face() { return (unb_face); } //@} /// \name Additional predicates, specialized for this topology-traits class. //@{ - /*! - * Compare the given vertex and the given point. + /*! Compare the given vertex and the given point. * \param p The point. * \param v The vertex. * \return The result of the comparison of the x-coordinates of p and v. @@ -563,8 +526,7 @@ public: virtual Comparison_result compare_x(const Point_2& p, const Vertex* v) const { return (this->m_geom_traits->compare_x_2_object()(p, v->point())); } - /*! - * Compare the given vertex and the given point. + /*! Compare the given vertex and the given point. * \param p The point. * \param v The vertex. * \return The result of the xy-lexicographic comparison of p and v. @@ -572,8 +534,7 @@ public: virtual Comparison_result compare_xy(const Point_2& p, const Vertex* v) const { return (this->m_geom_traits->compare_xy_2_object()(p, v->point())); } - /*! - * Compare the relative y-position of the given point and the given edge + /*! Compare the relative y-position of the given point and the given edge * (which may be fictitious). * \param p The point. * \param he The edge (one of the pair of halfedges). @@ -586,7 +547,7 @@ public: //@} }; -} //namespace CGAL +} // namespace CGAL #include diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_default_overlay_traits.h b/Arrangement_on_surface_2/include/CGAL/Arr_default_overlay_traits.h index 44853c307b1..15a73425737 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_default_overlay_traits.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_default_overlay_traits.h @@ -15,7 +15,7 @@ // $URL$ // $Id$ // SPDX-License-Identifier: GPL-3.0+ -// +// // // Author(s) : Ron Wein // Baruch Zukerman @@ -25,33 +25,32 @@ #include - /*! \file + * * Definition of default overlay-traits classes. */ #include #include -#include +#include namespace CGAL { -/*! - * \class +/*! \class + * * An overlay-traits class for computing the overlay of two arrangement that * are templated with the default DCEL classes, namely they store no extra * data with their DCEL features. The resulting arrangement is also assumed * to be templated with the default DCEL. */ -template +template class Arr_default_overlay_traits : - public _Arr_default_overlay_traits_base {}; -/*! - * \class +/*! \class + * * An overlay-traits class for computing the overlay of two arrangement whose * face records are extended with auxiliary data fields, of type Data1 and * Data2, respectively. The resulting arrangement is also assumed to be @@ -61,15 +60,13 @@ class Arr_default_overlay_traits : * object of type Data1 and Data2 is computed using the functor * Overlay_face_data. */ -template +template class Arr_face_overlay_traits : - public _Arr_default_overlay_traits_base + public _Arr_default_overlay_traits_base { public: - typedef typename ArrangementA::Face_const_handle Face_handle_A; typedef typename ArrangementB::Face_const_handle Face_handle_B; typedef typename ArrangementR::Face_handle Face_handle_R; @@ -77,24 +74,19 @@ public: typedef OverlayFaceData_ Overlay_face_data; private: - Overlay_face_data overlay_face_data; public: - - /*! - * Create a face f that matches the overlapping region between f1 and f2. + /*! Create a face f that matches the overlapping region between f1 and f2. */ - virtual void create_face (Face_handle_A f1, - Face_handle_B f2, - Face_handle_R f) const + virtual void create_face(Face_handle_A f1, Face_handle_B f2, + Face_handle_R f) const { // Overlay the data objects associated with f1 and f2 and store the result // with f. f->set_data (overlay_face_data (f1->data(), f2->data())); return; } - }; } //namespace CGAL diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_overlay_2.h b/Arrangement_on_surface_2/include/CGAL/Arr_overlay_2.h index 7f93999a4f5..0758ae41dd3 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_overlay_2.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_overlay_2.h @@ -18,39 +18,43 @@ // // // Author(s) : Baruch Zukerman -// Efi Fogel +// Efi Fogel #ifndef CGAL_ARR_OVERLAY_2_H #define CGAL_ARR_OVERLAY_2_H #include - /*! \file + * * Definition of the global Arr_overlay_2() function. */ -#include - -#include -#include -#include - #include +#include #include #include #include +#include +#include +#include +#include +#include +#include +#include #include namespace CGAL { -/*! - * Compute the overlay of two input arrangements. - * \param arr1 The first arrangement. - * \param arr2 The second arrangement. - * \param arr_res Output: The resulting arrangement. - * \param ovl_tr An overlay-traits class. As arr1, arr2 and res can be +/*! Compute the overlay of two input arrangements. + * \tparam GeometryTraitsA_2 the geometry traits of the first arrangement. + * \tparam GeometryTraitsB_2 the geometry traits of the second arrangement. + * \tparam GeometryTraitsRes_2 the geometry traits of the resulting arrangement. + * \tparam TopologyTraitsA the topology traits of the first arrangement. + * \tparam TopologyTraitsB the topology traits of the second arrangement. + * \tparam TopologyTraitsRes the topology traits of the resulting arrangement. + * \tparam OverlayTraits An overlay-traits class. As arr1, arr2 and res can be * templated with different geometry-traits class and * different DCELs (encapsulated in the various topology-traits * classes). The geometry-traits of the result arrangement is @@ -60,90 +64,110 @@ namespace CGAL { * in the result geometry-traits. * The overlay-traits class defines the various * overlay operations of pairs of DCEL features from - * TopTraitsA and TopTraitsB to the resulting ResDcel. + * TopologyTraitsA and TopologyTraitsB to the resulting ResDcel. */ -template -void overlay(const Arrangement_on_surface_2& arr1, - const Arrangement_on_surface_2& arr2, - Arrangement_on_surface_2& arr_res, - OverlayTraits& ovl_tr) +template +void +overlay(const Arrangement_on_surface_2& arr1, + const Arrangement_on_surface_2& arr2, + Arrangement_on_surface_2& arr, + OverlayTraits& ovl_tr) { - typedef Arrangement_on_surface_2 ArrA; - typedef Arrangement_on_surface_2 ArrB; - typedef Arrangement_on_surface_2 ArrRes; + typedef GeometryTraitsA_2 Agt2; + typedef GeometryTraitsB_2 Bgt2; + typedef GeometryTraitsRes_2 Rgt2; + typedef TopologyTraitsA Att; + typedef TopologyTraitsB Btt; + typedef TopologyTraitsRes Rtt; + typedef OverlayTraits Overlay_traits; + + typedef Arrangement_on_surface_2 Arr_a; + typedef Arrangement_on_surface_2 Arr_b; + typedef Arrangement_on_surface_2 Arr_res; + typedef typename Arr_res::Allocator Allocator; // some type assertions (not all, but better then nothing). - CGAL_static_assertion - ((boost::is_convertible::value)); - CGAL_static_assertion - ((boost::is_convertible::value)); - CGAL_static_assertion - ((boost::is_convertible::value)); - CGAL_static_assertion - ((boost::is_convertible::value)); +#if !defined(CGAL_NO_ASSERTIONS) + typedef typename Agt2::Point_2 A_point; + typedef typename Bgt2::Point_2 B_point; + typedef typename Rgt2::Point_2 Res_point; +#endif + CGAL_static_assertion((boost::is_convertible::value)); + CGAL_static_assertion((boost::is_convertible::value)); - typedef typename TopTraitsRes::template - Sweep_line_overlay_visitor - Ovl_visitor; +#if !defined(CGAL_NO_ASSERTIONS) + typedef typename Agt2::X_monotone_curve_2 A_xcv; + typedef typename Bgt2::X_monotone_curve_2 B_xcv; + typedef typename Rgt2::X_monotone_curve_2 Res_xcv; +#endif + CGAL_static_assertion((boost::is_convertible::value)); + CGAL_static_assertion((boost::is_convertible::value)); - typedef typename Ovl_visitor::Traits_2 Ovl_traits_2; - typedef typename Ovl_traits_2::X_monotone_curve_2 Ovl_x_monotone_curve_2; - typedef typename Ovl_traits_2::Point_2 Ovl_point_2; + typedef Arr_traits_basic_adaptor_2 Gt_adaptor_2; + typedef Arr_overlay_traits_2 + Ovl_gt2; + typedef Arr_overlay_event + Ovl_event; + typedef Arr_overlay_subcurve + Ovl_curve; + typedef typename TopologyTraitsRes::template + Overlay_helper + Ovl_helper; + typedef Arr_overlay_ss_visitor + Ovl_visitor; - typedef typename Ovl_traits_2::Cell_handle_red Cell_handle_red; - typedef typename Ovl_traits_2::Optional_cell_red Optional_cell_red; - typedef typename Ovl_traits_2::Cell_handle_blue Cell_handle_blue; - typedef typename Ovl_traits_2::Optional_cell_blue Optional_cell_blue; + typedef typename Ovl_gt2::X_monotone_curve_2 Ovl_x_monotone_curve_2; + typedef typename Ovl_gt2::Point_2 Ovl_point_2; + typedef typename Ovl_gt2::Cell_handle_red Cell_handle_red; + typedef typename Ovl_gt2::Optional_cell_red Optional_cell_red; + typedef typename Ovl_gt2::Cell_handle_blue Cell_handle_blue; + typedef typename Ovl_gt2::Optional_cell_blue Optional_cell_blue; CGAL_USE_TYPE(Optional_cell_red); CGAL_USE_TYPE(Optional_cell_blue); // The result arrangement cannot be on of the input arrangements. - CGAL_precondition(((void *)(&arr_res) != (void *)(&arr1)) && - ((void *)(&arr_res) != (void *)(&arr2))); + CGAL_precondition(((void*)(&arr) != (void*)(&arr1)) && + ((void*)(&arr) != (void*)(&arr2))); // Prepare a vector of extended x-monotone curves that represent all edges // in both input arrangements. Each curve is associated with a halfedge // directed from right to left. - typename ArrA::Halfedge_const_handle invalid_he1; - typename ArrB::Halfedge_const_handle invalid_he2; + typename Arr_a::Halfedge_const_handle invalid_he1; + typename Arr_b::Halfedge_const_handle invalid_he2; std::vector xcvs_vec(arr1.number_of_edges() + arr2.number_of_edges()); unsigned int i = 0; - typename ArrA::Edge_const_iterator eit1; + typename Arr_a::Edge_const_iterator eit1; for (eit1 = arr1.edges_begin(); eit1 != arr1.edges_end(); ++eit1, ++i) { - typename ArrA::Halfedge_const_handle he1 = eit1; + typename Arr_a::Halfedge_const_handle he1 = eit1; if (he1->direction() != ARR_RIGHT_TO_LEFT) he1 = he1->twin(); xcvs_vec[i] = Ovl_x_monotone_curve_2(eit1->curve(), he1, invalid_he2); } - typename ArrB::Edge_const_iterator eit2; + typename Arr_b::Edge_const_iterator eit2; for (eit2 = arr2.edges_begin(); eit2 != arr2.edges_end(); ++eit2, ++i) { - typename ArrB::Halfedge_const_handle he2 = eit2; + typename Arr_b::Halfedge_const_handle he2 = eit2; if (he2->direction() != ARR_RIGHT_TO_LEFT) he2 = he2->twin(); xcvs_vec[i] = Ovl_x_monotone_curve_2(eit2->curve(), invalid_he1, he2); } // Obtain a extended traits-class object and define the sweep-line visitor. - const typename ArrRes::Traits_adaptor_2* traits_adaptor = - arr_res.traits_adaptor(); + const typename Arr_res::Traits_adaptor_2* traits_adaptor = + arr.traits_adaptor(); /* We would like to avoid copy construction of the geometry traits class. * Copy construction is undesired, because it may results with data * duplication or even data loss. * - * If the type Ovl_traits_2 is the same as the type + * If the type Ovl_gt2 is the same as the type * GeomTraits, use a reference to GeomTraits to avoid constructing a new one. * Otherwise, instantiate a local variable of the former and provide * the later as a single parameter to the constructor. @@ -151,15 +175,12 @@ void overlay(const Arrangement_on_surface_2& arr1, * Use the form 'A a(*b);' and not ''A a = b;' to handle the case where A has * only an implicit constructor, (which takes *b as a parameter). */ - typedef Arr_traits_basic_adaptor_2< GeomTraitsRes > Geom_traits_adaptor_2; - typename boost::mpl::if_, - const Ovl_traits_2&, Ovl_traits_2>::type + typename boost::mpl::if_, + const Ovl_gt2&, Ovl_gt2>::type ex_traits(*traits_adaptor); - Ovl_visitor visitor(&arr1, &arr2, &arr_res, &ovl_tr); - Sweep_line_2 - sweep_line(&ex_traits, &visitor); + Ovl_visitor visitor(&arr1, &arr2, &arr, &ovl_tr); + Ss2::Surface_sweep_2 surface_sweep(&ex_traits, &visitor); // In case both arrangement do not contain isolated vertices, go on and // overlay them. @@ -168,8 +189,8 @@ void overlay(const Arrangement_on_surface_2& arr1, if (total_iso_verts == 0) { // Clear the result arrangement and perform the sweep to construct it. - arr_res.clear(); - sweep_line.sweep(xcvs_vec.begin(), xcvs_vec.end()); + arr.clear(); + surface_sweep.sweep(xcvs_vec.begin(), xcvs_vec.end()); xcvs_vec.clear(); return; } @@ -179,20 +200,20 @@ void overlay(const Arrangement_on_surface_2& arr1, std::vector pts_vec(total_iso_verts); i = 0; - typename ArrA::Vertex_const_iterator vit1; + typename Arr_a::Vertex_const_iterator vit1; for (vit1 = arr1.vertices_begin(); vit1 != arr1.vertices_end(); ++vit1) { if (vit1->is_isolated()) { - typename ArrA::Vertex_const_handle v1 = vit1; + typename Arr_a::Vertex_const_handle v1 = vit1; pts_vec[i++] = Ovl_point_2(vit1->point(), boost::make_optional(Cell_handle_red(v1)), boost::optional()); } } - typename ArrB::Vertex_const_iterator vit2; + typename Arr_b::Vertex_const_iterator vit2; for (vit2 = arr2.vertices_begin(); vit2 != arr2.vertices_end(); ++vit2) { if (vit2->is_isolated()) { - typename ArrB::Vertex_const_handle v2 = vit2; + typename Arr_b::Vertex_const_handle v2 = vit2; pts_vec[i++] = Ovl_point_2(vit2->point(), boost::optional(), boost::make_optional(Cell_handle_blue(v2))); @@ -200,36 +221,43 @@ void overlay(const Arrangement_on_surface_2& arr1, } // Clear the result arrangement and perform the sweep to construct it. - arr_res.clear(); - sweep_line.sweep(xcvs_vec.begin(), xcvs_vec.end(), - pts_vec.begin(), pts_vec.end()); + arr.clear(); + surface_sweep.sweep(xcvs_vec.begin(), xcvs_vec.end(), + pts_vec.begin(), pts_vec.end()); xcvs_vec.clear(); pts_vec.clear(); } -/*! - * Compute the (simple) overlay of two input arrangements. - * \param arr1 The first arrangement. - * \param arr2 The second arrangement. - * \param arr_res Output: The resulting arrangement. +/*! Compute the (simple) overlay of two input arrangements. + * \param[in] arr1 the first arrangement. + * \param[in] arr2 the second arrangement. + * \param[out] arr the resulting arrangement. */ -template -void overlay(const Arrangement_on_surface_2& arr1, - const Arrangement_on_surface_2& arr2, - Arrangement_on_surface_2& arr_res) +template +void +overlay(const Arrangement_on_surface_2& arr1, + const Arrangement_on_surface_2& arr2, + Arrangement_on_surface_2& arr) { - typedef Arrangement_on_surface_2 ArrA; - typedef Arrangement_on_surface_2 ArrB; - typedef Arrangement_on_surface_2 ArrRes; - _Arr_default_overlay_traits_base ovl_traits; - overlay(arr1, arr2, arr_res, ovl_traits); + typedef GeometryTraitsA_2 Agt2; + typedef GeometryTraitsB_2 Bgt2; + typedef GeometryTraitsRes_2 Rgt2; + typedef TopologyTraitsA Att; + typedef TopologyTraitsB Btt; + typedef TopologyTraitsRes Rtt; + typedef Arrangement_on_surface_2 Arr_a; + typedef Arrangement_on_surface_2 Arr_b; + typedef Arrangement_on_surface_2 Arr_res; + + _Arr_default_overlay_traits_base ovl_traits; + overlay(arr1, arr2, arr, ovl_traits); } -} //namespace CGAL +} // namespace CGAL #endif diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_spherical_topology_traits_2.h b/Arrangement_on_surface_2/include/CGAL/Arr_spherical_topology_traits_2.h index 9d2bb3e0e27..98829dd0fa3 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_spherical_topology_traits_2.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_spherical_topology_traits_2.h @@ -24,8 +24,8 @@ #include - /*! \file + * * The topology traits for great spherical arcs embedded on a sphere for the * arrangement package. */ @@ -35,20 +35,10 @@ #include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include #include - #include #include #include @@ -67,41 +57,46 @@ class Arrangement_on_surface_2; /*! This class handles the topology for arrangements of great spherical * arcs on the sphere embedded on 2D parametric surdace. */ -template > +template > class Arr_spherical_topology_traits_2 { public: + typedef GeometryTraits_2 Geometry_traits_2; + typedef Dcel_ Dcel; +private: + typedef Geometry_traits_2 Gt2; + +public: ///! \name The geometry-traits types. //@{ - typedef GeomTraits_ Geometry_traits_2; - typedef typename Geometry_traits_2::Point_2 Point_2; - typedef typename Geometry_traits_2::X_monotone_curve_2 X_monotone_curve_2; + typedef typename Gt2::Point_2 Point_2; + typedef typename Gt2::X_monotone_curve_2 X_monotone_curve_2; //@} ///! \name The DCEL types. //@{ - typedef Dcel_ Dcel; - typedef typename Dcel::Size Size; - typedef typename Dcel::Vertex Vertex; - typedef typename Dcel::Halfedge Halfedge; - typedef typename Dcel::Face Face; - typedef typename Dcel::Outer_ccb Outer_ccb; - typedef typename Dcel::Inner_ccb Inner_ccb; - typedef typename Dcel::Isolated_vertex Isolated_vertex; + typedef typename Dcel::Size Size; + typedef typename Dcel::Vertex Vertex; + typedef typename Dcel::Halfedge Halfedge; + typedef typename Dcel::Face Face; + typedef typename Dcel::Outer_ccb Outer_ccb; + typedef typename Dcel::Inner_ccb Inner_ccb; + typedef typename Dcel::Isolated_vertex Isolated_vertex; //@} //! \name Arrangement types //!@{ - typedef Arr_spherical_topology_traits_2 Self; - typedef Arr_traits_basic_adaptor_2 Traits_adaptor_2; + typedef Arr_spherical_topology_traits_2 Self; + typedef Arr_traits_basic_adaptor_2 Gt_adaptor_2; //!@} ///! \name The side tags //@{ - typedef typename Traits_adaptor_2::Left_side_category Left_side_category; - typedef typename Traits_adaptor_2::Bottom_side_category Bottom_side_category; - typedef typename Traits_adaptor_2::Top_side_category Top_side_category; - typedef typename Traits_adaptor_2::Right_side_category Right_side_category; + typedef typename Gt_adaptor_2::Left_side_category Left_side_category; + typedef typename Gt_adaptor_2::Bottom_side_category Bottom_side_category; + typedef typename Gt_adaptor_2::Top_side_category Top_side_category; + typedef typename Gt_adaptor_2::Right_side_category Right_side_category; BOOST_MPL_ASSERT ( @@ -145,11 +140,11 @@ private: Vertex_key_comparer() : m_geom_traits(NULL) {} /*! Construct */ - Vertex_key_comparer(const Traits_adaptor_2* geom_traits) : + Vertex_key_comparer(const Gt_adaptor_2* geom_traits) : m_geom_traits(geom_traits) {} - const Traits_adaptor_2* m_geom_traits; + const Gt_adaptor_2* m_geom_traits; bool operator()(const Point_2& p1, const Point_2& p2) const { @@ -180,7 +175,7 @@ protected: Vertex_map m_boundary_vertices; //! The geometry-traits adaptor. - const Traits_adaptor_2* m_geom_traits; + const Gt_adaptor_2* m_geom_traits; //! Inidicates whether the traits object should evetually be freed. bool m_own_geom_traits; @@ -199,7 +194,7 @@ public: /*! Constructor from a geometry-traits object. * \param traits the traits. */ - Arr_spherical_topology_traits_2(const Geometry_traits_2* traits); + Arr_spherical_topology_traits_2(const Gt2* traits); /*! Destructor */ ~Arr_spherical_topology_traits_2(); @@ -315,158 +310,137 @@ public: private: /// \name Auxiliary type definitions. //@{ - typedef Arrangement_on_surface_2 Arr; + typedef Arrangement_on_surface_2 Arr; - // Type definition for the constuction sweep-line visitor. - typedef Arr_construction_subcurve CSubcurve; - typedef Arr_construction_event - CEvent; - typedef Arr_spherical_construction_helper CHelper; - - // Type definition for the basic insertion sweep-line visitor. - typedef Arr_basic_insertion_traits_2 BInsTraits; - typedef Arr_construction_subcurve BISubcurve; - typedef Arr_construction_event BIEvent; - typedef Arr_spherical_insertion_helper - BIHelper; - - // Type definition for the insertion sweep-line visitor. - typedef Arr_insertion_traits_2 InsTraits; - typedef Arr_construction_subcurve ISubcurve; - typedef Arr_construction_event IEvent; - typedef Arr_spherical_insertion_helper - IHelper; - - // Type definition for the batched point-location sweep-line visitor. - typedef Arr_batched_point_location_traits_2 BplTraits; - typedef Arr_spherical_batched_pl_helper BplHelper; - - // Type definition for the vertical decomposition sweep-line visitor. - typedef Arr_batched_point_location_traits_2 VdTraits; - typedef Arr_spherical_vert_decomp_helper VdHelper; - - // Type definition for the overlay sweep-line visitor. - template - struct _Overlay_helper : - public Arr_spherical_overlay_helper - , Arr>, - Arr_overlay_subcurve > +public: + // The following definitions of helper functions use a C++11 features called + // alias template. This feature can be mimiked by non C++11 support simply by + // defining a type that inherits from the template we need to alias. However, + // the non-C++11 code requires the (re)definition of all constructors of the + // derived class. The non-C++11 code follows the commented out C++11 code. + // When we move to C++11 we can use the more elgant code. +#if defined(CGAL_CFG_NO_CPP0X_TEMPLATE_ALIASES) + // Type definition for the construction surface-sweep visitor. + template + struct Construction_helper : + public Arr_spherical_construction_helper { - typedef ExGeomTraits_ Ex_geomt_raits; - typedef ArrangementA_ Arrangement_a; - typedef ArrangementB_ Arrangement_b; - - typedef Arr_overlay_subcurve Overlay_subcurve; - typedef Arr_construction_event - Construction_event; - - typedef Arr_spherical_overlay_helper - Base; - - typedef typename Base::Traits_2 Traits_2; - typedef typename Base::Arrangement_red_2 Arrangement_red_2; - typedef typename Base::Arrangement_blue_2 Arrangement_blue_2; - typedef typename Base::Arrangement_2 Arrangement_2; - typedef typename Base::Event Event; - typedef typename Base::Subcurve Subcurve; - typedef typename Base::Construction_helper Construction_helper; - - _Overlay_helper(const Arrangement_a* arr_a, const Arrangement_b* arr_b) : - Base(arr_a, arr_b) - {} + typedef Arr_spherical_construction_helper + Base; + Construction_helper(Arr* arr) : Base(arr) {} }; + + // Type definition for the no-intersection construction surface-sweep visitor. + template + struct No_intersection_construction_helper : + public Arr_spherical_construction_helper + { + typedef Arr_spherical_construction_helper + Base; + No_intersection_construction_helper(Arr* arr) : Base(arr) {} + }; + + // Type definition for the insertion surface-sweep visitor. + typedef Arr_insertion_traits_2 I_traits; + template + struct Insertion_helper : + public Arr_spherical_insertion_helper + { + typedef Arr_spherical_insertion_helper + Base; + Insertion_helper(Arr* arr) : Base(arr) {} + }; + + // Type definition for the no-intersection insertion surface-sweep visitor. + typedef Arr_basic_insertion_traits_2 Nxi_traits; + template + struct No_intersection_insertion_helper : + public Arr_spherical_insertion_helper + { + typedef Arr_spherical_insertion_helper + Base; + No_intersection_insertion_helper(Arr* arr) : Base(arr) {} + }; + + // Type definition for the batched point-location surface-sweep visitor. + typedef Arr_batched_point_location_traits_2 Bpl_traits; + template + struct Batched_point_location_helper : + public Arr_spherical_batched_pl_helper + { + typedef Arr_spherical_batched_pl_helper + Base; + Batched_point_location_helper(const Arr* arr) : Base(arr) {} + }; + + // Type definition for the vertical decomposition surface-sweep visitor. + typedef Arr_batched_point_location_traits_2 Vd_traits; + template + struct Vertical_decomposition_helper : + public Arr_spherical_vert_decomp_helper + { + typedef Arr_spherical_vert_decomp_helper + Base; + Vertical_decomposition_helper(const Arr* arr) : Base(arr) {} + }; + + // Type definition for the overlay surface-sweep visitor. + template + struct Overlay_helper : + public Arr_spherical_overlay_helper + { + typedef Arr_spherical_overlay_helper + Base; + Overlay_helper(const ArrA* arr_a, const ArrB* arr_b) : Base(arr_a, arr_b) {} + }; +#else + // Type definition for the construction surface-sweep visitor. + template + using Construction_helper = + Arr_spherical_construction_helper; + + // Type definition for the no-intersection construction surface-sweep visitor. + template + using No_intersection_construction_helper = + Arr_spherical_construction_helper; + + // Type definition for the insertion surface-sweep visitor. + typedef Arr_insertion_traits_2 I_traits; + template + using Insertion_helper = + Arr_spherical_insertion_helper; + + // Type definition for the no-intersection insertion surface-sweep visitor. + typedef Arr_basic_insertion_traits_2 Nxi_traits; + template + using No_intersection_insertion_helper = + Arr_spherical_insertion_helper; + + // Type definition for the batched point-location surface-sweep visitor. + typedef Arr_batched_point_location_traits_2 Bpl_traits; + template + using Batched_point_location_helper = + Arr_spherical_batched_pl_helper; + + // Type definition for the vertical decomposition surface-sweep visitor. + typedef Arr_batched_point_location_traits_2 Vd_traits; + template + using Vertical_decomposition_helper = + Arr_spherical_vert_decomp_helper; + + // Type definition for the overlay surface-sweep visitor. + template + using Overlay_helper = + Arr_spherical_overlay_helper; +#endif //@} public: ///! \name Visitor types. //@{ - typedef Arr_construction_sl_visitor - Sweep_line_construction_visitor; - - typedef Arr_insertion_sl_visitor - Sweep_line_insertion_visitor; - - typedef Sweep_line_construction_visitor - Sweep_line_non_intersecting_construction_visitor; - - typedef Arr_basic_insertion_sl_visitor - Sweep_line_non_intersecting_insertion_visitor; - - template - struct Sweep_line_batched_point_location_visitor : - public Arr_batched_pl_sl_visitor - { - typedef OutputIterator_ Output_iterator; - - typedef Arr_batched_pl_sl_visitor Base; - typedef typename Base::Traits_2 Traits_2; - typedef typename Base::Event Event; - typedef typename Base::Subcurve Subcurve; - - Sweep_line_batched_point_location_visitor(const Arr* arr, - Output_iterator& oi) : - Base(arr, oi) - {} - }; - - template - struct Sweep_line_vertical_decomposition_visitor : - public Arr_vert_decomp_sl_visitor - { - typedef OutputIterator_ Output_iterator; - typedef Arr_vert_decomp_sl_visitor Base; - - typedef typename Base::Traits_2 Traits_2; - typedef typename Base::Event Event; - typedef typename Base::Subcurve Subcurve; - - Sweep_line_vertical_decomposition_visitor(const Arr* arr, - Output_iterator* oi) : - Base(arr, oi) - {} - }; - - template - struct Sweep_line_overlay_visitor : - public Arr_overlay_sl_visitor - <_Overlay_helper, - ArrangementA_, ArrangementB_>, OverlayTraits_> - { - typedef ArrangementA_ Arrangement_a; - typedef ArrangementB_ Arrangement_b; - typedef Arr Arrangement_result_2; - typedef OverlayTraits_ Overlay_traits; - - typedef Arr_overlay_traits_2 Geom_ovl_traits_2; - - typedef _Overlay_helper - Ovl_helper; - - typedef Arr_overlay_sl_visitor Base; - - typedef typename Base::Traits_2 Traits_2; - typedef typename Base::Event Event; - typedef typename Base::Subcurve Subcurve; - - Sweep_line_overlay_visitor(const Arrangement_a* arr_a, - const Arrangement_b* arr_b, - Arrangement_result_2* arr_res, - Overlay_traits* overlay_tr) : - Base(arr_a, arr_b, arr_res, overlay_tr) - {} - }; - typedef Arr_inc_insertion_zone_visitor Zone_insertion_visitor; typedef Arr_naive_point_location Default_point_location_strategy; @@ -505,8 +479,7 @@ public: bool& swap_predecessors) const; - /*! - * Given signs of two ccbs that show up when splitting upon insertion of + /*! Given signs of two ccbs that show up when splitting upon insertion of * curve into two, determine what happens to the face(s). * \param signs1 signs in x and y of the first implied ccb * \param signs2 signs in x and y of the secondd implied ccb @@ -573,8 +546,7 @@ public: Arr_parameter_space ps_x, Arr_parameter_space ps_y); - /*! - * Locate the predecessor halfedge for the given curve around a given + /*! Locate the predecessor halfedge for the given curve around a given * vertex with boundary conditions. * \param v The vertex. * \param cv The x-monotone curve. @@ -692,7 +664,7 @@ protected: //@} }; -} //namespace CGAL +} // namespace CGAL #include diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_bounded_planar_batched_pl_helper.h b/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_bounded_planar_batched_pl_helper.h index 34392fb9e39..e7ef681aa91 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_bounded_planar_batched_pl_helper.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_bounded_planar_batched_pl_helper.h @@ -15,89 +15,80 @@ // $URL$ // $Id$ // SPDX-License-Identifier: GPL-3.0+ -// +// // // Author(s) : Baruch Zukerman // Ron Wein +// Efi Fogel #ifndef CGAL_ARR_BOUNDED_PLANAR_BATCHED_PL_HELPER_H #define CGAL_ARR_BOUNDED_PLANAR_BATCHED_PL_HELPER_H #include - -/*! +/*! \file + * * Definition of the Arr_bounded_planar_batched_pl_helper class-template. */ namespace CGAL { -#include - /*! \class Arr_bounded_planar_batched_pl_helper - * A helper class for the batched point-location sweep-line visitor, suitable + * + * A helper class for the batched point-location surface-sweep visitor, suitable * for an Arrangement_on_surface_2 instantiated with a topology-traits class * for bounded curves in the plane. */ -template -class Arr_bounded_planar_batched_pl_helper -{ +template +class Arr_bounded_planar_batched_pl_helper { public: + typedef GeometryTraits_2 Geometry_traits_2; + typedef Arrangement_ Arrangement_2; + typedef Event_ Event; + typedef Subcurve_ Subcurve; + typedef typename Subcurve::Allocator Allocator; - typedef Traits_ Traits_2; - typedef Arrangement_ Arrangement_2; +private: + typedef Geometry_traits_2 Gt2; + typedef typename Arrangement_2::Face_const_handle Face_const_handle; - typedef typename Arrangement_2::Face_const_handle Face_const_handle; - - typedef Sweep_line_empty_visitor Base_visitor; - typedef typename Base_visitor::Event Event; - typedef typename Base_visitor::Subcurve Subcurve; +public: + typedef typename Arrangement_2::Topology_traits Topology_traits; protected: - - typedef typename Arrangement_2::Topology_traits Topology_traits; - // Data members: - const Topology_traits *m_top_traits; // The topology-traits class. - Face_const_handle m_unb_face; // The unbounded arrangement face. + const Topology_traits* m_top_traits; // The topology-traits class. + Face_const_handle m_unb_face; // The unbounded arrangement face. public: - - /*! - * Constructor. + /*! Constructor. * \param arr The arrangement. */ - Arr_bounded_planar_batched_pl_helper (const Arrangement_2 *arr) : - m_top_traits (arr->topology_traits()) + Arr_bounded_planar_batched_pl_helper(const Arrangement_2* arr) : + m_top_traits(arr->topology_traits()) {} /// \name Notification functions. //@{ /* A notification issued before the sweep process starts. */ - void before_sweep () + void before_sweep() { // Get the unbounded face. - m_unb_face = Face_const_handle (m_top_traits->unbounded_face()); + m_unb_face = Face_const_handle(m_top_traits->unbounded_face()); } - /*! - * A notification invoked after the sweep-line finishes handling the given + /*! A notification invoked after the sweep-line finishes handling the given * event. */ - void after_handle_event (Event* /* event */) - { - return; - } + void after_handle_event(Event* /* event */) { return; } //@} /*! Get the current top face. */ - Face_const_handle top_face () const - { - return (m_unb_face); - } + Face_const_handle top_face() const { return (m_unb_face); } }; -} //namespace CGAL +} // namespace CGAL #endif diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_bounded_planar_construction_helper.h b/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_bounded_planar_construction_helper.h index 7424a1e2b2a..b598d5183c6 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_bounded_planar_construction_helper.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_bounded_planar_construction_helper.h @@ -15,70 +15,88 @@ // $URL$ // $Id$ // SPDX-License-Identifier: GPL-3.0+ -// +// // // Author(s) : Baruch Zukerman // Ron Wein +// Efi Fogel #ifndef CGAL_ARR_BOUNDED_PLANAR_CONSTRUCTION_HELPER_H #define CGAL_ARR_BOUNDED_PLANAR_CONSTRUCTION_HELPER_H #include - -/*! +/*! \file + * * Definition of the Arr_bounded_planar_construction_helper class-template. */ -#include #include namespace CGAL { /*! \class Arr_bounded_planar_construction_helper + * * A helper class for the construction sweep-line visitor, suitable * for an Arrangement_on_surface_2 instantiated with a topology-traits class * for bounded curves in the plane. */ -template -class Arr_bounded_planar_construction_helper -{ +template +class Arr_bounded_planar_construction_helper { public: + typedef GeometryTraits_2 Geometry_traits_2; + typedef Arrangement_ Arrangement_2; + typedef Event_ Event; + typedef Subcurve_ Subcurve; + typedef typename Subcurve::Allocator Allocator; - typedef Traits_ Traits_2; - typedef Arrangement_ Arrangement_2; - typedef Event_ Event; - typedef Subcurve_ Subcurve; + // The following should be private. It is declared 'protected' as a + // workaround to a problem with VC. (At least VC 14 exhibits this problem). + // When declared private, VC claims that Gt2 is private (within + // Arr_bounded_planar_construction_helper); thus, it cannot be access by + // Arr_bounded_planar_construction_helper. +protected: + typedef Geometry_traits_2 Gt2; - typedef typename Traits_2::X_monotone_curve_2 X_monotone_curve_2; - typedef typename Traits_2::Point_2 Point_2; +public: + typedef typename Gt2::X_monotone_curve_2 X_monotone_curve_2; + typedef typename Gt2::Point_2 Point_2; - typedef Sweep_line_empty_visitor Base_visitor; + typedef typename Arrangement_2::Face_handle Face_handle; + typedef typename Arrangement_2::Halfedge_handle Halfedge_handle; - typedef typename Arrangement_2::Face_handle Face_handle; - typedef typename Arrangement_2::Halfedge_handle Halfedge_handle; - - typedef typename Subcurve::Halfedge_indices_list Indices_list; - typedef Unique_hash_map Halfedge_indices_map; + typedef typename Subcurve::Halfedge_indices_list Indices_list; + typedef Unique_hash_map + Halfedge_indices_map; + + /*! \struct rebind + * An auxiliary structure for rebinding the helper with a new types. + * Mainly used to rebind the geometry-traits type and a new type that derives + * from the old one. + */ + template + struct rebind { + typedef Arr_bounded_planar_construction_helper + other; + }; protected: - - typedef typename Arrangement_2::Topology_traits Topology_traits; + typedef typename Arrangement_2::Topology_traits Topology_traits; // Data members: - Topology_traits *m_top_traits; // The topology-traits class. - Face_handle m_unb_face; // The unbounded arrangement face. + Topology_traits* m_top_traits; // The topology-traits class. + Face_handle m_unb_face; // The unbounded arrangement face. Indices_list m_emptylist; public: - /*! Constructor. */ - Arr_bounded_planar_construction_helper (Arrangement_2 *arr) : - m_top_traits (arr->topology_traits()) + Arr_bounded_planar_construction_helper(Arrangement_2* arr) : + m_top_traits(arr->topology_traits()) {} /*! Destructor. */ @@ -89,71 +107,50 @@ public: //@{ /* A notification issued before the sweep process starts. */ - virtual void before_sweep () + virtual void before_sweep() { // Get the unbounded face. - m_unb_face = Face_handle (m_top_traits->unbounded_face()); + m_unb_face = Face_handle(m_top_traits->unbounded_face()); } - /*! - * A notification invoked before the sweep-line starts handling the given + /*! A notification invoked before the sweep-line starts handling the given * event. */ - virtual void before_handle_event (Event* /* event */) - { - return; - } + virtual void before_handle_event(Event* /* event */) { return; } /*! A notification invoked when a new subcurve is created. */ - virtual void add_subcurve (Halfedge_handle /* he */, Subcurve* /* sc */) - { - return; - } + virtual void add_subcurve(Halfedge_handle /* he */, Subcurve* /* sc */) + { return; } - Indices_list& halfedge_indices_list() { - return m_emptylist; - } + Indices_list& halfedge_indices_list() { return m_emptylist; } /*! Collect a subcurve index that does not see any status-line from below. */ - void add_subcurve_in_top_face (unsigned int /* index */) - { - return; - } + void add_subcurve_in_top_face(unsigned int /* index */) { return; } /*! A notification invoked before the given event it deallocated. */ - void before_deallocate_event (Event* /* event */) - { - return; - } - //@} - - /*! - * Set the map that maps each halfedge to the list of subcurve indices + void before_deallocate_event(Event* /* event */) { return; } + //@} + + /*! Set the map that maps each halfedge to the list of subcurve indices * that "see" the halfedge from below. */ - void set_halfedge_indices_map (Halfedge_indices_map& /* table */) - { - return; - } + void set_halfedge_indices_map(Halfedge_indices_map& /* table */) + { return; } - /*! - * Determine if we should swap the order of predecessor halfedges when + /*! Determine if we should swap the order of predecessor halfedges when * calling insert_at_vertices_ex() . */ - bool swap_predecessors (Event* /* event */) const + bool swap_predecessors(Event* /* event */) const { // In the bounded case the order of the predecessor is always correct // and there is no need to swap them. - return (false); + return false; } /*! Get the current top face. */ - Face_handle top_face () const - { - return (m_unb_face); - } + Face_handle top_face() const { return m_unb_face; } }; -} //namespace CGAL +} // namespace CGAL #endif diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_bounded_planar_insertion_helper.h b/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_bounded_planar_insertion_helper.h index dbaabf9c35d..1c641e0ad15 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_bounded_planar_insertion_helper.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_bounded_planar_insertion_helper.h @@ -15,75 +15,68 @@ // $URL$ // $Id$ // SPDX-License-Identifier: GPL-3.0+ -// +// // // Author(s) : Baruch Zukerman // Ron Wein +// Efi Fogel #ifndef CGAL_ARR_BOUNDED_PLANAR_INSERTION_HELPER_H #define CGAL_ARR_BOUNDED_PLANAR_INSERTION_HELPER_H #include - -/*! +/*! \file + * * Definition of the Arr_bounded_planar_insertion_helper class-template. */ -#include #include namespace CGAL { /*! \class Arr_bounded_planar_insertion_helper + * * A helper class for the insertion sweep-line visitors, suitable * for an Arrangement_on_surface_2 instantiated with a topology-traits class * for bounded curves in the plane. */ -template +template class Arr_bounded_planar_insertion_helper : - public Arr_bounded_planar_construction_helper { public: + typedef GeometryTraits_2 Geometry_traits_2; + typedef Arrangement_ Arrangement_2; + typedef Event_ Event; + typedef Subcurve_ Subcurve; - typedef Traits_ Traits_2; - typedef Arrangement_ Arrangement_2; - typedef Event_ Event; - typedef Subcurve_ Subcurve; - - typedef typename Traits_2::X_monotone_curve_2 X_monotone_curve_2; - typedef typename Traits_2::Point_2 Point_2; - - typedef Arr_bounded_planar_construction_helper Base; - - typedef Sweep_line_empty_visitor Base_visitor; - - typedef Arr_bounded_planar_insertion_helper Self; - - typedef Arr_construction_sl_visitor Parent_visitor; - - typedef typename Arrangement_2::Face_handle Face_handle; - - typedef typename Base::Indices_list Indices_list; - typedef typename Base::Halfedge_indices_map Halfedge_indices_map; +private: + typedef Geometry_traits_2 Gt2; + typedef Arr_bounded_planar_insertion_helper Self; + typedef Arr_bounded_planar_construction_helper + Base; + +public: + typedef typename Gt2::X_monotone_curve_2 X_monotone_curve_2; + typedef typename Gt2::Point_2 Point_2; + + typedef typename Arrangement_2::Face_handle Face_handle; + + typedef typename Base::Indices_list Indices_list; + typedef typename Base::Halfedge_indices_map Halfedge_indices_map; public: - /*! Constructor. */ - Arr_bounded_planar_insertion_helper (Arrangement_2 *arr) : - Base (arr) + Arr_bounded_planar_insertion_helper(Arrangement_2* arr) : + Base(arr) {} }; -} //namespace CGAL +} // namespace CGAL #endif diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_bounded_planar_overlay_helper.h b/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_bounded_planar_overlay_helper.h index 911fd1ab6fc..38ba275bc53 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_bounded_planar_overlay_helper.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_bounded_planar_overlay_helper.h @@ -15,18 +15,19 @@ // $URL$ // $Id$ // SPDX-License-Identifier: GPL-3.0+ -// +// // // Author(s) : Baruch Zukerman // Ron Wein +// Efi Fogel #ifndef CGAL_ARR_BOUNDED_PLANAR_OVERLAY_HELPER_H #define CGAL_ARR_BOUNDED_PLANAR_OVERLAY_HELPER_H #include - -/*! +/*! \file + * * Definition of the Arr_bounded_planar_overlay_helper class-template. */ @@ -35,55 +36,56 @@ namespace CGAL { /*! \class Arr_bounded_planar_overlay_helper + * * A helper class for the overlay sweep-line visitor, suitable for the overlay * of Arrangement_on_surface_2 objects instantiated with a topology-traits * class for bounded curves in the plane. */ -template -class Arr_bounded_planar_overlay_helper -{ +template +class Arr_bounded_planar_overlay_helper { public: + typedef GeometryTraits_2 Geometry_traits_2; + typedef ArrangementRed_2 Arrangement_red_2; + typedef ArrangementBlue_2 Arrangement_blue_2; + typedef Arrangement_ Arrangement_2; + typedef Event_ Event; + typedef Subcurve_ Subcurve; - typedef Traits_ Traits_2; - typedef Arrangement_ Arrangement_2; - typedef Event_ Event; - typedef Subcurve_ Subcurve; +private: + typedef Geometry_traits_2 Gt2; + typedef Arrangement_red_2 Ar2; + typedef Arrangement_blue_2 Ab2; - typedef typename Traits_2::X_monotone_curve_2 X_monotone_curve_2; - typedef typename Traits_2::Point_2 Point_2; +public: + typedef typename Gt2::X_monotone_curve_2 X_monotone_curve_2; + typedef typename Gt2::Point_2 Point_2; // The input arrangements (the "red" and the "blue" one): - typedef ArrangementRed_ Arrangement_red_2; - typedef typename Arrangement_red_2::Face_const_handle Face_handle_red; + typedef typename Ar2::Face_const_handle Face_handle_red; - typedef ArrangementBlue_ Arrangement_blue_2; - typedef typename Arrangement_blue_2::Face_const_handle Face_handle_blue; + typedef typename Ab2::Face_const_handle Face_handle_blue; // Define the helper class for the construction visitor. - typedef Arr_bounded_planar_construction_helper Construction_helper; + typedef Arr_bounded_planar_construction_helper + Construction_helper; protected: - // Data members: - const typename Arrangement_red_2::Topology_traits *m_red_top_traits; - const typename Arrangement_blue_2::Topology_traits *m_blue_top_traits; + const typename Ar2::Topology_traits* m_red_top_traits; + const typename Ab2::Topology_traits* m_blue_top_traits; - Face_handle_red m_red_ubf; // Red unbounded face. - Face_handle_blue m_blue_ubf; // Blue unbounded face. + Face_handle_red m_red_ubf; // Red unbounded face. + Face_handle_blue m_blue_ubf; // Blue unbounded face. public: - /*! Constructor, given the input red and blue arrangements. */ - Arr_bounded_planar_overlay_helper (const Arrangement_red_2 *red_arr, - const Arrangement_blue_2 *blue_arr) : + Arr_bounded_planar_overlay_helper(const Ar2* red_arr, const Ab2* blue_arr) : m_red_top_traits (red_arr->topology_traits()), m_blue_top_traits (blue_arr->topology_traits()) {} @@ -92,37 +94,26 @@ public: //@{ /* A notification issued before the sweep process starts. */ - void before_sweep () + void before_sweep() { // Get the unbounded faces in both arrangements. m_red_ubf = Face_handle_red (m_red_top_traits->unbounded_face()); m_blue_ubf = Face_handle_blue (m_blue_top_traits->unbounded_face()); - return; } - /*! - * A notification invoked before the sweep-line starts handling the given + /*! A notification invoked before the sweep-line starts handling the given * event. - */ - void before_handle_event (Event* /* e */) - { - return; - } + */ + void before_handle_event(Event* /* e */) {} //@} - /*! Get the current red top face. */ - Face_handle_red red_top_face () const - { - return (m_red_ubf); - } + /*! Obtain the current red top face. */ + Face_handle_red red_top_face() const { return m_red_ubf; } - /*! Get the current blue top face. */ - Face_handle_blue blue_top_face () const - { - return (m_blue_ubf); - } + /*! Obtain the current blue top face. */ + Face_handle_blue blue_top_face() const { return m_blue_ubf; } }; -} //namespace CGAL +} // namespace CGAL #endif diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_bounded_planar_topology_traits_2_impl.h b/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_bounded_planar_topology_traits_2_impl.h index 79cecac826a..3e8444062e9 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_bounded_planar_topology_traits_2_impl.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_bounded_planar_topology_traits_2_impl.h @@ -25,8 +25,8 @@ #include - /*! \file + * * Member-function definitions for the * Arr_bounded_planar_topology_traits_2 class. */ @@ -36,8 +36,8 @@ namespace CGAL { //----------------------------------------------------------------------------- // Assign the contents of another topology-traits class. // -template -void Arr_bounded_planar_topology_traits_2:: +template +void Arr_bounded_planar_topology_traits_2:: assign(const Self& other) { // Assign the base class. @@ -50,8 +50,8 @@ assign(const Self& other) //----------------------------------------------------------------------------- // Initialize an empty DCEL structure. // -template -void Arr_bounded_planar_topology_traits_2::init_dcel() +template +void Arr_bounded_planar_topology_traits_2::init_dcel() { // Clear the current DCEL. this->m_dcel.delete_all(); @@ -66,8 +66,9 @@ void Arr_bounded_planar_topology_traits_2::init_dcel() //----------------------------------------------------------------------------- // Make the necessary updates after the DCEL structure have been updated. // -template -void Arr_bounded_planar_topology_traits_2::dcel_updated() +template +void Arr_bounded_planar_topology_traits_2:: +dcel_updated() { // Go over the DCEL faces and locate the unbounded face. unb_face = NULL; @@ -81,6 +82,6 @@ void Arr_bounded_planar_topology_traits_2::dcel_updated() CGAL_assertion(unb_face != NULL); } -} //namespace CGAL +} // namespace CGAL #endif diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_bounded_planar_vert_decomp_helper.h b/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_bounded_planar_vert_decomp_helper.h index 2d02f8559c1..1d333d976df 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_bounded_planar_vert_decomp_helper.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_bounded_planar_vert_decomp_helper.h @@ -15,97 +15,82 @@ // $URL$ // $Id$ // SPDX-License-Identifier: GPL-3.0+ -// +// // // Author(s) : Ron Wein +// Efi Fogel #ifndef CGAL_ARR_BOUNDED_PLANAR_VERT_DEOCMP_HELPER_H #define CGAL_ARR_BOUNDED_PLANAR_VERT_DEOCMP_HELPER_H #include - /*! \file + * * Definition of the Arr_bounded_planar_vert_decomp_helper class-template. */ namespace CGAL { -#include - /*! \class Arr_bounded_planar_vert_decomp_helper + * * A helper class for the vertical decomposition sweep-line visitor, suitable * for an Arrangement_on_surface_2 instantiated with a topology-traits class * for bounded curves in the plane. */ -template -class Arr_bounded_planar_vert_decomp_helper -{ +template +class Arr_bounded_planar_vert_decomp_helper { public: + typedef GeometryTraits_2 Geometry_traits_2; + typedef Arrangement_ Arrangement_2; + typedef Event_ Event; + typedef Subcurve_ Subcurve; + typedef typename Subcurve::Allocator Allocator; - typedef Traits_ Traits_2; - typedef Arrangement_ Arrangement_2; +private: + typedef Geometry_traits_2 Gt2; - typedef typename Arrangement_2::Face_const_handle Face_const_handle; - - typedef Sweep_line_empty_visitor Base_visitor; - typedef typename Base_visitor::Event Event; - typedef typename Base_visitor::Subcurve Subcurve; +public: + typedef typename Arrangement_2::Face_const_handle Face_const_handle; + typedef typename Arrangement_2::Topology_traits Topology_traits; protected: - - typedef typename Arrangement_2::Topology_traits Topology_traits; - // Data members: - const Topology_traits *m_top_traits; // The topology-traits class. - Face_const_handle m_unb_face; // The unbounded arrangement face. + const Topology_traits* m_top_traits; // The topology-traits class. + Face_const_handle m_unb_face; // The unbounded arrangement face. public: - - /*! - * Constructor. + /*! Constructor. * \param arr The arrangement. */ - Arr_bounded_planar_vert_decomp_helper (const Arrangement_2 *arr) : - m_top_traits (arr->topology_traits()) + Arr_bounded_planar_vert_decomp_helper(const Arrangement_2* arr) : + m_top_traits(arr->topology_traits()) {} /// \name Notification functions. //@{ - /* A notification issued before the sweep process starts. */ - void before_sweep () + /*! A notification issued before the sweep process starts. */ + void before_sweep() { // Get the unbounded face. - m_unb_face = Face_const_handle (m_top_traits->unbounded_face()); + m_unb_face = Face_const_handle(m_top_traits->unbounded_face()); } - /*! - * A notification invoked after the sweep-line finishes handling the given + /*! A notification invoked after the sweep-line finishes handling the given * event. */ - void after_handle_event (Event* /* event */) - { - return; - } + void after_handle_event(Event* /* event */) { return; } //@} /*! Get the current top object. */ - CGAL::Object top_object () const - { - // Wrap the unbounded face by a CGAL object. - return (CGAL::make_object (m_unb_face)); - } + CGAL::Object top_object() const { return CGAL::make_object(m_unb_face); } /*! Get the current bottom object. */ - CGAL::Object bottom_object () const - { - // Wrap the unbounded face by a CGAL object. - return (CGAL::make_object (m_unb_face)); - } - + CGAL::Object bottom_object() const { return CGAL::make_object(m_unb_face); } }; -} //namespace CGAL +} // namespace CGAL #endif diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_planar_topology_traits_base_2.h b/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_planar_topology_traits_base_2.h index a6db6cd9ff6..59e3db12daa 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_planar_topology_traits_base_2.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_planar_topology_traits_base_2.h @@ -25,8 +25,8 @@ #include - /*! \file + * * Definition of the Arr_planar_topology_traits_base_2 class. */ @@ -34,23 +34,15 @@ #include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include #include namespace CGAL { /*! \class Arr_planar_topology_traits_base_2 + * * A base topology-traits class that encapsulates the embedding of 2D * arrangements of bounded or unbounded curves on the plane. */ @@ -134,8 +126,7 @@ public: /*! Get the DCEL (non-const version). */ Dcel& dcel() { return (m_dcel); } - /*! - * Receive a notification on the creation of a new boundary vertex that + /*! Receive a notification on the creation of a new boundary vertex that * corresponds to the given curve end. * \param v The new boundary vertex. * \param cv The x-monotone curve. @@ -173,8 +164,7 @@ public: } - /*! - * Given signs of two ccbs that show up when splitting upon insertion of + /*! Given signs of two ccbs that show up when splitting upon insertion of * curve into two, determine what happens to the face(s). * \param signs1 signs in x and y of the first implied ccb * \param signs2 signs in x and y of the secondd implied ccb @@ -190,11 +180,10 @@ public: { // In case of a planar topology, connecting two vertices on the same // inner CCB closes a new face that becomes a hole in the original face: - return (std::make_pair(true, true)); + return std::make_pair(true, true); } - /*! - * Determine whether the given point lies in the interior of the given face. + /*! Determine whether the given point lies in the interior of the given face. * \param f The face. * \param p The query point. * \param v The vertex associated with p (if exists). @@ -214,8 +203,7 @@ public: /// \name Additional predicates, specialized for this topology-traits class. //@{ - /*! - * Compare the given vertex (which may lie at infinity) and the given point. + /*! Compare the given vertex (which may lie at infinity) and the given point. * \param p The point. * \param v The vertex. * \return The result of the comparison of the x-coordinates of p and v. @@ -223,17 +211,15 @@ public: virtual Comparison_result compare_x(const Point_2& p, const Vertex* v) const = 0; - /*! - * Compare the given vertex (which may lie at infinity) and the given point. + /*! Compare the given vertex (which may lie at infinity) and the given point. * \param p The point. * \param v The vertex. * \return The result of the xy-lexicographic comparison of p and v. */ - virtual Comparison_result compare_xy (const Point_2& p, - const Vertex* v) const = 0; + virtual Comparison_result compare_xy(const Point_2& p, + const Vertex* v) const = 0; - /*! - * Compare the relative y-position of the given point and the given edge + /*! Compare the relative y-position of the given point and the given edge * (which may be fictitious). * \param p The point. * \param he The edge (one of the pair of halfedges). @@ -379,6 +365,6 @@ is_in_face(const Face* f, const Point_2& p, const Vertex* v) const return ((n_ray_intersections % 2) != 0); } -} //namespace CGAL +} // namespace CGAL #endif diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_spherical_batched_pl_helper.h b/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_spherical_batched_pl_helper.h index 1e7c9e4ac74..be77d549876 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_spherical_batched_pl_helper.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_spherical_batched_pl_helper.h @@ -19,45 +19,44 @@ // Author(s) : Baruch Zukerman // Ron Wein // Efi Fogel -// #ifndef CGAL_ARR_SPHERICAL_BATCHED_PL_HELPER_H #define CGAL_ARR_SPHERICAL_BATCHED_PL_HELPER_H #include - /*! \file + * * Definition of the Arr_spherical_batched_pl_helper class-template. */ namespace CGAL { -#include - /*! \class Arr_spherical_batched_pl_helper + * * A helper class for the batched point-location sweep-line visitor, suitable * for an Arrangement_on_surface_2 instantiated with a topology-traits class * for bounded curves in the plane. */ -template -class Arr_spherical_batched_pl_helper -{ +template +class Arr_spherical_batched_pl_helper { public: + typedef GeometryTraits_2 Geometry_traits_2; + typedef Arrangement_ Arrangement_2; + typedef Event_ Event; + typedef Subcurve_ Subcurve; + typedef typename Subcurve::Allocator Allocator; - typedef Traits_ Traits_2; - typedef Arrangement_ Arrangement_2; +private: + typedef Geometry_traits_2 Gt2; - typedef typename Arrangement_2::Face_const_handle Face_const_handle; - - typedef Sweep_line_empty_visitor Base_visitor; - typedef typename Base_visitor::Event Event; - typedef typename Base_visitor::Subcurve Subcurve; - typedef typename Event::Subcurve_iterator Subcurve_iterator; +public: + typedef typename Arrangement_2::Face_const_handle Face_const_handle; + typedef typename Event::Subcurve_iterator Subcurve_iterator; protected: - - typedef typename Arrangement_2::Topology_traits Topology_traits; + typedef typename Arrangement_2::Topology_traits Topology_traits; // Data members: //! The topology-traits class. @@ -84,8 +83,8 @@ public: /*! A notification invoked after the sweep-line finishes handling the given * event. */ - void after_handle_event(Event* event) { - + void after_handle_event(Event* event) + { if (event->parameter_space_in_y() == ARR_TOP_BOUNDARY) { Arr_curve_end ind = ((event->number_of_left_curves() == 0) && (event->number_of_right_curves() != 0)) ? @@ -94,7 +93,8 @@ public: if (ind == ARR_MIN_END) { it = nit = event->right_curves_begin(); it_end = event->right_curves_end(); - } else { + } + else { it = nit = event->left_curves_begin(); it_end = event->left_curves_end(); } @@ -126,12 +126,10 @@ public: } const Subcurve* sc = *it; // pick the one facing the top right corner now - CGAL_assertion(sc->last_curve().halfedge_handle()->direction() == ARR_LEFT_TO_RIGHT); + CGAL_assertion(sc->last_curve().halfedge_handle()->direction() == + ARR_LEFT_TO_RIGHT); m_spherical_face = sc->last_curve().halfedge_handle()->face(); } - - - return; } //@} @@ -139,6 +137,6 @@ public: Face_const_handle top_face() const { return m_spherical_face; } }; -} //namespace CGAL +} // namespace CGAL #endif 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 50c8e814212..edab3a79727 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 @@ -25,48 +25,71 @@ #include - /*! \file + * * Definition of the Arr_spherical_construction_helper class-template. */ -#include +#include #include namespace CGAL { /*! \class Arr_spherical_construction_helper + * * A helper class for the construction sweep-line visitor, suitable * for an Arrangement_on_surface_2 instantiated with a topology-traits class * for bounded curves in the plane. */ -template class Arr_spherical_construction_helper { public: - typedef Traits_ Traits_2; - typedef Arrangement_ Arrangement_2; - typedef Event_ Event; - typedef Subcurve_ Subcurve; - - typedef typename Traits_2::X_monotone_curve_2 X_monotone_curve_2; - typedef typename Traits_2::Point_2 Point_2; - - typedef Sweep_line_empty_visitor - Base_visitor; - - typedef typename Arrangement_2::Vertex_handle Vertex_handle; - typedef typename Arrangement_2::Halfedge_handle Halfedge_handle; - typedef typename Arrangement_2::Face_handle Face_handle; - - typedef typename Subcurve::Halfedge_indices_list Indices_list; - typedef Unique_hash_map Halfedge_indices_map; + typedef GeometryTraits_2 Geometry_traits_2; + typedef Arrangement_ Arrangement_2; + typedef Event_ Event; + typedef Subcurve_ Subcurve; + typedef typename Subcurve::Allocator Allocator; protected: - typedef typename Arrangement_2::Topology_traits Topology_traits; + typedef Geometry_traits_2 Gt2; - typedef typename Topology_traits::Vertex DVertex; - typedef typename Topology_traits::Halfedge DHalfedge; +public: + typedef typename Gt2::X_monotone_curve_2 X_monotone_curve_2; + typedef typename Gt2::Point_2 Point_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; + + typedef typename Subcurve::Halfedge_indices_list Indices_list; + typedef Unique_hash_map + Halfedge_indices_map; + + /*! \struct rebind + * An auxiliary structure for rebinding the helper with a new types. + * Mainly used to rebind the geometry-traits type and a new type that derives + * from the old one. + */ + template + struct rebind { + typedef Arr_spherical_construction_helper + other; + }; + + // The following should be private. It is declared 'protected' as a + // workaround to a problem with VC. (At least VC 14 exhibits this problem). + // When declared private, VC claims that Gt2 is private (within + // Arr_spherical_construction_helper); thus, it cannot be access by + // Arr_spherical_construction_helper. +protected: + typedef typename Arrangement_2::Topology_traits Topology_traits; + + typedef typename Topology_traits::Vertex DVertex; + typedef typename Topology_traits::Halfedge DHalfedge; // Data members: @@ -265,6 +288,6 @@ before_handle_event(Event* event) } } -} //namespace CGAL +} // namespace CGAL #endif diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_spherical_insertion_helper.h b/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_spherical_insertion_helper.h index dc9d4437bd6..f8f1678fa86 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_spherical_insertion_helper.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_spherical_insertion_helper.h @@ -25,46 +25,43 @@ #include - /*! \file + * * Definition of the Arr_spherical_insertion_helper class-template. */ -#include #include namespace CGAL { /*! \class Arr_spherical_insertion_helper + * * A helper class for the insertion sweep-line visitors, suitable * for an Arrangement_on_surface_2 instantiated with a topology-traits class * for bounded curves in the plane. */ -template class Arr_spherical_insertion_helper : - public Arr_spherical_construction_helper { public: - typedef Traits_ Traits_2; + typedef GeometryTraits_2 Geometry_traits_2; typedef Arrangement_ Arrangement_2; typedef Event_ Event; typedef Subcurve_ Subcurve; - typedef typename Traits_2::X_monotone_curve_2 X_monotone_curve_2; - typedef typename Traits_2::Point_2 Point_2; +private: + typedef Geometry_traits_2 Gt2; + typedef Arr_spherical_insertion_helper + Self; + typedef Arr_spherical_construction_helper + Base; - typedef Arr_spherical_construction_helper Base; - - typedef Sweep_line_empty_visitor - Base_visitor; - - typedef Arr_spherical_insertion_helper Self; - - typedef Arr_construction_sl_visitor Parent_visitor; +public: + typedef typename Gt2::X_monotone_curve_2 X_monotone_curve_2; + typedef typename Gt2::Point_2 Point_2; typedef typename Arrangement_2::Vertex_handle Vertex_handle; typedef typename Arrangement_2::Face_handle Face_handle; @@ -231,6 +228,6 @@ Arr_spherical_insertion_helper::top_face() const return this->m_spherical_face; } -} //namespace CGAL +} // namespace CGAL #endif diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_spherical_overlay_helper.h b/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_spherical_overlay_helper.h index 655b99b9255..0dbfbfd4fcf 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_spherical_overlay_helper.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_spherical_overlay_helper.h @@ -15,7 +15,7 @@ // $URL$ // $Id$ // SPDX-License-Identifier: GPL-3.0+ -// +// // // Author(s) : Baruch Zukerman // Ron Wein @@ -26,8 +26,8 @@ #include - /*! \file + * * Definition of the Arr_spherical_overlay_helper class-template. */ @@ -36,41 +36,47 @@ namespace CGAL { /*! \class Arr_spherical_overlay_helper + * * A helper class for the overlay sweep-line visitor, suitable for the overlay * of Arrangement_on_surface_2 objects instantiated with a topology-traits * class for bounded curves in the plane. */ -template -class Arr_spherical_overlay_helper -{ +template +class Arr_spherical_overlay_helper { public: - typedef Traits_ Traits_2; - typedef Arrangement_ Arrangement_2; - typedef Event_ Event; - typedef Subcurve_ Subcurve; + typedef GeometryTraits_2 Geometry_traits_2; + typedef ArrangementRed_2 Arrangement_red_2; + typedef ArrangementBlue_2 Arrangement_blue_2; + typedef Arrangement_ Arrangement_2; + typedef Event_ Event; + typedef Subcurve_ Subcurve; - typedef typename Traits_2::X_monotone_curve_2 X_monotone_curve_2; - typedef typename Traits_2::Point_2 Point_2; +private: + typedef Geometry_traits_2 Gt2; + typedef Arrangement_red_2 Ar2; + typedef Arrangement_blue_2 Ab2; - typedef typename Event::Subcurve_iterator Subcurve_iterator; +public: + typedef typename Gt2::X_monotone_curve_2 X_monotone_curve_2; + typedef typename Gt2::Point_2 Point_2; + + typedef typename Event::Subcurve_iterator Subcurve_iterator; // The input arrangements (the "red" and the "blue" one): - typedef ArrangementRed_ Arrangement_red_2; - typedef typename Arrangement_red_2::Topology_traits Topology_traits_red; - typedef typename Arrangement_red_2::Face_const_handle Face_handle_red; + typedef typename Ar2::Topology_traits Topology_traits_red; + typedef typename Ar2::Face_const_handle Face_handle_red; - typedef ArrangementBlue_ Arrangement_blue_2; - typedef typename Arrangement_blue_2::Topology_traits Topology_traits_blue; - typedef typename Arrangement_blue_2::Face_const_handle Face_handle_blue; + typedef typename Ab2::Topology_traits Topology_traits_blue; + typedef typename Ab2::Face_const_handle Face_handle_blue; // Define the helper class for the construction visitor. - typedef Arr_spherical_construction_helper Construction_helper; protected: @@ -86,8 +92,7 @@ protected: public: /*! Constructor, given the input red and blue arrangements. */ - Arr_spherical_overlay_helper(const Arrangement_red_2* red_arr, - const Arrangement_blue_2* blue_arr) : + Arr_spherical_overlay_helper(const Ar2* red_arr, const Ab2* blue_arr) : m_red_top_traits(red_arr->topology_traits()), m_blue_top_traits(blue_arr->topology_traits()) {} @@ -109,7 +114,7 @@ public: /*! A notification invoked before the sweep-line starts handling the given * event. - */ + */ void before_handle_event(Event* event) { if (event->parameter_space_in_y() != ARR_TOP_BOUNDARY && @@ -129,83 +134,83 @@ public: it_blue = it_red = event->left_curves_begin(); it_end = event->left_curves_end(); } - + // red arrangement - while ((it_red != it_end) && ((*it_red)->color() == Traits_2::BLUE)) + while ((it_red != it_end) && ((*it_red)->color() == Gt2::BLUE)) ++it_red; - + if (it_red != it_end) { const Subcurve* sc_red = *it_red; if (event->parameter_space_in_y() == ARR_TOP_BOUNDARY) { // The curve is incident to the north pole. switch (sc_red->color()) { - case Traits_2::RED: + case Gt2::RED: m_red_nf = (ind == ARR_MIN_END) ? sc_red->red_halfedge_handle()->twin()->face() : sc_red->red_halfedge_handle()->face(); break; - - case Traits_2::RB_OVERLAP: + + case Gt2::RB_OVERLAP: m_red_nf = (ind == ARR_MIN_END) ? sc_red->red_halfedge_handle()->twin()->face() : sc_red->red_halfedge_handle()->face(); break; - - case Traits_2::BLUE: break; + + case Gt2::BLUE: break; } } else { // The curve extends to the right from the curve of discontinuity. CGAL_assertion(ind == ARR_MIN_END); switch (sc_red->color()) { - case Traits_2::RED: + case Gt2::RED: m_red_nf = sc_red->red_halfedge_handle()->twin()->face(); break; - case Traits_2::RB_OVERLAP: + case Gt2::RB_OVERLAP: m_red_nf = sc_red->red_halfedge_handle()->twin()->face(); break; - case Traits_2::BLUE: break; + case Gt2::BLUE: break; } } } - + // blue arrangement - while ((it_blue != it_end) && ((*it_blue)->color() == Traits_2::RED)) + while ((it_blue != it_end) && ((*it_blue)->color() == Gt2::RED)) ++it_blue; - + if (it_blue != it_end) { const Subcurve* sc_blue = *it_blue; if (event->parameter_space_in_y() == ARR_TOP_BOUNDARY) { // The curve is incident to the north pole. switch (sc_blue->color()) { - case Traits_2::BLUE: - m_blue_nf = (ind == ARR_MIN_END) ? - sc_blue->blue_halfedge_handle()->twin()->face() : - sc_blue->blue_halfedge_handle()->face(); - break; - - case Traits_2::RB_OVERLAP: + case Gt2::BLUE: m_blue_nf = (ind == ARR_MIN_END) ? sc_blue->blue_halfedge_handle()->twin()->face() : sc_blue->blue_halfedge_handle()->face(); break; - case Traits_2::RED: break; + case Gt2::RB_OVERLAP: + m_blue_nf = (ind == ARR_MIN_END) ? + sc_blue->blue_halfedge_handle()->twin()->face() : + sc_blue->blue_halfedge_handle()->face(); + break; + + case Gt2::RED: break; } } else { // The curve extends to the right from the curve of discontinuity. CGAL_assertion(ind == ARR_MIN_END); switch (sc_blue->color()) { - case Traits_2::BLUE: + case Gt2::BLUE: m_blue_nf = sc_blue->blue_halfedge_handle()->twin()->face(); break; - - case Traits_2::RB_OVERLAP: + + case Gt2::RB_OVERLAP: m_blue_nf = sc_blue->blue_halfedge_handle()->twin()->face(); break; - - case Traits_2::RED: break; + + case Gt2::RED: break; } } } diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_spherical_topology_traits_2_impl.h b/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_spherical_topology_traits_2_impl.h index 4f9b7e68b0f..3fbba7dd92b 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_spherical_topology_traits_2_impl.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_spherical_topology_traits_2_impl.h @@ -24,8 +24,8 @@ #include - /*! \file + * * Member-function definitions for the * Arr_spherical_topology_traits_2 class. */ @@ -41,7 +41,7 @@ Arr_spherical_topology_traits_2() : m_south_pole(NULL), m_own_geom_traits(true) { - m_geom_traits = new Traits_adaptor_2; + m_geom_traits = new Gt_adaptor_2; m_boundary_vertices = Vertex_map(Vertex_key_comparer(m_geom_traits)); } @@ -54,7 +54,7 @@ Arr_spherical_topology_traits_2(const Geometry_traits_2* traits) : m_south_pole(NULL), m_own_geom_traits(false) { - m_geom_traits = static_cast(traits); + m_geom_traits = static_cast(traits); m_boundary_vertices = Vertex_map(Vertex_key_comparer(m_geom_traits)); } @@ -88,7 +88,7 @@ assign(const Self& other) } if (other.m_own_geom_traits) { - m_geom_traits = new Traits_adaptor_2; + m_geom_traits = new Gt_adaptor_2; m_own_geom_traits = true; } else { @@ -193,15 +193,15 @@ is_in_face(const Face* f, const Point_2& p, const Vertex* v) const * return false; */ - typename Traits_adaptor_2::Parameter_space_in_x_2 ps_x_op = + typename Gt_adaptor_2::Parameter_space_in_x_2 ps_x_op = m_geom_traits->parameter_space_in_x_2_object(); - typename Traits_adaptor_2::Parameter_space_in_y_2 ps_y_op = + typename Gt_adaptor_2::Parameter_space_in_y_2 ps_y_op = m_geom_traits->parameter_space_in_y_2_object(); - typename Traits_adaptor_2::Compare_x_2 cmp_x_op = + typename Gt_adaptor_2::Compare_x_2 cmp_x_op = m_geom_traits->compare_x_2_object(); - typename Traits_adaptor_2::Compare_y_at_x_2 cmp_y_at_x_op = + typename Gt_adaptor_2::Compare_y_at_x_2 cmp_y_at_x_op = m_geom_traits->compare_y_at_x_2_object(); - typename Traits_adaptor_2::Compare_x_point_curve_end_2 cmp_x_pt_ce = + typename Gt_adaptor_2::Compare_x_point_curve_end_2 cmp_x_pt_ce = m_geom_traits->compare_x_point_curve_end_2_object(); // Process the input point. @@ -717,7 +717,7 @@ _locate_around_vertex_on_discontinuity(Vertex* v, // Otherwise, we traverse the halfedges around v until we find the pair // of adjacent halfedges between which we should insert xc. - typename Traits_adaptor_2::Is_between_cw_2 is_between_cw = + typename Gt_adaptor_2::Is_between_cw_2 is_between_cw = m_geom_traits->is_between_cw_2_object(); bool eq_curr, eq_next; @@ -774,7 +774,7 @@ _locate_around_pole(Vertex* v, // Traverse all other halfedges, and compare their x-positions next to the // pole with the query curve xc. - typename Traits_adaptor_2::Compare_x_curve_ends_2 cmp_x_curve_ends = + typename Gt_adaptor_2::Compare_x_curve_ends_2 cmp_x_curve_ends = m_geom_traits->compare_x_curve_ends_2_object(); Arr_curve_end curr_end, next_end; Comparison_result curr_res, next_res; @@ -837,9 +837,9 @@ _face_below_vertex_on_discontinuity(Vertex* v) const // Otherwise, we traverse the halfedges around v and locate the first // halfedge we encounter if we go from "6 o'clock" clockwise. // First locate the lower left and the top right halfedges around v. - typename Traits_adaptor_2::Compare_y_at_x_right_2 cmp_y_at_x_op_right = + typename Gt_adaptor_2::Compare_y_at_x_right_2 cmp_y_at_x_op_right = m_geom_traits->compare_y_at_x_right_2_object(); - typename Traits_adaptor_2::Compare_y_at_x_left_2 cmp_y_at_x_op_left = + typename Gt_adaptor_2::Compare_y_at_x_left_2 cmp_y_at_x_op_left = m_geom_traits->compare_y_at_x_left_2_object(); Halfedge* lowest_left = NULL; diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_spherical_vert_decomp_helper.h b/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_spherical_vert_decomp_helper.h index 2b15c93ff30..a4c3067172d 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_spherical_vert_decomp_helper.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_spherical_vert_decomp_helper.h @@ -15,64 +15,63 @@ // $URL$ // $Id$ // SPDX-License-Identifier: GPL-3.0+ -// +// // Author(s) : Ron Wein // Efi Fogel -// #ifndef CGAL_ARR_SPHERICAL_VERT_DECOMP_HELPER_H #define CGAL_ARR_SPHERICAL_VERT_DECOMP_HELPER_H #include - /*! \file + * * Definition of the Arr_spherical_vert_decomp_helper class-template. */ namespace CGAL { -#include - /*! \class Arr_spherical_vert_decomp_helper + * * A helper class for the vertical decomposition sweep-line visitor, suitable * for an Arrangement_on_surface_2 instantiated with a topology-traits class * for bounded curves in the plane. */ -template -class Arr_spherical_vert_decomp_helper -{ +template +class Arr_spherical_vert_decomp_helper { public: + typedef GeometryTraits_2 Geometry_traits_2; + typedef Arrangement_ Arrangement_2; + typedef Event_ Event; + typedef Subcurve_ Subcurve; + typedef typename Subcurve::Allocator Allocator; - typedef Traits_ Traits_2; - typedef typename Traits_2::X_monotone_curve_2 X_monotone_curve_2; - typedef Arrangement_ Arrangement_2; +private: + typedef Geometry_traits_2 Gt2; - typedef typename Arrangement_2::Face_const_handle Face_const_handle; - typedef typename Arrangement_2::Vertex_const_handle Vertex_const_handle; +public: + typedef typename Gt2::X_monotone_curve_2 X_monotone_curve_2; - typedef Sweep_line_empty_visitor Base_visitor; - typedef typename Base_visitor::Event Event; - typedef typename Base_visitor::Subcurve Subcurve; + typedef typename Arrangement_2::Face_const_handle Face_const_handle; + typedef typename Arrangement_2::Vertex_const_handle Vertex_const_handle; protected: + typedef typename Arrangement_2::Topology_traits Topology_traits; - typedef typename Arrangement_2::Topology_traits Topology_traits; - - const Topology_traits *m_top_traits; // The topology traits. - Vertex_const_handle m_north_pole; // The north pole. - bool m_valid_north_pole; // Is this a valid vertex. - Face_const_handle m_north_face; // Current north face. - Vertex_const_handle m_south_pole; // The south pole. - bool m_valid_south_pole; // Is this a valid vertex. - Face_const_handle m_south_face; // Current south face. + const Topology_traits* m_top_traits; // The topology traits. + Vertex_const_handle m_north_pole; // The north pole. + bool m_valid_north_pole; // Is this a valid vertex. + Face_const_handle m_north_face; // Current north face. + Vertex_const_handle m_south_pole; // The south pole. + bool m_valid_south_pole; // Is this a valid vertex. + Face_const_handle m_south_face; // Current south face. public: - /*! Constructor. * \param arr The arrangement. */ - Arr_spherical_vert_decomp_helper(const Arrangement_2 *arr) : + Arr_spherical_vert_decomp_helper(const Arrangement_2* arr) : m_top_traits(arr->topology_traits()) {} @@ -111,8 +110,8 @@ public: //----------------------------------------------------------------------------- // A notification issued before the sweep process starts. // -template -void Arr_spherical_vert_decomp_helper::before_sweep() + template + void Arr_spherical_vert_decomp_helper::before_sweep() { // Get the north pole and the face that intially contains it. m_valid_north_pole = (m_top_traits->north_pole() != NULL); @@ -133,13 +132,12 @@ void Arr_spherical_vert_decomp_helper::before_sweep() // A notification invoked after the sweep-line finishes handling the given // event. /// -template -void -Arr_spherical_vert_decomp_helper::after_handle_event (Event *event) +template +void Arr_spherical_vert_decomp_helper:: +after_handle_event(Event *event) { // Ignore events that are not incident to the poles. - if (event->parameter_space_in_y() == ARR_INTERIOR) - return; + if (event->parameter_space_in_y() == ARR_INTERIOR) return; // The is exactly one curve incident to an event with boundary conditions. // Obtain this curve and check whether it already exists in the arrangement. @@ -148,33 +146,27 @@ Arr_spherical_vert_decomp_helper::after_handle_event (Event *event) ((event->number_of_left_curves() == 1) && (event->number_of_right_curves() == 0))); - const Arr_curve_end ind = + const Arr_curve_end ind = (event->number_of_left_curves() == 0 && event->number_of_right_curves() == 1) ? ARR_MIN_END : ARR_MAX_END; const X_monotone_curve_2& xc = (ind == ARR_MIN_END) ? (*(event->right_curves_begin()))->last_curve() : (*(event->left_curves_begin()))->last_curve(); - if (event->parameter_space_in_y() == ARR_TOP_BOUNDARY) - { + if (event->parameter_space_in_y() == ARR_TOP_BOUNDARY) { // The event is incident to the north pole: update the north face. if (ind == ARR_MIN_END) m_north_face = xc.halfedge_handle()->twin()->face(); else m_north_face = xc.halfedge_handle()->face(); } - else if (event->parameter_space_in_y() == ARR_BOTTOM_BOUNDARY) - { + else if (event->parameter_space_in_y() == ARR_BOTTOM_BOUNDARY) { // The event is incident to the south pole: update the south face. - if (ind == ARR_MIN_END) - m_south_face = xc.halfedge_handle()->face(); - else - m_south_face = xc.halfedge_handle()->twin()->face(); + if (ind == ARR_MIN_END) m_south_face = xc.halfedge_handle()->face(); + else m_south_face = xc.halfedge_handle()->twin()->face(); } - - return; } -} //namespace CGAL +} // namespace CGAL #endif diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_unb_planar_batched_pl_helper.h b/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_unb_planar_batched_pl_helper.h index d6d68e30704..8e8fca320e7 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_unb_planar_batched_pl_helper.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_unb_planar_batched_pl_helper.h @@ -18,80 +18,75 @@ // // // Author(s) : Baruch Zukerman -// Ron Wein -// Efi Fogel +// Ron Wein +// Efi Fogel #ifndef CGAL_ARR_UNB_PLANAR_BATCHED_PL_HELPER_H #define CGAL_ARR_UNB_PLANAR_BATCHED_PL_HELPER_H #include - -/*! +/*! \file + * * Definition of the Arr_unb_planar_batched_pl_helper class-template. */ namespace CGAL { -#include - /*! \class Arr_unb_planar_batched_pl_helper + * * A helper class for the batched point-location sweep-line visitor, suitable * for an Arrangement_on_surface_2 instantiated with a topology-traits class * for unbounded curves in the plane. */ -template -class Arr_unb_planar_batched_pl_helper -{ +template +class Arr_unb_planar_batched_pl_helper { public: + typedef GeometryTraits_2 Geometry_traits_2; + typedef Arrangement_ Arrangement_2; + typedef Event_ Event; + typedef Subcurve_ Subcurve; + typedef typename Subcurve::Allocator Allocator; - typedef Traits_ Traits_2; - typedef Arrangement_ Arrangement_2; +private: + typedef Geometry_traits_2 Gt2; - typedef typename Arrangement_2::Face_const_handle Face_const_handle; - - typedef Sweep_line_empty_visitor Base_visitor; - typedef typename Base_visitor::Event Event; - typedef typename Base_visitor::Subcurve Subcurve; +public: + typedef typename Arrangement_2::Face_const_handle Face_const_handle; protected: - typedef typename Arrangement_2::Topology_traits Topology_traits; typedef typename Arrangement_2::Halfedge_const_handle Halfedge_const_handle; typedef typename Arrangement_2::Vertex_const_handle Vertex_const_handle; // Data members: - const Topology_traits *m_top_traits; // The topology-traits class. - Halfedge_const_handle m_top_fict; // The current top fictitious halfedge. + const Topology_traits* m_top_traits; // The topology-traits class. + Halfedge_const_handle m_top_fict; // The current top fictitious halfedge. public: - /*! * Constructor. * \param arr The arrangement. */ - Arr_unb_planar_batched_pl_helper (const Arrangement_2 *arr) : - m_top_traits (arr->topology_traits()) + Arr_unb_planar_batched_pl_helper(const Arrangement_2* arr) : + m_top_traits(arr->topology_traits()) {} /// \name Notification functions. //@{ /* A notification issued before the sweep process starts. */ - void before_sweep (); + void before_sweep(); - /*! - * A notification invoked after the sweep-line finishes handling the given + /*! A notification invoked after the sweep-line finishes handling the given * event. */ - void after_handle_event (Event* event); + void after_handle_event(Event* event); //@} /*! Get the current top face. */ - Face_const_handle top_face () const - { - return (m_top_fict->face()); - } + Face_const_handle top_face() const { return (m_top_fict->face()); } }; //----------------------------------------------------------------------------- @@ -101,54 +96,49 @@ public: //----------------------------------------------------------------------------- // A notification issued before the sweep process starts. // -template -void Arr_unb_planar_batched_pl_helper::before_sweep () +template +void Arr_unb_planar_batched_pl_helper:: +before_sweep() { // Initialize the fictitious halfedge lying on the top edge of the // fictitious face. We start from the leftmost halfedge, which is // incident to the top-left vertex and directed from right to left. - Vertex_const_handle v_tl = - Vertex_const_handle (m_top_traits->top_left_vertex()); + Vertex_const_handle v_tl = + Vertex_const_handle(m_top_traits->top_left_vertex()); m_top_fict = v_tl->incident_halfedges(); if (m_top_fict->direction() == ARR_LEFT_TO_RIGHT) m_top_fict = m_top_fict->next()->twin(); - CGAL_assertion_code ( - Vertex_const_handle v_tr = - Vertex_const_handle (m_top_traits->top_right_vertex()); + CGAL_assertion_code( + Vertex_const_handle v_tr = + Vertex_const_handle(m_top_traits->top_right_vertex()); ); CGAL_assertion ((m_top_fict->source() == v_tr) || (m_top_fict->source()->parameter_space_in_x() == ARR_INTERIOR && m_top_fict->source()->parameter_space_in_y() == ARR_TOP_BOUNDARY)); - - return; } //----------------------------------------------------------------------------- // A notification invoked after the sweep-line finishes handling the given // event. // -template -void Arr_unb_planar_batched_pl_helper:: -after_handle_event (Event* event) +template +void Arr_unb_planar_batched_pl_helper:: +after_handle_event(Event* event) { // If the event is at infinity and occurs on the top edge of the fictitious // face (namely x is finite and y = +oo), we have to update the fictitious // edge we keep. - if (event->is_closed()) - return; + if (event->is_closed()) return; - if (event->parameter_space_in_x() != ARR_INTERIOR) - return; + if (event->parameter_space_in_x() != ARR_INTERIOR) return; if (event->parameter_space_in_y() == ARR_TOP_BOUNDARY) m_top_fict = m_top_fict->twin()->next()->twin(); - - return; } -} //namespace CGAL +} // namespace CGAL #endif diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_unb_planar_construction_helper.h b/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_unb_planar_construction_helper.h index 02758236d08..d544d8ab8ef 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_unb_planar_construction_helper.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_unb_planar_construction_helper.h @@ -15,85 +15,103 @@ // $URL$ // $Id$ // SPDX-License-Identifier: GPL-3.0+ -// +// // // Author(s) : Baruch Zukerman -// Ron Wein -// Efi Fogel +// Ron Wein +// Efi Fogel #ifndef CGAL_ARR_UNB_PLANAR_CONSTRUCTION_HELPER_H #define CGAL_ARR_UNB_PLANAR_CONSTRUCTION_HELPER_H #include - -/*! +/*! \file + * * Definition of the Arr_unb_planar_construction_helper class-template. */ -#include +#include #include namespace CGAL { /*! \class Arr_unb_planar_construction_helper + * * A helper class for the construction sweep-line visitor, suitable * for an Arrangement_on_surface_2 instantiated with a topology-traits class * for unbounded curves in the plane. */ -template -class Arr_unb_planar_construction_helper -{ +template +class Arr_unb_planar_construction_helper { public: + typedef GeometryTraits_2 Geometry_traits_2; + typedef Arrangement_ Arrangement_2; + typedef Event_ Event; + typedef Subcurve_ Subcurve; + typedef typename Subcurve::Allocator Allocator; - typedef Traits_ Traits_2; - typedef Arrangement_ Arrangement_2; - typedef Event_ Event; - typedef Subcurve_ Subcurve; + // The following should be private. It is declared 'protected' as a + // workaround to a problem with VC. (At least VC 14 exhibits this problem). + // When declared private, VC claims that Gt2 is private (within + // Arr_unb_planar_construction_helper); thus, it cannot be access by + // Arr_unb_planar_construction_helper. +protected: + typedef Geometry_traits_2 Gt2; - typedef typename Traits_2::X_monotone_curve_2 X_monotone_curve_2; - typedef typename Traits_2::Point_2 Point_2; +public: + typedef typename Gt2::X_monotone_curve_2 X_monotone_curve_2; + typedef typename Gt2::Point_2 Point_2; - typedef Sweep_line_empty_visitor - Base_visitor; + typedef typename Arrangement_2::Halfedge_handle Halfedge_handle; + typedef typename Arrangement_2::Face_handle Face_handle; - typedef typename Arrangement_2::Halfedge_handle Halfedge_handle; - typedef typename Arrangement_2::Face_handle Face_handle; - - typedef typename Subcurve::Halfedge_indices_list Indices_list; - typedef Unique_hash_map Halfedge_indices_map; + typedef typename Subcurve::Halfedge_indices_list Indices_list; + typedef Unique_hash_map + Halfedge_indices_map; + + /*! \struct rebind + * An auxiliary structure for rebinding the helper with a new types. + * Mainly used to rebind the geometry-traits type and a new type that derives + * from the old one. + */ + template + struct rebind { + typedef Arr_unb_planar_construction_helper + other; + }; protected: - - typedef typename Arrangement_2::Topology_traits Topology_traits; - typedef typename Arrangement_2::Vertex_handle Vertex_handle; + typedef typename Arrangement_2::Topology_traits Topology_traits; + typedef typename Arrangement_2::Vertex_handle Vertex_handle; // Data members: - Topology_traits* m_top_traits; // The topology-traits class. - Arr_accessor - m_arr_access; // An arrangement accessor. + Topology_traits* m_top_traits; // The topology-traits class. + Arr_accessor m_arr_access; // An arrangement accessor. - Halfedge_handle m_lh; // The current left fictitious - // halfedge (on x = -oo). - Halfedge_handle m_th; // The current top fictitious - // halfedge (on y = +oo). - Halfedge_handle m_bh; // The current bottom fictitious - // halfedge (on y = -oo). - Halfedge_handle m_rh; // The current right fictitious - // halfedge (on x = +oo). + Halfedge_handle m_lh; // The current left fictitious + // halfedge (on x = -oo). + Halfedge_handle m_th; // The current top fictitious + // halfedge (on y = +oo). + Halfedge_handle m_bh; // The current bottom fictitious + // halfedge (on y = -oo). + Halfedge_handle m_rh; // The current right fictitious + // halfedge (on x = +oo). - Indices_list m_subcurves_at_ubf; // Indices of the curves that + Indices_list m_subcurves_at_ubf; // Indices of the curves that // "see" m_th from below. - Event* m_prev_minus_inf_x_event; // The previous event at x = -oo. - Event* m_prev_plus_inf_y_event; // The previous event at y = +oo. + Event* m_prev_minus_inf_x_event; // The previous event at x = -oo. + Event* m_prev_plus_inf_y_event; // The previous event at y = +oo. + + Halfedge_indices_map* m_he_ind_map_p; // A pointer to a map of + // halfedges to indices lists + // (stored in the visitor class). - Halfedge_indices_map* m_he_ind_map_p; // A pointer to a map of - // halfedges to indices lists - // (stored in the visitor class). - public: - /*! Constructor. */ Arr_unb_planar_construction_helper(Arrangement_2* arr) : m_top_traits(arr->topology_traits()), @@ -125,15 +143,10 @@ public: /*! Collect a subcurve index that does not see any status-line from below. */ void add_subcurve_in_top_face(unsigned int index) - { - m_subcurves_at_ubf.push_back(index); - } + { m_subcurves_at_ubf.push_back(index); } /*! Get the indices of the halfedges below the subcurve. */ - Indices_list& halfedge_indices_list() - { - return (m_subcurves_at_ubf); - } + Indices_list& halfedge_indices_list() { return (m_subcurves_at_ubf); } /*! A notification invoked before the given event it deallocated. */ @@ -144,16 +157,14 @@ public: if (event == m_prev_plus_inf_y_event) m_prev_plus_inf_y_event = NULL; } - //@} - + //@} + /*! * Set the map that maps each halfedge to the list of subcurve indices * that "see" the halfedge from below. */ void set_halfedge_indices_map(Halfedge_indices_map& table) - { - m_he_ind_map_p = &table; - } + { m_he_ind_map_p = &table; } /*! * Determine if we should swap the order of predecessor halfedges when @@ -170,9 +181,7 @@ public: /*! Get the current top face. */ Face_handle top_face() const - { - return (m_th->face()); - } + { return (m_th->face()); } }; //----------------------------------------------------------------------------- @@ -182,7 +191,7 @@ public: //----------------------------------------------------------------------------- // A notification issued before the sweep process starts. // -template +template void Arr_unb_planar_construction_helper::before_sweep() { // Obtain the four fictitious vertices that form the "corners" of the @@ -192,7 +201,7 @@ void Arr_unb_planar_construction_helper::before_sweep() CGAL_assertion_code (Vertex_handle v_br = Vertex_handle(m_top_traits->bottom_right_vertex()); Vertex_handle v_tr = Vertex_handle(m_top_traits->top_right_vertex())); - + // Get the fictitous halfedges incident to these vertices, representing // the left, right, top and bottom edges of the fictitious face. // @@ -206,7 +215,7 @@ void Arr_unb_planar_construction_helper::before_sweep() // m_lh = v_tl->incident_halfedges(); m_lh = (m_lh->source() != v_bl) ? m_lh->next() : m_lh->twin(); - + m_bh = m_lh->next(); m_rh = m_bh->next(); m_th = m_rh->next(); @@ -216,15 +225,15 @@ void Arr_unb_planar_construction_helper::before_sweep() CGAL_assertion(m_lh->direction() == ARR_RIGHT_TO_LEFT); CGAL_assertion(m_lh->face() != fict_face); CGAL_assertion(m_lh->source() == v_tl && m_lh->target() == v_bl); - + CGAL_assertion(m_bh->direction() == ARR_LEFT_TO_RIGHT); CGAL_assertion(m_bh->face() != fict_face); CGAL_assertion(m_bh->source() == v_bl && m_bh->target() == v_br); - + CGAL_assertion(m_rh->direction() == ARR_LEFT_TO_RIGHT); CGAL_assertion(m_rh->face() != fict_face); CGAL_assertion(m_rh->source() == v_br && m_rh->target() == v_tr); - + CGAL_assertion(m_th->direction() == ARR_RIGHT_TO_LEFT); CGAL_assertion(m_th->face() != fict_face); CGAL_assertion(m_th->source() == v_tr && m_th->target() == v_tl); @@ -234,7 +243,7 @@ void Arr_unb_planar_construction_helper::before_sweep() // A notification invoked before the sweep-line starts handling the given // event. // -template +template void Arr_unb_planar_construction_helper:: before_handle_event(Event* event) { @@ -247,15 +256,15 @@ before_handle_event(Event* event) (event->number_of_right_curves() == 1)) || ((event->number_of_left_curves() == 1) && (event->number_of_right_curves() == 0))); - Arr_curve_end ind = (event->number_of_left_curves() == 0 && - event->number_of_right_curves() == 1) ? + Arr_curve_end ind = (event->number_of_left_curves() == 0 && + event->number_of_right_curves() == 1) ? ARR_MIN_END : ARR_MAX_END; - const X_monotone_curve_2& xc = (ind == ARR_MIN_END) ? + const X_monotone_curve_2& xc = (ind == ARR_MIN_END) ? (*(event->right_curves_begin()))->last_curve() : (*(event->left_curves_begin()))->last_curve(); - const Arr_parameter_space ps_x = event->parameter_space_in_x(); - const Arr_parameter_space ps_y = event->parameter_space_in_y(); + const Arr_parameter_space ps_x = event->parameter_space_in_x(); + const Arr_parameter_space ps_y = event->parameter_space_in_y(); // Create a vertex at infinity and split the corresponding fictitious edge. Vertex_handle v_at_inf = @@ -281,11 +290,9 @@ before_handle_event(Event* event) m_rh = m_rh->next(); return; - case ARR_INTERIOR: - break; + case ARR_INTERIOR: break; - default: - CGAL_error(); + default: CGAL_error(); } switch (ps_y) { @@ -304,7 +311,7 @@ before_handle_event(Event* event) // Update the incident halfedge of the previous vertex at y = +oo // (m_th used to be incident to it, but now we have split it). - if(m_prev_plus_inf_y_event != NULL) + if (m_prev_plus_inf_y_event != NULL) m_prev_plus_inf_y_event->set_halfedge_handle(m_th->next()); m_prev_plus_inf_y_event = event; @@ -316,8 +323,7 @@ before_handle_event(Event* event) list_ref.clear(); list_ref.splice(list_ref.end(), m_subcurves_at_ubf); } - else - { + else { m_subcurves_at_ubf.clear(); } CGAL_assertion(m_subcurves_at_ubf.empty()); @@ -331,6 +337,6 @@ before_handle_event(Event* event) } } -} //namespace CGAL +} // namespace CGAL #endif 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 65b2ed79369..0e39819d2dd 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 @@ -15,75 +15,69 @@ // $URL$ // $Id$ // SPDX-License-Identifier: GPL-3.0+ -// +// // // Author(s) : Baruch Zukerman -// Ron Wein -// Efi Fogel +// Ron Wein +// Efi Fogel #ifndef CGAL_ARR_UNB_PLANAR_INSERTION_HELPER_H #define CGAL_ARR_UNB_PLANAR_INSERTION_HELPER_H #include - -/*! +/*! \file + * * Definition of the Arr_unb_planar_insertion_helper class-template. */ -#include #include namespace CGAL { /*! \class Arr_unb_planar_insertion_helper + * * A helper class for the insertion sweep-line visitors, suitable * 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 { public: + typedef GeometryTraits_2 Geometry_traits_2; + typedef Arrangement_ Arrangement_2; + typedef Event_ Event; + typedef Subcurve_ Subcurve; - typedef Traits_ Traits_2; - typedef Arrangement_ Arrangement_2; - typedef Event_ Event; - typedef Subcurve_ Subcurve; +private: + typedef Geometry_traits_2 Gt2; + typedef Arr_unb_planar_insertion_helper + Self; + typedef Arr_unb_planar_construction_helper Base; - typedef typename Traits_2::X_monotone_curve_2 X_monotone_curve_2; - typedef typename Traits_2::Point_2 Point_2; +public: + typedef typename Gt2::X_monotone_curve_2 X_monotone_curve_2; + typedef typename Gt2::Point_2 Point_2; + typedef typename Arrangement_2::Face_handle Face_handle; - typedef Arr_unb_planar_construction_helper Base; - - typedef Sweep_line_empty_visitor - Base_visitor; - - typedef Arr_unb_planar_insertion_helper Self; - - typedef Arr_construction_sl_visitor Parent_visitor; - - typedef typename Arrangement_2::Face_handle Face_handle; - - typedef typename Base::Indices_list Indices_list; - typedef typename Base::Halfedge_indices_map Halfedge_indices_map; + typedef typename Base::Indices_list Indices_list; + typedef typename Base::Halfedge_indices_map Halfedge_indices_map; protected: + typedef typename Base::Topology_traits Topology_traits; + typedef typename Base::Vertex_handle Vertex_handle; + typedef typename Base::Halfedge_handle Halfedge_handle; - 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) + Arr_unb_planar_insertion_helper(Arrangement_2* arr) : + Base(arr) {} /*! Destructor. */ @@ -99,7 +93,7 @@ public: * A notification invoked before the sweep-line starts handling the given * event. */ - virtual void before_handle_event (Event* event); + virtual void before_handle_event(Event* event); //@} }; @@ -110,17 +104,14 @@ public: //----------------------------------------------------------------------------- // A notification issued before the sweep process starts. // -template -void Arr_unb_planar_insertion_helper::before_sweep () +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 (this->m_top_traits->top_left_vertex()); - Vertex_handle v_br = - Vertex_handle (this->m_top_traits->bottom_right_vertex()); + Vertex_handle v_bl = Vertex_handle (this->m_top_traits->bottom_left_vertex()); + Vertex_handle v_tl = Vertex_handle (this->m_top_traits->top_left_vertex()); + Vertex_handle v_br = Vertex_handle (this->m_top_traits->bottom_right_vertex()); // Get the fictitous halfedges incident to these vertices, and lying on // the left, right, top and bottom edges of the fictitious face. @@ -130,7 +121,7 @@ void Arr_unb_planar_insertion_helper::before_sweep () // ^ // x | m_rh // m_lh | x - // v + // v // v_bl (.)----->x (.) v_br // m_bh // @@ -138,9 +129,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(); @@ -148,8 +139,7 @@ void Arr_unb_planar_insertion_helper::before_sweep () this->m_rh = v_br->incident_halfedges(); if (this->m_rh->source()->parameter_space_in_x() == ARR_RIGHT_BOUNDARY) this->m_rh = this->m_rh->twin(); - else - this->m_rh = this->m_rh->next(); + else this->m_rh = this->m_rh->next(); CGAL_assertion_code ( Face_handle fict_face = Face_handle (this->m_top_traits->fictitious_face()); @@ -175,17 +165,15 @@ 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) +before_handle_event(Event* event) { - if (event->is_closed()) - return; + if (event->is_closed()) return; // In case the event lies at inifinity, check whether its incident curve // is already in the arrangement. - if (event->curve().halfedge_handle() == Halfedge_handle()) - { + if (event->curve().halfedge_handle() == Halfedge_handle()) { // The curve is not in the arrangement, use the base construction helper // to handle the event: Base::before_handle_event (event); @@ -195,40 +183,32 @@ 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) - { + + if (ps_x == ARR_LEFT_BOUNDARY) { // The event lies on the left fictitious halfedge. this->m_lh = this->m_lh->twin()->next()->twin(); this->m_prev_minus_inf_x_event = NULL; } - else if (ps_x == ARR_RIGHT_BOUNDARY) - { + else if (ps_x == ARR_RIGHT_BOUNDARY) { // The event lies on the right fictitious halfedge. this->m_rh = this->m_rh->twin()->prev()->twin(); } - else - { + else { const Arr_parameter_space ps_y = event->parameter_space_in_y(); - - if (ps_y == ARR_BOTTOM_BOUNDARY) - { + + if (ps_y == ARR_BOTTOM_BOUNDARY) { // The event lies on the bottom fictitious halfedge. this->m_bh = this->m_bh->twin()->prev()->twin(); } - else - { + else { // The event lies on the top fictitious halfedge. CGAL_assertion (ps_y == ARR_TOP_BOUNDARY); this->m_th = this->m_th->twin()->next()->twin(); this->m_prev_plus_inf_y_event = NULL; } } - - return; } - -} //namespace CGAL +} // namespace CGAL #endif 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 f68a994a495..5ba852715d0 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 @@ -15,7 +15,7 @@ // $URL$ // $Id$ // SPDX-License-Identifier: GPL-3.0+ -// +// // // Author(s) : Baruch Zukerman // Ron Wein @@ -26,8 +26,8 @@ #include - -/*! +/*! \file + * * Definition of the Arr_unb_planar_overlay_helper class-template. */ @@ -36,93 +36,83 @@ namespace CGAL { /*! \class Arr_unb_planar_overlay_helper + * * A helper class for the overlay sweep-line visitor, suitable for the overlay * of Arrangement_on_surface_2 objects instantiated with a topology-traits * class for unbounded curves in the plane. */ -template -class Arr_unb_planar_overlay_helper -{ +template +class Arr_unb_planar_overlay_helper { public: + typedef GeometryTraits_2 Geometry_traits_2; + typedef ArrangementRed_2 Arrangement_red_2; + typedef ArrangementBlue_2 Arrangement_blue_2; + typedef Arrangement_ Arrangement_2; + typedef Event_ Event; + typedef Subcurve_ Subcurve; - typedef Traits_ Traits_2; - typedef Arrangement_ Arrangement_2; - typedef Event_ Event; - typedef Subcurve_ Subcurve; +private: + typedef Geometry_traits_2 Gt2; + typedef Arrangement_red_2 Ar2; + typedef Arrangement_blue_2 Ab2; - typedef typename Traits_2::X_monotone_curve_2 X_monotone_curve_2; - typedef typename Traits_2::Point_2 Point_2; +public: + typedef typename Gt2::X_monotone_curve_2 X_monotone_curve_2; + typedef typename Gt2::Point_2 Point_2; // The input arrangements (the "red" and the "blue" one): - typedef ArrangementRed_ Arrangement_red_2; - typedef typename Arrangement_red_2::Halfedge_const_handle - Halfedge_handle_red; - typedef typename Arrangement_red_2::Face_const_handle Face_handle_red; - typedef typename Arrangement_red_2::Vertex_const_handle Vertex_handle_red; + typedef typename Ar2::Halfedge_const_handle Halfedge_handle_red; + typedef typename Ar2::Face_const_handle Face_handle_red; + typedef typename Ar2::Vertex_const_handle Vertex_handle_red; - typedef ArrangementBlue_ Arrangement_blue_2; - typedef typename Arrangement_blue_2::Halfedge_const_handle - Halfedge_handle_blue; - typedef typename Arrangement_blue_2::Face_const_handle Face_handle_blue; - typedef typename Arrangement_blue_2::Vertex_const_handle - Vertex_handle_blue; + typedef typename Ab2::Halfedge_const_handle Halfedge_handle_blue; + typedef typename Ab2::Face_const_handle Face_handle_blue; + typedef typename Ab2::Vertex_const_handle Vertex_handle_blue; // Define the helper class for the construction visitor. - typedef Arr_unb_planar_construction_helper Construction_helper; + typedef Arr_unb_planar_construction_helper Construction_helper; protected: - // Data members: - const typename Arrangement_red_2::Topology_traits *m_red_top_traits; - const typename Arrangement_blue_2::Topology_traits *m_blue_top_traits; + const typename Ar2::Topology_traits* m_red_top_traits; + const typename Ab2::Topology_traits* m_blue_top_traits; - Halfedge_handle_red m_red_th; // Red top fictitious halfedge. - Halfedge_handle_blue m_blue_th; // Blue top fictitious halfedge. + 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_blue v_blue_tl; // Blue 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: - /*! Constructor, given the input red and blue arrangements. */ - Arr_unb_planar_overlay_helper (const Arrangement_red_2 *red_arr, - const Arrangement_blue_2 *blue_arr) : - m_red_top_traits (red_arr->topology_traits()), - m_blue_top_traits (blue_arr->topology_traits()) + Arr_unb_planar_overlay_helper(const Ar2* red_arr, const Ab2* blue_arr) : + m_red_top_traits(red_arr->topology_traits()), + m_blue_top_traits(blue_arr->topology_traits()) {} /// \name Notification functions. //@{ /* A notification issued before the sweep process starts. */ - void before_sweep (); + void before_sweep(); - /*! - * A notification invoked before the sweep-line starts handling the given + /*! A notification invoked before the sweep-line starts handling the given * event. - */ - void before_handle_event (Event* e); + */ + void before_handle_event(Event* e); //@} /*! Get the current red top face. */ - Face_handle_red red_top_face () const - { - return (m_red_th->face()); - } + Face_handle_red red_top_face() const { return (m_red_th->face()); } /*! Get the current blue top face. */ - Face_handle_blue blue_top_face () const - { - return (m_blue_th->face()); - } + Face_handle_blue blue_top_face() const { return (m_blue_th->face()); } }; //----------------------------------------------------------------------------- @@ -132,93 +122,83 @@ public: //----------------------------------------------------------------------------- // A notification issued before the sweep process starts. // -template -void Arr_unb_planar_overlay_helper::before_sweep () +template +void Arr_unb_planar_overlay_helper:: +before_sweep() { // Get the top-left fictitious vertices in both arrangements. - v_red_tl = Vertex_handle_red (m_red_top_traits->top_left_vertex()); - v_blue_tl = Vertex_handle_blue (m_blue_top_traits->top_left_vertex()); + v_red_tl = Vertex_handle_red(m_red_top_traits->top_left_vertex()); + v_blue_tl = Vertex_handle_blue(m_blue_top_traits->top_left_vertex()); // Get the fictitious halfedges incident to the bottom-left fictitious // 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 (m_red_top_traits->bottom_left_vertex()); + 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 (m_blue_top_traits->bottom_left_vertex()); - + if (m_red_th->source() == v_red_tl) m_red_th = m_red_th->prev(); + + 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(); - return; + if (m_blue_th->source() == v_blue_tl) m_blue_th = m_blue_th->prev(); } //----------------------------------------------------------------------------- // A notification invoked before the sweep-line starts handling the given // event. // -template -void Arr_unb_planar_overlay_helper:: -before_handle_event (Event* e) +template +void Arr_unb_planar_overlay_helper:: +before_handle_event(Event* e) { // Nothing to do in case the event represents a valid point. - if (e->is_closed()) - return; - + 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. if (e->parameter_space_in_x() == ARR_LEFT_BOUNDARY || - (e->parameter_space_in_x() == ARR_INTERIOR && + (e->parameter_space_in_x() == ARR_INTERIOR && e->parameter_space_in_y() == ARR_TOP_BOUNDARY)) { - switch (e->curve().color()) - { - case (Traits_2::RED) : + switch (e->curve().color()) { + case (Gt2::RED) : // Update the red top fictitious halfedge. m_red_th = m_red_th->twin()->next()->twin(); - if (m_red_th->source() == v_red_tl) - m_red_th = m_red_th->prev(); + if (m_red_th->source() == v_red_tl) m_red_th = m_red_th->prev(); break; - - case (Traits_2::BLUE) : + + case (Gt2::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(); + if (m_blue_th->source() == v_blue_tl) m_blue_th = m_blue_th->prev(); break; - - case Traits_2::RB_OVERLAP : + + case Gt2::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) - m_red_th = m_red_th->prev(); + if (m_red_th->source() == v_red_tl) m_red_th = m_red_th->prev(); m_blue_th = m_blue_th->twin()->next()->twin(); - if (m_blue_th->source() == v_blue_tl) - m_blue_th = m_blue_th->prev(); - + if (m_blue_th->source() == v_blue_tl) m_blue_th = m_blue_th->prev(); break; } } - - return; } -} //namespace CGAL +} // namespace CGAL #endif diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_unb_planar_topology_traits_2_impl.h b/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_unb_planar_topology_traits_2_impl.h index 428dca1ed7d..caa5a6dc9e6 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_unb_planar_topology_traits_2_impl.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_unb_planar_topology_traits_2_impl.h @@ -25,8 +25,8 @@ #include - /*! \file + * * Member-function definitions for the * Arr_unb_planar_topology_traits_2 class. */ @@ -36,22 +36,22 @@ namespace CGAL { //----------------------------------------------------------------------------- // Default constructor. // -template +template Arr_unb_planar_topology_traits_2:: Arr_unb_planar_topology_traits_2(): - Base (), - v_bl (NULL), - v_tl (NULL), - v_br (NULL), - v_tr (NULL), - n_inf_verts (0), - fict_face (NULL) + Base(), + v_bl(NULL), + v_tl(NULL), + v_br(NULL), + v_tr(NULL), + n_inf_verts(0), + fict_face(NULL) {} //----------------------------------------------------------------------------- // Constructor with a geometry-traits class. // -template +template Arr_unb_planar_topology_traits_2:: Arr_unb_planar_topology_traits_2 (const Geometry_traits_2 * geom_traits) : Base (geom_traits), @@ -66,7 +66,7 @@ Arr_unb_planar_topology_traits_2 (const Geometry_traits_2 * geom_traits) : //----------------------------------------------------------------------------- // Assign the contents of another topology-traits class. // -template +template void Arr_unb_planar_topology_traits_2:: assign(const Self& other) { @@ -82,7 +82,7 @@ assign(const Self& other) //----------------------------------------------------------------------------- // Make the necessary updates after the DCEL structure have been updated. // -template +template void Arr_unb_planar_topology_traits_2::dcel_updated () { // Go over the DCEL vertices and locate the four fictitious ones. @@ -147,7 +147,7 @@ void Arr_unb_planar_topology_traits_2::dcel_updated () //----------------------------------------------------------------------------- // Initialize an empty DCEL structure. // -template +template void Arr_unb_planar_topology_traits_2::init_dcel () { // Clear the current DCEL. @@ -252,7 +252,7 @@ void Arr_unb_planar_topology_traits_2::init_dcel () //----------------------------------------------------------------------------- // Check if the given vertex is associated with the given curve end. // -template +template bool Arr_unb_planar_topology_traits_2:: are_equal(const Vertex *v, const X_monotone_curve_2& cv, Arr_curve_end ind, @@ -304,7 +304,7 @@ are_equal(const Vertex *v, // interior of the curve, find a place for a boundary vertex that will // represent the curve end along the face boundary. // -template +template CGAL::Object Arr_unb_planar_topology_traits_2:: place_boundary_vertex(Face *f, @@ -342,7 +342,7 @@ place_boundary_vertex(Face *f, //----------------------------------------------------------------------------- // Locate a DCEL feature that contains the given unbounded curve end. // -template +template CGAL::Object Arr_unb_planar_topology_traits_2:: locate_curve_end (const X_monotone_curve_2& cv, Arr_curve_end ind, Arr_parameter_space ps_x, Arr_parameter_space ps_y) @@ -403,7 +403,7 @@ locate_curve_end (const X_monotone_curve_2& cv, Arr_curve_end ind, //----------------------------------------------------------------------------- // Split a fictitious edge using the given vertex. // -template +template typename Arr_unb_planar_topology_traits_2::Halfedge* Arr_unb_planar_topology_traits_2:: split_fictitious_edge (Halfedge *e, Vertex *v) @@ -480,7 +480,7 @@ split_fictitious_edge (Halfedge *e, Vertex *v) //----------------------------------------------------------------------------- // Determine whether the given face is unbounded. // -template +template bool Arr_unb_planar_topology_traits_2:: is_unbounded(const Face *f) const { @@ -506,7 +506,7 @@ is_unbounded(const Face *f) const //----------------------------------------------------------------------------- // Determine whether the given boundary vertex is redundant. // -template +template bool Arr_unb_planar_topology_traits_2:: is_redundant(const Vertex *v) const { @@ -529,7 +529,7 @@ is_redundant(const Vertex *v) const //----------------------------------------------------------------------------- // Erase the given redundant vertex. // -template +template typename Arr_unb_planar_topology_traits_2::Halfedge* Arr_unb_planar_topology_traits_2:: erase_redundant_vertex (Vertex *v) @@ -601,7 +601,7 @@ erase_redundant_vertex (Vertex *v) // Compare the x-coordinates of a given vertex (which may lie at infinity) and // the given point. // -template +template Comparison_result Arr_unb_planar_topology_traits_2:: compare_x (const Point_2& p, const Vertex* v) const @@ -638,7 +638,7 @@ compare_x (const Point_2& p, const Vertex* v) const //----------------------------------------------------------------------------- // Compare the given vertex (which may lie at infinity) and the given point. // -template +template Comparison_result Arr_unb_planar_topology_traits_2:: compare_xy (const Point_2& p, const Vertex* v) const @@ -679,10 +679,10 @@ compare_xy (const Point_2& p, const Vertex* v) const // Compare the relative y-position of the given point and the given edge // (which may be fictitious). // -template +template Comparison_result Arr_unb_planar_topology_traits_2:: -compare_y_at_x (const Point_2& p, const Halfedge* he) const +compare_y_at_x(const Point_2& p, const Halfedge* he) const { // In case of a valid edge, just compare p to its associated curve. if (! he->has_null_curve()) diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_unb_planar_vert_decomp_helper.h b/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_unb_planar_vert_decomp_helper.h index e105733ad1f..f53abbe6861 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_unb_planar_vert_decomp_helper.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_unb_planar_vert_decomp_helper.h @@ -15,7 +15,7 @@ // $URL$ // $Id$ // SPDX-License-Identifier: GPL-3.0+ -// +// // // Author(s) : Ron Wein // Efi Fogel @@ -25,82 +25,71 @@ #include - /*! \file + * * Definition of the Arr_unb_planar_vert_decomp_helper class-template. */ namespace CGAL { -#include - /*! \class Arr_unb_planar_vert_decomp_helper + * * A helper class for the vertical decomposition sweep-line visitor, suitable * for an Arrangement_on_surface_2 instantiated with a topology-traits class * for unbounded curves in the plane. */ -template -class Arr_unb_planar_vert_decomp_helper -{ +template +class Arr_unb_planar_vert_decomp_helper { public: + typedef Traits_ Geometry_traits_2; + typedef Arrangement_ Arrangement_2; + typedef Event_ Event; + typedef Subcurve_ Subcurve; + typedef typename Subcurve::Allocator Allocator; - typedef Traits_ Traits_2; - typedef Arrangement_ Arrangement_2; +private: + typedef Geometry_traits_2 Gt2; - typedef typename Arrangement_2::Face_const_handle Face_const_handle; - - typedef Sweep_line_empty_visitor Base_visitor; - typedef typename Base_visitor::Event Event; - typedef typename Base_visitor::Subcurve Subcurve; +public: + typedef typename Arrangement_2::Face_const_handle Face_const_handle; protected: - typedef typename Arrangement_2::Topology_traits Topology_traits; typedef typename Arrangement_2::Halfedge_const_handle Halfedge_const_handle; typedef typename Arrangement_2::Vertex_const_handle Vertex_const_handle; // Data members: - const Topology_traits *m_top_traits; // The topology-traits class. - Halfedge_const_handle m_top_fict; // The current top fictitious halfedge. - Halfedge_const_handle m_bottom_fict; // The current bottom fictitious + const Topology_traits* m_top_traits; // The topology-traits class. + Halfedge_const_handle m_top_fict; // The current top fictitious halfedge. + Halfedge_const_handle m_bottom_fict; // The current bottom fictitious // halfedge. public: - - /*! - * Constructor. + /*! Constructor. * \param arr The arrangement. */ - Arr_unb_planar_vert_decomp_helper (const Arrangement_2 *arr) : - m_top_traits (arr->topology_traits()) + Arr_unb_planar_vert_decomp_helper(const Arrangement_2* arr) : + m_top_traits(arr->topology_traits()) {} /// \name Notification functions. //@{ /* A notification issued before the sweep process starts. */ - void before_sweep (); + void before_sweep(); - /*! - * A notification invoked after the sweep-line finishes handling the given + /*! A notification invoked after the sweep-line finishes handling the given * event. */ - void after_handle_event (Event* event); + void after_handle_event(Event* event); //@} /*! Get the current top object. */ - CGAL::Object top_object () const - { - // Wrap the top fictitious halfedge by a CGAL object. - return (CGAL::make_object (m_top_fict)); - } + CGAL::Object top_object() const { return CGAL::make_object(m_top_fict); } /*! Get the current bottom object. */ - CGAL::Object bottom_object () const - { - // Wrap the bottom fictitious halfedge by a CGAL object. - return (CGAL::make_object (m_bottom_fict)); - } + CGAL::Object bottom_object() const { return CGAL::make_object(m_bottom_fict); } }; //----------------------------------------------------------------------------- @@ -110,22 +99,23 @@ public: //----------------------------------------------------------------------------- // A notification issued before the sweep process starts. // -template -void Arr_unb_planar_vert_decomp_helper::before_sweep () +template +void Arr_unb_planar_vert_decomp_helper:: +before_sweep() { // Initialize the fictitious halfedge lying on the top edge of the // bounding rectangle. We start from the leftmost halfedge, which is // incident to the top-left vertex and directed from right to left. - Vertex_const_handle v_tl = - Vertex_const_handle (m_top_traits->top_left_vertex()); + Vertex_const_handle v_tl = + Vertex_const_handle(m_top_traits->top_left_vertex()); m_top_fict = v_tl->incident_halfedges(); if (m_top_fict->direction() == ARR_LEFT_TO_RIGHT) m_top_fict = m_top_fict->next()->twin(); - + CGAL_assertion_code ( - Vertex_const_handle v_tr = - Vertex_const_handle (m_top_traits->top_right_vertex()); + Vertex_const_handle v_tr = + Vertex_const_handle(m_top_traits->top_right_vertex()); ); CGAL_assertion ((m_top_fict->source() == v_tr) || @@ -135,60 +125,52 @@ void Arr_unb_planar_vert_decomp_helper::before_sweep () // Initialize the fictitious halfedge lying on the bottom edge of the // bounding rectangle. We start from the leftmost halfedge, which is // incident to the bottom-left vertex and whose source is not at -oo. - Vertex_const_handle v_bl = - Vertex_const_handle (m_top_traits->bottom_left_vertex()); + Vertex_const_handle v_bl = + Vertex_const_handle(m_top_traits->bottom_left_vertex()); m_bottom_fict = v_bl->incident_halfedges(); if (m_bottom_fict->source()->parameter_space_in_x() == ARR_LEFT_BOUNDARY) m_bottom_fict = m_bottom_fict->next()->twin(); - CGAL_assertion_code ( - Vertex_const_handle v_br = + CGAL_assertion_code( + Vertex_const_handle v_br = Vertex_const_handle (m_top_traits->bottom_right_vertex()); ); CGAL_assertion ((m_bottom_fict->source() == v_br) || (m_bottom_fict->source()->parameter_space_in_x() == ARR_INTERIOR && m_bottom_fict->source()->parameter_space_in_y() == ARR_BOTTOM_BOUNDARY)); - - return; } //----------------------------------------------------------------------------- // A notification invoked after the sweep-line finishes handling the given // event. // -template -void Arr_unb_planar_vert_decomp_helper:: -after_handle_event (Event* event) +template +void Arr_unb_planar_vert_decomp_helper:: +after_handle_event(Event* event) { // If the event is at infinity and occurs on the top edge of the fictitious // face (namely x is finite and y = +oo), we have to update the fictitious // halfedges we keep. - if (event->is_closed()) - return; + if (event->is_closed()) return; - if (event->parameter_space_in_x() != ARR_INTERIOR) - return; + if (event->parameter_space_in_x() != ARR_INTERIOR) return; - Arr_parameter_space ps_y = event->parameter_space_in_y(); + Arr_parameter_space ps_y = event->parameter_space_in_y(); - if (ps_y == ARR_TOP_BOUNDARY) - { + if (ps_y == ARR_TOP_BOUNDARY) { // Update the fictitious top halfedge. m_top_fict = m_top_fict->twin()->next()->twin(); } - else - { + else { CGAL_assertion (ps_y == ARR_BOTTOM_BOUNDARY); // Update the fictitious bottom halfedge. m_bottom_fict = m_bottom_fict->prev(); } - - return; } -} //namespace CGAL +} // namespace CGAL #endif diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_unb_planar_topology_traits_2.h b/Arrangement_on_surface_2/include/CGAL/Arr_unb_planar_topology_traits_2.h index cb9f7ea08bd..ed4f703b667 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_unb_planar_topology_traits_2.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_unb_planar_topology_traits_2.h @@ -25,8 +25,8 @@ #include - /*! \file + * * Definition of the Arr_unb_planar_topology_traits_2 class. */ @@ -43,54 +43,57 @@ namespace CGAL { // Forward declaration: -template +template class Arrangement_on_surface_2; /*! \class Arr_unb_planar_topology_traits_2 + * * A topology-traits class that encapsulates the embedding of 2D arrangements * of unbounded curves on the plane. */ -template > +template > class Arr_unb_planar_topology_traits_2 : - public Arr_planar_topology_traits_base_2 + public Arr_planar_topology_traits_base_2 { +public: + typedef GeometryTraits_2 Geometry_traits_2; + typedef Dcel_ Dcel; + private: - typedef Arr_planar_topology_traits_base_2 - Base; + typedef Geometry_traits_2 Gt2; + typedef Arr_planar_topology_traits_base_2 Base; public: ///! \name The geometry-traits types. //@{ - typedef GeomTraits_ Geometry_traits_2; - typedef typename Base::Point_2 Point_2; - typedef typename Base::X_monotone_curve_2 X_monotone_curve_2; + typedef typename Base::Point_2 Point_2; + typedef typename Base::X_monotone_curve_2 X_monotone_curve_2; //@} ///! \name The DCEL types. //@{ - typedef Dcel_ Dcel; - typedef typename Base::Size Size; - typedef typename Base::Vertex Vertex; - typedef typename Base::Halfedge Halfedge; - typedef typename Base::Face Face; - typedef typename Base::Outer_ccb Outer_ccb; - typedef typename Base::Inner_ccb Inner_ccb; - typedef typename Base::Isolated_vertex Isolated_vertex; + typedef typename Base::Size Size; + typedef typename Base::Vertex Vertex; + typedef typename Base::Halfedge Halfedge; + typedef typename Base::Face Face; + typedef typename Base::Outer_ccb Outer_ccb; + typedef typename Base::Inner_ccb Inner_ccb; + typedef typename Base::Isolated_vertex Isolated_vertex; //@} //! \name Arrangement types //!@{ - typedef Arr_unb_planar_topology_traits_2 Self; - typedef Arr_traits_basic_adaptor_2 Traits_adaptor_2; + typedef Arr_unb_planar_topology_traits_2 Self; + typedef Arr_traits_basic_adaptor_2 Gt_adaptor_2; //!@} ///! \name The side tags //@{ - typedef typename Traits_adaptor_2::Left_side_category Left_side_category; - typedef typename Traits_adaptor_2::Bottom_side_category Bottom_side_category; - typedef typename Traits_adaptor_2::Top_side_category Top_side_category; - typedef typename Traits_adaptor_2::Right_side_category Right_side_category; + typedef typename Gt_adaptor_2::Left_side_category Left_side_category; + typedef typename Gt_adaptor_2::Bottom_side_category Bottom_side_category; + typedef typename Gt_adaptor_2::Top_side_category Top_side_category; + typedef typename Gt_adaptor_2::Right_side_category Right_side_category; BOOST_MPL_ASSERT( (boost::mpl::or_< @@ -144,11 +147,11 @@ public: ///! \name Construction methods. //@{ - /*! Default constructor. */ + /*! Construct Default. */ Arr_unb_planar_topology_traits_2(); /*! Constructor with a geometry-traits class. */ - Arr_unb_planar_topology_traits_2(const Geometry_traits_2* tr); + Arr_unb_planar_topology_traits_2(const Gt2* tr); /*! Assign the contents of another topology-traits class. */ void assign(const Self& other); @@ -166,241 +169,205 @@ public: this->m_dcel.size_of_halfedges() == 8); } - /*! Check if the given vertex is concrete (associated with a point). */ + /*! Check whether the given vertex is concrete (associated with a point). */ bool is_concrete_vertex(const Vertex* v) const - { - return (! v->has_null_point()); - } + { return (! v->has_null_point()); } - /*! Get the number of concrete vertices. */ + /*! Obtain the number of concrete vertices. + * \return All vertices not lying at infinity are concrete. + */ Size number_of_concrete_vertices() const - { - // All vertices not lying at infinity are concrete. - return (this->m_dcel.size_of_vertices() - n_inf_verts); - } + { return (this->m_dcel.size_of_vertices() - n_inf_verts); } /*! Check if the given vertex is valid (not a fictitious one). */ bool is_valid_vertex(const Vertex* v) const { return (! v->has_null_point() || - (v != v_bl && v != v_tl && v != v_br && v != v_tr)); + ((v != v_bl) && (v != v_tl) && (v != v_br) && (v != v_tr))); } - /*! Get the number of valid vertices. */ + /*! Obtain the number of valid vertices. + * \return All vertices, except the four fictitious one, are valid. + */ Size number_of_valid_vertices() const - { - // All vertices, except the four fictitious one, are valid. - return (this->m_dcel.size_of_vertices() - 4); - } + { return (this->m_dcel.size_of_vertices() - 4); } - /*! Check if the given halfedge is valid (not a fictitious one). */ + /*! Check whether the given halfedge is valid (not a fictitious one). */ bool is_valid_halfedge(const Halfedge* he) const - { - return (! he->has_null_curve()); - } + { return (! he->has_null_curve()); } - /*! Get the number of valid halfedges. */ + /*! Obtain the number of valid halfedges. + * \return the number of valid halfedges, not including fictitious halfedges. + * Note that each vertex at infinity induces two fictitious halfedges + */ Size number_of_valid_halfedges() const - { - // Note that we do not count fictitious halfedges (each vertex at infinity - // induces two fictitious halfedges). - return (this->m_dcel.size_of_halfedges() - 2*n_inf_verts); - } + { return (this->m_dcel.size_of_halfedges() - 2*n_inf_verts); } - /*! Check if the given face is valid (not a fictitious one). */ - bool is_valid_face (const Face* f) const - { - return (! f->is_fictitious()); - } + /*! Check whether the given face is valid (not a fictitious one). */ + bool is_valid_face (const Face* f) const { return (! f->is_fictitious()); } - /*! Get the number of valid faces. */ + /*! Obtain the number of valid faces. + * \return the number of valid faces, not including ficitious DCEL faces. + */ Size number_of_valid_faces() const - { - // We do not count the ficitious DCEL face. - return (this->m_dcel.size_of_faces() - 1); - } + { return (this->m_dcel.size_of_faces() - 1); } //@} private: /// \name Auxiliary type definitions. //@{ - typedef Arrangement_on_surface_2 Arr; + typedef Arrangement_on_surface_2 Arr; - // Type definition for the constuction sweep-line visitor. - typedef Arr_construction_subcurve CSubcurve; - typedef Arr_construction_event - CEvent; - typedef Arr_unb_planar_construction_helper CHelper; - - // Type definition for the basic insertion sweep-line visitor. - typedef Arr_basic_insertion_traits_2 BInsTraits; - typedef Arr_construction_subcurve BISubcurve; - typedef Arr_construction_event - BIEvent; - typedef Arr_unb_planar_insertion_helper - BIHelper; - - // Type definition for the insertion sweep-line visitor. - typedef Arr_insertion_traits_2 InsTraits; - typedef Arr_construction_subcurve ISubcurve; - typedef Arr_construction_event - IEvent; - typedef Arr_unb_planar_insertion_helper - IHelper; - - // Type definition for the batched point-location sweep-line visitor. - typedef Arr_batched_point_location_traits_2 BplTraits; - typedef Arr_unb_planar_batched_pl_helper BplHelper; - - // Type definition for the vertical decomposition sweep-line visitor. - typedef Arr_batched_point_location_traits_2 VdTraits; - typedef Arr_unb_planar_vert_decomp_helper VdHelper; - - // Type definition for the overlay sweep-line visitor. - template - struct _Overlay_helper : public Arr_unb_planar_overlay_helper - , - Arr>, - Arr_overlay_subcurve > +public: + // The following definitions of helper functions use a C++11 features called + // alias template. This feature can be mimiked by non C++11 support simply by + // defining a type that inherits from the template we need to alias. However, + // the non-C++11 code requires the (re)definition of all constructors of the + // derived class. +#if defined(CGAL_CFG_NO_CPP0X_TEMPLATE_ALIASES) + // Type definition for the construction surface-sweep visitor. + template + struct Construction_helper : + public Arr_unb_planar_construction_helper { - typedef Arr_unb_planar_overlay_helper - , - Arr>, - Arr_overlay_subcurve > Base; - - typedef typename Base::Traits_2 Traits_2; - typedef typename Base::Arrangement_red_2 Arrangement_red_2; - typedef typename Base::Arrangement_blue_2 Arrangement_blue_2; - typedef typename Base::Arrangement_2 Arrangement_2; - typedef typename Base::Event Event; - typedef typename Base::Subcurve Subcurve; - typedef typename Base::Construction_helper Construction_helper; - - _Overlay_helper(const ArrangementA_* arrA, const ArrangementB_* arrB) : - Base(arrA, arrB) {} + typedef Arr_unb_planar_construction_helper + Base; + Construction_helper(Arr* arr) : Base(arr) {} }; + + // Type definition for the no-intersection construction surface-sweep visitor. + template + struct No_intersection_construction_helper : + public Arr_unb_planar_construction_helper + { + typedef Arr_unb_planar_construction_helper + Base; + No_intersection_construction_helper(Arr* arr) : Base(arr) {} + }; + + // Type definition for the insertion surface-sweep visitor. + typedef Arr_insertion_traits_2 I_traits; + template + struct Insertion_helper : + public Arr_unb_planar_insertion_helper + { + typedef Arr_unb_planar_insertion_helper + Base; + Insertion_helper(Arr* arr) : Base(arr) {} + }; + + // Type definition for the no-intersection insertion surface-sweep visitor. + typedef Arr_basic_insertion_traits_2 Nxi_traits; + template + struct No_intersection_insertion_helper : + public Arr_unb_planar_insertion_helper + { + typedef Arr_unb_planar_insertion_helper + Base; + No_intersection_insertion_helper(Arr* arr) : Base(arr) {} + }; + + // Type definition for the batched point-location surface-sweep visitor. + typedef Arr_batched_point_location_traits_2 Bpl_traits; + template + struct Batched_point_location_helper : + public Arr_unb_planar_batched_pl_helper + { + typedef Arr_unb_planar_batched_pl_helper + Base; + Batched_point_location_helper(const Arr* arr) : Base(arr) {} + }; + + // Type definition for the vertical decomposition surface-sweep visitor. + typedef Arr_batched_point_location_traits_2 Vd_traits; + template + struct Vertical_decomposition_helper : + public Arr_unb_planar_vert_decomp_helper + { + typedef Arr_unb_planar_vert_decomp_helper + Base; + Vertical_decomposition_helper(const Arr* arr) : Base(arr) {} + }; + + // Type definition for the overlay surface-sweep visitor. + template + struct Overlay_helper : + public Arr_unb_planar_overlay_helper + { + typedef Arr_unb_planar_overlay_helper + Base; + Overlay_helper(const ArrA* arr_a, const ArrB* arr_b) : Base(arr_a, arr_b) {} + }; +#else + // Type definition for the construction surface-sweep visitor. + template + using Construction_helper = + Arr_unb_planar_construction_helper; + + // Type definition for the no-intersection construction surface-sweep visitor. + template + using No_intersection_construction_helper = + Arr_unb_planar_construction_helper; + + // Type definition for the insertion surface-sweep visitor. + typedef Arr_insertion_traits_2 I_traits; + template + using Insertion_helper = + Arr_unb_planar_insertion_helper; + + // Type definition for the no-intersection insertion surface-sweep visitor. + typedef Arr_basic_insertion_traits_2 Nxi_traits; + template + using No_intersection_insertion_helper = + Arr_unb_planar_insertion_helper; + + // Type definition for the batched point-location surface-sweep visitor. + typedef Arr_batched_point_location_traits_2 Bpl_traits; + template + using Batched_point_location_helper = + Arr_unb_planar_batched_pl_helper; + + // Type definition for the vertical decomposition surface-sweep visitor. + typedef Arr_batched_point_location_traits_2 Vd_traits; + template + using Vertical_decomposition_helper = + Arr_unb_planar_vert_decomp_helper; + + // Type definition for the overlay surface-sweep visitor. + template + using Overlay_helper = + Arr_unb_planar_overlay_helper; +#endif //@} public: ///! \name Visitor types. //@{ - typedef Arr_construction_sl_visitor - Sweep_line_construction_visitor; - - typedef Arr_insertion_sl_visitor - Sweep_line_insertion_visitor; - - typedef Sweep_line_construction_visitor - Sweep_line_non_intersecting_construction_visitor; - - typedef Arr_basic_insertion_sl_visitor - Sweep_line_non_intersecting_insertion_visitor; - - template - struct Sweep_line_batched_point_location_visitor : - public Arr_batched_pl_sl_visitor - { - typedef OutputIterator_ Output_iterator; - - typedef Arr_batched_pl_sl_visitor Base; - typedef typename Base::Traits_2 Traits_2; - typedef typename Base::Event Event; - typedef typename Base::Subcurve Subcurve; - - Sweep_line_batched_point_location_visitor(const Arr* arr, - Output_iterator& oi) : - Base(arr, oi) - {} - }; - - template - struct Sweep_line_vertical_decomposition_visitor : - public Arr_vert_decomp_sl_visitor - { - typedef OutputIterator_ Output_iterator; - typedef Arr_vert_decomp_sl_visitor - Base; - - typedef typename Base::Traits_2 Traits_2; - typedef typename Base::Event Event; - typedef typename Base::Subcurve Subcurve; - - Sweep_line_vertical_decomposition_visitor(const Arr* arr, - Output_iterator* oi) : - Base(arr, oi) {} - }; - - template - struct Sweep_line_overlay_visitor : - public Arr_overlay_sl_visitor - <_Overlay_helper, - ArrangementA_, - ArrangementB_>, - OverlayTraits_> - { - typedef ArrangementA_ ArrangementA_2; - typedef ArrangementB_ ArrangementB_2; - typedef Arr Arrangement_result_2; - typedef OverlayTraits_ Overlay_traits; - - typedef Arr_overlay_traits_2 Geom_ovl_traits_2; - - typedef _Overlay_helper Ovl_helper; - - typedef Arr_overlay_sl_visitor Base; - - typedef typename Base::Traits_2 Traits_2; - typedef typename Base::Event Event; - typedef typename Base::Subcurve Subcurve; - - Sweep_line_overlay_visitor(const ArrangementA_2* arrA, - const ArrangementB_2* arrB, - Arrangement_result_2* arr_res, - Overlay_traits* overlay_tr) : - Base(arrA, arrB, arr_res, overlay_tr) - {} - }; - typedef Arr_inc_insertion_zone_visitor - Zone_insertion_visitor; + Zone_insertion_visitor; typedef Arr_walk_along_line_point_location - Default_point_location_strategy; + Default_point_location_strategy; typedef Arr_walk_along_line_point_location - Default_vertical_ray_shooting_strategy; + Default_vertical_ray_shooting_strategy; //@} ///! \name Topology-traits methods. //@{ - /*! - * Initialize an empty DCEL structure. + /*! Initialize an empty DCEL structure. */ void init_dcel(); - /*! - * Make the necessary updates after the DCEL structure have been updated. + /*! Make the necessary updates after the DCEL structure have been updated. */ void dcel_updated(); - /*! - * Check if the given vertex is associated with the given curve end. + /*! Check if the given vertex is associated with the given curve end. * \param v The vertex. * \param cv The x-monotone curve. * \param ind The curve end. @@ -413,8 +380,7 @@ public: const X_monotone_curve_2& cv, Arr_curve_end ind, Arr_parameter_space ps_x, Arr_parameter_space ps_y) const; - /*! - * Given a curve end with boundary conditions and a face that contains the + /*! Given a curve end with boundary conditions and a face that contains the * interior of the curve, find a place for a boundary vertex that will * represent the curve end along the face boundary. * \param f The face. @@ -432,8 +398,7 @@ public: Arr_parameter_space ps_x, Arr_parameter_space ps_y); - /*! - * Locate the predecessor halfedge for the given curve around a given + /*! Locate the predecessor halfedge for the given curve around a given * vertex with boundary conditions. * \param v The vertex. * \param cv The x-monotone curve. @@ -455,8 +420,7 @@ public: return (NULL); } - /*! - * Locate a DCEL feature that contains the given unbounded curve end. + /*! Locate a DCEL feature that contains the given unbounded curve end. * \param cv The x-monotone curve. * \param ind The curve end. * \param ps_x The boundary condition of the curve end in x. @@ -471,8 +435,7 @@ public: Arr_parameter_space ps_x, Arr_parameter_space ps_y); - /*! - * Split a fictitious edge using the given vertex. + /*! Split a fictitious edge using the given vertex. * \param e The edge to split (one of the pair of halfedges). * \param v The split vertex. * \pre e is a fictitious halfedge. @@ -481,22 +444,19 @@ public: */ Halfedge* split_fictitious_edge(Halfedge* e, Vertex* v); - /*! - * Determine whether the given face is unbounded. + /*! Determine whether the given face is unbounded. * \param f The face. * \return Whether f is unbounded. */ bool is_unbounded(const Face* f) const; - /*! - * Determine whether the given boundary vertex is redundant. + /*! Determine whether the given boundary vertex is redundant. * \param v The vertex. * \return Whether v is redundant, and should be erased. */ bool is_redundant(const Vertex* v) const; - /*! - * Erase the given redundant vertex by merging a fictitious edge. + /*! Erase the given redundant vertex by merging a fictitious edge. * The function does not free the vertex v itself. * \param v The vertex. * \pre v is a redundant vertex. @@ -536,42 +496,41 @@ public: /*! This function is used by the "walk" point-location strategy. */ const Face* initial_face() const { return fict_face; } - /*! Get the fictitious face (const version). */ + /*! Obtain the fictitious face (const version). */ const Face* fictitious_face() const { return fict_face; } - /*! Get the fictitious face (non-const version). */ + /*! Obtain the fictitious face (non-const version). */ Face* fictitious_face() { return fict_face; } - /*! Get the bottom-left fictitious vertex (const version). */ + /*! Obtain the bottom-left fictitious vertex (const version). */ const Vertex* bottom_left_vertex() const { return (v_bl); } - /*! Get the bottom-left fictitious vertex (non-const version). */ + /*! Obtain the bottom-left fictitious vertex (non-const version). */ Vertex* bottom_left_vertex() { return (v_bl); } - /*! Get the top-left fictitious vertex (const version). */ + /*! Obtain the top-left fictitious vertex (const version). */ const Vertex* top_left_vertex() const { return (v_tl); } - /*! Get the top-left fictitious vertex (non-const version). */ + /*! Obtain the top-left fictitious vertex (non-const version). */ Vertex* top_left_vertex() { return (v_tl); } - /*! Get the bottom-right fictitious vertex (const version). */ + /*! Obtain the bottom-right fictitious vertex (const version). */ const Vertex* bottom_right_vertex() const { return (v_br); } - /*! Get the bottom-right fictitious vertex (non-const version). */ + /*! Obtain the bottom-right fictitious vertex (non-const version). */ Vertex* bottom_right_vertex() { return (v_br); } - /*! Get the top-right fictitious vertex (const version). */ + /*! Obtain the top-right fictitious vertex (const version). */ const Vertex* top_right_vertex() const { return (v_tr); } - /*! Get the top-right fictitious vertex (non-const version). */ + /*! Obtain the top-right fictitious vertex (non-const version). */ Vertex* top_right_vertex() { return (v_tr); } //@} /// \name Additional predicates, specialized for this topology-traits class. //@{ - /*! - * Compare the given vertex (which may lie at infinity) and the given point. + /*! Compare the given vertex (which may lie at infinity) and the given point. * \param p The point. * \param v The vertex. * \return The result of the comparison of the x-coordinates of p and v. @@ -579,8 +538,7 @@ public: virtual Comparison_result compare_x(const Point_2& p, const Vertex* v) const; - /*! - * Compare the given vertex (which may lie at infinity) and the given point. + /*! Compare the given vertex (which may lie at infinity) and the given point. * \param p The point. * \param v The vertex. * \return The result of the xy-lexicographic comparison of p and v. @@ -588,8 +546,7 @@ public: virtual Comparison_result compare_xy(const Point_2& p, const Vertex* v) const; - /*! - * Compare the relative y-position of the given point and the given edge + /*! Compare the relative y-position of the given point and the given edge * (which may be fictitious). * \param p The point. * \param he The edge (one of the pair of halfedges). @@ -605,8 +562,7 @@ protected: /// \name Auxiliary functions. //@{ - /*! - * Get the curve associated with a boundary vertex. + /*! Obtain the curve associated with a boundary vertex. * \param v The vertex as infinity. * \param ind Output: ARR_MIN_END if the vertex is induced by the minimal end; * ARR_MAX_END if it is induced by the curve's maximal end. @@ -615,8 +571,7 @@ protected: */ const X_monotone_curve_2* _curve(const Vertex* v, Arr_curve_end& ind) const; - /*! - * Check whether the given infinite curve end lies on the given fictitious + /*! Check whether the given infinite curve end lies on the given fictitious * halfedge. * \param cv The curve. * \param ind Whether we refer to the minimal or maximal end of cv. @@ -635,7 +590,7 @@ protected: //@} }; -} //namespace CGAL +} // namespace CGAL #include diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_vertical_decomposition_2.h b/Arrangement_on_surface_2/include/CGAL/Arr_vertical_decomposition_2.h index cf3ed530701..e242fcd6477 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_vertical_decomposition_2.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_vertical_decomposition_2.h @@ -23,9 +23,12 @@ #include - #include -#include +#include +#include +#include +#include +#include #include #include @@ -33,8 +36,9 @@ namespace CGAL { -/*! - * Perform a vertical decomposition of an arrangement, by performing a +namespace Ss2 = Surface_sweep_2; + +/*! Perform a vertical decomposition of an arrangement, by performing a * "batched vertical ray-shooting" query from all arrangement vertices. * \param arr The arrangement. * \param oi Output: An output iterator of the vertices, each paired with @@ -46,107 +50,102 @@ namespace CGAL { * pair >, where * the Object represents a handle to an arrangement feature. */ -template +template OutputIterator -decompose(const Arrangement_on_surface_2& arr, +decompose(const Arrangement_on_surface_2& arr, OutputIterator oi) { - // Arrangement types: - typedef Arrangement_on_surface_2 Arrangement_2; - typedef typename TopTraits::template - Sweep_line_vertical_decomposition_visitor - Vd_visitor; + typedef GeometryTraits_2 Gt2; + typedef TopologyTraits Tt; + typedef OutputIterator Output_iterator; - typedef typename Arrangement_2::Vertex_const_iterator Vertex_const_iterator; - typedef typename Arrangement_2::Edge_const_iterator Edge_const_iterator; - typedef typename Arrangement_2::Vertex_const_handle Vertex_const_handle; - typedef typename Arrangement_2::Halfedge_const_handle Halfedge_const_handle; - typedef typename Arrangement_2::X_monotone_curve_2 X_monotone_curve_2; - typedef typename Arrangement_2::Point_2 Point_2; - typedef typename Vd_visitor::Traits_2 Vd_traits_2; - typedef typename Vd_traits_2::X_monotone_curve_2 Vd_x_monotone_curve_2; - typedef typename Vd_traits_2::Point_2 Vd_point_2; + // Arrangement types: + typedef Arrangement_on_surface_2 Arr; + typedef typename Arr::Vertex_const_iterator Vertex_const_iterator; + typedef typename Arr::Edge_const_iterator Edge_const_iterator; + typedef typename Arr::Vertex_const_handle Vertex_const_handle; + typedef typename Arr::Halfedge_const_handle Halfedge_const_handle; + typedef typename Arr::X_monotone_curve_2 X_monotone_curve_2; + typedef typename Arr::Point_2 Point_2; + typedef typename Arr::Allocator Allocator; + + // Surface sweep types: + typedef Arr_batched_point_location_traits_2 Vgt2; + typedef Ss2::No_overlap_event Vd_event; + typedef Ss2::No_overlap_subcurve + Vd_curve; + typedef typename Tt::template + Vertical_decomposition_helper Vd_helper; + typedef Arr_vert_decomp_ss_visitor + Vd_visitor; + typedef typename Vgt2::X_monotone_curve_2 Vd_x_monotone_curve_2; + typedef typename Vgt2::Point_2 Vd_point_2; // Go over all arrangement edges and collect their associated x-monotone // curves. To each curve we attach a halfedge handle going from right to // left. - std::vector xcurves_vec (arr.number_of_edges()); - Edge_const_iterator eit; - Halfedge_const_handle he; - unsigned int i = 0; + std::vector xcurves_vec(arr.number_of_edges()); - for (eit = arr.edges_begin(); eit != arr.edges_end(); ++eit, ++i) - { + size_t i(0); + Edge_const_iterator eit; + for (eit = arr.edges_begin(); eit != arr.edges_end(); ++eit) { // Associate each x-monotone curve with the halfedge that represents it // and is directed from right to left. - if (eit->direction() == ARR_RIGHT_TO_LEFT) - he = eit; - else - he = eit->twin(); + Halfedge_const_handle he = (eit->direction() == ARR_RIGHT_TO_LEFT) ? + eit : eit->twin(); //attempt to solve compile problem in one of the tests. created the // tmp_curve instead of passing eit->curve() as a parmeter to the function X_monotone_curve_2 tmp_curve = eit->curve(); - xcurves_vec[i] = Vd_x_monotone_curve_2 (tmp_curve, he); + xcurves_vec[i++] = Vd_x_monotone_curve_2(tmp_curve, he); } // Go over all isolated vertices and collect their points. To each point // we attach its vertex handle. - std::vector iso_pts_vec (arr.number_of_isolated_vertices()); - Vertex_const_iterator vit; - Vertex_const_handle iso_v; - + std::vector iso_pts_vec(arr.number_of_isolated_vertices()); i = 0; - for (vit = arr.vertices_begin(); vit != arr.vertices_end(); ++vit) - { + Vertex_const_iterator vit; + for (vit = arr.vertices_begin(); vit != arr.vertices_end(); ++vit) { // Associate isolated point with the vertex that represents it. - if (vit->is_isolated()) - { - iso_v = vit; + if (vit->is_isolated()) { + Vertex_const_handle iso_v = vit; //attempt to solve compile problem in one of the tests. created the // tmp_curve instead of passing eit->curve() as a parmeter to the - // function + // function Point_2 tmp_point = vit->point(); - iso_pts_vec[i] = Vd_point_2 (tmp_point, iso_v); - ++i; + iso_pts_vec[i++] = Vd_point_2(tmp_point, iso_v); } } // Obtain a extended traits-class object. - const GeomTraits * geom_traits = arr.geometry_traits(); + const Gt2* geom_traits = arr.geometry_traits(); /* We would like to avoid copy construction of the geometry traits class. * Copy construction is undesired, because it may results with data * duplication or even data loss. * - * If the type Vd_traits_2 is the same as the type - * GeomTraits, use a reference to GeomTraits to avoid constructing a new one. - * Otherwise, instantiate a local variable of the former and provide - * the later as a single parameter to the constructor. - * + * If the type Vgt2 is the same as the type Gt2, use a + * reference to Gt2 to avoid constructing a new one. Otherwise, + * instantiate a local variable of the former and provide the later as a + * single parameter to the constructor. + * * Use the form 'A a(*b);' and not ''A a = b;' to handle the case where A has * only an implicit constructor, (which takes *b as a parameter). */ - typename boost::mpl::if_, - const Vd_traits_2&, Vd_traits_2>::type + typename boost::mpl::if_, const Vgt2&, Vgt2>::type ex_traits(*geom_traits); // Define the sweep-line visitor and perform the sweep. - Vd_visitor visitor (&arr, &oi); - Basic_sweep_line_2 - sweep_line (&ex_traits, &visitor); - - sweep_line.sweep (xcurves_vec.begin(), xcurves_vec.end(), // Curves. - iso_pts_vec.begin(), iso_pts_vec.end()); // Action points. + Vd_visitor visitor(&arr, &oi); + Ss2::No_intersection_surface_sweep_2 + surface_sweep(&ex_traits, &visitor); + surface_sweep.sweep(xcurves_vec.begin(), xcurves_vec.end(), // Curves. + iso_pts_vec.begin(), iso_pts_vec.end()); // Action points. // Return a past-the-end iterator. - return (oi); + return oi; } - -} //namespace CGAL +} // namespace CGAL #endif diff --git a/Arrangement_on_surface_2/include/CGAL/Arrangement_2/Arr_default_planar_topology.h b/Arrangement_on_surface_2/include/CGAL/Arrangement_2/Arr_default_planar_topology.h index 6f56de73d3f..aab44a137d0 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arrangement_2/Arr_default_planar_topology.h +++ b/Arrangement_on_surface_2/include/CGAL/Arrangement_2/Arr_default_planar_topology.h @@ -15,7 +15,7 @@ // $URL$ // $Id$ // SPDX-License-Identifier: GPL-3.0+ -// +// // // Author(s): Ron Wein // Eric Berberich @@ -45,8 +45,8 @@ template struct Default_planar_topology_impl {}; template -struct Default_planar_topology_impl< GeomTraits, Dcel, - Arr_all_sides_oblivious_tag> +struct Default_planar_topology_impl { // A topology-traits class that supports only bounded curves: typedef Arr_bounded_planar_topology_traits_2 Traits; @@ -54,25 +54,24 @@ struct Default_planar_topology_impl< GeomTraits, Dcel, }; template -struct Default_planar_topology_impl< GeomTraits, Dcel, - Arr_not_all_sides_oblivious_tag> +struct Default_planar_topology_impl { // A topology-traits class that supports unbounded curves: typedef Arr_unb_planar_topology_traits_2 Traits; }; - } // namespace internal -template < class GeomTraits, class Dcel > -struct Default_planar_topology : - public internal::Default_planar_topology_impl < - GeomTraits, Dcel, - typename Arr_are_all_sides_oblivious_tag< - typename internal::Arr_complete_left_side_category< GeomTraits >::Category, - typename internal::Arr_complete_bottom_side_category< GeomTraits> ::Category, - typename internal::Arr_complete_top_side_category< GeomTraits >::Category, - typename internal::Arr_complete_right_side_category< GeomTraits >::Category >::result +template +struct Default_planar_topology : + public internal::Default_planar_topology_impl< + GeomTraits, Dcel, + typename Arr_are_all_sides_oblivious_tag< + typename internal::Arr_complete_left_side_category::Category, + typename internal::Arr_complete_bottom_side_category::Category, + typename internal::Arr_complete_top_side_category::Category, + typename internal::Arr_complete_right_side_category::Category>::result > {}; diff --git a/Arrangement_on_surface_2/include/CGAL/Arrangement_2/Arrangement_on_surface_2_global.h b/Arrangement_on_surface_2/include/CGAL/Arrangement_2/Arrangement_on_surface_2_global.h index 555d004e6ca..c624e260824 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arrangement_2/Arrangement_on_surface_2_global.h +++ b/Arrangement_on_surface_2/include/CGAL/Arrangement_2/Arrangement_on_surface_2_global.h @@ -26,35 +26,42 @@ #include - /*! \file * Global insertion functions for the Arrangement_2 class. */ #include #include +#include +#include #include #include -#include -#include #include #include #include #include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include - #include -#include - -#include - namespace CGAL { +namespace Ss2 = Surface_sweep_2; + //----------------------------------------------------------------------------- // Insert a curve into the arrangement (incremental insertion). // The inserted curve may intersect the existing arrangement. @@ -69,44 +76,44 @@ namespace CGAL { // const Arr_segment_2&, const Arr_walk_along_line_point_location<>&, // mpl_::bool_< true>)' // -template -void insert (Arrangement_on_surface_2& arr, - const typename GeomTraits::Curve_2& c, - const PointLocation& pl, ZoneVisitor &visitor, - boost::is_same::type) +template +void insert(Arrangement_on_surface_2& arr, + const typename GeometryTraits_2::Curve_2& c, + const PointLocation& pl, ZoneVisitor &visitor, + boost::is_same::type) { - typedef Arrangement_on_surface_2 Arr; - typedef ZoneVisitor Zone_visitor; + typedef GeometryTraits_2 Gt2; + typedef TopologyTraits Tt; + + typedef Arrangement_on_surface_2 Arr; + typedef ZoneVisitor Zone_visitor; // Obtain an arrangement accessor. - Arr_accessor arr_access (arr); + Arr_accessor arr_access(arr); // Initialize a zone-computation object an a visitor that performs the // incremental insertion. - Arrangement_zone_2 arr_zone (arr, &visitor); + Arrangement_zone_2 arr_zone(arr, &visitor); // Break the input curve into x-monotone subcurves and isolated points. - std::list x_objects; - std::list::const_iterator obj_iter; - const typename GeomTraits::X_monotone_curve_2 *x_curve; - const typename GeomTraits::Point_2 *iso_p; + std::list x_objects; + std::list::const_iterator obj_iter; + const typename Gt2::X_monotone_curve_2* x_curve; + const typename Gt2::Point_2* iso_p; - arr.geometry_traits()->make_x_monotone_2_object() - (c, std::back_inserter (x_objects)); + arr.geometry_traits()-> + make_x_monotone_2_object()(c, std::back_inserter(x_objects)); // Insert each x-monotone curve into the arrangement. - for (obj_iter = x_objects.begin(); obj_iter != x_objects.end(); ++obj_iter) - { + for (obj_iter = x_objects.begin(); obj_iter != x_objects.end(); ++obj_iter) { // Act according to the type of the current object. - x_curve = - object_cast (&(*obj_iter)); + x_curve = object_cast(&(*obj_iter)); - if (x_curve != NULL) - { + if (x_curve != NULL) { // Inserting an x-monotone curve: // Initialize the zone-computation object with the given curve. - arr_zone.init (*x_curve, pl); + arr_zone.init(*x_curve, pl); // Notify the arrangement observers that a global operation is about to // take place. @@ -119,13 +126,12 @@ void insert (Arrangement_on_surface_2& arr, // completed. arr_access.notify_after_global_change(); } - else - { - iso_p = object_cast (&(*obj_iter)); - CGAL_assertion (iso_p != NULL); + else { + iso_p = object_cast(&(*obj_iter)); + CGAL_assertion(iso_p != NULL); // Inserting a point into the arrangement: - insert_point (arr, *iso_p, pl); + insert_point(arr, *iso_p, pl); } } } @@ -144,46 +150,28 @@ void insert (Arrangement_on_surface_2& arr, // mpl_::bool_< true>)' // // -template -void insert(Arrangement_on_surface_2& arr, - const typename GeomTraits::X_monotone_curve_2& c, +template +void insert(Arrangement_on_surface_2& arr, + const typename GeometryTraits_2::X_monotone_curve_2& c, const PointLocation& pl, ZoneVisitor &visitor, boost::is_same::type) { - typedef Arrangement_on_surface_2 Arr; - typedef ZoneVisitor Zone_visitor; + typedef GeometryTraits_2 Gt2; + typedef TopologyTraits Tt; + + typedef Arrangement_on_surface_2 Arr; + typedef ZoneVisitor Zone_visitor; // Obtain an arrangement accessor. - Arr_accessor arr_access (arr); + Arr_accessor arr_access(arr); // Initialize a zone-computation object an a visitor that performs the // incremental insertion. - Arrangement_zone_2 arr_zone (arr, &visitor); + Arrangement_zone_2 arr_zone(arr, &visitor); // Initialize the zone-computation object with the given curve. - -/* Needs to be deleted!!! - { - std::cout << std::endl; - std::cout << "xxxxxxxxxxxx" << std::endl; - std::cout << "c: " << c << std::endl; - std::cout << std::endl; - typename Arr::Vertex_const_iterator vit; - std::cout << arr.number_of_vertices() << " vertices:" << std::endl; - for (vit = arr.vertices_begin(); vit != arr.vertices_end(); ++vit) - { - std::cout << "(" << vit->point() << ")"; - if (vit->is_isolated()) - std::cout << " - Isolated." << std::endl; - else - std::cout << " - degree " << vit->degree() << std::endl; - } - std::cout << std::endl; - std::cout << "xxxxxxxxxxxx" << std::endl; - } -*/ - arr_zone.init (c, pl); + arr_zone.init(c, pl); // Notify the arrangement observers that a global operation is about to // take place. @@ -199,13 +187,13 @@ void insert(Arrangement_on_surface_2& arr, //----------------------------------------------------------------------------- // Common interface for the insert of the Curve_2 and X_monotone_curve_2 -template -void insert (Arrangement_on_surface_2& arr, - const Curve& c, const PointLocation& pl, ZoneVisitor &visitor) +template +void insert(Arrangement_on_surface_2& arr, + const Curve& c, const PointLocation& pl, ZoneVisitor &visitor) { - typedef typename GeomTraits::X_monotone_curve_2 X_monotone_curve_2; - + typedef GeometryTraits_2 Gt2; + typedef typename Gt2::X_monotone_curve_2 X_monotone_curve_2; typedef typename boost::is_same::type Is_x_monotone; @@ -217,15 +205,18 @@ void insert (Arrangement_on_surface_2& arr, // For now the solution is to add a dummy variable at the end (referring // to point-location). Maybe the proper solution is to use boost::enable_if // together with appropriate tag. -template -void insert (Arrangement_on_surface_2& arr, - const Curve& c, const PointLocation& pl, - typename PointLocation::Point_2*) +template +void insert(Arrangement_on_surface_2& arr, + const Curve& c, const PointLocation& pl, + typename PointLocation::Point_2*) { - typedef typename TopTraits::Zone_insertion_visitor Zone_visitor; + typedef TopologyTraits Tt; + + typedef typename Tt::Zone_insertion_visitor Zone_visitor; Zone_visitor visitor; - insert (arr, c, pl, visitor); + insert(arr, c, pl, visitor); } //----------------------------------------------------------------------------- @@ -235,14 +226,16 @@ void insert (Arrangement_on_surface_2& arr, // Overloaded version with no point location object - using the default point // location. // -template -void insert(Arrangement_on_surface_2& arr, +template +void insert(Arrangement_on_surface_2& arr, const Curve& c) { - // Create a default point-location object and use it to insert the curve. - typename TopTraits::Default_point_location_strategy def_pl (arr); + typedef TopologyTraits Tt; - insert (arr, c, def_pl); + // Create a default point-location object and use it to insert the curve. + typename Tt::Default_point_location_strategy def_pl(arr); + + insert(arr, c, def_pl); } /*! Insert a range of x-monotone curves into an empty arrangement @@ -250,39 +243,50 @@ void insert(Arrangement_on_surface_2& arr, * \param begin the begining of the curve range * \param end past-the-end curve range */ -template -void insert_empty(Arrangement_on_surface_2& arr, - InputIterator begin_xcurves, InputIterator end_xcurves) +template +void +insert_empty(Arrangement_on_surface_2& arr, + InputIterator begin_xcurves, InputIterator end_xcurves) { - typedef typename TopTraits::Sweep_line_construction_visitor - Construct_visitor; - typedef typename Construct_visitor::Traits_2 Construct_traits; + typedef GeometryTraits_2 Gt2; + typedef TopologyTraits Tt; - const GeomTraits * geom_traits = arr.geometry_traits(); - Construct_visitor visitor(&arr); + // Arrangement types + typedef Arrangement_on_surface_2 Arr; + typedef typename Arr::Allocator Allocator; + + // Surface sweep types + typedef Arr_construction_event C_event; + typedef Arr_construction_subcurve + C_curve; + typedef typename Tt::template Construction_helper + C_helper; + typedef Arr_construction_ss_visitor C_visitor; + + typedef typename C_visitor::Geometry_traits_2 Cgt2; + + const Gt2* geom_traits = arr.geometry_traits(); + C_visitor visitor(&arr); /* We would like to avoid copy construction of the geometry traits class. * Copy construction is undesired, because it may results with data * duplication or even data loss. * - * If the type Construct_visitor::Traits_2 is the same as the type - * GeomTraits, use a reference to GeomTraits to avoid constructing a new one. - * Otherwise, instantiate a local variable of the former and provide - * the later as a single parameter to the constructor. + * If the type C_visitor::Geometry_traits_2 is the same as the type + * GeometryTraits_2, use a reference to GeometryTraits_2 to avoid constructing + * a new one. Otherwise, instantiate a local variable of the former and + * provide the later as a single parameter to the constructor. * * Use the form 'A a(*b);' and not ''A a = b;' to handle the case where A has * only an implicit constructor, (which takes *b as a parameter). */ - typename boost::mpl::if_, - const Construct_traits&, Construct_traits>::type + typename boost::mpl::if_, const Cgt2&, Cgt2>::type traits(*geom_traits); - // Define a sweep-line instance and perform the sweep: - Sweep_line_2 - sweep_line(&traits, &visitor); - sweep_line.sweep(begin_xcurves, end_xcurves); + // Define a surface-sweep instance and perform the sweep: + Ss2::Surface_sweep_2 surface_sweep(&traits, &visitor); + surface_sweep.sweep(begin_xcurves, end_xcurves); } /*! Insert a range of x-monotone curves and a range of isolated points into @@ -293,41 +297,51 @@ void insert_empty(Arrangement_on_surface_2& arr, * \param begin_points the begining of the point range * \param end_points past-the-end point range */ -template -void insert_empty(Arrangement_on_surface_2& arr, +void insert_empty(Arrangement_on_surface_2& + arr, XcInputIterator begin_xcurves, XcInputIterator end_xcurves, PInputIterator begin_points, PInputIterator end_points) { - typedef typename TopTraits::Sweep_line_construction_visitor - Construct_visitor; - typedef typename Construct_visitor::Traits_2 Construct_traits; + typedef GeometryTraits_2 Gt2; + typedef TopologyTraits Tt; - const GeomTraits * geom_traits = arr.geometry_traits(); - Construct_visitor visitor(&arr); + // Arrangement types + typedef Arrangement_on_surface_2 Arr; + typedef typename Arr::Allocator Allocator; + + // Surface sweep types + typedef Arr_construction_event C_event; + typedef Arr_construction_subcurve + C_curve; + typedef typename Tt::template Construction_helper + C_helper; + typedef Arr_construction_ss_visitor C_visitor; + + typedef typename C_visitor::Geometry_traits_2 Cgt2; + + const Gt2* geom_traits = arr.geometry_traits(); + C_visitor visitor(&arr); /* We would like to avoid copy construction of the geometry traits class. * Copy construction is undesired, because it may results with data * duplication or even data loss. * - * If the type Construct_visitor::Traits_2 is the same as the type - * GeomTraits, use a reference to GeomTraits to avoid constructing a new one. - * Otherwise, instantiate a local variable of the former and provide - * the later as a single parameter to the constructor. + * If the type C_visitor::Geometry_traits_2 is the same as the type + * GeometryTraits_2, use a reference to GeometryTraits_2 to avoid constructing + * a new one. Otherwise, instantiate a local variable of the former and + * provide the later as a single parameter to the constructor. * * Use the form 'A a(*b);' and not ''A a = b;' to handle the case where A has * only an implicit constructor, (which takes *b as a parameter). */ - typename boost::mpl::if_, - const Construct_traits&, Construct_traits>::type + typename boost::mpl::if_, const Cgt2&, Cgt2>::type traits(*geom_traits); - // Define a sweep-line instance and perform the sweep. - Sweep_line_2 - sweep_line(&traits, &visitor); - sweep_line.sweep(begin_xcurves, end_xcurves, begin_points, end_points); + // Define a surface-sweep instance and perform the sweep. + Ss2::Surface_sweep_2 surface_sweep(&traits, &visitor); + surface_sweep.sweep(begin_xcurves, end_xcurves, begin_points, end_points); } /*! Insert a range of x-monotone curves into a non-empty arrangement @@ -335,56 +349,63 @@ void insert_empty(Arrangement_on_surface_2& arr, * \param begin the begining of the curve range * \param end past-the-end curve range */ -template -void insert_non_empty(Arrangement_on_surface_2& arr, - XcInputIterator begin_xcurves, - XcInputIterator end_xcurves, +void insert_non_empty(Arrangement_on_surface_2& arr, + XcInputIterator begin_xcurves, XcInputIterator end_xcurves, PInputIterator begin_points, PInputIterator end_points) { - typedef typename TopTraits::Sweep_line_insertion_visitor - Insert_visitor; - typedef typename Insert_visitor::Traits_2 Insert_traits; - typedef typename Insert_visitor::Traits_2::X_monotone_curve_2 - Ex_x_monotone_curve_2; - typedef typename Insert_visitor::Traits_2::Point_2 Ex_point_2; + typedef GeometryTraits_2 Gt2; + typedef TopologyTraits Tt; - const GeomTraits * geom_traits = arr.geometry_traits(); - Insert_visitor visitor(&arr); + // Arrangement types + typedef Arrangement_on_surface_2 Arr; + typedef typename Arr::Allocator Allocator; + + // Surface sweep types + typedef Arr_insertion_traits_2 Igt2; + typedef Arr_construction_event I_event; + typedef Arr_construction_subcurve + I_curve; + typedef typename Tt::template Insertion_helper + I_helper; + typedef Arr_insertion_ss_visitor I_visitor; + typedef typename Igt2::X_monotone_curve_2 Ex_x_monotone_curve_2; + typedef typename Igt2::Point_2 Ex_point_2; + + const Gt2* geom_traits = arr.geometry_traits(); + I_visitor visitor(&arr); /* We would like to avoid copy construction of the geometry traits class. * Copy construction is undesired, because it may results with data * duplication or even data loss. * - * If the type Construct_visitor::Traits_2 is the same as the type - * GeomTraits, use a reference to GeomTraits to avoid constructing a new one. - * Otherwise, instantiate a local variable of the former and provide - * the later as a single parameter to the constructor. + * If the type Igt2 is the same as the type + * GeometryTraits_2, use a reference to GeometryTraits_2 to avoid constructing + * a new one. Otherwise, instantiate a local variable of the former and + * provide the later as a single parameter to the constructor. * * Use the form 'A a(*b);' and not ''A a = b;' to handle the case where A has * only an implicit constructor, (which takes *b as a parameter). */ - typename boost::mpl::if_, - const Insert_traits&, Insert_traits>::type + typename boost::mpl::if_, const Igt2&, Igt2>::type traits(*geom_traits); // Create a set of existing as well as new curves and points. std::list ex_cvs; std::list ex_pts; - prepare_for_sweep(arr, - begin_xcurves, end_xcurves, // the x-monotone curves - begin_points, end_points, // the points (if any) - std::back_inserter(ex_cvs), - std::back_inserter(ex_pts), - &traits); + Ss2::prepare_for_sweep(arr, + begin_xcurves, end_xcurves, // the x-monotone curves + begin_points, end_points, // the points (if any) + std::back_inserter(ex_cvs), + std::back_inserter(ex_pts), + &traits); - // Define a basic sweep-line instance and perform the sweep. - Sweep_line_2 - sweep_line(&traits, &visitor); - sweep_line.sweep(ex_cvs.begin(), ex_cvs.end(),ex_pts.begin(), ex_pts.end()); + // Define a basic surface-sweep instance and perform the sweep. + Ss2::Surface_sweep_2 surface_sweep(&traits, &visitor); + surface_sweep.sweep(ex_cvs.begin(), ex_cvs.end(),ex_pts.begin(), ex_pts.end()); } //----------------------------------------------------------------------------- @@ -402,37 +423,40 @@ void insert_non_empty(Arrangement_on_surface_2& arr, // const Arr_segment_2&, const Arr_walk_along_line_point_location<>&, // mpl_::bool_< true>)' // -template -void insert (Arrangement_on_surface_2& arr, - InputIterator begin, InputIterator end, - boost::is_same::type) +template +void insert(Arrangement_on_surface_2& arr, + InputIterator begin, InputIterator end, + boost::is_same::type) { - typedef Arrangement_on_surface_2 Arr; - typedef typename GeomTraits::Point_2 Point_2; - typedef typename GeomTraits::X_monotone_curve_2 X_monotone_curve_2; + typedef GeometryTraits_2 Gt2; + typedef TopologyTraits Tt; + + typedef Arrangement_on_surface_2 Arr; + typedef typename Gt2::Point_2 Point_2; + typedef typename Gt2::X_monotone_curve_2 X_monotone_curve_2; // Obtain an arrangement accessor. - Arr_accessor arr_access (arr); + Arr_accessor arr_access(arr); // Notify the arrangement observers that a global operation is about to // take place. arr_access.notify_before_global_change(); // Subdivide the input curves into x-monotone subcurves and isolated points. - const GeomTraits * geom_traits = arr.geometry_traits(); - std::list xcurves; - std::list iso_points; + const Gt2* geom_traits = arr.geometry_traits(); + std::list xcurves; + std::list iso_points; - make_x_monotone(begin, end, - std::back_inserter(xcurves), std::back_inserter(iso_points), - geom_traits); + Ss2::make_x_monotone(begin, end, + std::back_inserter(xcurves), + std::back_inserter(iso_points), + geom_traits); - if (arr.is_empty()) - insert_empty(arr, xcurves.begin(), xcurves.end(), - iso_points.begin(), iso_points.end()); - else - insert_non_empty(arr, xcurves.begin(), xcurves.end(), - iso_points.begin(), iso_points.end()); + if (arr.is_empty()) insert_empty(arr, xcurves.begin(), xcurves.end(), + iso_points.begin(), iso_points.end()); + else insert_non_empty(arr, xcurves.begin(), xcurves.end(), + iso_points.begin(), iso_points.end()); // Notify the arrangement observers that the global operation has been // completed. @@ -453,15 +477,19 @@ void insert (Arrangement_on_surface_2& arr, // const Arr_segment_2&, const Arr_walk_along_line_point_location<>&, // mpl_::bool_< true>)' // -template -void insert(Arrangement_on_surface_2& arr, +template +void insert(Arrangement_on_surface_2& arr, InputIterator begin, InputIterator end, boost::is_same::type) { - typedef Arrangement_on_surface_2 Arr; + typedef GeometryTraits_2 Gt2; + typedef TopologyTraits Tt; + + typedef Arrangement_on_surface_2 Arr; // Obtain an arrangement accessor. - Arr_accessor arr_access (arr); + Arr_accessor arr_access(arr); // Notify the arrangement observers that a global operation is about to // take place. @@ -470,11 +498,10 @@ void insert(Arrangement_on_surface_2& arr, // Choose the operation depending on whether the input arrangement is // empty (then we construct it from scratch), or not (where we just insert // the new curves). - if (arr.is_empty()) - insert_empty(arr, begin, end); + if (arr.is_empty()) insert_empty(arr, begin, end); else { // The arrangement is not empty: use the insertion visitor. - std::list empty; + std::list empty; insert_non_empty(arr, begin, end, empty.begin(), empty.end()); } @@ -485,18 +512,21 @@ void insert(Arrangement_on_surface_2& arr, //----------------------------------------------------------------------------- // Common interface for the inserts of the Curve_2 and X_monotone_curve_2 -template -void insert (Arrangement_on_surface_2& arr, - InputIterator begin, InputIterator end) +template +void insert(Arrangement_on_surface_2& arr, + InputIterator begin, InputIterator end) { - typedef typename GeomTraits::X_monotone_curve_2 X_monotone_curve_2; + typedef GeometryTraits_2 Gt2; + + typedef typename Gt2::X_monotone_curve_2 X_monotone_curve_2; typedef typename std::iterator_traits::value_type - Iterator_value_type; + Iterator_value_type; typedef typename boost::is_same::type - Is_x_monotone; + Is_x_monotone; - return insert (arr, begin, end, Is_x_monotone()); + return insert(arr, begin, end, Is_x_monotone()); } //----------------------------------------------------------------------------- @@ -505,24 +535,27 @@ void insert (Arrangement_on_surface_2& arr, // given as an isertion hint. // The inserted x-monotone curve may intersect the existing arrangement. // -template -void insert (Arrangement_on_surface_2& arr, - const typename GeomTraits::X_monotone_curve_2& c, - const Object& obj) +template +void insert(Arrangement_on_surface_2& arr, + const typename GeometryTraits_2::X_monotone_curve_2& c, + const Object& obj) { - typedef Arrangement_on_surface_2 Arr; - typedef typename TopTraits::Zone_insertion_visitor Zone_visitor; + typedef GeometryTraits_2 Gt2; + typedef TopologyTraits Tt; + + typedef Arrangement_on_surface_2 Arr; + typedef typename Tt::Zone_insertion_visitor Zone_visitor; // Obtain an arrangement accessor. - Arr_accessor arr_access (arr); + Arr_accessor arr_access(arr); // Define a zone-computation object an a visitor that performs the // incremental insertion. - Zone_visitor visitor; - Arrangement_zone_2 arr_zone (arr, &visitor); + Zone_visitor visitor; + Arrangement_zone_2 arr_zone(arr, &visitor); // Initialize the zone-computation object with the given curve. - arr_zone.init_with_hint (c, obj); + arr_zone.init_with_hint(c, obj); // Notify the arrangement observers that a global operation is about to // take place. @@ -539,67 +572,74 @@ void insert (Arrangement_on_surface_2& arr, // ---------------------------------------------------------------------------- // backward compatibility functions. /* DEPRECATED use insert() instead */ -template +template CGAL_DEPRECATED void insert_x_monotone_curve -(Arrangement_on_surface_2& arr, - const typename GeomTraits::X_monotone_curve_2& c, +(Arrangement_on_surface_2& arr, + const typename GeometryTraits_2::X_monotone_curve_2& c, const PointLocation& pl) { insert(arr, c, pl); } /* DEPRECATED use insert() instead */ -template +template CGAL_DEPRECATED void insert_x_monotone_curve -(Arrangement_on_surface_2& arr, - const typename GeomTraits::X_monotone_curve_2& c) +(Arrangement_on_surface_2& arr, + const typename GeometryTraits_2::X_monotone_curve_2& c) { insert(arr, c); } /* DEPRECATED use insert() instead */ -template +template CGAL_DEPRECATED void insert_x_monotone_curves -(Arrangement_on_surface_2& arr, +(Arrangement_on_surface_2& arr, InputIterator begin, InputIterator end) { insert(arr, begin, end); } /* DEPRECATED use insert() instead */ -template +template CGAL_DEPRECATED void insert_x_monotone_curve -(Arrangement_on_surface_2& arr, - const typename GeomTraits::X_monotone_curve_2& c, +(Arrangement_on_surface_2& arr, + const typename GeometryTraits_2::X_monotone_curve_2& c, const Object& obj) { insert(arr, c, obj); } /* DEPRECATED use insert() instead */ -template +template CGAL_DEPRECATED -void insert_curve(Arrangement_on_surface_2& arr, - const typename GeomTraits::Curve_2& c, +void insert_curve(Arrangement_on_surface_2& + arr, + const typename GeometryTraits_2::Curve_2& c, const PointLocation& pl) { insert(arr, c, pl); } /* DEPRECATED use insert() instead */ -template +template CGAL_DEPRECATED -void insert_curve(Arrangement_on_surface_2& arr, - const typename GeomTraits::Curve_2& c) +void insert_curve(Arrangement_on_surface_2& + arr, + const typename GeometryTraits_2::Curve_2& c) { insert(arr, c); } /* DEPRECATED use insert() instead */ -template +template CGAL_DEPRECATED -void insert_curves (Arrangement_on_surface_2& arr, - InputIterator begin, InputIterator end) +void insert_curves(Arrangement_on_surface_2& + arr, + InputIterator begin, InputIterator end) { insert(arr, begin, end); } @@ -609,30 +649,35 @@ void insert_curves (Arrangement_on_surface_2& arr, // interior does not intersect with any existing edge or vertex in the // arragement (incremental insertion). // -template -typename Arrangement_on_surface_2::Halfedge_handle +template +typename Arrangement_on_surface_2:: +Halfedge_handle insert_non_intersecting_curve -(Arrangement_on_surface_2& arr, - const typename GeomTraits::X_monotone_curve_2& c, +(Arrangement_on_surface_2& arr, + const typename GeometryTraits_2::X_monotone_curve_2& c, const PointLocation& pl) { - typedef Arrangement_on_surface_2 Arr; + typedef GeometryTraits_2 Gt2; + typedef TopologyTraits Tt; + + typedef Arrangement_on_surface_2 Arr; typedef Arr_traits_basic_adaptor_2 - Traits_adaptor_2; - typedef typename Arr::Vertex_const_handle Vertex_const_handle; - typedef typename Arr::Halfedge_const_handle Halfedge_const_handle; + Traits_adaptor_2; + typedef typename Arr::Vertex_const_handle Vertex_const_handle; + typedef typename Arr::Halfedge_const_handle Halfedge_const_handle; CGAL_USE_TYPE(Halfedge_const_handle); const Traits_adaptor_2* geom_traits = - static_cast (arr.geometry_traits()); + static_cast(arr.geometry_traits()); Arr_accessor arr_access(arr); // Check whether the left end has boundary conditions, and locate it in the // arrangement accordingly. - const Arr_parameter_space bx1 = + const Arr_parameter_space bx1 = geom_traits->parameter_space_in_x_2_object()(c, ARR_MIN_END); - const Arr_parameter_space by1 = + const Arr_parameter_space by1 = geom_traits->parameter_space_in_y_2_object()(c, ARR_MIN_END); CGAL::Object obj1; const Vertex_const_handle* vh1 = NULL; @@ -775,16 +820,19 @@ insert_non_intersecting_curve // arragement (incremental insertion). // Overloaded version with no point location object. // -template -typename Arrangement_on_surface_2::Halfedge_handle +template +typename Arrangement_on_surface_2:: +Halfedge_handle insert_non_intersecting_curve - (Arrangement_on_surface_2& arr, - const typename GeomTraits::X_monotone_curve_2& c) +(Arrangement_on_surface_2& arr, + const typename GeometryTraits_2::X_monotone_curve_2& c) { - // Create a default point-location object and use it to insert the curve. - typename TopTraits::Default_point_location_strategy def_pl (arr); + typedef TopologyTraits Tt; - return (insert_non_intersecting_curve (arr, c, def_pl)); + // Create a default point-location object and use it to insert the curve. + typename Tt::Default_point_location_strategy def_pl(arr); + + return (insert_non_intersecting_curve(arr, c, def_pl)); } /*! Insert a range of x-monotone curves into an empty arrangement @@ -792,25 +840,48 @@ insert_non_intersecting_curve * \param begin the begining of the curve range * \param end past-the-end curve range */ -template -void non_intersecting_insert_empty(Arrangement_on_surface_2& arr, +template +void non_intersecting_insert_empty(Arrangement_on_surface_2& arr, InputIterator begin_xcurves, InputIterator end_xcurves) { - const GeomTraits * geom_traits = arr.geometry_traits(); - typedef typename TopTraits::Sweep_line_non_intersecting_construction_visitor - Construct_visitor; - Construct_visitor visitor(&arr); - typename Construct_visitor::Traits_2 traits(*geom_traits); + typedef GeometryTraits_2 Gt2; + typedef TopologyTraits Tt; - // Define a basic sweep-line instance (which is not supposed to handle + // Arrangement types + typedef Arrangement_on_surface_2 Arr; + typedef typename Arr::Allocator Allocator; + + // Surface sweep types + + // The forth parameter of Arr_construction_subcurve is the base class of + // Arr_construction_subcurve. By default Arr_construction_subcurve derives + // from Default_subcurve, which is suitable for general curves + // including overlapping curves. Here we bypass Default_subcurve and + // force Arr_construction_subcurve to derive directly from + // No_overlap_subcurve (which is the base class of Default_subcurve). + typedef Arr_construction_event + Nxc_event; + typedef Arr_construction_subcurve + Nxc_curve; + typedef typename Tt::template No_intersection_construction_helper + Nxc_helper; + typedef Arr_construction_ss_visitor Nxc_visitor; + + const Gt2* traits = arr.geometry_traits(); + Nxc_visitor visitor(&arr); + + // Define a basic surface-sweep instance (which is not supposed to handle // insersections) and perform the sweep. - Basic_sweep_line_2 - sweep_line(&traits, &visitor); - sweep_line.sweep(begin_xcurves, end_xcurves); + Ss2::No_intersection_surface_sweep_2 + surface_sweep(traits, &visitor); + surface_sweep.sweep(begin_xcurves, end_xcurves); } /*! Insert a range of x-monotone curves into an empty arrangement @@ -818,45 +889,50 @@ void non_intersecting_insert_empty(Arrangement_on_surface_2 -void non_intersecting_insert_empty(Arrangement_on_surface_2& arr, +void non_intersecting_insert_empty(Arrangement_on_surface_2& arr, XcInputIterator begin_xcurves, XcInputIterator end_xcurves, PInputIterator begin_points, PInputIterator end_points) { - typedef typename TopTraits::Sweep_line_non_intersecting_construction_visitor - Construct_visitor; - typedef typename Construct_visitor::Traits_2 Construct_traits; + typedef GeometryTraits_2 Gt2; + typedef TopologyTraits Tt; - const GeomTraits * geom_traits = arr.geometry_traits(); - Construct_visitor visitor(&arr); + // Arrangement types + typedef Arrangement_on_surface_2 Arr; + typedef typename Arr::Allocator Allocator; - /* We would like to avoid copy construction of the geometry traits class. - * Copy construction is undesired, because it may results with data - * duplication or even data loss. - * - * If the type Construct_visitor::Traits_2 is the same as the type - * GeomTraits, use a reference to GeomTraits to avoid constructing a new one. - * Otherwise, instantiate a local variable of the former and provide - * the later as a single parameter to the constructor. - * - * Use the form 'A a(*b);' and not ''A a = b;' to handle the case where A has - * only an implicit constructor, (which takes *b as a parameter). - */ - typename boost::mpl::if_, - const Construct_traits&, Construct_traits>::type - traits(*geom_traits); + // Surface sweep types + // Type definition for the no-intersection construction surface-sweep visitor. + // The third parameter of Arr_construction_subcurve is the base class of + // Arr_construction_subcurve. By default Arr_construction_subcurve derives + // from Default_subcurve, which is suitable for general curves + // including overlapping curves. Here we bypass Default_subcurve and + // force Arr_construction_subcurve to derive directly from + // No_overlap_subcurve (which is the base class of Default_subcurve). + typedef Arr_construction_event + Nxc_event; + typedef Arr_construction_subcurve + Nxc_curve; + typedef typename Tt::template No_intersection_construction_helper + Nxc_helper; + typedef Arr_construction_ss_visitor Nxc_visitor; - // Define a basic sweep-line instance (which is not supposed to handle + const Gt2* traits = arr.geometry_traits(); + Nxc_visitor visitor(&arr); + + // Define a basic surface-sweep instance (which is not supposed to handle // insersections) and perform the sweep. - Basic_sweep_line_2 - sweep_line(&traits, &visitor); - sweep_line.sweep(begin_xcurves, end_xcurves, begin_points, end_points); + Ss2::No_intersection_surface_sweep_2 + surface_sweep(traits, &visitor); + surface_sweep.sweep(begin_xcurves, end_xcurves, begin_points, end_points); } /*! Insert a range of x-monotone curves into a non-empty arrangement @@ -864,58 +940,85 @@ void non_intersecting_insert_empty(Arrangement_on_surface_2 -void non_intersecting_insert_non_empty(Arrangement_on_surface_2& arr, - XcInputIterator begin_xcurves, - XcInputIterator end_xcurves, - PInputIterator begin_points, - PInputIterator end_points) +void +non_intersecting_insert_non_empty(Arrangement_on_surface_2& arr, + XcInputIterator begin_xcurves, + XcInputIterator end_xcurves, + PInputIterator begin_points, + PInputIterator end_points) { - typedef typename TopTraits::Sweep_line_non_intersecting_insertion_visitor - Insert_visitor; - typedef typename Insert_visitor::Traits_2 Insert_traits; - typedef typename Insert_visitor::Traits_2::X_monotone_curve_2 - Ex_x_monotone_curve_2; - typedef typename Insert_visitor::Traits_2::Point_2 Ex_point_2; + typedef GeometryTraits_2 Gt2; + typedef TopologyTraits Tt; - const GeomTraits * geom_traits = arr.geometry_traits(); - Insert_visitor visitor(&arr); + // Arrangement types + typedef Arrangement_on_surface_2 Arr; + typedef typename Arr::Allocator Allocator; + + // Surface sweep types + typedef Arr_basic_insertion_traits_2 Igt2; + + // The third parameter of Arr_construction_subcurve is the base class of + // Arr_construction_subcurve. By default Arr_construction_subcurve derives + // from Default_subcurve, which is suitable for general curves + // including overlapping curves. Here we bypass Default_subcurve and + // force Arr_construction_subcurve to derive directly from + // No_overlap_subcurve (which is the base class of Default_subcurve). + typedef Arr_construction_event + Nxi_event; + typedef Arr_construction_subcurve + Nxi_curve; + // typedef typename Tt::template No_intersection_insertion_event + // Nxi_event; + // typedef typename Tt::template No_intersection_insertion_curve + // Nxi_curve; + typedef typename Tt::template No_intersection_insertion_helper + Nxi_Helper; + typedef Arr_no_intersection_insertion_ss_visitor + Nxi_visitor; + typedef typename Igt2::X_monotone_curve_2 Ex_x_monotone_curve_2; + typedef typename Igt2::Point_2 Ex_point_2; + + const Gt2* geom_traits = arr.geometry_traits(); + Nxi_visitor visitor(&arr); /* We would like to avoid copy construction of the geometry traits class. * Copy construction is undesired, because it may results with data * duplication or even data loss. * - * If the type Construct_visitor::Traits_2 is the same as the type - * GeomTraits, use a reference to GeomTraits to avoid constructing a new one. - * Otherwise, instantiate a local variable of the former and provide - * the later as a single parameter to the constructor. + * If the type Nxi_visitor::Geometry_traits_2 is the same as the type + * GeometryTraits_2, use a reference to GeometryTraits_2 to avoid constructing + * a new one. Otherwise, instantiate a local variable of the former and + * provide the later as a single parameter to the constructor. * * Use the form 'A a(*b);' and not ''A a = b;' to handle the case where A has * only an implicit constructor, (which takes *b as a parameter). */ - typename boost::mpl::if_, - const Insert_traits&, Insert_traits>::type + typename boost::mpl::if_, const Igt2&, Igt2>::type traits(*geom_traits); // Create a set of existing as well as new curves and points. std::list ex_cvs; std::list ex_pts; - prepare_for_sweep(arr, - begin_xcurves, end_xcurves, // the x-monotone curves - begin_points, end_points, // the points (if any) - std::back_inserter(ex_cvs), - std::back_inserter(ex_pts), - &traits); + Ss2::prepare_for_sweep(arr, + begin_xcurves, end_xcurves, // the x-monotone curves + begin_points, end_points, // the points (if any) + std::back_inserter(ex_cvs), + std::back_inserter(ex_pts), + &traits); - // Define a basic sweep-line instance and perform the sweep. - Basic_sweep_line_2 - sweep_line(&traits, &visitor); - sweep_line.sweep(ex_cvs.begin(), ex_cvs.end(), ex_pts.begin(), ex_pts.end()); + // Define a basic surface-sweep instance and perform the sweep. + Ss2::No_intersection_surface_sweep_2 + surface_sweep(&traits, &visitor); + surface_sweep.sweep(ex_cvs.begin(), ex_cvs.end(), + ex_pts.begin(), ex_pts.end()); } //----------------------------------------------------------------------------- @@ -923,15 +1026,19 @@ void non_intersecting_insert_non_empty(Arrangement_on_surface_2 +template void insert_non_intersecting_curves - (Arrangement_on_surface_2& arr, - InputIterator begin, InputIterator end) +(Arrangement_on_surface_2& arr, + InputIterator begin, InputIterator end) { - typedef Arrangement_on_surface_2 Arr; + typedef GeometryTraits_2 Gt2; + typedef TopologyTraits Tt; + + typedef Arrangement_on_surface_2 Arr; // Obtain an arrangement accessor. - Arr_accessor arr_access (arr); + Arr_accessor arr_access(arr); // Notify the arrangement observers that a global operation is about to // take place. @@ -940,10 +1047,9 @@ void insert_non_intersecting_curves // Choose the operation depending on whether the input arrangement is // empty (then we construct it from scratch), or not (where we just insert // the new curves). - if (arr.is_empty()) - non_intersecting_insert_empty(arr, begin, end); + if (arr.is_empty()) non_intersecting_insert_empty(arr, begin, end); else { - std::list empty; + std::list empty; non_intersecting_insert_non_empty(arr, begin, end, empty.begin(), empty.end()); } @@ -958,31 +1064,34 @@ void insert_non_intersecting_curves // the edges incident to the end-vertices of the removed edge after its // deletion, the function performs these merges as well. // -template -typename Arrangement_on_surface_2::Face_handle -remove_edge -(Arrangement_on_surface_2& arr, - typename Arrangement_on_surface_2::Halfedge_handle e) +template +typename Arrangement_on_surface_2::Face_handle +remove_edge(Arrangement_on_surface_2& arr, + typename Arrangement_on_surface_2::Halfedge_handle e) { - typedef Arrangement_on_surface_2 Arr; - typedef Arr_traits_adaptor_2 Traits_adaptor_2; + typedef GeometryTraits_2 Gt2; + typedef TopologyTraits Tt; + + typedef Arrangement_on_surface_2 Arr; + typedef Arr_traits_adaptor_2 Traits_adaptor_2; // Notify the arrangement observers that a global operation is about to // take place. - Arr_accessor arr_access (arr); + Arr_accessor arr_access(arr); arr_access.notify_before_global_change(); // Keep track of the end-vertices of the edge we are about to remove. - typename Arr::Vertex_handle v_ends[2]; - bool is_removed[2]; + typename Arr::Vertex_handle v_ends[2]; + bool is_removed[2]; v_ends[0] = e->source(); is_removed[0] = - (v_ends[0]->is_at_open_boundary() || v_ends[0]->degree() == 1); + (v_ends[0]->is_at_open_boundary() || (v_ends[0]->degree() == 1)); v_ends[1] = e->target(); is_removed[1] = - (v_ends[1]->is_at_open_boundary() || v_ends[1]->degree() == 1); + (v_ends[1]->is_at_open_boundary() || (v_ends[1]->degree() == 1)); // Remove the edge from the arrangement. typename Arr::Face_handle face = arr.remove_edge (e); @@ -991,17 +1100,13 @@ remove_edge // curves associated with these edges can be merged, merge the two edges and // remove the vertex. - const Traits_adaptor_2 * traits = - static_cast (arr.geometry_traits()); + const Traits_adaptor_2* traits = + static_cast(arr.geometry_traits()); - typename Arr::Halfedge_around_vertex_circulator circ; - typename Arr::Halfedge_handle e1, e2; - int i; - - for (i = 0; i < 2; i++) - { - if (! is_removed[i] && v_ends[i]->degree() == 2) - { + typename Arr::Halfedge_around_vertex_circulator circ; + typename Arr::Halfedge_handle e1, e2; + for (size_t i = 0; i < 2; i++) { + if (! is_removed[i] && v_ends[i]->degree() == 2) { // Get the two edges incident to the end-vertex. circ = v_ends[i]->incident_halfedges(); e1 = circ; @@ -1009,15 +1114,13 @@ remove_edge e2 = circ; // Check if it is possible to merge the two edges. - if (traits->are_mergeable_2_object() (e1->curve(), e2->curve())) - { + if (traits->are_mergeable_2_object() (e1->curve(), e2->curve())) { // Merge the two curves. - typename GeomTraits::X_monotone_curve_2 cv; - traits->merge_2_object() (e1->curve(), e2->curve(), - cv); + typename Gt2::X_monotone_curve_2 cv; + traits->merge_2_object()(e1->curve(), e2->curve(), cv); // Merge the two edges in the arrangement. - arr.merge_edge (e1, e2, cv); + arr.merge_edge(e1, e2, cv); } } } @@ -1027,62 +1130,62 @@ remove_edge arr_access.notify_after_global_change(); // Return the face remaining after the removal of the edge. - return (face); + return face; } //----------------------------------------------------------------------------- // Insert a vertex that corresponds to a given point into the arrangement. // The inserted point may lie on any existing arrangement feature. // -template -typename Arrangement_on_surface_2::Vertex_handle -insert_point (Arrangement_on_surface_2& arr, - const typename GeomTraits::Point_2& p, - const PointLocation& pl) +template +typename Arrangement_on_surface_2::Vertex_handle +insert_point(Arrangement_on_surface_2& arr, + const typename GeometryTraits_2::Point_2& p, + const PointLocation& pl) { - typedef Arrangement_on_surface_2 Arr; + typedef GeometryTraits_2 Gt2; + typedef TopologyTraits Tt; + + typedef Arrangement_on_surface_2 Arr; // Act according to the type of arrangement feature that contains the point. - const typename Arr::Face_const_handle *fh; - const typename Arr::Halfedge_const_handle *hh; - const typename Arr::Vertex_const_handle *vh; - typename Arr::Vertex_handle vh_for_p; + const typename Arr::Face_const_handle* fh; + const typename Arr::Halfedge_const_handle* hh; + const typename Arr::Vertex_const_handle* vh; + typename Arr::Vertex_handle vh_for_p; // Locate the given point in the arrangement. - CGAL::Object obj = pl.locate (p); + CGAL::Object obj = pl.locate (p); // Notify the arrangement observers that a global operation is about to // take place. - Arr_accessor arr_access (arr); + Arr_accessor arr_access (arr); arr_access.notify_before_global_change(); - if ((fh = object_cast(&obj)) != NULL) - { + if ((fh = object_cast(&obj)) != NULL) { // p lies inside a face: Insert it as an isolated vertex it the interior of // this face. - vh_for_p = arr.insert_in_face_interior (p, - arr.non_const_handle (*fh)); + vh_for_p = arr.insert_in_face_interior(p, arr.non_const_handle (*fh)); } - else if ((hh = - object_cast(&obj)) != NULL) + else if ((hh = object_cast(&obj)) != + NULL) { // p lies in the interior of an edge: Split this edge to create a new // vertex associated with p. - typename GeomTraits::X_monotone_curve_2 sub_cv1, sub_cv2; - typename Arr::Halfedge_handle split_he; + typename Gt2::X_monotone_curve_2 sub_cv1, sub_cv2; + typename Arr::Halfedge_handle split_he; - arr.geometry_traits()->split_2_object() ((*hh)->curve(), p, - sub_cv1, sub_cv2); + arr.geometry_traits()->split_2_object()((*hh)->curve(), p, + sub_cv1, sub_cv2); - split_he = arr.split_edge (arr.non_const_handle (*hh), - sub_cv1, sub_cv2); + split_he = arr.split_edge(arr.non_const_handle(*hh), sub_cv1, sub_cv2); // The new vertex is the target of the returned halfedge. vh_for_p = split_he->target(); } - else - { + else { // In this case p lies on an existing vertex, so we just update this // vertex. vh = object_cast(&obj); @@ -1096,74 +1199,77 @@ insert_point (Arrangement_on_surface_2& arr, arr_access.notify_after_global_change(); // Return a handle for the vertex associated with p. - return (vh_for_p); + return vh_for_p; } //----------------------------------------------------------------------------- // Insert a vertex that corresponds to a given point into the arrangement. // The inserted point may lie on any existing arrangement feature. // -template -typename Arrangement_on_surface_2::Vertex_handle -insert_point (Arrangement_on_surface_2& arr, - const typename GeomTraits::Point_2& p) +template +typename Arrangement_on_surface_2:: +Vertex_handle +insert_point(Arrangement_on_surface_2& arr, + const typename GeometryTraits_2::Point_2& p) { - // Create a default point-location object and use it to insert the point. - typename TopTraits::Default_point_location_strategy def_pl (arr); + typedef TopologyTraits Tt; - return (insert_point (arr, p, def_pl)); + // Create a default point-location object and use it to insert the point. + typename Tt::Default_point_location_strategy def_pl(arr); + + return insert_point(arr, p, def_pl); } //----------------------------------------------------------------------------- // Remove a vertex from the arrangement. // -template -bool remove_vertex - (Arrangement_on_surface_2& arr, - typename Arrangement_on_surface_2::Vertex_handle v) +template +bool remove_vertex(Arrangement_on_surface_2& + arr, + typename Arrangement_on_surface_2< + GeometryTraits_2, TopologyTraits>::Vertex_handle v) { - typedef Arrangement_on_surface_2 Arr; - typedef Arr_traits_adaptor_2 Traits_adaptor_2; + typedef GeometryTraits_2 Gt2; + typedef TopologyTraits Tt; + + typedef Arrangement_on_surface_2 Arr; + typedef Arr_traits_adaptor_2 Traits_adaptor_2; // Notify the arrangement observers that a global operation is about to // take place. - Arr_accessor arr_access (arr); + Arr_accessor arr_access(arr); arr_access.notify_before_global_change(); // Act according to the number of edges incident to v. - bool removed = false; + bool removed = false; - if (v->is_isolated()) - { + if (v->is_isolated()) { // In case v is an isolated vertex, simply remove it. arr.remove_isolated_vertex (v); removed = true; } - else if (v->degree() == 2) - { + else if (v->degree() == 2) { // If the vertex has now two incident edges, and the curves associated // with these edges can be merged, merge the two edges and remove the // vertex. - const Traits_adaptor_2 * traits = + const Traits_adaptor_2* traits = static_cast(arr.geometry_traits()); - typename Arr::Halfedge_around_vertex_circulator circ; - typename Arr::Halfedge_handle e1, e2; + typename Arr::Halfedge_around_vertex_circulator circ; + typename Arr::Halfedge_handle e1, e2; circ = v->incident_halfedges(); e1 = circ; ++circ; e2 = circ; - if (traits->are_mergeable_2_object() (e1->curve(), e2->curve())) - { + if (traits->are_mergeable_2_object() (e1->curve(), e2->curve())) { // Merge the two curves. - typename GeomTraits::X_monotone_curve_2 cv; - traits->merge_2_object() (e1->curve(), e2->curve(), - cv); + typename Gt2::X_monotone_curve_2 cv; + traits->merge_2_object()(e1->curve(), e2->curve(), cv); // Merge the two edges in the arrangement. - arr.merge_edge (e1, e2, cv); + arr.merge_edge(e1, e2, cv); removed = true; } } @@ -1173,7 +1279,7 @@ bool remove_vertex arr_access.notify_after_global_change(); // Return an indication whether the vertex has been removed or not. - return (removed); + return removed; } //----------------------------------------------------------------------------- @@ -1181,83 +1287,80 @@ bool remove_vertex // edegs are disjoint-interior, and the holes are located in their proper // position. // -template -bool is_valid (const Arrangement_on_surface_2& arr) +template +bool +is_valid(const Arrangement_on_surface_2& arr) { - // First use the internal validity check. - if(!arr.is_valid()) - return (false); + typedef GeometryTraits_2 Gt2; + typedef TopologyTraits Tt; - typedef Arrangement_on_surface_2 Arr; - typedef GeomTraits Geometry_traits_2; - typedef typename Geometry_traits_2::X_monotone_curve_2 X_monotone_curve_2; - - // Define the sweep-line types: - typedef Sweep_line_do_curves_x_visitor Visitor; - typedef Sweep_line_2 Sweep_line_2; - - // Define the arrangement iterator and circulator types: - typedef typename Arr::Edge_const_iterator Edge_const_iterator; - typedef typename Arr::Halfedge_const_handle Halfedge_const_handle; - typedef typename Arr::Inner_ccb_const_iterator Inner_ccb_const_iterator; - typedef typename Arr::Face_const_iterator Face_const_iterator; - typedef typename Arr::Face_const_handle Face_const_handle; - typedef typename Arr::Vertex_const_handle Vertex_const_handle; + // Arrangement types (iterator and circulator types). + typedef Arrangement_on_surface_2 Arr; + typedef typename Arr::Allocator Allocator; + typedef typename Arr::Edge_const_iterator Edge_const_iterator; + typedef typename Arr::Halfedge_const_handle Halfedge_const_handle; + typedef typename Arr::Inner_ccb_const_iterator Inner_ccb_const_iterator; + typedef typename Arr::Face_const_iterator Face_const_iterator; + typedef typename Arr::Face_const_handle Face_const_handle; + typedef typename Arr::Vertex_const_handle Vertex_const_handle; typedef typename Arr::Isolated_vertex_const_iterator - Isolated_vertex_const_iterator; + Isolated_vertex_const_iterator; typedef typename Arr::Halfedge_around_vertex_const_circulator - Halfedge_around_vertex_const_circulator; + Halfedge_around_vertex_const_circulator; + + typedef typename Gt2::X_monotone_curve_2 X_monotone_curve_2; + + // The surface-sweep types: + typedef Ss2::Do_interior_intersect_visitor + Visitor; + typedef Ss2::Surface_sweep_2 Surface_sweep_2; + + // First use the internal validity check. + if (!arr.is_valid()) return (false); // Perform a sweep over all subcurves associated with arrangement edges. - std::vector curves_vec (arr.number_of_edges()); - Edge_const_iterator eit; - unsigned int i = 0; + std::vector curves_vec(arr.number_of_edges()); + unsigned int i = 0; + Edge_const_iterator eit; for (eit = arr.edges_begin(); eit != arr.edges_end(); ++eit, i++) curves_vec[i] = eit->curve(); - Visitor visitor; - const Geometry_traits_2 *traits = arr.geometry_traits(); - Sweep_line_2 sweep_line (traits, &visitor); + Visitor visitor; + const Gt2* traits = arr.geometry_traits(); + Surface_sweep_2 surface_sweep(traits, &visitor); + visitor.sweep_xcurves(curves_vec.begin(), curves_vec.end()); + bool are_edges_disjoint = (! visitor.found_intersection()); - visitor.sweep_xcurves (curves_vec.begin(), curves_vec.end()); - - bool are_edges_disjoint = (! visitor.found_intersection()); - - if (!are_edges_disjoint) - { - CGAL_warning_msg (are_edges_disjoint, - "Arrangement edges are not disjoint in their interior."); - return (false); + if (!are_edges_disjoint) { + CGAL_warning_msg(are_edges_disjoint, + "Arrangement edges are not disjoint in their interior."); + return false; } // Check that the holes and isolated vertices are located where they should. // At the same time, we prepare a vector that consists of all isolated // vertices and all leftmost vertices from every hole. - std::list > vf_list; + std::list > vf_list; - typename Geometry_traits_2::Compare_xy_2 compare_xy = - traits->compare_xy_2_object(); - Face_const_iterator fit; - Face_const_handle fh; - Inner_ccb_const_iterator ic_it; - Halfedge_const_handle ccb; - Isolated_vertex_const_iterator iv_it; - Vertex_const_handle left_v; - bool is_first; + typename Gt2::Compare_xy_2 compare_xy = traits->compare_xy_2_object(); + Face_const_iterator fit; + Face_const_handle fh; + Inner_ccb_const_iterator ic_it; + Halfedge_const_handle ccb; + Isolated_vertex_const_iterator iv_it; + Vertex_const_handle left_v; + bool is_first; - for (fit = arr.faces_begin(); fit != arr.faces_end(); ++fit) - { + for (fit = arr.faces_begin(); fit != arr.faces_end(); ++fit) { // Check all holes in the current face. fh = fit; - for (ic_it = fh->inner_ccbs_begin(); - ic_it != fh->inner_ccbs_end(); ++ic_it) + for (ic_it = fh->inner_ccbs_begin(); ic_it != fh->inner_ccbs_end(); ++ic_it) { ccb = *ic_it; is_first = true; - do - { + do { if (ccb->face() != fit) return (false); @@ -1279,8 +1382,7 @@ bool is_valid (const Arrangement_on_surface_2& arr) for (iv_it = fh->isolated_vertices_begin(); iv_it != fh->isolated_vertices_end(); ++iv_it) { - if (iv_it->face() != fit) - return (false); + if (iv_it->face() != fit) return (false); vf_list.push_back (std::make_pair (Vertex_const_handle(iv_it), fh)); } @@ -1288,31 +1390,29 @@ bool is_valid (const Arrangement_on_surface_2& arr) // Shoot a vertical ray from each vertex we have collected downward, and // check that this vertex is really contained in the proper face. - typename Geometry_traits_2::Compare_y_at_x_right_2 comp_y_at_x_right = - traits->compare_y_at_x_right_2_object(); - typename Geometry_traits_2::Compare_y_at_x_left_2 comp_y_at_x_left = - traits->compare_y_at_x_left_2_object(); + typename Gt2::Compare_y_at_x_right_2 comp_y_at_x_right = + traits->compare_y_at_x_right_2_object(); + typename Gt2::Compare_y_at_x_left_2 comp_y_at_x_left = + traits->compare_y_at_x_left_2_object(); typename std::list >::iterator vf_iter; - typename TopTraits::Default_point_location_strategy def_pl (arr); - Vertex_const_handle curr_v; - Object obj; - Halfedge_const_handle he_below; - Vertex_const_handle v_below; - Face_const_handle in_face; - Halfedge_around_vertex_const_circulator first, circ; - bool assign_ok; - const Halfedge_const_handle invalid_he; + typename Tt::Default_point_location_strategy def_pl(arr); + Vertex_const_handle curr_v; + Object obj; + Halfedge_const_handle he_below; + Vertex_const_handle v_below; + Face_const_handle in_face; + Halfedge_around_vertex_const_circulator first, circ; + bool assign_ok; + const Halfedge_const_handle invalid_he; - for (vf_iter = vf_list.begin(); vf_iter != vf_list.end(); ++vf_iter) - { + for (vf_iter = vf_list.begin(); vf_iter != vf_list.end(); ++vf_iter) { // Perform ray-shooting from the current vertex. curr_v = vf_iter->first; obj = def_pl.ray_shoot_down(curr_v->point()); - if (CGAL::assign(he_below, obj)) - { + if (CGAL::assign(he_below, obj)) { // Hit an edge - take the incident face of the halfedge directed to the // right. if (he_below->direction() == ARR_RIGHT_TO_LEFT) @@ -1320,29 +1420,21 @@ bool is_valid (const Arrangement_on_surface_2& arr) in_face = he_below->face(); } - else if (CGAL::assign(v_below, obj)) - { + else if (CGAL::assign(v_below, obj)) { // Hit a vertex. - if(v_below->is_isolated()) - { - in_face = v_below->face(); - } - else - { + if (v_below->is_isolated()) in_face = v_below->face(); + else { // Get the first halfedge around v_below that is directed from left to // right and the first halfedge that is directed from right to left. first = circ = v_below->incident_halfedges(); Halfedge_const_handle he_left; // A halfedge to the left of v_below. Halfedge_const_handle he_right; // A halfedge to the right of v_below. - do - { - if (circ->direction() == ARR_LEFT_TO_RIGHT) - { + do { + if (circ->direction() == ARR_LEFT_TO_RIGHT) { he_left = circ; } - else - { + else { he_right = circ; if (he_left != invalid_he && he_right != invalid_he) break; @@ -1353,8 +1445,7 @@ bool is_valid (const Arrangement_on_surface_2& arr) CGAL_assertion (he_left != invalid_he || he_right != invalid_he); - if (he_left != invalid_he && he_right != invalid_he) - { + if (he_left != invalid_he && he_right != invalid_he) { while (he_left->direction() == ARR_LEFT_TO_RIGHT) he_left = he_left->next()->twin(); @@ -1362,24 +1453,21 @@ bool is_valid (const Arrangement_on_surface_2& arr) CGAL_assertion (he_left->direction() == ARR_LEFT_TO_RIGHT); in_face = he_left->face(); } - else if (he_left != invalid_he) - { - Comparison_result res; + else if (he_left != invalid_he) { + Comparison_result res; Halfedge_const_handle he_curr = he_left; - do // as long as we have next he_left halfedge which is above - { + // as long as we have next he_left halfedge which is above + do { he_left = he_curr; he_curr = he_left->next()->twin(); - res = comp_y_at_x_left (he_curr->curve(), - he_left->curve(), - v_below->point()); + res = comp_y_at_x_left(he_curr->curve(), he_left->curve(), + v_below->point()); } while(res == LARGER); in_face = he_left->face(); } - else - { - Comparison_result res; + else { + Comparison_result res; Halfedge_const_handle he_curr = he_right; do // as long as we have he_right halfedge which is below @@ -1394,57 +1482,55 @@ bool is_valid (const Arrangement_on_surface_2& arr) } } } - else - { + else { // Hit nothing (an unbounded face is returned). assign_ok = CGAL::assign(in_face, obj); CGAL_assertion (assign_ok && in_face->is_unbounded()); - if (! assign_ok) - return (false); + if (! assign_ok) return false; } - if (vf_iter->second != in_face) - { + if (vf_iter->second != in_face) { CGAL_warning_msg (false, "An inner component is located in the wrong face."); - return (false); + return false; } } // If we reached here, the arrangement is valid: - return (true); + return true; } //----------------------------------------------------------------------------- // Compute the zone of the given x-monotone curve in the existing arrangement. // Meaning, it output the arrangment's vertices, edges and faces that the // x-monotone curve intersects. -template -OutputIterator zone (Arrangement_on_surface_2& arr, - const typename GeomTraits::X_monotone_curve_2& c, - OutputIterator oi, - const PointLocation& pl) +template +OutputIterator +zone(Arrangement_on_surface_2& arr, + const typename GeometryTraits_2::X_monotone_curve_2& c, + OutputIterator oi, + const PointLocation& pl) { + typedef GeometryTraits_2 Gt2; + typedef TopologyTraits Tt; + // Obtain an arrangement accessor. - typedef Arrangement_on_surface_2 - Arrangement_on_surface_2; + typedef Arrangement_on_surface_2 Arr; // Define a zone-computation object an a visitor that performs the // intersection check. - typedef Arr_compute_zone_visitor - Zone_visitor; + typedef Arr_compute_zone_visitor Zone_visitor; - Zone_visitor visitor (oi); - Arrangement_zone_2 - arr_zone (arr, &visitor); + Zone_visitor visitor(oi); + Arrangement_zone_2 arr_zone(arr, &visitor); - arr_zone.init (c, pl); + arr_zone.init(c, pl); arr_zone.compute_zone(); - return (oi); + return oi; } //----------------------------------------------------------------------------- @@ -1452,22 +1538,26 @@ OutputIterator zone (Arrangement_on_surface_2& arr, // Overloaded version with no point location object - the walk point-location // strategy is used as default. // -template -OutputIterator zone (Arrangement_on_surface_2& arr, - const typename GeomTraits::X_monotone_curve_2& c, - OutputIterator oi) +template +OutputIterator +zone(Arrangement_on_surface_2& arr, + const typename GeometryTraits_2::X_monotone_curve_2& c, + OutputIterator oi) { + typedef TopologyTraits Tt; + // Create a default point-location object and use it to insert the curve. - typename TopTraits::Default_point_location_strategy def_pl (arr); + typename Tt::Default_point_location_strategy def_pl(arr); //insert the curve using the walk point location - zone (arr, c, oi, def_pl); + zone(arr, c, oi, def_pl); return oi; } //----------------------------------------------------------------------------- -// Checks if the given x-monotone curve intersects the existing arrangement. +// Checks whether the given x-monotone curve intersects the existing arrangement. // The last parameter is used to resolve ambiguity between this function and // do_intersect of Curve_2 in case that X_monotone_curve_2 and Curve_2 are the // same class. The last parameter should be boost::true_type but we used a @@ -1476,27 +1566,30 @@ OutputIterator zone (Arrangement_on_surface_2& arr, // error: no matching function for call to `do_intersect(Arrangement_on_surface_2<>&, // const Arr_segment_2&, const Arr_walk_along_line_point_location<>&, mpl_::bool_< true>)' // -template -bool do_intersect (Arrangement_on_surface_2& arr, - const typename GeomTraits::X_monotone_curve_2& c, - const PointLocation& pl, boost::is_same::type) +template +bool +do_intersect(Arrangement_on_surface_2& arr, + const typename GeometryTraits_2::X_monotone_curve_2& c, + const PointLocation& pl, boost::is_same::type) { + typedef GeometryTraits_2 Gt2; + typedef TopologyTraits Tt; + // Obtain an arrangement accessor. - typedef Arrangement_on_surface_2 - Arrangement_on_surface_2; + typedef Arrangement_on_surface_2 Arr; // Define a zone-computation object an a visitor that performs the // intersection check. - typedef Arr_do_intersect_zone_visitor Zone_visitor; + typedef Arr_do_intersect_zone_visitor Zone_visitor; - Zone_visitor visitor; - Arrangement_zone_2 - arr_zone (arr, &visitor); + Zone_visitor visitor; + Arrangement_zone_2 arr_zone(arr, &visitor); - arr_zone.init (c, pl); + arr_zone.init(c, pl); arr_zone.compute_zone(); - return (visitor.do_intersect()); + return visitor.do_intersect(); } //----------------------------------------------------------------------------- @@ -1507,93 +1600,98 @@ bool do_intersect (Arrangement_on_surface_2& arr, // The last parameter should be boost::false_type but we used a // workaround since it didn't compile in FC3_g++-3.4.4 with the error of: // -// error: no matching function for call to `do_intersect(Arrangement_on_surface_2<>&, +// error: no matching function for call to +// `do_intersect(Arrangement_on_surface_2<>&, // const Arr_segment_2&, const Arr_walk_along_line_point_location<>&, mpl_::bool_< true>)' // -template -bool do_intersect (Arrangement_on_surface_2& arr, - const typename GeomTraits::X_monotone_curve_2& c, - const PointLocation& pl, boost::is_same::type) +template +bool +do_intersect(Arrangement_on_surface_2& arr, + const typename GeometryTraits_2::X_monotone_curve_2& c, + const PointLocation& pl, boost::is_same::type) { + typedef GeometryTraits_2 Gt2; + typedef TopologyTraits Tt; + // Obtain an arrangement accessor. - typedef Arrangement_on_surface_2 - Arrangement_on_surface_2; + typedef Arrangement_on_surface_2 Arr; // Break the input curve into x-monotone subcurves and isolated points. - typedef Arr_traits_adaptor_2 Traits_adaptor_2; + typedef Arr_traits_adaptor_2 Traits_adaptor_2; - const Traits_adaptor_2 * traits = - static_cast (arr.geometry_traits()); + const Traits_adaptor_2* traits = + static_cast(arr.geometry_traits()); - std::list x_objects; - std::list::const_iterator obj_iter; - const typename GeomTraits::X_monotone_curve_2 *x_curve; - const typename GeomTraits::Point_2 *iso_p; + std::list x_objects; + std::list::const_iterator obj_iter; + const typename Gt2::X_monotone_curve_2* x_curve; + const typename Gt2::Point_2* iso_p; - traits->make_x_monotone_2_object() (c, - std::back_inserter (x_objects)); + traits->make_x_monotone_2_object()(c, std::back_inserter(x_objects)); // Insert each x-monotone curve into the arrangement. - for (obj_iter = x_objects.begin(); obj_iter != x_objects.end(); ++obj_iter) - { + for (obj_iter = x_objects.begin(); obj_iter != x_objects.end(); ++obj_iter) { // Act according to the type of the current object. - x_curve = object_cast - (&(*obj_iter)); - if (x_curve != NULL) - { + x_curve = object_cast(&(*obj_iter)); + if (x_curve != NULL) { // Check if the x-monotone subcurve intersects the arrangement. if (do_intersect(arr, *x_curve, pl) == true) return true; } - else - { - iso_p = object_cast (&(*obj_iter)); - CGAL_assertion (iso_p != NULL); + else { + iso_p = object_cast(&(*obj_iter)); + CGAL_assertion(iso_p != NULL); // Check whether the isolated point lies inside a face (otherwise, // it conincides with a vertex or an edge). CGAL::Object obj = pl.locate (*iso_p); - return (object_cast(&obj) != NULL); + return (object_cast(&obj) != NULL); } } // If we reached here, the curve does not intersect the arrangement. - return (false); + return false; } //----------------------------------------------------------------------------- // Common interface for the do_intersect of the Curve_2 and X_monotone_curve_2 -template -bool do_intersect (Arrangement_on_surface_2& arr, - const Curve& c, const PointLocation& pl) +template +bool +do_intersect (Arrangement_on_surface_2& arr, + const Curve& c, const PointLocation& pl) { - typedef typename GeomTraits::X_monotone_curve_2 X_monotone_curve_2; + typedef GeometryTraits_2 Gt2; + + typedef typename Gt2::X_monotone_curve_2 X_monotone_curve_2; typedef typename boost::is_same::type - Is_x_monotone; + Is_x_monotone; return do_intersect(arr, c, pl, Is_x_monotone()); } //----------------------------------------------------------------------------- -// Checks if the given curve intersects the existing arrangement. +// Checks whether the given curve intersects the existing arrangement. // Overloaded version with no point location object - the walk point-location // strategy is used as default. -template -bool do_intersect (Arrangement_on_surface_2& arr, - const Curve& c) +template +bool +do_intersect(Arrangement_on_surface_2& arr, + const Curve& c) { - // Create a default point-location object and use it to insert the curve. - typename TopTraits::Default_point_location_strategy def_pl (arr); + typedef TopologyTraits Tt; - // check if the curve intersects the arrangement using the walk point + // Create a default point-location object and use it to insert the curve. + typename Tt::Default_point_location_strategy def_pl(arr); + + // check whether the curve intersects the arrangement using the walk point // location. - return do_intersect (arr, c, def_pl); + return do_intersect(arr, c, def_pl); } - -} //namespace CGAL +} // namespace CGAL #endif diff --git a/Arrangement_on_surface_2/include/CGAL/Arrangement_2/Arrangement_on_surface_2_impl.h b/Arrangement_on_surface_2/include/CGAL/Arrangement_2/Arrangement_on_surface_2_impl.h index 04b08a34862..c2221e56907 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arrangement_2/Arrangement_on_surface_2_impl.h +++ b/Arrangement_on_surface_2/include/CGAL/Arrangement_2/Arrangement_on_surface_2_impl.h @@ -26,14 +26,12 @@ // Ester Ezra, // Shai Hirsch, // and Eugene Lipovetsky) -// #ifndef CGAL_ARRANGEMENT_ON_SURFACE_2_IMPL_H #define CGAL_ARRANGEMENT_ON_SURFACE_2_IMPL_H #include - #ifndef CGAL_ARRANGEMENT_ON_SURFACE_INSERT_VERBOSE #define CGAL_ARRANGEMENT_ON_SURFACE_INSERT_VERBOSE 0 #endif @@ -2683,7 +2681,7 @@ _insert_at_vertices(DHalfedge* he_to, // Check what to do here, when allow_swap_of_predecessors = false and thus // signs1 and signs2 set to DEFAULT (=ZERO) values. // swapping is currently only disabled when _insert_at_vertices is called - // from Arr_construction_sl_visitor, which however uses the + // from Arr_construction_ss_visitor, which however uses the // 'swap_predecessors' member of the topology traits' construction helper. // So it's questionable whether we can combine the light-weigth swap // information with the slightly more expensive sign computations, to keep @@ -5491,6 +5489,6 @@ _are_curves_ordered_cw_around_vertrex(Vertex_const_handle v) const return true; } -} //namespace CGAL +} // namespace CGAL #endif diff --git a/Arrangement_on_surface_2/include/CGAL/Arrangement_on_surface_2.h b/Arrangement_on_surface_2/include/CGAL/Arrangement_on_surface_2.h index 023adc1cb1e..357d4bc9064 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arrangement_on_surface_2.h +++ b/Arrangement_on_surface_2/include/CGAL/Arrangement_on_surface_2.h @@ -72,6 +72,7 @@ class Arrangement_on_surface_2 { public: typedef GeomTraits_ Geometry_traits_2; typedef TopTraits_ Topology_traits; + typedef CGAL_ALLOCATOR(int) Allocator; // first define adaptor ... typedef Arr_traits_basic_adaptor_2 Traits_adaptor_2; diff --git a/Sweep_line_2/include/CGAL/Sweep_line_2/Arr_basic_insertion_traits_2.h b/Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_basic_insertion_traits_2.h similarity index 54% rename from Sweep_line_2/include/CGAL/Sweep_line_2/Arr_basic_insertion_traits_2.h rename to Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_basic_insertion_traits_2.h index 4ba58cc0809..3390e14ca61 100644 --- a/Sweep_line_2/include/CGAL/Sweep_line_2/Arr_basic_insertion_traits_2.h +++ b/Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_basic_insertion_traits_2.h @@ -15,7 +15,7 @@ // $URL$ // $Id$ // SPDX-License-Identifier: GPL-3.0+ -// +// // // Author(s) : Baruch Zukerman // Ron Wein @@ -25,10 +25,10 @@ #ifndef CGAL_ARR_BASIC_INSERTION_TRAITS_2_H #define CGAL_ARR_BASIC_INSERTION_TRAITS_2_H -#include +#include - -/*! +/*! \file + * * Defintion of the Arr_basic_insertion_traits_2 class. */ @@ -40,80 +40,77 @@ namespace CGAL { -/*! - * A basic meta-traits class that stores a halfedge handle with every - * x-monotone curve, and a vertex handle with each point. This information is +/*! A basic meta-traits class that stores a halfedge handle with every + * x-monotone curve, and a vertex handle with each point. This information is * used to speed up the aggregated insertion process. */ -template -class Arr_basic_insertion_traits_2 -{ +template +class Arr_basic_insertion_traits_2 { public: + typedef GeometryTraits_2 Geometry_traits_2; + typedef Arrangement_ Arrangement_2; - typedef Traits_ Traits_2; - typedef Arrangement_ Arrangement_2; +private: + typedef Geometry_traits_2 Gt2; - typedef typename Arrangement_2::Halfedge_handle Halfedge_handle; - typedef typename Arrangement_2::Vertex_handle Vertex_handle; - typedef typename Traits_2::X_monotone_curve_2 Base_x_monotone_curve_2; - typedef typename Traits_2::Point_2 Base_point_2; - typedef typename Traits_2::Construct_min_vertex_2 Base_construct_min_vertex_2; - typedef typename Traits_2::Construct_max_vertex_2 Base_construct_max_vertex_2; - typedef typename Traits_2::Compare_x_2 Base_compare_x_2; - typedef typename Traits_2::Compare_xy_2 Base_compare_xy_2; - typedef typename Traits_2::Compare_y_at_x_2 Base_compare_y_at_x_2; - typedef typename Traits_2::Compare_y_at_x_right_2 Base_compare_y_at_x_right_2; - typedef typename Traits_2::Equal_2 Base_equal_2; - typedef typename Traits_2::Is_vertical_2 Base_is_vertical_2; +public: + typedef typename Arrangement_2::Halfedge_handle Halfedge_handle; + typedef typename Arrangement_2::Vertex_handle Vertex_handle; - typedef typename Traits_2::Multiplicity Multiplicity; + typedef typename Gt2::X_monotone_curve_2 Base_x_monotone_curve_2; + typedef typename Gt2::Point_2 Base_point_2; + typedef typename Gt2::Construct_min_vertex_2 Base_construct_min_vertex_2; + typedef typename Gt2::Construct_max_vertex_2 Base_construct_max_vertex_2; + typedef typename Gt2::Compare_x_2 Base_compare_x_2; + typedef typename Gt2::Compare_xy_2 Base_compare_xy_2; + typedef typename Gt2::Compare_y_at_x_2 Base_compare_y_at_x_2; + typedef typename Gt2::Compare_y_at_x_right_2 Base_compare_y_at_x_right_2; + typedef typename Gt2::Equal_2 Base_equal_2; + typedef typename Gt2::Is_vertical_2 Base_is_vertical_2; - typedef typename Traits_2::Has_do_intersect_category - Has_do_intersect_category; + typedef typename Gt2::Multiplicity Multiplicity; - - typedef typename internal::Arr_complete_left_side_category< Traits_2 >::Category + typedef typename Gt2::Has_do_intersect_category + Has_do_intersect_category; + + + typedef typename internal::Arr_complete_left_side_category< Gt2>::Category Left_side_category; - typedef typename internal::Arr_complete_bottom_side_category< Traits_2 >::Category + typedef typename internal::Arr_complete_bottom_side_category< Gt2>::Category Bottom_side_category; - typedef typename internal::Arr_complete_top_side_category< Traits_2 >::Category + typedef typename internal::Arr_complete_top_side_category< Gt2>::Category Top_side_category; - typedef typename internal::Arr_complete_right_side_category< Traits_2 >::Category + typedef typename internal::Arr_complete_right_side_category< Gt2>::Category Right_side_category; - /* Insertion is implemented as sweep-line visitor. The sweep-line algorithm - * never uses Compare_y_at_x_left_2. + /* Insertion is implemented as surface-sweep visitor. The surface-sweep + * algorithm never uses Compare_y_at_x_left_2. */ typedef Tag_false Has_left_category; protected: - //! The base traits. - const Traits_2 * m_base_traits; + const Gt2* m_base_traits; public: - /*! Constructor. */ - Arr_basic_insertion_traits_2 (const Traits_2 & tr): - m_base_traits (&tr) + Arr_basic_insertion_traits_2(const Gt2& tr) : + m_base_traits(&tr) {} - /*! + /*! * Nested extension of the x-monotone curve type. */ - class Ex_x_monotone_curve_2 - { + class Ex_x_monotone_curve_2 { public: - typedef Base_x_monotone_curve_2 Base; protected: - - Base m_base_xcv; // The base x-monotone curve. - Halfedge_handle m_he_handle; // The corresponding arrangement edge - // (may be invalid). - bool m_overlap; // Does this curve represent and overlap - // of two other curves. + Base m_base_xcv; // The base x-monotone curve. + Halfedge_handle m_he_handle; // The corresponding arrangement edge + // (may be invalid). + bool m_overlap; // Does this curve represent and overlap + // of two other curves. public: @@ -124,191 +121,153 @@ public: {} Ex_x_monotone_curve_2(const Base& xcv): - m_base_xcv (xcv), + m_base_xcv(xcv), m_he_handle(), m_overlap(false) {} Ex_x_monotone_curve_2(const Base& xcv, Halfedge_handle he) : - m_base_xcv (xcv), - m_he_handle (he), + m_base_xcv(xcv), + m_he_handle(he), m_overlap(false) { - CGAL_precondition (he == Halfedge_handle() || - he->direction() == ARR_RIGHT_TO_LEFT); + CGAL_precondition(he == Halfedge_handle() || + he->direction() == ARR_RIGHT_TO_LEFT); } - const Base& base() const - { - return (m_base_xcv); - } + const Base& base() const { return m_base_xcv; } - Base& base() - { - return (m_base_xcv); - } + Base& base() { return m_base_xcv; } - operator const Base& () const - { - return (m_base_xcv); - } + operator const Base& () const { return m_base_xcv; } - Ex_x_monotone_curve_2& operator= (const Base& xcv) + Ex_x_monotone_curve_2& operator=(const Base& xcv) { m_base_xcv = xcv; m_he_handle = Halfedge_handle(); return (*this); } - Halfedge_handle halfedge_handle() const - { - return (m_he_handle); - } + Halfedge_handle halfedge_handle() const { return m_he_handle; } void set_halfedge_handle(Halfedge_handle he) { - CGAL_precondition (he == Halfedge_handle() || - he->direction() == ARR_RIGHT_TO_LEFT); + CGAL_precondition(he == Halfedge_handle() || + he->direction() == ARR_RIGHT_TO_LEFT); m_he_handle = he; } - bool is_overlapping () const - { - return (m_overlap); - } + bool is_overlapping() const { return m_overlap; } - void set_overlapping () - { - m_overlap = true; - } + void set_overlapping() { m_overlap = true; } }; typedef Ex_x_monotone_curve_2 X_monotone_curve_2; // For debugging purposes: - friend std::ostream& operator<< (std::ostream& os, - const X_monotone_curve_2& xcv) + friend std::ostream& operator<<(std::ostream& os, + const X_monotone_curve_2& xcv) { os << xcv.base(); return (os); } - - /*! + + /*! * Nested extension of the point type. */ - class Ex_point_2 - { + class Ex_point_2 { public: - typedef Base_point_2 Base; protected: - - Base m_base_pt; // The base point. - Vertex_handle m_v; // The corresponding arrangement vertex - // (may be invalid). + Base m_base_pt; // The base point. + Vertex_handle m_v; // The corresponding arrangement vertex + // (may be invalid). public: - Ex_point_2() : m_base_pt(), m_v() {} - Ex_point_2 (const Base& pt) : - m_base_pt (pt), + Ex_point_2(const Base& pt) : + m_base_pt(pt), m_v() {} - Ex_point_2 (const Base& pt, Vertex_handle v) : - m_base_pt (pt), - m_v (v) + Ex_point_2(const Base& pt, Vertex_handle v) : + m_base_pt(pt), + m_v(v) {} - const Base& base() const - { - return (m_base_pt); - } - - operator const Base& () const - { - return (m_base_pt); - } + const Base& base() const { return m_base_pt; } - Vertex_handle vertex_handle() const - { - return m_v; - } + operator const Base& () const { return m_base_pt; } - void set_vertex_handle(Vertex_handle v) - { - m_v = v; - } + Vertex_handle vertex_handle() const { return m_v; } + + void set_vertex_handle(Vertex_handle v) { m_v = v; } }; typedef Ex_point_2 Point_2; // For debugging purposes: - friend std::ostream& operator<< (std::ostream& os, - const Point_2& pt) + friend std::ostream& operator<<(std::ostream& os, const Point_2& pt) { os << pt.base(); - return (os); + return os; } /*! A functor that obtains the left endpoint of an x-monotone curve. */ class Construct_min_vertex_2 { protected: - Base_construct_min_vertex_2 m_base_min_v; - Base_equal_2 m_base_equal; - Halfedge_handle invalid_he; + Base_construct_min_vertex_2 m_base_min_v; + Base_equal_2 m_base_equal; + Halfedge_handle invalid_he; /*! Constructor. * The constructor is declared private to allow only the functor * obtaining function, which is a member of the nesting class, * constructing it. */ - Construct_min_vertex_2 (const Base_construct_min_vertex_2& base_min_v, - const Base_equal_2& base_equal) : - m_base_min_v (base_min_v), - m_base_equal (base_equal), + Construct_min_vertex_2(const Base_construct_min_vertex_2& base_min_v, + const Base_equal_2& base_equal) : + m_base_min_v(base_min_v), + m_base_equal(base_equal), invalid_he() {} //! Allow its functor obtaining function calling the private constructor. - friend class Arr_basic_insertion_traits_2; - + friend class Arr_basic_insertion_traits_2; + public: - Point_2 operator() (const X_monotone_curve_2 & xcv) + Point_2 operator()(const X_monotone_curve_2& xcv) { // If there is not halfedge associated with the curve, just return // a point with invalid halfedge handle. - const Base_point_2& base_p = m_base_min_v(xcv.base()); + const Base_point_2& base_p = m_base_min_v(xcv.base()); - if (xcv.halfedge_handle() == invalid_he) - return (Point_2 (base_p)); + if (xcv.halfedge_handle() == invalid_he) return (Point_2(base_p)); // Note that the halfedge associated with the curve is always directed // from right to left, so its target is the leftmost vertex. // We probably have to associate the point with the target vertex of // the halfedge associated with the curve. - Vertex_handle vh = xcv.halfedge_handle()->target(); + Vertex_handle vh = xcv.halfedge_handle()->target(); - if (! xcv.is_overlapping()) - return (Point_2(base_p, vh)); + if (! xcv.is_overlapping()) return (Point_2(base_p, vh)); // In case of an overlapping curve, make sure the curve endpoint equals // the point associated with the vertex. If not, we attach an invalid // vertex to the extended point. - if (! vh->is_at_open_boundary() && m_base_equal (base_p, vh->point())) + if (! vh->is_at_open_boundary() && m_base_equal(base_p, vh->point())) return (Point_2(base_p, vh)); - else - return (Point_2 (base_p)); + else return (Point_2(base_p)); } }; /*! Obtain a Construct_min_vertex_2 function object */ - Construct_min_vertex_2 construct_min_vertex_2_object () const + Construct_min_vertex_2 construct_min_vertex_2_object() const { return (Construct_min_vertex_2 (m_base_traits->construct_min_vertex_2_object(), @@ -318,57 +277,54 @@ public: /*! A functor that obtains the right endpoint of an x-monotone curve. */ class Construct_max_vertex_2 { protected: - Base_construct_max_vertex_2 m_base_max_v; - Base_equal_2 m_base_equal; - Halfedge_handle invalid_he; + Base_construct_max_vertex_2 m_base_max_v; + Base_equal_2 m_base_equal; + Halfedge_handle invalid_he; /*! Constructor. * The constructor is declared private to allow only the functor * obtaining function, which is a member of the nesting class, * constructing it. */ - Construct_max_vertex_2 (const Base_construct_max_vertex_2& base_max_v, - const Base_equal_2& base_equal) : - m_base_max_v (base_max_v), - m_base_equal (base_equal), + Construct_max_vertex_2(const Base_construct_max_vertex_2& base_max_v, + const Base_equal_2& base_equal) : + m_base_max_v(base_max_v), + m_base_equal(base_equal), invalid_he() {} //! Allow its functor obtaining function calling the private constructor. - friend class Arr_basic_insertion_traits_2; + friend class Arr_basic_insertion_traits_2; public: - Point_2 operator() (const X_monotone_curve_2 & xcv) + Point_2 operator()(const X_monotone_curve_2& xcv) { // If there is not halfedge associated with the curve, just return // a point with invalid halfedge handle. - const Base_point_2& base_p = m_base_max_v(xcv.base()); + const Base_point_2& base_p = m_base_max_v(xcv.base()); - if (xcv.halfedge_handle() == invalid_he) - return (Point_2 (base_p)); + if (xcv.halfedge_handle() == invalid_he) return (Point_2(base_p)); // Note that the halfedge associated with the curve is always directed // from right to left, so its source is the rightmost vertex. // We probably have to associate the point with the source vertex of // the halfedge associated with the curve. - Vertex_handle vh = xcv.halfedge_handle()->source(); + Vertex_handle vh = xcv.halfedge_handle()->source(); - if (! xcv.is_overlapping()) - return (Point_2(base_p, vh)); + if (! xcv.is_overlapping()) return (Point_2(base_p, vh)); // In case of an overlapping curve, make sure the curve endpoint equals // the point associated with the vertex. If not, we attach an invalid // vertex to the extended point. - if (! vh->is_at_open_boundary() && m_base_equal (base_p, vh->point())) + if (! vh->is_at_open_boundary() && m_base_equal(base_p, vh->point())) return (Point_2(base_p, vh)); - else - return (Point_2 (base_p)); + else return (Point_2(base_p)); } }; /*! Obtain a Construct_max_vertex_2 function object */ - Construct_max_vertex_2 construct_max_vertex_2_object () const + Construct_max_vertex_2 construct_max_vertex_2_object() const { return (Construct_max_vertex_2 (m_base_traits->construct_max_vertex_2_object(), @@ -385,27 +341,25 @@ public: * obtaining function, which is a member of the nesting class, * constructing it. */ - Compare_xy_2(const Base_compare_xy_2 & base) : m_base_cmp_xy(base) {} + Compare_xy_2(const Base_compare_xy_2& base) : m_base_cmp_xy(base) {} //! Allow its functor obtaining function calling the private constructor. - friend class Arr_basic_insertion_traits_2; + friend class Arr_basic_insertion_traits_2; public: - Comparison_result operator() (const Point_2& p1, const Point_2& p2) const + Comparison_result operator()(const Point_2& p1, const Point_2& p2) const { if(p1.vertex_handle() == p2.vertex_handle() && p1.vertex_handle() != Vertex_handle()) - return (EQUAL); + return EQUAL; return (m_base_cmp_xy(p1.base(), p2.base())); } }; /*! Obtain a Compare_xy_2 function object */ - Compare_xy_2 compare_xy_2_object () const - { - return (Compare_xy_2 (m_base_traits->compare_xy_2_object())); - } + Compare_xy_2 compare_xy_2_object() const + { return (Compare_xy_2(m_base_traits->compare_xy_2_object())); } /*! A functor that compares the y-coordinates of a point and an * x-monotone curve at the point x-coordinate. @@ -420,25 +374,21 @@ public: * constructing it. */ Compare_y_at_x_2(const Base_compare_y_at_x_2& base) : - m_base_cmp_y_at_x(base) + m_base_cmp_y_at_x(base) {} //! Allow its functor obtaining function calling the private constructor. - friend class Arr_basic_insertion_traits_2; + friend class Arr_basic_insertion_traits_2; public: - Comparison_result operator() (const Point_2& p, - const X_monotone_curve_2& xcv) const - { - return (m_base_cmp_y_at_x (p.base(), xcv.base())); - } + Comparison_result operator()(const Point_2& p, + const X_monotone_curve_2& xcv) const + { return (m_base_cmp_y_at_x(p.base(), xcv.base())); } }; /*! Obtain a Compare_y_at_x_2 function object */ - Compare_y_at_x_2 compare_y_at_x_2_object () const - { - return (Compare_y_at_x_2 (m_base_traits->compare_y_at_x_2_object())); - } + Compare_y_at_x_2 compare_y_at_x_2_object() const + { return (Compare_y_at_x_2(m_base_traits->compare_y_at_x_2_object())); } /*! A functor that compares compares the y-coordinates of two x-monotone * curves immediately to the right of their intersection point. @@ -457,21 +407,17 @@ public: {} //! Allow its functor obtaining function calling the private constructor. - friend class Arr_basic_insertion_traits_2; + friend class Arr_basic_insertion_traits_2; public: - Comparison_result operator() (const X_monotone_curve_2& xcv1, - const X_monotone_curve_2& xcv2, - const Point_2& p) const - { - return (m_base_cmp_y_at_x_right(xcv1.base(), - xcv2.base(), - p.base())); - } + Comparison_result operator()(const X_monotone_curve_2& xcv1, + const X_monotone_curve_2& xcv2, + const Point_2& p) const + { return (m_base_cmp_y_at_x_right(xcv1.base(), xcv2.base(), p.base())); } }; /*! Obtain a Compare_y_at_x_right_2 function object */ - Compare_y_at_x_right_2 compare_y_at_x_right_2_object () const + Compare_y_at_x_right_2 compare_y_at_x_right_2_object() const { return (Compare_y_at_x_right_2 (m_base_traits->compare_y_at_x_right_2_object())); @@ -492,28 +438,22 @@ public: Equal_2(const Base_equal_2& base) : m_base_eq(base) {} //! Allow its functor obtaining function calling the private constructor. - friend class Arr_basic_insertion_traits_2; + friend class Arr_basic_insertion_traits_2; public: /*! Check if two curves are the same. */ - bool operator() (const X_monotone_curve_2& xcv1, - const X_monotone_curve_2& xcv2) const - { - return (m_base_eq(xcv1.base(), xcv2.base())); - } + bool operator()(const X_monotone_curve_2& xcv1, + const X_monotone_curve_2& xcv2) const + { return (m_base_eq(xcv1.base(), xcv2.base())); } /*! Check if the two points are the same. */ - bool operator() (const Point_2& p1, const Point_2& p2) const - { - return (m_base_eq(p1.base(), p2.base())); - } + bool operator()(const Point_2& p1, const Point_2& p2) const + { return (m_base_eq(p1.base(), p2.base())); } }; /*! Obtain a Equal_2 function object */ - Equal_2 equal_2_object () const - { - return (Equal_2 (m_base_traits->equal_2_object())); - } + Equal_2 equal_2_object() const + { return (Equal_2(m_base_traits->equal_2_object())); } /*! A functor that compares the x-coordinates of two points */ class Compare_x_2 { @@ -528,20 +468,16 @@ public: Compare_x_2(const Base_compare_x_2& base) : m_base_cmp_x(base) {} //! Allow its functor obtaining function calling the private constructor. - friend class Arr_basic_insertion_traits_2; + friend class Arr_basic_insertion_traits_2; public: - Comparison_result operator() (const Point_2& p1, const Point_2& p2) const - { - return (m_base_cmp_x(p1.base(), p2.base())); - } + Comparison_result operator()(const Point_2& p1, const Point_2& p2) const + { return (m_base_cmp_x(p1.base(), p2.base())); } }; /*! Obtain a Compare_x_2 function object */ - Compare_x_2 compare_x_2_object () const - { - return (Compare_x_2 (m_base_traits->compare_x_2_object())); - } + Compare_x_2 compare_x_2_object() const + { return (Compare_x_2(m_base_traits->compare_x_2_object())); } /*! A functor that checks whether a given x-monotone curve is vertical. */ class Is_vertical_2 { @@ -556,20 +492,16 @@ public: Is_vertical_2(const Base_is_vertical_2& base) : m_base_is_vert(base) {} //! Allow its functor obtaining function calling the private constructor. - friend class Arr_basic_insertion_traits_2; + friend class Arr_basic_insertion_traits_2; public: - bool operator() (const X_monotone_curve_2& xcv) const - { - return (m_base_is_vert(xcv.base())); - } + bool operator()(const X_monotone_curve_2& xcv) const + { return (m_base_is_vert(xcv.base())); } }; /*! Obtain a Is_vertical_2 function object */ Is_vertical_2 is_vertical_2_object() const - { - return (Is_vertical_2(m_base_traits->is_vertical_2_object())); - } + { return (Is_vertical_2(m_base_traits->is_vertical_2_object())); } // left-right @@ -579,7 +511,7 @@ public: class Parameter_space_in_x_2 { protected: //! The base traits. - const Traits_2 * m_base; + const Gt2* m_base; /*! Constructor. * \param tr The base traits class. It must be passed, to handle non @@ -588,43 +520,34 @@ public: * obtaining function, which is a member of the nesting class, * constructing it. */ - Parameter_space_in_x_2 (const Traits_2 * tr) : m_base(tr) {} + Parameter_space_in_x_2(const Gt2* tr) : m_base(tr) {} //! Allow its functor obtaining function calling the private constructor. - friend class Arr_basic_insertion_traits_2; + friend class Arr_basic_insertion_traits_2; public: - Arr_parameter_space operator() (const X_monotone_curve_2 & xcv, - Arr_curve_end ce) const - { - return (m_base->parameter_space_in_x_2_object() (xcv.base(), ce)); - } + Arr_parameter_space operator()(const X_monotone_curve_2& xcv, + Arr_curve_end ce) const + { return (m_base->parameter_space_in_x_2_object()(xcv.base(), ce)); } - Arr_parameter_space operator()(const Point_2 & p) const - { - return m_base->parameter_space_in_x_2_object() (p.base()); - } + Arr_parameter_space operator()(const Point_2& p) const + { return m_base->parameter_space_in_x_2_object()(p.base()); } - Arr_parameter_space operator()(const X_monotone_curve_2 & xcv) const - { - return m_base->parameter_space_in_x_2_object() (xcv.base()); - } - + Arr_parameter_space operator()(const X_monotone_curve_2& xcv) const + { return m_base->parameter_space_in_x_2_object()(xcv.base()); } }; /*! Obtain a Parameter_space_in_x_2 function object */ - Parameter_space_in_x_2 parameter_space_in_x_2_object () const - { - return Parameter_space_in_x_2 (m_base_traits); - } - + Parameter_space_in_x_2 parameter_space_in_x_2_object() const + { return Parameter_space_in_x_2(m_base_traits); } + /*! A function object that determines whether an x-monotone curve or a * point coincide with the vertical identification curve. */ class Is_on_x_identification_2 { protected: //! The base traits. - const Traits_2 * m_base; + const Gt2* m_base; /*! Constructor. * \param tr The base traits class. It must be passed, to handle non @@ -633,39 +556,31 @@ public: * obtaining function, which is a member of the nesting class, * constructing it. */ - Is_on_x_identification_2 (const Traits_2 * tr) : m_base(tr) {} + Is_on_x_identification_2(const Gt2* tr) : m_base(tr) {} //! Allow its functor obtaining function calling the private constructor. - friend class Arr_basic_insertion_traits_2; + friend class Arr_basic_insertion_traits_2; public: - bool operator()(const Point_2 & p) const - { - return m_base->is_on_x_identification_2_object() (p.base()); - } + bool operator()(const Point_2& p) const + { return m_base->is_on_x_identification_2_object()(p.base()); } - bool operator()(const X_monotone_curve_2 & xcv) const - { - return m_base->is_on_x_identification_2_object() (xcv.base()); - } - + bool operator()(const X_monotone_curve_2& xcv) const + { return m_base->is_on_x_identification_2_object()(xcv.base()); } }; /*! Obtain a Is_on_x_identification_2 function object */ - Is_on_x_identification_2 is_on_x_identification_2_object () const - { - return Is_on_x_identification_2 (m_base_traits); - } + Is_on_x_identification_2 is_on_x_identification_2_object() const + { return Is_on_x_identification_2(m_base_traits); } /*! A functor that compares the y-coordinates of two points on vertical * boundaries. */ - class Compare_y_on_boundary_2 - { + class Compare_y_on_boundary_2 { protected: //! The base traits. - const Traits_2 * m_base; - + const Gt2* m_base; + /*! Constructor. * \param base The base traits class. It must be passed, to handle non * stateless traits objects, (which stores data). @@ -673,29 +588,23 @@ public: * obtaining function, which is a member of the nesting class, * constructing it. */ - Compare_y_on_boundary_2 (const Traits_2 * base) : m_base(base) {} + Compare_y_on_boundary_2(const Gt2* base) : m_base(base) {} //! Allow its functor obtaining function calling the private constructor. - friend class Arr_basic_insertion_traits_2; + friend class Arr_basic_insertion_traits_2; public: /*! Use tag dispatching to avoid compilation errors in case the functor * is not defined */ - Comparison_result operator() (const Point_2 & p1, - const Point_2 & p2) const - { - return m_base->compare_y_on_boundary_2_object()(p1.base(), p2.base()); - } - + Comparison_result operator()(const Point_2& p1, const Point_2& p2) const + { return m_base->compare_y_on_boundary_2_object()(p1.base(), p2.base()); } }; /*! Obtain a Compare_y_on_boundary_2 object - */ + */ Compare_y_on_boundary_2 compare_y_on_boundary_2_object() const - { - return Compare_y_on_boundary_2(m_base_traits); - } + { return Compare_y_on_boundary_2(m_base_traits); } /*! A functor that compares the y-coordinates of curve ends near the * boundary of the parameter space. @@ -703,7 +612,7 @@ public: class Compare_y_near_boundary_2 { protected: //! The base traits. - const Traits_2 * m_base; + const Gt2* m_base; /*! Constructor. * \param base The base traits class. It must be passed, to handle non @@ -712,33 +621,29 @@ public: * obtaining function, which is a member of the nesting class, * constructing it. */ - Compare_y_near_boundary_2(const Traits_2 * base) : m_base(base) {} + Compare_y_near_boundary_2(const Gt2* base) : m_base(base) {} //! Allow its functor obtaining function calling the private constructor. - friend class Arr_basic_insertion_traits_2; + friend class Arr_basic_insertion_traits_2; public: /*! Use tag dispatching to avoid compilation errors in case the functor * is not defined */ - Comparison_result operator() (const X_monotone_curve_2 & xcv1, - const X_monotone_curve_2 & xcv2, - Arr_curve_end ce) const + Comparison_result operator()(const X_monotone_curve_2& xcv1, + const X_monotone_curve_2& xcv2, + Arr_curve_end ce) const { - return m_base->compare_y_near_boundary_2_object() (xcv1.base(), - xcv2.base(), ce); + return m_base->compare_y_near_boundary_2_object()(xcv1.base(), + xcv2.base(), ce); } }; /*! Obtain a Compare_y_near_boundary_2 object - */ + */ Compare_y_near_boundary_2 compare_y_near_boundary_2_object() const - { - return Compare_y_near_boundary_2 (m_base_traits); - } - - + { return Compare_y_near_boundary_2(m_base_traits); } // bottom-top @@ -748,7 +653,7 @@ public: class Parameter_space_in_y_2 { protected: //! The base traits. - const Traits_2 * m_base; + const Gt2* m_base; /*! Constructor. * \param tr The base traits class. It must be passed, to handle non @@ -757,35 +662,27 @@ public: * obtaining function, which is a member of the nesting class, * constructing it. */ - Parameter_space_in_y_2(const Traits_2 * tr) : m_base(tr) {} + Parameter_space_in_y_2(const Gt2* tr) : m_base(tr) {} //! Allow its functor obtaining function calling the private constructor. - friend class Arr_basic_insertion_traits_2; + friend class Arr_basic_insertion_traits_2; public: - Arr_parameter_space operator() (const X_monotone_curve_2& xcv, - Arr_curve_end ce) const - { - return m_base->parameter_space_in_y_2_object() (xcv.base(), ce); - } + Arr_parameter_space operator()(const X_monotone_curve_2& xcv, + Arr_curve_end ce) const + { return m_base->parameter_space_in_y_2_object()(xcv.base(), ce); } - Arr_parameter_space operator()(const Point_2 & p) const - { - return m_base->parameter_space_in_y_2_object() (p.base()); - } + Arr_parameter_space operator()(const Point_2& p) const + { return m_base->parameter_space_in_y_2_object()(p.base()); } - Arr_parameter_space operator()(const X_monotone_curve_2 & xcv) const - { - return m_base->parameter_space_in_y_2_object() (xcv.base()); - } + Arr_parameter_space operator()(const X_monotone_curve_2& xcv) const + { return m_base->parameter_space_in_y_2_object()(xcv.base()); } }; /*! Obtain a Parameter_space_in_y_2 function object */ - Parameter_space_in_y_2 parameter_space_in_y_2_object () const - { - return Parameter_space_in_y_2 (m_base_traits); - } + Parameter_space_in_y_2 parameter_space_in_y_2_object() const + { return Parameter_space_in_y_2(m_base_traits); } /*! A function object that determines whether an x-monotone curve or a * point coincide with the horizontal identification curve. @@ -793,7 +690,7 @@ public: class Is_on_y_identification_2 { protected: //! The base traits. - const Traits_2 * m_base; + const Gt2* m_base; /*! Constructor. * \param tr The base traits class. It must be passed, to handle non @@ -802,29 +699,22 @@ public: * obtaining function, which is a member of the nesting class, * constructing it. */ - Is_on_y_identification_2 (const Traits_2 * tr) : m_base(tr) {} + Is_on_y_identification_2(const Gt2* tr) : m_base(tr) {} //! Allow its functor obtaining function calling the private constructor. - friend class Arr_basic_insertion_traits_2; + friend class Arr_basic_insertion_traits_2; public: - bool operator()(const Point_2 & p) const - { - return m_base->is_on_y_identification_2_object() (p.base()); - } + bool operator()(const Point_2& p) const + { return m_base->is_on_y_identification_2_object()(p.base()); } bool operator()(const X_monotone_curve_2 & xcv) const - { - return m_base->is_on_y_identification_2_object() (xcv.base()); - } - + { return m_base->is_on_y_identification_2_object()(xcv.base()); } }; /*! Obtain a Is_on_y_identification_2 function object */ - Is_on_y_identification_2 is_on_y_identification_2_object () const - { - return Is_on_y_identification_2 (m_base_traits); - } + Is_on_y_identification_2 is_on_y_identification_2_object() const + { return Is_on_y_identification_2(m_base_traits); } /*! A functor that compares the x-limits of curve ends on the * boundary of the parameter space. @@ -832,7 +722,7 @@ public: class Compare_x_at_limit_2 { protected: //! The base traits. - const Traits_2 * m_base; + const Gt2* m_base; /*! Constructor. * \param base The base traits class. It must be passed, to handle non @@ -841,44 +731,37 @@ public: * obtaining function, which is a member of the nesting class, * constructing it. */ - Compare_x_at_limit_2 (const Traits_2 * base) : m_base(base) {} + Compare_x_at_limit_2(const Gt2* base) : m_base(base) {} //! Allow its functor obtaining function calling the private constructor. - friend class Arr_basic_insertion_traits_2; + friend class Arr_basic_insertion_traits_2; public: /*! Use tag dispatching to avoid compilation errors in case the functor * is not defined */ - Comparison_result operator() (const Point_2 & p, - const X_monotone_curve_2 & xcv, - Arr_curve_end ce) const - { - - return m_base->compare_x_at_limit_2_object() (p.base(), - xcv.base(), ce); - } + Comparison_result operator()(const Point_2& p, + const X_monotone_curve_2& xcv, + Arr_curve_end ce) const + { return m_base->compare_x_at_limit_2_object()(p.base(), xcv.base(), ce); } /*! Use tag dispatching to avoid compilation errors in case the functor * is not defined */ - Comparison_result operator() (const X_monotone_curve_2 & xcv1, - Arr_curve_end ce1, - const X_monotone_curve_2 & xcv2, - Arr_curve_end ce2) const + Comparison_result operator()(const X_monotone_curve_2& xcv1, + Arr_curve_end ce1, + const X_monotone_curve_2& xcv2, + Arr_curve_end ce2) const { - return m_base->compare_x_at_limit_2_object() (xcv1.base(), ce1, - xcv2.base(), ce2); + return m_base->compare_x_at_limit_2_object()(xcv1.base(), ce1, + xcv2.base(), ce2); } - }; - + /*! Obtain a Compare_x_at_limit_2 object - */ + */ Compare_x_at_limit_2 compare_x_at_limit_2_object() const - { - return Compare_x_at_limit_2(m_base_traits); - } + { return Compare_x_at_limit_2(m_base_traits); } /*! A functor that compares the x-coordinates of curve ends near the @@ -887,7 +770,7 @@ public: class Compare_x_near_limit_2 { protected: //! The base traits. - const Traits_2 * m_base; + const Gt2* m_base; /*! Constructor. * \param base The base traits class. It must be passed, to handle non @@ -896,42 +779,39 @@ public: * obtaining function, which is a member of the nesting class, * constructing it. */ - Compare_x_near_limit_2 (const Traits_2 * base) : m_base(base) {} + Compare_x_near_limit_2(const Gt2* base) : m_base(base) {} //! Allow its functor obtaining function calling the private constructor. - friend class Arr_basic_insertion_traits_2; + friend class Arr_basic_insertion_traits_2; public: - /*! Use tag dispatching to avoid compilation errors in case the functor * is not defined */ - Comparison_result operator() (const X_monotone_curve_2 & xcv1, - const X_monotone_curve_2 & xcv2, - Arr_curve_end ce) const + Comparison_result operator()(const X_monotone_curve_2& xcv1, + const X_monotone_curve_2& xcv2, + Arr_curve_end ce) const { - return m_base->compare_x_near_limit_2_object() (xcv1.base(), xcv2.base(), - ce); + return m_base->compare_x_near_limit_2_object()(xcv1.base(), xcv2.base(), + ce); } }; - + /*! Obtain a Compare_x_near_limit_2 object - */ + */ Compare_x_near_limit_2 compare_x_near_limit_2_object() const - { - return Compare_x_near_limit_2(m_base_traits); - } + { return Compare_x_near_limit_2(m_base_traits); } /*! A functor that compares the x-coordinates of two points on vertical * boundaries. */ - class Compare_x_on_boundary_2 + class Compare_x_on_boundary_2 { protected: //! The base traits. - const Traits_2 * m_base; - + const Gt2* m_base; + /*! Constructor. * \param base The base traits class. It must be passed, to handle non * stateless traits objects, (which stores data). @@ -939,26 +819,24 @@ public: * obtaining function, which is a member of the nesting class, * constructing it. */ - Compare_x_on_boundary_2 (const Traits_2 * base) : m_base(base) {} + Compare_x_on_boundary_2(const Gt2* base) : m_base(base) {} //! Allow its functor obtaining function calling the private constructor. - friend class Arr_basic_insertion_traits_2; + friend class Arr_basic_insertion_traits_2; public: /*! Use tag dispatching to avoid compilation errors in case the functor * is not defined */ - Comparison_result operator() (const Point_2 & p1, - const Point_2 & p2) const - { - return m_base->compare_x_on_boundary_2_object()(p1.base(), p2.base()); - } + Comparison_result operator()(const Point_2& p1, const Point_2& p2) const + { return m_base->compare_x_on_boundary_2_object()(p1.base(), p2.base()); } /*! Use tag dispatching to avoid compilation errors in case the functor * is not defined */ - Comparison_result operator() (const Point_2 & pt, - const X_monotone_curve_2& xcv, Arr_curve_end ce) const + Comparison_result operator()(const Point_2 & pt, + const X_monotone_curve_2& xcv, + Arr_curve_end ce) const { return m_base->compare_x_on_boundary_2_object()(pt.base(), xcv.base(), ce); } @@ -966,20 +844,20 @@ public: /*! Use tag dispatching to avoid compilation errors in case the functor * is not defined */ - Comparison_result operator() (const X_monotone_curve_2& xcv1, Arr_curve_end ce1, - const X_monotone_curve_2& xcv2, Arr_curve_end ce2) const + Comparison_result operator()(const X_monotone_curve_2& xcv1, + Arr_curve_end ce1, + const X_monotone_curve_2& xcv2, + Arr_curve_end ce2) const { - return m_base->compare_x_on_boundary_2_object()(xcv1.base(), ce1, xcv2.base(), ce2); + return m_base->compare_x_on_boundary_2_object()(xcv1.base(), ce1, + xcv2.base(), ce2); } - }; /*! Obtain a Compare_x_on_boundary_2 object - */ + */ Compare_x_on_boundary_2 compare_x_on_boundary_2_object() const - { - return Compare_x_on_boundary_2(m_base_traits); - } + { return Compare_x_on_boundary_2(m_base_traits); } /*! A functor that compares the x-coordinates of curve ends near the * boundary of the parameter space. @@ -987,7 +865,7 @@ public: class Compare_x_near_boundary_2 { protected: //! The base traits. - const Traits_2 * m_base; + const Gt2* m_base; /*! Constructor. * \param base The base traits class. It must be passed, to handle non @@ -996,33 +874,28 @@ public: * obtaining function, which is a member of the nesting class, * constructing it. */ - Compare_x_near_boundary_2 (const Traits_2 * base) : m_base(base) {} + Compare_x_near_boundary_2(const Gt2* base) : m_base(base) {} //! Allow its functor obtaining function calling the private constructor. - friend class Arr_basic_insertion_traits_2; + friend class Arr_basic_insertion_traits_2; public: - /*! Use tag dispatching to avoid compilation errors in case the functor * is not defined */ - Comparison_result operator() (const X_monotone_curve_2 & xcv1, - const X_monotone_curve_2 & xcv2, - Arr_curve_end ce) const + Comparison_result operator()(const X_monotone_curve_2& xcv1, + const X_monotone_curve_2& xcv2, + Arr_curve_end ce) const { - return m_base->compare_x_near_boundary_2_object() (xcv1.base(), xcv2.base(), - ce); + return m_base->compare_x_near_boundary_2_object()(xcv1.base(), + xcv2.base(), ce); } - }; - - /*! Obtain a Compare_x_near_boundary_2 object - */ - Compare_x_near_boundary_2 compare_x_near_boundary_2_object() const - { - return Compare_x_near_boundary_2(m_base_traits); - } + /*! Obtain a Compare_x_near_boundary_2 object + */ + Compare_x_near_boundary_2 compare_x_near_boundary_2_object() const + { return Compare_x_near_boundary_2(m_base_traits); } }; } //namespace CGAL diff --git a/Sweep_line_2/include/CGAL/Sweep_line_2/Arr_batched_pl_sl_visitor.h b/Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_batched_pl_ss_visitor.h similarity index 65% rename from Sweep_line_2/include/CGAL/Sweep_line_2/Arr_batched_pl_sl_visitor.h rename to Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_batched_pl_ss_visitor.h index 72203140be8..658b75ccce5 100644 --- a/Sweep_line_2/include/CGAL/Sweep_line_2/Arr_batched_pl_sl_visitor.h +++ b/Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_batched_pl_ss_visitor.h @@ -15,82 +15,104 @@ // $URL$ // $Id$ // SPDX-License-Identifier: GPL-3.0+ -// +// // // Author(s) : Baruch Zukerman // Ron Wein +// Efi Fogel -#ifndef CGAL_ARR_BATCHED_PL_SL_VISITOR_H -#define CGAL_ARR_BATCHED_PL_SL_VISITOR_H +#ifndef CGAL_ARR_BATCHED_PL_SS_VISITOR_H +#define CGAL_ARR_BATCHED_PL_SS_VISITOR_H -#include +#include - -/*! - * Definition of the Arr_batched_pl_sl_visitor class-template. +/*! \file + * + * Definition of the Arr_batched_pl_ss_visitor class-template. */ #include #include - -#include -#include +#include +#include namespace CGAL { -/*! \class Arr_batched_pl_sl_visitor - * A sweep-line visitor for performing batched point-location queries on an +namespace Ss2 = Surface_sweep_2; + +/*! \class Arr_batched_pl_ss_visitor + * + * A surface-sweep visitor for performing batched point-location queries on an * arrangement embedded on a surface. */ -template -class Arr_batched_pl_sl_visitor : public Helper_::Base_visitor { +template +class Arr_batched_pl_ss_visitor : + public Ss2::Default_visitor_base >::type> +{ public: typedef Helper_ Helper; - typedef OutputIterator_ OutputIterator; + typedef OutputIterator Output_iterator; - typedef typename Helper::Traits_2 Traits_2; - typedef typename Helper::Arrangement_2 Arrangement_2; + typedef typename Helper::Geometry_traits_2 Geometry_traits_2; typedef typename Helper::Event Event; typedef typename Helper::Subcurve Subcurve; + typedef typename Helper::Allocator Allocator; +private: + typedef Geometry_traits_2 Gt2; + typedef Arr_batched_pl_ss_visitor + Self; + typedef typename Default::Get::type Visitor; + typedef typename Ss2::Default_visitor_base Base; + +public: + typedef typename Helper::Arrangement_2 Arrangement_2; typedef typename Arrangement_2::Vertex_const_handle Vertex_const_handle; typedef typename Arrangement_2::Halfedge_const_handle Halfedge_const_handle; typedef typename Arrangement_2::Face_const_handle Face_const_handle; protected: - typedef typename Helper::Base_visitor Base; typedef typename Base::Status_line_iterator Status_line_iterator; - + typedef Arr_point_location_result Pl_result; typedef typename Pl_result::Type Pl_result_type; // Data members: - Helper m_helper; // The helper class. - OutputIterator& m_out; // An output iterator for the result. + Helper m_helper; // The helper class. + Output_iterator& m_out; // An output iterator for the result. template Pl_result_type pl_make_result(T t) { return Pl_result::make_result(t); } - inline Pl_result_type pl_default_result() { return Pl_result::default_result(); } - + + inline Pl_result_type pl_default_result() + { return Pl_result::default_result(); } + public: - /*! - * Constructor. + /*! Constructor. * \param arr The arrangement. * \param oi A pointer to the output iterator that will store the result. */ - Arr_batched_pl_sl_visitor(const Arrangement_2* arr, OutputIterator& oi) : + Arr_batched_pl_ss_visitor(const Arrangement_2* arr, Output_iterator& oi) : m_helper(arr), m_out(oi) {} - + /* A notification issued before the sweep process starts. */ void before_sweep(); - /*! - * A notification invoked after the sweep-line finishes handling the given + /*! A notification invoked after the surface-sweep finishes handling the given * event. * \param event The event. - * \param above An iterator to the sweep-line subcurves lying right above + * \param above An iterator to the surface-sweep subcurves lying right above * (or on) the event point. * \param on_above Whether the event is locates on the subcurve above it. */ @@ -106,27 +128,26 @@ public: //----------------------------------------------------------------------------- // A notification issued before the sweep process starts. // -template -void Arr_batched_pl_sl_visitor::before_sweep() + template + void Arr_batched_pl_ss_visitor::before_sweep() { // We just have to notify the helper that the sweep process now starts. m_helper.before_sweep(); } //----------------------------------------------------------------------------- -// A notification invoked after the sweep-line finishes handling the given +// A notification invoked after the surface-sweep finishes handling the given // event. // -template -bool Arr_batched_pl_sl_visitor:: +template +bool Arr_batched_pl_ss_visitor:: after_handle_event(Event* event, Status_line_iterator above, bool on_above) { // Notify the helper on the event. m_helper.after_handle_event(event); // We are only interested in events associated with query points: - if (! event->is_query()) - return true; + if (! event->is_query()) return true; // Check on what kind of feature does the current query point lie. if (event->is_action()) { @@ -178,11 +199,11 @@ after_handle_event(Event* event, Status_line_iterator above, bool on_above) // If we reached here, the status-line iterator refers to a halfedge above // the query point, such that the query point is located in the incident // face of this halfedge. - Halfedge_const_handle he = (*above)->last_curve().halfedge_handle(); + Halfedge_const_handle he = (*above)->last_curve().halfedge_handle(); *m_out++ = std::make_pair(event->point().base(), pl_make_result(he->face())); return true; } -} //namespace CGAL +} // namespace CGAL #endif diff --git a/Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_construction_event.h b/Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_construction_event.h new file mode 100644 index 00000000000..bd2ea6c9f85 --- /dev/null +++ b/Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_construction_event.h @@ -0,0 +1,92 @@ +// Copyright (c) 2006,2007,2009,2010,2011 Tel-Aviv University (Israel). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// You can redistribute it and/or modify it under the terms of the GNU +// General Public License as published by the Free Software Foundation, +// either version 3 of the License, or (at your option) any later version. +// +// Licensees holding a valid commercial license may use this file in +// accordance with the commercial license agreement provided with the software. +// +// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Author(s) : Tali Zvi +// Baruch Zukerman +// Efi Fogel + +#ifndef CGAL_ARR_CONSTRUCTION_EVENT_H +#define CGAL_ARR_CONSTRUCTION_EVENT_H + +#include + +/*! \file + * + * Definition of the Arr_construction_event class-template. + */ + +#include +#include +#include +#include + +namespace CGAL { + +namespace Ss2 = Surface_sweep_2; + +/*! \class Default_event + * + * This template represents an event used by the surface-sweep framework, where + * the input curves for the surface-sweep procedure are to be inserted into a + * 2D arrangement. + * + * \tparam GeometryTraits_2 the geometry traits. + * \tparam Arrangement_ the type of the costructed arrangement. + * \tparam Allocator_ a type of an element that is used to acquire/release + * memory for elements of the event queue and the status + * structure, and to construct/destroy the elements in that + * memory. The type must meet the requirements of Allocator. + * \tparam SurfaceSweepBaseEvent the base class of the event. + * \tparam SurfaceSweepBaseCurve the base class of the subcurve. + * + * We exploit the curiously recurring template pattern (CRTP) idiom to establish + * an interdependency between the curve and the event types, which are template + * parameters of the surface-sweep visitor class templates. It enables the + * definition of these two types, which refer one to another; (the curves to the + * right of an event and the curves to its left are data members of the event, + * and the two events associated with the endpoints of a curve are data memebrs + * of the curve.) + * + * If you need to represent an event with additional data members, introduce a + * new type, say x, that derives from x_base, and have x_base derive from + * Arr_construction_event_base; do not use this class as base in your + * derivation. + */ +template + class SurfaceSweepBaseEvent = Ss2::Default_event_base, + template + class SurfaceSweepBaseCurve = Ss2::Default_subcurve> +class Arr_construction_event : + public Arr_construction_event_base< + GeometryTraits_2, + Arr_construction_subcurve, + Allocator_, + SurfaceSweepBaseCurve>, + Arrangement_, SurfaceSweepBaseEvent> +{ +public: + /*! Construct default. */ + Arr_construction_event() {} +}; + +} // namespace CGAL + +#endif diff --git a/Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_construction_event_base.h b/Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_construction_event_base.h new file mode 100644 index 00000000000..f5f25e1ce0b --- /dev/null +++ b/Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_construction_event_base.h @@ -0,0 +1,238 @@ +// Copyright (c) 2006,2007,2009,2010,2011 Tel-Aviv University (Israel). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// You can redistribute it and/or modify it under the terms of the GNU +// General Public License as published by the Free Software Foundation, +// either version 3 of the License, or (at your option) any later version. +// +// Licensees holding a valid commercial license may use this file in +// accordance with the commercial license agreement provided with the software. +// +// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Author(s) : Tali Zvi +// Baruch Zukerman +// Efi Fogel + +#ifndef CGAL_ARR_CONSTRUCTION_EVENT_BASE_H +#define CGAL_ARR_CONSTRUCTION_EVENT_BASE_H + +#include + +/*! \file + * + * Definition of the Arr_construction_event_base class-template. + */ + +#include + +#include +#include + +namespace CGAL { + +namespace Ss2 = Surface_sweep_2; + +/*! \class Arr_construction_event_base + * + * This template represents an event used by the surface-sweep framework. It + * inherits either from `Default_event_base` (the default) or + * 'No_overlap_event_base' depending on whether the curve may overlap or not. + * It stores the data associated with an event in addition to the information + * stored in its base class. When constructing an arrangement, additional + * information is stored, in order to expedite the insertion of curves into the + * arrangement. + * + * The additional infomation contains the following: + * - among the left curves of the event, we keep the highest halfedge that + * was inserted into the arrangement at any given time and when there are no + * left curves, we keep the highest halfedge that was inseted to the right. + * + * \tparam GeometryTraits_2 the geometry traits. + * \tparam Allocator_ a type of an element that is used to acquire/release + * memory for elements of the event queue and the status + * structure, and to construct/destroy the elements in that + * memory. The type must meet the requirements of Allocator. + * \tparam SurfaceSweepEvent a template, an instance of which is used as the + * base class. + * + * \sa `Default_event_base` + * \sa `No_overlap_event_base` + */ +template + class SurfaceSweepEvent = Ss2::Default_event_base> +class Arr_construction_event_base : + public SurfaceSweepEvent +{ +public: + typedef GeometryTraits_2 Geometry_traits_2; + typedef Subcurve_ Subcurve; + typedef Arrangement_ Arrangement_2; + + typedef typename Arrangement_2::Vertex_handle Vertex_handle; + typedef typename Arrangement_2::Halfedge_handle Halfedge_handle; + +private: + typedef Geometry_traits_2 Gt2; + typedef SurfaceSweepEvent Base; + typedef Arr_construction_event_base Self; + +public: + typedef typename Gt2::X_monotone_curve_2 X_monotone_curve_2; + typedef typename Gt2::Point_2 Point_2; + + typedef typename Base::Subcurve_container Subcurve_container; + typedef typename Base::Subcurve_iterator Subcurve_iterator; + typedef typename Base::Subcurve_reverse_iterator Subcurve_reverse_iterator; + +protected: + // Data members: + std::vector m_isCurveInArr; // Stores for each incident + // subcurve whether it has been + // inserted into the arrangement. + + Halfedge_handle m_halfedge; // A halfedge handle. + Vertex_handle m_vertex; // A vertex handle. + + unsigned int m_right_curves_counter; // Number of subcurves defined + // to the event's right that + // haven't been added to the + // arrangement, when that counter + // is zero, we can deallocate the + // event. + +public: + /*! Default constructor. */ + Arr_construction_event_base(): + m_halfedge(), + m_vertex(), + m_right_curves_counter(0) + {} + + /*! Destructor */ + ~Arr_construction_event_base() {} + + /*! Add a curve to the right of the event. */ + std::pair + add_curve_to_right(Subcurve* curve, const Gt2* tr) + { + std::pair res = Base::add_curve_to_right(curve, tr); + + if (res.second != this->right_curves_end() && res.first == false) + ++m_right_curves_counter; + + return res; + } + + /*! Add a curve pair to the right of the event. */ + std::pair + add_curve_pair_to_right(Subcurve* sc1, Subcurve* sc2) + { + //increment twice the counter of right curves + m_right_curves_counter+=2; + return (Base::add_curve_pair_to_right(sc1, sc2)); + } + + /*! using the additional data that we store at the event, we compute + * how much we have to jump (he = he->next()->twin()) from the halfedge + * that is stored in the event, to the halefge that is previous to 'curve' + * that is about to be inserted into the arrangement. + */ + int compute_halfedge_jump_count(Subcurve* curve) + { + int i = 0; + int skip = 0; + int counter = 0; + unsigned int j; + + for (j = 0 ; j < m_isCurveInArr.size() ; j++) { + if (m_isCurveInArr[j]) skip++; + } + skip--; // now 'skip' holds the amount of the right curves of the event + // that are already inserted to the planar map - 1 (minus 1) + + Subcurve_iterator iter = this->right_curves_end(); + size_t num_left_curves = this->number_of_left_curves(); + + for (--iter; iter != this->right_curves_begin() ; --iter, ++counter) { + if (curve == (*iter)) { + m_isCurveInArr[counter] = true; + + if ((i == 0) && (num_left_curves == 0)) return (skip); + if (num_left_curves == 0) return (i - 1); + return (i); + } + + if (m_isCurveInArr[counter]) i++; + } + + CGAL_assertion(curve == (*iter)); + m_isCurveInArr[counter] = true; + + if (num_left_curves == 0) i--; + + return (i); + } + + /*! Return true iff 'curve' is the toppest curve among the halfedges + * to the right fo the event that were already were inserted to the + * arrangement. + */ + bool is_curve_largest(Subcurve *curve) + { + int counter = 0; + + Subcurve_reverse_iterator rev_iter; + for (rev_iter = this->right_curves_rbegin(); + rev_iter != this->right_curves_rend() && curve != (*rev_iter) ; + ++rev_iter, ++ counter) + { + if (m_isCurveInArr[counter] == true) return false; + } + return true; + } + + /*! Resize the bit-vector indicating whether the incident curves are already + * in the arrangement, and set all flags to false. + */ + void init_subcurve_in_arrangement_flags(size_t n) + { m_isCurveInArr.resize(n, false); } + + /*! Check if the i'th subcurve is in the arrangement. */ + bool is_subcurve_in_arrangement(unsigned int i) const + { return (m_isCurveInArr[i]); } + + /*! Set the flag indicating whether the i'th subcurve is in the arrangement. + */ + void set_subcurve_in_arrangement(unsigned int i, bool flag) + { m_isCurveInArr[i] = flag; } + + /*! Set the halfedge handle. */ + void set_halfedge_handle(Halfedge_handle h) { m_halfedge = h; } + + /*! Get the halfedge handle. */ + Halfedge_handle halfedge_handle() const { return m_halfedge; } + + /*! Set the vertex handle. */ + void set_vertex_handle(Vertex_handle v) { m_vertex = v; } + + /*! Get the vertex handle. */ + Vertex_handle vertex_handle() const { return m_vertex; } + + /*! Decrement the count of curves to the right that we have't done yet with + * (haven't been inserted to the arrangement). */ + unsigned int dec_right_curves_counter() { return (--m_right_curves_counter); } + + /*! Get the number of subcurves to the right of the event that we have't + * done yet with (haven't been inserted to the arrangement). + */ + unsigned int right_curves_counter() const { return (m_right_curves_counter); } +}; + +} // namespace CGAL + +#endif diff --git a/Sweep_line_2/include/CGAL/Sweep_line_2/Arr_construction_sl_visitor.h b/Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_construction_ss_visitor.h similarity index 86% rename from Sweep_line_2/include/CGAL/Sweep_line_2/Arr_construction_sl_visitor.h rename to Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_construction_ss_visitor.h index 1ddca02b8ea..b439719f380 100644 --- a/Sweep_line_2/include/CGAL/Sweep_line_2/Arr_construction_sl_visitor.h +++ b/Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_construction_ss_visitor.h @@ -21,26 +21,31 @@ // Ron Wein // Efi Fogel -#ifndef CGAL_ARR_CONSTRUCTION_SL_VISITOR_H -#define CGAL_ARR_CONSTRUCTION_SL_VISITOR_H - -#include +#ifndef CGAL_ARR_CONSTRUCTION_SS_VISITOR_H +#define CGAL_ARR_CONSTRUCTION_SS_VISITOR_H +#include #ifndef CGAL_ARR_CONSTRUCTION_SL_VISITOR_VERBOSE #define CGAL_ARR_CONSTRUCTION_SL_VISITOR_VERBOSE 0 #endif -/*! - * Definition of the Arr_construction_sl_visitor class-template. +/*! \file + * + * Definition of the Arr_construction_ss_visitor class-template. */ +#include + #include #include -#include +#include +#include namespace CGAL { +namespace Ss2 = Surface_sweep_2; + /*! \struct Integer_hash_function * An auxiliary hash functor for integers. */ @@ -50,38 +55,55 @@ struct Integer_hash_function { std::size_t operator()(unsigned int i) const { return i; } }; -/*! \class Arr_construction_sl_visitor +/*! \class Arr_construction_ss_visitor * A sweep-line visitor for constructing an arrangement embedded on a surface. */ -template -class Arr_construction_sl_visitor : public Helper_::Base_visitor { +template +class Arr_construction_ss_visitor : + public Ss2::Default_visitor_base >::type> +{ public: - typedef Helper_ Helper; + typedef Helper_ Helper; - typedef typename Helper::Traits_2 Traits_2; - typedef typename Helper::Arrangement_2 Arrangement_2; - typedef typename Helper::Base_visitor Base; - typedef typename Helper::Event Event; - typedef typename Helper::Subcurve Subcurve; + typedef typename Helper::Geometry_traits_2 Geometry_traits_2; + typedef typename Helper::Event Event; + typedef typename Helper::Subcurve Subcurve; + typedef typename Helper::Allocator Allocator; - typedef typename Traits_2::X_monotone_curve_2 X_monotone_curve_2; - typedef typename Traits_2::Point_2 Point_2; +private: + typedef Geometry_traits_2 Gt2; + typedef Arr_construction_ss_visitor Self; + typedef typename Default::Get::type Visitor; + typedef Ss2::Default_visitor_base + Base; + +public: + typedef typename Gt2::X_monotone_curve_2 X_monotone_curve_2; + typedef typename Gt2::Point_2 Point_2; protected: - typedef typename Arrangement_2::Topology_traits Topology_traits; - typedef typename Arrangement_2::Vertex_handle Vertex_handle; - typedef typename Arrangement_2::Halfedge_handle Halfedge_handle; - typedef typename Arrangement_2::Face_handle Face_handle; + typedef typename Helper::Arrangement_2 Arrangement_2; + typedef typename Arrangement_2::Topology_traits Topology_traits; + typedef typename Arrangement_2::Vertex_handle Vertex_handle; + typedef typename Arrangement_2::Halfedge_handle Halfedge_handle; + typedef typename Arrangement_2::Face_handle Face_handle; - typedef typename Base::Event_subcurve_iterator Event_subcurve_iterator; + typedef typename Base::Event_subcurve_iterator Event_subcurve_iterator; typedef typename Base::Event_subcurve_reverse_iterator Event_subcurve_reverse_iterator; - typedef typename Base::Status_line_iterator Status_line_iterator; + typedef typename Subcurve::Status_line_iterator Status_line_iterator; - typedef typename Helper::Indices_list Indices_list; - typedef typename Helper::Halfedge_indices_map Halfedge_indices_map; + typedef typename Helper::Indices_list Indices_list; + typedef typename Helper::Halfedge_indices_map Halfedge_indices_map; typedef Unique_hash_map - Iso_vertices_map; + Iso_vertices_map; protected: Helper m_helper; // The helper class. @@ -110,7 +132,7 @@ protected: public: /*! Constructor. */ - Arr_construction_sl_visitor(Arrangement_2* arr) : + Arr_construction_ss_visitor(Arrangement_2* arr) : m_helper(arr), m_arr(arr), m_top_traits(arr->topology_traits()), @@ -121,7 +143,7 @@ public: { m_helper.set_halfedge_indices_map(m_he_indices_table); } /*! Destructor. */ - virtual ~Arr_construction_sl_visitor() {} + virtual ~Arr_construction_ss_visitor() {} /// \name Sweep-line notifications. //@{ @@ -214,8 +236,7 @@ public: //@} /*! Get the last event associated with the given subcurve. */ - Event* last_event_on_subcurve(Subcurve* sc) - { return (reinterpret_cast((sc)->last_event())); } + Event* last_event_on_subcurve(Subcurve* sc) { return sc->last_event(); } private: /// \name Auxiliary functions. @@ -253,16 +274,16 @@ private: //----------------------------------------------------------------------------- // A notification issued before the sweep process starts. // Notifies the helper that the sweep process now starts. -template -void Arr_construction_sl_visitor::before_sweep() +template +void Arr_construction_ss_visitor::before_sweep() { m_helper.before_sweep(); } //----------------------------------------------------------------------------- // A notification invoked before the sweep-line starts handling the given // event. // -template -void Arr_construction_sl_visitor::before_handle_event(Event* event) +template +void Arr_construction_ss_visitor::before_handle_event(Event* event) { #if CGAL_ARR_CONSTRUCTION_SL_VISITOR_VERBOSE std::cout << "CGAL_CSLV before_handle_event" << std::endl; @@ -275,8 +296,8 @@ void Arr_construction_sl_visitor::before_handle_event(Event* event) // A notification invoked after the sweep-line finishes handling the given // event. // -template -bool Arr_construction_sl_visitor:: +template +bool Arr_construction_ss_visitor:: after_handle_event(Event* event, Status_line_iterator iter, bool /* flag */) { #if CGAL_ARR_CONSTRUCTION_SL_VISITOR_VERBOSE @@ -361,11 +382,8 @@ after_handle_event(Event* event, Status_line_iterator iter, bool /* flag */) // to their right endpoint). Event_subcurve_iterator left_it; for (left_it = event->left_curves_begin(); - left_it != event->left_curves_end(); - ++left_it) - { + left_it != event->left_curves_end(); ++left_it) (*left_it)->set_last_event(event); - } // In case there are no right subcurves, the event can be deallocated. if (event->number_of_right_curves() == 0) { @@ -382,11 +400,8 @@ after_handle_event(Event* event, Status_line_iterator iter, bool /* flag */) // to their left endpoint). Event_subcurve_iterator right_it; for (right_it = event->right_curves_begin(); - right_it != event->right_curves_end(); - ++right_it) - { + right_it != event->right_curves_end(); ++right_it) (*right_it)->set_last_event(event); - } // Mark that the event cannot be deallocated just yet. return false; @@ -395,8 +410,8 @@ after_handle_event(Event* event, Status_line_iterator iter, bool /* flag */) //----------------------------------------------------------------------------- // A notification invoked when a new subcurve is created. // -template -void Arr_construction_sl_visitor:: +template +void Arr_construction_ss_visitor:: add_subcurve(const X_monotone_curve_2& cv, Subcurve* sc) { #if CGAL_ARR_CONSTRUCTION_SL_VISITOR_VERBOSE @@ -414,33 +429,25 @@ add_subcurve(const X_monotone_curve_2& cv, Subcurve* sc) const Halfedge_handle invalid_he; #if CGAL_ARR_CONSTRUCTION_SL_VISITOR_VERBOSE - if (last_event->is_closed()) { + if (last_event->is_closed()) std::cout << "CGAL_CSLG lastevent: " << last_event->point() << std::endl; - } if (he_left != invalid_he) { std::cout << "he_left : " << &(*he_left) << std::endl; - if (!he_left->is_fictitious()) { + if (!he_left->is_fictitious()) std::cout << "he_leftcv : " << he_left->curve() << std::endl; - } else { - std::cout << "he_left : fictitious" << std::endl; - } + else std::cout << "he_left : fictitious" << std::endl; std::cout << "he_leftdir : " << he_left->direction() << std::endl; std::cout << "he_leftfac : " << &(*he_left->face()) << std::endl; - } else { - std::cout << "he_left : invalid" << std::endl; } + else std::cout << "he_left : invalid" << std::endl; if (he_right != invalid_he) { std::cout << "he_right : " << &(*he_right) << std::endl; - if (!he_right->is_fictitious()) { + if (!he_right->is_fictitious()) std::cout << "he_rightcv : " << he_right->curve() << std::endl; - } else { - std::cout << "he_right : fictitious" << std::endl; - } + else std::cout << "he_right : fictitious" << std::endl; std::cout << "he_rightdir: " << he_right->direction() << std::endl; std::cout << "he_rightfac: " << &(*he_right->face()) << std::endl; - } else { - std::cout << "he_right : invalid" << std::endl; - } + } else std::cout << "he_right : invalid" << std::endl; #endif // Check whether the previous event on the curve is not in the arrangement @@ -466,17 +473,14 @@ add_subcurve(const X_monotone_curve_2& cv, Subcurve* sc) // Therefore, we use it to insert the subcurve. // First, we skip some halfedges around the left vertex to get the true // predecessor halfedge for the insertion. - for (int i = 0; i < jump; i++) - he_left = (he_left->next())->twin(); + for (int i = 0; i < jump; i++) he_left = (he_left->next())->twin(); #if CGAL_ARR_CONSTRUCTION_SL_VISITOR_VERBOSE if (jump != 0) { std::cout << "CGAL_CSLV JUMP: " << jump << std::endl; - if (!he_left->is_fictitious()) { + if (!he_left->is_fictitious()) std::cout << "he_leftcv : " << he_left->curve() << std::endl; - } else { - std::cout << "he_left : fictitious" << std::endl; - } + else std::cout << "he_left : fictitious" << std::endl; std::cout << "he_leftdir : " << he_left->direction() << std::endl; std::cout << "he_leftfac : " << &(*he_left->face()) << std::endl; } @@ -565,9 +569,9 @@ add_subcurve(const X_monotone_curve_2& cv, Subcurve* sc) //----------------------------------------------------------------------------- // Insert the given subcurve in the interior of an arrangement face. // -template -typename Arr_construction_sl_visitor::Halfedge_handle -Arr_construction_sl_visitor:: +template +typename Arr_construction_ss_visitor::Halfedge_handle +Arr_construction_ss_visitor:: insert_in_face_interior(const X_monotone_curve_2& cv, Subcurve* sc) { #if CGAL_ARR_CONSTRUCTION_SL_VISITOR_VERBOSE @@ -614,9 +618,9 @@ insert_in_face_interior(const X_monotone_curve_2& cv, Subcurve* sc) //----------------------------------------------------------------------------- // Insert the given subcurve using its two end-vertices. // -template -typename Arr_construction_sl_visitor::Halfedge_handle -Arr_construction_sl_visitor:: +template +typename Arr_construction_ss_visitor::Halfedge_handle +Arr_construction_ss_visitor:: insert_at_vertices(const X_monotone_curve_2& cv, Halfedge_handle prev1, Halfedge_handle prev2, @@ -625,20 +629,14 @@ insert_at_vertices(const X_monotone_curve_2& cv, { #if CGAL_ARR_CONSTRUCTION_SL_VISITOR_VERBOSE std::cout << "CGAL_CSLV insert_at_vertices:\ncurve:" << cv << std::endl; - if (!prev1->is_fictitious()) { + if (!prev1->is_fictitious()) std::cout << "prev1cv : " << prev1->curve() << std::endl; - } - else { - std::cout << "prev1 : fictitious" << std::endl; - } + else std::cout << "prev1 : fictitious" << std::endl; std::cout << "prev1dir : " << prev1->direction() << std::endl; std::cout << "prev1fac : " << &(*prev1->face()) << std::endl; - if (!prev2->is_fictitious()) { + if (!prev2->is_fictitious()) std::cout << "prev2cv : " << prev2->curve() << std::endl; - } - else { - std::cout << "prev2 : fictitious" << std::endl; - } + else std::cout << "prev2 : fictitious" << std::endl; std::cout << "prev2dir : " << prev2->direction() << std::endl; std::cout << "prev2fac : " << &(*prev2->face()) << std::endl; #endif @@ -718,9 +716,9 @@ insert_at_vertices(const X_monotone_curve_2& cv, //----------------------------------------------------------------------------- // Insert the given subcurve from a vertex that corresponds to its right end. // -template -typename Arr_construction_sl_visitor::Halfedge_handle -Arr_construction_sl_visitor:: +template +typename Arr_construction_ss_visitor::Halfedge_handle +Arr_construction_ss_visitor:: insert_from_right_vertex(const X_monotone_curve_2& cv, Halfedge_handle prev, Subcurve* sc) @@ -766,20 +764,18 @@ insert_from_right_vertex(const X_monotone_curve_2& cv, //----------------------------------------------------------------------------- // Insert the given subcurve from a vertex that corresponds to its left end. // -template -typename Arr_construction_sl_visitor::Halfedge_handle -Arr_construction_sl_visitor:: +template +typename Arr_construction_ss_visitor::Halfedge_handle +Arr_construction_ss_visitor:: insert_from_left_vertex(const X_monotone_curve_2& cv, Halfedge_handle prev, Subcurve* sc) { #if CGAL_ARR_CONSTRUCTION_SL_VISITOR_VERBOSE std::cout << "CGAL_CSLV insert_from_left_vertex:\ncurve:" << cv << std::endl; - if (!prev->is_fictitious()) { + if (!prev->is_fictitious()) std::cout << "prevcv : " << prev->curve() << std::endl; - } else { - std::cout << "prev : fictitious" << std::endl; - } + else std::cout << "prev : fictitious" << std::endl; std::cout << "prevdir : " << prev->direction() << std::endl; std::cout << "prevfac : " << &(*prev->face()) << std::endl; #endif @@ -814,9 +810,9 @@ insert_from_left_vertex(const X_monotone_curve_2& cv, //----------------------------------------------------------------------------- // Insert an isolated vertex into the arrangement. // -template -typename Arr_construction_sl_visitor::Vertex_handle -Arr_construction_sl_visitor:: +template +typename Arr_construction_ss_visitor::Vertex_handle +Arr_construction_ss_visitor:: insert_isolated_vertex(const Point_2& pt, Status_line_iterator /* iter */) { #if CGAL_ARR_CONSTRUCTION_SL_VISITOR_VERBOSE @@ -825,14 +821,15 @@ insert_isolated_vertex(const Point_2& pt, Status_line_iterator /* iter */) // Insert the isolated vertex in the interior of the current top face, as // given by the helper class. - return (m_arr->insert_in_face_interior(_point(pt), m_helper.top_face())); + return m_arr->insert_in_face_interior(_point(pt), m_helper.top_face()); } //----------------------------------------------------------------------------- // Reloacte holes and isolated vertices inside a newly created face. // -template -void Arr_construction_sl_visitor::relocate_in_new_face(Halfedge_handle he) +template +void Arr_construction_ss_visitor:: +relocate_in_new_face(Halfedge_handle he) { #if CGAL_ARR_CONSTRUCTION_SL_VISITOR_VERBOSE std::cout << "CGAL_CSLV relocate" << std::endl; @@ -911,8 +908,8 @@ void Arr_construction_sl_visitor::relocate_in_new_face(Halfedge_handle he) //----------------------------------------------------------------------------- // Map the given subcurve index to the given halfedge handle. // -template -void Arr_construction_sl_visitor:: +template +void Arr_construction_ss_visitor:: _map_new_halfedge(unsigned int i, Halfedge_handle he) { #if CGAL_ARR_CONSTRUCTION_SL_VISITOR_VERBOSE @@ -927,6 +924,6 @@ _map_new_halfedge(unsigned int i, Halfedge_handle he) m_sc_he_table[i] = he; } -} //namespace CGAL +} // namespace CGAL #endif diff --git a/Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_construction_subcurve.h b/Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_construction_subcurve.h new file mode 100644 index 00000000000..803ada84cf8 --- /dev/null +++ b/Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_construction_subcurve.h @@ -0,0 +1,220 @@ +// Copyright (c) 2006,2007,2009,2010,2011 Tel-Aviv University (Israel). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// You can redistribute it and/or modify it under the terms of the GNU +// General Public License as published by the Free Software Foundation, +// either version 3 of the License, or (at your option) any later version. +// +// Licensees holding a valid commercial license may use this file in +// accordance with the commercial license agreement provided with the software. +// +// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Author(s) : Tali Zvi +// Baruch Zukerman + +#ifndef CGAL_ARR_CONSTRUCTION_SUBCURVE_H +#define CGAL_ARR_CONSTRUCTION_SUBCURVE_H + +#include + +/*! \file + * + * Definition of the Arr_construction_subcurve class-template, which is an + * extended curve type, referred to as Subcurve, used by the surface-sweep + * framework. + * + * The surface-sweep framework is implemented as a template that is + * parameterized, among the other, by the Subcurve and Event types. That is, + * instance types of Subcurve and Event must be available when the + * surface-sweep template is instantiated. + * + * Arr_construction_subcurve derives from an instance of the Default_subcurve + * class template. The user is allowed to introduce new types that derive from + * an instance of the Arr_construction_subcurve class template. However, some of + * the fields of this template depends on the Subcurve type. We use the + * curiously recurring template pattern (CRTP) idiom to force the correct + * matching of these types. + */ + +#include +#include + +namespace CGAL { + +namespace Ss2 = Surface_sweep_2; + +/*! \class Arr_construction_subcurve_base + * + * This is the base class of the Arr_construction_subcurve class template used + * by the (CRTP) idiom. + * \tparam GeometryTraits_2 the geometry traits. + * \tparam Event_ the event type. + * \tparam Allocator_ a type of an element that is used to acquire/release + * memory for elements of the event queue and the status + * structure, and to construct/destroy the elements in that + * memory. The type must meet the requirements of Allocator. + * \tparam Subcurve_ the subcurve actual type. + * + * The information contained in this class last: + * - ishe event that was handled on the curve. + * - The index for a subcurve that may represent a hole + * - Indices of all halfedge below the curve that may represent a hole. + */ +template + class SurfaceSweepBaseCurve, + typename Subcurve_> +class Arr_construction_subcurve_base : + public SurfaceSweepBaseCurve +{ +public: + typedef GeometryTraits_2 Geometry_traits_2; + typedef Subcurve_ Subcurve; + typedef Event_ Event; + typedef Allocator_ Allocator; + +private: + typedef Geometry_traits_2 Gt2; + typedef SurfaceSweepBaseCurve + Base; + +public: + typedef typename Gt2::X_monotone_curve_2 X_monotone_curve_2; + typedef Event* Event_ptr; + typedef std::list Halfedge_indices_list; + + /*! Construct default. */ + Arr_construction_subcurve_base() : + Base(), + m_last_event(0), + m_index(0) + {} + + /*! Constructor from an x-monotone curve. */ + Arr_construction_subcurve_base(X_monotone_curve_2& curve) : + Base(curve), + m_last_event(0), + m_index(0) + {} + +protected: + // Data members: + Event_ptr m_last_event; // The last event that was handled on the curve. + + /*! index for a subcurve that may represent a hole (emarge from the left + * most vertex of a hole, and its the upper most curve). other subcurves + * will have 0 value (invalid index) + */ + unsigned int m_index; // Index for a subcurve that may represent a hole + // (emarge from the leftmost vertex of a hole, + // and it is the topmost curve). Other subcurves + // have a 0 (invalid) index. + + Halfedge_indices_list m_halfedge_indices; + // Indices of all halfedge below the curve that + // may represent a hole. + +public: + /*! Initialize the curve. */ + void init(const X_monotone_curve_2& curve) { Base::init(curve); } + + /*! Set the event associated with the left end of the subcurve. */ + template + void set_left_event(SweepEvent* left) + { + Base::set_left_event(left); + set_last_event(left); + } + + /*! Set the last event on the subcurve. */ + void set_last_event(Event_ptr e) { m_last_event = e; } + + /*! Obtain the last event. */ + Event_ptr last_event() const { return m_last_event; } + + /*! Obtain the subcurve index. */ + unsigned int index() const { return m_index; } + + /*! Set the subcurve index. */ + void set_index(unsigned int i) { m_index = i; } + + /*! Check whether the index is valid. */ + bool has_valid_index() const { return (m_index != 0); } + + /*! Add an index of a halfedge below the subcurve. */ + void add_halfedge_index(unsigned int i) { m_halfedge_indices.push_back(i); } + + /*! Clear the indices of the halfedges below the subcurve. */ + void clear_halfedge_indices() { m_halfedge_indices.clear(); } + + /*! Check if there are any halfedges below the subcurve. */ + bool has_halfedge_indices() const { return (!m_halfedge_indices.empty()); } + + /*! Obtain the indices of the halfedges below the subcurve. */ + Halfedge_indices_list& halfedge_indices_list() { return m_halfedge_indices; } +}; + +/*! \class Arr_construction_subcurve + * + * This class that holds information about a curve that is added to the + * arrangement. In addition to the information that is contained in + * Surface_sweep_subcurve, when an arrangement is constructed, a pointer to the + * last handled event on the curve is stored (in the base class). This + * information is used to retrieve hints when a subcurve of this curve is + * inserted into the planar map. + * + * Inherits from `Surface_sweep_subcurve` + * \sa `Surface_sweep_subcurve` + */ +template + class SurfaceSweepBaseCurve = Ss2::Default_subcurve, + typename Subcurve_ = Default> +class Arr_construction_subcurve : + public Arr_construction_subcurve_base< + GeometryTraits_2, Event_, Allocator_, + SurfaceSweepBaseCurve, + typename Default::Get >::type> +{ +public: + typedef GeometryTraits_2 Geometry_traits_2; + typedef Event_ Event; + typedef Allocator_ Allocator; + +private: + typedef Geometry_traits_2 Gt2; + typedef Arr_construction_subcurve + Self; + typedef typename Default::Get::type Subcurve; + typedef Arr_construction_subcurve_base + Base; + +public: + typedef typename Gt2::X_monotone_curve_2 X_monotone_curve_2; + + typedef typename Base::Event_ptr Event_ptr; + typedef typename Base::Halfedge_indices_list Halfedge_indices_list; + + /*! Construct deafult. */ + Arr_construction_subcurve() {} + + /*! Constructor from an x-monotone curve. */ + Arr_construction_subcurve(X_monotone_curve_2& curve) : + Base(curve) + {} +}; + + +} // namespace CGAL + +#endif diff --git a/Sweep_line_2/include/CGAL/Sweep_line_2/Arr_default_overlay_traits_base.h b/Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_default_overlay_traits_base.h similarity index 98% rename from Sweep_line_2/include/CGAL/Sweep_line_2/Arr_default_overlay_traits_base.h rename to Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_default_overlay_traits_base.h index 326c5e60185..e8b0cb18526 100644 --- a/Sweep_line_2/include/CGAL/Sweep_line_2/Arr_default_overlay_traits_base.h +++ b/Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_default_overlay_traits_base.h @@ -15,25 +15,25 @@ // $URL$ // $Id$ // SPDX-License-Identifier: GPL-3.0+ -// +// // // Author(s) : Ron Wein // Baruch Zukerman /*! \file + * * Definition of the internal _Arr_default_overlay_traits_base class template. */ #ifndef CGAL_ARR_DEFAULT_OVERLAY_TRAITS_BASE_H #define CGAL_ARR_DEFAULT_OVERLAY_TRAITS_BASE_H -#include - +#include namespace CGAL { -/*! - * \class +/*! \class + * * An overlay-traits class for computing the overlay of two arrangement that * are templated with the default DCEL classes, namely they store no extra * data with their DCEL features. The resulting arrangement is also assumed @@ -51,7 +51,7 @@ public: typedef typename ArrangementB::Vertex_const_handle Vertex_handle_B; typedef typename ArrangementB::Halfedge_const_handle Halfedge_handle_B; typedef typename ArrangementB::Face_const_handle Face_handle_B; - + typedef typename ArrangementR::Vertex_handle Vertex_handle_R; typedef typename ArrangementR::Halfedge_handle Halfedge_handle_R; typedef typename ArrangementR::Face_handle Face_handle_R; @@ -59,7 +59,7 @@ public: /*! Destructor. */ virtual ~_Arr_default_overlay_traits_base () {} - + /*! * Create a vertex v that corresponds to the coinciding vertices v1 and v2. */ diff --git a/Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_insertion_ss_visitor.h b/Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_insertion_ss_visitor.h new file mode 100644 index 00000000000..5f29f041a83 --- /dev/null +++ b/Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_insertion_ss_visitor.h @@ -0,0 +1,170 @@ +// Copyright (c) 2006,2007,2009,2010,2011 Tel-Aviv University (Israel). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// You can redistribute it and/or modify it under the terms of the GNU +// General Public License as published by the Free Software Foundation, +// either version 3 of the License, or (at your option) any later version. +// +// Licensees holding a valid commercial license may use this file in +// accordance with the commercial license agreement provided with the software. +// +// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Author(s) : Baruch Zukerman +// Ron Wein +// Efi Fogel + +#ifndef CGAL_ARR_INSERTION_SS_VISITOR_H +#define CGAL_ARR_INSERTION_SS_VISITOR_H + +#include + +/*! \file + * + * Definition of the Arr_insertion_ss_visitor class-template. This class can be + * further split into two, where one derives from the other, such that the + * derived class handles the case of inserting curves into a non-empty + * arrangement, and the base class handles the case of inserting curves into a + * empty arrangement. + */ + +#include +#include + +namespace CGAL { + +/*! \class Arr_insertion_ss_visitor + * + * A sweep-line visitor for inserting new curves into an existing arrangement + * embedded on a surface. + */ +template +class Arr_insertion_ss_visitor : + public Arr_no_intersection_insertion_ss_visitor< + Helper_, + typename Default::Get >::type> +{ +public: + typedef Helper_ Helper; + + typedef typename Helper::Geometry_traits_2 Geometry_traits_2; + typedef typename Helper::Event Event; + typedef typename Helper::Subcurve Subcurve; + +private: + typedef Geometry_traits_2 Gt2; + typedef Arr_insertion_ss_visitor Self; + typedef typename Default::Get::type Visitor; + typedef Arr_no_intersection_insertion_ss_visitor + Base; + +public: + typedef typename Gt2::X_monotone_curve_2 X_monotone_curve_2; + typedef typename Gt2::Point_2 Point_2; + + typedef typename Helper::Arrangement_2 Arrangement_2; + typedef typename Arrangement_2::Halfedge_handle Halfedge_handle; + +private: + X_monotone_curve_2 sub_cv1; // Auxiliary variables + X_monotone_curve_2 sub_cv2; // (used for splitting curves). + +public: + /*! A notification invoked when a new subcurve is created. */ + void add_subcurve(const X_monotone_curve_2& cv, Subcurve* sc); + + /*! Constructor. */ + Arr_insertion_ss_visitor(Arrangement_2* arr) : Base(arr) {} + + /// \name Edge-split functions (to be overridden by the child visitor). + //@{ + + /*! Check if the halfedge associated with the given subcurve will be split + * at the given event. + * \param sc The subcurve. + * \param event The event. + */ + virtual bool is_split_event(Subcurve* sc, Event* event); + + /*! Split the given edge edge. + * \param he The edge to split. + * \param sc The associated subcurve. + * \param The split point. + * \return A handle to the split edge. + */ + virtual Halfedge_handle split_edge(Halfedge_handle he, Subcurve* sc, + const Point_2& pt); + //@} +}; + +//----------------------------------------------------------------------------- +// Member-function definitions: +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Check if the halfedge associated with the given subcurve will be split +// at the given event. +// +template +bool Arr_insertion_ss_visitor:: +is_split_event(Subcurve* sc, Event* event) +{ + if (sc->last_curve().halfedge_handle() == Halfedge_handle(NULL)) return false; + + if (! sc->originating_subcurve1()) + return (sc->left_event() != this->current_event()); + return (this->is_split_event(sc->originating_subcurve1(), event) || + this->is_split_event(sc->originating_subcurve2(), event)); + } + +//----------------------------------------------------------------------------- +// Split an edge. +// +template +typename Arr_insertion_ss_visitor::Halfedge_handle +Arr_insertion_ss_visitor::split_edge(Halfedge_handle he, Subcurve* sc, + const Point_2& pt) +{ + // Make sure that the halfedge associated with sc is the directed from + // right to left, since we always "look" above , and the incident face + // is on the left of the halfedge + CGAL_assertion(he->direction() == ARR_RIGHT_TO_LEFT); + + this->traits()->split_2_object()(he->curve(), pt, sub_cv2, sub_cv1); + Halfedge_handle new_he = + this->m_arr_access.split_edge_ex(he, pt.base(), + sub_cv1.base(), sub_cv2.base()); + Event* last_event_on_sc = sc->last_event(); + if (last_event_on_sc->halfedge_handle() == he) + last_event_on_sc->set_halfedge_handle(new_he->next()); + + return new_he; +} + +//----------------------------------------------------------------------------- +// A notification invoked when a new subcurve is created. +// +template +void Arr_insertion_ss_visitor:: +add_subcurve(const X_monotone_curve_2& cv, Subcurve* sc) +{ + if (Base::add_subcurve_(cv, sc)) return; + + // sc is an overlap Subcurve of existing edge and new curve, + // which means that the edeg will have to be modified + if (sc->originating_subcurve1()) { + this->m_arr->modify_edge + (this->current_event()->halfedge_handle()->next()->twin(), cv.base()); + } + + Halfedge_handle next_ccw_he = + this->current_event()->halfedge_handle()->next()->twin(); + this->current_event()->set_halfedge_handle(next_ccw_he); +} + +} // namespace CGAL + +#endif diff --git a/Sweep_line_2/include/CGAL/Sweep_line_2/Arr_insertion_traits_2.h b/Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_insertion_traits_2.h similarity index 52% rename from Sweep_line_2/include/CGAL/Sweep_line_2/Arr_insertion_traits_2.h rename to Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_insertion_traits_2.h index 026351de989..0e229da5291 100644 --- a/Sweep_line_2/include/CGAL/Sweep_line_2/Arr_insertion_traits_2.h +++ b/Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_insertion_traits_2.h @@ -15,7 +15,7 @@ // $URL$ // $Id$ // SPDX-License-Identifier: GPL-3.0+ -// +// // // Author(s) : Baruch Zukerman // Efi Fogel @@ -23,61 +23,64 @@ #ifndef CGAL_ARR_INSERTION_TRAITS_2_H #define CGAL_ARR_INSERTION_TRAITS_2_H -#include +#include - -/*! +/*! \file + * * Defintion of the Arr_insertion_traits_2 class. */ -#include +#include namespace CGAL { -/*! \class +/*! \class Arr_insertion_traits_2 + * * A meta-traits class that stores a halfedge handle with every x-monotone * curve, and a vertex handle with each point. This information is used to * speed up the aggregated insertion process. */ -template -class Arr_insertion_traits_2 : - public Arr_basic_insertion_traits_2 +template +class Arr_insertion_traits_2 : + public Arr_basic_insertion_traits_2 { public: + typedef GeometryTraits_2 Geometry_traits_2; + typedef Arrangement_2_ Arrangement_2; - typedef Traits_ Traits_2; - typedef Arr_basic_insertion_traits_2 Base; +private: + typedef Geometry_traits_2 Gt2; + typedef Arrangement_2 Arr2; + typedef Arr_basic_insertion_traits_2 Base; - typedef typename Traits_2::Intersect_2 Base_intersect_2; - typedef typename Traits_2::Split_2 Base_split_2; - typedef typename Base::Base_x_monotone_curve_2 Base_x_monotone_curve_2; - typedef typename Base::X_monotone_curve_2 X_monotone_curve_2; - typedef typename Base::Halfedge_handle Halfedge_handle; - typedef typename Base::Base_point_2 Base_point_2; - typedef typename Base::Point_2 Point_2; - typedef typename Base::Multiplicity Multiplicity; +public: + typedef typename Gt2::Intersect_2 Base_intersect_2; + typedef typename Gt2::Split_2 Base_split_2; + typedef typename Base::Base_x_monotone_curve_2 Base_x_monotone_curve_2; + typedef typename Base::X_monotone_curve_2 X_monotone_curve_2; + typedef typename Base::Halfedge_handle Halfedge_handle; + typedef typename Base::Base_point_2 Base_point_2; + typedef typename Base::Point_2 Point_2; + typedef typename Base::Multiplicity Multiplicity; typedef typename Base::Has_left_category Has_left_category; typedef typename Base::Has_do_intersect_category Has_do_intersect_category; // should be ok, as basic_insertion (=Base) completes incomplete tags - typedef typename Base::Left_side_category Left_side_category; - typedef typename Base::Bottom_side_category Bottom_side_category; - typedef typename Base::Top_side_category Top_side_category; - typedef typename Base::Right_side_category Right_side_category; + typedef typename Base::Left_side_category Left_side_category; + typedef typename Base::Bottom_side_category Bottom_side_category; + typedef typename Base::Top_side_category Top_side_category; + typedef typename Base::Right_side_category Right_side_category; /* Insertion is implemented as sweep-line visitor. The sweep-line algorithm * never performs merging of curves. Therefore, AreMergeable_2 and * Merge_2 are not needed either. */ typedef Tag_false Has_merge_category; - -public: +public: /*! Constructor with a traits class. */ - Arr_insertion_traits_2 (const Traits_2& tr) : - Base (tr) - {} + Arr_insertion_traits_2(const Gt2& tr) : Base(tr) {} /*! A functor that compares compares the y-coordinates of two x-monotone * curves immediately to the right of their intersection point. @@ -85,70 +88,65 @@ public: class Intersect_2 { protected: //! The base operators. - Base_intersect_2 m_base_intersect; - Halfedge_handle invalid_he; + Base_intersect_2 m_base_intersect; + Halfedge_handle invalid_he; /*! Constructor. * The constructor is declared private to allow only the functor * obtaining function, which is a member of the nesting class, * constructing it. */ - Intersect_2 (const Base_intersect_2& base) : + Intersect_2(const Base_intersect_2& base) : m_base_intersect (base), invalid_he() {} //! Allow its functor obtaining function calling the private constructor. - friend class Arr_insertion_traits_2; - + friend class Arr_insertion_traits_2; + public: template - OutputIterator operator() (const X_monotone_curve_2& cv1, - const X_monotone_curve_2& cv2, - OutputIterator oi) + OutputIterator operator()(const X_monotone_curve_2& cv1, + const X_monotone_curve_2& cv2, + OutputIterator oi) { - if(cv1.halfedge_handle() != invalid_he && - cv2.halfedge_handle() != invalid_he) + if ((cv1.halfedge_handle() != invalid_he) && + (cv2.halfedge_handle() != invalid_he)) { // The curves are interior-disjoint as both of them are already in // the arrangement. - return (oi); + return oi; } - OutputIterator oi_end = m_base_intersect(cv1.base(), - cv2.base(), oi); - const Base_x_monotone_curve_2 *base_overlap_cv; - const std::pair *intersect_p; + OutputIterator oi_end = m_base_intersect(cv1.base(), cv2.base(), oi); + const Base_x_monotone_curve_2* base_overlap_cv; + const std::pair* intersect_p; // convert objects that are associated with Base_x_monotone_curve_2 to - // X_monotone_curve_2 - for(; oi != oi_end; ++oi) - { - base_overlap_cv = object_cast (&(*oi)); - if (base_overlap_cv != NULL) - { + // X_monotone_curve_2 + for(; oi != oi_end; ++oi) { + base_overlap_cv = object_cast(&(*oi)); + if (base_overlap_cv != NULL) { // Add halfedge handles to the resulting curve. - Halfedge_handle he; + Halfedge_handle he; - if (cv1.halfedge_handle() != invalid_he) - he = cv1.halfedge_handle(); + if (cv1.halfedge_handle() != invalid_he) he = cv1.halfedge_handle(); else if (cv2.halfedge_handle() != invalid_he) he = cv2.halfedge_handle(); - X_monotone_curve_2 overlap_cv (*base_overlap_cv, he); + X_monotone_curve_2 overlap_cv (*base_overlap_cv, he); overlap_cv.set_overlapping(); *oi = make_object (overlap_cv); } - else - { - intersect_p = - object_cast > (&(*oi)); + else { + intersect_p = + object_cast >(&(*oi)); CGAL_assertion (intersect_p != NULL); - *oi = make_object (std::make_pair (Point_2(intersect_p->first), - intersect_p->second)); + *oi = make_object(std::make_pair(Point_2(intersect_p->first), + intersect_p->second)); } } @@ -159,15 +157,13 @@ public: /*! Obtain a Intersect_2 function object */ Intersect_2 intersect_2_object () const - { - return (Intersect_2 (this->m_base_traits->intersect_2_object())); - } + { return (Intersect_2(this->m_base_traits->intersect_2_object())); } /*! A functor that splits an arc at a point. */ class Split_2 { protected: //! The base operator. - Base_split_2 m_base_split; + Base_split_2 m_base_split; /*! Constructor. * The constructor is declared private to allow only the functor @@ -177,11 +173,11 @@ public: Split_2(const Base_split_2& base) : m_base_split (base) {} //! Allow its functor obtaining function calling the private constructor. - friend class Arr_insertion_traits_2; - + friend class Arr_insertion_traits_2; + public: - void operator() (const X_monotone_curve_2& cv, const Point_2 & p, - X_monotone_curve_2& c1, X_monotone_curve_2& c2) + void operator()(const X_monotone_curve_2& cv, const Point_2 & p, + X_monotone_curve_2& c1, X_monotone_curve_2& c2) { m_base_split(cv.base(), p.base(), c1.base(), c2.base()); c1.set_halfedge_handle(cv.halfedge_handle()); @@ -189,13 +185,11 @@ public: } }; - /*! Obtain a plit_2 function object */ - Split_2 split_2_object () const - { - return (Split_2 (this->m_base_traits->split_2_object())); - } + /*! Obtain a Split_2 function object */ + Split_2 split_2_object() const + { return (Split_2(this->m_base_traits->split_2_object())); } }; -} //namespace CGAL +} // namespace CGAL #endif diff --git a/Sweep_line_2/include/CGAL/Sweep_line_2/Arr_basic_insertion_sl_visitor.h b/Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_no_intersection_insertion_ss_visitor.h similarity index 78% rename from Sweep_line_2/include/CGAL/Sweep_line_2/Arr_basic_insertion_sl_visitor.h rename to Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_no_intersection_insertion_ss_visitor.h index 730c0278b7f..d74e1f78584 100644 --- a/Sweep_line_2/include/CGAL/Sweep_line_2/Arr_basic_insertion_sl_visitor.h +++ b/Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_no_intersection_insertion_ss_visitor.h @@ -15,55 +15,75 @@ // $URL$ // $Id$ // SPDX-License-Identifier: GPL-3.0+ -// +// // // Author(s) : Baruch Zukerman // Ron Wein // Efi Fogel -#ifndef CGAL_ARR_BASIC_INSERTION_SL_VISITOR_H -#define CGAL_ARR_BASIC_INSERTION_SL_VISITOR_H +#ifndef CGAL_ARR_NO_INTERSECTION_INSERTION_SS_VISITOR_H +#define CGAL_ARR_NO_INTERSECTION_INSERTION_SS_VISITOR_H -#include +#include - -/*! - * Definition of the Arr_basic_insertion_sl_visitor class-template. +/*! \file + * + * Definition of the Arr_no_intersection_insertion_ss_visitor class-template. + * This class can be further split into two, where one derives from the other, + * such that the derived class handles the case of inserting non-intersecting + * curves into a non-empty arrangement, and the base class handles the case of + * inserting non-intersecting curves into a empty arrangement. */ +#include +#include + namespace CGAL { -/*! \class Arr_basic_insertion_sl_visitor +/*! \class Arr_no_intersection_insertion_ss_visitor + * * A sweep-line visitor for inserting new curves into an existing arrangement * embedded on a surface, where these curves are interior-disjoint from all * existing arrangement edges and vertices (so no intersections occur). */ -template -class Arr_basic_insertion_sl_visitor : public Helper_::Parent_visitor { +template +class Arr_no_intersection_insertion_ss_visitor : + public Arr_construction_ss_visitor< + Helper_, + typename Default::Get >::type> +{ public: - typedef Helper_ Helper; + typedef Helper_ Helper; - typedef typename Helper::Traits_2 Traits_2; - typedef typename Helper::Arrangement_2 Arrangement_2; - typedef typename Helper::Parent_visitor Base; - typedef typename Helper::Event Event; - typedef typename Helper::Subcurve Subcurve; - - typedef typename Traits_2::X_monotone_curve_2 X_monotone_curve_2; - typedef typename Traits_2::Point_2 Point_2; + typedef typename Helper::Geometry_traits_2 Geometry_traits_2; + typedef typename Helper::Event Event; + typedef typename Helper::Subcurve Subcurve; + +private: + typedef Geometry_traits_2 Gt2; + typedef Arr_no_intersection_insertion_ss_visitor + Self; + typedef typename Default::Get::type Visitor; + typedef Arr_construction_ss_visitor Base; + +public: + typedef typename Gt2::X_monotone_curve_2 X_monotone_curve_2; + typedef typename Gt2::Point_2 Point_2; protected: - typedef typename Base::Status_line_iterator Status_line_iterator; - typedef typename Base::Vertex_handle Vertex_handle; - typedef typename Base::Halfedge_handle Halfedge_handle; - typedef typename Base::Face_handle Face_handle; - typedef typename Base::Event_subcurve_iterator Event_subcurve_iterator; + typedef typename Subcurve::Status_line_iterator Status_line_iterator; typedef typename Base::Event_subcurve_reverse_iterator 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; + public: /*! Constructor. */ - Arr_basic_insertion_sl_visitor(Arrangement_2* arr) : Base(arr) {} + Arr_no_intersection_insertion_ss_visitor(Arrangement_2* arr) : Base(arr) {} /// \name Sweep-line notifications. //@{ @@ -71,8 +91,7 @@ public: /* A notification issued before the sweep process starts. */ void before_sweep(); - /*! - * A notification invoked before the sweep-line starts handling the given + /*! A notification invoked before the sweep-line starts handling the given * event. */ void before_handle_event(Event* event); @@ -88,8 +107,8 @@ public: Arr_curve_end /* cv_end */, bool /* is_new */) {} - void update_event (Event* /* e */, const X_monotone_curve_2& /* cv */, - Arr_curve_end /* cv_end */, bool /* is_new */) + void update_event(Event* /* e */, const X_monotone_curve_2& /* cv */, + Arr_curve_end /* cv_end */, bool /* is_new */) {} void update_event(Event* /* e */, Subcurve* /* sc1 */, Subcurve* /* sc2 */, @@ -106,8 +125,7 @@ public: } //@} - /*! - * Insert the given subcurve in the interior of a face. + /*! Insert the given subcurve in the interior of a face. * \param cv The geometric subcurve. * \param sc The sweep-line subcurve information. * \return A handle to the inserted halfedge. @@ -115,8 +133,7 @@ public: virtual Halfedge_handle insert_in_face_interior(const X_monotone_curve_2& cv, Subcurve* sc); - /*! - * Insert the given subcurve given its left end-vertex. + /*! Insert the given subcurve given its left end-vertex. * \param cv The geometric entity. * \param prev The predecessor halfedge around the left vertex. * \param sc The sweep-line subcurve information. @@ -126,8 +143,7 @@ public: insert_from_left_vertex(const X_monotone_curve_2& cv, Halfedge_handle he, Subcurve* sc); - /*! - * Insert the given subcurve given its right end-vertex. + /*! Insert the given subcurve given its right end-vertex. * \param cv The geometric entity. * \param prev The predecessor halfedge around the right vertex. * \param sc The sweep-line subcurve information. @@ -137,8 +153,7 @@ public: insert_from_right_vertex(const X_monotone_curve_2& cv, Halfedge_handle prev, Subcurve* sc); - /*! - * Insert the given subcurve given its two end-vertices. + /*! Insert the given subcurve given its two end-vertices. * \param cv The geometric subcurve. * \param prev1 The predecessor halfedge around the left vertex. * \param prev2 The predecessor halfedge around the right vertex. @@ -150,10 +165,9 @@ public: Halfedge_handle prev1, Halfedge_handle prev2, Subcurve* sc, - bool &new_face_created); + bool& new_face_created); - /*! - * Insert an isolated vertex into the arrangement. + /*! Insert an isolated vertex into the arrangement. * \param pt The point associated with the vertex. * \param iter The location of the corresponding event in the status line. * \return A handle to the inserted vertex. @@ -165,8 +179,7 @@ public: /// \name Edge-split functions (to be overridden by the child visitor). //@{ - /*! - * Check if the halfedge associated with the given subcurve will be split + /*! Check if the halfedge associated with the given subcurve will be split * at the given event. * In this case there are no splits. */ @@ -179,7 +192,7 @@ public: virtual Halfedge_handle split_edge(Halfedge_handle /*he*/, Subcurve* /*sc*/, const Point_2& /*pt*/) - { return Halfedge_handle(); } + { return Halfedge_handle(); } //@} protected: @@ -209,6 +222,9 @@ protected: /*! Locate the face containing the current object in its interior. */ Face_handle _ray_shoot_up(Status_line_iterator iter); + + /*! Add a new curve. */ + bool add_subcurve_(const X_monotone_curve_2& cv, Subcurve* sc); //@} }; @@ -219,16 +235,17 @@ protected: //----------------------------------------------------------------------------- // A notification issued before the sweep process starts. // Notifies the helper that the sweep process now starts. -template -void Arr_basic_insertion_sl_visitor::before_sweep() +template +void Arr_no_intersection_insertion_ss_visitor::before_sweep() { this->m_helper.before_sweep(); } //----------------------------------------------------------------------------- // A notification invoked before the sweep-line starts handling the given // event. // -template -void Arr_basic_insertion_sl_visitor::before_handle_event(Event* event) +template +void Arr_no_intersection_insertion_ss_visitor:: +before_handle_event(Event* event) { // First we notify the helper class on the event. this->m_helper.before_handle_event(event); @@ -249,7 +266,7 @@ void Arr_basic_insertion_sl_visitor::before_handle_event(Event* event) } } } - + if (! event->has_left_curves()) { // Indicates if there's halfedge to the right of the event. Event_subcurve_reverse_iterator right_it; @@ -272,7 +289,7 @@ void Arr_basic_insertion_sl_visitor::before_handle_event(Event* event) // The event has left and right curves. Event_subcurve_reverse_iterator iter; Halfedge_handle he; - bool exist_right_halfedge = false; + bool exist_right_halfedge = false; int i = 0; for (iter = event->right_curves_rbegin(); iter != event->right_curves_rend(); ++iter, ++i) @@ -282,34 +299,34 @@ void Arr_basic_insertion_sl_visitor::before_handle_event(Event* event) exist_right_halfedge = true; event->set_subcurve_in_arrangement(i, true); if (!is_split_event(*iter, event)) { - // halfedge will not be split. + // halfedge will not be split. event->set_halfedge_handle(he); } else { he = split_edge((*iter)->last_curve().halfedge_handle(), (*iter), event->point()); - + // 'he' has the same source as the split halfedge. event->set_halfedge_handle(he); X_monotone_curve_2& last_curve = const_cast((*iter)->last_curve()); last_curve.set_halfedge_handle(he); - + //there cannot be another existing halfedge that need to be split // because they are disjoint return; } } } - + if (exist_right_halfedge) return; - // if we have reached here, there are no halfedges to the right of + // if we have reached here, there are no halfedges to the right of // the event, but still can be on the left of the event for (iter = event->left_curves_rbegin(); iter != event->left_curves_rend(); ++iter) { - he =(*iter)->last_curve().halfedge_handle(); + he = (*iter)->last_curve().halfedge_handle(); if (he != invalid_he) { event->set_halfedge_handle(he->twin()); return; @@ -318,37 +335,42 @@ void Arr_basic_insertion_sl_visitor::before_handle_event(Event* event) } //----------------------------------------------------------------------------- -// A notification invoked when a new subcurve is created. +// Add a new curve. // -template -void Arr_basic_insertion_sl_visitor:: -add_subcurve(const X_monotone_curve_2& cv, Subcurve* sc) +template +bool Arr_no_intersection_insertion_ss_visitor:: +add_subcurve_(const X_monotone_curve_2& cv, Subcurve* sc) { const Halfedge_handle invalid_he; if (cv.halfedge_handle() == invalid_he) { // The curve will be inserted into the arrangement: Base::add_subcurve(cv, sc); + return true; } - else { - // sc is an overlap Subcurve of existing edge and new curve, - // which means that the edeg will have to be modified - if (sc->originating_subcurve1()) { - this->m_arr->modify_edge - (this->current_event()->halfedge_handle()->next()->twin(), cv.base()); - } + return false; +} - Halfedge_handle next_ccw_he = - this->current_event()->halfedge_handle()->next()->twin(); - this->current_event()->set_halfedge_handle(next_ccw_he); - } + +//----------------------------------------------------------------------------- +// A notification invoked when a new subcurve is created. +// +template +void Arr_no_intersection_insertion_ss_visitor:: +add_subcurve(const X_monotone_curve_2& cv, Subcurve* sc) +{ + if (add_subcurve_(cv, sc)) return; + + Halfedge_handle next_ccw_he = + this->current_event()->halfedge_handle()->next()->twin(); + this->current_event()->set_halfedge_handle(next_ccw_he); } //----------------------------------------------------------------------------- // Insert the given subcurve in the interior of an arrangement face. // -template -typename Arr_basic_insertion_sl_visitor::Halfedge_handle -Arr_basic_insertion_sl_visitor:: +template +typename Arr_no_intersection_insertion_ss_visitor::Halfedge_handle +Arr_no_intersection_insertion_ss_visitor:: insert_in_face_interior(const X_monotone_curve_2& cv, Subcurve* sc) { Event* last_event = this->last_event_on_subcurve(sc); @@ -371,9 +393,9 @@ insert_in_face_interior(const X_monotone_curve_2& cv, Subcurve* sc) //----------------------------------------------------------------------------- // Insert the given subcurve from a vertex that corresponds to its left end. // -template -typename Arr_basic_insertion_sl_visitor::Halfedge_handle -Arr_basic_insertion_sl_visitor:: +template +typename Arr_no_intersection_insertion_ss_visitor::Halfedge_handle +Arr_no_intersection_insertion_ss_visitor:: insert_from_left_vertex(const X_monotone_curve_2& cv, Halfedge_handle he, Subcurve* sc) { @@ -387,9 +409,9 @@ insert_from_left_vertex(const X_monotone_curve_2& cv, Halfedge_handle he, //----------------------------------------------------------------------------- // Insert the given subcurve from a vertex that corresponds to its right end. // -template -typename Arr_basic_insertion_sl_visitor::Halfedge_handle -Arr_basic_insertion_sl_visitor:: +template +typename Arr_no_intersection_insertion_ss_visitor::Halfedge_handle +Arr_no_intersection_insertion_ss_visitor:: insert_from_right_vertex(const X_monotone_curve_2& cv, Halfedge_handle he, Subcurve* sc) { @@ -403,9 +425,9 @@ insert_from_right_vertex(const X_monotone_curve_2& cv, Halfedge_handle he, //----------------------------------------------------------------------------- // Insert the given subcurve using its two end-vertices. // -template -typename Arr_basic_insertion_sl_visitor::Halfedge_handle -Arr_basic_insertion_sl_visitor:: +template +typename Arr_no_intersection_insertion_ss_visitor::Halfedge_handle +Arr_no_intersection_insertion_ss_visitor:: insert_at_vertices(const X_monotone_curve_2& cv, Halfedge_handle prev1, Halfedge_handle prev2, Subcurve* sc, bool &new_face_created) @@ -414,14 +436,14 @@ insert_at_vertices(const X_monotone_curve_2& cv, //----------------------------------------------------------------------------- // Insert an isolated vertex into the arrangement. // -template -typename Arr_basic_insertion_sl_visitor::Vertex_handle -Arr_basic_insertion_sl_visitor:: +template +typename Arr_no_intersection_insertion_ss_visitor::Vertex_handle +Arr_no_intersection_insertion_ss_visitor:: 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(); - + // Look up and insert the isolated vertex in the incident face of the // halfedge we see. Face_handle f = _ray_shoot_up(iter); @@ -431,9 +453,9 @@ insert_isolated_vertex(const Point_2& pt, Status_line_iterator iter) //----------------------------------------------------------------------------- // Perform the actual insertion // -template -typename Arr_basic_insertion_sl_visitor::Halfedge_handle -Arr_basic_insertion_sl_visitor:: +template +typename Arr_no_intersection_insertion_ss_visitor::Halfedge_handle +Arr_no_intersection_insertion_ss_visitor:: _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 @@ -492,7 +514,7 @@ _insert_in_face_interior(const X_monotone_curve_2& cv, Subcurve* sc) // Look up and insert the edge in the interior of the incident face of the // halfedge we see. - Face_handle f = _ray_shoot_up(this->status_line_position(sc)); + Face_handle f = _ray_shoot_up(sc->hint()); return (this->m_arr_access.insert_in_face_interior_ex(f, cv.base(), ARR_LEFT_TO_RIGHT, v1, v2)); @@ -501,9 +523,9 @@ _insert_in_face_interior(const X_monotone_curve_2& cv, Subcurve* sc) //----------------------------------------------------------------------------- // Perform the actual insertion // -template -typename Arr_basic_insertion_sl_visitor::Halfedge_handle -Arr_basic_insertion_sl_visitor:: +template +typename Arr_no_intersection_insertion_ss_visitor::Halfedge_handle +Arr_no_intersection_insertion_ss_visitor:: _insert_from_left_vertex(const X_monotone_curve_2& cv, Halfedge_handle prev, Subcurve* sc) { @@ -538,9 +560,9 @@ _insert_from_left_vertex(const X_monotone_curve_2& cv, //----------------------------------------------------------------------------- // Perform the actual insertion // -template -typename Arr_basic_insertion_sl_visitor::Halfedge_handle -Arr_basic_insertion_sl_visitor:: +template +typename Arr_no_intersection_insertion_ss_visitor::Halfedge_handle +Arr_no_intersection_insertion_ss_visitor:: _insert_from_right_vertex(const X_monotone_curve_2& cv, Halfedge_handle prev, Subcurve* sc) { @@ -575,9 +597,9 @@ _insert_from_right_vertex(const X_monotone_curve_2& cv, Halfedge_handle prev, //----------------------------------------------------------------------------- // Perform the actual insertion // -template -typename Arr_basic_insertion_sl_visitor::Halfedge_handle -Arr_basic_insertion_sl_visitor:: +template +typename Arr_no_intersection_insertion_ss_visitor::Halfedge_handle +Arr_no_intersection_insertion_ss_visitor:: _insert_at_vertices(const X_monotone_curve_2& cv, Halfedge_handle prev1, Halfedge_handle prev2, Subcurve* sc, bool& new_face_created) @@ -609,7 +631,7 @@ _insert_at_vertices(const X_monotone_curve_2& cv, // existing face (pointed by the twin halfedge) and move the relevant // holes and isolated vertices into the new face. if (new_face_created) this->m_arr_access.relocate_in_new_face(new_he); - + // Return a handle to the new halfedge directed from prev1's target to // prev2's target. Note that this may be the twin halfedge of the one // returned by _insert_at_vertices(); @@ -620,9 +642,10 @@ _insert_at_vertices(const X_monotone_curve_2& cv, //----------------------------------------------------------------------------- // Locate the face containing the current object in its interior. // -template -typename Arr_basic_insertion_sl_visitor::Face_handle -Arr_basic_insertion_sl_visitor::_ray_shoot_up(Status_line_iterator iter) +template +typename Arr_no_intersection_insertion_ss_visitor::Face_handle +Arr_no_intersection_insertion_ss_visitor:: +_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. @@ -638,6 +661,6 @@ Arr_basic_insertion_sl_visitor::_ray_shoot_up(Status_line_iterator iter) return (this->m_helper.top_face()); } -} //namespace CGAL +} // namespace CGAL #endif diff --git a/Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_overlay_event.h b/Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_overlay_event.h new file mode 100644 index 00000000000..805e3fc5cb6 --- /dev/null +++ b/Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_overlay_event.h @@ -0,0 +1,67 @@ +// Copyright (c) 2006,2007,2009,2010,2011 Tel-Aviv University (Israel). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// You can redistribute it and/or modify it under the terms of the GNU +// General Public License as published by the Free Software Foundation, +// either version 3 of the License, or (at your option) any later version. +// +// Licensees holding a valid commercial license may use this file in +// accordance with the commercial license agreement provided with the software. +// +// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Author(s) : Tali Zvi +// Baruch Zukerman +// Efi Fogel + +#ifndef CGAL_ARR_OVERLAY_EVENT_H +#define CGAL_ARR_OVERLAY_EVENT_H + +#include + +/*! \file + * + * Definition of the Arr_construction_event_base class-template. + */ + +#include +#include + +namespace CGAL { + +/* \class Arr_overlay_event + * + * This template represents an event used by the surface-sweep framework, where + * the input curves for the surface-sweep procedure are extracted from two + * arrangements that are overlaid. + * + * \tparam GeometryTraits_2 the geometry traits. + * \tparam Arrangement_ the type of the arrangement that is the resulting + * arrangement the overlay process. + * \tparam Allocator_ a type of an element that is used to acquire/release + * memory for elements of the event queue and the status + * structure, and to construct/destroy the elements in that + * memory. The type must meet the requirements of Allocator. + */ +template +class Arr_overlay_event : + public Arr_construction_event_base, + Allocator_>, + Arrangement_> +{ +public: + /*! Construct default. */ + Arr_overlay_event() {} +}; + +} // namespace CGAL + +#endif diff --git a/Sweep_line_2/include/CGAL/Sweep_line_2/Arr_overlay_sl_visitor.h b/Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_overlay_ss_visitor.h similarity index 84% rename from Sweep_line_2/include/CGAL/Sweep_line_2/Arr_overlay_sl_visitor.h rename to Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_overlay_ss_visitor.h index 978ea77e1c7..fc688892496 100644 --- a/Sweep_line_2/include/CGAL/Sweep_line_2/Arr_overlay_sl_visitor.h +++ b/Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_overlay_ss_visitor.h @@ -21,14 +21,14 @@ // Ron Wein // Efi Fogel -#ifndef CGAL_ARR_OVERLAY_SL_VISITOR_H -#define CGAL_ARR_OVERLAY_SL_VISITOR_H - -#include +#ifndef CGAL_ARR_OVERLAY_SS_VISITOR_H +#define CGAL_ARR_OVERLAY_SS_VISITOR_H +#include /*! \file - * Definition of the Arr_overlay_sl_visitor class-template. + * + * Definition of the Arr_overlay_ss_visitor class-template. */ #include @@ -37,82 +37,100 @@ #include #include -#include +#include #include +#include namespace CGAL { -/*! \class Arr_overlay_sl_visitor +/*! \class Arr_overlay_ss_visitor + * * A sweep-line visitor for overlaying a "red" arrangement and a "blue" * arrangement, creating a result arrangement. All three arrangements are * embedded on the same type of surface and use the same geometry traits. */ -template -class Arr_overlay_sl_visitor : public - Arr_construction_sl_visitor +template +class Arr_overlay_ss_visitor : + public Arr_construction_ss_visitor< + typename OverlayHelper::Construction_helper, + typename Default::Get >::type> { public: - typedef OverlayHelper_ Overlay_helper; - typedef OverlayTraits_ Overlay_traits; + typedef OverlayHelper Overlay_helper; + typedef OverlayTraits Overlay_traits; - typedef typename Overlay_helper::Traits_2 Traits_2; - typedef typename Overlay_helper::Event Event; - typedef typename Overlay_helper::Subcurve Subcurve; + typedef typename Overlay_helper::Geometry_traits_2 Geometry_traits_2; + typedef typename Overlay_helper::Event Event; + typedef typename Overlay_helper::Subcurve Subcurve; - typedef typename Traits_2::X_monotone_curve_2 X_monotone_curve_2; - typedef typename Traits_2::Point_2 Point_2; + typedef typename Overlay_helper::Arrangement_red_2 Arrangement_red_2; + typedef typename Overlay_helper::Arrangement_blue_2 Arrangement_blue_2; + + typedef typename Overlay_helper::Construction_helper Construction_helper; + + +private: + typedef Geometry_traits_2 Gt2; + typedef Arrangement_red_2 Ar2; + typedef Arrangement_blue_2 Ab2; + + typedef Arr_overlay_ss_visitor + Self; + typedef typename Default::Get::type Visitor; + typedef Arr_construction_ss_visitor + Base; + +public: + typedef typename Gt2::X_monotone_curve_2 X_monotone_curve_2; + typedef typename Gt2::Point_2 Point_2; // The input arrangements (the "red" and the "blue" one): - typedef typename Overlay_helper::Arrangement_red_2 Arrangement_red_2; - typedef typename Arrangement_red_2::Halfedge_const_handle - Halfedge_handle_red; - typedef typename Arrangement_red_2::Face_const_handle Face_handle_red; - typedef typename Arrangement_red_2::Vertex_const_handle Vertex_handle_red; + typedef typename Ar2::Halfedge_const_handle Halfedge_handle_red; + typedef typename Ar2::Face_const_handle Face_handle_red; + typedef typename Ar2::Vertex_const_handle Vertex_handle_red; - typedef typename Overlay_helper::Arrangement_blue_2 Arrangement_blue_2; - typedef typename Arrangement_blue_2::Halfedge_const_handle - Halfedge_handle_blue; - typedef typename Arrangement_blue_2::Face_const_handle Face_handle_blue; - typedef typename Arrangement_blue_2::Vertex_const_handle Vertex_handle_blue; + typedef typename Ab2::Halfedge_const_handle Halfedge_handle_blue; + typedef typename Ab2::Face_const_handle Face_handle_blue; + typedef typename Ab2::Vertex_const_handle Vertex_handle_blue; // The resulting arrangement: - typedef typename Overlay_helper::Arrangement_2 Arrangement_2; - typedef typename Arrangement_2::Halfedge_handle Halfedge_handle; - typedef typename Arrangement_2::Face_handle Face_handle; - typedef typename Arrangement_2::Vertex_handle Vertex_handle; + typedef typename Overlay_helper::Arrangement_2 Arrangement_2; + typedef typename Arrangement_2::Halfedge_handle Halfedge_handle; + typedef typename Arrangement_2::Face_handle Face_handle; + typedef typename Arrangement_2::Vertex_handle Vertex_handle; typedef typename Arrangement_2::Ccb_halfedge_circulator Ccb_halfedge_circulator; - typedef typename Arrangement_2::Outer_ccb_iterator Outer_ccb_iterator; - - // The base construction visitor: - typedef typename Overlay_helper::Construction_helper Construction_helper; - typedef Arr_construction_sl_visitor Base; + typedef typename Arrangement_2::Outer_ccb_iterator Outer_ccb_iterator; typedef typename Base::Event_subcurve_iterator Event_subcurve_iterator; typedef typename Base::Event_subcurve_reverse_iterator Event_subcurve_reverse_iterator; - typedef typename Base::Status_line_iterator Status_line_iterator; + typedef typename Base::Status_line_iterator Status_line_iterator; protected: - typedef typename Traits_2::Cell_handle_red Cell_handle_red; - typedef typename Traits_2::Optional_cell_red Optional_cell_red; - typedef typename Traits_2::Cell_handle_blue Cell_handle_blue; - typedef typename Traits_2::Optional_cell_blue Optional_cell_blue; + typedef typename Gt2::Cell_handle_red Cell_handle_red; + typedef typename Gt2::Optional_cell_red Optional_cell_red; + typedef typename Gt2::Cell_handle_blue Cell_handle_blue; + typedef typename Gt2::Optional_cell_blue Optional_cell_blue; typedef std::pair - Halfedge_info; - typedef Unique_hash_map Halfedge_map; + Halfedge_info; + typedef Unique_hash_map + Halfedge_map; - typedef std::pair Handle_info; + typedef std::pair Handle_info; typedef boost::unordered_map - Vertex_map; + Vertex_map; // Side categoties: - typedef typename Traits_2::Left_side_category Left_side_category; - typedef typename Traits_2::Bottom_side_category Bottom_side_category; - typedef typename Traits_2::Top_side_category Top_side_category; - typedef typename Traits_2::Right_side_category Right_side_category; + typedef typename Gt2::Left_side_category Left_side_category; + typedef typename Gt2::Bottom_side_category Bottom_side_category; + typedef typename Gt2::Top_side_category Top_side_category; + typedef typename Gt2::Right_side_category Right_side_category; typedef typename Arr_has_identified_sides::result @@ -135,8 +153,8 @@ protected: // and blue halfedges that induce it. public: /*! Constructor */ - Arr_overlay_sl_visitor(const Arrangement_red_2* red_arr, - const Arrangement_blue_2* blue_arr, + Arr_overlay_ss_visitor(const Ar2* red_arr, + const Ab2* blue_arr, Arrangement_2* res_arr, Overlay_traits* overlay_traits): Base(res_arr), @@ -149,7 +167,7 @@ public: {} /*! Destructor */ - virtual ~Arr_overlay_sl_visitor() {} + virtual ~Arr_overlay_ss_visitor() {} /// \name Sweep-line notifications. //@{ @@ -396,8 +414,8 @@ protected: //----------------------------------------------------------------------------- // A notification issued before the sweep process starts. // -template -void Arr_overlay_sl_visitor::before_sweep() + template + void Arr_overlay_ss_visitor::before_sweep() { // Initialize the necessary fields in the base construction visitor. // Note that the construction visitor also informs its helper class that @@ -412,8 +430,9 @@ void Arr_overlay_sl_visitor::before_sweep() // A notification invoked before the sweep-line starts handling the given // event. // -template -void Arr_overlay_sl_visitor::before_handle_event(Event* event) +template +void +Arr_overlay_ss_visitor::before_handle_event(Event* event) { // Let the base construction visitor do the work (and also inform its helper // class on the event). @@ -427,8 +446,8 @@ void Arr_overlay_sl_visitor::before_handle_event(Event* event) // A notification invoked after the sweep-line finishes handling the given // event. // -template -bool Arr_overlay_sl_visitor:: +template +bool Arr_overlay_ss_visitor:: after_handle_event(Event* event, Status_line_iterator iter, bool flag) { // Let the base construction visitor handle the event. @@ -445,9 +464,9 @@ after_handle_event(Event* event, Status_line_iterator iter, bool flag) if (sc_above == NULL) { if (rev_iter != event->right_curves_rend()) { - if ((*rev_iter)->color() == Traits_2::BLUE) + if ((*rev_iter)->color() == Gt2::BLUE) (*rev_iter)->set_red_top_face(m_overlay_helper.red_top_face()); - else if ((*rev_iter)->color() == Traits_2::RED) + else if ((*rev_iter)->color() == Gt2::RED) (*rev_iter)->set_blue_top_face(m_overlay_helper.blue_top_face()); (*rev_iter)->set_subcurve_above(NULL); @@ -479,8 +498,8 @@ after_handle_event(Event* event, Status_line_iterator iter, bool flag) //----------------------------------------------------------------------------- // Update an event that corresponds to a curve endpoint. // -template -void Arr_overlay_sl_visitor:: +template +void Arr_overlay_ss_visitor:: update_event(Event* e, const Point_2& end_point, const X_monotone_curve_2& /* cv */, @@ -499,16 +518,16 @@ update_event(Event* e, //----------------------------------------------------------------------------- // Update an event. // -template -void Arr_overlay_sl_visitor::update_event(Event* e, - Subcurve* sc) +template +void Arr_overlay_ss_visitor::update_event(Event* e, + Subcurve* sc) { // Update the red and blue halfedges associated with the point as necessary. Point_2& pt = e->point(); if (pt.is_red_cell_empty()) { CGAL_assertion(! pt.is_blue_cell_empty()); - CGAL_assertion(sc->color() == Traits_2::RED); + CGAL_assertion(sc->color() == Gt2::RED); Halfedge_handle_red red_he = sc->red_halfedge_handle(); pt.set_red_cell(boost::make_optional(Cell_handle_red(red_he))); @@ -522,8 +541,9 @@ void Arr_overlay_sl_visitor::update_event(Event* e, //----------------------------------------------------------------------------- // Update an event. // -template -void Arr_overlay_sl_visitor::update_event(Event* e, +template +void +Arr_overlay_ss_visitor::update_event(Event* e, const Point_2& p, bool /* is_new */) { @@ -536,8 +556,8 @@ void Arr_overlay_sl_visitor::update_event(Event* e, //----------------------------------------------------------------------------- // A notification issued when the sweep process has ended. // -template -void Arr_overlay_sl_visitor::after_sweep() +template +void Arr_overlay_ss_visitor::after_sweep() { // Notify boundary vertices: typename Vertex_map::iterator it; @@ -562,9 +582,9 @@ void Arr_overlay_sl_visitor::after_sweep() //----------------------------------------------------------------------------- // Insert the given subcurve in the interior of an arrangement face. // -template -typename Arr_overlay_sl_visitor::Halfedge_handle -Arr_overlay_sl_visitor:: +template +typename Arr_overlay_ss_visitor::Halfedge_handle +Arr_overlay_ss_visitor:: insert_in_face_interior(const X_monotone_curve_2& cv, Subcurve* sc) { // Insert the halfedge using the base construction visitor. @@ -595,9 +615,9 @@ insert_in_face_interior(const X_monotone_curve_2& cv, Subcurve* sc) //----------------------------------------------------------------------------- // Insert the given subcurve given its left end-vertex. // -template -typename Arr_overlay_sl_visitor::Halfedge_handle -Arr_overlay_sl_visitor:: +template +typename Arr_overlay_ss_visitor::Halfedge_handle +Arr_overlay_ss_visitor:: insert_from_left_vertex(const X_monotone_curve_2& cv, Halfedge_handle prev, Subcurve* sc) @@ -627,9 +647,9 @@ insert_from_left_vertex(const X_monotone_curve_2& cv, //----------------------------------------------------------------------------- // Insert the given subcurve given its right end-vertex. // -template -typename Arr_overlay_sl_visitor::Halfedge_handle -Arr_overlay_sl_visitor:: +template +typename Arr_overlay_ss_visitor::Halfedge_handle +Arr_overlay_ss_visitor:: insert_from_right_vertex(const X_monotone_curve_2& cv, Halfedge_handle prev, Subcurve* sc) @@ -658,9 +678,9 @@ insert_from_right_vertex(const X_monotone_curve_2& cv, //----------------------------------------------------------------------------- // Insert the given subcurve given its two end-vertices. // -template -typename Arr_overlay_sl_visitor::Halfedge_handle -Arr_overlay_sl_visitor:: +template +typename Arr_overlay_ss_visitor::Halfedge_handle +Arr_overlay_ss_visitor:: insert_at_vertices(const X_monotone_curve_2& cv, Halfedge_handle prev1, Halfedge_handle prev2, @@ -696,17 +716,17 @@ insert_at_vertices(const X_monotone_curve_2& cv, // Traverse the boundary of the new face, and locate halfedge originated // by red or by blue halfedges along its boundary. // We stop the traversal earlier if we locate a red and a blue halfedge. - const Halfedge_handle_red invalid_red_he; - const Halfedge_handle_blue invalid_blue_he; + const Halfedge_handle_red invalid_red_he; + const Halfedge_handle_blue invalid_blue_he; - Halfedge_handle_red red_he; - Halfedge_handle_blue blue_he; + Halfedge_handle_red red_he; + Halfedge_handle_blue blue_he; CGAL_assertion(new_face->number_of_outer_ccbs() > 0); Outer_ccb_iterator occb_it = new_face->outer_ccbs_begin(); // msvc CL requires the breakdown to the following 2 statements: - Ccb_halfedge_circulator ccb_first = *occb_it; - Ccb_halfedge_circulator ccb_circ = ccb_first; + Ccb_halfedge_circulator ccb_first = *occb_it; + Ccb_halfedge_circulator ccb_circ = ccb_first; do { // Get the current halfedge on the face boundary and obtain its @@ -776,9 +796,9 @@ insert_at_vertices(const X_monotone_curve_2& cv, //----------------------------------------------------------------------------- // Insert an isolated vertex into the arrangement. // -template -typename Arr_overlay_sl_visitor::Vertex_handle -Arr_overlay_sl_visitor:: +template +typename Arr_overlay_ss_visitor::Vertex_handle +Arr_overlay_ss_visitor:: insert_isolated_vertex(const Point_2& pt, Status_line_iterator iter) { @@ -819,7 +839,7 @@ insert_isolated_vertex(const Point_2& pt, red_face = m_overlay_helper.red_top_face(); } else { - if (sc_above->color() != Traits_2::BLUE) { + if (sc_above->color() != Gt2::BLUE) { red_face = sc_above->red_halfedge_handle()->face(); } else { @@ -855,7 +875,7 @@ insert_isolated_vertex(const Point_2& pt, blue_face = m_overlay_helper.blue_top_face(); } else { - if (sc_above->color() != Traits_2::RED) { + if (sc_above->color() != Gt2::RED) { blue_face = sc_above->blue_halfedge_handle()->face(); } else { @@ -878,8 +898,8 @@ insert_isolated_vertex(const Point_2& pt, // Map a newly created halfedge in the result arrangement to its originator // red and blue halfedges. // -template -void Arr_overlay_sl_visitor:: +template +void Arr_overlay_ss_visitor:: _map_halfedge_and_twin(Halfedge_handle he, Halfedge_handle_red red_he, Halfedge_handle_blue blue_he) @@ -905,8 +925,8 @@ _map_halfedge_and_twin(Halfedge_handle he, //----------------------------------------------------------------------------- // Update the boundary vertices map. // -template -void Arr_overlay_sl_visitor:: +template +void Arr_overlay_ss_visitor:: _map_boundary_vertices(Event* event, Vertex_handle v, boost::mpl::bool_) { // Update the red and blue object if the last event on sc is on the boundary. @@ -942,9 +962,10 @@ _map_boundary_vertices(Event* event, Vertex_handle v, boost::mpl::bool_) //----------------------------------------------------------------------------- // Update the boundary vertices map. // -template -void Arr_overlay_sl_visitor:: -_map_boundary_vertices(Event* /* event */, Vertex_handle /* v */, boost::mpl::bool_) +template +void Arr_overlay_ss_visitor:: +_map_boundary_vertices(Event* /* event */, Vertex_handle /* v */, + boost::mpl::bool_) {} /* Notify the overlay traits about a newly created vertex. @@ -953,8 +974,8 @@ _map_boundary_vertices(Event* /* event */, Vertex_handle /* v */, boost::mpl::bo * this case, we postpone the notification for all (contracted and identified) * boundary side vertices to the end of the sweep. */ -template -void Arr_overlay_sl_visitor:: +template +void Arr_overlay_ss_visitor:: _create_vertex(Event* event, Vertex_handle new_v, Subcurve* sc, @@ -999,8 +1020,8 @@ _create_vertex(Event* event, } /* Notify the overlay traits about a newly created vertex. */ -template -void Arr_overlay_sl_visitor:: +template +void Arr_overlay_ss_visitor:: _create_vertex(Event* event, Vertex_handle new_v, Subcurve* sc, @@ -1044,10 +1065,10 @@ _create_vertex(Event* event, //----------------------------------------------------------------------------- // Update a newly created result edge using the overlay traits. // -template -void -Arr_overlay_sl_visitor::_create_edge(Subcurve* sc, - Halfedge_handle new_he) +template +void Arr_overlay_ss_visitor:: +_create_edge(Subcurve* sc, + Halfedge_handle new_he) { // Note that the "red" and "blue" halfedges are always directed from right // to left, so we make sure the overlaid halfedge is also directed from @@ -1055,7 +1076,7 @@ Arr_overlay_sl_visitor::_create_edge(Subcurve* sc, if (new_he->direction() != ARR_RIGHT_TO_LEFT) new_he = new_he->twin(); // Examine the various cases for the creation of a new edge. - if (sc->color() == Traits_2::RB_OVERLAP) { + if (sc->color() == Gt2::RB_OVERLAP) { // The new edge represents an overlap between a red halfedge and a blue // halfedge. Halfedge_handle_red red_he = sc->red_halfedge_handle(); @@ -1063,7 +1084,7 @@ Arr_overlay_sl_visitor::_create_edge(Subcurve* sc, m_overlay_traits->create_edge(red_he, blue_he, new_he); } - else if (sc->color() == Traits_2::RED) { + else if (sc->color() == Gt2::RED) { // We have a red edge on a blue face. Halfedge_handle_red red_he = sc->red_halfedge_handle(); Subcurve* sc_above = sc->subcurve_above(); @@ -1072,7 +1093,7 @@ Arr_overlay_sl_visitor::_create_edge(Subcurve* sc, m_overlay_traits->create_edge(red_he, blue_f, new_he); } else { - CGAL_assertion(sc->color() == Traits_2::BLUE); + CGAL_assertion(sc->color() == Gt2::BLUE); // We have a blue edge on a red face. Halfedge_handle_blue blue_he = sc->blue_halfedge_handle(); @@ -1083,6 +1104,6 @@ Arr_overlay_sl_visitor::_create_edge(Subcurve* sc, } } -} //namespace CGAL +} // namespace CGAL #endif diff --git a/Sweep_line_2/include/CGAL/Sweep_line_2/Arr_overlay_subcurve.h b/Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_overlay_subcurve.h similarity index 54% rename from Sweep_line_2/include/CGAL/Sweep_line_2/Arr_overlay_subcurve.h rename to Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_overlay_subcurve.h index 71ea56c5e69..07db8cba4d9 100644 --- a/Sweep_line_2/include/CGAL/Sweep_line_2/Arr_overlay_subcurve.h +++ b/Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_overlay_subcurve.h @@ -15,7 +15,7 @@ // $URL$ // $Id$ // SPDX-License-Identifier: GPL-3.0+ -// +// // // Author(s) : Baruch Zukerman // Ron Wein @@ -23,52 +23,71 @@ #ifndef CGAL_OVERLAY_SUBCURVE_H #define CGAL_OVERLAY_SUBCURVE_H -#include - +#include /*! \file + * * Definition of the Arr_overlay_subcurve class-template. */ -#include +#include +#include namespace CGAL { +namespace Ss2 = Surface_sweep_2; + /*! \class + * * Representation of a subcurve in the overlay process. A subcurve can * originate from a "red" arrangement or from a "blue" arrangement that are * overlaid one on top of the other. It stores information of the halfedge * from the opposite color it "sees" from below, so it can be easily located * in the proper place in the resulting arrangement. + * + * \tparam GeometryTraits_2 the geometry traits. + * \tparam Event_ the event type. + * \tparam Allocator_ a type of an element that is used to acquire/release + * memory for elements of the event queue and the status + * structure, and to construct/destroy the elements in that */ -template -class Arr_overlay_subcurve : public Arr_construction_subcurve +template +class Arr_overlay_subcurve : + public Arr_construction_subcurve > { public: + typedef GeometryTraits_2 Geometry_traits_2; + typedef Event_ Event; + typedef Allocator_ Allocator; - typedef Traits_ Traits_2; - typedef typename Traits_2::Point_2 Point_2; - typedef typename Traits_2::X_monotone_curve_2 X_monotone_curve_2; +private: + typedef Geometry_traits_2 Gt2; + typedef Arr_overlay_subcurve Self; + typedef Arr_construction_subcurve Base; - typedef Arr_construction_subcurve Base; - typedef Arr_overlay_subcurve Self; +public: + typedef typename Gt2::Point_2 Point_2; + typedef typename Gt2::X_monotone_curve_2 X_monotone_curve_2; - typedef typename Base::Status_line_iterator Status_line_iterator; + typedef typename Base::Status_line_iterator Status_line_iterator; - typedef typename Traits_2::Color Color; + typedef typename Gt2::Color Color; - typedef typename Traits_2::Halfedge_handle_red Halfedge_handle_red; - typedef typename Traits_2::Face_handle_red Face_handle_red; - typedef typename Face_handle_red::value_type Face_red; + typedef typename Gt2::Halfedge_handle_red Halfedge_handle_red; + typedef typename Gt2::Face_handle_red Face_handle_red; + typedef typename Face_handle_red::value_type Face_red; - typedef typename Traits_2::Halfedge_handle_blue Halfedge_handle_blue; - typedef typename Traits_2::Face_handle_blue Face_handle_blue; - typedef typename Face_handle_blue::value_type Face_blue; - - typedef Sweep_line_event Event; + typedef typename Gt2::Halfedge_handle_blue Halfedge_handle_blue; + typedef typename Gt2::Face_handle_blue Face_handle_blue; + typedef typename Face_handle_blue::value_type Face_blue; protected: - // Data members: Self* m_above; // A subcurve of an opposite color that lies above. @@ -78,52 +97,48 @@ protected: } m_top_face; // If m_above is NULL, points the top face in // the arrangement of the opposite color that // contains the subcurve. - + public: /*! Constructor. */ Arr_overlay_subcurve() : Base(), m_above(NULL) - { - m_top_face.red = NULL; - } + { m_top_face.red = NULL; } /*! constructor given a curve. */ Arr_overlay_subcurve(const X_monotone_curve_2& curve) : Base(curve), m_above(NULL) - { - m_top_face.red = NULL; - } + { m_top_face.red = NULL; } /*! Get the subcurve lying above above this subcurve in the status line. */ - Self* subcurve_above() const { return (m_above); } + Self* subcurve_above() const { return m_above; } /*! Set the subcurve above. */ void set_subcurve_above(Self* sc) { m_above = sc; } /*! Get the color of the associated curve. */ - Color color() const { return (this->m_lastCurve.color()); } + Color color() const { return (this->last_curve().color()); } /*! Check if two subcurves have the same color. */ bool has_same_color(const Self* sc) const - { return (this->m_lastCurve.color() == sc->color()); } + { return (this->last_curve().color() == sc->color()); } /*! Get the red halfedge that represents the subcurve. */ Halfedge_handle_red red_halfedge_handle() const - { return (this->m_lastCurve.red_halfedge_handle()); } + { return (this->last_curve().red_halfedge_handle()); } /*! Get the blue halfedge that represents the subcurve. */ Halfedge_handle_blue blue_halfedge_handle() const - { return (this->m_lastCurve.blue_halfedge_handle()); } + { return (this->last_curve().blue_halfedge_handle()); } /*! Get the red top face that contains the subcurve. */ const Face_handle_red red_top_face() const - { return (Face_handle_red(m_top_face.red)); } + { return Face_handle_red(m_top_face.red); } /*! Get the blue top face that contains the subcurve. */ const Face_handle_blue blue_top_face() const - { return (Face_handle_blue(m_top_face.blue)); } + { return Face_handle_blue(m_top_face.blue); } /*! Set the red top face. */ void set_red_top_face(Face_handle_red fh) { m_top_face.red = &(*fh); } @@ -135,13 +150,13 @@ public: void set_top_face(const Self* sc) { CGAL_precondition(sc->m_above == NULL); - + // Mark there is no curve above and copy the face pointer. m_above = NULL; m_top_face.red = sc->m_top_face.red; } }; - -} //namespace CGAL + +} // namespace CGAL #endif diff --git a/Sweep_line_2/include/CGAL/Sweep_line_2/Arr_overlay_traits_2.h b/Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_overlay_traits_2.h similarity index 83% rename from Sweep_line_2/include/CGAL/Sweep_line_2/Arr_overlay_traits_2.h rename to Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_overlay_traits_2.h index 6858063a9f3..1ef10dcf3c9 100644 --- a/Sweep_line_2/include/CGAL/Sweep_line_2/Arr_overlay_traits_2.h +++ b/Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_overlay_traits_2.h @@ -15,7 +15,7 @@ // $URL$ // $Id$ // SPDX-License-Identifier: GPL-3.0+ -// +// // // Author(s) : Baruch Zukerman // Ron Wein @@ -24,10 +24,10 @@ #ifndef CGAL_ARR_OVERLAY_TRAITS_2_H #define CGAL_ARR_OVERLAY_TRAITS_2_H -#include +#include - -/*! +/*! \file + * * Defintion of the Arr_overlay_traits_2 class-template. */ @@ -40,60 +40,60 @@ namespace CGAL { /*! \class + * * A meta-traits class that stores a red or a blue halfedge handle with every * x-monotone curve, and a red or blue vertex handle with each point. This * information is used to speed up the overlay of a red arrangement and a blue * arrangement one on top of the other. */ -template +template class Arr_overlay_traits_2 { public: - typedef GeometryTraits_ Traits_2; - typedef ArrangementRed_ Arrangement_red_2; - typedef ArrangementBlue_ Arrangement_blue_2; + typedef GeometryTraits_2 Geometry_traits_2; + typedef ArrangementRed_2 Arrangement_red_2; + typedef ArrangementBlue_2 Arrangement_blue_2; - typedef typename Arrangement_red_2::Face_const_handle - Face_handle_red; - typedef typename Arrangement_blue_2::Face_const_handle - Face_handle_blue; +private: + typedef Geometry_traits_2 Gt2; + typedef Arrangement_red_2 Ar2; + typedef Arrangement_blue_2 Ab2; - typedef typename Arrangement_red_2::Halfedge_const_handle - Halfedge_handle_red; - typedef typename Arrangement_blue_2::Halfedge_const_handle - Halfedge_handle_blue; +public: + typedef typename Ar2::Face_const_handle Face_handle_red; + typedef typename Ab2::Face_const_handle Face_handle_blue; - typedef typename Arrangement_red_2::Vertex_const_handle - Vertex_handle_red; - typedef typename Arrangement_blue_2::Vertex_const_handle - Vertex_handle_blue; + typedef typename Ar2::Halfedge_const_handle Halfedge_handle_red; + typedef typename Ab2::Halfedge_const_handle Halfedge_handle_blue; - typedef typename Traits_2::X_monotone_curve_2 Base_x_monotone_curve_2; - typedef typename Traits_2::Point_2 Base_point_2; - typedef typename Traits_2::Multiplicity Multiplicity; + typedef typename Ar2::Vertex_const_handle Vertex_handle_red; + typedef typename Ab2::Vertex_const_handle Vertex_handle_blue; - typedef typename Traits_2::Compare_x_2 Base_compare_x_2; - typedef typename Traits_2::Compare_xy_2 Base_compare_xy_2; - typedef typename Traits_2::Construct_min_vertex_2 Base_construct_min_vertex_2; - typedef typename Traits_2::Construct_max_vertex_2 Base_construct_max_vertex_2; - typedef typename Traits_2::Is_vertical_2 Base_is_vertical_2; - typedef typename Traits_2::Compare_y_at_x_2 Base_compare_y_at_x_2; - typedef typename Traits_2::Compare_y_at_x_right_2 Base_compare_y_at_x_right_2; - typedef typename Traits_2::Intersect_2 Base_intersect_2; - typedef typename Traits_2::Split_2 Base_split_2; - typedef typename Traits_2::Equal_2 Base_equal_2; + typedef typename Gt2::X_monotone_curve_2 Base_x_monotone_curve_2; + typedef typename Gt2::Point_2 Base_point_2; + typedef typename Gt2::Multiplicity Multiplicity; - typedef typename Traits_2::Has_do_intersect_category - Has_do_intersect_category; + typedef typename Gt2::Compare_x_2 Base_compare_x_2; + typedef typename Gt2::Compare_xy_2 Base_compare_xy_2; + typedef typename Gt2::Construct_min_vertex_2 Base_construct_min_vertex_2; + typedef typename Gt2::Construct_max_vertex_2 Base_construct_max_vertex_2; + typedef typename Gt2::Is_vertical_2 Base_is_vertical_2; + typedef typename Gt2::Compare_y_at_x_2 Base_compare_y_at_x_2; + typedef typename Gt2::Compare_y_at_x_right_2 Base_compare_y_at_x_right_2; + typedef typename Gt2::Intersect_2 Base_intersect_2; + typedef typename Gt2::Split_2 Base_split_2; + typedef typename Gt2::Equal_2 Base_equal_2; - typedef typename internal::Arr_complete_left_side_category::Category - Left_side_category; - typedef typename internal::Arr_complete_bottom_side_category::Category - Bottom_side_category; - typedef typename internal::Arr_complete_top_side_category::Category - Top_side_category; - typedef typename internal::Arr_complete_right_side_category::Category - Right_side_category; + typedef typename Gt2::Has_do_intersect_category Has_do_intersect_category; + + typedef typename internal::Arr_complete_left_side_category::Category + Left_side_category; + typedef typename internal::Arr_complete_bottom_side_category::Category + Bottom_side_category; + typedef typename internal::Arr_complete_top_side_category::Category + Top_side_category; + typedef typename internal::Arr_complete_right_side_category::Category + Right_side_category; /* Overlay is implemented as sweep-line visitor. The sweep-line algorithm * never uses Compare_y_at_x_left_2, and it never performs merging of curves. @@ -101,7 +101,7 @@ public: */ typedef Tag_false Has_left_category; typedef Tag_false Has_merge_category; - + // The color of a feature. enum Color { RED, // From the "red" arrangement. @@ -116,7 +116,7 @@ public: typedef boost::variant Cell_handle_blue; typedef boost::optional Optional_cell_blue; - + template Optional_cell_red make_optional_cell_red(Handle_red handle_red) { return boost::make_optional(Cell_handle_red(handle_red)); } @@ -124,34 +124,34 @@ public: template Optional_cell_red make_optional_cell_blue(Handle_blue handle_blue) { return boost::make_optional(Cell_handle_blue(handle_blue)); } - + private: - const Traits_2* m_base_traits; // The base traits object. + const Gt2* m_base_traits; // The base traits object. public: /*! Default constructor. */ Arr_overlay_traits_2() {} /*! Constructor from a base traits class. */ - Arr_overlay_traits_2(const Traits_2& base_tr) : m_base_traits(&base_tr) {} + Arr_overlay_traits_2(const Gt2& base_tr) : m_base_traits(&base_tr) {} - const Traits_2* base_traits() const { return m_base_traits; } + const Gt2* base_traits() const { return m_base_traits; } /*! \class * Nested extension of the x-monotone curve type. */ class Ex_x_monotone_curve_2 { public: - typedef Base_x_monotone_curve_2 Base; + typedef Base_x_monotone_curve_2 Base; protected: - Base m_base_xcv; // The base curve. - Halfedge_handle_red m_red_halfedge_handle; // The red halfedge. - Halfedge_handle_blue m_blue_halfedge_handle; // The blue halfedge. + Base m_base_xcv; // The base curve. + Halfedge_handle_red m_red_halfedge_handle; // The red halfedge. + Halfedge_handle_blue m_blue_halfedge_handle; // The blue halfedge. public: /*! Default constructor. */ - Ex_x_monotone_curve_2() : + Ex_x_monotone_curve_2() : m_base_xcv(), m_red_halfedge_handle(), m_blue_halfedge_handle() @@ -193,7 +193,7 @@ public: /*! Get the red halfedge handle. */ Halfedge_handle_red red_halfedge_handle() const { return m_red_halfedge_handle; } - + /*! Get the blue halfedge handle. */ Halfedge_handle_blue blue_halfedge_handle() const { return m_blue_halfedge_handle; } @@ -219,8 +219,8 @@ public: /*! Get the color of the subcurve. */ Color color() const { - Halfedge_handle_red null_red_he; - Halfedge_handle_blue null_blue_he; + Halfedge_handle_red null_red_he; + Halfedge_handle_blue null_blue_he; if ((m_red_halfedge_handle != null_red_he) && (m_blue_halfedge_handle == null_blue_he)) @@ -229,14 +229,14 @@ public: if ((m_blue_halfedge_handle != null_blue_he) && (m_red_halfedge_handle == null_red_he)) return BLUE; - + // Overlap, return the RB_OVERLAP color: - CGAL_assertion((m_red_halfedge_handle != null_red_he) && + CGAL_assertion((m_red_halfedge_handle != null_red_he) && (m_blue_halfedge_handle != null_blue_he)); return RB_OVERLAP; } }; // nested class Ex_x_monotone_curve_2 - END - + typedef Ex_x_monotone_curve_2 X_monotone_curve_2; // For debugging purposes: @@ -246,13 +246,13 @@ public: os << xcv.base(); return os; } - + /*! \class * Nested extension of the point type. */ class Ex_point_2 { public: - typedef Base_point_2 Base; + typedef Base_point_2 Base; protected: Base m_base_pt; // The base point. @@ -321,7 +321,7 @@ public: /*! Obtain the blue cell handle or NULL if it doesn't exist. */ const Cell_handle_blue* blue_cell_handle() const { return m_blue_cell ? &(*m_blue_cell) : NULL; } - + /*! Obtain the red vertex handle or NULL if it doesn't exist. */ const Vertex_handle_red* red_vertex_handle() const { @@ -361,9 +361,8 @@ public: Intersect_2(const Arr_overlay_traits_2* traits) : m_traits(traits) {} //! Allow its functor obtaining function calling the protected constructor. - friend class Arr_overlay_traits_2; - + friend class Arr_overlay_traits_2; + public: template OutputIterator operator()(const X_monotone_curve_2& xcv1, @@ -373,7 +372,7 @@ public: // In case the curves originate from the same arrangement, they are // obviously interior-disjoint. if (xcv1.color() == xcv2.color()) return oi; - + if ((xcv1.color() == RB_OVERLAP) || (xcv2.color() == RB_OVERLAP)) return oi; @@ -415,7 +414,7 @@ public: const Arr_parameter_space bx2 = ps_x_op(xcv2, ARR_MIN_END); const Arr_parameter_space by2 = ps_y_op(xcv2, ARR_MIN_END); - const Traits_2* m_base_tr = m_traits->base_traits(); + const Gt2* m_base_tr = m_traits->base_traits(); if ((bx1 == ARR_INTERIOR) && (by1 == ARR_INTERIOR) && (bx2 == ARR_INTERIOR) && (by2 == ARR_INTERIOR)) @@ -431,7 +430,7 @@ public: m_base_tr->intersect_2_object()(xcv2.base(), xcv1.base(), oi); // Convert objects that are associated with Base_x_monotone_curve_2 to - // the exteneded X_monotone_curve_2. + // the exteneded X_monotone_curve_2. while (oi != oi_end) { base_ipt = object_cast >(&(*oi)); @@ -467,10 +466,10 @@ public: // We have a red-blue overlap, so we mark the curve accordingly. Halfedge_handle_red red_he; Halfedge_handle_blue blue_he; - + if (xcv1.color() == RED) { red_he = xcv1.red_halfedge_handle(); - + // Overlap can occur only between curves from a different color. CGAL_assertion(xcv2.color() == BLUE); blue_he = xcv2.blue_halfedge_handle(); @@ -481,7 +480,7 @@ public: red_he = xcv2.red_halfedge_handle(); blue_he = xcv1.blue_halfedge_handle(); } - + *oi++ = CGAL::make_object(X_monotone_curve_2(*overlap_xcv, red_he, blue_he)); } @@ -509,9 +508,8 @@ public: Split_2(const Base_split_2& base) : m_base_split(base) {} //! Allow its functor obtaining function calling the protected constructor. - friend class Arr_overlay_traits_2; - + friend class Arr_overlay_traits_2; + public: void operator()(const X_monotone_curve_2& xcv, const Point_2& p, X_monotone_curve_2& c1, X_monotone_curve_2& c2) @@ -551,11 +549,10 @@ public: {} //! Allow its functor obtaining function calling the protected constructor. - friend class Arr_overlay_traits_2; - + friend class Arr_overlay_traits_2; + public: - Point_2 operator()(const X_monotone_curve_2& xcv) + Point_2 operator()(const X_monotone_curve_2& xcv) { // Create the objects that wrap the arrangement vertex. // Note that the halfedges associated with the curves are always @@ -585,11 +582,11 @@ public: /*! Obtain a Construct_min_vertex_2 functor object. */ Construct_min_vertex_2 construct_min_vertex_2_object() const { - return + return Construct_min_vertex_2(m_base_traits->construct_min_vertex_2_object(), m_base_traits->equal_2_object()); } - + /*! A functor that obtains the right endpoint of an x-monotone curve. */ class Construct_max_vertex_2 { protected: @@ -609,9 +606,8 @@ public: {} //! Allow its functor obtaining function calling the protected constructor. - friend class Arr_overlay_traits_2; - + friend class Arr_overlay_traits_2; + public: Point_2 operator()(const X_monotone_curve_2& xcv) const { @@ -623,14 +619,14 @@ public: Optional_cell_blue blue_cell; if ((xcv.color() == RED) || (xcv.color() == RB_OVERLAP)) - red_cell = + red_cell = (! xcv.red_halfedge_handle()->source()->is_at_open_boundary() && m_base_equal(base_p, xcv.red_halfedge_handle()->source()->point())) ? boost::make_optional(Cell_handle_red(xcv.red_halfedge_handle()->source())) : boost::make_optional(Cell_handle_red(xcv.red_halfedge_handle())); - + if ((xcv.color() == BLUE) || (xcv.color() == RB_OVERLAP)) - blue_cell = + blue_cell = (! xcv.blue_halfedge_handle()->source()->is_at_open_boundary() && m_base_equal(base_p, xcv.blue_halfedge_handle()->source()->point())) ? boost::make_optional(Cell_handle_blue(xcv.blue_halfedge_handle()->source())) : @@ -662,9 +658,8 @@ public: Is_vertical_2(const Base_is_vertical_2& base) : m_base_is_vert(base) {} //! Allow its functor obtaining function calling the protected constructor. - friend class Arr_overlay_traits_2; - + friend class Arr_overlay_traits_2; + public: bool operator()(const X_monotone_curve_2& xcv) const { return m_base_is_vert(xcv.base()); } @@ -690,9 +685,8 @@ public: Equal_2(const Base_equal_2& base) : m_base_equal(base) {} //! Allow its functor obtaining function calling the protected constructor. - friend class Arr_overlay_traits_2; - + friend class Arr_overlay_traits_2; + public: bool operator()(const Point_2& p1, const Point_2& p2) const { return m_base_equal(p1.base(), p2.base()); } @@ -705,7 +699,7 @@ public: /*! Obtain a Equal_2 functor object. */ Equal_2 equal_2_object() const { return Equal_2(m_base_traits->equal_2_object()); } - + /*! A functor that compares the x-coordinates of two points */ class Compare_x_2 { protected: @@ -720,9 +714,8 @@ public: Compare_x_2(const Base_compare_x_2& base) : m_base_cmp_x(base) {} //! Allow its functor obtaining function calling the protected constructor. - friend class Arr_overlay_traits_2; - + friend class Arr_overlay_traits_2; + public: Comparison_result operator()(const Point_2& p1, const Point_2& p2) const { return m_base_cmp_x(p1.base(), p2.base()); } @@ -746,9 +739,8 @@ public: Compare_xy_2(const Base_compare_xy_2& base) : m_base_cmp_xy(base) {} //! Allow its functor obtaining function calling the protected constructor. - friend class Arr_overlay_traits_2; - + friend class Arr_overlay_traits_2; + public: Comparison_result operator()(const Point_2& p1, const Point_2& p2) const { @@ -766,7 +758,7 @@ public: // - the points are not equal if the corresponding handles are not equal. // - if the corresponding handles are equal, the points must be equal // but this holds for any two points. - + if ((vr1 && vb1) || (vr2 && vb2)) // In case of an overlapping vertex, just perform the comparison. return (m_base_cmp_xy(p1.base(), p2.base())); @@ -802,9 +794,8 @@ public: {} //! Allow its functor obtaining function calling the protected constructor. - friend class Arr_overlay_traits_2; - + friend class Arr_overlay_traits_2; + public: Comparison_result operator()(const Point_2& p, const X_monotone_curve_2& xcv) const @@ -833,9 +824,8 @@ public: {} //! Allow its functor obtaining function calling the protected constructor. - friend class Arr_overlay_traits_2; - + friend class Arr_overlay_traits_2; + public: Comparison_result operator()(const X_monotone_curve_2& xcv1, const X_monotone_curve_2& xcv2, @@ -846,7 +836,7 @@ public: /*! Obtain a Construct_min_vertex_2 functor object. */ Compare_y_at_x_right_2 compare_y_at_x_right_2_object() const { - return + return Compare_y_at_x_right_2(m_base_traits->compare_y_at_x_right_2_object()); } @@ -858,19 +848,18 @@ public: class Parameter_space_in_x_2 { protected: //! The base traits. - const Traits_2* m_base; + const Gt2* m_base; /*! Constructor. * The constructor is declared protected to allow only the functor * obtaining function, which is a member of the nesting class, * constructing it. */ - Parameter_space_in_x_2(const Traits_2* tr) : m_base(tr) {} - + Parameter_space_in_x_2(const Gt2* tr) : m_base(tr) {} + //! Allow its functor obtaining function calling the protected constructor. - friend class Arr_overlay_traits_2; - + friend class Arr_overlay_traits_2; + public: Arr_parameter_space operator()(const X_monotone_curve_2& xcv, Arr_curve_end ce) const @@ -885,27 +874,26 @@ public: /*! Obtain an Parameter_space_in_x_2 functor object. */ Parameter_space_in_x_2 parameter_space_in_x_2_object() const - { return Parameter_space_in_x_2(m_base_traits); } - + { return Parameter_space_in_x_2(m_base_traits); } + /*! A function object that determines whether an x-monotone curve or a * point coincide with the vertical identification curve. */ class Is_on_x_identification_2 { protected: //! The base traits. - const Traits_2* m_base; + const Gt2* m_base; /*! Constructor. * The constructor is declared protected to allow only the functor * obtaining function, which is a member of the nesting class, * constructing it. */ - Is_on_x_identification_2(const Traits_2* tr) : m_base(tr) {} - + Is_on_x_identification_2(const Gt2* tr) : m_base(tr) {} + //! Allow its functor obtaining function calling the protected constructor. - friend class Arr_overlay_traits_2; - + friend class Arr_overlay_traits_2; + public: Arr_parameter_space operator()(const Point_2& p) const { return m_base->is_on_x_identification_2_object()(p.base()); } @@ -916,7 +904,7 @@ public: /*! Obtain an Is_on_x_identification_2 functor object. */ Is_on_x_identification_2 is_on_x_identification_2_object() const - { return Is_on_x_identification_2(m_base_traits); } + { return Is_on_x_identification_2(m_base_traits); } /*! A functor that compares the y-values of pointss on the * boundary of the parameter space. @@ -924,7 +912,7 @@ public: class Compare_y_on_boundary_2 { protected: //! The base traits. - const Traits_2* m_base; + const Gt2* m_base; /*! Constructor. * \param base The base traits class. It must be passed, to handle the @@ -933,17 +921,16 @@ public: * obtaining function, which is a member of the nesting class, * constructing it. */ - Compare_y_on_boundary_2(const Traits_2* base) : m_base(base) {} + Compare_y_on_boundary_2(const Gt2* base) : m_base(base) {} //! Allow its functor obtaining function calling the protected constructor. - friend class Arr_overlay_traits_2; - + friend class Arr_overlay_traits_2; + public: Comparison_result operator()(const Point_2& pt1, const Point_2& pt2) const { return m_base->compare_y_on_boundary_2_object()(pt1.base(), pt2.base()); } }; - + /*! Obtain a Compare_y_on_boundary_2 functor. */ Compare_y_on_boundary_2 compare_y_on_boundary_2_object() const { return Compare_y_on_boundary_2(m_base_traits); } @@ -954,7 +941,7 @@ public: class Compare_y_near_boundary_2 { protected: //! The base traits. - const Traits_2* m_base; + const Gt2* m_base; /*! Constructor. * \param base The base traits class. It must be passed, to handle the @@ -963,15 +950,14 @@ public: * obtaining function, which is a member of the nesting class, * constructing it. */ - Compare_y_near_boundary_2(const Traits_2* base) : m_base(base) {} + Compare_y_near_boundary_2(const Gt2* base) : m_base(base) {} //! Allow its functor obtaining function calling the protected constructor. - friend class Arr_overlay_traits_2; - + friend class Arr_overlay_traits_2; + public: Comparison_result operator()(const X_monotone_curve_2& xcv1, - const X_monotone_curve_2& xcv2, + const X_monotone_curve_2& xcv2, Arr_curve_end ce) const { // If the traits class does not support open curves, we just @@ -980,33 +966,32 @@ public: xcv2.base(), ce); } }; - + /*! Obtain a Compare_y_near_boundary_2 functor. */ Compare_y_near_boundary_2 compare_y_near_boundary_2_object() const { return Compare_y_near_boundary_2(m_base_traits); } - + // bottom-top - + /*! A functor that determines whether an endpoint of an x-monotone arc lies * on a boundary of the parameter space along the y axis. */ class Parameter_space_in_y_2 { protected: //! The base traits. - const Traits_2* m_base; + const Gt2* m_base; /*! Constructor. * The constructor is declared protected to allow only the functor * obtaining function, which is a member of the nesting class, * constructing it. */ - Parameter_space_in_y_2(const Traits_2* tr) : m_base(tr) {} - + Parameter_space_in_y_2(const Gt2* tr) : m_base(tr) {} + //! Allow its functor obtaining function calling the protected constructor. - friend class Arr_overlay_traits_2; - + friend class Arr_overlay_traits_2; + public: Arr_parameter_space operator()(const X_monotone_curve_2& xcv, Arr_curve_end ce) const @@ -1021,7 +1006,7 @@ public: /*! Obtain an Parameter_space_in_y_2 functor object. */ Parameter_space_in_y_2 parameter_space_in_y_2_object() const - { return Parameter_space_in_y_2(m_base_traits); } + { return Parameter_space_in_y_2(m_base_traits); } /*! A function object that determines whether an x-monotone curve or a * point coincide with the vertical identification curve. @@ -1029,19 +1014,18 @@ public: class Is_on_y_identification_2 { protected: //! The base traits. - const Traits_2* m_base; + const Gt2* m_base; /*! Constructor. * The constructor is declared protected to allow only the functor * obtaining function, which is a member of the nesting class, * constructing it. */ - Is_on_y_identification_2(const Traits_2* tr) : m_base(tr) {} - + Is_on_y_identification_2(const Gt2* tr) : m_base(tr) {} + //! Allow its functor obtaining function calling the protected constructor. - friend class Arr_overlay_traits_2; - + friend class Arr_overlay_traits_2; + public: Arr_parameter_space operator()(const Point_2& p) const { return m_base->is_on_y_identification_2_object()(p.base()); } @@ -1052,7 +1036,7 @@ public: /*! Obtain an Is_on_y_identification_2 functor object. */ Is_on_y_identification_2 is_on_y_identification_2_object() const - { return Is_on_y_identification_2(m_base_traits); } + { return Is_on_y_identification_2(m_base_traits); } /*! A functor that compares the x-limits of curve ends on the * boundary of the parameter space. @@ -1060,7 +1044,7 @@ public: class Compare_x_at_limit_2 { protected: //! The base traits. - const Traits_2* m_base; + const Gt2* m_base; /*! Constructor. * \param base The base traits class. It must be passed, to handle the @@ -1069,12 +1053,11 @@ public: * obtaining function, which is a member of the nesting class, * constructing it. */ - Compare_x_at_limit_2(const Traits_2* base) : m_base(base) {} + Compare_x_at_limit_2(const Gt2* base) : m_base(base) {} //! Allow its functor obtaining function calling the protected constructor. - friend class Arr_overlay_traits_2; - + friend class Arr_overlay_traits_2; + public: Comparison_result operator()(const Point_2& p, const X_monotone_curve_2& xcv, @@ -1101,7 +1084,7 @@ public: class Compare_x_near_limit_2 { protected: //! The base traits. - const Traits_2* m_base; + const Gt2* m_base; /*! Constructor. * \param base The base traits class. It must be passed, to handle the @@ -1110,12 +1093,11 @@ public: * obtaining function, which is a member of the nesting class, * constructing it. */ - Compare_x_near_limit_2(const Traits_2* base) : m_base(base) {} + Compare_x_near_limit_2(const Gt2* base) : m_base(base) {} //! Allow its functor obtaining function calling the protected constructor. - friend class Arr_overlay_traits_2; - + friend class Arr_overlay_traits_2; + public: Comparison_result operator()(const X_monotone_curve_2& xcv1, const X_monotone_curve_2& xcv2, @@ -1136,7 +1118,7 @@ public: class Compare_x_on_boundary_2 { protected: //! The base traits. - const Traits_2* m_base; + const Gt2* m_base; /*! Constructor. * \param base The base traits class. It must be passed, to handle the @@ -1145,12 +1127,11 @@ public: * obtaining function, which is a member of the nesting class, * constructing it. */ - Compare_x_on_boundary_2(const Traits_2* base) : m_base(base) {} + Compare_x_on_boundary_2(const Gt2* base) : m_base(base) {} //! Allow its functor obtaining function calling the protected constructor. - friend class Arr_overlay_traits_2; - + friend class Arr_overlay_traits_2; + public: Comparison_result operator()(const Point_2& pt1, const Point_2& pt2) const { return m_base->compare_x_on_boundary_2_object()(pt1.base(), pt2.base()); } @@ -1172,7 +1153,7 @@ public: xcv2.base(), ce2); } }; - + /*! Obtain a Compare_x_on_boundary_2 functor. */ Compare_x_on_boundary_2 compare_x_on_boundary_2_object() const { return Compare_x_on_boundary_2(m_base_traits); } @@ -1183,7 +1164,7 @@ public: class Compare_x_near_boundary_2 { protected: //! The base traits. - const Traits_2* m_base; + const Gt2* m_base; /*! Constructor. * \param base The base traits class. It must be passed, to handle the @@ -1192,18 +1173,18 @@ public: * obtaining function, which is a member of the nesting class, * constructing it. */ - Compare_x_near_boundary_2(const Traits_2* base) : m_base(base) {} + Compare_x_near_boundary_2(const Gt2* base) : m_base(base) {} //! Allow its functor obtaining function calling the protected constructor. - friend class Arr_overlay_traits_2; - + friend class Arr_overlay_traits_2; + public: Comparison_result operator()(const X_monotone_curve_2& xcv1, const X_monotone_curve_2& xcv2, Arr_curve_end ce) const { - return m_base->compare_x_near_boundary_2_object()(xcv1.base(), xcv2.base(), + return m_base->compare_x_near_boundary_2_object()(xcv1.base(), + xcv2.base(), ce); } }; @@ -1213,6 +1194,6 @@ public: { return Compare_x_near_boundary_2(m_base_traits); } }; -} //namespace CGAL +} // namespace CGAL #endif diff --git a/Sweep_line_2/include/CGAL/Sweep_line_2/Arr_vert_decomp_sl_visitor.h b/Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_vert_decomp_ss_visitor.h similarity index 61% rename from Sweep_line_2/include/CGAL/Sweep_line_2/Arr_vert_decomp_sl_visitor.h rename to Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_vert_decomp_ss_visitor.h index e47bfc1222b..1ee7df61589 100644 --- a/Sweep_line_2/include/CGAL/Sweep_line_2/Arr_vert_decomp_sl_visitor.h +++ b/Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_vert_decomp_ss_visitor.h @@ -18,102 +18,115 @@ // // // Author(s) : Ron Wein +// Efi Fogel -#ifndef CGAL_ARR_VERT_DECOMP_SL_VISITOR_H -#define CGAL_ARR_VERT_DECOMP_SL_VISITOR_H +#ifndef CGAL_ARR_VERT_DECOMP_SS_VISITOR_H +#define CGAL_ARR_VERT_DECOMP_SS_VISITOR_H -#include +#include - -/*! - * Definition of the Arr_vert_decomp_sl_visitor class-template. +/*! \file + * + * Definition of the Arr_vert_decomp_ss_visitor class-template. */ namespace CGAL { +#include #include +#include -/*! \class Arr_vert_decomp_sl_visitor +/*! \class Arr_vert_decomp_ss_visitor + * * A sweep-line visitor for performing vertical decomposition on an * arrangement embedded on a surface. */ -template -class Arr_vert_decomp_sl_visitor : - public Helper_::Base_visitor +template +class Arr_vert_decomp_ss_visitor : + public Ss2::Default_visitor_base >::type> { public: - typedef Helper_ Helper; - typedef OutputIterator_ OutputIterator; + typedef OutputIterator Output_iterator; - typedef typename Helper::Traits_2 Traits_2; - typedef typename Helper::Arrangement_2 Arrangement_2; - typedef typename Helper::Base_visitor Base; + typedef typename Helper::Geometry_traits_2 Geometry_traits_2; typedef typename Helper::Event Event; typedef typename Helper::Subcurve Subcurve; + typedef typename Helper::Allocator Allocator; +private: + typedef Geometry_traits_2 Gt2; + typedef Arr_vert_decomp_ss_visitor + Self; + typedef typename Default::Get::type Visitor; + typedef typename Ss2::Default_visitor_base Base; +public: + typedef typename Helper::Arrangement_2 Arrangement_2; typedef typename Arrangement_2::Vertex_const_handle Vertex_const_handle; typedef std::pair Vert_pair; typedef std::pair Vert_entry; protected: - typedef typename Base::Status_line_iterator Status_line_iterator; typedef typename Arrangement_2::Halfedge_const_handle Halfedge_const_handle; //typedef typename Arrangement_2::Vertex_const_handle Vertex_const_handle; typedef typename Arrangement_2::Halfedge_around_vertex_const_circulator - Halfedge_around_vertex_const_circulator; + Halfedge_around_vertex_const_circulator; // Data members: - Helper m_helper; // The helper class. + Helper m_helper; // The helper class. - const typename Arrangement_2::Geometry_traits_2 *m_traits; - // The traits class. + const typename Arrangement_2::Geometry_traits_2* m_traits; + // The traits class. - const Vertex_const_handle invalid_vh; - // An invalid vertex handle. + const Vertex_const_handle invalid_vh; + // An invalid vertex handle. - Vertex_const_handle m_prev_vh; // The previous vertex. - CGAL::Object m_prev_obj_below; // The object this vertex sees below it. - CGAL::Object m_prev_obj_above; // The object this vertex sees above it. + Vertex_const_handle m_prev_vh; // The previous vertex. + CGAL::Object m_prev_obj_below; // The object this vertex sees below it. + CGAL::Object m_prev_obj_above; // The object this vertex sees above it. - OutputIterator *m_out; // An output iterator for the result. + Output_iterator* m_out; // An output iterator for the result. public: - - /*! - * Constructor. + /*! Constructor. * \param arr The arrangement. * \param oi A pointer to the output iterator that will store the result. */ - Arr_vert_decomp_sl_visitor (const Arrangement_2 *arr, - OutputIterator *oi) : - m_helper (arr), - m_traits (arr->geometry_traits()), + Arr_vert_decomp_ss_visitor(const Arrangement_2* arr, OutputIterator* oi) : + m_helper(arr), + m_traits(arr->geometry_traits()), invalid_vh(), - m_out (oi) + m_out(oi) {} /* A notification issued before the sweep process starts. */ - void before_sweep (); + void before_sweep(); - /*! - * A notification invoked after the sweep-line finishes handling the given + /*! A notification invoked after the sweep-line finishes handling the given * event. * \param event The event. * \param above An iterator to the sweep-line subcurves lying right above * (or on) the event point. * \param on_above Whether the event is locates on the subcurve above it. */ - bool after_handle_event (Event* event, - Status_line_iterator above, - bool on_above); + bool after_handle_event(Event* event, + Status_line_iterator above, + bool on_above); - /*! - * A notification issued when the sweep process is over. + /*! A notification issued when the sweep process is over. */ - void after_sweep (); + void after_sweep(); }; //----------------------------------------------------------------------------- @@ -123,48 +136,43 @@ public: //----------------------------------------------------------------------------- // A notification issued before the sweep process starts. // -template -void Arr_vert_decomp_sl_visitor::before_sweep () +template +void Arr_vert_decomp_ss_visitor::before_sweep() { // Notify the helper that the sweep process now starts. m_helper.before_sweep(); // Set an invalid previous vertex. m_prev_vh = Vertex_const_handle(); - - return; } //----------------------------------------------------------------------------- // A notification invoked after the sweep-line finishes handling the given // event. // -template -bool Arr_vert_decomp_sl_visitor::after_handle_event - (Event* event, - Status_line_iterator above, bool /* on_above */) +template +bool Arr_vert_decomp_ss_visitor:: +after_handle_event(Event* event, + Status_line_iterator above, bool /* on_above */) { // Notify the helper on the event. - m_helper.after_handle_event (event); + m_helper.after_handle_event(event); // We are only interested in events associated with valid points: - if (! event->is_closed()) - return (true); + if (! event->is_closed()) return true; // Get the vertex handle associated with the current event (stored with // the point). - Vertex_const_handle vh = event->point().vertex_handle(); - CGAL::Object obj_above, obj_below; + Vertex_const_handle vh = event->point().vertex_handle(); + CGAL::Object obj_above, obj_below; // Check the feature from above. - if (above == this->status_line_end()) - { + if (above == this->status_line_end()) { // There is no concrete subcurve above the current event point, so we use // the helper class to obtain the object above. obj_above = m_helper.top_object(); } - else - { + else { // We have a valid subcurve above the event: get its halfedge handle // and associate it with the vertex. obj_above = @@ -173,10 +181,10 @@ bool Arr_vert_decomp_sl_visitor::after_handle_event // Check if the previous vertex we handled has the same x-coordinate // as the current one (it lies vertically below the current vertex). - const bool prev_same_x = + const bool prev_same_x = (m_prev_vh != invalid_vh && - m_traits->compare_x_2_object() (vh->point(), - m_prev_vh->point()) == EQUAL); + m_traits->compare_x_2_object()(vh->point(), + m_prev_vh->point()) == EQUAL); // Decrement the status-line iterator to reach the subcurve below the // event point. If the number of right subcurves associated with the @@ -186,52 +194,42 @@ bool Arr_vert_decomp_sl_visitor::after_handle_event const size_t n_right = event->number_of_right_curves(); size_t k; - for (k = 0; k < n_right; k++) - --below; + for (k = 0; k < n_right; k++) --below; - if (below == this->status_line_begin()) - { - if (prev_same_x) - { + if (below == this->status_line_begin()) { + if (prev_same_x) { // The previous vertex is vertically below the current vertex, // so we update their respective entries in the output map. // We first check if the two vertices are connected (by a vertical // segment) - if so, they "see" empty features. - bool vert_connected = false; + bool vert_connected = false; - if (! vh->is_isolated()) - { - Halfedge_around_vertex_const_circulator circ, first; + if (! vh->is_isolated()) { + Halfedge_around_vertex_const_circulator circ, first; first = circ = vh->incident_halfedges(); - do - { - if (circ->source() == m_prev_vh) - vert_connected = true; + do { + if (circ->source() == m_prev_vh) vert_connected = true; ++circ; } while (! vert_connected && circ != first); } - if (! vert_connected) - { + if (! vert_connected) { obj_below = CGAL::make_object(m_prev_vh); m_prev_obj_above = CGAL::make_object(vh); } - else - { + else { obj_below = CGAL::Object(); m_prev_obj_above = CGAL::Object(); } } - else - { + else { // There is no concrete subcurve below the current event point, so we // use the helper class to obtain the object below. obj_below = m_helper.bottom_object(); } } - else - { + else { // Decrement the iterator once more in order to reach the subcurve below // the current event. --below; @@ -257,34 +255,29 @@ bool Arr_vert_decomp_sl_visitor::after_handle_event // the respective entries in the output map accordingly. // We first check if the two vertices are connected (by a vertical // segment) - if so, they "see" empty features. - bool vert_connected = false; + bool vert_connected = false; - if (! vh->is_isolated()) - { - Halfedge_around_vertex_const_circulator circ, first; + if (! vh->is_isolated()) { + Halfedge_around_vertex_const_circulator circ, first; first = circ = vh->incident_halfedges(); - do - { + do { if (circ->source() == m_prev_vh) vert_connected = true; ++circ; } while (! vert_connected && circ != first); } - if (! vert_connected) - { + if (! vert_connected) { obj_below = CGAL::make_object(m_prev_vh); m_prev_obj_above = CGAL::make_object(vh); } - else - { + else { obj_below = CGAL::Object(); m_prev_obj_above = CGAL::Object(); } } - else - { + else { // Get the halfedge handle of the subcurve below the current event and // associate it with its vertex. obj_below = @@ -294,10 +287,9 @@ bool Arr_vert_decomp_sl_visitor::after_handle_event // We can now create the entry for the previous vertex, as we are not // going to change the identity of the features below or above it. - if (m_prev_vh != Vertex_const_handle()) - { - *(*m_out) = Vert_entry (m_prev_vh, Vert_pair (m_prev_obj_below, - m_prev_obj_above)); + if (m_prev_vh != Vertex_const_handle()) { + *(*m_out) = Vert_entry(m_prev_vh, Vert_pair(m_prev_obj_below, + m_prev_obj_above)); ++(*m_out); } @@ -308,26 +300,23 @@ bool Arr_vert_decomp_sl_visitor::after_handle_event m_prev_obj_above = obj_above; // It is safe to deallocate the event. - return (true); + return true; } //----------------------------------------------------------------------------- // A notification issued when the sweep process is over. // -template -void Arr_vert_decomp_sl_visitor::after_sweep () +template +void Arr_vert_decomp_ss_visitor::after_sweep() { // Create an entry for the last vertex (the xy-largest one). - if (m_prev_vh != invalid_vh) - { - *(*m_out) = Vert_entry (m_prev_vh, Vert_pair (m_prev_obj_below, - m_prev_obj_above)); + if (m_prev_vh != invalid_vh) { + *(*m_out) = Vert_entry(m_prev_vh, Vert_pair(m_prev_obj_below, + m_prev_obj_above)); ++(*m_out); } - - return; } -} //namespace CGAL +} // namespace CGAL #endif diff --git a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/cgal_test_base b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/cgal_test_base index 65b8e559807..d98a584c016 100755 --- a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/cgal_test_base +++ b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/cgal_test_base @@ -1695,7 +1695,7 @@ compile_and_run test_iso_verts compile_and_run test_vert_ray_shoot_vert_segments test_construction_segments -test_construction_linear +test_construction_linear_curves test_construction_spherical_arcs test_overlay_segments diff --git a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/test_rational_function_traits_2.cpp b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/test_rational_function_traits_2.cpp index c0f74174fb4..45e19e2b1f1 100644 --- a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/test_rational_function_traits_2.cpp +++ b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/test_rational_function_traits_2.cpp @@ -18,7 +18,7 @@ int main() #include //Algebraic Kernel #include //Traits #include //Arrangement -#include +#include #include typedef CGAL::CORE_arithmetic_kernel::Integer Number_type; diff --git a/Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Gps_agg_meta_traits.h b/Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Gps_agg_meta_traits.h index dd3f1afba8a..c14ad00b0c8 100644 --- a/Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Gps_agg_meta_traits.h +++ b/Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Gps_agg_meta_traits.h @@ -15,16 +15,15 @@ // $URL$ // $Id$ // SPDX-License-Identifier: GPL-3.0+ -// +// // // Author(s) : Baruch Zukerman -#ifndef CGAL_GPS_AGG_META_TRAITS_H -#define CGAL_GPS_AGG_META_TRAITS_H +#ifndef CGAL_BSO_2_GPS_AGG_META_TRAITS_H +#define CGAL_BSO_2_GPS_AGG_META_TRAITS_H #include - #include #include #include @@ -33,7 +32,7 @@ namespace CGAL { -template +template class Gps_agg_curve_data : public Curve_with_halfedge { protected: @@ -41,15 +40,14 @@ protected: typedef typename Arrangement::Halfedge_handle Halfedge_handle; typedef Curve_with_halfedge Base; - const Arrangement* m_arr; // pointer to the arrangement containing the edge. - unsigned int m_bc; // the boudary counter of the halfedge with the same - //direction as the curve + const Arrangement* m_arr; // pointer to the arrangement containing the edge. + unsigned int m_bc; // the boudary counter of the halfedge with the same + // direction as the curve - unsigned int m_twin_bc; // the boudary counter of the halfedge with the same - //direction as the curve + unsigned int m_twin_bc; // the boudary counter of the halfedge with the same + // direction as the curve public: - Gps_agg_curve_data() : Base(), m_arr(NULL), @@ -57,176 +55,134 @@ public: m_twin_bc(0) {} - Gps_agg_curve_data(const Arrangement* arr, - Halfedge_handle he, - unsigned int bc, - unsigned int twin_bc): + Gps_agg_curve_data(const Arrangement* arr, Halfedge_handle he, + unsigned int bc, unsigned int twin_bc) : Base(he), m_arr(arr), m_bc(bc), m_twin_bc(twin_bc) {} - unsigned int bc() const - { - return m_bc; - } + unsigned int bc() const { return m_bc; } - unsigned int twin_bc() const - { - return m_twin_bc; - } + unsigned int twin_bc() const { return m_twin_bc; } - unsigned int& bc() - { - return m_bc; - } + unsigned int& bc() { return m_bc; } - unsigned int& twin_bc() - { - return m_twin_bc; - } + unsigned int& twin_bc() { return m_twin_bc; } - void set_bc(unsigned int bc) - { - m_bc = bc; - } + void set_bc(unsigned int bc) { m_bc = bc; } - void set_twin_bc(unsigned int twin_bc) - { - m_twin_bc = twin_bc; - } - - const Arrangement* arr() const - { - return m_arr; - } + void set_twin_bc(unsigned int twin_bc) { m_twin_bc = twin_bc; } + const Arrangement* arr() const { return m_arr; } }; - -template +template class Gps_agg_meta_traits : public Gps_traits_decorator, Point_with_vertex > { - typedef Arrangement_ Arrangement; - typedef typename Arrangement::Traits_adaptor_2 Traits; + typedef Arrangement_ Arrangement; + typedef Arrangement Arr; - typedef typename Traits::X_monotone_curve_2 Base_X_monotone_curve_2; - typedef typename Traits::Point_2 Base_Point_2; - typedef typename Traits::Construct_min_vertex_2 Base_Construct_min_vertex_2; - typedef typename Traits::Construct_max_vertex_2 Base_Construct_max_vertex_2; - typedef typename Traits::Compare_endpoints_xy_2 Base_Compare_endpoints_xy_2; - typedef typename Traits::Compare_xy_2 Base_Compare_xy_2; - typedef typename Traits::Compare_y_at_x_right_2 Base_Compare_y_at_x_right_2; - typedef typename Traits::Compare_y_at_x_2 Base_Compare_y_at_x_2; - typedef typename Traits::Intersect_2 Base_Intersect_2; - typedef typename Traits::Split_2 Base_Split_2; + typedef typename Arr::Traits_adaptor_2 Traits; + typedef Traits Gt2; - typedef typename Traits::Parameter_space_in_x_2 Base_Parameter_space_in_x_2; - typedef typename Traits::Compare_y_near_boundary_2 - Base_Compare_y_near_boundary_2; + typedef typename Gt2::X_monotone_curve_2 Base_X_monotone_curve_2; + typedef typename Gt2::Point_2 Base_Point_2; + typedef typename Gt2::Construct_min_vertex_2 Base_Construct_min_vertex_2; + typedef typename Gt2::Construct_max_vertex_2 Base_Construct_max_vertex_2; + typedef typename Gt2::Compare_endpoints_xy_2 Base_Compare_endpoints_xy_2; + typedef typename Gt2::Compare_xy_2 Base_Compare_xy_2; + typedef typename Gt2::Compare_y_at_x_right_2 Base_Compare_y_at_x_right_2; + typedef typename Gt2::Compare_y_at_x_2 Base_Compare_y_at_x_2; + typedef typename Gt2::Intersect_2 Base_Intersect_2; + typedef typename Gt2::Split_2 Base_Split_2; - typedef typename Traits::Parameter_space_in_y_2 Base_Parameter_space_in_y_2; - typedef typename Traits::Compare_x_near_boundary_2 - Base_Compare_x_near_boundary_2; + typedef typename Gt2::Parameter_space_in_x_2 Base_Parameter_space_in_x_2; + typedef typename Gt2::Compare_y_near_boundary_2 + Base_Compare_y_near_boundary_2; + typedef typename Gt2::Parameter_space_in_y_2 Base_Parameter_space_in_y_2; + typedef typename Gt2::Compare_x_near_boundary_2 + Base_Compare_x_near_boundary_2; - typedef Gps_agg_meta_traits Self; - typedef Gps_traits_decorator, - Point_with_vertex > - Base; +public: + typedef typename Gt2::Multiplicity Multiplicity; + typedef Gps_agg_curve_data Curve_data; + typedef Point_with_vertex Point_data; - public: - typedef typename Base::X_monotone_curve_2 X_monotone_curve_2; - typedef typename Base::Point_2 Point_2; - typedef typename Traits::Has_left_category Has_left_category; - typedef typename Traits::Has_merge_category Has_merge_category; - typedef typename Traits::Has_do_intersect_category Has_do_intersect_category; +private: + typedef Gps_traits_decorator + Base; - typedef typename Arrangement::Left_side_category Left_side_category; - typedef typename Arrangement::Bottom_side_category Bottom_side_category; - typedef typename Arrangement::Top_side_category Top_side_category; - typedef typename Arrangement::Right_side_category Right_side_category; +public: + typedef typename Base::X_monotone_curve_2 X_monotone_curve_2; + typedef typename Base::Point_2 Point_2; + typedef typename Gt2::Has_left_category Has_left_category; + typedef typename Gt2::Has_merge_category Has_merge_category; + typedef typename Gt2::Has_do_intersect_category + Has_do_intersect_category; - typedef typename Traits::Multiplicity Multiplicity; - + typedef typename Arr::Left_side_category Left_side_category; + typedef typename Arr::Bottom_side_category Bottom_side_category; + typedef typename Arr::Top_side_category Top_side_category; + typedef typename Arr::Right_side_category Right_side_category; // a side is either oblivious or open (unbounded) - BOOST_MPL_ASSERT( - (boost::mpl::or_< - boost::is_same< Left_side_category, Arr_oblivious_side_tag >, - boost::is_same< Left_side_category, Arr_open_side_tag > > - ) - ); - BOOST_MPL_ASSERT( - (boost::mpl::or_< - boost::is_same< Bottom_side_category, Arr_oblivious_side_tag >, - boost::is_same< Bottom_side_category, Arr_open_side_tag > > - ) - ); - BOOST_MPL_ASSERT( - (boost::mpl::or_< - boost::is_same< Top_side_category, Arr_oblivious_side_tag >, - boost::is_same< Top_side_category, Arr_open_side_tag > > - ) - ); - BOOST_MPL_ASSERT( - (boost::mpl::or_< - boost::is_same< Right_side_category, Arr_oblivious_side_tag >, - boost::is_same< Right_side_category, Arr_open_side_tag > > - ) - ); + BOOST_MPL_ASSERT((boost::mpl::or_< + boost::is_same, + boost::is_same >)); + BOOST_MPL_ASSERT((boost::mpl::or_< + boost::is_same, + boost::is_same >)); + BOOST_MPL_ASSERT((boost::mpl::or_< + boost::is_same, + boost::is_same >)); + BOOST_MPL_ASSERT((boost::mpl::or_< + boost::is_same, + boost::is_same >)); - typedef typename Base::Curve_data Curve_data; - typedef typename Base::Point_data Point_data; + typedef typename Arr::Halfedge_handle Halfedge_handle; + typedef typename Arr::Vertex_handle Vertex_handle; - typedef typename Arrangement::Halfedge_handle Halfedge_handle; - typedef typename Arrangement::Vertex_handle Vertex_handle; + Gps_agg_meta_traits() {} + Gps_agg_meta_traits(const Gt2& base_tr) : Base(base_tr) {} - Gps_agg_meta_traits() - {} - - Gps_agg_meta_traits(const Traits & base_tr) : Base(base_tr) - {} - - class Intersect_2 - { + class Intersect_2 { private: - Base_Intersect_2 m_base; - Base_Compare_endpoints_xy_2 m_base_cmp_endpoints; - Base_Compare_xy_2 m_base_cmp_xy; - Base_Construct_min_vertex_2 m_base_ctr_min_v; + Base_Intersect_2 m_base; + Base_Compare_endpoints_xy_2 m_base_cmp_endpoints; + Base_Compare_xy_2 m_base_cmp_xy; + Base_Construct_min_vertex_2 m_base_ctr_min_v; public: - /*! Constructor. */ - Intersect_2 (const Base_Intersect_2& base, - const Base_Compare_endpoints_xy_2& base_cmp_endpoints, - const Base_Compare_xy_2& base_cmp_xy, - const Base_Construct_min_vertex_2& base_ctr_min_v) : + /*! Construct. */ + Intersect_2(const Base_Intersect_2& base, + const Base_Compare_endpoints_xy_2& base_cmp_endpoints, + const Base_Compare_xy_2& base_cmp_xy, + const Base_Construct_min_vertex_2& base_ctr_min_v) : m_base(base), m_base_cmp_endpoints(base_cmp_endpoints), m_base_cmp_xy(base_cmp_xy), m_base_ctr_min_v(base_ctr_min_v) {} - template - OutputIterator operator() (const X_monotone_curve_2& cv1, - const X_monotone_curve_2& cv2, - OutputIterator oi) const + template + OutputIterator operator()(const X_monotone_curve_2& cv1, + const X_monotone_curve_2& cv2, + OutputIterator oi) const { - if (cv1.data().arr() == cv2.data().arr()) - { - return (oi); // the curves are disjoint-interior because they - // are already at the same arrangement. + if (cv1.data().arr() == cv2.data().arr()) { + return oi; // the curves are disjoint-interior because they + // are already at the same arrangement. } - - const std::pair *base_pt; - const Base_X_monotone_curve_2 *overlap_cv; + + const std::pair* base_pt; + const Base_X_monotone_curve_2* overlap_cv; OutputIterator oi_end; if(m_base_cmp_xy(m_base_ctr_min_v(cv1.base()), m_base_ctr_min_v(cv2.base())) == LARGER) @@ -235,48 +191,40 @@ class Gps_agg_meta_traits : oi_end = m_base(cv2.base(), cv1.base(), oi); // convert objects that are associated with Base_X_monotone_curve_2 to - // the extenede X_monotone_curve_2 - for(; oi != oi_end; ++oi) - { + // the extenede X_monotone_curve_2 + for (; oi != oi_end; ++oi) { base_pt = object_cast >(&(*oi)); - if (base_pt != NULL) - { - Point_2 point_plus (base_pt->first); // the extended point - *oi = CGAL::make_object(std::make_pair(point_plus, + if (base_pt != NULL) { + Point_2 point_plus(base_pt->first); // the extended point + *oi = CGAL::make_object(std::make_pair(point_plus, base_pt->second)); } - else - { - overlap_cv = object_cast (&(*oi)); + else { + overlap_cv = object_cast(&(*oi)); - if (overlap_cv != NULL) - { + if (overlap_cv != NULL) { unsigned int ov_bc; unsigned int ov_twin_bc; - if (m_base_cmp_endpoints(cv1) == m_base_cmp_endpoints(cv2)) - { + if (m_base_cmp_endpoints(cv1) == m_base_cmp_endpoints(cv2)) { // cv1 and cv2 have the same directions ov_bc = cv1.data().bc() + cv2.data().bc(); ov_twin_bc = cv1.data().twin_bc() + cv2.data().twin_bc(); } - else - { + else { // cv1 and cv2 have opposite directions ov_bc = cv1.data().bc() + cv2.data().twin_bc(); ov_twin_bc = cv1.data().twin_bc() + cv2.data().bc(); } - if(m_base_cmp_endpoints(*overlap_cv) != m_base_cmp_endpoints(cv1)) - { + if(m_base_cmp_endpoints(*overlap_cv) != m_base_cmp_endpoints(cv1)) { // overlap_cv, cv1 have opposite directions std::swap(ov_bc, ov_twin_bc); } - Curve_data cv_data(cv1.data().arr(), - Halfedge_handle(), + Curve_data cv_data(cv1.data().arr(), Halfedge_handle(), ov_bc, ov_twin_bc); - *oi = CGAL::make_object (X_monotone_curve_2(*overlap_cv, cv_data)); + *oi = CGAL::make_object(X_monotone_curve_2(*overlap_cv, cv_data)); } } } @@ -285,8 +233,8 @@ class Gps_agg_meta_traits : } }; - /*! Get an Intersect_2 functor object. */ - Intersect_2 intersect_2_object () const + /*! Obtain an Intersect_2 functor object. */ + Intersect_2 intersect_2_object() const { return Intersect_2(this->m_base_tr->intersect_2_object(), this->m_base_tr->compare_endpoints_xy_2_object(), @@ -294,231 +242,179 @@ class Gps_agg_meta_traits : this->m_base_tr->construct_min_vertex_2_object()); } - - class Split_2 - { + class Split_2 { private: - Base_Split_2 m_base_split; + Base_Split_2 m_base_split; public: + /*! Construct. */ + Split_2(const Base_Split_2& base) : m_base_split(base) {} - /*! Constructor. */ - Split_2 (const Base_Split_2& base) : m_base_split (base) - {} - - void operator() (const X_monotone_curve_2& cv, const Point_2 & p, - X_monotone_curve_2& c1, X_monotone_curve_2& c2) const + void operator()(const X_monotone_curve_2& cv, const Point_2 & p, + X_monotone_curve_2& c1, X_monotone_curve_2& c2) const { - m_base_split(cv.base(), - p.base(), - c1.base(), - c2.base()); + m_base_split(cv.base(), p.base(), c1.base(), c2.base()); const Curve_data& cv_data = cv.data(); - c1.set_data(Curve_data(cv_data.arr(), - Halfedge_handle(), - cv_data.bc(), + c1.set_data(Curve_data(cv_data.arr(), Halfedge_handle(), cv_data.bc(), cv_data.twin_bc())); - - c2.set_data(Curve_data(cv_data.arr(), - Halfedge_handle(), - cv_data.bc(), + + c2.set_data(Curve_data(cv_data.arr(), Halfedge_handle(), cv_data.bc(), cv_data.twin_bc())); } }; - /*! Get a Split_2 functor object. */ - Split_2 split_2_object () const - { - return Split_2(this->m_base_tr->split_2_object()); - } + /*! Obtain a Split_2 functor object. */ + Split_2 split_2_object() const + { return Split_2(this->m_base_tr->split_2_object()); } - - class Construct_min_vertex_2 - { + class Construct_min_vertex_2 { private: Base_Construct_min_vertex_2 m_base; public: - Construct_min_vertex_2(const Base_Construct_min_vertex_2& base) : - m_base(base) + m_base(base) {} - - /*! - * Get the left endpoint of the x-monotone curve (segment). + + /*! Obtain the left endpoint of the x-monotone curve (segment). * \param cv The curve. * \return The left endpoint. */ - Point_2 operator() (const X_monotone_curve_2 & cv) const + Point_2 operator()(const X_monotone_curve_2 & cv) const { - if(cv.data().halfedge() == Halfedge_handle()) - return (Point_2 (m_base(cv.base()))); + if (cv.data().halfedge() == Halfedge_handle()) + return (Point_2(m_base(cv.base()))); CGAL_assertion ((Arr_halfedge_direction)cv.data().halfedge()->direction() == ARR_LEFT_TO_RIGHT); - return Point_2 (m_base(cv.base()), cv.data().halfedge()->source()); + return Point_2(m_base(cv.base()), cv.data().halfedge()->source()); } }; /*! Get a Construct_min_vertex_2 functor object. */ - Construct_min_vertex_2 construct_min_vertex_2_object () const + Construct_min_vertex_2 construct_min_vertex_2_object() const { return Construct_min_vertex_2(this->m_base_tr-> construct_min_vertex_2_object()); } - class Construct_max_vertex_2 - { + class Construct_max_vertex_2 { private: Base_Construct_max_vertex_2 m_base; public: - - Construct_max_vertex_2(const Base_Construct_max_vertex_2& base): + Construct_max_vertex_2(const Base_Construct_max_vertex_2& base) : m_base(base) {} - - /*! - * Get the right endpoint of the x-monotone curve (segment). + + /*! Obtain the right endpoint of the x-monotone curve (segment). * \param cv The curve. * \return The right endpoint. */ - Point_2 operator() (const X_monotone_curve_2 & cv) const + Point_2 operator()(const X_monotone_curve_2& cv) const { - if(cv.data().halfedge() == Halfedge_handle()) - return (Point_2 (m_base(cv.base()))); + if (cv.data().halfedge() == Halfedge_handle()) + return (Point_2(m_base(cv.base()))); CGAL_assertion((Arr_halfedge_direction)cv.data().halfedge()->direction() == ARR_LEFT_TO_RIGHT); - return Point_2 (m_base(cv.base()), cv.data().halfedge()->target()); + return Point_2(m_base(cv.base()), cv.data().halfedge()->target()); } }; /*! Get a Construct_min_vertex_2 functor object. */ - Construct_max_vertex_2 construct_max_vertex_2_object () const + Construct_max_vertex_2 construct_max_vertex_2_object() const { return Construct_max_vertex_2(this->m_base_tr-> construct_max_vertex_2_object()); } - - class Compare_xy_2 - { + class Compare_xy_2 { private: Base_Compare_xy_2 m_base; public: + Compare_xy_2(const Base_Compare_xy_2& base) : m_base(base) {} - Compare_xy_2(const Base_Compare_xy_2& base): - m_base(base) - {} - - - /*! - * Get the left endpoint of the x-monotone curve (segment). + /*! Obtain the left endpoint of the x-monotone curve (segment). * \param cv The curve. * \return The left endpoint. */ - Comparison_result operator() (const Point_2& p1, const Point_2& p2) const + Comparison_result operator()(const Point_2& p1, const Point_2& p2) const { const Point_data& inf1 = p1.data(); const Point_data& inf2 = p2.data(); - if(inf1.vertex() == Vertex_handle() || inf2.vertex() == Vertex_handle()) - { - return(m_base(p1.base(), p2.base())); - } + if (inf1.vertex() == Vertex_handle() || inf2.vertex() == Vertex_handle()) + return m_base(p1.base(), p2.base()); - if(inf1.vertex() == inf2.vertex()) - return (EQUAL); - - return(m_base(p1.base(), p2.base())); + if (inf1.vertex() == inf2.vertex()) return EQUAL; + return m_base(p1.base(), p2.base()); } }; - - /*! Get a Construct_min_vertex_2 functor object. */ - Compare_xy_2 compare_xy_2_object () const - { - return Compare_xy_2(this->m_base_tr->compare_xy_2_object()); - } - - + /*! Obtain a Construct_min_vertex_2 functor object. */ + Compare_xy_2 compare_xy_2_object() const + { return Compare_xy_2(this->m_base_tr->compare_xy_2_object()); } // left-right - - - class Parameter_space_in_x_2 - { + class Parameter_space_in_x_2 { private: Base_Parameter_space_in_x_2 m_base; - + public: - - Parameter_space_in_x_2(const Base_Parameter_space_in_x_2& base): + Parameter_space_in_x_2(const Base_Parameter_space_in_x_2& base) : m_base(base) {} - - /*! Obtains the parameter space at the end of a curve-end along the x-axis. - */ - Arr_parameter_space operator() (const X_monotone_curve_2 & cv, - const Arr_curve_end& end) const - { - return m_base(cv.base(), end); - } - - /*! Obtains the parameter space for a curve along the x-axis. - */ - Arr_parameter_space operator() (const X_monotone_curve_2 & cv) const - { - return m_base(cv.base()); - } - /*! Obtains the parameter space for a point along the x-axis. + /*! Obtain the parameter space at the end of a curve-end along the x-axis. */ - Arr_parameter_space operator() (const Point_2 & pt) const - { - return m_base(pt.base()); - } + Arr_parameter_space operator()(const X_monotone_curve_2 & cv, + const Arr_curve_end& end) const + { return m_base(cv.base(), end); } + + /*! Obtain the parameter space for a curve along the x-axis. + */ + Arr_parameter_space operator()(const X_monotone_curve_2 & cv) const + { return m_base(cv.base()); } + + /*! Obtain the parameter space for a point along the x-axis. + */ + Arr_parameter_space operator()(const Point_2 & pt) const + { return m_base(pt.base()); } }; - - /*! Get a Construct_min_vertex_2 functor object. */ - Parameter_space_in_x_2 parameter_space_in_x_2_object () const + + /*! Obtain a Construct_min_vertex_2 functor object. */ + Parameter_space_in_x_2 parameter_space_in_x_2_object() const { - return Parameter_space_in_x_2( - this->m_base_tr->parameter_space_in_x_2_object() - ); + return Parameter_space_in_x_2(this->m_base_tr-> + parameter_space_in_x_2_object()); } - class Compare_y_near_boundary_2 - { + class Compare_y_near_boundary_2 { private: Base_Compare_y_near_boundary_2 m_base; - + public: - - Compare_y_near_boundary_2(const Base_Compare_y_near_boundary_2& base): + Compare_y_near_boundary_2(const Base_Compare_y_near_boundary_2& base) : m_base(base) {} - - /*! - * Compare the relative y-positions of two curve ends. + + /*! Compare the relative y-positions of two curve ends. */ - Comparison_result operator() (const X_monotone_curve_2 & xcv1, - const X_monotone_curve_2 & xcv2, - Arr_curve_end ce) const - { - return m_base(xcv1, xcv2, ce); - } + Comparison_result operator()(const X_monotone_curve_2 & xcv1, + const X_monotone_curve_2 & xcv2, + Arr_curve_end ce) const + { return m_base(xcv1, xcv2, ce); } }; - - /*! Get a Construct_min_vertex_2 functor object. */ - Compare_y_near_boundary_2 compare_y_near_boundary_2_object () const + + /*! Obtain a Construct_min_vertex_2 functor object. */ + Compare_y_near_boundary_2 compare_y_near_boundary_2_object() const { - return Compare_y_near_boundary_2( - this->m_base_tr->compare_y_near_boundary_2_object() + return Compare_y_near_boundary_2(this->m_base_tr-> + compare_y_near_boundary_2_object() ); } @@ -527,93 +423,76 @@ class Gps_agg_meta_traits : // bottom-top - - class Parameter_space_in_y_2 - { + class Parameter_space_in_y_2 { private: Base_Parameter_space_in_y_2 m_base; - + public: - - Parameter_space_in_y_2(const Base_Parameter_space_in_y_2& base): + Parameter_space_in_y_2(const Base_Parameter_space_in_y_2& base) : m_base(base) {} - - /*! Obtains the parameter space at the end of a curve-end along the y-axis. - */ - Arr_parameter_space operator() (const X_monotone_curve_2 & cv, - const Arr_curve_end& end) const - { - return m_base(cv.base(), end); - } - - /*! Obtains the parameter space for a curve along the x-axis. - */ - Arr_parameter_space operator() (const X_monotone_curve_2 & cv) const - { - return m_base(cv.base()); - } - /*! Obtains the parameter space for a point along the x-axis. + /*! Obtain the parameter space at the end of a curve-end along the y-axis. */ - Arr_parameter_space operator() (const Point_2 & pt) const - { - return m_base(pt.base()); - } - + Arr_parameter_space operator()(const X_monotone_curve_2 & cv, + const Arr_curve_end& end) const + { return m_base(cv.base(), end); } + + /*! Obtain the parameter space for a curve along the x-axis. + */ + Arr_parameter_space operator()(const X_monotone_curve_2 & cv) const + { return m_base(cv.base()); } + + /*! Obtain the parameter space for a point along the x-axis. + */ + Arr_parameter_space operator()(const Point_2 & pt) const + { return m_base(pt.base()); } }; - - /*! Get a Construct_min_vertex_2 functor object. */ - Parameter_space_in_y_2 parameter_space_in_y_2_object () const + + /*! Obtain a Construct_min_vertex_2 functor object. */ + Parameter_space_in_y_2 parameter_space_in_y_2_object() const { - return Parameter_space_in_y_2 - (this->m_base_tr->parameter_space_in_y_2_object()); + return Parameter_space_in_y_2(this->m_base_tr-> + parameter_space_in_y_2_object()); } - class Compare_x_near_boundary_2 - { + class Compare_x_near_boundary_2 { private: Base_Compare_x_near_boundary_2 m_base; - + public: - - Compare_x_near_boundary_2(const Base_Compare_x_near_boundary_2& base): + Compare_x_near_boundary_2(const Base_Compare_x_near_boundary_2& base) : m_base(base) {} - + /*! Compare the relative x-positions of a vertical curve and another given * curve end. */ - Comparison_result operator() (const Point_2 & p, - const X_monotone_curve_2 & xcv, - Arr_curve_end ce) const - { - return m_base(p, xcv, ce); - } + Comparison_result operator()(const Point_2& p, + const X_monotone_curve_2& xcv, + Arr_curve_end ce) const + { return m_base(p, xcv, ce); } /*! Compare the relative x-positions of two curve ends. */ - Comparison_result operator() (const X_monotone_curve_2 & xcv1, - Arr_curve_end ce1, - const X_monotone_curve_2 & xcv2, - Arr_curve_end ce2) const - { - return m_base(xcv1, ce1, xcv2, ce2); - } + Comparison_result operator()(const X_monotone_curve_2& xcv1, + Arr_curve_end ce1, + const X_monotone_curve_2& xcv2, + Arr_curve_end ce2) const + { return m_base(xcv1, ce1, xcv2, ce2); } }; - - /*! Get a Construct_min_vertex_2 functor object. */ - Compare_x_near_boundary_2 compare_x_near_boundary_2_object () const + + /*! Obtain a Construct_min_vertex_2 functor object. */ + Compare_x_near_boundary_2 compare_x_near_boundary_2_object() const { - return Compare_x_near_boundary_2 - (this->m_base_tr->compare_x_near_boundary_2_object()); + return Compare_x_near_boundary_2(this->m_base_tr-> + compare_x_near_boundary_2_object()); } // TODO Compare_x_on_boundary_2 // TODO Is_on_y_identification_2 - }; -} //namespace CGAL +} // namespace CGAL #endif diff --git a/Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Gps_agg_op.h b/Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Gps_agg_op.h index f9e6548274a..fbb71764dda 100644 --- a/Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Gps_agg_op.h +++ b/Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Gps_agg_op.h @@ -19,130 +19,118 @@ // Author(s) : Baruch Zukerman // Ophir Setter -#ifndef CGAL_GPS_AGG_OP_H -#define CGAL_GPS_AGG_OP_H +#ifndef CGAL_BSO_2_GPS_AGG_OP_H +#define CGAL_BSO_2_GPS_AGG_OP_H #include - -/*! - \file Gps_agg_op.h - \brief The class Gps_agg_op is responsible for aggregated Boolean set - operations depending on a visitor template parameter. - It uses the sweep-line algorithm from the arrangement packages - to overlay all the polygon sets, and then it uses a BFS that - determines which of the faces is contained in the result using - the visitor. -*/ - +/*! \file Gps_agg_op.h + * + * The class Gps_agg_op is responsible for aggregated Boolean set operations + * depending on a visitor template parameter. It uses the surface-sweep + * algorithm from the arrangement packages to overlay all the polygon sets, and + * then it uses a BFS that determines which of the faces is contained in the + * result using the visitor. + */ #include -#include -#include -#include +#include +#include +#include #include #include -//#include -#include +#include #include -#include +#include namespace CGAL { -template -class Gps_agg_op -{ - typedef Arrangement_ Arrangement_2; - typedef typename Arrangement_2::Traits_adaptor_2 Traits_2; - typedef typename Traits_2::Curve_const_iterator Curve_const_iterator; - typedef Gps_agg_meta_traits Meta_traits; - typedef typename Meta_traits::Curve_data Curve_data; - typedef typename Meta_traits::X_monotone_curve_2 Meta_X_monotone_curve_2; - typedef typename Arrangement_2::Halfedge_handle Halfedge_handle; - typedef typename Arrangement_2::Halfedge_iterator Halfedge_iterator; - typedef typename Arrangement_2::Face_handle Face_handle; - typedef typename Arrangement_2::Edge_iterator Edge_iterator; - typedef typename Arrangement_2::Vertex_handle Vertex_handle; - typedef typename Arrangement_2::Ccb_halfedge_const_circulator - Ccb_halfedge_const_circulator; - typedef typename Arrangement_2::Ccb_halfedge_circulator - Ccb_halfedge_circulator; +template +class Gps_agg_op { + typedef Arrangement_ Arrangement_2; + typedef BfsVisitor Bfs_visitor; - typedef std::pair *> Arr_entry; + typedef typename Arrangement_2::Traits_adaptor_2 Geometry_traits_2; + typedef typename Arrangement_2::Topology_traits Topology_traits; - typedef Arr_construction_subcurve Subcurve; + typedef Arrangement_2 Arr; + typedef Geometry_traits_2 Gt2; + typedef Topology_traits Tt; - typedef Arr_construction_event Base_event; - Arrangement_2> Base_event; + typedef typename Gt2::Curve_const_iterator Curve_const_iterator; + typedef Gps_agg_meta_traits Mgt2; + typedef typename Mgt2::Curve_data Curve_data; + typedef typename Mgt2::X_monotone_curve_2 Meta_X_monotone_curve_2; - typedef Indexed_event Event; + typedef typename Arr::Halfedge_handle Halfedge_handle; + typedef typename Arr::Halfedge_iterator Halfedge_iterator; + typedef typename Arr::Face_handle Face_handle; + typedef typename Arr::Edge_iterator Edge_iterator; + typedef typename Arr::Vertex_handle Vertex_handle; + typedef typename Arr::Allocator Allocator; - typedef Gps_agg_op_visitor Visitor; + typedef std::pair *> Arr_entry; - typedef Gps_agg_op_sweep_line_2 Sweep_line_2; + // We obtain a proper helper type from the topology traits of the arrangement. + // However, the arrangement is parametrized with the Gt2 geometry traits, + // while we need the Mgt2 geometry traits (which derives from Gt2). + // Thus, we rebind the helper. + // We cannot parameterized the arrangement with the Mgt2 geometry + // traits to start with, because it extends the curve type with arrangement + // dependent types. (It is parameterized with the arrangement type.) + typedef Indexed_event Event; + typedef Arr_construction_subcurve + Subcurve; + typedef typename Tt::template Construction_helper + Helper_tmp; + typedef typename Helper_tmp::template rebind::other + Helper; + typedef Gps_agg_op_visitor Visitor; + typedef Gps_agg_op_surface_sweep_2 Surface_sweep_2; - typedef Unique_hash_map Edges_hash; + typedef Unique_hash_map + Edges_hash; + + typedef Unique_hash_map Faces_hash; + typedef Gps_bfs_scanner Bfs_scanner; - typedef Unique_hash_map Faces_hash; - typedef Bfs_visitor_ Bfs_visitor; - typedef Gps_bfs_scanner Bfs_scanner; - protected: - Arrangement_2* m_arr; - Meta_traits* m_traits; - Visitor m_visitor; - Sweep_line_2 m_sweep_line; - Edges_hash m_edges_hash; // maps halfedge to its BC (boundary counter) - Faces_hash m_faces_hash; // maps face to its IC (inside count) - -public: + Arr* m_arr; + Mgt2* m_traits; + Visitor m_visitor; + Surface_sweep_2 m_surface_sweep; + Edges_hash m_edges_hash; // maps halfedge to its BC (boundary counter) + Faces_hash m_faces_hash; // maps face to its IC (inside count) +public: /*! Constructor. */ - Gps_agg_op (Arrangement_2& arr, std::vector& vert_vec, - const Traits_2 & tr) : - m_arr (&arr), - m_traits(new Meta_traits(tr)), - m_visitor (&arr, &m_edges_hash, &vert_vec), - m_sweep_line (m_traits, &m_visitor) + Gps_agg_op(Arr& arr, std::vector& vert_vec, const Gt2& tr) : + m_arr(&arr), + m_traits(new Mgt2(tr)), + m_visitor(&arr, &m_edges_hash, &vert_vec), + m_surface_sweep(m_traits, &m_visitor) {} - void sweep_arrangements(unsigned int lower, - unsigned int upper, - unsigned int jump, - std::vector& arr_vec) + void sweep_arrangements(unsigned int lower, unsigned int upper, + unsigned int jump, std::vector& arr_vec) { std::list curves_list; - unsigned int n_inf_pgn = 0; // number of infinte polygons (arrangement + unsigned int n_inf_pgn = 0; // number of infinte polygons (arrangement // with a contained unbounded face unsigned int n_pgn = 0; // number of polygons (arrangements) unsigned int i; - for (i = lower; i <= upper; i += jump, ++n_pgn) - { + for (i = lower; i <= upper; i += jump, ++n_pgn) { // The BFS scan (after the loop) starts in the reference face, // so we count the number of polygons that contain the reference face. - Arrangement_2* arr = (arr_vec[i]).first; - if (arr->reference_face()->contained()) - ++n_inf_pgn; + Arr* arr = (arr_vec[i]).first; + if (arr->reference_face()->contained()) ++n_inf_pgn; Edge_iterator itr = arr->edges_begin(); - for(; itr != arr->edges_end(); ++itr) - { - // take only relevant edges (which seperate between contained and + for(; itr != arr->edges_end(); ++itr) { + // take only relevant edges (which seperate between contained and // non-contained faces. Halfedge_iterator he = itr; if(he->face()->contained() == he->twin()->face()->contained()) @@ -155,11 +143,10 @@ public: } } - m_sweep_line.sweep (curves_list.begin(), curves_list.end(), - lower, upper, jump, - arr_vec); + m_surface_sweep.sweep(curves_list.begin(), curves_list.end(), + lower, upper, jump, arr_vec); - m_faces_hash[m_arr->reference_face()] = n_inf_pgn; + m_faces_hash[m_arr->reference_face()] = n_inf_pgn; Bfs_visitor visitor(&m_edges_hash, &m_faces_hash, n_pgn); visitor.visit_ubf(m_arr->faces_begin(), n_inf_pgn); Bfs_scanner scanner(visitor); @@ -167,10 +154,9 @@ public: visitor.after_scan(*m_arr); } - ~Gps_agg_op() - { - delete m_traits; - } + /*! Destruct. + */ + ~Gps_agg_op() { delete m_traits; } }; } //namespace CGAL diff --git a/Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Gps_agg_op_surface_sweep_2.h b/Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Gps_agg_op_surface_sweep_2.h new file mode 100644 index 00000000000..ec2bc79085a --- /dev/null +++ b/Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Gps_agg_op_surface_sweep_2.h @@ -0,0 +1,251 @@ +// Copyright (c) 2005 Tel-Aviv University (Israel). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// You can redistribute it and/or modify it under the terms of the GNU +// General Public License as published by the Free Software Foundation, +// either version 3 of the License, or (at your option) any later version. +// +// Licensees holding a valid commercial license may use this file in +// accordance with the commercial license agreement provided with the software. +// +// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Author(s) : Baruch Zukerman +// Ron Wein + +#ifndef CGAL_BSO_2_GSP_AGG_OP_SURFACE_SWEEP_2_H +#define CGAL_BSO_2_GSP_AGG_OP_SURFACE_SWEEP_2_H + +#include + +#include + +#include +#include + +namespace CGAL { + +namespace Ss2 = Surface_sweep_2; + +template +class Gps_agg_op_surface_sweep_2 : public Ss2::Surface_sweep_2 { +public: + typedef Arrangement_ Arrangement_2; + typedef Visitor_ Visitor; + + typedef typename Visitor::Geometry_traits_2 Geometry_traits_2; + + typedef Arrangement_2 Arr; + typedef Geometry_traits_2 Gt2; + + typedef typename Gt2::Point_2 Point_2; + typedef typename Gt2::X_monotone_curve_2 X_monotone_curve_2; + + typedef typename Arr::Vertex_handle Vertex_handle; + typedef typename Arr::Halfedge_handle Halfedge_handle; + + typedef std::pair *> Arr_entry; + + typedef Ss2::Surface_sweep_2 Base; + + typedef typename Visitor::Event Event; + typedef typename Visitor::Subcurve Subcurve; + + typedef typename Base::Event_queue_iterator EventQueueIter; + typedef typename Event::Subcurve_iterator EventCurveIter; + + typedef typename Event::Attribute Attribute; + + typedef std::list SubCurveList; + typedef typename SubCurveList::iterator SubCurveListIter; + +public: + /*! Constructor. + * \param visitor A pointer to a sweep-line visitor object. + */ + Gps_agg_op_surface_sweep_2(Visitor* visitor) : Base(visitor) {} + + /*! Constructor. + * \param traits A pointer to a sweep-line traits object. + * \param visitor A pointer to a sweep-line visitor object. + */ + Gps_agg_op_surface_sweep_2(Gt2* traits, Visitor* visitor) : + Base(traits, visitor) + {} + + /*! Perform the sweep. */ + template + void sweep(CurveInputIterator curves_begin, CurveInputIterator curves_end, + unsigned int lower, unsigned int upper, unsigned int jump, + std::vector& arr_vec) + { + CGAL_assertion(this->m_queue->empty() && this->m_statusLine.size() == 0); + + typedef Unique_hash_map Vertices_map; + typedef typename Gt2::Compare_xy_2 Compare_xy_2; + + this->m_visitor->before_sweep(); + // Allocate all of the Subcurve objects as one block. + this->m_num_of_subCurves = + static_cast(std::distance(curves_begin, curves_end)); + if (this->m_num_of_subCurves > 0) + this->m_subCurves = + this->m_subCurveAlloc.allocate(this->m_num_of_subCurves); + + this->m_curves_pair_set.resize(2 * this->m_num_of_subCurves); + + // Initialize the event queue using the vertices vectors. Note that these + // vertices are already sorted, we simply have to merge them + Vertices_map vert_map; + Vertex_handle vh; + Vertex_handle invalid_v; + unsigned int i = lower; + unsigned int n = static_cast((arr_vec[i].second)->size()); + unsigned int j; + EventQueueIter q_iter; + bool first = true; + Attribute event_type; + Event* event; + + for (j = 0; j < n && (vh = (*(arr_vec[i].second))[j]) != invalid_v; j++) { + // Insert the vertices of the first vector one after the other. + event_type = _type_of_vertex(vh); + if (event_type == Event::DEFAULT) continue; + + event = this->_allocate_event(vh->point(), event_type, + ARR_INTERIOR, ARR_INTERIOR); + // \todo When the boolean set operations are exteneded to support + // unbounded curves, we will need here a special treatment. + + #ifndef CGAL_ARRANGEMENT_ON_SURFACE_2_H + event->set_finite(); + #endif + + if (! first) { + q_iter = this->m_queue->insert_after(q_iter, event); + } + else { + q_iter = this->m_queue->insert(event); + first = false; + } + + vert_map[vh] = event; + } + + Comparison_result res = LARGER; + Compare_xy_2 comp_xy = this->m_traits->compare_xy_2_object(); + EventQueueIter q_end = this->m_queue->end(); + + for (i += jump; i <= upper; i += jump) { + // Merge the vertices of the other vectors into the existing queue. + q_iter = this->m_queue->begin(); + n = static_cast((arr_vec[i].second)->size()); + + for (j = 0; j < n && (vh = (*(arr_vec[i].second))[j]) != invalid_v; j++) { + event_type = _type_of_vertex(vh); + if (event_type == Event::DEFAULT) continue; + + while ((q_iter != q_end) && + (res = comp_xy(vh->point(), (*q_iter)->point())) == LARGER) + { + ++q_iter; + } + + if (res == SMALLER || q_iter == q_end) { + event = this->_allocate_event(vh->point(), event_type, + ARR_INTERIOR, ARR_INTERIOR); + // \todo When the boolean set operations are exteneded to support + // unbounded curves, we will need here a special treatment. + + #ifndef CGAL_ARRANGEMENT_ON_SURFACE_2_H + event->set_finite(); + #endif + + this->m_queue->insert_before(q_iter, event); + vert_map[vh] = event; + } + else if (res == EQUAL) { + // In this case q_iter points to an event already associated with + // the vertex, so we just update the map: + vert_map[vh] = *q_iter; + } + } + } + + // Go over all curves (which are associated with halfedges) and associate + // them with the events we have just created. + unsigned int index = 0; + CurveInputIterator iter; + Halfedge_handle he; + Event* e_left; + Event* e_right; + + for (iter = curves_begin; iter != curves_end; ++iter, index++) { + // Get the events associated with the end-vertices of the current + // halfedge. + he = iter->data().halfedge(); + + CGAL_assertion(vert_map.is_defined(he->source())); + CGAL_assertion(vert_map.is_defined(he->target())); + + if ((Arr_halfedge_direction)he->direction() == ARR_LEFT_TO_RIGHT) { + e_left = vert_map[he->source()]; + e_right = vert_map[he->target()]; + } + else { + e_left = vert_map[he->target()]; + e_right = vert_map[he->source()]; + } + + // Create the subcurve object. + this->m_subCurveAlloc.construct(this->m_subCurves + index, + this->m_masterSubcurve); + + (this->m_subCurves + index)->init(*iter); + (this->m_subCurves + index)->set_left_event(e_left); + (this->m_subCurves + index)->set_right_event(e_right); + + e_right->add_curve_to_left(this->m_subCurves + index); + this->_add_curve_to_right(e_left, this->m_subCurves + index); + } + + // Perform the sweep: + this->_sweep(); + this->_complete_sweep(); + this->m_visitor->after_sweep(); + + return; + } + +private: + /*! + * Check if the given vertex is an endpoint of an edge we are going + * to use in the sweep. + */ + Attribute _type_of_vertex(Vertex_handle v) + { + typename Arr::Halfedge_around_vertex_circulator first, circ; + + circ = first = v->incident_halfedges(); + do { + // Check if the current edge separates two faces with unequal + // containment flags (otherwise we will simply not keep it). + if (circ->face()->contained() != circ->twin()->face()->contained()) { + if ((Arr_halfedge_direction)circ->direction() == ARR_LEFT_TO_RIGHT) + return (Event::RIGHT_END); + else return (Event::LEFT_END); + } + ++circ; + + } while (circ != first); + + // If we reached here, we should not keep this vertex. + return (Event::DEFAULT); + } +}; + +} // namespace CGAL + +#endif diff --git a/Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Gps_agg_op_sweep.h b/Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Gps_agg_op_sweep.h deleted file mode 100644 index 9d416ce5d9d..00000000000 --- a/Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Gps_agg_op_sweep.h +++ /dev/null @@ -1,300 +0,0 @@ -// Copyright (c) 2005 Tel-Aviv University (Israel). -// All rights reserved. -// -// This file is part of CGAL (www.cgal.org). -// You can redistribute it and/or modify it under the terms of the GNU -// General Public License as published by the Free Software Foundation, -// either version 3 of the License, or (at your option) any later version. -// -// Licensees holding a valid commercial license may use this file in -// accordance with the commercial license agreement provided with the software. -// -// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -// -// $URL$ -// $Id$ -// SPDX-License-Identifier: GPL-3.0+ -// -// Author(s) : Baruch Zukerman -// Ron Wein - -#ifndef CGAL_GSP_AGG_OP_SWEEP_H -#define CGAL_GSP_AGG_OP_SWEEP_H - -#include - - -#include -#include - -namespace CGAL { - -template -class Gps_agg_op_sweep_line_2 : - public Sweep_line_2 -{ -public: - - typedef Arrangement_ Arrangement_2; - typedef MetaTraits_ Traits_2; - typedef typename Traits_2::Point_2 Point_2; - typedef typename Traits_2::X_monotone_curve_2 X_monotone_curve_2; - - typedef typename Arrangement_2::Vertex_handle Vertex_handle; - typedef typename Arrangement_2::Halfedge_handle Halfedge_handle; - - typedef std::pair *> Arr_entry; - - typedef Sweep_line_2 Base; - - typedef SweepEvent Event; - - - typedef typename Base::Event_queue_iterator EventQueueIter; - typedef typename Event::Subcurve_iterator EventCurveIter; - - typedef typename Base::Base_event Base_event; - typedef typename Base_event::Attribute Attribute; - - typedef typename Base::Base_subcurve Base_subcurve; - - typedef CurveWrap Subcurve; - - typedef std::list SubCurveList; - typedef typename SubCurveList::iterator SubCurveListIter; - - - typedef typename Base::Status_line_iterator StatusLineIter; - -public: - - /*! - * Constructor. - * \param visitor A pointer to a sweep-line visitor object. - */ - Gps_agg_op_sweep_line_2 (SweepVisitor* visitor) : - Base (visitor) - {} - - /*! - * Constructor. - * \param traits A pointer to a sweep-line traits object. - * \param visitor A pointer to a sweep-line visitor object. - */ - Gps_agg_op_sweep_line_2 (Traits_2 *traits, SweepVisitor* visitor) : - Base(traits, visitor) - {} - - /*! Perform the sweep. */ - template - void sweep (CurveInputIterator curves_begin, - CurveInputIterator curves_end, - unsigned int lower, - unsigned int upper, - unsigned int jump, - std::vector& arr_vec) - { - CGAL_assertion (this->m_queue->empty() && - this->m_statusLine.size() == 0); - - typedef Unique_hash_map Vertices_map; - typedef typename Traits_2::Compare_xy_2 Compare_xy_2; - - this->m_visitor->before_sweep(); - // Allocate all of the Subcurve objects as one block. - this->m_num_of_subCurves = static_cast(std::distance (curves_begin, curves_end)); - if (this->m_num_of_subCurves > 0) - this->m_subCurves = - this->m_subCurveAlloc.allocate (this->m_num_of_subCurves); - - this->m_curves_pair_set.resize (2 * this->m_num_of_subCurves); - - // Initialize the event queue using the vertices vectors. Note that these - // vertices are already sorted, we simply have to merge them - Vertices_map vert_map; - Vertex_handle vh; - Vertex_handle invalid_v; - unsigned int i = lower; - unsigned int n = static_cast((arr_vec[i].second)->size()); - unsigned int j; - EventQueueIter q_iter; - bool first = true; - Attribute event_type; - Event *event; - - for (j = 0; - j < n && (vh = (*(arr_vec[i].second))[j]) != invalid_v; - j++) - { - // Insert the vertices of the first vector one after the other. - event_type = _type_of_vertex (vh); - if (event_type == Base_event::DEFAULT) - continue; - - event = this->_allocate_event (vh->point(), event_type, - ARR_INTERIOR, ARR_INTERIOR); - // \todo When the boolean set operations are exteneded to support - // unbounded curves, we will need here a special treatment. - - #ifndef CGAL_ARRANGEMENT_ON_SURFACE_2_H - event->set_finite(); - #endif - - if (! first) - { - q_iter = this->m_queue->insert_after (q_iter, event); - } - else - { - q_iter = this->m_queue->insert (event); - first = false; - } - - vert_map[vh] = event; - } - - Comparison_result res = LARGER; - Compare_xy_2 comp_xy = this->m_traits->compare_xy_2_object(); - EventQueueIter q_end = this->m_queue->end(); - - for (i += jump; i <= upper; i += jump) - { - // Merge the vertices of the other vectors into the existing queue. - q_iter = this->m_queue->begin(); - n = static_cast((arr_vec[i].second)->size()); - - for (j = 0; - j < n && (vh = (*(arr_vec[i].second))[j]) != invalid_v; - j++) - { - event_type = _type_of_vertex (vh); - if (event_type == Base_event::DEFAULT) - continue; - - while (q_iter != q_end && - (res = comp_xy (vh->point(), (*q_iter)->point())) == LARGER) - { - ++q_iter; - } - - if (res == SMALLER || q_iter == q_end) - { - event = this->_allocate_event (vh->point(), event_type, - ARR_INTERIOR, ARR_INTERIOR); - // \todo When the boolean set operations are exteneded to support - // unbounded curves, we will need here a special treatment. - - #ifndef CGAL_ARRANGEMENT_ON_SURFACE_2_H - event->set_finite(); - #endif - - this->m_queue->insert_before (q_iter, event); - vert_map[vh] = event; - } - else if (res == EQUAL) - { - // In this case q_iter points to an event already associated with - // the vertex, so we just update the map: - vert_map[vh] = *q_iter; - } - } - } - - // Go over all curves (which are associated with halfedges) and associate - // them with the events we have just created. - unsigned int index = 0; - CurveInputIterator iter; - Halfedge_handle he; - Event *e_left; - Event *e_right; - - for (iter = curves_begin; iter != curves_end; ++iter, index++) - { - // Get the events associated with the end-vertices of the current - // halfedge. - he = iter->data().halfedge(); - - CGAL_assertion (vert_map.is_defined (he->source())); - CGAL_assertion (vert_map.is_defined (he->target())); - - if ((Arr_halfedge_direction)he->direction() == ARR_LEFT_TO_RIGHT) - { - e_left = vert_map[he->source()]; - e_right = vert_map[he->target()]; - } - else - { - e_left = vert_map[he->target()]; - e_right = vert_map[he->source()]; - } - - // Create the subcurve object. - this->m_subCurveAlloc.construct (this->m_subCurves + index, - this->m_masterSubcurve); - - (this->m_subCurves + index)->init (*iter); - (this->m_subCurves + index)->set_left_event(e_left); - (this->m_subCurves + index)->set_right_event(e_right); - - e_right->add_curve_to_left (this->m_subCurves + index); - this->_add_curve_to_right (e_left, this->m_subCurves + index); - } - - // Perform the sweep: - this->_sweep(); - this->_complete_sweep(); - this->m_visitor->after_sweep(); - - return; - } - -private: - - /*! - * Check if the given vertex is an endpoint of an edge we are going - * to use in the sweep. - */ - Attribute _type_of_vertex (Vertex_handle v) - { - typename Arrangement_2::Halfedge_around_vertex_circulator first, circ; - - circ = first = v->incident_halfedges(); - do - { - // Check if the current edge separates two faces with unequal - // containment flags (otherwise we will simply not keep it). - if (circ->face()->contained() != circ->twin()->face()->contained()) - { - if ((Arr_halfedge_direction)circ->direction() == ARR_LEFT_TO_RIGHT) - return (Base_event::RIGHT_END); - else - return (Base_event::LEFT_END); - } - ++circ; - - } while (circ != first); - - // If we reached here, we should not keep this vertex. - return (Base_event::DEFAULT); - } -}; - - -} //namespace CGAL - -#endif diff --git a/Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Gps_agg_op_visitor.h b/Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Gps_agg_op_visitor.h index 6f0f30c025a..481c81a9349 100644 --- a/Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Gps_agg_op_visitor.h +++ b/Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Gps_agg_op_visitor.h @@ -15,307 +15,237 @@ // $URL$ // $Id$ // SPDX-License-Identifier: GPL-3.0+ -// +// // // Author(s) : Baruch Zukerman // Ron Wein -#ifndef CGAL_GSP_AGG_OP_VISITOR_H -#define CGAL_GSP_AGG_OP_VISITOR_H +#ifndef CGAL_BSO_2_GSP_AGG_OP_VISITOR_H +#define CGAL_BSO_2_GSP_AGG_OP_VISITOR_H #include - -#include -#include -#include -#include +#include +#include #include #include #include +#include namespace CGAL { -template +template class Gps_agg_op_base_visitor : - public - Arr_construction_sl_visitor< - // TODO derive (helper) from topology traits class - typename boost::mpl::if_< - boost::is_same< typename Arr_are_all_sides_oblivious_tag< - typename Traits::Left_side_category, - typename Traits::Bottom_side_category, - typename Traits::Top_side_category, - typename Traits::Right_side_category - >::result, Arr_all_sides_oblivious_tag >, - Arr_bounded_planar_construction_helper, - Arr_unb_planar_construction_helper - >::type - > + public Arr_construction_ss_visitor< + Helper_, + typename Default::Get >::type> { - protected: - typedef Arrangement_ Arrangement; +public: + typedef Helper_ Helper; + typedef Arrangement_ Arrangement_2; + typedef typename Helper::Geometry_traits_2 Geometry_traits_2; + typedef typename Helper::Event Event; + typedef typename Helper::Subcurve Subcurve; - - typedef typename boost::mpl::if_< - boost::is_same< typename Arr_are_all_sides_oblivious_tag< - typename Traits::Left_side_category, - typename Traits::Bottom_side_category, - typename Traits::Top_side_category, - typename Traits::Right_side_category - >::result, Arr_all_sides_oblivious_tag >, - Arr_bounded_planar_construction_helper, - Arr_unb_planar_construction_helper - >::type Construction_helper; - typedef Arr_construction_sl_visitor Base; - - typedef typename Base::Status_line_iterator SL_iterator; - typedef typename Base::Halfedge_handle Halfedge_handle; - typedef typename Base::Vertex_handle Vertex_handle; - typedef typename Base::Event_subcurve_iterator SubCurveIter; - typedef typename Base::Event_subcurve_reverse_iterator SubCurveRevIter; - typedef typename Traits::X_monotone_curve_2 X_monotone_curve_2; - typedef typename Traits::Point_2 Point_2; - - typedef Unique_hash_map Edges_hash; - -protected: - - Edges_hash* m_edges_hash; // maps halfedges to their BC (coundary counter) +private: + typedef Geometry_traits_2 Gt2; + typedef Arrangement_2 Arr; + typedef Gps_agg_op_base_visitor + Self; + typedef typename Default::Get::type Visitor; + typedef Arr_construction_ss_visitor Base; public: + typedef typename Arr::Halfedge_handle Halfedge_handle; + typedef typename Arr::Vertex_handle Vertex_handle; + typedef typename Gt2::X_monotone_curve_2 X_monotone_curve_2; + typedef typename Gt2::Point_2 Point_2; - Gps_agg_op_base_visitor(Arrangement *arr, - Edges_hash* hash): Base(arr), - m_edges_hash(hash) + typedef Unique_hash_map + Edges_hash; + +protected: + Edges_hash* m_edges_hash; // maps halfedges to their BC (coundary counter) + +public: + Gps_agg_op_base_visitor(Arr* arr, Edges_hash* hash) : + Base(arr), + m_edges_hash(hash) {} // TODO (IMPORTANT): unbounded helper might be not fully supported // TODO add mpl-warning virtual Halfedge_handle insert_in_face_interior(const X_monotone_curve_2& cv, - Subcurve* sc) + Subcurve* sc) { - Halfedge_handle he = - Base::insert_in_face_interior(cv, sc); + Halfedge_handle he = Base::insert_in_face_interior(cv, sc); insert_edge_to_hash(he, cv); - return (he); + return he; } virtual Halfedge_handle insert_at_vertices(const X_monotone_curve_2& cv, Halfedge_handle hhandle, Halfedge_handle prev, Subcurve* sc, - bool &new_face_created) + bool& new_face_created) { Halfedge_handle res_he = Base::insert_at_vertices(cv, hhandle, prev, sc, new_face_created); insert_edge_to_hash(res_he, cv); - return (res_he); + return res_he; } - virtual Halfedge_handle insert_from_right_vertex - (const X_monotone_curve_2& cv, - Halfedge_handle he, - Subcurve* sc) + virtual Halfedge_handle insert_from_right_vertex(const X_monotone_curve_2& cv, + Halfedge_handle he, + Subcurve* sc) { - Halfedge_handle res_he = - Base::insert_from_right_vertex(cv, he, sc); + Halfedge_handle res_he = Base::insert_from_right_vertex(cv, he, sc); insert_edge_to_hash(res_he, cv); - return (res_he); + return res_he; } - virtual Halfedge_handle insert_from_left_vertex - (const X_monotone_curve_2& cv, - Halfedge_handle he, - Subcurve* sc) + virtual Halfedge_handle insert_from_left_vertex(const X_monotone_curve_2& cv, + Halfedge_handle he, + Subcurve* sc) { - Halfedge_handle res_he = - Base::insert_from_left_vertex(cv, he, sc); + Halfedge_handle res_he = Base::insert_from_left_vertex(cv, he, sc); insert_edge_to_hash(res_he, cv); - return (res_he); + return res_he; } - - private: - void insert_edge_to_hash(Halfedge_handle he, const X_monotone_curve_2& cv) { - const Comparison_result he_dir = - ((Arr_halfedge_direction)he->direction() == ARR_LEFT_TO_RIGHT) ? SMALLER : LARGER; + const Comparison_result he_dir = + ((Arr_halfedge_direction)he->direction() == ARR_LEFT_TO_RIGHT) ? + SMALLER : LARGER; const Comparison_result cv_dir = this->m_arr_access.arrangement().geometry_traits()-> compare_endpoints_xy_2_object()(cv); - if (he_dir == cv_dir) - { + if (he_dir == cv_dir) { (*m_edges_hash)[he] = cv.data().bc(); (*m_edges_hash)[he->twin()] = cv.data().twin_bc(); } - else - { + else { (*m_edges_hash)[he] = cv.data().twin_bc(); (*m_edges_hash)[he->twin()] = cv.data().bc(); } } - - }; -template -class Indexed_event : public BaseEvent_ +template +class Gps_agg_op_visitor : + public Gps_agg_op_base_visitor > { +public: + typedef Helper_ Helper; + typedef Arrangement_ Arrangement_2; + + typedef typename Helper::Geometry_traits_2 Geometry_traits_2; + typedef typename Helper::Event Event; + typedef typename Helper::Subcurve Subcurve; + private: + typedef Geometry_traits_2 Gt2; + typedef Arrangement_2 Arr; - unsigned int m_index; + typedef Gps_agg_op_visitor Self; + typedef typename Default::Get::type Visitor; + typedef Gps_agg_op_base_visitor Base; public: + typedef typename Base::Halfedge_handle Halfedge_handle; + typedef typename Base::Vertex_handle Vertex_handle; + typedef typename Gt2::X_monotone_curve_2 X_monotone_curve_2; + typedef typename Gt2::Point_2 Point_2; - Indexed_event () : - BaseEvent_(), - m_index (0) - {} - - unsigned int index () const - { - return (m_index); - } - - void set_index (unsigned int index) - { - m_index = index; - return; - } -}; - -template -class Gps_agg_op_visitor : - public Gps_agg_op_base_visitor -{ protected: - - typedef Arrangement_ Arrangement; - - typedef Gps_agg_op_base_visitor Base; - - typedef typename Base::SL_iterator SL_iterator; - typedef typename Base::Halfedge_handle Halfedge_handle; - typedef typename Base::Vertex_handle Vertex_handle; - typedef typename Base::SubCurveIter SubCurveIter; - typedef typename Base::SubCurveRevIter SubCurveRevIter; - typedef typename Traits::X_monotone_curve_2 X_monotone_curve_2; - typedef typename Traits::Point_2 Point_2; - -protected: - - unsigned int m_event_count; // The number of events so far. - std::vector *m_vertices_vec; // The vertices, sorted in - // ascending order. + unsigned int m_event_count; // The number of events so far. + std::vector* m_vertices_vec; // The vertices, sorted in + // ascending order. public: - - Gps_agg_op_visitor (Arrangement *arr, - typename Base::Edges_hash* hash, - std::vector* vertices_vec) : - Base (arr, hash), - m_event_count (0), - m_vertices_vec (vertices_vec) + Gps_agg_op_visitor(Arr* arr, typename Base::Edges_hash* hash, + std::vector* vertices_vec) : + Base(arr, hash), + m_event_count(0), + m_vertices_vec(vertices_vec) {} - void before_handle_event (Event* event) + void before_handle_event(Event* event) { - event->set_index (m_event_count); + event->set_index(m_event_count); m_event_count++; - - return; } - virtual Halfedge_handle - insert_in_face_interior (const X_monotone_curve_2& cv, - Subcurve* sc) + virtual Halfedge_handle + insert_in_face_interior(const X_monotone_curve_2& cv, Subcurve* sc) { Halfedge_handle res_he = Base::insert_in_face_interior(cv, sc); // We now have a halfedge whose source vertex is associated with the // last event and whose target vertex is associated with the current event: - Event *curr_event = reinterpret_cast(this->current_event()); - Event *last_event = reinterpret_cast((sc)->last_event()); + Event* curr_event = this->current_event(); + Event* last_event = (sc)->last_event(); - CGAL_assertion ((Arr_halfedge_direction)res_he->direction() == ARR_LEFT_TO_RIGHT); - _insert_vertex (curr_event, res_he->target()); - _insert_vertex (last_event, res_he->source()); + CGAL_assertion((Arr_halfedge_direction)res_he->direction() == + ARR_LEFT_TO_RIGHT); + _insert_vertex(curr_event, res_he->target()); + _insert_vertex(last_event, res_he->source()); - return (res_he); + return res_he; } - virtual Halfedge_handle - insert_from_right_vertex (const X_monotone_curve_2& cv, - Halfedge_handle he, - Subcurve* sc) + virtual Halfedge_handle insert_from_right_vertex(const X_monotone_curve_2& cv, + Halfedge_handle he, + Subcurve* sc) { - Halfedge_handle res_he = Base::insert_from_right_vertex (cv, he, sc); + Halfedge_handle res_he = Base::insert_from_right_vertex(cv, he, sc); // We now have a halfedge whose target vertex is associated with the // last event (we have already dealt with its source vertex). - Event *last_event = reinterpret_cast((sc)->last_event()); - CGAL_assertion ((Arr_halfedge_direction)res_he->direction() == ARR_RIGHT_TO_LEFT); - _insert_vertex (last_event, res_he->target()); - - return (res_he); + Event* last_event = (sc)->last_event(); + CGAL_assertion((Arr_halfedge_direction)res_he->direction() == + ARR_RIGHT_TO_LEFT); + _insert_vertex(last_event, res_he->target()); + return res_he; } - virtual Halfedge_handle - insert_from_left_vertex (const X_monotone_curve_2& cv, - Halfedge_handle he, - Subcurve* sc) + virtual Halfedge_handle insert_from_left_vertex(const X_monotone_curve_2& cv, + Halfedge_handle he, + Subcurve* sc) { - Halfedge_handle res_he = Base::insert_from_left_vertex (cv, he, sc); + Halfedge_handle res_he = Base::insert_from_left_vertex(cv, he, sc); // We now have a halfedge whose target vertex is associated with the - // current event (we have already dealt with its source vertex). - Event *curr_event = reinterpret_cast(this->current_event()); + // current event(we have already dealt with its source vertex). + Event* curr_event = this->current_event(); - CGAL_assertion ((Arr_halfedge_direction)res_he->direction() == ARR_LEFT_TO_RIGHT); + CGAL_assertion((Arr_halfedge_direction)res_he->direction() == + ARR_LEFT_TO_RIGHT); _insert_vertex (curr_event, res_he->target()); - - return (res_he); + return res_he; } private: - - void _insert_vertex (const Event* event, - Vertex_handle v) + void _insert_vertex(const Event* event, Vertex_handle v) { - const unsigned int index = event->index(); - - if (index >= m_vertices_vec->size()) - m_vertices_vec->resize (2 * (index + 1)); - + const unsigned int index = event->index(); + if (index >= m_vertices_vec->size()) m_vertices_vec->resize(2 * (index + 1)); (*m_vertices_vec)[index] = v; - return; } }; -} //namespace CGAL +} // namespace CGAL #endif diff --git a/Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Gps_polygon_simplifier.h b/Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Gps_polygon_simplifier.h index b512784de04..562a381c35f 100644 --- a/Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Gps_polygon_simplifier.h +++ b/Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Gps_polygon_simplifier.h @@ -19,90 +19,97 @@ // // Author(s) : Baruch Zukerman -#ifndef CGAL_GPS_POLYGON_SIMPILFIER_H -#define CGAL_GPS_POLYGON_SIMPILFIER_H +#ifndef CGAL_BSO_2_GPS_POLYGON_SIMPILFIER_H +#define CGAL_BSO_2_GPS_POLYGON_SIMPILFIER_H #include - #include -#include -#include -#include - -#include +#include +#include +#include #include #include - #include #include #include namespace CGAL { -template -class Gps_polygon_simplifier -{ - typedef Arrangement_ Arrangement_2; - typedef typename Arrangement_2::Geometry_traits_2 Traits_2; - typedef typename Traits_2::Curve_const_iterator Curve_const_iterator; - typedef typename Traits_2::Polygon_2 Polygon_2; - typedef typename Traits_2::Polygon_with_holes_2 Polygon_with_holes_2; - typedef typename Traits_2::Construct_curves_2 Construct_curves_2; +namespace Ss2 = Surface_sweep_2; - typedef Gps_simplifier_traits Meta_traits; - typedef typename Meta_traits::Curve_data Curve_data; - typedef typename Meta_traits::X_monotone_curve_2 Meta_X_monotone_curve_2; - typedef typename Arrangement_2::Halfedge_handle Halfedge_handle; - typedef typename Arrangement_2::Halfedge_iterator Halfedge_iterator; - typedef typename Arrangement_2::Face_handle Face_handle; - typedef typename Arrangement_2::Face_iterator Face_iterator; - typedef typename Arrangement_2::Edge_iterator Edge_iterator; - typedef typename Arrangement_2::Vertex_handle Vertex_handle; - typedef typename Arrangement_2::Ccb_halfedge_const_circulator +template +class Gps_polygon_simplifier { + typedef Arrangement_ Arrangement_2; + + typedef typename Arrangement_2::Geometry_traits_2 Geometry_traits_2; + typedef typename Arrangement_2::Topology_traits Topology_traits; + + typedef Arrangement_2 Arr; + typedef Geometry_traits_2 Gt2; + typedef Topology_traits Tt; + + typedef typename Gt2::Curve_const_iterator Curve_const_iterator; + typedef typename Gt2::Polygon_2 Polygon_2; + typedef typename Gt2::Polygon_with_holes_2 Polygon_with_holes_2; + typedef typename Gt2::Construct_curves_2 Construct_curves_2; + + typedef Gps_simplifier_traits Mgt2; + typedef typename Mgt2::Curve_data Curve_data; + typedef typename Mgt2::X_monotone_curve_2 Meta_X_monotone_curve_2; + + typedef typename Arr::Halfedge_handle Halfedge_handle; + typedef typename Arr::Halfedge_iterator Halfedge_iterator; + typedef typename Arr::Face_handle Face_handle; + typedef typename Arr::Face_iterator Face_iterator; + typedef typename Arr::Edge_iterator Edge_iterator; + typedef typename Arr::Vertex_handle Vertex_handle; + typedef typename Arr::Ccb_halfedge_const_circulator Ccb_halfedge_const_circulator; - typedef typename Arrangement_2::Ccb_halfedge_circulator - Ccb_halfedge_circulator; - typedef Arr_construction_subcurve Subcurve; - typedef Arr_construction_event Event; + typedef typename Arr::Ccb_halfedge_circulator Ccb_halfedge_circulator; + typedef typename Arr::Allocator Allocator; - typedef Gps_agg_op_base_visitor Visitor; + // We obtain a proper helper type from the topology traits of the arrangement. + // However, the arrangement is parametrized with the Gt2 geometry traits, + // while we need the Mgt2 geometry traits (which derives from Gt2). + // Thus, we rebind the helper. + // We cannot parameterized the arrangement with the Mgt2 geometry + // traits to start with, because it extends the curve type with arrangement + // dependent types. (It is parameterized with the arrangement type.) + typedef Indexed_event Event; + typedef Arr_construction_subcurve + Subcurve; + typedef typename Tt::template Construction_helper + Helper_tmp; + typedef typename Helper_tmp::template rebind::other + Helper; + typedef Gps_agg_op_base_visitor Visitor; + typedef Ss2::Surface_sweep_2 Surface_sweep_2; - typedef CGAL::Sweep_line_2 Sweep_line_2; + typedef Unique_hash_map + Edges_hash; - typedef Unique_hash_map Edges_hash; - - typedef Unique_hash_map Faces_hash; - typedef Gps_bfs_join_visitor Bfs_visitor; - typedef Gps_bfs_scanner Bfs_scanner; + typedef Unique_hash_map Faces_hash; + typedef Gps_bfs_join_visitor Bfs_visitor; + typedef Gps_bfs_scanner Bfs_scanner; protected: - Arrangement_2* m_arr; - const Meta_traits* m_traits; - bool m_own_traits; - Visitor m_visitor; - Sweep_line_2 m_sweep_line; - Edges_hash m_edges_hash; // maps halfedge to its BC (boundary counter) - Faces_hash m_faces_hash; // maps face to its IC (inside count) + Arr* m_arr; + const Mgt2* m_traits; + bool m_own_traits; + Visitor m_visitor; + Surface_sweep_2 m_surface_sweep; + Edges_hash m_edges_hash; // maps halfedge to its BC (boundary counter) + Faces_hash m_faces_hash; // maps face to its IC (inside count) public: - /*! Constructor. */ - Gps_polygon_simplifier(Arrangement_2& arr, const Traits_2& tr) : + /*! Construct. */ + Gps_polygon_simplifier(Arr& arr, const Gt2& tr) : m_arr(&arr), - m_traits(new Meta_traits(tr)), + m_traits(new Mgt2(tr)), m_own_traits(true), m_visitor(&arr, &m_edges_hash), - m_sweep_line(m_traits, &m_visitor) + m_surface_sweep(m_traits, &m_visitor) {} /*! Destructor. */ @@ -117,32 +124,30 @@ public: void simplify(const Polygon_2& pgn) { Construct_curves_2 ctr_curves = - reinterpret_cast(m_traits)->construct_curves_2_object(); + reinterpret_cast(m_traits)->construct_curves_2_object(); std::list curves_list; - std::pair itr_pair = ctr_curves(pgn); + std::pair itr_pair = + ctr_curves(pgn); unsigned int index = 0; - for(Curve_const_iterator itr = itr_pair.first; - itr != itr_pair.second; - ++itr, ++index) + for (Curve_const_iterator itr = itr_pair.first; itr != itr_pair.second; + ++itr, ++index) { Curve_data cv_data(1, 0, index); curves_list.push_back(Meta_X_monotone_curve_2(*itr, cv_data)); } m_traits->set_polygon_size(static_cast(curves_list.size())); - m_sweep_line.sweep(curves_list.begin(), curves_list.end()); + m_surface_sweep.sweep(curves_list.begin(), curves_list.end()); // we use the first face with out outer ccbs. This assumpsion should // be fixed when we can make a face with no outer ccb to a face with // outer ccb. Face_iterator it; for (it = m_arr->faces_begin(); it != m_arr->faces_end(); ++it) - if (it->number_of_outer_ccbs() == 0) - break; + if (it->number_of_outer_ccbs() == 0) break; CGAL_assertion(it != m_arr->faces_end()); m_faces_hash[it] = 0; @@ -153,17 +158,15 @@ public: visitor.after_scan(*m_arr); } - const Arrangement_2& arrangement() const - { - return (*m_arr); - } - - Arrangement_2& arrangement() - { - return (*m_arr); - } + /*! Obtain the arrangement. + */ + const Arr& arrangement() const { return (*m_arr); } + /*! Obtain the arrangement. + */ + Arr& arrangement() { return (*m_arr); } }; -} //namespace CGAL + +} // namespace CGAL #endif diff --git a/Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Gps_polygon_validation.h b/Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Gps_polygon_validation.h index 8e57094b357..2fbc2f20981 100644 --- a/Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Gps_polygon_validation.h +++ b/Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Gps_polygon_validation.h @@ -22,35 +22,30 @@ // Boris Kozorovitzky // Guy Zucker -#ifndef CGAL_GPS_POLYGON_VALIDATION_2_H -#define CGAL_GPS_POLYGON_VALIDATION_2_H +#ifndef CGAL_BSO_2_GPS_POLYGON_VALIDATION_2_H +#define CGAL_BSO_2_GPS_POLYGON_VALIDATION_2_H #include - #include #include #include - #include -#include -#include -#include -#include +#include +#include #include #include - #include #include #include - namespace CGAL { -/*Arrangement is templated with extended face dcel*/ +namespace Ss2 = Surface_sweep_2; + template -class ValidationOverlayTraits : +class Validation_overlay_traits : public CGAL::Arr_default_overlay_traits { public: @@ -80,14 +75,12 @@ public: } public: - ValidationOverlayTraits() : hole_overlap(false) {} - bool getHoleOverlap() { - return hole_overlap; - } - void setHoleOverlap(bool b) { - hole_overlap = b; - return; - } + Validation_overlay_traits() : hole_overlap(false) {} + + bool getHoleOverlap() { return hole_overlap; } + + void setHoleOverlap(bool b) { hole_overlap = b; } + private: mutable bool hole_overlap; }; @@ -96,24 +89,30 @@ private: * A visitor used for checking whether the edges of a polygon are * non-intersecting. */ -template +template class Gps_polygon_validation_visitor : - public Sweep_line_empty_visitor + public Ss2::Default_visitor, + GeometryTraits_2, Allocator_> { +public: + typedef GeometryTraits_2 Geometry_traits_2; + typedef Allocator_ Allocator; + private: - typedef ArrTraits_ Traits_2; - typedef Gps_polygon_validation_visitor Self; - typedef typename Traits_2::X_monotone_curve_2 X_monotone_curve_2; - typedef typename Traits_2::Point_2 Point_2; - - typedef Sweep_line_empty_visitor Base; - typedef typename Base::Event Event; - typedef typename Base::Subcurve Subcurve; - typedef typename Base::Status_line_iterator SL_iterator; - - typedef Basic_sweep_line_2 Sweep_line; + typedef Geometry_traits_2 Gt2; + typedef Gps_polygon_validation_visitor + Self; + typedef Ss2::Default_visitor Base; public: + typedef typename Gt2::X_monotone_curve_2 X_monotone_curve_2; + typedef typename Gt2::Point_2 Point_2; + + typedef typename Base::Event Event; + typedef typename Base::Subcurve Subcurve; + typedef typename Base::Status_line_iterator SL_iterator; + enum Error_code { ERROR_NONE = 0, ERROR_EDGE_INTERSECTION, @@ -131,8 +130,8 @@ public: template void sweep(XCurveIterator begin, XCurveIterator end) { - //Perform the sweep - reinterpret_cast(this->m_sweep_line)->sweep(begin, end); + // Perform the sweep + this->m_surface_sweep->sweep(begin, end); } bool after_handle_event(Event* event, SL_iterator, bool) @@ -140,25 +139,26 @@ public: if (event->is_intersection()) { m_error_code = ERROR_EDGE_INTERSECTION; m_is_valid = false; - reinterpret_cast(this->m_sweep_line)->stop_sweep(); + this->m_surface_sweep->stop_sweep(); } else if (event->is_weak_intersection()) { m_error_code = ERROR_EDGE_VERTEX_INTERSECTION; m_is_valid = false; - reinterpret_cast(this->m_sweep_line)->stop_sweep(); + this->m_surface_sweep->stop_sweep(); } else if (event->is_overlap()) { m_error_code = ERROR_EDGE_OVERLAP; m_is_valid = false; - reinterpret_cast(this->m_sweep_line)->stop_sweep(); - } else { + this->m_surface_sweep->stop_sweep(); + } + else { if (m_is_s_simple && (event->number_of_right_curves() + event->number_of_left_curves()) != 2) { m_error_code = ERROR_VERTEX_INTERSECTION; m_is_valid = false; - reinterpret_cast(this->m_sweep_line)->stop_sweep(); + this->m_surface_sweep->stop_sweep(); } } return true; @@ -175,7 +175,6 @@ private: Error_code m_error_code; }; - //Traits_2 templates the General_polygon_set_2 Traits. //These include types for polygon and PWH. template @@ -220,12 +219,12 @@ bool is_closed_polygon(const typename Traits_2::Polygon_2& pgn, } // Make sure that the last target equals the first source. - if (equal_func (construct_vertex_func (*curr, 0), - construct_vertex_func (*curr, 1))) + if (equal_func(construct_vertex_func (*curr, 0), + construct_vertex_func (*curr, 1))) return false; - if (! equal_func (construct_vertex_func (*curr, 1), - construct_vertex_func (*begin, 0))) + if (! equal_func(construct_vertex_func (*curr, 1), + construct_vertex_func (*begin, 0))) return false; return true; @@ -236,16 +235,17 @@ template bool is_simple_polygon(const typename Traits_2::Polygon_2& pgn, const Traits_2& traits) { - typedef typename Traits_2::Curve_const_iterator Curve_const_iterator; - typedef std::pair Cci_pair; + typedef typename Traits_2::Curve_const_iterator Curve_const_iterator; + typedef std::pair + Cci_pair; // Sweep the boundary curves and look for intersections. - typedef Gps_polygon_validation_visitor Visitor; - typedef Sweep_line_2 Sweep_line; + typedef Gps_polygon_validation_visitor Visitor; + typedef Ss2::Surface_sweep_2 Surface_sweep; - Cci_pair itr_pair = traits.construct_curves_2_object()(pgn); - Visitor visitor; - Sweep_line sweep_line (&traits, &visitor); + Cci_pair itr_pair = traits.construct_curves_2_object()(pgn); + Visitor visitor; + Surface_sweep surface_sweep(&traits, &visitor); visitor.sweep(itr_pair.first, itr_pair.second); if (!visitor.is_valid()) { @@ -320,7 +320,6 @@ bool is_valid_polygon(const typename Traits_2::Polygon_2& pgn, return true; } - template bool is_closed_polygon_with_holes(const typename Traits_2::Polygon_with_holes_2& pgn, @@ -337,7 +336,7 @@ is_closed_polygon_with_holes(const typename Traits_2::Polygon_with_holes_2& pgn, } // templated point location version -template +template bool is_crossover_outer_boundary(const typename Traits_2::Polygon_with_holes_2& pgn, const Traits_2& traits, PointLocation& pl) @@ -458,17 +457,16 @@ is_crossover_outer_boundary(const typename Traits_2::Polygon_with_holes_2& pgn, */ typename Arrangement_2::Face_handle fh = (*he_path.begin())->twin()->face(); for (he_itr = he_path.begin(); he_itr != he_path.end(); he_itr++) { - if ((*he_itr)->twin()->face() != fh) - return false; + if ((*he_itr)->twin()->face() != fh) return false; } return true; } template -bool is_crossover_outer_boundary -(const typename Traits_2::Polygon_with_holes_2& pgn, const Traits_2& traits) +bool +is_crossover_outer_boundary(const typename Traits_2::Polygon_with_holes_2& pgn, + const Traits_2& traits) { - typedef CGAL::Gps_default_dcel Dcel; // IMPORTATNT! TODO! // Currently the topology traits is the bounded planar traits. This @@ -490,25 +488,25 @@ template bool is_relatively_simple_polygon_with_holes (const typename Traits_2::Polygon_with_holes_2& pgn, const Traits_2& traits) { - typedef typename Traits_2::Curve_const_iterator Curve_const_iterator; - typedef std::pair Cci_pair; - typedef typename Traits_2::Construct_curves_2 Construct_curves_2; + typedef typename Traits_2::Curve_const_iterator Curve_const_iterator; + typedef std::pair + Cci_pair; + typedef typename Traits_2::Construct_curves_2 Construct_curves_2; - typedef typename Traits_2::X_monotone_curve_2 X_monotone_curve_2; - typedef Gps_polygon_validation_visitor Visitor; - typedef Sweep_line_2 Sweep_line; - typedef typename Traits_2::Polygon_with_holes_2 Polygon_with_holes_2; + typedef typename Traits_2::X_monotone_curve_2 X_monotone_curve_2; + typedef Gps_polygon_validation_visitor Visitor; + typedef Ss2::Surface_sweep_2 Surface_sweep; + typedef typename Traits_2::Polygon_with_holes_2 Polygon_with_holes_2; Construct_curves_2 construct_curves_func = traits.construct_curves_2_object(); // Construct a container of all outer boundary curves. - Cci_pair itr_pair = construct_curves_func (pgn.outer_boundary()); + Cci_pair itr_pair = construct_curves_func (pgn.outer_boundary()); std::list outer_curves; - std::copy (itr_pair.first, itr_pair.second, - std::back_inserter(outer_curves)); + std::copy(itr_pair.first, itr_pair.second, std::back_inserter(outer_curves)); // Create visitor and sweep to verify outer boundary is relatively simple - Visitor relative_visitor(false); - Sweep_line sweep_line (&traits, &relative_visitor); - relative_visitor.sweep (outer_curves.begin(), outer_curves.end()); + Visitor relative_visitor(false); + Surface_sweep surface_sweep(&traits, &relative_visitor); + relative_visitor.sweep(outer_curves.begin(), outer_curves.end()); if (!relative_visitor.is_valid()) { switch (relative_visitor.error_code()) { case Visitor::ERROR_NONE: break; @@ -548,7 +546,8 @@ bool has_valid_orientation_polygon_with_holes { typedef Gps_traits_adaptor Traits_adapter_2; typedef typename Traits_2::Curve_const_iterator Curve_const_iterator; - typedef std::pair Cci_pair; + typedef std::pair + Cci_pair; typedef typename Traits_2::Construct_curves_2 Construct_curves_2; typedef typename Traits_adapter_2::Orientation_2 Check_orientation_2; @@ -560,10 +559,10 @@ bool has_valid_orientation_polygon_with_holes Check_orientation_2 check_orientation_func = traits_adapter.orientation_2_object(); // Check the orientation of the outer boundary. - Cci_pair itr_pair = construct_curves_func (pgn.outer_boundary()); + Cci_pair itr_pair = construct_curves_func(pgn.outer_boundary()); if ((itr_pair.first != itr_pair.second) && - (check_orientation_func (itr_pair.first, itr_pair.second) != + (check_orientation_func(itr_pair.first, itr_pair.second) != COUNTERCLOCKWISE)) { return false; @@ -573,10 +572,10 @@ bool has_valid_orientation_polygon_with_holes typename Polygon_with_holes_2::Hole_const_iterator hoit; for (hoit = pgn.holes_begin(); hoit != pgn.holes_end(); ++hoit) { - itr_pair = construct_curves_func (*hoit); + itr_pair = construct_curves_func(*hoit); if ((itr_pair.first != itr_pair.second) && - (check_orientation_func (itr_pair.first, itr_pair.second) != CLOCKWISE)) + (check_orientation_func(itr_pair.first, itr_pair.second) != CLOCKWISE)) { return false; } @@ -598,38 +597,38 @@ bool has_valid_orientation_polygon_with_holes * the boundary and the iterative loop will be stopped after a small number of * iterations. */ -template +template bool are_holes_and_boundary_pairwise_disjoint (const typename Traits_2::Polygon_with_holes_2& pwh, Traits_2& traits) { - typedef typename Traits_2::Curve_const_iterator Curve_const_iterator; - typedef std::pair Cci_pair; - typedef typename Traits_2::Construct_curves_2 Construct_curves_2; - - typedef CGAL::Gps_default_dcel Dcel; + typedef typename Traits_2::Curve_const_iterator Curve_const_iterator; + typedef std::pair + Cci_pair; + typedef typename Traits_2::Construct_curves_2 Construct_curves_2; + typedef CGAL::Gps_default_dcel Dcel; // IMPORTATNT! TODO! // Currently the topology traits is the bounded planar traits. This // should be replaced with a templated topology traits! typedef typename Default_planar_topology::Traits - Topology_traits; - + Topology_traits; typedef CGAL::Gps_on_surface_base_2 - Polygon_set_2; - typedef typename Polygon_set_2::Size Size; - typedef typename Traits_2::Polygon_2 Polygon_2; - typedef typename Traits_2::Polygon_with_holes_2 Polygon_with_holes_2; + Polygon_set_2; + typedef typename Polygon_set_2::Size Size; + typedef typename Traits_2::Polygon_2 Polygon_2; + typedef typename Traits_2::Polygon_with_holes_2 Polygon_with_holes_2; typedef typename Polygon_with_holes_2::Hole_const_iterator - Hole_const_iterator; - typedef typename Traits_2::X_monotone_curve_2 X_monotone_curve_2; - typedef std::pair - Cci_pair; - typedef typename Traits_2::Construct_curves_2 Construct_curves_2; + Hole_const_iterator; + typedef typename Traits_2::X_monotone_curve_2 X_monotone_curve_2; + typedef std::pair + Cci_pair; + typedef typename Traits_2::Construct_curves_2 Construct_curves_2; typedef typename Traits_2::Construct_general_polygon_with_holes_2 Construct_polygon_with_holes_2; - typedef Gps_polygon_validation_visitor Visitor; - typedef Sweep_line_2 Sweep_line ; - typedef typename Polygon_set_2::Arrangement_on_surface_2 Arrangement_2; + typedef Gps_polygon_validation_visitor Visitor; + typedef Ss2::Surface_sweep_2 Surface_sweep; + typedef typename Polygon_set_2::Arrangement_on_surface_2 + Arrangement_2; /* Should be perfored more efficeintly than using sweep and than * difference(). @@ -645,7 +644,7 @@ bool are_holes_and_boundary_pairwise_disjoint Hole_const_iterator hoit; // Construct a container of all boundary curves. Polygon_2 pgn2 = traits.construct_outer_boundary_object()(pwh); - Construct_curves_2 construct_curves_func; + Construct_curves_2 construct_curves_func; Cci_pair itr_pair = construct_curves_func(pgn2); std::list curves; @@ -662,7 +661,7 @@ bool are_holes_and_boundary_pairwise_disjoint // Perform the sweep and check for curve intersections on the interior. // Traits_2 traits; moved to top, needed also for boundary. Visitor visitor(false); - Sweep_line sweep_line(&traits, &visitor); + Surface_sweep surface_sweep(&traits, &visitor); visitor.sweep(curves.begin(), curves.end()); if (!visitor.is_valid()) return false; @@ -673,7 +672,7 @@ bool are_holes_and_boundary_pairwise_disjoint // functors for creating a pwh needed for inserting pgns into the arrangement // quickly Construct_polygon_with_holes_2 construct_pwh_functor = - traits.construct_polygon_with_holes_2_object() ; + traits.construct_polygon_with_holes_2_object(); for (hoit = pwh.holes_begin(); hoit != pwh.holes_end(); ++hoit) { Polygon_2 hole(*hoit); hole.reverse_orientation(); @@ -714,8 +713,8 @@ bool are_holes_and_boundary_pairwise_disjoint * (simple) polygon. */ - //Polygon_with_holes_2 boundary(pwh.outer_boundary(), fit, fit); - Polygon_with_holes_2 boundary = construct_pwh_functor(pwh.outer_boundary()); + // Polygon_with_holes_2 boundary(pwh.outer_boundary(), fit, fit); + Polygon_with_holes_2 boundary = construct_pwh_functor(pwh.outer_boundary()); // Unbounded outer boundaries contain all the holes and the holes were checked // and are OK. if (boundary.is_unbounded()) return true; @@ -727,7 +726,7 @@ bool are_holes_and_boundary_pairwise_disjoint * reasons, we use a customized overlay traits and perform an arrangement * overlay instead of difference */ - ValidationOverlayTraits valOverlayTraits; + Validation_overlay_traits valOverlayTraits; valOverlayTraits.setHoleOverlap(false); Polygon_set_2 gps2(traits); @@ -799,6 +798,6 @@ bool is_valid_unknown_polygon(const typename Traits_2::Polygon_2& pgn, const Traits_2& traits) { return is_valid_polygon(pgn, traits); } -} //namespace CGAL +} // namespace CGAL #endif diff --git a/Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Indexed_event.h b/Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Indexed_event.h new file mode 100644 index 00000000000..44301d93b4c --- /dev/null +++ b/Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Indexed_event.h @@ -0,0 +1,55 @@ +// Copyright (c) 2005 Tel-Aviv University (Israel). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// You can redistribute it and/or modify it under the terms of the GNU +// General Public License as published by the Free Software Foundation, +// either version 3 of the License, or (at your option) any later version. +// +// Licensees holding a valid commercial license may use this file in +// accordance with the commercial license agreement provided with the software. +// +// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Author(s) : Baruch Zukerman +// Ron Wein +// Efi Fogel + +#ifndef CGAL_BSO_2_INDEXED_VISITOR_H +#define CGAL_BSO_2_INDEXED_VISITOR_H + +#include + +#include + +namespace CGAL { + +/* \class Indexed_event + */ +template +class Indexed_event : + public Arr_construction_event_base< + GeometryTraits_2, + Arr_construction_subcurve, + Allocator_>, + Arrangement_> +{ +private: + unsigned int m_index; + +public: + Indexed_event() : m_index (0) {} + + unsigned int index() const { return (m_index); } + + void set_index(unsigned int index) { m_index = index; } +}; + +} // namespace CGAL + +#endif diff --git a/CGAL_ipelets/demo/CGAL_ipelets/arrangement.cpp b/CGAL_ipelets/demo/CGAL_ipelets/arrangement.cpp index 7642988c5ee..db7bb998fc0 100644 --- a/CGAL_ipelets/demo/CGAL_ipelets/arrangement.cpp +++ b/CGAL_ipelets/demo/CGAL_ipelets/arrangement.cpp @@ -15,7 +15,7 @@ // $URL$ // $Id$ // SPDX-License-Identifier: LGPL-3.0+ -// +// // // Author(s) : Sebastien Loriot, Sylvain Pion @@ -29,9 +29,9 @@ #endif #include #include -#include +#include #include -#include +#include namespace CGAL_argt{ @@ -44,7 +44,7 @@ typedef std::list Curve_list; typedef std::list X_monotone_list; const std::string sublabel[] = { - "Segmentation","Help" + "Segmentation","Help" }; const std::string helpmsg[] = { @@ -52,7 +52,7 @@ const std::string helpmsg[] = { }; -class ArrPolyIpelet +class ArrPolyIpelet : public CGAL::Ipelet_base{ public: ArrPolyIpelet() @@ -68,12 +68,12 @@ void ArrPolyIpelet::protected_run(int fn){ X_monotone_list output_curves; Curve_list input_curves; - //Argt + //Argt std::list sg_list; std::list cir_list; std::list pol_list; std::list arc_list; - + read_active_objects( CGAL::dispatch_or_drop_output( std::back_inserter(pol_list), @@ -87,13 +87,13 @@ void ArrPolyIpelet::protected_run(int fn){ for (std::list::iterator it=pol_list.begin();it!=pol_list.end();++it) for(Polygon_2::Edge_const_iterator edge_it=it->edges_begin();edge_it!=it->edges_end();++edge_it) input_curves.push_back(Curve_2(edge_it->point(0),edge_it->point(1))); - + for (std::list::iterator it=sg_list.begin();it!=sg_list.end();++it) input_curves.push_back(Curve_2(it->point(0),it->point(1))); - + for (std::list::iterator it=cir_list.begin();it!=cir_list.end();++it) input_curves.push_back(Curve_2(it->center(),sqrt(CGAL::to_double(it->squared_radius())))); - + for (std::list::iterator it=arc_list.begin();it!=arc_list.end();++it) input_curves.push_back( Curve_2( CGAL::cpp11::get<0>(*it).center(), @@ -106,10 +106,10 @@ void ArrPolyIpelet::protected_run(int fn){ Traits T; CGAL::compute_subcurves(input_curves.begin(),input_curves.end(),std::back_inserter(output_curves),false,T); - - + + for (X_monotone_list::iterator it=output_curves.begin();it!=output_curves.end();++it){ Point_2 S(CGAL::to_double(it->source().x()),CGAL::to_double(it->source().y())); Point_2 T(CGAL::to_double(it->target().x()),CGAL::to_double(it->target().y())); diff --git a/Documentation/doc/Customizations.txt b/Documentation/doc/Customizations.txt index f348d3da698..7523551114f 100644 --- a/Documentation/doc/Customizations.txt +++ b/Documentation/doc/Customizations.txt @@ -17,14 +17,14 @@ The package overview is build by having a special command that is filtered by the python script pkglist_filter.py. A command has to be of the form \package_listing{PKG_NAME}, where -PKG_NAME cannot contain a closing }. +PKG_NAME cannot contain a closing }. The command is replaced by the text between the two delimiters PkgDescBegin and PkgDescEnd in the file ../PKG_NAME/doc/PKG_NAME/PackageDescription.txt If PKG_NAME is of the form A/B the selected file is ../A/doc/B/PackageDescription.txt. This is to support packages like -Sweep_line_2 and TDS_2 which don't reside in their own packages in the SCM. +TDS_2, which don't reside in their own packages in the SCM. ### Footnotes ### @@ -65,7 +65,7 @@ All of it is in `header.html` and `hacks.js`. # Things that would be nice to have # ## Search ## -The search function could be better: +The search function could be better: - member functions could be removed - global functions could be searchable - package codenames could be supported @@ -83,4 +83,3 @@ try. ## Package Overview ## Build the Package Overview with the help of the Build System. - diff --git a/Documentation/doc/Documentation/dependencies b/Documentation/doc/Documentation/dependencies index 6bb4323622a..b2d0fad9785 100644 --- a/Documentation/doc/Documentation/dependencies +++ b/Documentation/doc/Documentation/dependencies @@ -57,7 +57,7 @@ Principal_component_analysis STL_Extension Skin_surface_3 Snap_rounding_2 -Sweep_line_2 +Surface_sweep_2 Arrangement_on_surface_2 Boolean_set_operations_2 TDS_2 @@ -67,7 +67,7 @@ Three Triangulation_3 Triangulation Ridges_3 -Point_set_3 +Point_set_3 Point_set_processing_3 Point_set_shape_detection_3 Polyline_simplification_2 diff --git a/Documentation/doc/Documentation/packages.txt b/Documentation/doc/Documentation/packages.txt index 7895dbc9fe1..6afbefa3d81 100644 --- a/Documentation/doc/Documentation/packages.txt +++ b/Documentation/doc/Documentation/packages.txt @@ -67,7 +67,7 @@ h1 { \section PartArrangements Arrangements \package_listing{Arrangement_on_surface_2} -\package_listing{Sweep_line_2} +\package_listing{Surface_sweep_2} \package_listing{Snap_rounding_2} \package_listing{Envelope_2} \package_listing{Envelope_3} diff --git a/Installation/cmake/modules/list_of_documented_headers.cmake b/Installation/cmake/modules/list_of_documented_headers.cmake index f1947ec799d..e01ca994878 100644 --- a/Installation/cmake/modules/list_of_documented_headers.cmake +++ b/Installation/cmake/modules/list_of_documented_headers.cmake @@ -823,7 +823,7 @@ CGAL/Surface_mesh/Surface_mesh.h CGAL/Surface_mesh_traits_generator_3.h CGAL/Surface_mesh_vertex_base_3.h CGAL/surface_neighbor_coordinates_3.h -CGAL/Sweep_line_2_algorithms.h +CGAL/Surface_Sweep_2_algorithms.h CGAL/tags.h CGAL/Taucs_solver_traits.h CGAL/Tetrahedron_3.h diff --git a/Installation/include/CGAL/config.h b/Installation/include/CGAL/config.h index 69f851441aa..ec672540645 100644 --- a/Installation/include/CGAL/config.h +++ b/Installation/include/CGAL/config.h @@ -3,7 +3,7 @@ // ETH Zurich (Switzerland), // INRIA Sophia-Antipolis (France), // Max-Planck-Institute Saarbruecken (Germany), -// and Tel-Aviv University (Israel). All rights reserved. +// and Tel-Aviv University (Israel). All rights reserved. // // This file is part of CGAL (www.cgal.org); you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public License as @@ -19,9 +19,10 @@ // $URL$ // $Id$ // SPDX-License-Identifier: LGPL-3.0+ -// // -// Author(s) : Wieger Wesselink +// +// +// Author(s) : Wieger Wesselink // Michael Hoffmann // Sylvain Pion // Laurent Rineau @@ -106,7 +107,7 @@ # define BOOST_TT_HAS_POST_INCREMENT_HPP_INCLUDED #endif -// The following header file defines among other things BOOST_PREVENT_MACRO_SUBSTITUTION +// The following header file defines among other things BOOST_PREVENT_MACRO_SUBSTITUTION #include #include @@ -240,6 +241,10 @@ || (BOOST_VERSION < 103600) #define CGAL_CFG_NO_CPP0X_EXPLICIT_CONVERSION_OPERATORS 1 #endif +#if defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) || \ + defined(BOOST_NO_TEMPLATE_ALIASES) || (BOOST_VERSION < 103900) +#define CGAL_CFG_NO_CPP0X_TEMPLATE_ALIASES 1 +#endif // Some random list to let us write C++11 without thinking about // each feature we are using. @@ -288,7 +293,7 @@ #define CGAL_VERSION_NUMBER(x,y,z) (1000001 + 10000*x + 100*y + 10*z) * 1000 #ifndef CGAL_NO_DEPRECATED_CODE -#define CGAL_BEGIN_NAMESPACE namespace CGAL { +#define CGAL_BEGIN_NAMESPACE namespace CGAL { #define CGAL_END_NAMESPACE } #endif @@ -400,10 +405,10 @@ #endif //-------------------------------------------------------------------// -// When the global min and max are no longer defined (as macros) -// because of NOMINMAX flag definition, we define our own global +// When the global min and max are no longer defined (as macros) +// because of NOMINMAX flag definition, we define our own global // min/max functions to make the Microsoft headers compile. (afxtempl.h) -// Users that does not want the global min/max +// Users that does not want the global min/max // should define CGAL_NOMINMAX //-------------------------------------------------------------------// #include @@ -425,7 +430,7 @@ using std::max; # define CGAL_PRETTY_FUNCTION __FUNCSIG__ #elif defined __GNUG__ # define CGAL_PRETTY_FUNCTION __PRETTY_FUNCTION__ -#else +#else # define CGAL_PRETTY_FUNCTION __func__ // with sunpro, this requires -features=extensions #endif diff --git a/Installation/include/CGAL/license/Sweep_line_2.h b/Installation/include/CGAL/license/Surface_sweep_2.h similarity index 100% rename from Installation/include/CGAL/license/Sweep_line_2.h rename to Installation/include/CGAL/license/Surface_sweep_2.h diff --git a/Installation/include/CGAL/license/gpl_package_list.txt b/Installation/include/CGAL/license/gpl_package_list.txt index bf36cf2c59d..46f5b172373 100644 --- a/Installation/include/CGAL/license/gpl_package_list.txt +++ b/Installation/include/CGAL/license/gpl_package_list.txt @@ -77,7 +77,7 @@ Surface_mesh_segmentation Triangulated Surface Mesh Segmentation Surface_mesh_shortest_path Triangulated Surface Mesh Shortest Paths Surface_mesh_simplification Triangulated Surface Mesh Simplification Surface_mesh_skeletonization Triangulated Surface Mesh Skeletonization -Sweep_line_2 2D Intersection of Curves +Surface_sweep_2 2D Intersection of Curves TDS_2 2D Triangulation Data Structure TDS_3 3D Triangulation Data Structure Three Three diff --git a/Snap_rounding_2/doc/Snap_rounding_2/dependencies b/Snap_rounding_2/doc/Snap_rounding_2/dependencies index 1602b748d84..bf4cf65a566 100644 --- a/Snap_rounding_2/doc/Snap_rounding_2/dependencies +++ b/Snap_rounding_2/doc/Snap_rounding_2/dependencies @@ -5,5 +5,5 @@ Algebraic_foundations Circulator Stream_support Arrangement_on_surface_2 -Sweep_line_2 +Surface_sweep_2 Spatial_searching diff --git a/Snap_rounding_2/include/CGAL/Snap_rounding_2.h b/Snap_rounding_2/include/CGAL/Snap_rounding_2.h index b098833be6b..d9ef472e821 100644 --- a/Snap_rounding_2/include/CGAL/Snap_rounding_2.h +++ b/Snap_rounding_2/include/CGAL/Snap_rounding_2.h @@ -15,9 +15,10 @@ // $URL$ // $Id$ // SPDX-License-Identifier: GPL-3.0+ -// +// // // author(s) : Eli Packer + #ifndef CGAL_SNAP_ROUNDING_2_H #define CGAL_SNAP_ROUNDING_2_H @@ -29,7 +30,7 @@ #include #include #include -#include +#include #include #include #include @@ -78,7 +79,7 @@ private: typedef typename Traits::Segment_2 Segment_2; typedef typename Traits::Point_2 Point_2; typedef CGAL::Segment_data Segment_data; - + private: // p is the center of the hot pixel Point_2 p; @@ -156,7 +157,7 @@ private: typedef std::list Segment_data_list; typedef CGAL::Hot_pixel_dir_cmp Hot_pixel_dir_cmp; typedef std::set Hot_pixel_set; - + public: // friend class Segment_data; // friend class Hot_pixel; @@ -175,7 +176,7 @@ public: NT pixel_size, bool int_output, bool do_isr, Segment_data_list & seg_list, Multiple_kd_tree * mul_kd_tree); - + private: Traits m_gt; @@ -245,7 +246,7 @@ void Segment_data::determine_direction(SEG_Direction & seg_dir) Compare_x_2 compare_x = m_gt.compare_x_2_object(); Compare_y_2 compare_y = m_gt.compare_y_2_object(); - + Comparison_result cx = compare_x(p, q); Comparison_result cy = compare_y(p, q); @@ -332,7 +333,7 @@ bool Hot_pixel::intersect_left(const Segment_2 & seg, { typedef typename Traits_::Compare_y_2 Compare_y_2; typedef typename Traits_::Construct_vertex_2 Construct_vertex_2; - + Object result; Point_2 p; Segment_2 s; @@ -342,7 +343,7 @@ bool Hot_pixel::intersect_left(const Segment_2 & seg, if (assign(p, result)) { Compare_y_2 compare_y = m_gt.compare_y_2_object(); Construct_vertex_2 construct_vertex = m_gt.construct_vertex_2_object(); - + Comparison_result c_p = compare_y(p, p_up); Comparison_result c_target = compare_y(construct_vertex(seg, 1), p_up); Comparison_result c_source = compare_y(construct_vertex(seg, 0), p_up); @@ -364,17 +365,17 @@ bool Hot_pixel::intersect_right(const Segment_2 & seg, typedef typename Traits_::Compare_x_2 Compare_x_2; typedef typename Traits_::Construct_vertex_2 Construct_vertex_2; - Object result; + Object result; Point_2 p; Segment_2 s; - + result = intersection(seg, *right_seg); if (assign(p,result)) { // bottom right point was checked in intersect_bot Compare_y_2 compare_y = m_gt.compare_y_2_object(); Construct_vertex_2 construct_vertex = m_gt.construct_vertex_2_object(); - + Comparison_result c1 = compare_y(p, p_up); Comparison_result c2 = compare_y(p, p_down); @@ -392,7 +393,7 @@ bool Hot_pixel::intersect_right(const Segment_2 & seg, Compare_x_2 compare_x = m_gt.compare_x_2_object(); Comparison_result c_target = compare_x(p_right, trg); Comparison_result c_source = compare_x(p_right, src); - + return (((seg_dir == SEG_LEFT || seg_dir == SEG_DOWN_LEFT || seg_dir == SEG_UP_LEFT) && c_target != EQUAL) || ((seg_dir == SEG_RIGHT || seg_dir == SEG_DOWN_RIGHT || @@ -408,7 +409,7 @@ bool Hot_pixel::intersect_bot(const Segment_2 & seg, { typedef typename Traits_::Compare_x_2 Compare_x_2; typedef typename Traits_::Construct_vertex_2 Construct_vertex_2; - + Object result; Point_2 p; Segment_2 s; @@ -418,12 +419,12 @@ bool Hot_pixel::intersect_bot(const Segment_2 & seg, if (assign(p,result)) { Compare_x_2 compare_x = m_gt.compare_x_2_object(); Construct_vertex_2 construct_vertex = m_gt.construct_vertex_2_object(); - + Comparison_result c_p = compare_x(p, p_right); Comparison_result c_target = compare_x(construct_vertex(seg, 1), p_right); Comparison_result c_source = compare_x(construct_vertex(seg, 0), p_right); - return(c_p != EQUAL || (seg_dir == SEG_UP_LEFT && c_target != EQUAL) || + return(c_p != EQUAL || (seg_dir == SEG_UP_LEFT && c_target != EQUAL) || (seg_dir == SEG_DOWN_RIGHT && c_source != EQUAL)); } else if (assign(s,result)) return(true); @@ -439,14 +440,14 @@ bool Hot_pixel::intersect_top(const Segment_2 & seg, typedef typename Traits_::Compare_x_2 Compare_x_2; typedef typename Traits_::Compare_y_2 Compare_y_2; typedef typename Traits_::Construct_vertex_2 Construct_vertex_2; - + Object result; Point_2 p; Segment_2 s; - + result = intersection(seg, *top_seg); - if (assign(p,result)) + if (assign(p,result)) { Compare_x_2 compare_x = m_gt.compare_x_2_object(); Compare_y_2 compare_y = m_gt.compare_y_2_object(); @@ -465,7 +466,7 @@ bool Hot_pixel::intersect_top(const Segment_2 & seg, seg_dir == SEG_DOWN_RIGHT) && c3 != EQUAL) || ((seg_dir == SEG_UP || seg_dir == SEG_UP_LEFT || seg_dir == SEG_UP_RIGHT) && c4 != EQUAL)); - } + } return(false); } @@ -490,7 +491,7 @@ operator()(const Hot_pixel * h1, const Hot_pixel * h2) const Compare_x_2 compare_x = m_gt.compare_x_2_object(); Compare_y_2 compare_y = m_gt.compare_y_2_object(); - + Comparison_result cx = compare_x(h1->get_center(), h2->get_center()); Comparison_result cy = compare_y(h1->get_center(), h2->get_center()); @@ -501,30 +502,30 @@ operator()(const Hot_pixel * h1, const Hot_pixel * h2) const // segment intersect template bool Hot_pixel_dir_cmp::operator ()(const Hot_pixel * h1, - const Hot_pixel * h2) + const Hot_pixel * h2) { typedef typename Traits_::Compare_x_2 Compare_x_2; typedef typename Traits_::Compare_y_2 Compare_y_2; Compare_x_2 compare_x = m_gt.compare_x_2_object(); Compare_y_2 compare_y = m_gt.compare_y_2_object(); - + Comparison_result cx = compare_x(h1->get_center(), h2->get_center()); Comparison_result cy = compare_y(h1->get_center(), h2->get_center()); SEG_Direction seg_dir = h1->get_direction(); // Point segment intersects only one pixel, thus ignored return((seg_dir == SEG_UP_RIGHT && (cx == SMALLER || (cx == EQUAL && - cy == SMALLER))) || - (seg_dir == SEG_UP_LEFT && (cx == LARGER || (cx == EQUAL && - cy == SMALLER))) || - (seg_dir == SEG_DOWN_RIGHT && (cx == SMALLER || (cx == EQUAL && + cy == SMALLER))) || + (seg_dir == SEG_UP_LEFT && (cx == LARGER || (cx == EQUAL && + cy == SMALLER))) || + (seg_dir == SEG_DOWN_RIGHT && (cx == SMALLER || (cx == EQUAL && cy == LARGER))) || (seg_dir == SEG_DOWN_LEFT && (cx == LARGER || (cx == EQUAL && - cy == LARGER))) || + cy == LARGER))) || (seg_dir == SEG_UP && cy == SMALLER) || - (seg_dir == SEG_DOWN && cy == LARGER) || - (seg_dir == SEG_LEFT && cx == LARGER) || + (seg_dir == SEG_DOWN && cy == LARGER) || + (seg_dir == SEG_LEFT && cx == LARGER) || (seg_dir == SEG_RIGHT && cx == SMALLER)); } @@ -540,7 +541,7 @@ find_hot_pixels_and_create_kd_trees(NT pixel_size, typedef typename std::list::iterator Segment_data_iter; typedef std::list Segment_list; typedef typename std::list::const_iterator Point_const_iter; - + typedef typename Traits::Construct_segment_2 Construct_segment_2; Construct_segment_2 construct_seg = m_gt.construct_segment_2_object(); @@ -577,7 +578,7 @@ find_hot_pixels_and_create_kd_trees(NT pixel_size, ++iter) { simple_seg_list.push_back(construct_seg(iter->source(), iter->target())); - } + } *mul_kd_tree = new Multiple_kd_tree(hot_pixels_list, number_of_kd_trees, simple_seg_list); } @@ -593,7 +594,7 @@ find_intersected_hot_pixels(Segment_data & seg, Multiple_kd_tree * mul_kd_tree) { typedef typename std::list::iterator Hot_pixel_iter; - + Hot_pixel_iter iter; SEG_Direction seg_dir; @@ -601,10 +602,10 @@ find_intersected_hot_pixels(Segment_data & seg, seg.determine_direction(seg_dir); number_of_intersections = 0; std::list hot_pixels_list; - + mul_kd_tree->get_intersecting_points(hot_pixels_list, Segment_2(seg.segment()), pixel_size); - + for (iter = hot_pixels_list.begin();iter != hot_pixels_list.end();++iter) { if ((*iter)->intersect(seg,seg_dir)) { (*iter)->set_direction(seg_dir); @@ -703,14 +704,14 @@ iterate(OutputContainer & output_container, typedef typename std::set::iterator Hot_pixel_iter; typedef typename std::list::iterator Segment_data_iter; - + Polyline_type seg_output; Hot_pixel_set hot_pixels_intersected_set; Hot_pixel_iter hot_pixel_iter; int number_of_intersections; Hot_pixel * hp; SEG_Direction seg_dir; - + for (Segment_data_iter iter = seg_list.begin(); iter != seg_list.end(); ++iter) { @@ -742,7 +743,7 @@ iterate(OutputContainer & output_container, } output_container.push_back(seg_output); - } + } } /*! */ @@ -763,7 +764,7 @@ void snap_rounding_2(InputIterator begin, typedef CGAL::Segment_data Segment_data; typedef CGAL::Multiple_kd_tree Multiple_kd_tree; typedef std::list Segment_data_list; - + Segment_data_list seg_list; Multiple_kd_tree * mul_kd_tree = NULL; diff --git a/Sweep_line_2/doc/Sweep_line_2/CGAL/Sweep_line_2_algorithms.h b/Surface_sweep_2/doc/Surface_sweep_2/CGAL/Surface_sweep_2_algorithms.h similarity index 100% rename from Sweep_line_2/doc/Sweep_line_2/CGAL/Sweep_line_2_algorithms.h rename to Surface_sweep_2/doc/Surface_sweep_2/CGAL/Surface_sweep_2_algorithms.h diff --git a/Sweep_line_2/doc/Sweep_line_2/Doxyfile.in b/Surface_sweep_2/doc/Surface_sweep_2/Doxyfile.in similarity index 100% rename from Sweep_line_2/doc/Sweep_line_2/Doxyfile.in rename to Surface_sweep_2/doc/Surface_sweep_2/Doxyfile.in diff --git a/Sweep_line_2/doc/Sweep_line_2/PackageDescription.txt b/Surface_sweep_2/doc/Surface_sweep_2/PackageDescription.txt similarity index 100% rename from Sweep_line_2/doc/Sweep_line_2/PackageDescription.txt rename to Surface_sweep_2/doc/Surface_sweep_2/PackageDescription.txt diff --git a/Surface_sweep_2/doc/Surface_sweep_2/Surface_sweep_2.txt b/Surface_sweep_2/doc/Surface_sweep_2/Surface_sweep_2.txt new file mode 100644 index 00000000000..05eba3e9757 --- /dev/null +++ b/Surface_sweep_2/doc/Surface_sweep_2/Surface_sweep_2.txt @@ -0,0 +1,61 @@ +namespace CGAL { +/*! + +\mainpage User Manual +\anchor Chapter_2D_Intersection_of_Curves +\anchor I1_ChapterSurfaceSweep + +\cgalAutoToc +\authors Baruch Zukerman, Ron Wein, and Efi Fogel + +\section Surface_sweep_2Introduction Introduction + +Let \f$ {\mathcal C} = \{C_1, C_2, \ldots, C_n\}\f$ be a set of +curves. We wish to compute all intersection points between two curves +in the set in an output-sensitive manner, without having to go over +all \f$ O(n^2)\f$ curve pairs. To this end, we sweep an imaginary line +\f$ l\f$ from \f$ x = -\infty\f$ to \f$ x = \infty\f$ over the +plane. While sweeping the plane, we keep track of the order of curves +intersecting it. This order changes at a finite number of event +points, such that we only have to calculate the intersection +points between two curves when they become contiguous. For more +details on the surface-sweep algorithm see, for example, +\cgalCite{bkos-cgaa-00}, Chapter 2. + +This chapter describes three functions implemented using the +surface-sweep algorithm: given a collection of input curves, compute all +intersection points, compute the set of subcurves that are pairwise +interior-disjoint induced by them, and checking whether there is at +least one pair of curves among them that intersect in their interior. + +The implementation is robust. It supports general curves and handles +all degenerate cases, including overlapping curves, vertical segments, +and tangency between curves. The robustness of the algorithm is +guaranteed if the functions are instantiated with a traits class that +employs certified computations. This traits class must be a model of +the `ArrangementTraits_2` concept - see the Chapter \ref +chapterArrangement_on_surface_2 "2D Arrangements" for more details. + +The complexity of the surface-sweep algorithm is \f$ O((n + +k)\log{n})\f$ where \f$ n\f$ is the number of the input curves and \f$ +k\f$ is the number of intersection points induced by these curves. + +\section Surface_sweep_2Example Example + +The simple program listed below computes intersection points induced by +a set of four input segments illustrated in \cgalFigureRef{SL_secsimple}. + +\cgalFigureBegin{SL_secsimple,sl_simple.png} +Four input segments +\cgalFigureEnd + +\cgalExample{Surface_sweep_2/plane_sweep.cpp} + +\section Surface_sweep_2Design Design and Implementation History + +The current version of the surface-sweep algorithm was written by Efi +Fogel, based on previous implementations by Baruch Ester Ezra, Tali +Zvi, and Baruch Zukerman. + +*/ +} /* namespace CGAL */ diff --git a/Sweep_line_2/doc/Sweep_line_2/dependencies b/Surface_sweep_2/doc/Surface_sweep_2/dependencies similarity index 100% rename from Sweep_line_2/doc/Sweep_line_2/dependencies rename to Surface_sweep_2/doc/Surface_sweep_2/dependencies diff --git a/Surface_sweep_2/doc/Surface_sweep_2/examples.txt b/Surface_sweep_2/doc/Surface_sweep_2/examples.txt new file mode 100644 index 00000000000..50ffcc88b40 --- /dev/null +++ b/Surface_sweep_2/doc/Surface_sweep_2/examples.txt @@ -0,0 +1,3 @@ +/*! +\example Surface_sweep_2/plane_sweep.cpp +*/ diff --git a/Sweep_line_2/doc/Sweep_line_2/fig/Curve_intersections_2.png b/Surface_sweep_2/doc/Surface_sweep_2/fig/Curve_intersections_2.png similarity index 100% rename from Sweep_line_2/doc/Sweep_line_2/fig/Curve_intersections_2.png rename to Surface_sweep_2/doc/Surface_sweep_2/fig/Curve_intersections_2.png diff --git a/Sweep_line_2/doc/Sweep_line_2/fig/sl_simple.png b/Surface_sweep_2/doc/Surface_sweep_2/fig/sl_simple.png similarity index 100% rename from Sweep_line_2/doc/Sweep_line_2/fig/sl_simple.png rename to Surface_sweep_2/doc/Surface_sweep_2/fig/sl_simple.png diff --git a/Sweep_line_2/examples/Sweep_line_2/CMakeLists.txt b/Surface_sweep_2/examples/Surface_sweep_2/CMakeLists.txt similarity index 90% rename from Sweep_line_2/examples/Sweep_line_2/CMakeLists.txt rename to Surface_sweep_2/examples/Surface_sweep_2/CMakeLists.txt index 15204756bea..b924fdabad3 100644 --- a/Sweep_line_2/examples/Sweep_line_2/CMakeLists.txt +++ b/Surface_sweep_2/examples/Surface_sweep_2/CMakeLists.txt @@ -1,7 +1,7 @@ # Created by the script cgal_create_CMakeLists # This is the CMake script for compiling a set of CGAL applications. -project( Sweep_line_2_Examples ) +project( Surface_sweep_2_Examples ) cmake_minimum_required(VERSION 2.6.2) @@ -20,7 +20,7 @@ find_package( CGAL QUIET COMPONENTS ) if ( NOT CGAL_FOUND ) message(STATUS "This project requires the CGAL library, and will not be compiled.") - return() + return() endif() @@ -35,7 +35,7 @@ if ( NOT Boost_FOUND ) message(STATUS "This project requires the Boost library, and will not be compiled.") - return() + return() endif() @@ -51,8 +51,4 @@ include_directories( BEFORE ../../include ) include( CGAL_CreateSingleSourceCGALProgram ) -create_single_source_cgal_program( "sweep_line.cpp" ) - - - - +create_single_source_cgal_program( "plane_sweep.cpp" ) diff --git a/Surface_sweep_2/examples/Surface_sweep_2/plane_sweep.cpp b/Surface_sweep_2/examples/Surface_sweep_2/plane_sweep.cpp new file mode 100644 index 00000000000..d6d2fbbdfa8 --- /dev/null +++ b/Surface_sweep_2/examples/Surface_sweep_2/plane_sweep.cpp @@ -0,0 +1,45 @@ +//! \file examples/Arrangement_on_surface_2/plane_sweep.cpp +// Computing intersection points among curves using the surface-sweep alg. + +#include + +#include +#include +#include + +typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel; +typedef Kernel::Point_2 Point_2; +typedef CGAL::Arr_segment_traits_2 Traits_2; +typedef Traits_2::Curve_2 Segment_2; + +int main() +{ + // Construct the input segments. + Segment_2 segments[] = {Segment_2 (Point_2 (1, 5), Point_2 (8, 5)), + Segment_2 (Point_2 (1, 1), Point_2 (8, 8)), + Segment_2 (Point_2 (3, 1), Point_2 (3, 8)), + Segment_2 (Point_2 (8, 5), Point_2 (8, 8))}; + + // Compute all intersection points. + std::list pts; + + CGAL::compute_intersection_points(segments, segments + 4, + std::back_inserter(pts)); + + // Print the result. + std::cout << "Found " << pts.size() << " intersection points: " << std::endl; + std::copy(pts.begin(), pts.end(), + std::ostream_iterator(std::cout, "\n")); + + // Compute the non-intersecting sub-segments induced by the input segments. + std::list sub_segs; + + CGAL::compute_subcurves(segments, segments + 4, std::back_inserter(sub_segs)); + + std::cout << "Found " << sub_segs.size() + << " interior-disjoint sub-segments." << std::endl; + + CGAL_assertion(CGAL::do_curves_intersect (segments, segments + 4)); + + return 0; +} diff --git a/Arrangement_on_surface_2/include/CGAL/Basic_sweep_line_2.h b/Surface_sweep_2/include/CGAL/No_intersection_surface_sweep_2.h similarity index 88% rename from Arrangement_on_surface_2/include/CGAL/Basic_sweep_line_2.h rename to Surface_sweep_2/include/CGAL/No_intersection_surface_sweep_2.h index 113fc21c018..d1bb5a642dc 100644 --- a/Arrangement_on_surface_2/include/CGAL/Basic_sweep_line_2.h +++ b/Surface_sweep_2/include/CGAL/No_intersection_surface_sweep_2.h @@ -17,26 +17,24 @@ // SPDX-License-Identifier: GPL-3.0+ // // Author(s) : Baruch Zukerman -// Efi Fogel +// Efi Fogel // (based on old version by Tali Zvi) #ifndef CGAL_BASIC_SWEEP_LINE_2_H #define CGAL_BASIC_SWEEP_LINE_2_H -#include - - /*! \file - * Definition of the Basic_sweep_line_2 class. + * + * Definition of the No_intersection_surface_sweep_2 class. */ -// #include + #include +#include #include #include -#include -#include -#include +#include +#include #include #include #include @@ -107,30 +105,32 @@ #endif namespace CGAL { +namespace Surface_sweep_2 { -/*! \class Basic_Sweep_line_2 +/*! \class No_intersection_surface_sweep_2 * A class that implements the sweep line algorithm for general x-monotone * curves that are pairwise disjoint in their interiors (an additional set * of isolated points may also be supplied). * The x-montone curve type and the point type are defined by the traits class * that is one of the template parameters. */ -template , - typename Event_ = Sweep_line_event, - typename Allocator_ = CGAL_ALLOCATOR(int)> -class Basic_sweep_line_2 { +template +class No_intersection_surface_sweep_2 { public: - typedef Traits_ Traits_2; - typedef Visitor_ Visitor; - typedef Event_ Event; - typedef Subcurve_ Subcurve; - typedef Allocator_ Allocator; + typedef Visitor_ Visitor; - typedef Arr_traits_basic_adaptor_2 Traits_adaptor_2; - typedef typename Traits_adaptor_2::Point_2 Point_2; - typedef typename Traits_adaptor_2::X_monotone_curve_2 X_monotone_curve_2; + typedef typename Visitor::Geometry_traits_2 Geometry_traits_2; + typedef typename Visitor::Event Event; + typedef typename Visitor::Subcurve Subcurve; + typedef typename Visitor::Allocator Allocator; + +private: + typedef Geometry_traits_2 Gt2; + +public: + typedef Arr_traits_basic_adaptor_2 Traits_adaptor_2; + typedef typename Traits_adaptor_2::Point_2 Point_2; + typedef typename Traits_adaptor_2::X_monotone_curve_2 X_monotone_curve_2; typedef typename Traits_adaptor_2::Left_side_category Left_side_category; typedef typename Traits_adaptor_2::Bottom_side_category Bottom_side_category; @@ -145,13 +145,14 @@ public: protected: typedef typename Arr_are_all_sides_oblivious_tag< - Left_side_category, Bottom_side_category, - Top_side_category, Right_side_category >::result + Left_side_category, Bottom_side_category, + Top_side_category, Right_side_category >::result Are_all_sides_oblivious_category; public: - typedef CGAL::Compare_events Compare_events; - typedef Multiset Event_queue; + typedef CGAL::Surface_sweep_2::Event_comparer + Event_comparer; + typedef Multiset Event_queue; typedef typename Event_queue::iterator Event_queue_iterator; typedef typename Event::Subcurve_iterator @@ -159,14 +160,11 @@ public: typedef typename Event::Subcurve_const_iterator Event_subcurve_const_iterator; - typedef Sweep_line_event Base_event; - typedef typename Base_event::Attribute Attribute; + typedef typename Event::Attribute Attribute; - typedef Sweep_line_subcurve Base_subcurve; - typedef class Curve_comparer Compare_curves; - typedef Multiset Status_line; + typedef class Curve_comparer Compare_curves; + typedef Multiset + Status_line; typedef typename Status_line::iterator Status_line_iterator; typedef typename Allocator::template rebind Event_alloc_rebind; @@ -197,7 +195,7 @@ protected: Compare_curves m_statusLineCurveLess; // Comparison functor for the status line. - Compare_events m_queueEventLess; // Comparison functor for the event queue. + Event_comparer m_queueEventLess; // Comparison functor for the event queue. Event_queue* m_queue; // The event queue (the X-structure). @@ -236,16 +234,16 @@ public: /*! Constructor. * \param visitor A pointer to a sweep-line visitor object. */ - Basic_sweep_line_2(Visitor* visitor); + No_intersection_surface_sweep_2(Visitor* visitor); /*! Constructor with a traits class. * \param traits A pointer to a sweep-line traits object. * \param visitor A pointer to a sweep-line visitor object. */ - Basic_sweep_line_2(const Traits_2* traits, Visitor* visitor); + No_intersection_surface_sweep_2(const Gt2* traits, Visitor* visitor); /*! Destructor. */ - virtual ~Basic_sweep_line_2(); + virtual ~No_intersection_surface_sweep_2(); /*! Run the sweep-line algorithm on a given range of x-monotone curves. * \param curves_begin An iterator for the first curve in the range. @@ -283,7 +281,7 @@ public: { m_visitor->before_sweep(); _init_sweep(curves_begin, curves_end); - _init_points(action_points_begin, action_points_end, Base_event::ACTION); + _init_points(action_points_begin, action_points_end, Event::ACTION); //m_visitor->after_init(); _sweep(); _complete_sweep(); @@ -314,8 +312,8 @@ public: { m_visitor->before_sweep(); _init_sweep(curves_begin, curves_end); - _init_points(action_points_begin, action_points_end, Base_event::ACTION); - _init_points(query_points_begin, query_points_end, Base_event::QUERY); + _init_points(action_points_begin, action_points_end, Event::ACTION); + _init_points(query_points_begin, query_points_end, Event::QUERY); //m_visitor->after_init(); _sweep(); _complete_sweep(); @@ -362,7 +360,7 @@ public: Event* current_event() { return m_currentEvent; } /*! Get the traits object */ - const Traits_2* traits() { return m_traits; } + const Gt2* traits() { return m_traits; } protected: /*! Perform the main sweep-line loop. */ @@ -453,6 +451,11 @@ protected: virtual bool _add_curve_to_right(Event* event, Subcurve* curve, bool overlap_exist = false); + /*! Add a curve as a right curve or left curve when the event is created + * or updated. + */ + virtual void _add_curve(Event* e, Subcurve* sc, Attribute type); + /*! Remove a curve from the status line. */ void _remove_curve_from_status_line(Subcurve *leftCurve); @@ -546,7 +549,7 @@ protected: void decrease_indent(); void print_start(const char* name, bool do_eol = true); void print_end(const char* name, bool do_eol = true); - void print_curve(const Base_subcurve* sc); + void print_curve(const Subcurve* sc); void print_event_info(const Event* e); void PrintEventQueue(); @@ -558,13 +561,14 @@ protected: }; -//DEBUG UTILITIES +} // namespace Surface_sweep_2 +} // namespace CGAL + +// DEBUG UTILITIES #ifdef CGAL_SL_VERBOSE - #include + #include #endif -} //namespace CGAL - -#include +#include #endif diff --git a/Sweep_line_2/include/CGAL/Sweep_line_2.h b/Surface_sweep_2/include/CGAL/Surface_sweep_2.h similarity index 71% rename from Sweep_line_2/include/CGAL/Sweep_line_2.h rename to Surface_sweep_2/include/CGAL/Surface_sweep_2.h index 3851e3e9f48..0c701c646bf 100644 --- a/Sweep_line_2/include/CGAL/Sweep_line_2.h +++ b/Surface_sweep_2/include/CGAL/Surface_sweep_2.h @@ -20,26 +20,29 @@ // Efi Fogel // (based on old version by Tali Zvi) -#ifndef CGAL_SWEEP_LINE_2_H -#define CGAL_SWEEP_LINE_2_H - -#include +#ifndef CGAL_SURFACE_SWEEP_2_H +#define CGAL_SURFACE_SWEEP_2_H +#include /*! \file - * Definition of the Sweep_line_2 class. + * + * Definition of the Surface_sweep_2 class. */ #include + #include -#include -#include +#include +#include #include namespace CGAL { +namespace Surface_sweep_2 { /*! \class - * Sweep_line_2 is a class that implements the sweep line algorithm based + * + * Surface_sweep_2 is a class that implements the sweep line algorithm based * on the algorithm of Bentley and Ottmann. * It extends the algorithm to support not only segments but general x-monotone * curves as well and isolated points. @@ -77,48 +80,44 @@ namespace CGAL { * */ -template , - typename Event_ = Sweep_line_event, - typename Allocator_ = CGAL_ALLOCATOR(int) > -class Sweep_line_2 : - public Basic_sweep_line_2 -{ +template +class Surface_sweep_2 : public No_intersection_surface_sweep_2 { public: - typedef Traits_ Traits_2; - typedef Visitor_ Visitor; - typedef Event_ Event; - typedef Subcurve_ Subcurve; - typedef Allocator_ Allocator; + typedef Visitor_ Visitor; - typedef Basic_sweep_line_2 - Base; +private: + typedef No_intersection_surface_sweep_2 Base; - typedef typename Base::Traits_adaptor_2 Traits_adaptor_2; - typedef typename Traits_adaptor_2::Point_2 Point_2; - typedef typename Traits_adaptor_2::X_monotone_curve_2 X_monotone_curve_2; +public: + typedef typename Base::Geometry_traits_2 Geometry_traits_2; + typedef typename Base::Event Event; + typedef typename Base::Subcurve Subcurve; + typedef typename Base::Allocator Allocator; - typedef typename Base::Event_queue_iterator Event_queue_iterator; - typedef typename Event::Subcurve_iterator Event_subcurve_iterator; + typedef typename Base::Traits_adaptor_2 Traits_adaptor_2; + typedef typename Traits_adaptor_2::Point_2 Point_2; + typedef typename Traits_adaptor_2::X_monotone_curve_2 X_monotone_curve_2; - typedef typename Base::Base_event Base_event; - typedef typename Base_event::Attribute Attribute; + typedef typename Base::Event_queue_iterator Event_queue_iterator; + typedef typename Event::Subcurve_iterator Event_subcurve_iterator; - typedef typename Base::Base_subcurve Base_subcurve; + typedef typename Event::Attribute Attribute; - typedef std::list Subcurve_container; - typedef typename Subcurve_container::iterator Subcurve_iterator; + typedef std::list Subcurve_container; + typedef typename Subcurve_container::iterator Subcurve_iterator; - typedef typename Base::Status_line_iterator Status_line_iterator; + typedef typename Base::Status_line_iterator Status_line_iterator; - typedef CGAL::Curve_pair Curve_pair; - typedef CGAL::Curve_pair_hasher Curve_pair_hasher; - typedef CGAL::Equal_curve_pair Equal_curve_pair; + typedef CGAL::Surface_sweep_2::Curve_pair Curve_pair; + typedef CGAL::Surface_sweep_2::Curve_pair_hasher + Curve_pair_hasher; + typedef CGAL::Surface_sweep_2::Equal_curve_pair + Equal_curve_pair; typedef Open_hash - Curve_pair_set; + Curve_pair_set; - typedef random_access_input_iterator > - vector_inserter; + typedef std::vector Object_vector; + typedef random_access_input_iterator vector_inserter; protected: // Data members: @@ -139,23 +138,22 @@ public: /*! Constructor. * \param visitor A pointer to a sweep-line visitor object. */ - Sweep_line_2(Visitor* visitor) : Base(visitor), m_curves_pair_set(0) {} + Surface_sweep_2(Visitor* visitor) : Base(visitor), m_curves_pair_set(0) {} /*! * Construct. * \param traits A pointer to a sweep-line traits object. * \param visitor A pointer to a sweep-line visitor object. */ - Sweep_line_2(const Traits_2* traits, Visitor* visitor) : + Surface_sweep_2(const Geometry_traits_2* traits, Visitor* visitor) : Base(traits, visitor), m_curves_pair_set(0) {} /*! Destrcut. */ - virtual ~Sweep_line_2() {} + virtual ~Surface_sweep_2() {} protected: - /*! Initialize the data structures for the sweep-line algorithm. */ virtual void _init_structures(); @@ -176,6 +174,11 @@ protected: virtual bool _add_curve_to_right(Event* event, Subcurve* curve, bool overlap_exist = false); + /*! Add a curve as a right curve or left curve when the event is created + * or updated. + */ + void _add_curve(Event* e, Subcurve* sc, Attribute type); + /*! Fix overlapping subcurves before handling the current event. */ void _fix_overlap_subcurves(); @@ -225,9 +228,10 @@ protected: void _fix_finished_overlap_subcurve(Subcurve* sc); }; -} //namespace CGAL +} // namespace Surface_sweep_2 +} // namespace CGAL // The member-function definitions can be found in: -#include +#include #endif diff --git a/Surface_sweep_2/include/CGAL/Surface_sweep_2/Curve_comparer.h b/Surface_sweep_2/include/CGAL/Surface_sweep_2/Curve_comparer.h new file mode 100644 index 00000000000..d5941b286a2 --- /dev/null +++ b/Surface_sweep_2/include/CGAL/Surface_sweep_2/Curve_comparer.h @@ -0,0 +1,123 @@ +// Copyright (c) 2006,2007,2009,2010,2011 Tel-Aviv University (Israel). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// You can redistribute it and/or modify it under the terms of the GNU +// General Public License as published by the Free Software Foundation, +// either version 3 of the License, or (at your option) any later version. +// +// Licensees holding a valid commercial license may use this file in +// accordance with the commercial license agreement provided with the software. +// +// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Author(s) : Tali Zvi +// Baruch Zukerman +// Ron Wein +// Efi Fogel + +#ifndef CGAL_SURFACE_SWEEP_2_CURVE_COMPARER_H +#define CGAL_SURFACE_SWEEP_2_CURVE_COMPARER_H + +#include + +/*! \file + * + * Comparison functor of curves used by the surface-sweep algorithm. + */ + +#include +#include +#include +#include + +namespace CGAL { +namespace Surface_sweep_2 { + +/*! A functor used to compare curves and curve endpoints by their vertical + * y-order. Used to maintain the order of curves in the status line (the + * Y-structure) in the surface-sweep algorithm. + */ +template +class Curve_comparer { +public: + typedef GeometryTraits_2 Geometry_traits_2; + typedef Event_ Event; + typedef Subcurve_ Subcurve; + +private: + typedef Geometry_traits_2 Gt2; + +public: + typedef Arr_traits_basic_adaptor_2 Traits_adaptor_2; + + typedef typename Traits_adaptor_2::Point_2 Point_2; + typedef typename Traits_adaptor_2::X_monotone_curve_2 X_monotone_curve_2; + +private: + const Traits_adaptor_2* m_traits; // A geometric-traits object. + Event** m_curr_event; // Points to the current event point. + +public: + /*! Construct. */ + Curve_comparer(const Traits_adaptor_2* t, Event** e_ptr) : + m_traits(t), + m_curr_event(e_ptr) + {} + + /*! Compare the vertical position of two subcurves in the status line. + * This operator is called only in debug mode. + */ + Comparison_result operator()(const Subcurve* c1, const Subcurve* c2) const + { + // In case to two curves are right curves at the same event, compare + // to the right of the event point. + if (std::find((*m_curr_event)->right_curves_begin(), + (*m_curr_event)->right_curves_end(), + c1) != (*m_curr_event)->right_curves_end() && + std::find((*m_curr_event)->right_curves_begin(), + (*m_curr_event)->right_curves_end(), + c2) != (*m_curr_event)->right_curves_end()) + { + return m_traits->compare_y_at_x_right_2_object() + (c1->last_curve(), c2->last_curve(), (*m_curr_event)->point()); + } + + Arr_parameter_space ps_x1 = + m_traits->parameter_space_in_x_2_object()(c1->last_curve(), ARR_MIN_END); + Arr_parameter_space ps_y1 = + m_traits->parameter_space_in_y_2_object()(c1->last_curve(), ARR_MIN_END); + + if ((ps_x1 == ARR_INTERIOR) && (ps_y1 == ARR_INTERIOR)) + { + // The first curve has a valid left endpoint. Compare the y-position + // of this endpoint to the second subcurve. + return m_traits->compare_y_at_x_2_object() + (m_traits->construct_min_vertex_2_object()(c1->last_curve()), + c2->last_curve()); + } + + // We use the fact that the two curves are interior disjoint. As c2 is + // already in the status line, then if c1 left end has a negative boundary + // condition it obviously above it. + CGAL_assertion(ps_x1 != ARR_RIGHT_BOUNDARY); + + if (ps_x1 == ARR_LEFT_BOUNDARY) return LARGER; + + // For similar reasons, if c1 begins on the bottom boundary it is below + // c2, if it is on the top boundary it is above it. + CGAL_assertion (ps_y1 != ARR_INTERIOR); + return (ps_y1 == ARR_BOTTOM_BOUNDARY) ? SMALLER : LARGER; + } + + /*! Compare the relative y-order of the given point and the given subcurve. + */ + Comparison_result operator()(const Point_2& pt, const Subcurve* sc) const + { return m_traits->compare_y_at_x_2_object()(pt, sc->last_curve()); } +}; + +} // namespace Surface_sweep_2 +} // namespace CGAL + +#endif diff --git a/Surface_sweep_2/include/CGAL/Surface_sweep_2/Curve_pair.h b/Surface_sweep_2/include/CGAL/Surface_sweep_2/Curve_pair.h new file mode 100644 index 00000000000..29f1d4fee11 --- /dev/null +++ b/Surface_sweep_2/include/CGAL/Surface_sweep_2/Curve_pair.h @@ -0,0 +1,193 @@ +// Copyright (c) 2006,2007,2009,2010,2011 Tel-Aviv University (Israel). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// You can redistribute it and/or modify it under the terms of the GNU +// General Public License as published by the Free Software Foundation, +// either version 3 of the License, or (at your option) any later version. +// +// Licensees holding a valid commercial license may use this file in +// accordance with the commercial license agreement provided with the software. +// +// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Author(s) : Baruch Zukerman +// Ron Wein + +#ifndef CGAL_SURFACE_SWEEP_2_CURVE_PAIR_H +#define CGAL_SURFACE_SWEEP_2_CURVE_PAIR_H + +#include + +#include + +/*! \file + * + * Definition of the Curve_pair class template and related functors. + */ + +namespace CGAL { +namespace Surface_sweep_2 { + +/*! \class + * + * A pair of subcurves. + */ +template +class Curve_pair { +public: + typedef Subcurve_ Subcurve; + +private: + // Data members: + std::pair m_pair; + +public: + /*! Construct default. */ + Curve_pair() {} + + /*! Construct from two subcurves. + */ + Curve_pair(Subcurve* sc1, Subcurve* sc2) + { m_pair = CGAL::make_sorted_pair(sc1, sc2); } + + /*! Obtain the first subcurve. */ + Subcurve* first() const { return m_pair.first; } + + /*! Obtain the second subcurve. */ + Subcurve* second() const { return m_pair.second; } +}; + +/*! \struct + * Less functor for curve pairs. + */ +template +struct Less_curve_pair { + typedef Subcurve_ Subcurve; + typedef class Curve_pair Curve_pair; + + bool operator()(const Curve_pair& pair1, const Curve_pair& pair2) const + { + if (pair1.first() < pair2.first()) return true; + if (pair1.first() > pair2.first()) return false; + if (pair1.second() < pair2.second()) return true; + return false; + } +}; + +/*! \struct + * A hash functor for curve pairs. + */ +template +struct Curve_pair_hasher { + typedef Subcurve_ Subcurve; + typedef class Curve_pair Curve_pair; + + size_t operator()(const Curve_pair& pair) const + { + const size_t half_n_bits = sizeof(size_t) * 8 / 2; + const size_t val1 = reinterpret_cast(pair.first()); + const size_t val2 = reinterpret_cast(pair.second()); + return (((val1 << half_n_bits) | (val1 >> half_n_bits)) ^ val2); + } +}; + +/*! \struct + * Equaility functor for curve pairs. + */ +template +struct Equal_curve_pair { + typedef Subcurve_ Subcurve; + typedef class Curve_pair Curve_pair; + + bool operator()(const Curve_pair& pair1, const Curve_pair& pair2) const + { + return ((pair1.first() == pair2.first()) && + (pair1.second() == pair2.second())); + } +}; + +/*! \class + * A random-access iterator that can automatically resize its container. + */ +template +class random_access_input_iterator { +public: + typedef Container_ Container; + typedef typename Container::value_type value_type; + typedef random_access_input_iterator Self; + +private: + // Data members: + Container* m_container; // The container. + unsigned int m_index; // The current index. + +public: + random_access_input_iterator() {} + + random_access_input_iterator(Container& _container, unsigned int _index = 0) : + m_container(&_container), + m_index(_index) + {} + + value_type& operator*() + { + if(m_index >= m_container->capacity()) { + m_container->reserve(2 * m_index + 1); + m_container->resize(m_index+1); + } + else if(m_index >= m_container->size()) + m_container->resize(m_index+1); + return (*m_container)[m_index]; + } + + Self& operator++() + { + ++m_index; + return (*this); + } + + Self operator++ (int) + { + Self temp = *this; + ++m_index; + return (temp); + } + + Self& operator--() + { + --m_index; + return (*this); + } + + Self operator--(int) + { + Self temp = *this; + --m_index; + return (temp); + } + + bool operator==(const Self& other) + { + CGAL_precondition(m_container == other.m_container); + return (m_index == other.m_index); + } + + bool operator!=(const Self& other) + { + CGAL_precondition(m_container == other.m_container); + return !(*this == other); + } + + unsigned int operator-(const Self& other) + { + CGAL_precondition(m_container == other.m_container); + return (m_index - other.m_index); + } +}; + +} // namespace Surface_sweep_2 +} // namespace CGAL + +#endif diff --git a/Surface_sweep_2/include/CGAL/Surface_sweep_2/Default_event.h b/Surface_sweep_2/include/CGAL/Surface_sweep_2/Default_event.h new file mode 100644 index 00000000000..a65a9ed5e6a --- /dev/null +++ b/Surface_sweep_2/include/CGAL/Surface_sweep_2/Default_event.h @@ -0,0 +1,76 @@ +// Copyright (c) 2006,2007,2009,2010,2011 Tel-Aviv University (Israel). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// You can redistribute it and/or modify it under the terms of the GNU +// General Public License as published by the Free Software Foundation, +// either version 3 of the License, or (at your option) any later version. +// +// Licensees holding a valid commercial license may use this file in +// accordance with the commercial license agreement provided with the software. +// +// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Author(s) : Tali Zvi , +// Baruch Zukerman +// Ron Wein +// Efi Fogel + +#ifndef CGAL_SURFACE_SWEEP_2_DEFAULT_EVENT_H +#define CGAL_SURFACE_SWEEP_2_DEFAULT_EVENT_H + +#include + +/*! \file + * + * Defintion of the Default_event class. + */ + +#include +#include + +namespace CGAL { +namespace Surface_sweep_2 { + +/*! \class Default_event + * + * This template represents an event used by the surface-sweep framework, where + * the input curves for the surface-sweep procedure may overlap. + * + * \tparam GeometryTraits_2 the geometry traits. + * \tparam Allocator_ a type of an element that is used to acquire/release + * memory for elements of the event queue and the status + * structure, and to construct/destroy the elements in that + * memory. The type must meet the requirements of Allocator. + * + * We exploit the curiously recurring template pattern (CRTP) idiom to establish + * an interdependency between the curve and the event types, which are template + * parameters of the surface-sweep visitor class templates. It enables the + * definition of these two types, which refer one to another; (the curves to the + * right of an event and the curves to its left are data members of the event, + * and the two events associated with the endpoints of a curve are data memebrs + * of the curve.) + * + * If you need to represent an event with additional data members, introduce a + * new type, say x, that derives from x_base, and have x_base derive from + * Default_event_base; do not use this class as base in your derivation. + */ +template +class Default_event : + public Default_event_base, + Allocator_> > +{ +public: + /*! Construct default. */ + Default_event() {} +}; + +} // namespace Surface_sweep_2 +} // namespace CGAL + +#endif diff --git a/Surface_sweep_2/include/CGAL/Surface_sweep_2/Default_event_base.h b/Surface_sweep_2/include/CGAL/Surface_sweep_2/Default_event_base.h new file mode 100644 index 00000000000..33ed37a164a --- /dev/null +++ b/Surface_sweep_2/include/CGAL/Surface_sweep_2/Default_event_base.h @@ -0,0 +1,179 @@ +// Copyright (c) 2006,2007,2009,2010,2011 Tel-Aviv University (Israel). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// You can redistribute it and/or modify it under the terms of the GNU +// General Public License as published by the Free Software Foundation, +// either version 3 of the License, or (at your option) any later version. +// +// Licensees holding a valid commercial license may use this file in +// accordance with the commercial license agreement provided with the software. +// +// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Author(s) : Tali Zvi , +// Baruch Zukerman +// Ron Wein +// Efi Fogel + +#ifndef CGAL_SURFACE_SWEEP_2_DEFAULT_EVENT_BASE_H +#define CGAL_SURFACE_SWEEP_2_DEFAULT_EVENT_BASE_H + +#include + +/*! \file + * + * Defintion of the Default_event_base class. + */ + +#include + +namespace CGAL { +namespace Surface_sweep_2 { + +/*! \class Default_event_base + * + * A class associated with an event in a sweep line algorithm. + * An intersection point in the sweep line algorithm is refered to as an event. + * This class contains the information that is associated with any given + * event point. This information contains the following: + * - the actual point + * - a list of curves that pass through the event point and defined to + * the left of the event point. + * - a list of curves that pass through the event point and defined to + * the right of the event point. + * + * The class mostly exists to store information and does not have any + * significant functionality otherwise. + * + */ +template +class Default_event_base : + public No_overlap_event_base +{ +public: + typedef GeometryTraits_2 Geometry_traits_2; + typedef Subcurve_ Subcurve; + +private: + typedef Geometry_traits_2 Gt2; + typedef No_overlap_event_base Base; + +public: + typedef typename Base::X_monotone_curve_2 X_monotone_curve_2; + typedef typename Base::Point_2 Point_2; + + typedef typename Base::Left_side_category Left_side_category; + typedef typename Base::Bottom_side_category Bottom_side_category; + typedef typename Base::Top_side_category Top_side_category; + typedef typename Base::Right_side_category Right_side_category; + + typedef typename Base::Subcurve_container Subcurve_container; + typedef typename Base::Subcurve_iterator Subcurve_iterator; + typedef typename Base::Subcurve_const_iterator Subcurve_const_iterator; + typedef typename Base::Subcurve_reverse_iterator Subcurve_reverse_iterator; + +public: + /*! Default constructor. */ + Default_event_base() {} + + /*! Add a subcurve to the container of left curves. */ + void add_curve_to_left(Subcurve* curve) + { + // Look for the subcurve. + Subcurve_iterator iter; + for (iter = this->left_curves_begin(); iter != this->left_curves_end(); + ++iter) + { + // Do nothing if the curve exists. + if ((curve == *iter) || (*iter)->is_inner_node(curve)) 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))) { + *iter = curve; + return; + } + } + + // The curve does not exist - insert it to the container. + this->push_back_curve_to_left(curve); + } + + /*! Add a subcurve to the container of right curves. */ + std::pair + add_curve_to_right(Subcurve* curve, const Gt2* tr) + { + if (! this->has_right_curves()) { + this->push_back_curve_to_right(curve); + return (std::make_pair(false, this->right_curves_begin())); + } + + // Check if its an event at open boundary, + // and if so then there is no overlap + //(there cannot be two non-overlap curves at the same event at open + // boundary). + if (!this->is_closed()) + return (std::make_pair(true, this->right_curves_begin())); + + Subcurve_iterator iter = this->right_curves_begin(); + Comparison_result res; + + while ((res = tr->compare_y_at_x_right_2_object() + (curve->last_curve(), (*iter)->last_curve(), this->point())) == + LARGER) + { + ++iter; + if (iter == this->right_curves_end()) { + this->m_right_curves.insert(iter, curve); + return std::make_pair(false, --iter); + } + } + + //overlap !! + if (res == EQUAL) return std::make_pair(true, iter); + + this->m_right_curves.insert(iter, curve); + return std::make_pair(false, --iter); + } + + /*! Remove a curve from the set of left curves. */ + void remove_curve_from_left(Subcurve* curve) + { + Subcurve_iterator iter; + for (iter = this->left_curves_begin(); iter!= this->left_curves_end(); + ++iter) + { + if (curve->has_common_leaf(*iter)) { + this->m_left_curves.erase(iter); + return; + } + } + } + + bool is_right_curve_bigger(Subcurve* c1, Subcurve* c2) + { + Subcurve_iterator iter; + for (iter = this->right_curves_begin(); iter != this->right_curves_end(); + ++iter) + { + if ((*iter == c1) || + (static_cast((*iter)->originating_subcurve1()) == c1) || + (static_cast((*iter)->originating_subcurve2()) == c1)) + return false; + + if ((*iter == c2) || + (static_cast((*iter)->originating_subcurve1()) == c2) || + (static_cast((*iter)->originating_subcurve2()) == c2)) + return true; + } + + return true; + } +}; + +} // namespace Surface_sweep_2 +} // namespace CGAL + +#endif diff --git a/Surface_sweep_2/include/CGAL/Surface_sweep_2/Default_subcurve.h b/Surface_sweep_2/include/CGAL/Surface_sweep_2/Default_subcurve.h new file mode 100644 index 00000000000..b0069149b83 --- /dev/null +++ b/Surface_sweep_2/include/CGAL/Surface_sweep_2/Default_subcurve.h @@ -0,0 +1,303 @@ +// Copyright (c) 2006,2007,2009,2010,2011 Tel-Aviv University (Israel). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// You can redistribute it and/or modify it under the terms of the GNU +// General Public License as published by the Free Software Foundation, +// either version 3 of the License, or (at your option) any later version. +// +// Licensees holding a valid commercial license may use this file in +// accordance with the commercial license agreement provided with the software. +// +// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Author(s) : Tali Zvi , +// Baruch Zukerman +// Ron Wein +// Efi Fogel + +#ifndef CGAL_SURFACE_SWEEP_DEFAULT_SUBCURVE_H +#define CGAL_SURFACE_SWEEP_DEFAULT_SUBCURVE_H + +#include + +/*! \file + * + * Defintion of the Default_subcurve class, which is an extended curve + * type, referred to as Subcurve, used by the surface-sweep framework. + * + * The surface-sweep framework is implemented as a template that is + * parameterized, among the other, by the Subcurve and Event types. That is, + * instance types of Subcurve and Event must be available when the + * surface-sweep template is instantiated. + * + * Default_subcurve derives from an instance of the No_overlap_subcurve class + * template. The user is allowed to introduce new types that derive from an + * instance of the Default_subcurve class template. However, some of the fields + * of this template depends on the Subcurve type. We use the curiously + * recurring template pattern (CRTP) idiom to force the correct matching of + * these types. + */ + +#include +#include +#include +#include + +namespace CGAL { +namespace Surface_sweep_2 { + +/*! \class Default_subcurve_base + * + * This is the base class of the Default_subcurve class template used by + * the (CRTP) idiom. + * \tparam GeometryTraits_2 the geometry traits. + * \tparam Event_ the event type. + * \tparam Allocator_ a type of an element that is used to acquire/release + * memory for elements of the event queue and the status + * structure, and to construct/destroy the elements in that + * memory. The type must meet the requirements of Allocator. + * \tparam Subcurve_ the subcurve actual type. + * + * The information contained in this class is: + * - two pointers to subcurves that are the originating subcurves in case of + * an overlap, otherwise thay are both NULL. + */ +template +class Default_subcurve_base : + public No_overlap_subcurve +{ +public: + typedef GeometryTraits_2 Geometry_traits_2; + typedef Subcurve_ Subcurve; + typedef Event_ Event; + +private: + typedef Geometry_traits_2 Gt2; + typedef No_overlap_subcurve Base; + +public: + typedef typename Gt2::X_monotone_curve_2 X_monotone_curve_2; + + /*! Construct default. + */ + Default_subcurve_base() : + m_orig_subcurve1(NULL), + m_orig_subcurve2(NULL) + {} + + /*! Construct from a curve. + */ + Default_subcurve_base(const X_monotone_curve_2& curve) : + Base(curve), + m_orig_subcurve1(NULL), + m_orig_subcurve2(NULL) + {} + +protected: + Subcurve* m_orig_subcurve1; // The overlapping hierarchy + Subcurve* m_orig_subcurve2; // (relevant only in case of overlaps). + +public: + /*! Get the subcurves that originate an overlap. */ + Subcurve* originating_subcurve1() { return m_orig_subcurve1; } + + Subcurve* originating_subcurve2() { return m_orig_subcurve2; } + + const Subcurve* originating_subcurve1() const { return m_orig_subcurve1; } + + const Subcurve* originating_subcurve2() const { return m_orig_subcurve2; } + + /*! Set the subcurves that originate an overlap. */ + void set_originating_subcurve1(Subcurve* orig_subcurve1) + { m_orig_subcurve1 = orig_subcurve1; } + + void set_originating_subcurve2(Subcurve* orig_subcurve2) + { m_orig_subcurve2 = orig_subcurve2; } + + /*! Get all the leaf-nodes in the hierarchy of overlapping subcurves. */ + template + OutputIterator all_leaves(OutputIterator oi) + { + if (m_orig_subcurve1 == NULL) { + *oi++ = reinterpret_cast(this); + return oi; + } + + oi = m_orig_subcurve1->all_leaves(oi); + oi = m_orig_subcurve2->all_leaves(oi); + return oi; + } + + /*! Check whether the given subcurve is a node in the overlapping hierarchy. + */ + bool is_inner_node(Subcurve* s) + { + if (this == s) return true; + if (m_orig_subcurve1 == NULL) return false; + return (m_orig_subcurve1->is_inner_node(s) || + m_orig_subcurve2->is_inner_node(s)); + } + + /*! Check whether the given subcurve is a leaf in the overlapping hierarchy. + */ + bool is_leaf(Subcurve* s) + { + if (m_orig_subcurve1 == NULL) return (this == s); + return (m_orig_subcurve1->is_leaf(s) || + m_orig_subcurve2->is_leaf(s)); + } + + /*! Check whether the two hierarchies contain the same leaf nodes. */ + bool has_same_leaves(Subcurve* s) + { + std::list my_leaves; + std::list other_leaves; + + all_leaves(std::back_inserter(my_leaves)); + s->all_leaves(std::back_inserter(other_leaves)); + + typename std::list::iterator iter; + for (iter = my_leaves.begin(); iter != my_leaves.end(); ++iter) { + if (std::find(other_leaves.begin(), other_leaves.end(), *iter) == + other_leaves.end()) + return false; + } + + for (iter = other_leaves.begin(); iter != other_leaves.end(); ++iter) { + if (std::find(my_leaves.begin(), my_leaves.end(), *iter) == + my_leaves.end()) + return false; + } + + return true; + } + + /*! Check whether the two hierarchies contain a common leaf node. */ + bool has_common_leaf(Subcurve* s) + { + std::list my_leaves; + std::list other_leaves; + + all_leaves(std::back_inserter(my_leaves)); + s->all_leaves(std::back_inserter(other_leaves)); + + typename std::list::iterator iter; + for (iter = my_leaves.begin(); iter != my_leaves.end(); ++iter) { + if (std::find(other_leaves.begin(), other_leaves.end(), *iter) != + other_leaves.end()) + return true; + } + return false; + } + + /*! Get all distinct nodes from the two hierarchies. */ + template + OutputIterator distinct_nodes(Subcurve* s, OutputIterator oi) + { + if (m_orig_subcurve1 == NULL) { + Subcurve* subcurve = reinterpret_cast(this); + if (s->is_leaf(subcurve)) *oi++ = subcurve; + return oi; + } + + if (! s->is_inner_node(m_orig_subcurve1)) *oi++ = m_orig_subcurve1; + else oi++ = m_orig_subcurve1->distinct_nodes(s, oi); + + if (! s->is_inner_node(m_orig_subcurve2)) *oi++ = m_orig_subcurve2; + else oi++ = m_orig_subcurve2->distinct_nodes(s, oi); + + return oi; + } + + /*! Get the depth of the overlap hierarchy. */ + unsigned int overlap_depth() + { + if (m_orig_subcurve1 == NULL) return (1); + + unsigned int depth1 = m_orig_subcurve1->overlap_depth(); + unsigned int depth2 = m_orig_subcurve2->overlap_depth(); + if (depth1 > depth2) return (depth1 + 1); + else return (depth2 + 1); + } +}; + +/*! \class Default_subcurve + * + * This is a class template that wraps a traits curve of type + * X_monotone_curve_2. It contains data that is used when applying the sweep + * algorithm on a set of x-monotone curves. This class derives from the + * No_overlap_subcurve class template. + * + * \tparam GeometryTraits_2 the geometry traits. + * \tparam Event_ the event type. + * \tparam Allocator_ a type of an element that is used to acquire/release + * memory for elements of the event queue and the status + * structure, and to construct/destroy the elements in that + * memory. The type must meet the requirements of Allocator. + * \tparam Subcurve_ the type of the subcurve or Default. If the default is not + * overriden it implies that the type is + * No_overlap_subcurve + */ +template +class Default_subcurve : + public Default_subcurve_base >::type> +{ +public: + typedef GeometryTraits_2 Geometry_traits_2; + typedef Event_ Event; + typedef Allocator_ Allocator; + +private: + typedef Geometry_traits_2 Gt2; + typedef Default_subcurve + Self; + typedef typename Default::Get::type Subcurve; + typedef Default_subcurve_base + Base; + +public: + typedef typename Gt2::X_monotone_curve_2 X_monotone_curve_2; + +public: + /*! Construct default. + */ + Default_subcurve() {} + + /*! Construct from a curve. + */ + Default_subcurve(const X_monotone_curve_2& curve) : Base(curve) {} + + /*! Destruct. + */ + ~Default_subcurve() {} + +#ifdef CGAL_SL_VERBOSE + void Print() const; +#endif +}; + +#ifdef CGAL_SL_VERBOSE +template +void Default_subcurve::Print() const +{ + std::cout << "Curve " << this + << " (" << this->last_curve() << ") " + << " [sc1: " << this->originating_subcurve1() + << ", sc2: " << this->originating_subcurve2() << "]"; +} +#endif + +} // namespace Surface_sweep_2 +} // namespace CGAL + +#endif diff --git a/Surface_sweep_2/include/CGAL/Surface_sweep_2/Default_visitor.h b/Surface_sweep_2/include/CGAL/Surface_sweep_2/Default_visitor.h new file mode 100644 index 00000000000..9b50d932401 --- /dev/null +++ b/Surface_sweep_2/include/CGAL/Surface_sweep_2/Default_visitor.h @@ -0,0 +1,61 @@ +// Copyright (c) 2006,2007,2009,2010,2011 Tel-Aviv University (Israel). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// You can redistribute it and/or modify it under the terms of the GNU +// General Public License as published by the Free Software Foundation, +// either version 3 of the License, or (at your option) any later version. +// +// Licensees holding a valid commercial license may use this file in +// accordance with the commercial license agreement provided with the software. +// +// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Author(s) : Baruch Zukerman +// Efi Fogel + +#ifndef CGAL_SURFACE_SWEEP_2_DEFAULT_VISITOR_H +#define CGAL_SURFACE_SWEEP_2_DEFAULT_VISITOR_H + +#include + +/*! \file + * + * Definition of the Default_visitor class-template. + */ + +#include +#include +#include + +namespace CGAL { +namespace Surface_sweep_2 { + +/*! \class Default_visitor + * + * An empty surface-sweep visitor that does little. It is used as a base-class + * for other concrete visitors that produce some output. It is also used to + * set default values for the allocator, event, and subcurve types. + */ +template , + typename Subcurve_ = Default_subcurve > +class Default_visitor : public Default_visitor_base +{ +public: + typedef GeometryTraits_2 Geometry_traits_2; + typedef Allocator_ Allocator; + typedef Event_ Event; + typedef Subcurve_ Subcurve; +}; + +} // namespace Surface_sweep_2 +} // namespace CGAL + +#endif diff --git a/Surface_sweep_2/include/CGAL/Surface_sweep_2/Default_visitor_base.h b/Surface_sweep_2/include/CGAL/Surface_sweep_2/Default_visitor_base.h new file mode 100644 index 00000000000..ad0d8bd9b95 --- /dev/null +++ b/Surface_sweep_2/include/CGAL/Surface_sweep_2/Default_visitor_base.h @@ -0,0 +1,200 @@ +// Copyright (c) 2006,2007,2009,2010,2011 Tel-Aviv University (Israel). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// You can redistribute it and/or modify it under the terms of the GNU +// General Public License as published by the Free Software Foundation, +// either version 3 of the License, or (at your option) any later version. +// +// Licensees holding a valid commercial license may use this file in +// accordance with the commercial license agreement provided with the software. +// +// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Author(s) : Baruch Zukerman +// Efi Fogel + +#ifndef CGAL_SURFACE_SWEEP_2_DEFAULT_VISITOR_BASE_H +#define CGAL_SURFACE_SWEEP_2_DEFAULT_VISITOR_BASE_H + +#include + +/*! \file + * + * Definition of the Default_visitor_base class-template. + */ + +#include + +namespace CGAL { +namespace Surface_sweep_2 { + +/*! \class Default_visitor_base + * + * An empty surface-sweep visitor that does little. It is used as a base-class + * for other concrete visitors that produce some output. + * + * The surface-sweep framework consists of hierarchy of several types, where one + * derives from the other. The base type is capable of sweeping curves that do + * not intersect in their interiors. It is implemented as a template that is + * parameterized by a visitor. The user is allowed to introduce new visitor + * types that derive from the Default_visitor_base basic type. However, this + * basic type provides access to the base type of the surface-sweep + * hierarchy. We use the curiously recurring template pattern (CRTP) idiom to + * have access to the correct base surface-sweep type. + * \tparam GeometryTraits_2 the geometry traits trype. + * \tparam Event_ the sweep event type. + * \tparam Subcurve_ the sweep subcurve type. + * \tparam Allocator_ the allocator used to allocate events and subcurves during + * the sweep. + * \tparam Visitor_ the actual visitor used, which is derived from + * Default_visitor_base. + */ +template +class Default_visitor_base { +public: + typedef GeometryTraits_2 Geometry_traits_2; + typedef Event_ Event; + typedef Subcurve_ Subcurve; + typedef Allocator_ Allocator; + typedef Visitor_ Visitor; + +private: + typedef Geometry_traits_2 Gt2; + typedef Default_visitor_base + Self; + +public: + typedef typename Subcurve::Status_line_iterator Status_line_iterator; + + typedef typename Gt2::X_monotone_curve_2 X_monotone_curve_2; + typedef typename Gt2::Point_2 Point_2; + + typedef typename Event::Subcurve_iterator Event_subcurve_iterator; + typedef typename Event::Subcurve_reverse_iterator + Event_subcurve_reverse_iterator; + + typedef No_intersection_surface_sweep_2 Surface_sweep_2; + +protected: + // Data members: + Surface_sweep_2* m_surface_sweep; // The sweep-line object. + +public: + /*! Constructor. */ + Default_visitor_base () : m_surface_sweep(NULL) {} + + /*! Destructor */ + virtual ~Default_visitor_base() {} + + /*! Attach the a sweep-line object. */ + void attach(Surface_sweep_2* sl) { m_surface_sweep = sl; } + + /*! + * A notification invoked before the sweep-line starts handling the given + * event. + */ + void before_handle_event(Event* /* event */) {} + + /*! + * A notification invoked after the sweep-line finishes handling the given + * event. + */ + bool after_handle_event(Event* /* event */, + Status_line_iterator /* iter */, + bool /* flag */) + { return true; } + + /*! A notification invoked when a new subcurve is created. */ + void add_subcurve(X_monotone_curve_2 /* cv */, + Subcurve* /* sc */) + {} + + /*! A notification issued before the sweep process starts. */ + void before_sweep() + {} + + /*! A notification issued after the sweep process ends. */ + void after_sweep() + {} + + /*! Update the event to be the given curve end. */ + void update_event(Event* /* e */, + const Point_2& /* end_point */, + const X_monotone_curve_2& /* cv */, + Arr_curve_end /* cv_end */, + bool /* is_new */) + {} + + /*! Update the event to be the given infinite curve end. */ + void update_event(Event* /* e */, + const X_monotone_curve_2& /* cv */, + Arr_curve_end /* cv_end */, + bool /* is_new */) + {} + + /*! Update the event to be the intersection point of two subcurves. */ + void update_event(Event* /* e */, + Subcurve* /* sc1 */, + Subcurve* /* sc2 */, + bool /* is_new */) + {} + + /*! Update the event. */ + void update_event(Event* /* e */, + Subcurve* /* sc1 */) + {} + + /*! Update the event. */ + void update_event(Event* /* e */, + const Point_2& /* pt */, + bool /* is_new */) + {} + + /* Found overlap */ + void found_overlap(Subcurve* /* sc1 */, + Subcurve* /* sc2 */, + Subcurve* /* ov_sc */) + {} + + /*! Obtain the first subcurve in the status line. */ + Status_line_iterator status_line_begin() + { return surface_sweep()->status_line_begin(); } + + /*! Obtain a past-the-end iterator for the subcurves in the status line. */ + Status_line_iterator status_line_end() + { return surface_sweep()->status_line_end(); } + + /*! Obtain the number of subcurves in the status line. */ + unsigned status_line_size() const + { return surface_sweep()->status_line_size(); } + + /*! Check if the status line is empty. */ + bool is_status_line_empty() const + { return surface_sweep()->is_status_line_empty(); } + + /*! Deallocate the given event. */ + void deallocate_event(Event* e) { surface_sweep()->deallocate_event(e); } + + /*! Stop the sweep-line process. */ + void stop_sweep() { surface_sweep()->stop_sweep(); } + + /*! Obtain the sweep-line object. */ + Surface_sweep_2* surface_sweep() { return m_surface_sweep; } + + /*! Obtain the sweep-line object. */ + const Surface_sweep_2* surface_sweep() const { return m_surface_sweep; } + + /*! Obtain the current event. */ + Event* current_event() { return surface_sweep()->current_event(); } + + /*! Obtain the geometry-traits class. */ + const Gt2* traits() { return surface_sweep()->traits(); } +}; + +} // namespace Surface_sweep_2 +} // namespace CGAL + +#endif diff --git a/Surface_sweep_2/include/CGAL/Surface_sweep_2/Do_interior_intersect_visitor.h b/Surface_sweep_2/include/CGAL/Surface_sweep_2/Do_interior_intersect_visitor.h new file mode 100644 index 00000000000..bb43344f1a1 --- /dev/null +++ b/Surface_sweep_2/include/CGAL/Surface_sweep_2/Do_interior_intersect_visitor.h @@ -0,0 +1,152 @@ +// Copyright (c) 2006,2007,2009,2010,2011 Tel-Aviv University (Israel). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// You can redistribute it and/or modify it under the terms of the GNU +// General Public License as published by the Free Software Foundation, +// either version 3 of the License, or (at your option) any later version. +// +// Licensees holding a valid commercial license may use this file in +// accordance with the commercial license agreement provided with the software. +// +// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Author(s) : Baruch Zukerman +// Ron Wein +// Efi Fogel + +#ifndef CGAL_SURFACE_SWEEP_2_DO_INTERIOR_INTERSECT_VISITORS_H +#define CGAL_SURFACE_SWEEP_2_DO_INTERIOR_INTERSECT_VISITORS_H + +#include + +/*! \file + * + * Definition of the basic sweep-line visitors, for the usage of the global + * sweep-line functions. + */ + +#include + +#include + +namespace CGAL { +namespace Surface_sweep_2 { + +/*! \class Do_interior_intersect_visitor + * + * A simple sweep-line visitor that determines whether the curves in a given set + * intersect in their interiors. + */ +template +class Do_interior_intersect_visitor : + public Default_visitor, + GeometryTraits_2, Allocator_> +{ +public: + typedef GeometryTraits_2 Geometry_traits_2; + typedef Allocator_ Allocator; + +private: + typedef Geometry_traits_2 Gt2; + typedef Do_interior_intersect_visitor Self; + typedef Default_visitor Base; + +public: + typedef typename Base::Event Event; + typedef typename Base::Subcurve Subcurve; + + typedef typename Subcurve::Status_line_iterator Status_line_iterator; + + typedef typename Gt2::X_monotone_curve_2 X_monotone_curve_2; + typedef typename Gt2::Point_2 Point_2; + + typedef typename Base::Surface_sweep_2 Surface_sweep_2; + +protected: + // Data members: + bool m_found_x; // Have we found an intersection so far. + +public: + Do_interior_intersect_visitor() : m_found_x(false) {} + + template + void sweep(CurveIterator begin, CurveIterator end) + { + std::vector curves_vec; + std::vector points_vec; + + curves_vec.reserve(std::distance(begin,end)); + make_x_monotone(begin, end, + std::back_inserter(curves_vec), + std::back_inserter(points_vec), + this-> traits()); + + // Perform the sweep. + Surface_sweep_2* sl = this->surface_sweep(); + sl->sweep(curves_vec.begin(), curves_vec.end(), + points_vec.begin(), points_vec.end()); + } + + void update_event(Event* /* e */, + Subcurve* /* sc1 */, + Subcurve* /* sc2 */, + bool /* is_new */) + { m_found_x = true; } + + void update_event(Event* /* e */, + Subcurve* /* sc1 */) + { m_found_x = true; } + + void update_event(Event* /* e */, + const Point_2& /* end_point */, + const X_monotone_curve_2& /* cv */, + Arr_curve_end /* cv_end */, + bool /* is_new */) + {} + + void update_event(Event* /* e */, + const X_monotone_curve_2& /* cv */, + Arr_curve_end /* cv_end */, + bool /* is_new */) + {} + + void update_event(Event* /* e */, + const Point_2& /* pt */, + bool /* is_new */) + {} + + template + void sweep_xcurves(XCurveIterator begin, XCurveIterator end) + { + // Perform the sweep. + Surface_sweep_2* sl = this->surface_sweep(); + sl->sweep(begin, end); + } + + void found_overlap(Subcurve* /* sc1 */, + Subcurve* /* sc2 */, + Subcurve* /* ov_sc */) + { m_found_x = true; } + + bool after_handle_event(Event* /* event */, + Status_line_iterator /* iter */, + bool /* flag */) + { + if (m_found_x) { + Surface_sweep_2* sl = this->surface_sweep(); + sl->stop_sweep(); + } + return true; + } + + bool found_intersection() { return m_found_x; } +}; + +} // namespace Surface_sweep_2 +} // namespace CGAL + +#endif diff --git a/Surface_sweep_2/include/CGAL/Surface_sweep_2/Event_comparer.h b/Surface_sweep_2/include/CGAL/Surface_sweep_2/Event_comparer.h new file mode 100644 index 00000000000..b31d6feaabe --- /dev/null +++ b/Surface_sweep_2/include/CGAL/Surface_sweep_2/Event_comparer.h @@ -0,0 +1,270 @@ +// Copyright (c) 2006,2007,2009,2010,2011 Tel-Aviv University (Israel). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// You can redistribute it and/or modify it under the terms of the GNU +// General Public License as published by the Free Software Foundation, +// either version 3 of the License, or (at your option) any later version. +// +// Licensees holding a valid commercial license may use this file in +// accordance with the commercial license agreement provided with the software. +// +// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Author(s) : Tali Zvi +// Baruch Zukerman +// Ron Wein +// Efi Fogel + +#ifndef CGAL_SURFACE_SWEEP_2_EVENT_COMPARER_H +#define CGAL_SURFACE_SWEEP_2_EVENT_COMPARER_H + +#include + +/*! \file + * + * Comparison functor of curves used by the surface-sweep algorithm. + */ + +#include +#include +#include + +namespace CGAL { +namespace Surface_sweep_2 { + +/*! \class + * A functor used to compare events and event points in an xy-lexicographic + * order. Used to maintain the order of the event queue (the X-structure) + * in the sweep-line algorithm. + */ +template +class Event_comparer { +public: + typedef GeometryTraits_2 Geometry_traits_2; + typedef Event_ Event; + +private: + typedef Geometry_traits_2 Gt2; +public: + + typedef typename Gt2::Point_2 Point_2; + typedef typename Gt2::X_monotone_curve_2 X_monotone_curve_2; + + // should be ok, as Gt2 is supposed to be the adaptor + typedef typename Gt2::Left_side_category Left_side_category; + typedef typename Gt2::Bottom_side_category Bottom_side_category; + typedef typename Gt2::Top_side_category Top_side_category; + typedef typename Gt2::Right_side_category Right_side_category; + +private: + // Data members: + const Gt2* m_traits; // The geometric-traits object. + + Arr_parameter_space m_ps_in_x; // Storing curve information when + Arr_parameter_space m_ps_in_y; // comparing a curve end with + Arr_curve_end m_index; // boundary conditions. + +public: + /*! Cosntruct. */ + Event_comparer(const Gt2* traits) : m_traits(traits) {} + + /*! Compare two existing events. + * This operator is called by the multiset assertions only in + * debug mode (to verify that event was inserted at the right place). + */ + Comparison_result operator()(const Event* e1, const Event* e2) const + { + const bool on_boundary1 = e1->is_on_boundary(); + const bool on_boundary2 = e2->is_on_boundary(); + + if (! on_boundary1 && ! on_boundary2) { + // Both events do not have boundary conditions - just compare the points. + return m_traits->compare_xy_2_object()(e1->point(), e2->point()); + } + + if (! on_boundary1) { + // Compare the point associated with the first event with the second + // boundary event. + return this->operator()(e1->point(), e2); + } + + if (! on_boundary2) { + // Compare the point associated with the second event with the first + // boundary event. + return CGAL::opposite(this->operator()(e2->point(), e1)); + } + + return _compare_curve_end_with_event(e1->curve(), _curve_end(e1), + e1->parameter_space_in_x(), + e1->parameter_space_in_y(), + e2); + } + + /*! Compare a point, which should be inserted into the event queue, + * with an existing event point. + */ + Comparison_result operator()(const Point_2& pt, const Event* e2) const + { + const bool on_boundary2 = e2->is_on_boundary(); + + if (! on_boundary2) { + // If e2 is a normal event, just compare pt and the event point. + return m_traits->compare_xy_2_object() (pt, e2->point()); + } + + // Get the sign of the event's boundary condition in x. Note that a valid + // point is always larger than any negative boundary event and smaller + // than any positive boundary event. + Arr_parameter_space ps_x2 = e2->parameter_space_in_x(); + + if (ps_x2 == ARR_LEFT_BOUNDARY) return LARGER; + else if (ps_x2 == ARR_RIGHT_BOUNDARY) return SMALLER; + + // Get the curve end that e2 represents, and compare the x-position of the + // given point and this curve end. + Arr_curve_end ind = _curve_end(e2); + Comparison_result res = + m_traits->compare_x_point_curve_end_2_object()(pt, e2->curve(), ind); + + if (res != EQUAL) return res; + + // The event and the point has the same x-position. Get the sign of the + // event's boundary condition in y. Note that a valid point is always + // larger than any negative boundary event and smaller than any positive + // boundary event. + Arr_parameter_space ps_y2 = e2->parameter_space_in_y(); + + CGAL_assertion (ps_y2 != ARR_INTERIOR); + return (ps_y2 == ARR_BOTTOM_BOUNDARY) ? LARGER : SMALLER; + } + + /*! Compare a curve end, which should be inserted into the event queue, + * with an existing event point. + * Note that the index of the curve end as well as its boundary conditions + * must be set beforehand using set_index() and set_parameter_space_in_x/y(). + */ + Comparison_result operator()(const X_monotone_curve_2& cv, + const Event* e2) const + { + return _compare_curve_end_with_event(cv, m_index, m_ps_in_x, m_ps_in_y, e2); + } + + /// \name Set the boundary conditions of a curve end we are about to compare. + //@{ + void set_parameter_space_in_x(Arr_parameter_space bx) { m_ps_in_x = bx; } + + void set_parameter_space_in_y(Arr_parameter_space by) { m_ps_in_y = by; } + + void set_index(Arr_curve_end ind) { m_index = ind; } + //@} + +private: + /*! Compare a given curve end with an event. + * \param cv The curve. + * \param ind The curve end. + * \param ps_x The boundary condition of the curve end in x. + * \param ps_y The boundary condition of the curve end in y. + * \param e2 The event, which may have boundary conditions. + * \return The comparison result of the curve end with the event. + */ + Comparison_result + _compare_curve_end_with_event(const X_monotone_curve_2& cv, + Arr_curve_end ind, + Arr_parameter_space ps_x, + Arr_parameter_space ps_y, + const Event* e2) const + { + // Check if the curve end has a boundary condition in x. + if (ps_x == ARR_LEFT_BOUNDARY) { + if (e2->parameter_space_in_x() == ARR_LEFT_BOUNDARY) { + // Both defined on the left boundary - compare them there. + CGAL_assertion (ind == ARR_MIN_END); + + return m_traits->compare_y_curve_ends_2_object() (cv, e2->curve(), ind); + } + + // The curve end is obviously smaller. + return SMALLER; + } + + if (ps_x == ARR_RIGHT_BOUNDARY) { + if (e2->parameter_space_in_x() == ARR_RIGHT_BOUNDARY) { + // Both defined on the right boundary - compare them there. + CGAL_assertion (ind == ARR_MAX_END); + + return m_traits->compare_y_curve_ends_2_object()(cv, e2->curve(), ind); + } + + // The curve end is obviously larger. + return LARGER; + } + + // Check if the event has a boundary condition in x. Note that if it + // has a negative boundary condition, the curve end is larger than it, + // and if it has a positive boundary condition, the curve end is smaller. + if (e2->parameter_space_in_x() == ARR_LEFT_BOUNDARY) return (LARGER); + if (e2->parameter_space_in_x() == ARR_RIGHT_BOUNDARY) return (SMALLER); + + CGAL_assertion(ps_y != ARR_INTERIOR); + Comparison_result res; + + Arr_curve_end ind2 = _curve_end(e2); + + // Act according to the boundary sign of the event. + if (e2->parameter_space_in_y() == ARR_BOTTOM_BOUNDARY) { + + // Compare the x-positions of the two entities. + res = m_traits->compare_x_curve_ends_2_object()(cv, ind, + e2->curve(), ind2); + if (res != EQUAL) return res; + + // In case of equal x-positions, the curve end is larger than the event, + // which lies on the bottom boundary (unless it also lies on the bottom + // boundary). + if (ps_y == ARR_BOTTOM_BOUNDARY) return EQUAL; + + return (LARGER); + } + + if (e2->parameter_space_in_y() == ARR_TOP_BOUNDARY) { + // Compare the x-positions of the two entities. + res = + m_traits->compare_x_curve_ends_2_object()(cv, ind, e2->curve(), ind2); + if (res != EQUAL) return res; + + // In case of equal x-positions, the curve end is smaller than the event, + // which lies on the top boundary (unless it also lies on the top + // boundary). + if (ps_y == ARR_TOP_BOUNDARY) return EQUAL; + + return SMALLER; + } + + // If we reached here, e2 is not a boundary event and is associated with + // a valid point. We compare the x-position of this point with the curve + // end. + res = m_traits->compare_x_point_curve_end_2_object()(e2->point(), cv, ind); + + if (res != EQUAL) return CGAL::opposite(res); + + // In case of equal x-positions, is the curve end has a negative boundary + // sign, then it lies on the bottom boundary below the event. Otherwise, + // it lies on the top aboundary above the event e2. + return (ps_y == ARR_BOTTOM_BOUNDARY) ? SMALLER : LARGER; + } + + /*! Detemine if the given event represents a left or a right curve end. */ + inline Arr_curve_end _curve_end(const Event* e) const + { + return (e->has_left_curves()) ? + ((e->is_right_end()) ? ARR_MAX_END : ARR_MIN_END) : + ((e->is_left_end()) ? ARR_MIN_END : ARR_MAX_END); + } +}; + +} // namespace Surface_sweep_2 +} // namespace CGAL + +#endif diff --git a/Surface_sweep_2/include/CGAL/Surface_sweep_2/Intersection_points_visitor.h b/Surface_sweep_2/include/CGAL/Surface_sweep_2/Intersection_points_visitor.h new file mode 100644 index 00000000000..4868f2999e3 --- /dev/null +++ b/Surface_sweep_2/include/CGAL/Surface_sweep_2/Intersection_points_visitor.h @@ -0,0 +1,122 @@ +// Copyright (c) 2006,2007,2009,2010,2011 Tel-Aviv University (Israel). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// You can redistribute it and/or modify it under the terms of the GNU +// General Public License as published by the Free Software Foundation, +// either version 3 of the License, or (at your option) any later version. +// +// Licensees holding a valid commercial license may use this file in +// accordance with the commercial license agreement provided with the software. +// +// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Author(s) : Baruch Zukerman +// Ron Wein +// Efi Fogel + +#ifndef CGAL_SURFACE_SWEEP_2_INTERSECTION_POINTS_VISITOR_H +#define CGAL_SURFACE_SWEEP_2_INTERSECTION_POINTS_VISITOR_H + +#include + +/*! \file + * + * Definition of a surface-sweep visitor that reports all intersection points + * among a set of input curves. + */ + +#include +// #include + +#include +#include + +namespace CGAL { +namespace Surface_sweep_2 { + +/*! \class Intersection_points_visitor + * + * A simple surface-sweep visitor that reports all intersection points among a + * set of input curves. Used by compute_intersection_points(). + */ +template +class Intersection_points_visitor : + public Default_visitor, + GeometryTraits_2, Allocator_> +{ +public: + typedef GeometryTraits_2 Geometry_traits_2; + typedef OutputIterator Output_iterator; + typedef Allocator_ Allocator; + +private: + typedef Geometry_traits_2 Gt2; + typedef Intersection_points_visitor + Self; + typedef Default_visitor Base; + +public: + typedef typename Base::Event Event; + typedef typename Base::Subcurve Subcurve; + + typedef typename Subcurve::Status_line_iterator Status_line_iterator; + + typedef typename Gt2::X_monotone_curve_2 X_monotone_curve_2; + typedef typename Gt2::Point_2 Point_2; + + typedef typename Base::Surface_sweep_2 Surface_sweep_2; + +protected: + Output_iterator m_out; // The output points. + bool m_includeEndPoints; // Should we include endpoints. + +public: + Intersection_points_visitor(Output_iterator out, bool endpoints) : + m_out(out), + m_includeEndPoints(endpoints) + {} + + template + void sweep(CurveIterator begin, CurveIterator end) + { + std::vector curves_vec; + std::vector points_vec; + + curves_vec.reserve(std::distance(begin,end)); + make_x_monotone(begin, end, + std::back_inserter(curves_vec), + std::back_inserter(points_vec), + this->traits()); + + //Perform the sweep + Surface_sweep_2* sl = this->surface_sweep(); + sl->sweep(curves_vec.begin(), curves_vec.end(), + points_vec.begin(), points_vec.end()); + } + + bool after_handle_event(Event* event, + Status_line_iterator /* iter */, + bool /* flag */) + { + if ((m_includeEndPoints || + event->is_intersection() || + event->is_weak_intersection()) && event->is_closed()) + { + *m_out = event->point(); + ++m_out; + } + return true; + } + + Output_iterator output_iterator() { return m_out; } +}; + +} // namespace Surface_sweep_2 +} // namespace CGAL + +#endif diff --git a/Sweep_line_2/include/CGAL/Sweep_line_2/Basic_sweep_line_2_impl.h b/Surface_sweep_2/include/CGAL/Surface_sweep_2/No_intersection_surface_sweep_2_impl.h similarity index 79% rename from Sweep_line_2/include/CGAL/Sweep_line_2/Basic_sweep_line_2_impl.h rename to Surface_sweep_2/include/CGAL/Surface_sweep_2/No_intersection_surface_sweep_2_impl.h index f7aaa486147..75f5bf36b5a 100644 --- a/Sweep_line_2/include/CGAL/Sweep_line_2/Basic_sweep_line_2_impl.h +++ b/Surface_sweep_2/include/CGAL/Surface_sweep_2/No_intersection_surface_sweep_2_impl.h @@ -21,25 +21,25 @@ // Eric Berberich // (based on old version by Tali Zvi) -#ifndef CGAL_BASIC_SWEEP_LINE_2_IMPL_H -#define CGAL_BASIC_SWEEP_LINE_2_IMPL_H - -#include +#ifndef CGAL_NO_INTERSECTION_SURFACE_SWEEP_2_IMPL_H +#define CGAL_NO_INTERSECTION_SURFACE_SWEEP_2_IMPL_H +#include /*! \file - * Member-function definitions for the Basic_sweep_line_2 class. + * + * Member-function definitions for the No_intersection_surface_sweep_2 class. */ namespace CGAL { +namespace Surface_sweep_2 { //----------------------------------------------------------------------------- // Constructor. // -template -Basic_sweep_line_2:: -Basic_sweep_line_2(Visitor* visitor) : +template +No_intersection_surface_sweep_2:: +No_intersection_surface_sweep_2(Visitor* visitor) : m_traits(new Traits_adaptor_2()), m_traitsOwner(true), m_statusLineCurveLess(m_traits, &m_currentEvent), @@ -58,10 +58,9 @@ Basic_sweep_line_2(Visitor* visitor) : //----------------------------------------------------------------------------- // Constructor with a given traits-class. // -template -Basic_sweep_line_2:: -Basic_sweep_line_2(const Traits_2* traits, Visitor* visitor) : +template +No_intersection_surface_sweep_2:: +No_intersection_surface_sweep_2(const Gt2* traits, Visitor* visitor) : m_traits(static_cast(traits)), m_traitsOwner(false), m_statusLineCurveLess(m_traits, &m_currentEvent), @@ -80,9 +79,8 @@ Basic_sweep_line_2(const Traits_2* traits, Visitor* visitor) : //----------------------------------------------------------------------------- // Destrcutor. // -template -Basic_sweep_line_2::~Basic_sweep_line_2() +template +No_intersection_surface_sweep_2::~No_intersection_surface_sweep_2() { // Free the traits-class object, if we own it. if (m_traitsOwner) delete m_traits; @@ -103,9 +101,8 @@ Basic_sweep_line_2::~Basic_sweep_line_2() //----------------------------------------------------------------------------- // Stop the sweep-line process. // -template -void Basic_sweep_line_2::stop_sweep() +template +void No_intersection_surface_sweep_2::stop_sweep() { // Clear the event queue, deallocating all events but the current one // (the first event in the queue). @@ -133,10 +130,8 @@ void Basic_sweep_line_2::stop_sweep() //----------------------------------------------------------------------------- // Deallocate event object.. // -template -void Basic_sweep_line_2:: -deallocate_event(Event* event) +template +void No_intersection_surface_sweep_2::deallocate_event(Event* event) { // Remove the event from the set of allocated events. m_allocated_events.erase(event); @@ -149,9 +144,8 @@ deallocate_event(Event* event) //----------------------------------------------------------------------------- // Perform the main sweep-line loop. // -template -void Basic_sweep_line_2::_sweep() +template +void No_intersection_surface_sweep_2::_sweep() { CGAL_SL_PRINT_TEXT("Ordered sequence of "); CGAL_SL_PRINT(m_queue->size()); @@ -210,9 +204,8 @@ void Basic_sweep_line_2::_sweep() //----------------------------------------------------------------------------- // Initialize the data structures for the sweep-line algorithm. // -template -void Basic_sweep_line_2::_init_structures() +template +void No_intersection_surface_sweep_2::_init_structures() { CGAL_assertion(m_queue->empty()); CGAL_assertion((m_statusLine.size() == 0)); @@ -226,9 +219,8 @@ void Basic_sweep_line_2::_init_structures() //----------------------------------------------------------------------------- // Complete the sweep (complete the data structures). // -template -void Basic_sweep_line_2::_complete_sweep() +template +void No_intersection_surface_sweep_2::_complete_sweep() { CGAL_assertion(m_queue->empty()); CGAL_assertion((m_statusLine.size() == 0)); @@ -244,10 +236,9 @@ void Basic_sweep_line_2::_complete_sweep() //----------------------------------------------------------------------------- // Initialize an event associated with a point. // -template -void Basic_sweep_line_2:: -_init_point(const Point_2& pt, Attribute type) +template +void No_intersection_surface_sweep_2::_init_point(const Point_2& pt, + Attribute type) { // Create the event, or obtain an existing event in the queue. // Note that an isolated point does not have any boundary conditions. @@ -261,9 +252,8 @@ _init_point(const Point_2& pt, Attribute type) //----------------------------------------------------------------------------- // Initialize the events associated with an x-monotone curve. // -template -void Basic_sweep_line_2:: +template +void No_intersection_surface_sweep_2:: _init_curve(const X_monotone_curve_2& curve, unsigned int index) { // Construct and initialize a subcurve object. @@ -279,14 +269,13 @@ _init_curve(const X_monotone_curve_2& curve, unsigned int index) //----------------------------------------------------------------------------- // Initialize an event associated with an x-monotone curve end. // -template -void Basic_sweep_line_2:: +template +void No_intersection_surface_sweep_2:: _init_curve_end(const X_monotone_curve_2& cv, Arr_curve_end ind, Subcurve* sc) { // Get the boundary conditions of the curve end. const Attribute end_attr = - (ind == ARR_MIN_END) ? Base_event::LEFT_END : Base_event::RIGHT_END; + (ind == ARR_MIN_END) ? Event::LEFT_END : Event::RIGHT_END; Arr_parameter_space ps_x = m_traits->parameter_space_in_x_2_object()(cv, ind); Arr_parameter_space ps_y = m_traits->parameter_space_in_y_2_object()(cv, ind); @@ -323,9 +312,8 @@ _init_curve_end(const X_monotone_curve_2& cv, Arr_curve_end ind, Subcurve* sc) //----------------------------------------------------------------------------- // Handle the subcurves to the left of the current event point. // -template -void Basic_sweep_line_2::_handle_left_curves() +template +void No_intersection_surface_sweep_2::_handle_left_curves() { CGAL_SL_PRINT_START_EOL("handling left curves at ("); CGAL_SL_DEBUG(PrintEvent(m_currentEvent)); @@ -344,18 +332,15 @@ void Basic_sweep_line_2::_handle_left_curves() if (m_is_event_on_above) { // The current event is on the interior of existing curve on the // status line. Since the basic sweep does not allow intersections, - // this is possible only if the event is an isolated query point. + // this is possible only if the event is an isolated query point. CGAL_assertion(! m_currentEvent->has_right_curves() && m_currentEvent->is_query()); - //m_is_event_on_above = true; m_visitor->before_handle_event(m_currentEvent); } - else - m_visitor->before_handle_event(m_currentEvent); + else m_visitor->before_handle_event(m_currentEvent); } - else - m_visitor->before_handle_event(m_currentEvent); + else m_visitor->before_handle_event(m_currentEvent); // Nothing else to do (no left curves). CGAL_SL_PRINT_END_EOL("handling left curves"); @@ -400,10 +385,8 @@ void Basic_sweep_line_2::_handle_left_curves() //----------------------------------------------------------------------------- // Handle an event that does not have any incident left curves. // -template -void Basic_sweep_line_2:: -_handle_event_without_left_curves() +template +void No_intersection_surface_sweep_2::_handle_event_without_left_curves() { // Check if the event is a boundary event or not. const Arr_parameter_space ps_x = m_currentEvent->parameter_space_in_x(); @@ -453,9 +436,8 @@ _handle_event_without_left_curves() // Sort the left subcurves of an event point according to their order in // their status line (no geometric comprasions are needed). // -template -void Basic_sweep_line_2::_sort_left_curves() +template +void No_intersection_surface_sweep_2::_sort_left_curves() { CGAL_SL_PRINT_START_EOL("sorting left curves"); CGAL_assertion(m_currentEvent->has_left_curves()); @@ -518,9 +500,8 @@ void Basic_sweep_line_2::_sort_left_curves() //----------------------------------------------------------------------------- // Handle the subcurves to the right of the current event point. // -template -void Basic_sweep_line_2::_handle_right_curves() +template +void No_intersection_surface_sweep_2::_handle_right_curves() { CGAL_SL_PRINT_START("Handling right curves at ("); CGAL_SL_DEBUG(PrintEvent(m_currentEvent)); @@ -537,12 +518,17 @@ void Basic_sweep_line_2::_handle_right_curves() // status line. Event_subcurve_iterator curr = m_currentEvent->right_curves_begin(); Event_subcurve_iterator right_end = m_currentEvent->right_curves_end(); - Status_line_iterator sl_iter; while (curr != right_end) { - CGAL_SL_PRINT_INSERT(*curr); - sl_iter = m_statusLine.insert_before(m_status_line_insert_hint, *curr); Subcurve* sc = *curr; + CGAL_SL_PRINT_INSERT(sc); + + // Insert the curve to the left-curves of the right event. + // sc->right_event()->add_curve_to_left(sc); + + // Insert the curve into the status line. + Status_line_iterator sl_iter = + m_statusLine.insert_before(m_status_line_insert_hint, sc); sc->set_hint(sl_iter); CGAL_SL_DEBUG(PrintStatusLine();); @@ -556,9 +542,8 @@ void Basic_sweep_line_2::_handle_right_curves() //----------------------------------------------------------------------------- // Add a subcurve to the right of an event point. // -template -bool Basic_sweep_line_2:: +template +bool No_intersection_surface_sweep_2:: _add_curve_to_right(Event* event, Subcurve* curve, bool /* overlap_exist */) { #if defined(CGAL_NO_ASSERTIONS) @@ -575,9 +560,8 @@ _add_curve_to_right(Event* event, Subcurve* curve, bool /* overlap_exist */) //----------------------------------------------------------------------------- // Remove a curve from the status line. // -template -void Basic_sweep_line_2:: +template +void No_intersection_surface_sweep_2:: _remove_curve_from_status_line(Subcurve* sc) { CGAL_SL_PRINT_START("removing a curve from the status line, "); @@ -602,12 +586,12 @@ _remove_curve_from_status_line(Subcurve* sc) //----------------------------------------------------------------------------- // Allocate an event object associated with a valid point. // -template -typename Basic_sweep_line_2::Event* -Basic_sweep_line_2:: -_allocate_event(const Point_2& pt, Attribute type, - Arr_parameter_space ps_x, Arr_parameter_space ps_y) +template +typename No_intersection_surface_sweep_2::Event* +No_intersection_surface_sweep_2::_allocate_event(const Point_2& pt, + Attribute type, + Arr_parameter_space ps_x, + Arr_parameter_space ps_y) { // Allocate the event. Event* e = m_eventAlloc.allocate(1); @@ -623,10 +607,9 @@ _allocate_event(const Point_2& pt, Attribute type, // Allocate an event at open boundary, // which is not associated with a valid point. // -template -typename Basic_sweep_line_2::Event* -Basic_sweep_line_2:: +template +typename No_intersection_surface_sweep_2::Event* +No_intersection_surface_sweep_2:: _allocate_event_at_open_boundary(Attribute type, Arr_parameter_space ps_x, Arr_parameter_space ps_y) @@ -642,13 +625,13 @@ _allocate_event_at_open_boundary(Attribute type, //----------------------------------------------------------------------------- // Push a closed event point into the event queue. // -template -std::pair::Event*, - bool> -Basic_sweep_line_2:: -_push_event(const Point_2& pt, Attribute type, - Arr_parameter_space ps_x, Arr_parameter_space ps_y, Subcurve* sc) +template +std::pair::Event*, bool> +No_intersection_surface_sweep_2::_push_event(const Point_2& pt, + Attribute type, + Arr_parameter_space ps_x, + Arr_parameter_space ps_y, + Subcurve* sc) { // Look for the point in the event queue. Event* e; @@ -676,27 +659,20 @@ _push_event(const Point_2& pt, Attribute type, // endpoints, update the event and the subcurve records accordingly. // Note that this must be done before we actually insert the new event // into the event queue. - if (sc != NULL) { - if (type == Base_event::LEFT_END) { - sc->set_left_event(e); - _add_curve_to_right(e, sc); - } - else { - CGAL_assertion(type == Base_event::RIGHT_END); - sc->set_right_event(e); - e->add_curve_to_left(sc); - } - } + _add_curve(e, sc, type); + // Insert the new event into the queue using the hint we got when we + // looked for it. + if (! exist) m_queue->insert_before(pair_res.first, e); + +#ifdef CGAL_SL_VERBOSE if (! exist) { - // Insert the new event into the queue using the hint we got when we - // looked for it. - m_queue->insert_before(pair_res.first, e); CGAL_SL_PRINT_NEW_EVENT(pt, e); } else { CGAL_SL_PRINT_UPDATE_EVENT(pt, e); } +#endif // Return the resulting event and a flag indicating whether we have created // a new event. @@ -706,17 +682,15 @@ _push_event(const Point_2& pt, Attribute type, //----------------------------------------------------------------------------- // Push an event point associated with a curve end into the event queue. // -template -std::pair::Event*, - bool> -Basic_sweep_line_2:: -_push_event(const X_monotone_curve_2& cv, Arr_curve_end ind, Attribute type, - Arr_parameter_space ps_x, Arr_parameter_space ps_y, Subcurve* sc) +template +std::pair::Event*, bool> +No_intersection_surface_sweep_2::_push_event(const X_monotone_curve_2& cv, + Arr_curve_end ind, + Attribute type, + Arr_parameter_space ps_x, + Arr_parameter_space ps_y, + Subcurve* sc) { - //cv has no member named 'base' - //std::cout << "cv: " << cv.base() << std::endl; - // Look for the curve end in the event queue. Event* e; @@ -759,26 +733,38 @@ _push_event(const X_monotone_curve_2& cv, Arr_curve_end ind, Attribute type, // endpoints, update the event and the subcurve records accordingly. // Note that this must be done before we actually insert the new event // into the event queue. - if (sc != NULL) { - if (type == Base_event::LEFT_END) { - sc->set_left_event(e); - _add_curve_to_right(e, sc); - } - else { - CGAL_assertion(type == Base_event::RIGHT_END); - sc->set_right_event(e); - e->add_curve_to_left(sc); - } - } + _add_curve(e, sc, type); + + // Insert the new event into the queue using the hint we got when we + // looked for it. + if (! exist) m_queue->insert_before(pair_res.first, e); - if (! exist) { - // Insert the new event into the queue using the hint we got when we - // looked for it. - m_queue->insert_before(pair_res.first, e); - } return (std::make_pair(e, !exist)); } -} //namespace CGAL +//----------------------------------------------------------------------------- +// add a curve as a right curve or left curve when the event is created +// or updated. +// +template +void No_intersection_surface_sweep_2::_add_curve(Event* e, Subcurve* sc, + Attribute type) +{ + if (sc == NULL) return; + + if (type == Event::LEFT_END) { + sc->set_left_event(e); + _add_curve_to_right(e, sc); + return; + } + + CGAL_assertion(type == Event::RIGHT_END); + sc->set_right_event(e); + // Defer the insertion of the curve to the left-curves of the right event. + e->add_curve_to_left(sc); +} + +} // namespace Surface_sweep_2 +} // namespace CGAL #endif diff --git a/Surface_sweep_2/include/CGAL/Surface_sweep_2/No_overlap_event.h b/Surface_sweep_2/include/CGAL/Surface_sweep_2/No_overlap_event.h new file mode 100644 index 00000000000..793356867ad --- /dev/null +++ b/Surface_sweep_2/include/CGAL/Surface_sweep_2/No_overlap_event.h @@ -0,0 +1,78 @@ +// Copyright (c) 2006,2007,2009,2010,2011 Tel-Aviv University (Israel). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// You can redistribute it and/or modify it under the terms of the GNU +// General Public License as published by the Free Software Foundation, +// either version 3 of the License, or (at your option) any later version. +// +// Licensees holding a valid commercial license may use this file in +// accordance with the commercial license agreement provided with the software. +// +// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Author(s) : Tali Zvi , +// Baruch Zukerman +// Ron Wein +// Efi Fogel + +#ifndef CGAL_SURFACE_SWEEP_2_NO_OVERLAP_EVENT_H +#define CGAL_SURFACE_SWEEP_2_NO_OVERLAP_EVENT_H + +#include + +/*! \file + * + * Defintion of the No_overlap_event class. + */ + +#include +#include + +namespace CGAL { +namespace Surface_sweep_2 { + +/*! \class No_overlap_event + * + * This template represents an event used by the surface-sweep framework, where + * the input curves for the surface-sweep procedure are guaranteed not to + * overlap. + * + * \tparam GeometryTraits_2 the geometry traits. + * \tparam Allocator_ a type of an element that is used to acquire/release + * memory for elements of the event queue and the status + * structure, and to construct/destroy the elements in that + * memory. The type must meet the requirements of Allocator. + * + * We exploit the curiously recurring template pattern (CRTP) idiom to establish + * an interdependency between the curve and the event types, which are template + * parameters of the surface-sweep visitor class templates. It enables the + * definition of these two types, which refer one to another; (the curves to the + * right of an event and the curves to its left are data members of the event, + * and the two events associated with the endpoints of a curve are data memebrs + * of the curve.) + * + * If you need to represent an event with additional data members, introduce a + * new type, say x, that derives from x_base, and have x_base derive from + * No_overlap_event_base; do not use this class as base in your derivation. + */ +template +class No_overlap_event : + public No_overlap_event_base, + Allocator_> > +{ +public: + /*! Construct default. */ + No_overlap_event() {} +}; + +} // namespace Surface_sweep_2 +} // namespace CGAL + +#endif diff --git a/Sweep_line_2/include/CGAL/Sweep_line_2/Sweep_line_event.h b/Surface_sweep_2/include/CGAL/Surface_sweep_2/No_overlap_event_base.h similarity index 53% rename from Sweep_line_2/include/CGAL/Sweep_line_2/Sweep_line_event.h rename to Surface_sweep_2/include/CGAL/Surface_sweep_2/No_overlap_event_base.h index af93827abf7..0652e48a990 100644 --- a/Sweep_line_2/include/CGAL/Sweep_line_2/Sweep_line_event.h +++ b/Surface_sweep_2/include/CGAL/Surface_sweep_2/No_overlap_event_base.h @@ -18,28 +18,27 @@ // // Author(s) : Tali Zvi , // Baruch Zukerman -// Ron Wein -// Efi Fogel +// Ron Wein +// Efi Fogel -#ifndef CGAL_SWEEP_LINE_EVENT_H -#define CGAL_SWEEP_LINE_EVENT_H - -#include +#ifndef CGAL_SURFACE_SWEEP_2_NO_OVERLAP_EVENT_BASE_H +#define CGAL_SURFACE_SWEEP_2_NO_OVERLAP_EVENT_BASE_H +#include /*! \file - * Defintion of the Sweep_line_event class. + * + * Defintion of the No_overlap_event_base class. */ #include -#include - namespace CGAL { +namespace Surface_sweep_2 { -/*! \class Sweep_line_event +/*! \class No_overlap_event_base * - * A class associated with an event in a sweep line algorithm. + * A class associated with an event in a surface-sweep algorithm. * An intersection point in the sweep line algorithm is refered to as an event. * This class contains the information that is associated with any given * event point. This information contains the following: @@ -53,26 +52,28 @@ namespace CGAL { * significant functionality otherwise. * */ -template -class Sweep_line_event { +template +class No_overlap_event_base { public: - typedef Traits_ Traits_2; - typedef typename Traits_2::X_monotone_curve_2 X_monotone_curve_2; - typedef typename Traits_2::Point_2 Point_2; + typedef GeometryTraits_2 Geometry_traits_2; + typedef Subcurve_ Subcurve; - // should be ok, as Traits_ has already extended by Basic_sweep_line - typedef typename internal::Arr_complete_left_side_category::Category +private: + typedef Geometry_traits_2 Gt2; + +public: + typedef typename Gt2::X_monotone_curve_2 X_monotone_curve_2; + typedef typename Gt2::Point_2 Point_2; + + typedef typename internal::Arr_complete_left_side_category::Category Left_side_category; - typedef typename internal::Arr_complete_bottom_side_category::Category + typedef typename internal::Arr_complete_bottom_side_category::Category Bottom_side_category; - typedef typename internal::Arr_complete_top_side_category::Category + typedef typename internal::Arr_complete_top_side_category::Category Top_side_category; - typedef typename internal::Arr_complete_right_side_category::Category + typedef typename internal::Arr_complete_right_side_category::Category Right_side_category; - typedef Subcurve_ Subcurve; - //template - //struct SC_container { typedef std::list other; }; typedef std::list Subcurve_container; typedef typename Subcurve_container::iterator Subcurve_iterator; typedef typename Subcurve_container::const_iterator Subcurve_const_iterator; @@ -80,6 +81,7 @@ public: Subcurve_reverse_iterator; /*! \enum The event type (with other information bits). */ + enum Attribute { DEFAULT = 0, LEFT_END = 1, // A curve's left-end is on the event point. @@ -96,10 +98,10 @@ protected: // Data members: Point_2 m_point; // The point associated with the event. - Subcurve_container m_leftCurves; // The curves lying to the left of the + Subcurve_container m_left_curves; // The curves lying to the left of the // event and incident to it. - Subcurve_container m_rightCurves; // The curves lying to the right of the + Subcurve_container m_right_curves; // The curves lying to the right of the // event and incident to it, sorted by // their y-value to the right of the point. @@ -111,7 +113,7 @@ protected: public: /*! Default constructor. */ - Sweep_line_event() : + No_overlap_event_base() : m_type(0), m_ps_x(static_cast(ARR_INTERIOR)), m_ps_y(static_cast(ARR_INTERIOR)), @@ -145,47 +147,29 @@ public: { // Look for the subcurve. Subcurve_iterator iter; - - //std::cout << "add_curve_to_left, curve: "; - //curve->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)) { - //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))) { - //std::cout << "add_curve_to_left, curve overlaps" << std::endl; - *iter = curve; - return; - } + for (iter = m_left_curves.begin(); iter != m_left_curves.end(); ++iter) { + if (curve == *iter) return; // do nothing if the curve exists. } // The curve does not exist - insert it to the container. - m_leftCurves.push_back(curve); - // std::cout << "add_curve_to_left, pushed back" << std::endl; - - //this->Print(); + m_left_curves.push_back(curve); } /*! Add a subcurve to the container of left curves (without checks). */ void push_back_curve_to_left(Subcurve* curve) - { m_leftCurves.push_back(curve); } + { m_left_curves.push_back(curve); } + + /*! Add a subcurve to the container of right curves (without checks). */ + void push_back_curve_to_right(Subcurve* curve) + { m_right_curves.push_back(curve); } /*! 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* curve, const Gt2* tr) { - if (m_rightCurves.empty()) { - m_rightCurves.push_back(curve); - return (std::make_pair(false, m_rightCurves.begin())); + if (m_right_curves.empty()) { + m_right_curves.push_back(curve); + return (std::make_pair(false, m_right_curves.begin())); } // Check if its an event at open boundary, @@ -193,27 +177,25 @@ public: //(there cannot be two non-overlap curves at the same event at open // boundary). if (!this->is_closed()) - return (std::make_pair(true, m_rightCurves.begin())); + return (std::make_pair(true, m_right_curves.begin())); - Subcurve_iterator iter = m_rightCurves.begin(); + Subcurve_iterator iter = m_right_curves.begin(); Comparison_result res; while ((res = tr->compare_y_at_x_right_2_object() (curve->last_curve(), (*iter)->last_curve(), m_point)) == LARGER) { ++iter; - if (iter == m_rightCurves.end()) { - m_rightCurves.insert(iter, curve); + if (iter == m_right_curves.end()) { + m_right_curves.insert(iter, curve); return std::make_pair(false, --iter); } } - if (res == EQUAL) //overlap !! - { - return std::make_pair(true, iter); - } + // Cannot overlap! + CGAL_assertion(res != EQUAL); - m_rightCurves.insert(iter, curve); + m_right_curves.insert(iter, curve); return std::make_pair(false, --iter); } @@ -224,92 +206,87 @@ public: std::pair add_curve_pair_to_right(Subcurve* sc1, Subcurve* sc2) { - m_rightCurves.push_back(sc1); - m_rightCurves.push_back(sc2); + m_right_curves.push_back(sc1); + m_right_curves.push_back(sc2); - Subcurve_iterator iter = m_rightCurves.end(); + Subcurve_iterator iter = m_right_curves.end(); --iter; return (std::make_pair(false, iter)); } - /*! Remove a curve from the set of left curves. */ - void remove_curve_from_left(Subcurve* curve) - { - Subcurve_iterator iter; - for (iter = m_leftCurves.begin(); iter!= m_leftCurves.end(); ++iter) { - if (curve->has_common_leaf(*iter)) { - m_leftCurves.erase(iter); - return; - } - } - } + /*! Return an iterator to the first curve to the left of the event. */ + Subcurve_iterator left_curves_begin() { return (m_left_curves.begin()); } - /*! Returns an iterator to the first curve to the left of the event. */ - Subcurve_iterator left_curves_begin() { return (m_leftCurves.begin()); } + /*! Return an iterator to the one past the last curve to the left + * of the event. + */ + Subcurve_iterator left_curves_end() { return (m_left_curves.end()); } - /*! Returns an iterator to the one past the last curve to the left - of the event. */ - Subcurve_iterator left_curves_end() { return (m_leftCurves.end()); } + /*! Return an iterator to the first curve to the right of the event. */ + Subcurve_iterator right_curves_begin() { return (m_right_curves.begin()); } - /*! Returns an iterator to the first curve to the right of the event. */ - Subcurve_iterator right_curves_begin() { return (m_rightCurves.begin()); } - - /*! Returns an iterator to the one past the last curve to the right - of the event. */ - Subcurve_iterator right_curves_end() { return (m_rightCurves.end()); } + /*! Return an iterator to the one past the last curve to the right + * of the event. + */ + Subcurve_iterator right_curves_end() { return (m_right_curves.end()); } /*! Returns a const iterator to the first curve to the left of the event. */ Subcurve_const_iterator left_curves_begin() const - { return m_leftCurves.begin(); } + { return m_left_curves.begin(); } - /*! Returns a const iterator to the past the end curve to the left - of the event. */ + /*! Return a const iterator to the past the end curve to the left + * of the event. + */ Subcurve_const_iterator left_curves_end() const - { return m_leftCurves.end(); } + { return m_left_curves.end(); } - /*! Returns a const iterator to the first curve to the right of the event. */ + /*! Return a const iterator to the first curve to the right of the event. */ Subcurve_const_iterator right_curves_begin() const - { return m_rightCurves.begin(); } + { return m_right_curves.begin(); } - /*! Returns a const iterator to the past the end curve to the right - of the event. */ + /*! Return a const iterator to the past the end curve to the right + * of the event. + */ Subcurve_const_iterator right_curves_end() const - { return m_rightCurves.end(); } + { return m_right_curves.end(); } - /*! Returns a reverse_iterator to the first curve of the reversed list - of the right curves of the event. */ + /*! Return a reverse_iterator to the first curve of the reversed list + * of the right curves of the event. + */ Subcurve_reverse_iterator right_curves_rbegin() - { return m_rightCurves.rbegin(); } + { return m_right_curves.rbegin(); } - /*! Returns a reverse_iterator to the past-end curve of the reversed list - of the right curves of the event. */ + /*! Return a reverse_iterator to the past-end curve of the reversed list + * of the right curves of the event. + */ Subcurve_reverse_iterator right_curves_rend() - { return m_rightCurves.rend(); } + { return m_right_curves.rend(); } - /*! Returns a reverse_iterator to the first curve of the reversed list - of the left curves of the event. */ + /*! Return a reverse_iterator to the first curve of the reversed list + * of the left curves of the event. + */ Subcurve_reverse_iterator left_curves_rbegin() - { return m_leftCurves.rbegin(); } + { return m_left_curves.rbegin(); } - /*! Returns a reverse_iterator to the past-end curve of the reversed list - of the left curves of the event. */ + /*! Return a reverse_iterator to the past-end curve of the reversed list + * of the left curves of the event. + */ Subcurve_reverse_iterator left_curves_rend() - { return m_leftCurves.rend(); } + { return m_left_curves.rend(); } - /*! Returns the number of curves defined to the left of the event. */ - size_t number_of_left_curves() { return m_leftCurves.size(); } + /*! Return the number of curves defined to the left of the event. */ + size_t number_of_left_curves() { return m_left_curves.size(); } - /*! Returns the number of curves defined to the right of the event. */ - size_t number_of_right_curves() { return (m_rightCurves.size()); } + /*! Return the number of curves defined to the right of the event. */ + size_t number_of_right_curves() { return (m_right_curves.size()); } - /*! Checks if at least one curve is defined to the left of the event. */ - bool has_left_curves() const { return (! m_leftCurves.empty()); } + /*! Check whether at least one curve is defined to the left of the event. */ + bool has_left_curves() const { return (! m_left_curves.empty()); } /*! Checks if at least one curve is defined to the right of the event. */ - bool has_right_curves() const { return (! m_rightCurves.empty()); } + bool has_right_curves() const { return (! m_right_curves.empty()); } - /*! - * Get the actual event point (const version). + /*! Obtain the actual event point (const version). * \pre The event is associated with a valid point. */ const Point_2& point() const @@ -318,8 +295,7 @@ public: return m_point; } - /*! - * Get the actual event point (non-const version). + /*! Obtain the actual event point (non-const version). * \pre The event is associated with a valid point. */ Point_2& point() @@ -328,17 +304,15 @@ public: return m_point; } - /*! - * Get a curve associated with the event (const version). + /*! Obtain a curve associated with the event (const version). * \pre The event has incident curves. */ const X_monotone_curve_2& curve() const { - if (has_left_curves()) - return (m_leftCurves.front()->last_curve()); + if (has_left_curves()) return (m_left_curves.front()->last_curve()); - CGAL_assertion (has_right_curves()); - return (m_rightCurves.front()->last_curve()); + CGAL_assertion(has_right_curves()); + return (m_right_curves.front()->last_curve()); } /*! Set the event point. */ @@ -402,46 +376,28 @@ public: template void replace_left_curves(InputIterator begin, InputIterator end) { - Subcurve_iterator left_iter = m_leftCurves.begin(); + Subcurve_iterator left_iter = m_left_curves.begin(); for (InputIterator iter = begin; iter != end; ++iter, ++left_iter) - *left_iter = static_cast(*iter); - m_leftCurves.erase(left_iter, m_leftCurves.end()); - } - - bool is_right_curve_bigger(Subcurve* c1, Subcurve* c2) - { - Subcurve_iterator iter; - for (iter = m_rightCurves.begin(); iter != m_rightCurves.end(); ++iter) { - if ((*iter == c1) || - (static_cast((*iter)->originating_subcurve1()) == c1) || - (static_cast((*iter)->originating_subcurve2()) == c1)) - return false; - - if ((*iter == c2) || - (static_cast((*iter)->originating_subcurve1()) == c2) || - (static_cast((*iter)->originating_subcurve2()) == c2)) - return true; - } - - return true; + *left_iter = *iter; + m_left_curves.erase(left_iter, m_left_curves.end()); } /*! Check if the two curves are negihbors to the left of the event. */ bool are_left_neighbours(Subcurve* c1, Subcurve* c2) { - Subcurve_iterator left_iter = m_leftCurves.begin(); - for (; left_iter != m_leftCurves.end(); ++left_iter) { + Subcurve_iterator left_iter = m_left_curves.begin(); + for (; left_iter != m_left_curves.end(); ++left_iter) { if (*left_iter == c1) { Subcurve_iterator temp = left_iter; ++temp; - if (temp != m_leftCurves.end()) return (*temp == c2); + if (temp != m_left_curves.end()) return (*temp == c2); return false; } if (*left_iter == c2) { Subcurve_iterator temp = left_iter; ++temp; - if (temp!=m_leftCurves.end()) return (*temp == c1); + if (temp != m_left_curves.end()) return (*temp == c1); return false; } } @@ -455,52 +411,51 @@ public: }; #ifdef CGAL_SL_VERBOSE - template - void Sweep_line_event::Print() - { - std::cout << "\tEvent info: " << "\n" ; - if (this->is_closed()) - std::cout << "\t" << m_point << "\n" ; - else { - std::cout << "\t"; - Arr_parameter_space ps_x = this->parameter_space_in_x(); - Arr_parameter_space ps_y = this->parameter_space_in_y(); +template +void No_overlap_event_base::Print() +{ + std::cout << "\tEvent info: " << "\n" ; + if (this->is_closed()) std::cout << "\t" << m_point << "\n" ; + else { + std::cout << "\t"; + Arr_parameter_space ps_x = this->parameter_space_in_x(); + Arr_parameter_space ps_y = this->parameter_space_in_y(); - switch (ps_x) { - case ARR_LEFT_BOUNDARY: std::cout << "left boundary"; break; - case ARR_RIGHT_BOUNDARY: std::cout << "right boundary"; break; + switch (ps_x) { + case ARR_LEFT_BOUNDARY: std::cout << "left boundary"; break; + case ARR_RIGHT_BOUNDARY: std::cout << "right boundary"; break; + case ARR_INTERIOR: + default: + switch (ps_y) { + case ARR_BOTTOM_BOUNDARY: std::cout << "bottom boundary"; break; + case ARR_TOP_BOUNDARY: std::cout << "top boundary"; break; case ARR_INTERIOR: - default: - switch (ps_y) { - case ARR_BOTTOM_BOUNDARY: std::cout << "bottom boundary"; break; - case ARR_TOP_BOUNDARY: std::cout << "top boundary"; break; - case ARR_INTERIOR: - default: - CGAL_error(); - } + default: CGAL_error(); } } - std::cout << "\n"; - - std::cout << "\tLeft curves: \n" ; - Subcurve_iterator iter; - for (iter = m_leftCurves.begin(); iter != m_leftCurves.end(); ++iter) { - std::cout << "\t"; - (*iter)->Print(); - std::cout << "\n"; - } - std::cout << std::endl; - std::cout << "\tRight curves: \n" ; - for (iter = m_rightCurves.begin(); iter != m_rightCurves.end(); ++iter) { - std::cout << "\t"; - (*iter)->Print(); - std::cout << "\n"; - } - - std::cout << std::endl; } + std::cout << "\n"; + + std::cout << "\tLeft curves: \n" ; + Subcurve_iterator iter; + for (iter = m_left_curves.begin(); iter != m_left_curves.end(); ++iter) { + std::cout << "\t"; + (*iter)->Print(); + std::cout << "\n"; + } + std::cout << std::endl; + std::cout << "\tRight curves: \n" ; + for (iter = m_right_curves.begin(); iter != m_right_curves.end(); ++iter) { + std::cout << "\t"; + (*iter)->Print(); + std::cout << "\n"; + } + + std::cout << std::endl; +} #endif // CGAL_SL_VERBOSE -} //namespace CGAL +} // namespace Surface_sweep_2 +} // namespace CGAL #endif diff --git a/Surface_sweep_2/include/CGAL/Surface_sweep_2/No_overlap_subcurve.h b/Surface_sweep_2/include/CGAL/Surface_sweep_2/No_overlap_subcurve.h new file mode 100644 index 00000000000..3aef9a91391 --- /dev/null +++ b/Surface_sweep_2/include/CGAL/Surface_sweep_2/No_overlap_subcurve.h @@ -0,0 +1,210 @@ +// Copyright (c) 2006,2007,2009,2010,2011 Tel-Aviv University (Israel). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// You can redistribute it and/or modify it under the terms of the GNU +// General Public License as published by the Free Software Foundation, +// either version 3 of the License, or (at your option) any later version. +// +// Licensees holding a valid commercial license may use this file in +// accordance with the commercial license agreement provided with the software. +// +// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Author(s) : Tali Zvi , +// Baruch Zukerman +// Ron Wein +// Efi Fogel + +#ifndef CGAL_SURFACE_SWEEP_2_NO_OVERLAP_SUBCURVE_H +#define CGAL_SURFACE_SWEEP_2_NO_OVERLAP_SUBCURVE_H + +#include + +/*! \file + * + * Defintion of the No_overlap_subcurve class, which is an + * extended curve type, referred to as Subcurve, used by the surface-sweep + * framework. + * + * The surface-sweep framework is implemented as a template that is + * parameterized by a visitor; the visitor is parameterized, among the other, by + * the Subcurve and Event types. That is, instance types of Subcurve and Event + * must be available when the surface-sweep template is instantiated. + * + * No_overlap_subcurve is the most basic type. The user is allowed + * to introduce new types that derive from the basic type. However, some of the + * fields of the basic type depends on the Subcurve type. We use the curiously + * recurring template pattern (CRTP) idiom to force the correct matching of + * these types. + */ + +#include +#include +#include +#include + +namespace CGAL { +namespace Surface_sweep_2 { + +/*! \class No_overlap_subcurve_base + * + * This is the base class of the No_overlap_subcurve class + * template used by the (CRTP) idiom. + * \tparam GeometryTraits_2 the geometry traits. + * \tparam Subcurve_ the subcurve actual type. + * + * The information contained in this class is: + * - two event points, which are associated with the left and right end of the + * curve. + * - an iterator that points to the location of the subcurve in the status line. + */ +template +class No_overlap_subcurve_base { +public: + typedef GeometryTraits_2 Geometry_traits_2; + typedef Subcurve_ Subcurve; + typedef Event_ Event; + typedef Allocator_ Allocator; + +private: + typedef Geometry_traits_2 Gt2; + +public: + typedef Curve_comparer Compare_curves; + typedef Multiset + Status_line; + typedef typename Status_line::iterator Status_line_iterator; + +protected: + Status_line_iterator m_hint; // The location of the subcurve in the + // status line (the Y-structure). + Event* m_left_event; // The event associated with the left end. + Event* m_right_event; // The event associated with the right end + +public: + /*! Check whether the given event is the matches the right-end event. + */ + template + bool is_end_point(const SweepEvent* event) const + { return (m_right_event == event); } + + /*! Obtain the event that corresponds to the left end of the subcurve. + */ + Event* left_event() const { return m_left_event; } + + /*! Obtain the event that corresponds to the right end of the subcurve. + */ + Event* right_event() const { return m_right_event; } + + /*! Set the event that corresponds to the left end of the subcurve. */ + void set_left_event(Event* event) { m_left_event = event; } + + /*! Set the event that corresponds to the right end of the subcurve. */ + void set_right_event(Event* event) { m_right_event = event; } + + /*! Obtain the location of the subcurve in the status line .*/ + Status_line_iterator hint() const { return m_hint; } + + /*! Set the location of the subcurve in the status line .*/ + void set_hint(Status_line_iterator hint) { m_hint = hint; } +}; + +/*! \class No_overlap_subcurve + * + * This is a class template that wraps a traits curve of type + * X_monotone_curve_2. It contains data that is used when applying the sweep + * algorithm on a set of x-monotone curves. This class derives from the + * No_overlap_subcurve_base class template. + * + * The information contained in this class (in addition to the information + * contaisn in its base) is: + * - the remaining x-monotone curve that is to the right of the current sweep + * line. + * \tparam GeometryTraits_2 the geometry traits. + * \tparam Event_ the event type. + * \tparam Allocator_ a type of an element that is used to acquire/release + * memory for elements of the event queue and the status + * structure, and to construct/destroy the elements in that + * memory. The type must meet the requirements of Allocator. + * \tparam Subcurve_ the type of the subcurve or Default. If the default is not + * overriden it implies that the type is No_overlap_subcurve. + */ +template +class No_overlap_subcurve : + public No_overlap_subcurve_base< + GeometryTraits_2, Event_, Allocator_, + typename Default::Get >::type> +{ +public: + typedef GeometryTraits_2 Geometry_traits_2; + typedef Event_ Event; + typedef Allocator_ Allocator; + +private: + typedef Geometry_traits_2 Gt2; + typedef No_overlap_subcurve + Self; + typedef typename Default::Get::type Subcurve; + typedef No_overlap_subcurve_base + Base; + +public: + typedef typename Gt2::X_monotone_curve_2 X_monotone_curve_2; + + typedef typename Base::Status_line_iterator Status_line_iterator; + +protected: + // Data members: + X_monotone_curve_2 m_last_curve; // The portion of the curve that lies to + // the right of the last event point + // that occured on the curve. + +public: + /*! Construct default. */ + No_overlap_subcurve() {} + + /*! Construct from a curve. + * \param curve the input x-monotone curve. + */ + No_overlap_subcurve(const X_monotone_curve_2& curve) : + m_last_curve(curve) + {} + + /*! Initialize the subcurves by setting the curve. */ + void init(const X_monotone_curve_2& curve) { m_last_curve = curve; } + + /*! Destruct. */ + ~No_overlap_subcurve() {} + + /*! Get the last intersecing curve so far (const version). */ + const X_monotone_curve_2& last_curve() const { return m_last_curve; } + + /*! Get the last intersecing curve so far (non-const version). */ + X_monotone_curve_2& last_curve() { return m_last_curve; } + + /*! Set the last intersecing curve so far. + */ + void set_last_curve(const X_monotone_curve_2& cv) { m_last_curve = cv; } + +#ifdef CGAL_SL_VERBOSE + void Print() const; +#endif +}; + +#ifdef CGAL_SL_VERBOSE +template +void No_overlap_subcurve::Print() const +{ std::cout << "Curve " << this << " (" << last_curve() << ") "; } +#endif + +} // namespace Surface_sweep_2 +} // namespace CGAL + +#endif diff --git a/Surface_sweep_2/include/CGAL/Surface_sweep_2/Subcurves_visitor.h b/Surface_sweep_2/include/CGAL/Surface_sweep_2/Subcurves_visitor.h new file mode 100644 index 00000000000..50a8e88a72f --- /dev/null +++ b/Surface_sweep_2/include/CGAL/Surface_sweep_2/Subcurves_visitor.h @@ -0,0 +1,124 @@ +// Copyright (c) 2005,2006,2007,2009,2010,2011 Tel-Aviv University (Israel). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// You can redistribute it and/or modify it under the terms of the GNU +// General Public License as published by the Free Software Foundation, +// either version 3 of the License, or (at your option) any later version. +// +// Licensees holding a valid commercial license may use this file in +// accordance with the commercial license agreement provided with the software. +// +// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Author(s): Baruch Zukerman +// Efi Fogel +// (based on old version by Tali Zvi) + +#ifndef CGAL_SURFACE_SWEEP_2_SUBCURVES_VISITOR_H +#define CGAL_SURFACE_SWEEP_2_SUBCURVES_VISITOR_H + +#include + +/*! \file + * + * Definition of a surface-sweep visitor that reports all maximal x-monotone + * non-intersecting x-monotone curves induced by a set of input curves. + */ + +#include + +#include +#include + +namespace CGAL { +namespace Surface_sweep_2 { + +/*! \class Subcurves_visitor + * + * A simple sweep-line visitor that reports all maximal x-monotone + * non-intersecting x-monotone curves induced by a set of input curves. Used by + * compute_subcurves(). + */ +template +class Subcurves_visitor : + public Default_visitor, + GeometryTraits_2, Allocator_> +{ +public: + typedef GeometryTraits_2 Geometry_traits_2; + typedef OutputIerator Output_ierator; + typedef Allocator_ Allocator; + +private: + typedef Geometry_traits_2 Gt2; + typedef Subcurves_visitor + Self; + typedef Default_visitor Base; + +public: + typedef typename Gt2::X_monotone_curve_2 X_monotone_curve_2; + typedef typename Gt2::Point_2 Point_2; + + typedef typename Base::Event Event; + typedef typename Base::Subcurve Subcurve; + + typedef typename Subcurve::Status_line_iterator Status_line_iterator; + + typedef typename Base::Surface_sweep_2 Surface_sweep_2; + +protected: + // Data members: + Output_ierator m_out; // The output curves. + bool m_overlapping; // Should we report overlapping curves twice. + +public: + Subcurves_visitor(Output_ierator out, bool overlapping) : + m_out(out), + m_overlapping(overlapping) + {} + + template + void sweep(CurveIterator begin, CurveIterator end) + { + std::vector curves_vec; + std::vector points_vec; + + curves_vec.reserve(std::distance(begin,end)); + make_x_monotone(begin, end, + std::back_inserter(curves_vec), + std::back_inserter(points_vec), + this->traits()); + + // Perform the sweep. + Surface_sweep_2* sl = this->surface_sweep(); + sl->sweep(curves_vec.begin(), curves_vec.end(), + points_vec.begin(), points_vec.end()); + } + + void add_subcurve(const X_monotone_curve_2& cv, Subcurve *sc) + { + if (!m_overlapping) { + // Report the curve once, whether it represents an overlap or not. + *m_out = cv; + ++m_out; + } + else { + unsigned int overlap_depth = sc->overlap_depth(); + for (unsigned int i = 0; i < overlap_depth; ++i) { + *m_out = cv; + ++m_out; + } + } + } + + Output_ierator output_iterator() { return m_out; } +}; + +} // namespace Surface_sweep_2 +} // namespace CGAL + +#endif diff --git a/Sweep_line_2/include/CGAL/Sweep_line_2/Sweep_line_2_debug.h b/Surface_sweep_2/include/CGAL/Surface_sweep_2/Surface_sweep_2_debug.h similarity index 62% rename from Sweep_line_2/include/CGAL/Sweep_line_2/Sweep_line_2_debug.h rename to Surface_sweep_2/include/CGAL/Surface_sweep_2/Surface_sweep_2_debug.h index f4c512fab3c..1a3548618be 100644 --- a/Sweep_line_2/include/CGAL/Sweep_line_2/Sweep_line_2_debug.h +++ b/Surface_sweep_2/include/CGAL/Surface_sweep_2/Surface_sweep_2_debug.h @@ -19,23 +19,24 @@ // Author(s) : Baruch Zukerman // Efi Fogel -#ifndef CGAL_SWEEP_LINE_2_DEBUG_H -#define CGAL_SWEEP_LINE_2_DEBUG_H +#ifndef CGAL_SURFACE_SWEEP_2_DEBUG_H +#define CGAL_SURFACE_SWEEP_2_DEBUG_H -#include +#include +#include -#include +namespace CGAL { +namespace Surface_sweep_2 { //////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// // DEBUG UTILITIES // //////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// -template -void Basic_sweep_line_2:: -print_text(const char* text, bool do_eol) +template +void No_intersection_surface_sweep_2::print_text(const char* text, + bool do_eol) { if (m_need_indent) for (uint8_t i = m_indent_size; i != 0; --i) std::cout << " "; @@ -44,28 +45,24 @@ print_text(const char* text, bool do_eol) if (do_eol) print_eol(); } -template -void Basic_sweep_line_2::print_eol() +template +void No_intersection_surface_sweep_2::print_eol() { std::cout << std::endl; m_need_indent = true; } -template -void Basic_sweep_line_2::increase_indent() +template +void No_intersection_surface_sweep_2::increase_indent() { m_indent_size += 2; } -template -void Basic_sweep_line_2::decrease_indent() +template +void No_intersection_surface_sweep_2::decrease_indent() { m_indent_size -= 2; } -template -void Basic_sweep_line_2:: -print_start(const char* name, bool do_eol) +template +void No_intersection_surface_sweep_2::print_start(const char* name, + bool do_eol) { print_text("Start "); print_text(name); @@ -73,10 +70,9 @@ print_start(const char* name, bool do_eol) increase_indent(); } -template -void Basic_sweep_line_2:: -print_end(const char* name, bool do_eol) +template +void No_intersection_surface_sweep_2::print_end(const char* name, + bool do_eol) { decrease_indent(); print_text("End "); @@ -84,10 +80,8 @@ print_end(const char* name, bool do_eol) if (do_eol) print_eol(); } -template -void Basic_sweep_line_2:: -print_curve(const Base_subcurve* sc) +template +void No_intersection_surface_sweep_2::print_curve(const Subcurve* sc) { if (m_need_indent) for (uint8_t i = m_indent_size; i != 0; --i) std::cout << " "; @@ -95,9 +89,8 @@ print_curve(const Base_subcurve* sc) m_need_indent = false; } -template -void Basic_sweep_line_2::PrintEventQueue() +template +void No_intersection_surface_sweep_2::PrintEventQueue() { print_text("Event queue: ", true); Event_queue_iterator iter = m_queue->begin(); @@ -108,18 +101,16 @@ void Basic_sweep_line_2::PrintEventQueue() CGAL_SL_DEBUG(std::cout << "--------------------------------" << std::endl;) } -template -void Basic_sweep_line_2::PrintSubCurves() +template +void No_intersection_surface_sweep_2::PrintSubCurves() { print_text("Sub curves: ", true); for (size_t i = 0; i < m_num_of_subCurves; ++i) m_subCurves[i].Print(); print_eol(); } -template -void Basic_sweep_line_2::PrintStatusLine() +template +void No_intersection_surface_sweep_2::PrintStatusLine() { if (m_statusLine.size() == 0) { print_text("Status line: empty", true); @@ -146,10 +137,9 @@ void Basic_sweep_line_2::PrintStatusLine() print_eol(); } -template -void Basic_sweep_line_2:: -PrintOpenBoundaryType (Arr_parameter_space ps_x, Arr_parameter_space ps_y) +template +void No_intersection_surface_sweep_2:: +PrintOpenBoundaryType(Arr_parameter_space ps_x, Arr_parameter_space ps_y) { switch (ps_x) { case ARR_LEFT_BOUNDARY: std::cout << "left boundary"; return; @@ -166,10 +156,8 @@ PrintOpenBoundaryType (Arr_parameter_space ps_x, Arr_parameter_space ps_y) } } -template -void Basic_sweep_line_2:: -PrintEvent(const Event* e) +template +void No_intersection_surface_sweep_2::PrintEvent(const Event* e) { if (e->is_closed()) std::cout << e->point(); else { @@ -180,10 +168,8 @@ PrintEvent(const Event* e) } } -template -void Basic_sweep_line_2:: -print_event_info(const Event* e) +template +void No_intersection_surface_sweep_2::print_event_info(const Event* e) { print_text("Event Info: "); PrintEvent(e); @@ -208,4 +194,7 @@ print_event_info(const Event* e) print_text("End Event Info", true); } +} // namespace Surface_sweep_2 +} // namespace CGAL + #endif diff --git a/Sweep_line_2/include/CGAL/Sweep_line_2/Sweep_line_2_impl.h b/Surface_sweep_2/include/CGAL/Surface_sweep_2/Surface_sweep_2_impl.h similarity index 85% rename from Sweep_line_2/include/CGAL/Sweep_line_2/Sweep_line_2_impl.h rename to Surface_sweep_2/include/CGAL/Surface_sweep_2/Surface_sweep_2_impl.h index 5c74ff989b0..932d7ed9621 100644 --- a/Sweep_line_2/include/CGAL/Sweep_line_2/Sweep_line_2_impl.h +++ b/Surface_sweep_2/include/CGAL/Surface_sweep_2/Surface_sweep_2_impl.h @@ -20,24 +20,24 @@ // Efi Fogel // (based on old version by Tali Zvi) -#ifndef CGAL_SWEEP_LINE_2_IMPL_H -#define CGAL_SWEEP_LINE_2_IMPL_H - -#include +#ifndef CGAL_SURFACE_SWEEP_2_IMPL_H +#define CGAL_SURFACE_SWEEP_2_IMPL_H +#include /*! \file - * Member-function definitions of the Sweep_line_2 class-template. + * + * Member-function definitions of the Surface_sweep_2 class-template. */ namespace CGAL { +namespace Surface_sweep_2 { //----------------------------------------------------------------------------- // Initialize the data structures for the sweep-line algorithm. // -template -void Sweep_line_2::_init_structures() +template +void Surface_sweep_2::_init_structures() { // Initailize the structures maintained by the base sweep-line class. Base::_init_structures(); @@ -49,9 +49,8 @@ void Sweep_line_2::_init_structures() //----------------------------------------------------------------------------- // Complete the sweep (complete the data structures). // -template -void Sweep_line_2::_complete_sweep() +template +void Surface_sweep_2::_complete_sweep() { CGAL_SL_PRINT_START_EOL("completing the sweep"); @@ -78,9 +77,8 @@ void Sweep_line_2::_complete_sweep() //----------------------------------------------------------------------------- // Handle the subcurves to the left of the current event point. // -template -void Sweep_line_2::_handle_left_curves() +template +void Surface_sweep_2::_handle_left_curves() { CGAL_SL_PRINT_START("handling left curves at ("); CGAL_SL_DEBUG(this->PrintEvent(this->m_currentEvent)); @@ -121,7 +119,7 @@ void Sweep_line_2::_handle_left_curves() // Obtain the subcurve that contains the current event, and add it to // the left curves incident to the event. - Subcurve* sc = static_cast(*(this->m_status_line_insert_hint)); + Subcurve* sc = *(this->m_status_line_insert_hint); const X_monotone_curve_2& last_curve = sc->last_curve(); this->m_currentEvent->set_weak_intersection(); @@ -208,9 +206,8 @@ void Sweep_line_2::_handle_left_curves() //----------------------------------------------------------------------------- // Handle the subcurves to the right of the current event point. // -template -void Sweep_line_2::_handle_right_curves() +template +void Surface_sweep_2::_handle_right_curves() { CGAL_SL_PRINT_START("handling right curves at ("); CGAL_SL_DEBUG(this->PrintEvent(this->m_currentEvent)); @@ -246,15 +243,15 @@ void Sweep_line_2::_handle_right_curves() if (slIter != this->m_statusLine.begin()) { // get the previous curve in the y-str Status_line_iterator prev = slIter; --prev; - _intersect(static_cast(*prev), static_cast(*slIter)); + _intersect(*prev, *slIter); } Event_subcurve_iterator prevOne = currentOne; ++currentOne; while (currentOne != rightCurveEnd) { CGAL_SL_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); @@ -263,11 +260,8 @@ void Sweep_line_2::_handle_right_curves() // If the two curves used to be neighbours before, we do not need to // intersect them again. - if (!this->m_currentEvent->are_left_neighbours - (static_cast(*currentOne), static_cast(*prevOne))) - { + if (!this->m_currentEvent->are_left_neighbours(*currentOne, *prevOne)) _intersect(*prevOne, *currentOne); - } prevOne = currentOne; ++currentOne; @@ -277,9 +271,7 @@ void Sweep_line_2::_handle_right_curves() //the next Subcurve at the status line ++slIter; - if (slIter != this->m_statusLine.end()) - _intersect(static_cast(*prevOne), - static_cast(*slIter)); + if (slIter != this->m_statusLine.end()) _intersect(*prevOne, *slIter); CGAL_SL_PRINT_END_EOL("handling right curves"); } @@ -287,9 +279,8 @@ void Sweep_line_2::_handle_right_curves() //----------------------------------------------------------------------------- // Add a subcurve to the right of an event point. // -template -bool Sweep_line_2:: +template +bool Surface_sweep_2:: _add_curve_to_right(Event* event, Subcurve* curve, bool overlap_exist) { CGAL_SL_PRINT_START("adding a Curve to the right of ("); @@ -309,7 +300,7 @@ _add_curve_to_right(Event* event, Subcurve* curve, bool overlap_exist) return false; } - if ((curve)->is_inner_node(*iter)) { + if (curve->is_inner_node(*iter)) { *iter = curve; // replace the current curve with the new one. CGAL_SL_PRINT_END_EOL ("adding a Curve to the right (curve partially overlaps)"); @@ -323,26 +314,26 @@ _add_curve_to_right(Event* event, Subcurve* curve, bool overlap_exist) * matching left curve, and only if it has, make the switch. If this is * the case, then other modifications are necessary. I hope it's not. */ - if ((curve)->has_same_leaves(*iter)) { + if (curve->has_same_leaves(*iter)) { *iter = curve; // replace the current curve with the new one. CGAL_SL_PRINT_END_EOL ("adding a Curve to the right (curve completely overlaps)"); return false; } - if ((curve)->has_common_leaf(*iter)) { + if (curve->has_common_leaf(*iter)) { /*! Collect all the distinct nodes of curves including the common nodes. * \todo EF, common nodes should be excluded. It is not incorrect to * include a common node, because in the recursive call it becomes * 'curve', which is an inner node of iter, and it is discarded; see 2 * conditions above. */ - std::list list_of_sc; + std::list list_of_sc; curve->distinct_nodes(*iter, std::back_inserter(list_of_sc)); - typename std::list::iterator sc_iter; + typename std::list::iterator sc_iter; for (sc_iter = list_of_sc.begin(); sc_iter != list_of_sc.end(); ++sc_iter) - _add_curve_to_right(event, static_cast(*sc_iter)); + _add_curve_to_right(event, *sc_iter); CGAL_SL_PRINT_END_EOL("adding a Curve to the right (common leaf)"); return true; @@ -367,10 +358,9 @@ _add_curve_to_right(Event* event, Subcurve* curve, bool overlap_exist) //----------------------------------------------------------------------------- // Remove a curve from the status line. // -template -void Sweep_line_2:: -_remove_curve_from_status_line(Subcurve* leftCurve, bool remove_for_good) +template +void Surface_sweep_2::_remove_curve_from_status_line(Subcurve* leftCurve, + bool remove_for_good) { CGAL_SL_PRINT_START("removing a curve from the status line, "); CGAL_SL_PRINT_CURVE(leftCurve); @@ -403,8 +393,7 @@ _remove_curve_from_status_line(Subcurve* leftCurve, bool remove_for_good) Status_line_iterator next = sliter; ++next; // intersect *next with *prev - _intersect(static_cast(*prev), - static_cast(*next)); + _intersect(*prev, *next); } CGAL_SL_PRINT_ERASE(*sliter); this->m_statusLine.erase(sliter); @@ -414,10 +403,8 @@ _remove_curve_from_status_line(Subcurve* leftCurve, bool remove_for_good) //----------------------------------------------------------------------------- // Compute intersections between the two given curves. // -template -void Sweep_line_2::_intersect(Subcurve* c1, - Subcurve* c2) +template +void Surface_sweep_2::_intersect(Subcurve* c1, Subcurve* c2) { CGAL_SL_PRINT_START("computing intersection of "); CGAL_SL_PRINT_CURVE(c1); @@ -425,14 +412,14 @@ void Sweep_line_2::_intersect(Subcurve* c1, CGAL_SL_PRINT_CURVE(c2); CGAL_SL_PRINT_EOL(); - typedef typename Tr::Multiplicity Multiplicity; + typedef typename Geometry_traits_2::Multiplicity Multiplicity; CGAL_assertion(c1 != c2); // look up for (c1,c2) in the table and insert if doesnt exist Curve_pair cv_pair(c1,c2); - if (! (m_curves_pair_set.insert(cv_pair)).second) - return; //the curves have already been checked for intersection + // Check whether the curves have already been checked for intersection + if (! (m_curves_pair_set.insert(cv_pair)).second) return; float load_factor = static_cast(m_curves_pair_set.size()) / m_curves_pair_set.bucket_count(); @@ -485,9 +472,7 @@ void Sweep_line_2::_intersect(Subcurve* c1, // object is a point, we can ignore last intersection (note that in case of // an overlap that ends at the common endpoint, we definately want to keep // the intersection object). - if (reinterpret_cast(c1->right_event()) == - reinterpret_cast(c2->right_event())) - { + if (c1->right_event() == c2->right_event()) { vector_inserter vi_last = vi_end; --vi_last; @@ -501,18 +486,18 @@ void Sweep_line_2::_intersect(Subcurve* c1, // In case both right curve-ends have boundary conditions and are not // open, check whether the right endpoints are the same. If they are, // skip the last intersection point. - const Arr_parameter_space ps_x1 = - this->m_traits->parameter_space_in_x_2_object()(c1->last_curve(), - ARR_MAX_END); - const Arr_parameter_space ps_y1 = - this->m_traits->parameter_space_in_y_2_object()(c1->last_curve(), - ARR_MAX_END); - const Arr_parameter_space ps_x2 = - this->m_traits->parameter_space_in_x_2_object()(c2->last_curve(), - ARR_MAX_END); - const Arr_parameter_space ps_y2 = - this->m_traits->parameter_space_in_y_2_object()(c2->last_curve(), - ARR_MAX_END); + const Arr_parameter_space ps_x1 = + this->m_traits->parameter_space_in_x_2_object()(c1->last_curve(), + ARR_MAX_END); + const Arr_parameter_space ps_y1 = + this->m_traits->parameter_space_in_y_2_object()(c1->last_curve(), + ARR_MAX_END); + const Arr_parameter_space ps_x2 = + this->m_traits->parameter_space_in_x_2_object()(c2->last_curve(), + ARR_MAX_END); + const Arr_parameter_space ps_y2 = + this->m_traits->parameter_space_in_y_2_object()(c2->last_curve(), + ARR_MAX_END); if ((ps_x1 == ps_x2) && (ps_y1 == ps_y2) && ((ps_x1 != ARR_INTERIOR) || (ps_y2 != ARR_INTERIOR)) && @@ -536,7 +521,7 @@ void Sweep_line_2::_intersect(Subcurve* c1, } } - const std::pair* xp_point; + const std::pair* xp_point; // Efi: why not skipping in a loop?check only one (that is, why not in a loop)? if (vi != vi_end) { @@ -587,13 +572,12 @@ void Sweep_line_2::_intersect(Subcurve* c1, //----------------------------------------------------------------------------- // Create an intersection-point event between two curves. // -template -void Sweep_line_2:: -_create_intersection_point(const Point_2& xp, - unsigned int multiplicity, - Subcurve*& c1, Subcurve*& c2, - bool is_overlap) +template +void Surface_sweep_2::_create_intersection_point(const Point_2& xp, + unsigned int multiplicity, + Subcurve*& c1, + Subcurve*& c2, + bool is_overlap) { CGAL_SL_PRINT_START_EOL("createing an intersection point netween"); CGAL_SL_PRINT_CURVE(c1); @@ -603,7 +587,7 @@ _create_intersection_point(const Point_2& xp, // insert the event and check if an event at this point already exists. const std::pair& pair_res = - this->_push_event(xp, Base_event::DEFAULT, ARR_INTERIOR, ARR_INTERIOR); + this->_push_event(xp, Event::DEFAULT, ARR_INTERIOR, ARR_INTERIOR); Event* e = pair_res.first; if (pair_res.second) { @@ -691,9 +675,8 @@ _create_intersection_point(const Point_2& xp, //----------------------------------------------------------------------------- // Fix overlap Subcurves before handling the current event. // -template -void Sweep_line_2::_fix_overlap_subcurves() +template +void Surface_sweep_2::_fix_overlap_subcurves() { CGAL_SL_PRINT_START_EOL("fixing overlap subcurves"); @@ -709,8 +692,8 @@ void Sweep_line_2::_fix_overlap_subcurves() // right end point. if ((Event*)leftCurve->right_event() == this->m_currentEvent) { if (leftCurve->originating_subcurve1() != NULL) { - Subcurve* orig_sc_1 = (Subcurve*)leftCurve->originating_subcurve1(); - Subcurve* orig_sc_2 = (Subcurve*)leftCurve->originating_subcurve2(); + Subcurve* orig_sc_1 = leftCurve->originating_subcurve1(); + Subcurve* orig_sc_2 = leftCurve->originating_subcurve2(); _fix_finished_overlap_subcurve(orig_sc_1); _fix_finished_overlap_subcurve(orig_sc_2); @@ -731,11 +714,10 @@ void Sweep_line_2::_fix_overlap_subcurves() * \param overlap_exist a flag indicates if the overlap X_monotone_curve_2 was * computed already (is true than its stored at sub_cv1 data member). */ -template -void Sweep_line_2:: -_handle_overlap(Event* event, Subcurve* curve, Event_subcurve_iterator iter, - bool overlap_exist) +template +void Surface_sweep_2::_handle_overlap(Event* event, Subcurve* curve, + Event_subcurve_iterator iter, + bool overlap_exist) { // An overlap occurs: CGAL_SL_PRINT_START_EOL("handling overlap at right insertion"); @@ -744,7 +726,7 @@ _handle_overlap(Event* event, Subcurve* curve, Event_subcurve_iterator iter, if (overlap_exist) overlap_cv = sub_cv1; else { // compute the overlap. - std::vector obj_vec; + std::vector obj_vec; vector_inserter vit(obj_vec); this->m_traits->intersect_2_object()(curve->last_curve(), (*iter)->last_curve(), @@ -760,9 +742,9 @@ _handle_overlap(Event* event, Subcurve* curve, Event_subcurve_iterator iter, // Get the right end of overlap_cv (if it is closed from the right). Event* right_end; - Arr_parameter_space ps_x_r = + Arr_parameter_space ps_x_r = this->m_traits->parameter_space_in_x_2_object()(overlap_cv, ARR_MAX_END); - Arr_parameter_space ps_y_r = + Arr_parameter_space ps_y_r = this->m_traits->parameter_space_in_y_2_object()(overlap_cv, ARR_MAX_END); CGAL_assertion(ps_x_r != ARR_LEFT_BOUNDARY); @@ -782,7 +764,7 @@ _handle_overlap(Event* event, Subcurve* curve, Event_subcurve_iterator iter, this->m_traits->construct_max_vertex_2_object()(overlap_cv); const std::pair& pair_res = - this->_push_event(end_overlap, Base_event::OVERLAP, ps_x_r, ps_y_r); + this->_push_event(end_overlap, Event::OVERLAP, ps_x_r, ps_y_r); right_end = pair_res.first; } @@ -883,10 +865,8 @@ _handle_overlap(Event* event, Subcurve* curve, Event_subcurve_iterator iter, // sc - some originating subcurve of a aubcurve that stores an overlap // notice thah this function is recursive since an originating subcurve of // an overlap can be itself a subcurve that stores overlap and so on. -template -void Sweep_line_2:: -_fix_finished_overlap_subcurve(Subcurve* sc) +template +void Surface_sweep_2::_fix_finished_overlap_subcurve(Subcurve* sc) { CGAL_SL_PRINT_START("fixing finished overlap subcurve "); CGAL_SL_PRINT_CURVE(sc); @@ -902,7 +882,7 @@ _fix_finished_overlap_subcurve(Subcurve* sc) sc->set_last_curve(sub_cv2); this->m_currentEvent->set_weak_intersection(); - this->m_visitor->update_event(this->m_currentEvent,(Subcurve*)sc); + this->m_visitor->update_event(this->m_currentEvent, sc); CGAL_SL_PRINT_END_EOL("Fixing finished overlap subcurve"); return; @@ -916,8 +896,8 @@ _fix_finished_overlap_subcurve(Subcurve* sc) // sc is a subcurve that stores overlap, we have to continue with the // recursion and deal with his two originating subcurves recursively. - Subcurve* orig_sc_1 = (Subcurve*)sc->originating_subcurve1(); - Subcurve* orig_sc_2 = (Subcurve*)sc->originating_subcurve2(); + Subcurve* orig_sc_1 = sc->originating_subcurve1(); + Subcurve* orig_sc_2 = sc->originating_subcurve2(); _fix_finished_overlap_subcurve(orig_sc_1); _fix_finished_overlap_subcurve(orig_sc_2); @@ -925,6 +905,27 @@ _fix_finished_overlap_subcurve(Subcurve* sc) CGAL_SL_PRINT_END_EOL("fixing finished overlap subcurve"); } -} //namespace CGAL +//----------------------------------------------------------------------------- +// add a curve as a right curve or left curve when the event is created +// or updated. +// +template +void Surface_sweep_2::_add_curve(Event* e, Subcurve* sc, Attribute type) +{ + if (sc == NULL) return; + + if (type == Event::LEFT_END) { + sc->set_left_event(e); + _add_curve_to_right(e, sc); + return; + } + + CGAL_assertion(type == Event::RIGHT_END); + sc->set_right_event(e); + e->add_curve_to_left(sc); +} + +} // namespace Surface_sweep_2 +} // namespace CGAL #endif diff --git a/Sweep_line_2/include/CGAL/Sweep_line_2/Sweep_line_2_utils.h b/Surface_sweep_2/include/CGAL/Surface_sweep_2/Surface_sweep_2_utils.h similarity index 67% rename from Sweep_line_2/include/CGAL/Sweep_line_2/Sweep_line_2_utils.h rename to Surface_sweep_2/include/CGAL/Surface_sweep_2/Surface_sweep_2_utils.h index 60491803adc..a8565c7ba73 100644 --- a/Sweep_line_2/include/CGAL/Sweep_line_2/Sweep_line_2_utils.h +++ b/Surface_sweep_2/include/CGAL/Surface_sweep_2/Surface_sweep_2_utils.h @@ -15,24 +15,23 @@ // $URL$ // $Id$ // SPDX-License-Identifier: GPL-3.0+ -// +// // // Author(s) : Baruch Zukerman // Ron Wein // Efi Fogel -#ifndef CGAL_SWEEP_LINE_2_UTILS -#define CGAL_SWEEP_LINE_2_UTILS - -#include +#ifndef CGAL_SURFACE_SWEEP_2_UTILS_H +#define CGAL_SURFACE_SWEEP_2_UTILS_H +#include /*! \file + * * Auxiliary functions for the usage of the various sweep-line visitors. */ #include - #include #include #include @@ -40,9 +39,9 @@ #include namespace CGAL { +namespace Surface_sweep_2 { -/*! - * Subdivide a range of input curves into x-monotone objects. +/*! Subdivide a range of input curves into x-monotone objects. * \param begin The first input curve (of type Curve_2). * \param end A part-the-end iterator for the input curves. * \param x_curves Output: The x-monotone subcurves @@ -50,61 +49,53 @@ namespace CGAL { * \param iso_points Output: The isolated points (of type Point_2). * \param tr A geometry-traits class. */ -template -void make_x_monotone (CurveInputIter begin, CurveInputIter end, - XCurveOutIter x_curves, - PointOutIter iso_points, - const Traits * tr) +template +void make_x_monotone(CurveInputIter begin, CurveInputIter end, + XCurveOutIter x_curves, + PointOutIter iso_points, + const Traits* tr) { // Split the input curves into x-monotone objects. - std::size_t num_of_curves = std::distance(begin, end); - std::vector object_vec; - CurveInputIter iter; + std::size_t num_of_curves = std::distance(begin, end); + std::vector object_vec; + CurveInputIter iter; - object_vec.reserve (num_of_curves); - for (iter = begin; iter != end; ++iter) - { - tr->make_x_monotone_2_object()(*iter, - std::back_inserter(object_vec)); + object_vec.reserve(num_of_curves); + for (iter = begin; iter != end; ++iter) { + tr->make_x_monotone_2_object()(*iter, std::back_inserter(object_vec)); } // Transform each object to either a point or an x-monotone curve. typedef typename Traits::X_monotone_curve_2 X_monotone_curve_2; typedef typename Traits::Point_2 Point_2; - const X_monotone_curve_2 *xcv; - const Point_2 *pt; - unsigned int i; + const X_monotone_curve_2* xcv; + const Point_2* pt; + unsigned int i; - for (i = 0 ; i < object_vec.size() ; ++i) - { + for (i = 0 ; i < object_vec.size() ; ++i) { xcv = object_cast (&(object_vec[i])); - if (xcv != NULL) - { + if (xcv != NULL) { // The object is an x-monotone curve. *x_curves = *xcv; ++x_curves; } - else - { + else { // The object is an isolated point. pt = object_cast (&(object_vec[i])); CGAL_assertion (pt != NULL); - + *iso_points = *pt; ++iso_points; } } - - return; } -/*! - * Given an arrangement and two ranges of x-monotone curves and isolated +/*! Given an arrangement and two ranges of x-monotone curves and isolated * points, representing objects that should be inserted into the arrangement, * create two output sets of extended x-monotone curves and isolated points, * including the arrangement edges and isolated vertices. @@ -117,24 +108,24 @@ void make_x_monotone (CurveInputIter begin, CurveInputIter end, * \param pts_end A past-the-end iterator for the isolated input points. * \param x_curves Output: The extended x-monotone subcurves * (of type ExTraits::X_monotone_curve_2). - * \param iso_points Output: The extended isolated points + * \param iso_points Output: The extended isolated points * (of type ExTraits::Point_2). * \param ex_tr An extended geometry-traits class. * This parameter is not actually in use, but is needed in order * to instantiate the template parameter ExTraits. */ -template -void prepare_for_sweep (Arrangement& arr, - XCurveInputIter xcvs_begin, XCurveInputIter xcvs_end, - PointInputIter pts_begin, PointInputIter pts_end, - XCurveOutIter x_curves, - PointOutIter iso_points, - const ExTraits * /* ex_tr */) +template +void prepare_for_sweep(Arrangement& arr, + XCurveInputIter xcvs_begin, XCurveInputIter xcvs_end, + PointInputIter pts_begin, PointInputIter pts_end, + XCurveOutIter x_curves, + PointOutIter iso_points, + const ExTraits * /* ex_tr */) { typedef typename Arrangement::Vertex_iterator Vertex_iterator; typedef typename Arrangement::Edge_iterator Edge_iterator; @@ -143,35 +134,30 @@ void prepare_for_sweep (Arrangement& arr, typedef typename ExTraits::X_monotone_curve_2 Ex_x_monotone_curve_2; typedef typename ExTraits::Point_2 Ex_point_2; - - // Go over the input objects and copy them to the output iterators. - XCurveInputIter xcv_it; - PointInputIter pt_it; - for (xcv_it = xcvs_begin; xcv_it != xcvs_end; ++xcv_it) - { + // Go over the input objects and copy them to the output iterators. + XCurveInputIter xcv_it; + PointInputIter pt_it; + + for (xcv_it = xcvs_begin; xcv_it != xcvs_end; ++xcv_it) { *x_curves = Ex_x_monotone_curve_2 (*xcv_it); ++x_curves; } - for (pt_it = pts_begin; pt_it != pts_end; ++pt_it) - { + for (pt_it = pts_begin; pt_it != pts_end; ++pt_it) { *iso_points = Ex_point_2 (*pt_it); ++iso_points; } - + // Go over the arrangement edges and insert their associated x-monotone // curves into the output iterator. To each curve we attach a handle to the // halfedge that goes from right to left. Edge_iterator eit; Halfedge_handle he; - - for (eit = arr.edges_begin(); eit != arr.edges_end(); ++eit) - { - if (eit->direction() == ARR_LEFT_TO_RIGHT) - he = eit->twin(); - else - he = eit; + + for (eit = arr.edges_begin(); eit != arr.edges_end(); ++eit) { + if (eit->direction() == ARR_LEFT_TO_RIGHT) he = eit->twin(); + else he = eit; *x_curves = Ex_x_monotone_curve_2 (he->curve(), he); ++x_curves; @@ -183,20 +169,16 @@ void prepare_for_sweep (Arrangement& arr, Vertex_iterator vit; Vertex_handle v; - for (vit = arr.vertices_begin(); vit != arr.vertices_end(); ++vit) - { + for (vit = arr.vertices_begin(); vit != arr.vertices_end(); ++vit) { v = vit; - if (v->is_isolated()) - { + if (v->is_isolated()) { *iso_points = Ex_point_2 (v->point(), v); ++iso_points; } } - - return; } - -} //namespace CGAL +} // namespace CGAL +} // namespace Surface_sweep_2 #endif diff --git a/Sweep_line_2/include/CGAL/Sweep_line_2_algorithms.h b/Surface_sweep_2/include/CGAL/Surface_sweep_2_algorithms.h similarity index 55% rename from Sweep_line_2/include/CGAL/Sweep_line_2_algorithms.h rename to Surface_sweep_2/include/CGAL/Surface_sweep_2_algorithms.h index 1d8e2e9e293..54937fd21cf 100644 --- a/Sweep_line_2/include/CGAL/Sweep_line_2_algorithms.h +++ b/Surface_sweep_2/include/CGAL/Surface_sweep_2_algorithms.h @@ -21,18 +21,20 @@ // Efi Fogel // (based on old version by Tali Zvi) -#ifndef CGAL_SWEEP_LINE_2_ALGORITHMS_H -#define CGAL_SWEEP_LINE_2_ALGORITHMS_H +#ifndef CGAL_SURFACE_SWEEP_2_ALGORITHMS_H +#define CGAL_SURFACE_SWEEP_2_ALGORITHMS_H -#include +#include - -/*! - * \file Definition of the sweep-line related functions. +/*! File + * + * \file Definition of the surface-sweep related functions. */ -#include -#include +#include +#include +#include +#include #include #include @@ -43,6 +45,8 @@ namespace CGAL { +namespace Ss2 = Surface_sweep_2; + template struct Default_arr_traits {}; @@ -83,7 +87,8 @@ class Rational_arc_d_1; } template -struct Default_arr_traits > +struct Default_arr_traits > { typedef CGAL::Arr_rational_function_traits_2 Traits; }; @@ -100,9 +105,8 @@ struct Default_arr_traits > typedef CGAL::Arr_linear_traits_2 Traits; }; -/*! - * Compute all intersection points induced by a range of input curves. - * The intersections are calculated using the sweep-line algorithm. +/*! Compute all intersection points induced by a range of input curves. + * The intersections are calculated using the surface-sweep algorithm. * \param begin An input iterator for the first curve in the range. * \param end A input past-the-end iterator for the range. * \param points Output: An output iterator for the intersection points @@ -112,45 +116,43 @@ struct Default_arr_traits > * \pre The value-type of CurveInputIterator is Traits::Curve_2, and the * value-type of OutputIterator is Traits::Point_2. */ -template -OutputIterator compute_intersection_points (CurveInputIterator curves_begin, - CurveInputIterator curves_end, - OutputIterator points, - bool report_endpoints, - Traits &tr) +template +OutputIterator compute_intersection_points(CurveInputIterator curves_begin, + CurveInputIterator curves_end, + OutputIterator points, + bool report_endpoints, + Traits &tr) { - // Define the sweep-line types: - typedef Sweep_line_points_visitor Visitor; - typedef Sweep_line_2< Traits, - Sweep_line_points_visitor > - Sweep_line; + // Define the surface-sweep types: + typedef Ss2::Intersection_points_visitor + Visitor; + typedef Ss2::Surface_sweep_2 Surface_sweep; // Perform the sweep and obtain the intersection points. - Visitor visitor (points, report_endpoints); - Sweep_line sweep_line (&tr, &visitor); + Visitor visitor(points, report_endpoints); + Surface_sweep surface_sweep(&tr, &visitor); visitor.sweep(curves_begin, curves_end); - return (visitor.output_iterator()); + return visitor.output_iterator(); } -template -OutputIterator compute_intersection_points (CurveInputIterator curves_begin, - CurveInputIterator curves_end, - OutputIterator points, - bool report_endpoints = false) +template +OutputIterator compute_intersection_points(CurveInputIterator curves_begin, + CurveInputIterator curves_end, + OutputIterator points, + bool report_endpoints = false) { typedef typename std::iterator_traits::value_type Curve; typename Default_arr_traits::Traits traits; - return (compute_intersection_points(curves_begin, curves_end, points, - report_endpoints, traits)); + return compute_intersection_points(curves_begin, curves_end, points, + report_endpoints, traits); } -/*! - * Compute all x-monotone subcurves that are disjoint in their interiors +/*! Compute all x-monotone subcurves that are disjoint in their interiors * induced by a range of input curves. - * The subcurves are calculated using the sweep-line algorithm. + * The subcurves are calculated using the surface-sweep algorithm. * \param begin An input iterator for the first curve in the range. * \param end A input past-the-end iterator for the range. * \param points Output: An output iterator for the subcurve. @@ -159,74 +161,67 @@ OutputIterator compute_intersection_points (CurveInputIterator curves_begin, * \pre The value-type of CurveInputIterator is Traits::Curve_2, and the * value-type of OutputIterator is Traits::X_monotone_curve_2. */ -template -OutputIterator compute_subcurves (CurveInputIterator curves_begin, - CurveInputIterator curves_end, - OutputIterator subcurves, - bool mult_overlaps, Traits &tr) +template +OutputIterator compute_subcurves(CurveInputIterator curves_begin, + CurveInputIterator curves_end, + OutputIterator subcurves, + bool mult_overlaps, Traits& tr) { - // Define the sweep-line types: - typedef Sweep_line_subcurves_visitor Visitor; - typedef Sweep_line_2 > - Sweep_line; + // Define the surface-sweep types: + typedef Ss2::Subcurves_visitor Visitor; + typedef Ss2::Surface_sweep_2 Surface_sweep; // Perform the sweep and obtain the subcurves. - Visitor visitor (subcurves, mult_overlaps); - Sweep_line sweep_line (&tr, &visitor); + Visitor visitor(subcurves, mult_overlaps); + Surface_sweep surface_sweep(&tr, &visitor); visitor.sweep(curves_begin, curves_end); - return (visitor.output_iterator()); + return visitor.output_iterator(); } - -template -OutputIterator compute_subcurves (CurveInputIterator curves_begin, - CurveInputIterator curves_end, - OutputIterator subcurves, - bool mult_overlaps = false) +template +OutputIterator compute_subcurves(CurveInputIterator curves_begin, + CurveInputIterator curves_end, + OutputIterator subcurves, + bool mult_overlaps = false) { typedef typename std::iterator_traits::value_type Curve; - typename Default_arr_traits::Traits m_traits; + typename Default_arr_traits::Traits m_traits; return compute_subcurves(curves_begin, curves_end, subcurves, mult_overlaps, m_traits); } -/*! - * Determine if there occurs an intersection between any pair of curves in +/*! Determine if there occurs an intersection between any pair of curves in * a given range. * \param begin An input iterator for the first curve in the range. * \param end A input past-the-end iterator for the range. * \return (true) if any pair of curves intersect; (false) otherwise. */ -template -bool do_curves_intersect (CurveInputIterator curves_begin, - CurveInputIterator curves_end, Traits &tr) +template +bool do_curves_intersect(CurveInputIterator curves_begin, + CurveInputIterator curves_end, Traits& tr) { - // Define the sweep-line types: - typedef Sweep_line_do_curves_x_visitor Visitor; - typedef Sweep_line_2 > - Sweep_line; + // Define the surface-sweep types: + typedef Ss2::Do_interior_intersect_visitor Visitor; + typedef Ss2::Surface_sweep_2 Surface_sweep; // Perform the sweep and obtain the subcurves. - Visitor visitor; - Sweep_line sweep_line (&tr, &visitor); + Visitor visitor; + Surface_sweep surface_sweep(&tr, &visitor); visitor.sweep(curves_begin, curves_end); - - return (visitor.found_intersection()); + return visitor.found_intersection(); } - -template -bool do_curves_intersect (CurveInputIterator curves_begin, - CurveInputIterator curves_end) +template +bool do_curves_intersect(CurveInputIterator curves_begin, + CurveInputIterator curves_end) { typedef typename std::iterator_traits::value_type Curve; - typename Default_arr_traits::Traits m_traits; - return do_curves_intersect (curves_begin, curves_end, m_traits); + typename Default_arr_traits::Traits m_traits; + return do_curves_intersect(curves_begin, curves_end, m_traits); } -} //namespace CGAL +} // namespace CGAL #endif diff --git a/Surface_sweep_2/include/CGAL/Sweep_line_2_algorithms.h b/Surface_sweep_2/include/CGAL/Sweep_line_2_algorithms.h new file mode 100644 index 00000000000..a2d162c2afa --- /dev/null +++ b/Surface_sweep_2/include/CGAL/Sweep_line_2_algorithms.h @@ -0,0 +1,29 @@ +// Copyright (c) 2005,2006,2007,2009,2010,2011 Tel-Aviv University (Israel). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// You can redistribute it and/or modify it under the terms of the GNU +// General Public License as published by the Free Software Foundation, +// either version 3 of the License, or (at your option) any later version. +// +// Licensees holding a valid commercial license may use this file in +// accordance with the commercial license agreement provided with the software. +// +// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Author(s): Efi Fogel + +#ifndef CGAL_SWEEP_LINE_2_ALGORITHMS_H +#define CGAL_SWEEP_LINE_2_ALGORITHMS_H + +#include + +/*! \file + * + * This file exists for backward compatibility. + */ + +#include + +#endif diff --git a/Sweep_line_2/package_info/Sweep_line_2/copyright b/Surface_sweep_2/package_info/Surface_sweep_2/copyright similarity index 100% rename from Sweep_line_2/package_info/Sweep_line_2/copyright rename to Surface_sweep_2/package_info/Surface_sweep_2/copyright diff --git a/Sweep_line_2/package_info/Sweep_line_2/description.txt b/Surface_sweep_2/package_info/Surface_sweep_2/description.txt similarity index 100% rename from Sweep_line_2/package_info/Sweep_line_2/description.txt rename to Surface_sweep_2/package_info/Surface_sweep_2/description.txt diff --git a/Sweep_line_2/package_info/Sweep_line_2/license.txt b/Surface_sweep_2/package_info/Surface_sweep_2/license.txt similarity index 100% rename from Sweep_line_2/package_info/Sweep_line_2/license.txt rename to Surface_sweep_2/package_info/Surface_sweep_2/license.txt diff --git a/Surface_sweep_2/package_info/Surface_sweep_2/long_description.txt b/Surface_sweep_2/package_info/Surface_sweep_2/long_description.txt new file mode 100644 index 00000000000..4cd1b445bcd --- /dev/null +++ b/Surface_sweep_2/package_info/Surface_sweep_2/long_description.txt @@ -0,0 +1,8 @@ +This package consists of an a robust implementation of an efficient variant +of the well-known plane-sweep algorithm. The implementation follows the Exact +Geometric Computation paradigm and thus guarantees exact results. It handles +all cases including degeneracies, such as isolated points, vertical segments, +and overlapping curves. It is not limited to segments---it can handle sets of +general x-monotone curves provided as input. The implementation provides a +framework that can be used to implement other concrete algorithms, such as the +overlay of two arrangements on surfaces. diff --git a/Sweep_line_2/package_info/Sweep_line_2/maintainer b/Surface_sweep_2/package_info/Surface_sweep_2/maintainer similarity index 100% rename from Sweep_line_2/package_info/Sweep_line_2/maintainer rename to Surface_sweep_2/package_info/Surface_sweep_2/maintainer diff --git a/Sweep_line_2/test/Sweep_line_2/CMakeLists.txt b/Surface_sweep_2/test/Surface_sweep_2/CMakeLists.txt similarity index 98% rename from Sweep_line_2/test/Sweep_line_2/CMakeLists.txt rename to Surface_sweep_2/test/Surface_sweep_2/CMakeLists.txt index 4e7754d3f9c..66da70cbcdf 100644 --- a/Sweep_line_2/test/Sweep_line_2/CMakeLists.txt +++ b/Surface_sweep_2/test/Surface_sweep_2/CMakeLists.txt @@ -2,7 +2,7 @@ # This is the CMake script for compiling a CGAL application. -project( Sweep_line_2_Tests ) +project( Surface_sweep_2_Tests ) cmake_minimum_required(VERSION 2.8.10) @@ -57,8 +57,7 @@ if ( CGAL_FOUND ) compile_and_run_sweep(test_sweep_conic test_sweep_conic.cpp ${NAIVE} ${CGAL_CONIC_TRAITS} "DATA/conics") else() - - message(STATUS "This program requires the CGAL library, and will not be compiled.") - -endif() + message(STATUS "This program requires the CGAL library, and will not be compiled.") + +endif() diff --git a/Sweep_line_2/test/Sweep_line_2/CompareCurveList.h b/Surface_sweep_2/test/Surface_sweep_2/CompareCurveList.h similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/CompareCurveList.h rename to Surface_sweep_2/test/Surface_sweep_2/CompareCurveList.h diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/conics/con01.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/conics/con01.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/conics/con01.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/conics/con01.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/conics/con02.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/conics/con02.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/conics/con02.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/conics/con02.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/conics/con03.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/conics/con03.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/conics/con03.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/conics/con03.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/conics/con04.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/conics/con04.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/conics/con04.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/conics/con04.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/conics/con05.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/conics/con05.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/conics/con05.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/conics/con05.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/conics/con06.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/conics/con06.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/conics/con06.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/conics/con06.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/conics/con07.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/conics/con07.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/conics/con07.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/conics/con07.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/conics/con08.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/conics/con08.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/conics/con08.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/conics/con08.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/conics/con09.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/conics/con09.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/conics/con09.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/conics/con09.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/conics/con10.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/conics/con10.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/conics/con10.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/conics/con10.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/polylines/big_overlap b/Surface_sweep_2/test/Surface_sweep_2/DATA/polylines/big_overlap similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/polylines/big_overlap rename to Surface_sweep_2/test/Surface_sweep_2/DATA/polylines/big_overlap diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/polylines/big_overlap2 b/Surface_sweep_2/test/Surface_sweep_2/DATA/polylines/big_overlap2 similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/polylines/big_overlap2 rename to Surface_sweep_2/test/Surface_sweep_2/DATA/polylines/big_overlap2 diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/polylines/closed_polyline b/Surface_sweep_2/test/Surface_sweep_2/DATA/polylines/closed_polyline similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/polylines/closed_polyline rename to Surface_sweep_2/test/Surface_sweep_2/DATA/polylines/closed_polyline diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/polylines/collinears b/Surface_sweep_2/test/Surface_sweep_2/DATA/polylines/collinears similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/polylines/collinears rename to Surface_sweep_2/test/Surface_sweep_2/DATA/polylines/collinears diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/polylines/edge_vertex_intersection b/Surface_sweep_2/test/Surface_sweep_2/DATA/polylines/edge_vertex_intersection similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/polylines/edge_vertex_intersection rename to Surface_sweep_2/test/Surface_sweep_2/DATA/polylines/edge_vertex_intersection diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/polylines/endpoint_intersection b/Surface_sweep_2/test/Surface_sweep_2/DATA/polylines/endpoint_intersection similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/polylines/endpoint_intersection rename to Surface_sweep_2/test/Surface_sweep_2/DATA/polylines/endpoint_intersection diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/polylines/partial_overlap b/Surface_sweep_2/test/Surface_sweep_2/DATA/polylines/partial_overlap similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/polylines/partial_overlap rename to Surface_sweep_2/test/Surface_sweep_2/DATA/polylines/partial_overlap diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/polylines/partial_overlap2 b/Surface_sweep_2/test/Surface_sweep_2/DATA/polylines/partial_overlap2 similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/polylines/partial_overlap2 rename to Surface_sweep_2/test/Surface_sweep_2/DATA/polylines/partial_overlap2 diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/polylines/segment_overlap b/Surface_sweep_2/test/Surface_sweep_2/DATA/polylines/segment_overlap similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/polylines/segment_overlap rename to Surface_sweep_2/test/Surface_sweep_2/DATA/polylines/segment_overlap diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/polylines/self_cut b/Surface_sweep_2/test/Surface_sweep_2/DATA/polylines/self_cut similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/polylines/self_cut rename to Surface_sweep_2/test/Surface_sweep_2/DATA/polylines/self_cut diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/polylines/simple_intersection b/Surface_sweep_2/test/Surface_sweep_2/DATA/polylines/simple_intersection similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/polylines/simple_intersection rename to Surface_sweep_2/test/Surface_sweep_2/DATA/polylines/simple_intersection diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/polylines/total_overlap b/Surface_sweep_2/test/Surface_sweep_2/DATA/polylines/total_overlap similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/polylines/total_overlap rename to Surface_sweep_2/test/Surface_sweep_2/DATA/polylines/total_overlap diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/polylines/triangle b/Surface_sweep_2/test/Surface_sweep_2/DATA/polylines/triangle similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/polylines/triangle rename to Surface_sweep_2/test/Surface_sweep_2/DATA/polylines/triangle diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/polylines/two_segments b/Surface_sweep_2/test/Surface_sweep_2/DATA/polylines/two_segments similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/polylines/two_segments rename to Surface_sweep_2/test/Surface_sweep_2/DATA/polylines/two_segments diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/polylines/vertex_intersection b/Surface_sweep_2/test/Surface_sweep_2/DATA/polylines/vertex_intersection similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/polylines/vertex_intersection rename to Surface_sweep_2/test/Surface_sweep_2/DATA/polylines/vertex_intersection diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/polylines/vertical_segment b/Surface_sweep_2/test/Surface_sweep_2/DATA/polylines/vertical_segment similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/polylines/vertical_segment rename to Surface_sweep_2/test/Surface_sweep_2/DATA/polylines/vertical_segment diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segment_circles/edge_vertex_intersection b/Surface_sweep_2/test/Surface_sweep_2/DATA/segment_circles/edge_vertex_intersection similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segment_circles/edge_vertex_intersection rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segment_circles/edge_vertex_intersection diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segment_circles/segs_and_circles b/Surface_sweep_2/test/Surface_sweep_2/DATA/segment_circles/segs_and_circles similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segment_circles/segs_and_circles rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segment_circles/segs_and_circles diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segment_circles/simple_intersection b/Surface_sweep_2/test/Surface_sweep_2/DATA/segment_circles/simple_intersection similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segment_circles/simple_intersection rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segment_circles/simple_intersection diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segment_circles/triangle b/Surface_sweep_2/test/Surface_sweep_2/DATA/segment_circles/triangle similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segment_circles/triangle rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segment_circles/triangle diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segment_circles/two_segments b/Surface_sweep_2/test/Surface_sweep_2/DATA/segment_circles/two_segments similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segment_circles/two_segments rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segment_circles/two_segments diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segment_circles/vertex_intersection b/Surface_sweep_2/test/Surface_sweep_2/DATA/segment_circles/vertex_intersection similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segment_circles/vertex_intersection rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segment_circles/vertex_intersection diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segment_circles/vertical_segment b/Surface_sweep_2/test/Surface_sweep_2/DATA/segment_circles/vertical_segment similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segment_circles/vertical_segment rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segment_circles/vertical_segment diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments/H_degeneracy b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments/H_degeneracy similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments/H_degeneracy rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments/H_degeneracy diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments/edge_vertex_intersection b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments/edge_vertex_intersection similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments/edge_vertex_intersection rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments/edge_vertex_intersection diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments/simple_intersection b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments/simple_intersection similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments/simple_intersection rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments/simple_intersection diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments/star_4 b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments/star_4 similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments/star_4 rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments/star_4 diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments/triangle b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments/triangle similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments/triangle rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments/triangle diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments/two_segments b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments/two_segments similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments/two_segments rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments/two_segments diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments/vertex_intersection b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments/vertex_intersection similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments/vertex_intersection rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments/vertex_intersection diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments/vertical_segment b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments/vertical_segment similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments/vertical_segment rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments/vertical_segment diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test00.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test00.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test00.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test00.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test01.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test01.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test01.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test01.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test02.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test02.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test02.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test02.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test03.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test03.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test03.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test03.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test04.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test04.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test04.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test04.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test05.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test05.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test05.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test05.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test06.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test06.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test06.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test06.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test07.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test07.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test07.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test07.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test08.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test08.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test08.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test08.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test09.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test09.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test09.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test09.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test10.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test10.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test10.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test10.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test11.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test11.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test11.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test11.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test12.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test12.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test12.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test12.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test13.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test13.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test13.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test13.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test14.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test14.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test14.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test14.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test15.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test15.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test15.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test15.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test16.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test16.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test16.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test16.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test17.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test17.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test17.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test17.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test18.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test18.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test18.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test18.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test19.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test19.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test19.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test19.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test20.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test20.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test20.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test20.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test21.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test21.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test21.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test21.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test22.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test22.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test22.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test22.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test23.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test23.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test23.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test23.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test24.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test24.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test24.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test24.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test25.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test25.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test25.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test25.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test26.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test26.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test26.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test26.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test27.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test27.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test27.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test27.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test28.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test28.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test28.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test28.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test29.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test29.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test29.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test29.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test30.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test30.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test30.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test30.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test31.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test31.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test31.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test31.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test32.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test32.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test32.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test32.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test33.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test33.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test33.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test33.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test34.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test34.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test34.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test34.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test35.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test35.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test35.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test35.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test36.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test36.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test36.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test36.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test37.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test37.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test37.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test37.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test40.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test40.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test40.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test40.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test41.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test41.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test41.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test41.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test42.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test42.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test42.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test42.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test43.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test43.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test43.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test43.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test44.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test44.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test44.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test44.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test45.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test45.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test45.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test45.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test46.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test46.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test46.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test46.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test47.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test47.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test47.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test47.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test48.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test48.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test48.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test48.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test49.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test49.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test49.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test49.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test50.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test50.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test50.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test50.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test51.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test51.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test51.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test51.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test52.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test52.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test52.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test52.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test53.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test53.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test53.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test53.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test54.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test54.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test54.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test54.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test55.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test55.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test55.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test55.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test56.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test56.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test56.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test56.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test60.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test60.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test60.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test60.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test61.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test61.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test61.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test61.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test62.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test62.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test62.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test62.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test63.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test63.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test63.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test63.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test64.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test64.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test64.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test64.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test65.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test65.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test65.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test65.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test66.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test66.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test66.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test66.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test67.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test67.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test67.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test67.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test68.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test68.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test68.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test68.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test69.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test69.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test69.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test69.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test70.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test70.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test70.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test70.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test71.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test71.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test71.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test71.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test72.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test72.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test72.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test72.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test73.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test73.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test73.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test73.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test74.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test74.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test74.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test74.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test75.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test75.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test75.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test75.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test76.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test76.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test76.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test76.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test77.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test77.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test77.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test77.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test78.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test78.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test78.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test78.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test79.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test79.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test79.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test79.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test80.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test80.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test80.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test80.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test81.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test81.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test81.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test81.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test82.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test82.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test82.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test82.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test83.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test83.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test83.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test83.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test84.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test84.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test84.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test84.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test85.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test85.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test85.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test85.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test86.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test86.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test86.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test86.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test87.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test87.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test87.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test87.txt diff --git a/Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test88.txt b/Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test88.txt similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/DATA/segments_tight/test88.txt rename to Surface_sweep_2/test/Surface_sweep_2/DATA/segments_tight/test88.txt diff --git a/Sweep_line_2/test/Sweep_line_2/cgal_test b/Surface_sweep_2/test/Surface_sweep_2/cgal_test similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/cgal_test rename to Surface_sweep_2/test/Surface_sweep_2/cgal_test diff --git a/Sweep_line_2/test/Sweep_line_2/cgal_test_base b/Surface_sweep_2/test/Surface_sweep_2/cgal_test_base similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/cgal_test_base rename to Surface_sweep_2/test/Surface_sweep_2/cgal_test_base diff --git a/Sweep_line_2/test/Sweep_line_2/cgal_test_with_cmake b/Surface_sweep_2/test/Surface_sweep_2/cgal_test_with_cmake similarity index 100% rename from Sweep_line_2/test/Sweep_line_2/cgal_test_with_cmake rename to Surface_sweep_2/test/Surface_sweep_2/cgal_test_with_cmake diff --git a/Sweep_line_2/test/Sweep_line_2/test_sweep.cpp b/Surface_sweep_2/test/Surface_sweep_2/test_sweep.cpp similarity index 93% rename from Sweep_line_2/test/Sweep_line_2/test_sweep.cpp rename to Surface_sweep_2/test/Surface_sweep_2/test_sweep.cpp index 2c3a5c4cc18..14084a04191 100644 --- a/Sweep_line_2/test/Sweep_line_2/test_sweep.cpp +++ b/Surface_sweep_2/test/Surface_sweep_2/test_sweep.cpp @@ -13,7 +13,7 @@ #define CGAL_POLYLINE_TRAITS 11 #define CGAL_CONIC_TRAITS 21 -// Picking a default Traits class (this, with the +// Picking a default Traits class (this, with the // PL flag enables the running of the test independently of cgal_make.) #ifndef CGAL_ARR_TEST_TRAITS #define CGAL_ARR_TEST_TRAITS CGAL_SEGMENT_TRAITS @@ -52,7 +52,7 @@ int main() // Choose traits -#if CGAL_ARR_TEST_TRAITS==CGAL_SEGMENT_TRAITS +#if CGAL_ARR_TEST_TRAITS==CGAL_SEGMENT_TRAITS #include #include #include @@ -78,10 +78,10 @@ int main() #include #include -#include +#include #include "CompareCurveList.h" -#if CGAL_ARR_TEST_TRAITS==CGAL_SEGMENT_TRAITS +#if CGAL_ARR_TEST_TRAITS==CGAL_SEGMENT_TRAITS typedef CGAL::Gmpq NT; typedef CGAL::Cartesian Kernel; typedef CGAL::Arr_segment_traits_2 Traits; @@ -132,10 +132,10 @@ int main(int argc, char * argv[]) std::cerr << "Cannot open file " << argv[1] << "!" << std::endl; return -1; } - + CurveList curves; ReadCurveList(inp, curves); - + Traits tr; // get subcurves w/o overlapping @@ -168,7 +168,7 @@ int main(int argc, char * argv[]) // get intersection points (with endpoints) PointList points_with_ends_list_out; CGAL::compute_intersection_points(curves.begin(), - curves.end(), + curves.end(), std::back_inserter(points_with_ends_list_out), true); @@ -176,14 +176,14 @@ int main(int argc, char * argv[]) // get intersection points w/o end points PointList points_without_ends_list_out; CGAL::compute_intersection_points(curves.begin(), - curves.end(), + curves.end(), std::back_inserter(points_without_ends_list_out), false); std::cout << points_without_ends_list_out.size() << " points_without_ends_list_out(size)\n"; // check the do_curves_intersecting method - bool do_intersect_out = + bool do_intersect_out = CGAL::do_curves_intersect(curves.begin(), curves.end()); @@ -203,28 +203,28 @@ int main(int argc, char * argv[]) CurveList curves_with_overlap_list; ReadCurveListRational(inp, curves_with_overlap_list); - if ( !compare_lists(curves_no_overlap_list_out, + if ( !compare_lists(curves_no_overlap_list_out, curves_no_overlap_list, tr) ) return -1; - if ( !compare_lists(curves_with_overlap_list_out, + if ( !compare_lists(curves_with_overlap_list_out, curves_with_overlap_list, tr) ) return -1; - if ( !compare_lists(points_with_ends_list_out, + if ( !compare_lists(points_with_ends_list_out, points_with_ends_list, tr)) return -1; - if ( !compare_lists(points_without_ends_list_out, + if ( !compare_lists(points_without_ends_list_out, points_without_ends_list, tr)) return -1; bool do_intersect = false; - if((points_without_ends_list.size() != 0) || + if((points_without_ends_list.size() != 0) || (curves_no_overlap_list_out.size() != curves_with_overlap_list_out.size())) do_intersect = true; - + if (do_intersect_out != do_intersect) return -1; diff --git a/Sweep_line_2/test/Sweep_line_2/test_sweep_conic.cpp b/Surface_sweep_2/test/Surface_sweep_2/test_sweep_conic.cpp similarity index 80% rename from Sweep_line_2/test/Sweep_line_2/test_sweep_conic.cpp rename to Surface_sweep_2/test/Surface_sweep_2/test_sweep_conic.cpp index b911e335022..f01da3d395c 100644 --- a/Sweep_line_2/test/Sweep_line_2/test_sweep_conic.cpp +++ b/Surface_sweep_2/test/Surface_sweep_2/test_sweep_conic.cpp @@ -10,8 +10,7 @@ int main() #else #include - -#include +#include #include #include @@ -22,36 +21,31 @@ int main() #include #include +typedef CGAL::CORE_algebraic_number_traits Nt_traits; +typedef Nt_traits::Rational Rational; +typedef Nt_traits::Algebraic Algebraic; +typedef CGAL::Cartesian Rat_kernel; +typedef Rat_kernel::Point_2 Rat_point_2; +typedef Rat_kernel::Segment_2 Rat_segment_2; +typedef Rat_kernel::Circle_2 Rat_circle_2; +typedef CGAL::Cartesian Alg_kernel; +typedef CGAL::Arr_conic_traits_2 + Traits_2; -typedef CGAL::CORE_algebraic_number_traits Nt_traits; -typedef Nt_traits::Rational Rational; -typedef Nt_traits::Algebraic Algebraic; -typedef CGAL::Cartesian Rat_kernel; -typedef Rat_kernel::Point_2 Rat_point_2; -typedef Rat_kernel::Segment_2 Rat_segment_2; -typedef Rat_kernel::Circle_2 Rat_circle_2; -typedef CGAL::Cartesian Alg_kernel; -typedef CGAL::Arr_conic_traits_2 Traits_2; +typedef Traits_2::Curve_2 Curve_2; +typedef Traits_2::X_monotone_curve_2 X_monotone_curve_2; +typedef Traits_2::Point_2 Point_2; +typedef std::list CurveList; -typedef Traits_2::Curve_2 Curve_2; -typedef Traits_2::X_monotone_curve_2 X_monotone_curve_2; -typedef Traits_2::Point_2 Point_2; -typedef std::list CurveList; - -typedef std::list PointList; -typedef PointList::iterator PointListIter; +typedef std::list PointList; +typedef PointList::iterator PointListIter; /*! Conic reader */ -template -class Conic_reader -{ +template +class Conic_reader { public: - - int ReadData(const char * filename, CurveList & curves, - CGAL::Bbox_2 & bbox) + int ReadData(const char* filename, CurveList& curves, CGAL::Bbox_2& bbox) { Curve_2 cv; char dummy[256]; @@ -69,21 +63,21 @@ public: curves.push_back(cv); CGAL::Bbox_2 curve_bbox = cv.bbox(); if (i == 0) bbox = curve_bbox; - else bbox = bbox + curve_bbox; + else bbox = bbox + curve_bbox; } inp.close(); return 0; } - + void ReadCurve(std::ifstream & is, Curve_2 & cv) { // Read a line from the input file. char one_line[128]; - + skip_comments (is, one_line); std::string stringvalues(one_line); std::istringstream str_line (stringvalues, std::istringstream::in); - + // Get the arc type. // Supported types are: 'f' - Full ellipse (or circle). // 'e' - Elliptic arc (or circular arc). @@ -92,12 +86,12 @@ public: bool is_circle = false; // Is this a circle. Rat_circle_2 circle; Rational r, s, t, u, v, w; // The conic coefficients. - + str_line >> type; - + // An ellipse (full ellipse or a partial ellipse): if (type == 'f' || type == 'F' || type == 'e' || type == 'E') - { + { // Read the ellipse (using the format "a b x0 y0"): // // x - x0 2 y - y0 2 @@ -105,12 +99,12 @@ public: // a b // int a, b, x0, y0; - + str_line >> a >> b >> x0 >> y0; - + Rational a_sq = Rational(a*a); Rational b_sq = Rational(b*b); - + if (a == b) { is_circle = true; @@ -126,7 +120,7 @@ public: v = Rational(-2*y0*a_sq); w = Rational(x0*x0*b_sq + y0*y0*a_sq - a_sq*b_sq); } - + if (type == 'f' || type == 'F') { // Create a full ellipse (or circle). @@ -139,7 +133,7 @@ public: { // Read the endpointd of the arc. int x1, y1, x2, y2; - + str_line >> x1 >> y1 >> x2 >> y2; Point_2 source = Point_2 (Algebraic(x1), Algebraic(y1)); @@ -154,25 +148,25 @@ public: cv = Curve_2 (r, s, t, u, v, w, CGAL::CLOCKWISE, source, target); - } + } } else if (type == 's' || type == 'S') { // Read a segment, given by its endpoints (x1,y1) and (x2,y2); int x1, y1, x2, y2; - + str_line >> x1 >> y1 >> x2 >> y2; - + // Create the segment. Rat_point_2 source = Rat_point_2 (Rational(x1), Rational(y1)); Rat_point_2 target = Rat_point_2 (Rational(x2), Rational(y2)); - + cv = Curve_2(Rat_segment_2 (source, target)); } - + return; } - + void skip_comments( std::ifstream& is, char* one_line ) { while( !is.eof() ){ @@ -180,7 +174,7 @@ public: if( one_line[0] != '#' ){ break; } - } + } } }; @@ -192,7 +186,7 @@ int main (int argc, char** argv) bool verbose = false; // Define a test objects to read the conic arcs from it. - if (argc<2) + if (argc<2) { std::cerr << "Usage: Conic_traits_test " << std::endl; exit(1); @@ -207,15 +201,15 @@ int main (int argc, char** argv) // run the sweep std::list mylist; - CGAL::compute_subcurves(curves.begin(), curves.end(), + CGAL::compute_subcurves(curves.begin(), curves.end(), std::back_inserter(mylist), false); - - + + PointList point_list_with_ends; - CGAL::compute_intersection_points(curves.begin(), curves.end(), + CGAL::compute_intersection_points(curves.begin(), curves.end(), std::back_inserter(point_list_with_ends), true); int point_count_with_ends_calculated = point_list_with_ends.size(); - + // generate the string for the output std::stringstream out1; for ( std::list::iterator iter = mylist.begin() ; @@ -223,12 +217,12 @@ int main (int argc, char** argv) { out1 << *iter << "\n"; } - + // read the output from the file std::stringstream out2; char buf[1024]; int count = 0; - + std::ifstream in_file(argv[1]); in_file >> count; in_file.getline(buf, 1024); // to get rid of the new line @@ -244,7 +238,7 @@ int main (int argc, char** argv) int point_count_with_ends_from_file = 0; in_file >> point_count_with_ends_from_file; in_file.close(); - + if ( verbose ) { std::cout << "Result: \n" << mylist.size() << "\n"; @@ -254,15 +248,15 @@ int main (int argc, char** argv) std::cout << *i << "\n"; } } - + std::string calculated = out1.str(); std::string infile = out2.str(); - + if ( infile == calculated ) { - if ( point_count_with_ends_from_file != + if ( point_count_with_ends_from_file != point_count_with_ends_calculated ) { - std::cout << "number of intersection points (with ends):" - << point_count_with_ends_calculated << ". Should be " + std::cout << "number of intersection points (with ends):" + << point_count_with_ends_calculated << ". Should be " << point_count_with_ends_from_file << "\n"; std::cout << argv[1] << " Error\n"; return -1; @@ -278,8 +272,8 @@ int main (int argc, char** argv) std::cout << "--" << std::endl; return -1; } - - return 0; + + return 0; } #endif diff --git a/Sweep_line_2/doc/Sweep_line_2/Sweep_line_2.txt b/Sweep_line_2/doc/Sweep_line_2/Sweep_line_2.txt deleted file mode 100644 index 086bf757cff..00000000000 --- a/Sweep_line_2/doc/Sweep_line_2/Sweep_line_2.txt +++ /dev/null @@ -1,60 +0,0 @@ -namespace CGAL { -/*! - -\mainpage User Manual -\anchor Chapter_2D_Intersection_of_Curves -\anchor I1_ChapterSweepLine - -\cgalAutoToc -\authors Baruch Zukerman, Ron Wein, and Efi Fogel - -\section Sweep_line_2Introduction Introduction - -Let \f$ {\mathcal C} = \{C_1, C_2, \ldots, C_n\}\f$ be a set of curves. -We wish to compute all intersection points between -two curves in the set in an output-sensitive manner, without having to -go over all \f$ O(n^2)\f$ curve pairs. To this end, we sweep an imaginary line \f$ l\f$ -from \f$ x = -\infty\f$ to \f$ x = \infty\f$ over the plane. While sweeping -the plane, we keep track of the order of curves intersecting it. -This order changes at a finite number of event points, such that -we only have to calculate the intersection points -between two curves when they become contiguous. For more details on the -sweep-line algorithm see, for example, \cgalCite{bkos-cgaa-00}, Chapter 2. - -This chapter describes three functions implemented using the sweep-line -algorithm: given a collection of input curves, compute all intersection points, -compute the set of subcurves that are pairwise interior-disjoint induced by them, -and checking whether there is at least one pair of curves among them that intersect in their interior. - -The implementation is robust. It supports general -curves and handles all degenerate cases, including overlapping curves, -vertical segments, and tangency between curves. The robustness of the -algorithm is guaranteed if the functions are instantiated with a traits -class that employs certified computations. This traits class must be a model -of the `ArrangementTraits_2` concept - see the -Chapter \ref chapterArrangement_on_surface_2 "2D Arrangements" for more details. - -The complexity of the sweep-line algorithm is \f$ O((n + k)\log{n})\f$ where \f$ n\f$ -is the number of the input curves and \f$ k\f$ is the number of -intersection points induced by these curves. - -\section Sweep_line_2Example Example - -The simple program listed below computes intersection points induced by -a set of four input segments illustrated in \cgalFigureRef{SL_secsimple}. - -\cgalFigureBegin{SL_secsimple,sl_simple.png} -Four input segments -\cgalFigureEnd - -\cgalExample{Sweep_line_2/sweep_line.cpp} - -\section Sweep_line_2Design Design and Implementation History - -The current version of the sweep-line algorithm was written by -Baruch Zukerman, based on previous implementations by Ester Ezra and -Tali Zvi. - -*/ -} /* namespace CGAL */ - diff --git a/Sweep_line_2/doc/Sweep_line_2/examples.txt b/Sweep_line_2/doc/Sweep_line_2/examples.txt deleted file mode 100644 index ccafc547dab..00000000000 --- a/Sweep_line_2/doc/Sweep_line_2/examples.txt +++ /dev/null @@ -1,3 +0,0 @@ -/*! -\example Sweep_line_2/sweep_line.cpp -*/ diff --git a/Sweep_line_2/examples/Sweep_line_2/sweep_line.cpp b/Sweep_line_2/examples/Sweep_line_2/sweep_line.cpp deleted file mode 100644 index 0ac42c7a646..00000000000 --- a/Sweep_line_2/examples/Sweep_line_2/sweep_line.cpp +++ /dev/null @@ -1,47 +0,0 @@ -//! \file examples/Arrangement_on_surface_2/sweep_line.cpp -// Computing intersection points among curves using the sweep line. - -#include -#include -#include -#include -#include -#include - -typedef CGAL::Quotient NT; -typedef CGAL::Cartesian Kernel; -typedef Kernel::Point_2 Point_2; -typedef CGAL::Arr_segment_traits_2 Traits_2; -typedef Traits_2::Curve_2 Segment_2; - -int main() -{ - // Construct the input segments. - Segment_2 segments[] = {Segment_2 (Point_2 (1, 5), Point_2 (8, 5)), - Segment_2 (Point_2 (1, 1), Point_2 (8, 8)), - Segment_2 (Point_2 (3, 1), Point_2 (3, 8)), - Segment_2 (Point_2 (8, 5), Point_2 (8, 8))}; - - // Compute all intersection points. - std::list pts; - - CGAL::compute_intersection_points (segments, segments + 4, - std::back_inserter (pts)); - - // Print the result. - std::cout << "Found " << pts.size() << " intersection points: " << std::endl; - std::copy (pts.begin(), pts.end(), - std::ostream_iterator(std::cout, "\n")); - - // Compute the non-intersecting sub-segments induced by the input segments. - std::list sub_segs; - - CGAL::compute_subcurves(segments, segments + 4, std::back_inserter(sub_segs)); - - std::cout << "Found " << sub_segs.size() - << " interior-disjoint sub-segments." << std::endl; - - CGAL_assertion (CGAL::do_curves_intersect (segments, segments + 4)); - - return 0; -} diff --git a/Sweep_line_2/include/CGAL/Sweep_line_2/Arr_construction_event.h b/Sweep_line_2/include/CGAL/Sweep_line_2/Arr_construction_event.h deleted file mode 100644 index 859b5571235..00000000000 --- a/Sweep_line_2/include/CGAL/Sweep_line_2/Arr_construction_event.h +++ /dev/null @@ -1,272 +0,0 @@ -// Copyright (c) 2006,2007,2009,2010,2011 Tel-Aviv University (Israel). -// All rights reserved. -// -// This file is part of CGAL (www.cgal.org). -// You can redistribute it and/or modify it under the terms of the GNU -// General Public License as published by the Free Software Foundation, -// either version 3 of the License, or (at your option) any later version. -// -// Licensees holding a valid commercial license may use this file in -// accordance with the commercial license agreement provided with the software. -// -// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -// -// $URL$ -// $Id$ -// SPDX-License-Identifier: GPL-3.0+ -// -// -// Author(s) : Tali Zvi -// Baruch Zukerman -// Efi Fogel - -#ifndef CGAL_ARR_CONSTRUCTION_EVENT_H -#define CGAL_ARR_CONSTRUCTION_EVENT_H - -#include - - -/*! \file - * Definition of the Arr_construction_event class-template. - */ - -#include -#include -#include - -namespace CGAL { - -/*! \class Arr_construction_event - * - * Stores the data associated with an event. - * In addition to the information stored in Sweep_line_event, when - * constructing an arrangement, additional information is kept, in - * order to speed insertion of curves into the planar map. - * - * The additional infomation contains the following: - * - among the left curves of the event, we keep the highest halfedge that - * was inserted into the arrangement at any given time and when there no - * left curves, we keep the highest halfedge that was inseted to the right. - * - * Inherits from `Sweep_line_event`. - * \sa `Sweep_line_event` - */ - -template -class Arr_construction_event : - public Sweep_line_event -{ -public: - - typedef Traits_ Traits_2; - typedef Subcurve_ Subcurve; - typedef Arrangement_ Arrangement_2; - typedef typename Arrangement_2::Vertex_handle Vertex_handle; - typedef typename Arrangement_2::Halfedge_handle Halfedge_handle; - - typedef typename Traits_2::X_monotone_curve_2 X_monotone_curve_2; - typedef typename Traits_2::Point_2 Point_2; - - typedef Sweep_line_event Base; - - typedef Arr_construction_event Self; - - typedef typename Base::Subcurve_container Subcurve_container; - typedef typename Base::Subcurve_iterator Subcurve_iterator; - typedef typename Base::Subcurve_reverse_iterator Subcurve_reverse_iterator; - -protected: - - // Data members: - std::vector m_isCurveInArr; // Stores for each incident - // subcurve whether it has been - // inserted into the arrangement. - - Halfedge_handle m_halfedge; // A halfedge handle. - Vertex_handle m_vertex; // A vertex handle. - - unsigned int m_right_curves_counter; // Number of subcurves defined - // to the event's right that - // haven't been added to the - // arrangement, when that counter - // is zero, we can deallocate the - // event. - -public: - - /*! Default constructor. */ - Arr_construction_event(): - m_halfedge(), - m_vertex(), - m_right_curves_counter(0) - {} - - /*! Destructor */ - ~Arr_construction_event() - {} - - /*! Add a curve to the right of the event. */ - std::pair - add_curve_to_right (Subcurve *curve, - const Traits_2 * tr) - { - std::pair res = - Base::add_curve_to_right(curve, tr); - - if(res.second != this->m_rightCurves.end() && res.first == false) - ++m_right_curves_counter; - - return res; - } - - /*! Add a curve pair to the right of the event. */ - std::pair - add_curve_pair_to_right (Subcurve *sc1, Subcurve *sc2) - { - //increment twice the counter of right curves - m_right_curves_counter+=2; - return (Base::add_curve_pair_to_right(sc1, sc2)); - } - - /*! using the additional data that we store at the event, we compute - * how much we have to jump (he = he->next()->twin()) from the halfedge - * that is stored in the event, to the halefge that is previous to 'curve' - * that is about to be inserted into the arrangement. - */ - int compute_halfedge_jump_count(Subcurve *curve) - { - int i = 0; - int skip = 0; - int counter = 0; - unsigned int j; - - for (j = 0 ; j < m_isCurveInArr.size() ; j++ ) - { - if (m_isCurveInArr[j]) - skip++; - } - skip--; // now 'skip' holds the amount of the right curves of the event - // that are already inserted to the planar map - 1 (minus 1) - - Subcurve_iterator iter = this->m_rightCurves.end(); - size_t num_left_curves = this->number_of_left_curves(); - - for (--iter; iter != this->m_rightCurves.begin() ; --iter, ++counter) - { - if (curve == (*iter)) - { - m_isCurveInArr[counter] = true; - - if ((i == 0) && (num_left_curves == 0)) - return (skip); - if (num_left_curves == 0) - return (i - 1); - - return (i); - } - - if (m_isCurveInArr[counter]) - i++; - } - - CGAL_assertion(curve == (*iter)); - m_isCurveInArr[counter] = true; - - if (num_left_curves == 0) - i--; - - return (i); - } - - /*! return true iff 'curve' is the toppest curve among the halfedges - * to the right fo the event that were already were inserted to the - * arrangement. - */ - bool is_curve_largest (Subcurve *curve) - { - int counter = 0; - - Subcurve_reverse_iterator rev_iter; - for (rev_iter = this->m_rightCurves.rbegin(); - rev_iter != this->m_rightCurves.rend() && curve != (*rev_iter) ; - ++rev_iter, ++ counter) - { - if(m_isCurveInArr[counter] == true) - return false; - } - return true; - } - - /*! - * Resize the bit-vector indicating whether the incident curves are already - * in the arrangement, and set all flags to false. - */ - void init_subcurve_in_arrangement_flags (size_t n) - { - m_isCurveInArr.resize (n, false); - return; - } - - /*! Check if the i'th subcurve is in the arrangement. */ - bool is_subcurve_in_arrangement (unsigned int i) const - { - return (m_isCurveInArr[i]); - } - - /*! - * Set the flag indicating whether the i'th subcurve is in the arrangement. - */ - void set_subcurve_in_arrangement (unsigned int i, bool flag) - { - m_isCurveInArr[i] = flag; - return; - } - - /*! Set the halfedge handle. */ - void set_halfedge_handle (Halfedge_handle h) - { - m_halfedge = h; - } - - /*! Get the halfedge handle. */ - Halfedge_handle halfedge_handle() const - { - return m_halfedge; - } - - /*! Set the vertex handle. */ - void set_vertex_handle (Vertex_handle v) - { - m_vertex = v; - } - - /*! Get the vertex handle. */ - Vertex_handle vertex_handle() const - { - return m_vertex; - } - - /*! Decrement the count of curves to the right that we have't done yet with - * (haven't been inserted to the arrangement). */ - unsigned int dec_right_curves_counter() - { - return (--m_right_curves_counter); - } - - /*! Get the number of subcurves to the right of the event that we have't - * done yet with (haven't been inserted to the arrangement). - */ - unsigned int right_curves_counter() const - { - return (m_right_curves_counter); - } - -}; - -} //namespace CGAL - -#endif diff --git a/Sweep_line_2/include/CGAL/Sweep_line_2/Arr_construction_subcurve.h b/Sweep_line_2/include/CGAL/Sweep_line_2/Arr_construction_subcurve.h deleted file mode 100644 index fefc3992a04..00000000000 --- a/Sweep_line_2/include/CGAL/Sweep_line_2/Arr_construction_subcurve.h +++ /dev/null @@ -1,140 +0,0 @@ -// Copyright (c) 2006,2007,2009,2010,2011 Tel-Aviv University (Israel). -// All rights reserved. -// -// This file is part of CGAL (www.cgal.org). -// You can redistribute it and/or modify it under the terms of the GNU -// General Public License as published by the Free Software Foundation, -// either version 3 of the License, or (at your option) any later version. -// -// Licensees holding a valid commercial license may use this file in -// accordance with the commercial license agreement provided with the software. -// -// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -// -// $URL$ -// $Id$ -// SPDX-License-Identifier: GPL-3.0+ -// -// -// Author(s) : Tali Zvi -// Baruch Zukerman - -#ifndef CGAL_ARR_CONSTRUCTION_SUBCURVE_H -#define CGAL_ARR_CONSTRUCTION_SUBCURVE_H - -#include - - -/*! \file - * Definition of the Arr_construction_subcurve class-template. - */ - -#include - -namespace CGAL { - -/*! \class Arr_construction_subcurve - * - * a class that holds information about a curve that is added to - * the arrangement. - * In addition to the information that is contained in Sweep_line_subcurve, - * when an arrangement is constructed, a pointer to the last handled event - * on the curve is stored. This information is used to retrieve - * hints when a subcurve of this curve is inserted into the planar map. - * - * Inherits from `Sweep_line_subcurve` - * \sa `Sweep_line_subcurve` - */ - -template -class Arr_construction_subcurve : public Sweep_line_subcurve -{ -public: - typedef Traits_ Traits_2; - typedef typename Traits_2::Point_2 Point_2; - typedef typename Traits_2::X_monotone_curve_2 X_monotone_curve_2; - - typedef Sweep_line_subcurve Base; - typedef Arr_construction_subcurve Self; - - typedef typename Base::Status_line_iterator Status_line_iterator; - typedef void* Event_ptr; - typedef std::list Halfedge_indices_list; - -protected: - - // Data members: - Event_ptr m_lastEvent; // The last event that was handled on the curve. - - /*! index for a subcurve that may represent a hole (emarge from the left - * most vertex of a hole, and its the upper most curve). other subcurves - * will have 0 value (invalid index) - */ - unsigned int m_index; // Index for a subcurve that may represent a hole - // (emarge from the leftmost vertex of a hole, - // and it is the topmost curve). Other subcurves - // have a 0 (invalid) index. - - Halfedge_indices_list m_halfedge_indices; - // Indices of all halfedge below the curve that - // may represent a hole. - -public: - /*! Deafult constructor. */ - Arr_construction_subcurve() : - Base(), - m_lastEvent(0), - m_index(0) - {} - - /*! Constructor from an x-monotone curve. */ - Arr_construction_subcurve(X_monotone_curve_2& curve) : - Base( curve), - m_lastEvent(0), - m_index(0) - {} - - /*! Initialize the curve. */ - void init(const X_monotone_curve_2& curve) { Base::init(curve); } - - /*! Set the event associated with the left end of the subcurve. */ - template - void set_left_event(SweepEvent* left) - { - Base::set_left_event(left); - m_lastEvent = left; - } - - /*! Set the last event on the subcurve. */ - void set_last_event(Event_ptr e) { m_lastEvent = e; } - - /*! Get the last event. */ - Event_ptr last_event() const { return m_lastEvent; } - - /*! Get the subcurve index. */ - unsigned int index() const { return m_index; } - - /*! Set the subcurve index. */ - void set_index(unsigned int i) { m_index = i; } - - /*! Check if the index is valid. */ - bool has_valid_index() const { return (m_index != 0); } - - /*! Add an index of a halfedge below the subcurve. */ - void add_halfedge_index(unsigned int i) { m_halfedge_indices.push_back(i); } - - /*! Clear the indices of the halfedges below the subcurve. */ - void clear_halfedge_indices() { m_halfedge_indices.clear(); } - - /*! Check if there are any halfedges below the subcurve. */ - bool has_halfedge_indices() const { return (!m_halfedge_indices.empty()); } - - /*! Get the indices of the halfedges below the subcurve. */ - Halfedge_indices_list& halfedge_indices_list() { return m_halfedge_indices; } -}; - - -} //namespace CGAL - -#endif diff --git a/Sweep_line_2/include/CGAL/Sweep_line_2/Arr_insertion_sl_visitor.h b/Sweep_line_2/include/CGAL/Sweep_line_2/Arr_insertion_sl_visitor.h deleted file mode 100644 index 6c5cdfb4a7c..00000000000 --- a/Sweep_line_2/include/CGAL/Sweep_line_2/Arr_insertion_sl_visitor.h +++ /dev/null @@ -1,141 +0,0 @@ -// Copyright (c) 2006,2007,2009,2010,2011 Tel-Aviv University (Israel). -// All rights reserved. -// -// This file is part of CGAL (www.cgal.org). -// You can redistribute it and/or modify it under the terms of the GNU -// General Public License as published by the Free Software Foundation, -// either version 3 of the License, or (at your option) any later version. -// -// Licensees holding a valid commercial license may use this file in -// accordance with the commercial license agreement provided with the software. -// -// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -// -// $URL$ -// $Id$ -// SPDX-License-Identifier: GPL-3.0+ -// -// Author(s) : Baruch Zukerman -// Ron Wein -// Efi Fogel - -#ifndef CGAL_ARR_INSERTION_SL_VISITOR_H -#define CGAL_ARR_INSERTION_SL_VISITOR_H - -#include - - -/*! - * Definition of the Arr_insertion_sl_visitor class-template. - */ - -#include - -namespace CGAL { - -/*! \class Arr_insertion_sl_visitor - * A sweep-line visitor for inserting new curves into an existing arrangement - * embedded on a surface. - */ -template -class Arr_insertion_sl_visitor : - public Arr_basic_insertion_sl_visitor -{ -public: - typedef Helper_ Helper; - - typedef Arr_basic_insertion_sl_visitor Base; - - typedef typename Base::Traits_2 Traits_2; - typedef typename Base::Arrangement_2 Arrangement_2; - typedef typename Base::Event Event; - typedef typename Base::Subcurve Subcurve; - - typedef typename Base::Halfedge_handle Halfedge_handle; - typedef typename Base::X_monotone_curve_2 X_monotone_curve_2; - typedef typename Base::Point_2 Point_2; - -private: - X_monotone_curve_2 sub_cv1; // Auxiliary variables - X_monotone_curve_2 sub_cv2; // (used for splitting curves). - -public: - /*! Constructor. */ - Arr_insertion_sl_visitor (Arrangement_2* arr) : Base(arr) {} - - /// \name Edge-split functions (to be overridden by the child visitor). - //@{ - - /*! - * Check if the halfedge associated with the given subcurve will be split - * at the given event. - * \param sc The subcurve. - * \param event The event. - */ - virtual bool is_split_event(Subcurve* sc, Event* event); - - /*! - * Split the given edge edge. - * \param he The edge to split. - * \param sc The associated subcurve. - * \param The split point. - * \return A handle to the split edge. - */ - virtual Halfedge_handle split_edge(Halfedge_handle he, Subcurve* sc, - const Point_2& pt); - //@} -}; - -//----------------------------------------------------------------------------- -// Memeber-function definitions: -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// Check if the halfedge associated with the given subcurve will be split -// at the given event. -// -template -bool Arr_insertion_sl_visitor::is_split_event(Subcurve* sc, Event* event) -{ - if (sc->last_curve().halfedge_handle() == Halfedge_handle(NULL)) - return false; - - if (! sc->originating_subcurve1()) { - return (reinterpret_cast(sc->left_event()) != - this->current_event()); - } - return - (this->is_split_event - (reinterpret_cast(sc->originating_subcurve1()), event) || - this->is_split_event - (reinterpret_cast(sc->originating_subcurve2()), event)); - } - -//----------------------------------------------------------------------------- -// Split an edge. -// -template -typename Arr_insertion_sl_visitor::Halfedge_handle -Arr_insertion_sl_visitor::split_edge(Halfedge_handle he, Subcurve* sc, - const Point_2& pt) -{ - // Make sure that the halfedge associated with sc is the directed from - // right to left, since we always "look" above , and the incident face - // is on the left of the halfedge - CGAL_assertion (he->direction() == ARR_RIGHT_TO_LEFT); - - this->traits()->split_2_object()(he->curve(), pt, sub_cv2, sub_cv1); - Halfedge_handle new_he = - this->m_arr_access.split_edge_ex(he, pt.base(), - sub_cv1.base(), sub_cv2.base()); - Event* last_event_on_sc = reinterpret_cast(sc->last_event()); - if (last_event_on_sc->halfedge_handle() == he) - last_event_on_sc->set_halfedge_handle(new_he->next()); - - return new_he; -} - -} //namespace CGAL - -#endif diff --git a/Sweep_line_2/include/CGAL/Sweep_line_2/Sweep_line_2_visitors.h b/Sweep_line_2/include/CGAL/Sweep_line_2/Sweep_line_2_visitors.h deleted file mode 100644 index 839dc15e461..00000000000 --- a/Sweep_line_2/include/CGAL/Sweep_line_2/Sweep_line_2_visitors.h +++ /dev/null @@ -1,290 +0,0 @@ -// Copyright (c) 2006,2007,2009,2010,2011 Tel-Aviv University (Israel). -// All rights reserved. -// -// This file is part of CGAL (www.cgal.org). -// You can redistribute it and/or modify it under the terms of the GNU -// General Public License as published by the Free Software Foundation, -// either version 3 of the License, or (at your option) any later version. -// -// Licensees holding a valid commercial license may use this file in -// accordance with the commercial license agreement provided with the software. -// -// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -// -// $URL$ -// $Id$ -// SPDX-License-Identifier: GPL-3.0+ -// -// -// Author(s) : Baruch Zukerman -// Ron Wein - -#ifndef CGAL_SWEEP_LINE_2_VISITORS_H -#define CGAL_SWEEP_LINE_2_VISITORS_H - -#include - - -/*! \file - * Definition of the basic sweep-line visitors, for the usage of the global - * sweep-line functions. - */ - -#include -#include -#include -#include -#include -#include - -namespace CGAL { - -/*! \class - * A simple sweep-line visitor that reports all intersection points among a - * set of input curves. - */ -template -class Sweep_line_points_visitor : - public Sweep_line_empty_visitor -{ - typedef Traits_ Traits_2; - typedef OutputIerator_ Output_ierator; - typedef Sweep_line_points_visitor Self; - - typedef Sweep_line_empty_visitor Base; - typedef typename Base::Event Event; - typedef typename Base::Subcurve Subcurve; - typedef typename Base::Event_subcurve_iterator Event_subcurve_iterator; - typedef typename Base::Status_line_iterator Status_line_iterator; - - - typedef typename Traits_2::X_monotone_curve_2 X_monotone_curve_2; - typedef typename Traits_2::Point_2 Point_2; - - typedef CGAL::Sweep_line_2 Sweep_line_2; - -protected: - Output_ierator m_out; // The output points. - bool m_includeEndPoints; // Should we include endpoints. - -public: - Sweep_line_points_visitor(Output_ierator out, bool endpoints) : - m_out(out), - m_includeEndPoints(endpoints) - {} - - template - void sweep(CurveIterator begin, CurveIterator end) - { - std::vector curves_vec; - std::vector points_vec; - - curves_vec.reserve(std::distance(begin,end)); - make_x_monotone(begin, end, - std::back_inserter(curves_vec), - std::back_inserter(points_vec), - this->traits()); - - //Perform the sweep - Sweep_line_2* sl = reinterpret_cast(this->sweep_line()); - - sl->sweep(curves_vec.begin(), curves_vec.end(), - points_vec.begin(), points_vec.end()); - } - - bool after_handle_event(Event* event, - Status_line_iterator /* iter */, - bool /* flag */) - { - if ((m_includeEndPoints || - event->is_intersection() || - event->is_weak_intersection()) && event->is_closed()) - { - *m_out = event->point(); - ++m_out; - } - return true; - } - - Output_ierator output_iterator() { return m_out; } -}; - -/*! \class - * A simple sweep-line visitor that reports all non-intersecting - * x-monotone curves induced by a set of input curves. - */ -template -class Sweep_line_subcurves_visitor : - public Sweep_line_empty_visitor -{ - typedef Traits_ Traits_2; - typedef OutputIerator_ Output_ierator; - typedef Sweep_line_subcurves_visitor Self; - - typedef typename Traits_2::X_monotone_curve_2 X_monotone_curve_2; - typedef typename Traits_2::Point_2 Point_2; - - typedef Sweep_line_empty_visitor Base; - typedef typename Base::Event Event; - typedef typename Base::Subcurve Subcurve; - typedef typename Base::Status_line_iterator Status_line_iterator; - - typedef CGAL::Sweep_line_2 Sweep_line_2; - -protected: - // Data members: - Output_ierator m_out; // The output curves. - bool m_overlapping; // Should we report overlapping curves twice. - -public: - Sweep_line_subcurves_visitor(Output_ierator out, bool overlapping) : - m_out(out), - m_overlapping(overlapping) - {} - - template - void sweep(CurveIterator begin, CurveIterator end) - { - std::vector curves_vec; - std::vector points_vec; - - curves_vec.reserve(std::distance(begin,end)); - make_x_monotone(begin, end, - std::back_inserter(curves_vec), - std::back_inserter(points_vec), - this->traits()); - - // Perform the sweep. - Sweep_line_2* sl = reinterpret_cast(this->sweep_line()); - - sl->sweep(curves_vec.begin(), curves_vec.end(), - points_vec.begin(), points_vec.end()); - } - - void add_subcurve(const X_monotone_curve_2& cv, Subcurve *sc) - { - if (!m_overlapping) { - // Report the curve once, whether it represents an overlap or not. - *m_out = cv; - ++m_out; - } - else { - unsigned int overlap_depth = sc->overlap_depth(); - for (unsigned int i = 0; i < overlap_depth; ++i) { - *m_out = cv; - ++m_out; - } - } - } - - Output_ierator output_iterator() { return m_out; } -}; - -/*! \class - * A simple sweep-line visitor that determines if there are intersections - * in the interiors of the given curve set. - */ -template -class Sweep_line_do_curves_x_visitor : - public Sweep_line_empty_visitor -{ - typedef Traits_ Traits_2; - typedef Sweep_line_do_curves_x_visitor Self; - - typedef typename Traits_2::X_monotone_curve_2 X_monotone_curve_2; - typedef typename Traits_2::Point_2 Point_2; - - typedef Sweep_line_empty_visitor Base; - typedef typename Base::Event Event; - typedef typename Base::Subcurve Subcurve; - typedef typename Base::Status_line_iterator Status_line_iterator; - - typedef CGAL::Sweep_line_2 Sweep_line_2; - -protected: - // Data members: - bool m_found_x; // Have we found an intersection so far. - -public: - Sweep_line_do_curves_x_visitor() : - m_found_x(false) - {} - - template - void sweep(CurveIterator begin, CurveIterator end) - { - std::vector curves_vec; - std::vector points_vec; - - curves_vec.reserve(std::distance(begin,end)); - make_x_monotone(begin, end, - std::back_inserter(curves_vec), - std::back_inserter(points_vec), - this-> traits()); - - // Perform the sweep. - Sweep_line_2* sl = reinterpret_cast(this->sweep_line()); - - sl->sweep(curves_vec.begin(), curves_vec.end(), - points_vec.begin(), points_vec.end()); - } - - void update_event(Event* /* e */, - Subcurve* /* sc1 */, - Subcurve* /* sc2 */, - bool /* is_new */) - { m_found_x = true; } - - void update_event(Event* /* e */, - Subcurve* /* sc1 */) - { m_found_x = true; } - - void update_event(Event* /* e */, - const Point_2& /* end_point */, - const X_monotone_curve_2& /* cv */, - Arr_curve_end /* cv_end */, - bool /* is_new */) - {} - - void update_event(Event* /* e */, - const X_monotone_curve_2& /* cv */, - Arr_curve_end /* cv_end */, - bool /* is_new */) - {} - - void update_event(Event* /* e */, - const Point_2& /* pt */, - bool /* is_new */) - {} - - template - void sweep_xcurves(XCurveIterator begin, XCurveIterator end) - { - // Perform the sweep. - Sweep_line_2* sl = reinterpret_cast(this->sweep_line()); - sl->sweep(begin, end); - } - - void found_overlap(Subcurve* /* sc1 */, - Subcurve* /* sc2 */, - Subcurve* /* ov_sc */) - { m_found_x = true; } - - bool after_handle_event(Event* /* event */, - Status_line_iterator /* iter */, - bool /* flag */) - { - if (m_found_x) { - Sweep_line_2* sl = reinterpret_cast(this->sweep_line()); - sl->stop_sweep(); - } - return true; - } - - bool found_intersection() { return m_found_x; } -}; - -} //namespace CGAL - -#endif diff --git a/Sweep_line_2/include/CGAL/Sweep_line_2/Sweep_line_curve_pair.h b/Sweep_line_2/include/CGAL/Sweep_line_2/Sweep_line_curve_pair.h deleted file mode 100644 index d7894f25a6f..00000000000 --- a/Sweep_line_2/include/CGAL/Sweep_line_2/Sweep_line_curve_pair.h +++ /dev/null @@ -1,223 +0,0 @@ -// Copyright (c) 2006,2007,2009,2010,2011 Tel-Aviv University (Israel). -// All rights reserved. -// -// This file is part of CGAL (www.cgal.org). -// You can redistribute it and/or modify it under the terms of the GNU -// General Public License as published by the Free Software Foundation, -// either version 3 of the License, or (at your option) any later version. -// -// Licensees holding a valid commercial license may use this file in -// accordance with the commercial license agreement provided with the software. -// -// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -// -// $URL$ -// $Id$ -// SPDX-License-Identifier: GPL-3.0+ -// -// -// Author(s) : Baruch Zukerman -// Ron Wein - -#ifndef CGAL_SWEEP_LINE_CURVE_PAIR_H -#define CGAL_SWEEP_LINE_CURVE_PAIR_H - -#include - - -/*! \file - * Definition of the Curve_pair class and related functors. - */ - -namespace CGAL { - -/*! \class - * A pair of subcurves. - */ -template -class Curve_pair -{ -public: - - typedef Subcurve_ Subcurve; - -private: - - // Data members: - std::pair m_pair; - -public: - - /*! Default constructor. */ - Curve_pair(){} - - /*! Constructor from two subcurves. */ - Curve_pair (Subcurve *sc1, Subcurve *sc2) - { - // The smallest pointer will be the first. - if(sc1 < sc2) - m_pair = std::make_pair (sc1,sc2); - else - m_pair = std::make_pair (sc2,sc1); - } - - /*! Get the first subcurve. */ - Subcurve* first() const - { - return (m_pair.first); - } - - /*! Get the second subcurve. */ - Subcurve* second() const - { - return (m_pair.second); - } -}; - -/*! \struct - * Less functor for curve pairs. - */ -template -struct Less_curve_pair -{ - typedef Subcurve_ Subcurve; - typedef class Curve_pair Curve_pair; - - bool operator() (const Curve_pair& pair1, const Curve_pair& pair2) const - { - if (pair1.first() < pair2.first()) - return true; - if (pair1.first() > pair2.first()) - return false; - if (pair1.second() < pair2.second()) - return true; - return false; - } -}; - -/*! \struct - * A hash functor for curve pairs. - */ -template -struct Curve_pair_hasher -{ - typedef Subcurve_ Subcurve; - typedef class Curve_pair Curve_pair; - - size_t operator() (const Curve_pair& pair) const - { - const size_t half_n_bits = sizeof(size_t) * 8 / 2; - const size_t val1 = reinterpret_cast (pair.first()); - const size_t val2 = reinterpret_cast (pair.second()); - - return (((val1 << half_n_bits) | (val1 >> half_n_bits)) ^ val2); - } -}; - -/*! \struct - * Equaility functor for curve pairs. - */ -template -struct Equal_curve_pair -{ - typedef Subcurve_ Subcurve; - typedef class Curve_pair Curve_pair; - - bool operator() (const Curve_pair& pair1, const Curve_pair& pair2) const - { - return (pair1.first() == pair2.first() && - pair1.second() == pair2.second()); - } -}; - -/*! \class - * A random-access iterator that can automatically resize its container. - */ -template -class random_access_input_iterator -{ -public: - - typedef Container_ Container; - typedef typename Container::value_type value_type; - typedef random_access_input_iterator Self; - -private: - - // Data members: - Container *m_container; // The container. - unsigned int m_index; // The current index. - -public: - - random_access_input_iterator() - {} - - random_access_input_iterator (Container& _container, - unsigned int _index = 0): - m_container(&_container), - m_index(_index) - {} - - value_type& operator*() - { - if(m_index >= m_container->capacity()) - { - m_container->reserve(2 * m_index + 1); - m_container->resize(m_index+1); - } - else - if(m_index >= m_container->size()) - m_container->resize(m_index+1); - return (*m_container)[m_index]; - } - - Self& operator++() - { - ++m_index; - return (*this); - } - - Self operator++ (int) - { - Self temp = *this; - ++m_index; - return (temp); - } - - Self& operator--() - { - --m_index; - return (*this); - } - - Self operator-- (int) - { - Self temp = *this; - --m_index; - return (temp); - } - - bool operator== (const Self& other) - { - CGAL_precondition (m_container == other.m_container); - return (m_index == other.m_index); - } - - bool operator!=(const Self& other) - { - CGAL_precondition(m_container == other.m_container); - return !(*this == other); - } - - unsigned int operator-(const Self& other) - { - CGAL_precondition(m_container == other.m_container); - return (m_index - other.m_index); - } -}; - -} //namespace CGAL - -#endif diff --git a/Sweep_line_2/include/CGAL/Sweep_line_2/Sweep_line_functors.h b/Sweep_line_2/include/CGAL/Sweep_line_2/Sweep_line_functors.h deleted file mode 100644 index c01205cf416..00000000000 --- a/Sweep_line_2/include/CGAL/Sweep_line_2/Sweep_line_functors.h +++ /dev/null @@ -1,406 +0,0 @@ -// Copyright (c) 2006,2007,2009,2010,2011 Tel-Aviv University (Israel). -// All rights reserved. -// -// This file is part of CGAL (www.cgal.org). -// You can redistribute it and/or modify it under the terms of the GNU -// General Public License as published by the Free Software Foundation, -// either version 3 of the License, or (at your option) any later version. -// -// Licensees holding a valid commercial license may use this file in -// accordance with the commercial license agreement provided with the software. -// -// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -// -// $URL$ -// $Id$ -// SPDX-License-Identifier: GPL-3.0+ -// -// -// Author(s) : Tali Zvi -// Baruch Zukerman -// Ron Wein -// Efi Fogel - -#ifndef CGAL_SWEEP_LINE_FUNCTORS_H -#define CGAL_SWEEP_LINE_FUNCTORS_H - -#include - - -/*! \file - * Comparison functors used by the sweep-line algorithm. - */ - -#include -#include -#include -#include - -namespace CGAL { - -/*! \class - * A functor used to compare events and event points in an xy-lexicographic - * order. Used to maintain the order of the event queue (the X-structure) - * in the sweep-line algorithm. - */ -template -class Compare_events -{ -public: - - typedef Traits_ Traits_2; - typedef Event_ Event; - - typedef typename Traits_2::Point_2 Point_2; - typedef typename Traits_2::X_monotone_curve_2 X_monotone_curve_2; - - // should be ok, as Traits_2 is supposed to be the adaptor - typedef typename Traits_2::Left_side_category Left_side_category; - typedef typename Traits_2::Bottom_side_category Bottom_side_category; - typedef typename Traits_2::Top_side_category Top_side_category; - typedef typename Traits_2::Right_side_category Right_side_category; - -private: - - // Data members: - const Traits_2 * m_traits; // The geometric-traits object. - - Arr_parameter_space m_ps_in_x; // Storing curve information when - Arr_parameter_space m_ps_in_y; // comparing a curve end with - Arr_curve_end m_index; // boundary conditions. - -public: - - /*! Cosntructor. */ - Compare_events (const Traits_2 * traits) : - m_traits (traits) - {} - - /*! - * Compare two existing events. - * This operator is called by the multiset assertions only in - * debug mode (to verify that event was inserted at the right place). - */ - Comparison_result operator()(const Event* e1, const Event* e2) const - { - const bool on_boundary1 = e1->is_on_boundary(); - const bool on_boundary2 = e2->is_on_boundary(); - - if (! on_boundary1 && ! on_boundary2) - { - // Both events do not have boundary conditions - just compare the points. - return (m_traits->compare_xy_2_object()(e1->point(), e2->point())); - } - - if (! on_boundary1) - { - // Compare the point associated with the first event with the second - // boundary event. - return ( this->operator()(e1->point(), e2) ); - } - - if (! on_boundary2) - { - // Compare the point associated with the second event with the first - // boundary event. - return (CGAL::opposite(this->operator()(e2->point(), e1))); - } - - return (_compare_curve_end_with_event (e1->curve(), _curve_end(e1), - e1->parameter_space_in_x(), - e1->parameter_space_in_y(), - e2)); - } - - /*! - * Compare a point, which should be inserted into the event queue, - * with an existing event point. - */ - Comparison_result operator() (const Point_2& pt, const Event* e2) const - { - const bool on_boundary2 = e2->is_on_boundary(); - - if (! on_boundary2) - { - // If e2 is a normal event, just compare pt and the event point. - return (m_traits->compare_xy_2_object() (pt, e2->point())); - } - - // Get the sign of the event's boundary condition in x. Note that a valid - // point is always larger than any negative boundary event and smaller - // than any positive boundary event. - Arr_parameter_space ps_x2 = e2->parameter_space_in_x(); - - if (ps_x2 == ARR_LEFT_BOUNDARY) - return (LARGER); - else if (ps_x2 == ARR_RIGHT_BOUNDARY) - return (SMALLER); - - // Get the curve end that e2 represents, and compare the x-position of the - // given point and this curve end. - Arr_curve_end ind = _curve_end(e2); - Comparison_result res = - m_traits->compare_x_point_curve_end_2_object()(pt, e2->curve(), ind); - - if (res != EQUAL) - return (res); - - // The event and the point has the same x-position. Get the sign of the - // event's boundary condition in y. Note that a valid point is always - // larger than any negative boundary event and smaller than any positive - // boundary event. - Arr_parameter_space ps_y2 = e2->parameter_space_in_y(); - - CGAL_assertion (ps_y2 != ARR_INTERIOR); - return (ps_y2 == ARR_BOTTOM_BOUNDARY) ? LARGER : SMALLER; - } - - /*! - * Compare a curve end, which should be inserted into the event queue, - * with an existing event point. - * Note that the index of the curve end as well as its boundary conditions - * must be set beforehand using set_index() and set_parameter_space_in_x/y(). - */ - Comparison_result operator() (const X_monotone_curve_2& cv, - const Event* e2) const - { - return _compare_curve_end_with_event(cv, m_index, m_ps_in_x, m_ps_in_y, e2); - } - - /// \name Set the boundary conditions of a curve end we are about to compare. - //@{ - void set_parameter_space_in_x (Arr_parameter_space bx) - { - m_ps_in_x = bx; - } - - void set_parameter_space_in_y (Arr_parameter_space by) - { - m_ps_in_y = by; - } - - void set_index (Arr_curve_end ind) - { - m_index = ind; - } - //@} - -private: - - /*! - * Compare a given curve end with an event. - * \param cv The curve. - * \param ind The curve end. - * \param ps_x The boundary condition of the curve end in x. - * \param ps_y The boundary condition of the curve end in y. - * \param e2 The event, which may have boundary conditions. - * \return The comparison result of the curve end with the event. - */ - Comparison_result - _compare_curve_end_with_event (const X_monotone_curve_2& cv, - Arr_curve_end ind, - Arr_parameter_space ps_x, - Arr_parameter_space ps_y, - const Event* e2) const - { - // Check if the curve end has a boundary condition in x. - if (ps_x == ARR_LEFT_BOUNDARY) - { - if (e2->parameter_space_in_x() == ARR_LEFT_BOUNDARY) - { - // Both defined on the left boundary - compare them there. - CGAL_assertion (ind == ARR_MIN_END); - - return - m_traits->compare_y_curve_ends_2_object() (cv, e2->curve(), ind); - } - - // The curve end is obviously smaller. - return (SMALLER); - } - - if (ps_x == ARR_RIGHT_BOUNDARY) - { - if (e2->parameter_space_in_x() == ARR_RIGHT_BOUNDARY) - { - // Both defined on the right boundary - compare them there. - CGAL_assertion (ind == ARR_MAX_END); - - return (m_traits->compare_y_curve_ends_2_object() (cv, e2->curve(), - ind)); - } - - // The curve end is obviously larger. - return (LARGER); - } - - // Check if the event has a boundary condition in x. Note that if it - // has a negative boundary condition, the curve end is larger than it, - // and if it has a positive boundary condition, the curve end is smaller. - if (e2->parameter_space_in_x() == ARR_LEFT_BOUNDARY) - return (LARGER); - - if (e2->parameter_space_in_x() == ARR_RIGHT_BOUNDARY) - return (SMALLER); - - CGAL_assertion (ps_y != ARR_INTERIOR); - Comparison_result res; - - Arr_curve_end ind2 = _curve_end(e2); - - // Act according to the boundary sign of the event. - if (e2->parameter_space_in_y() == ARR_BOTTOM_BOUNDARY) - { - - // Compare the x-positions of the two entities. - res = m_traits->compare_x_curve_ends_2_object() (cv, ind, - e2->curve(), ind2); - if (res != EQUAL) - return (res); - - // In case of equal x-positions, the curve end is larger than the event, - // which lies on the bottom boundary (unless it also lies on the bottom - // boundary). - if (ps_y == ARR_BOTTOM_BOUNDARY) - return (EQUAL); - - return (LARGER); - } - - if (e2->parameter_space_in_y() == ARR_TOP_BOUNDARY) - { - // Compare the x-positions of the two entities. - res = m_traits->compare_x_curve_ends_2_object() (cv, ind, - e2->curve(), ind2); - if (res != EQUAL) - return (res); - - // In case of equal x-positions, the curve end is smaller than the event, - // which lies on the top boundary (unless it also lies on the top - // boundary). - if (ps_y == ARR_TOP_BOUNDARY) - return (EQUAL); - - return (SMALLER); - } - - // If we reached here, e2 is not a boundary event and is associated with - // a valid point. We compare the x-position of this point with the curve - // end. - res = m_traits->compare_x_point_curve_end_2_object() (e2->point(), cv, ind); - - if (res != EQUAL) - return (CGAL::opposite(res)); - - // In case of equal x-positions, is the curve end has a negative boundary - // sign, then it lies on the bottom boundary below the event. Otherwise, - // it lies on the top aboundary above the event e2. - return (ps_y == ARR_BOTTOM_BOUNDARY) ? SMALLER : LARGER; - } - - /*! Detemine if the given event represents a left or a right curve end. */ - inline Arr_curve_end _curve_end (const Event* e) const - { - return (e->has_left_curves()) ? - ((e->is_right_end()) ? ARR_MAX_END : ARR_MIN_END) : - ((e->is_left_end()) ? ARR_MIN_END : ARR_MAX_END); - } -}; - -// Forward decleration: -template -class Sweep_line_event; - -/*! \class - * A functor used to compare curves and curve endpoints by their vertical - * y-order. Used to maintain the order of the status line (the Y-structure) - * in the sweep-line algorithm. - */ -template -class Curve_comparer -{ -public: - - typedef Traits_ Traits_2; - typedef Subcurve_ Subcurve; - typedef Arr_traits_basic_adaptor_2 Traits_adaptor_2; - - typedef typename Traits_adaptor_2::Point_2 Point_2; - typedef typename Traits_adaptor_2::X_monotone_curve_2 X_monotone_curve_2; - typedef Sweep_line_event Event; - -private: - - const Traits_adaptor_2 * m_traits; // A geometric-traits object. - Event **m_curr_event; // Points to the current event point. - -public: - - /*! Constructor. */ - template - Curve_comparer (const Traits_adaptor_2 * t, Sweep_event** e_ptr) : - m_traits(t), - m_curr_event(reinterpret_cast(e_ptr)) - {} - - /*! - * Compare the vertical position of two subcurves in the status line. - * This operator is called only in debug mode. - */ - Comparison_result operator()(const Subcurve *c1, const Subcurve *c2) const - { - // In case to two curves are right curves at the same event, compare - // to the right of the event point. - if (std::find((*m_curr_event)->right_curves_begin(), - (*m_curr_event)->right_curves_end(), - c1) != (*m_curr_event)->right_curves_end() && - std::find((*m_curr_event)->right_curves_begin(), - (*m_curr_event)->right_curves_end(), - c2) != (*m_curr_event)->right_curves_end()) - { - return (m_traits->compare_y_at_x_right_2_object() - (c1->last_curve(), c2->last_curve(), (*m_curr_event)->point())); - } - - Arr_parameter_space ps_x1 = - m_traits->parameter_space_in_x_2_object()(c1->last_curve(), ARR_MIN_END); - Arr_parameter_space ps_y1 = - m_traits->parameter_space_in_y_2_object()(c1->last_curve(), ARR_MIN_END); - - if ((ps_x1 == ARR_INTERIOR) && (ps_y1 == ARR_INTERIOR)) - { - // The first curve has a valid left endpoint. Compare the y-position - // of this endpoint to the second subcurve. - return m_traits->compare_y_at_x_2_object() - (m_traits->construct_min_vertex_2_object()(c1->last_curve()), - c2->last_curve()); - } - - // We use the fact that the two curves are interior disjoint. As c2 is - // already in the status line, then if c1 left end has a negative boundary - // condition it obviously above it. - CGAL_assertion (ps_x1 != ARR_RIGHT_BOUNDARY); - - if (ps_x1 == ARR_LEFT_BOUNDARY) - return (LARGER); - - // For similar reasons, if c1 begins on the bottom boundary it is below - // c2, if it is on the top boundary it is above it. - CGAL_assertion (ps_y1 != ARR_INTERIOR); - return (ps_y1 == ARR_BOTTOM_BOUNDARY) ? SMALLER : LARGER; - } - - /*! - * Compare the relative y-order of the given point and the given subcurve. - */ - Comparison_result operator() (const Point_2& pt, const Subcurve *sc) const - { - return (m_traits->compare_y_at_x_2_object()(pt, sc->last_curve())); - } - -}; - -} //namespace CGAL - -#endif diff --git a/Sweep_line_2/include/CGAL/Sweep_line_2/Sweep_line_subcurve.h b/Sweep_line_2/include/CGAL/Sweep_line_2/Sweep_line_subcurve.h deleted file mode 100644 index 35773693885..00000000000 --- a/Sweep_line_2/include/CGAL/Sweep_line_2/Sweep_line_subcurve.h +++ /dev/null @@ -1,275 +0,0 @@ -// Copyright (c) 2006,2007,2009,2010,2011 Tel-Aviv University (Israel). -// All rights reserved. -// -// This file is part of CGAL (www.cgal.org). -// You can redistribute it and/or modify it under the terms of the GNU -// General Public License as published by the Free Software Foundation, -// either version 3 of the License, or (at your option) any later version. -// -// Licensees holding a valid commercial license may use this file in -// accordance with the commercial license agreement provided with the software. -// -// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -// -// $URL$ -// $Id$ -// SPDX-License-Identifier: GPL-3.0+ -// -// Author(s) : Tali Zvi , -// Baruch Zukerman -// Ron Wein -// Efi Fogel - -#ifndef CGAL_SWEEP_LINE_SUBCURVE_H -#define CGAL_SWEEP_LINE_SUBCURVE_H - -#include - - -/*! \file - * Defintion of the Sweep_line_subcurve class. - */ - -#include -#include -#include -#include - -namespace CGAL { - -/*! \class Sweep_line_subcurve - * - * This is a wrapper class to X_monotone_curve_2 in the traits class, that - * contains data that is used when applying the sweep algorithm on a set of - * x-monotone curves. - * - * The information contained in this class is: - * - the remaining x-monotone curve that is to the right of the current sweep - * line. - * - two event points which are associated with the left and right end of the - * curve. - * - an iterator that points to the location of the subcurve at the status line. - * - two pointers to subcurves that are the originating subcurves in case of - * an overlap, otherwise thay are both NULL. - */ -template -class Sweep_line_subcurve { -public: - typedef Traits_ Traits_2; - typedef typename Traits_2::Point_2 Point_2; - typedef typename Traits_2::X_monotone_curve_2 X_monotone_curve_2; - - typedef Sweep_line_subcurve Self; - typedef Curve_comparer Compare_curves; - typedef Multiset - Status_line; - typedef typename Status_line::iterator Status_line_iterator; - - typedef Sweep_line_event Event; - -protected: - // Data members: - X_monotone_curve_2 m_lastCurve; // The portion of the curve that lies to - // the right of the last event point - // that occured on the curve. - - Event* m_left_event; // The event associated with the left end. - Event* m_right_event; // The event associated with the right end - - Status_line_iterator m_hint; // The location of the subcurve in the - // status line (the Y-structure). - - Self* m_orig_subcurve1; // The overlapping hierarchy - Self* m_orig_subcurve2; // (relevant only in case of overlaps). - -public: - - /*! Construct default. - */ - Sweep_line_subcurve() : - m_orig_subcurve1(NULL), - m_orig_subcurve2(NULL) - {} - - /*! Construct from a curve. - */ - Sweep_line_subcurve(const X_monotone_curve_2& curve) : - m_lastCurve(curve), - m_orig_subcurve1(NULL), - m_orig_subcurve2(NULL) - {} - - /*! Initialize the subcurves by setting the curve. */ - void init(const X_monotone_curve_2& curve) { m_lastCurve = curve; } - - /*! Destructor. */ - ~Sweep_line_subcurve() {} - - /*! Get the last intersecing curve so far (const version). */ - const X_monotone_curve_2& last_curve() const { return m_lastCurve; } - - /*! Get the last intersecing curve so far (non-const version). */ - X_monotone_curve_2& last_curve() { return m_lastCurve; } - - /*! Set the last intersecing curve so far. */ - void set_last_curve(const X_monotone_curve_2& cv) { m_lastCurve = cv; } - - /*! Check if the given event is the matches the right-end event. */ - template - bool is_end_point(const SweepEvent* event) const - { return (m_right_event == (Event*)event); } - - /*! Get the event that corresponds to the left end of the subcurve. */ - Event* left_event() const { return m_left_event; } - - /*! Get the event that corresponds to the right end of the subcurve. */ - Event* right_event() const { return m_right_event; } - - /*! Set the event that corresponds to the left end of the subcurve. */ - template - void set_left_event(SweepEvent* event) { m_left_event =(Event*)event; } - - /*! Set the event that corresponds to the right end of the subcurve. */ - template - void set_right_event(SweepEvent* event) { m_right_event = (Event*)event; } - - /*! Get the location of the subcurve in the status line .*/ - Status_line_iterator hint() const { return m_hint; } - - /*! Set the location of the subcurve in the status line .*/ - void set_hint(Status_line_iterator hint) { m_hint = hint; } - - /*! Get the subcurves that originate an overlap. */ - Self* originating_subcurve1() { return m_orig_subcurve1; } - - Self* originating_subcurve2() { return m_orig_subcurve2; } - - /*! Set the subcurves that originate an overlap. */ - void set_originating_subcurve1(Self* orig_subcurve1) - { m_orig_subcurve1 = orig_subcurve1; } - - void set_originating_subcurve2(Self* orig_subcurve2) - { m_orig_subcurve2 = orig_subcurve2; } - - /*! Get all the leaf-nodes in the hierarchy of overlapping subcurves. */ - template - OutputIterator all_leaves(OutputIterator oi) - { - if (m_orig_subcurve1 == NULL) { - *oi++ = this; - return oi; - } - - oi = m_orig_subcurve1->all_leaves(oi); - oi = m_orig_subcurve2->all_leaves(oi); - return oi; - } - - /*! Check if the given subcurve is a node in the overlapping hierarchy. */ - bool is_inner_node(Self *s) - { - if (this == s) return true; - if (m_orig_subcurve1 == NULL) return false; - return (m_orig_subcurve1->is_inner_node(s) || - m_orig_subcurve2->is_inner_node(s)); - } - - /*! Check if the given subcurve is a leaf in the overlapping hierarchy. */ - bool is_leaf(Self* s) - { - if (m_orig_subcurve1 == NULL) return (this == s); - return (m_orig_subcurve1->is_leaf(s) || m_orig_subcurve2->is_leaf(s)); - } - - /*! Check if the two hierarchies contain the same leaf nodes. */ - bool has_same_leaves(Self* s) - { - std::list my_leaves; - std::list other_leaves; - - this->all_leaves(std::back_inserter(my_leaves)); - s->all_leaves(std::back_inserter(other_leaves)); - - typename std::list::iterator iter; - for (iter = my_leaves.begin(); iter != my_leaves.end(); ++iter) { - if (std::find(other_leaves.begin(), other_leaves.end(), *iter) == - other_leaves.end()) - return false; - } - - for (iter = other_leaves.begin(); iter != other_leaves.end(); ++iter) { - if (std::find(my_leaves.begin(), my_leaves.end(), *iter) == - my_leaves.end()) - return false; - } - - return true; - } - - /*! Check if the two hierarchies contain a common leaf node. */ - bool has_common_leaf(Self *s) - { - std::list my_leaves; - std::list other_leaves; - - this->all_leaves(std::back_inserter(my_leaves)); - s->all_leaves(std::back_inserter(other_leaves)); - - typename std::list::iterator iter; - for (iter = my_leaves.begin(); iter != my_leaves.end(); ++iter) { - if (std::find(other_leaves.begin(), other_leaves.end(), *iter) != - other_leaves.end()) - return true; - } - return false; - } - - /*! Get all distinct nodes from the two hierarchies. */ - template - OutputIterator distinct_nodes(Self* s, OutputIterator oi) - { - if (m_orig_subcurve1 == NULL) { - if (s->is_leaf(this)) *oi++ = this; - return oi; - } - - if (! s->is_inner_node (m_orig_subcurve1)) *oi++ = m_orig_subcurve1; - else oi++ = m_orig_subcurve1->distinct_nodes(s, oi); - - if (! s->is_inner_node (m_orig_subcurve2)) *oi++ = m_orig_subcurve2; - else oi++ = m_orig_subcurve2->distinct_nodes(s, oi); - - return oi; - } - - /*! Get the depth of the overlap hierarchy. */ - unsigned int overlap_depth() - { - if (m_orig_subcurve1 == NULL) return (1); - - unsigned int depth1 = m_orig_subcurve1->overlap_depth(); - unsigned int depth2 = m_orig_subcurve2->overlap_depth(); - if (depth1 > depth2) return (depth1 + 1); - else return (depth2 + 1); - } - -#ifdef CGAL_SL_VERBOSE - void Print() const; -#endif -}; - -#ifdef CGAL_SL_VERBOSE - template - void Sweep_line_subcurve::Print() const - { - std::cout << "Curve " << this - << " (" << m_lastCurve << ") " - << " [sc1: " << m_orig_subcurve1 - << ", sc2: " << m_orig_subcurve2 << "]"; - } -#endif - -} //namespace CGAL - -#endif diff --git a/Sweep_line_2/include/CGAL/Sweep_line_empty_visitor.h b/Sweep_line_2/include/CGAL/Sweep_line_empty_visitor.h deleted file mode 100644 index 8792e3184f9..00000000000 --- a/Sweep_line_2/include/CGAL/Sweep_line_empty_visitor.h +++ /dev/null @@ -1,286 +0,0 @@ -// Copyright (c) 2006,2007,2009,2010,2011 Tel-Aviv University (Israel). -// All rights reserved. -// -// This file is part of CGAL (www.cgal.org). -// You can redistribute it and/or modify it under the terms of the GNU -// General Public License as published by the Free Software Foundation, -// either version 3 of the License, or (at your option) any later version. -// -// Licensees holding a valid commercial license may use this file in -// accordance with the commercial license agreement provided with the software. -// -// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -// -// $URL$ -// $Id$ -// SPDX-License-Identifier: GPL-3.0+ -// -// -// Author(s) : Baruch Zukerman - -#ifndef CGAL_SWEEP_LINE_EMPTY_VISITOR_H -#define CGAL_SWEEP_LINE_EMPTY_VISITOR_H - -#include - - -/*! \file - * Definition of the Sweep_line_empty_visitor class-template. - */ - -#include -#include -#include - -namespace CGAL { - -/*! \class - * An empty sweep-line visitor that does nothing. It is used as a base-class - * for other concrete visitors that produce some output. - */ -template , - typename Event_ = Sweep_line_event, - class Allocator_ = CGAL_ALLOCATOR(int)> -class Sweep_line_empty_visitor -{ -public: - - typedef Traits_ Traits_2; - typedef Subcurve_ Subcurve; - typedef Event_ Event; - typedef Allocator_ Allocator; - - typedef typename Traits_2::X_monotone_curve_2 X_monotone_curve_2; - typedef typename Traits_2::Point_2 Point_2; - - typedef Sweep_line_empty_visitor Self; - -private: - - // we want to hide the Sweep_line type - typedef Basic_sweep_line_2 Sweep_line; - - typedef typename Sweep_line::Status_line_iterator Base_status_line_iter; - -public: - - /*! \class - * A wrapper for the base status-line iterator. - */ - class Status_line_iterator : public Base_status_line_iter - { - public: - - typedef Subcurve* value_type; - typedef value_type& reference; - typedef value_type* pointer; - typedef typename Base_status_line_iter::difference_type difference_type; - typedef typename Base_status_line_iter::iterator_category - iterator_category; - /*! Constructor. */ - Status_line_iterator() - {} - - /*! Constructor from a base iterator. */ - Status_line_iterator (Base_status_line_iter iter) : - Base_status_line_iter (iter) - {} - - // Overriden operator* - reference operator* () - { - return (reinterpret_cast - (((Base_status_line_iter*)this)->operator*())); - } - - // Overriden operator-> - pointer operator-> () - { - return (reinterpret_cast - (Base_status_line_iter::operator->())); - } - }; - - - typedef typename Event::Subcurve_iterator Event_subcurve_iterator; - typedef typename Event::Subcurve_reverse_iterator - Event_subcurve_reverse_iterator; - -protected: - - // Data members: - void* m_sweep_line; // The sweep-line object. - -public: - - /*! Constructor. */ - Sweep_line_empty_visitor () : - m_sweep_line (NULL) - {} - - /*! Attach the a sweep-line object. */ - void attach (void* sl) - { - m_sweep_line = sl; - } - - /*! Destructor */ - virtual ~Sweep_line_empty_visitor() - {} - - /*! - * A notification invoked before the sweep-line starts handling the given - * event. - */ - void before_handle_event (Event* /* event */) - {} - - /*! - * A notification invoked after the sweep-line finishes handling the given - * event. - */ - bool after_handle_event (Event* /* event */, - Status_line_iterator /* iter */, - bool /* flag */) - { - return (true); - } - - /*! A notification invoked when a new subcurve is created. */ - void add_subcurve (X_monotone_curve_2 /* cv */, - Subcurve* /* sc */) - {} - - /*! A notification issued before the sweep process starts. */ - void before_sweep() - {} - - /*! A notification issued after the sweep process ends. */ - void after_sweep() - {} - - /*! Update the event to be the given curve end. */ - void update_event (Event* /* e */, - const Point_2& /* end_point */, - const X_monotone_curve_2& /* cv */, - Arr_curve_end /* cv_end */, - bool /* is_new */) - {} - - /*! Update the event to be the given infinite curve end. */ - void update_event (Event* /* e */, - const X_monotone_curve_2& /* cv */, - Arr_curve_end /* cv_end */, - bool /* is_new */) - {} - - /*! Update the event to be the intersection point of two subcurves. */ - void update_event (Event* /* e */, - Subcurve* /* sc1 */, - Subcurve* /* sc2 */, - bool /* is_new */) - {} - - /*! Update the event. */ - void update_event (Event* /* e */, - Subcurve* /* sc1 */) - {} - - /*! Update the event. */ - void update_event (Event* /* e */, - const Point_2& /* pt */, - bool /* is_new */) - {} - - /* Found overlap */ - void found_overlap (Subcurve* /* sc1 */, - Subcurve* /* sc2 */, - Subcurve* /* ov_sc */) - {} - - /*! Get the first subcurve in the status line. */ - Status_line_iterator status_line_begin() - { - return (this->_sweep_line()->status_line_begin()); - } - - /*! Get a past-the-end iterator for the subcurves in the status line. */ - Status_line_iterator status_line_end() - { - return (this->_sweep_line()->status_line_end()); - } - - /*! Get the position of the given subcurve in the status line. */ - Status_line_iterator status_line_position (Subcurve *sc) - { - return (sc->hint()); - } - - /*! Get the number of subcurves in the status line. */ - unsigned status_line_size() const - { - return (this->_sweep_line()->status_line_size()); - } - - /*! Check if the status line is empty. */ - bool is_status_line_empty() const - { - return (this->_sweep_line()->is_status_line_empty()); - } - - /*! Deallocate the given event. */ - void deallocate_event (Event* e) - { - this->_sweep_line()->deallocate_event(e); - } - - /*! Stop the sweep-line process. */ - void stop_sweep() - { - this->_sweep_line()->stop_sweep(); - } - - /*! Get the sweep-line object. */ - void* sweep_line () - { - return (m_sweep_line); - } - - /*! Get the current event. */ - Event* current_event() - { - return (this->_sweep_line()->current_event()); - } - - /*! Get the geometry-traits class. */ - const Traits_2 * traits () - { - return (this->_sweep_line()->traits()); - } - -private: - - /*! Get the sweep-line object. */ - Sweep_line* _sweep_line () - { - return (reinterpret_cast(m_sweep_line)); - } - - const Sweep_line* _sweep_line () const - { - return (reinterpret_cast(m_sweep_line)); - } -}; - -} //namespace CGAL - -#endif diff --git a/Sweep_line_2/package_info/Sweep_line_2/long_description.txt b/Sweep_line_2/package_info/Sweep_line_2/long_description.txt deleted file mode 100644 index e906f7b29d5..00000000000 --- a/Sweep_line_2/package_info/Sweep_line_2/long_description.txt +++ /dev/null @@ -1,42 +0,0 @@ -Given a set C of planar curves, the arrangement A(C) is the -subdivision of the plane into zero-dimensional, one-dimensional and -two-dimensional cells, called vertices, edges and faces, respectively, -induced by the curves in C. Arrangements are ubiquitous in the -computational-geometry literature and have many applications -in fields like motion planning, computer-aided design, geographical -information systems, etc. - -The curves in C can intersect each other (a single curve may also -be self-intersecting or may be comprised of several disconnected -branches) and are not necessarily x-monotone. We construct a -collection C'' of x-monotone subcurves that are pairwise disjoint in -their interiors. We do it in two steps as follows. First, we decompose -each curve in C into maximal x-monotone subcurves (and possibly -isolated points), obtaining the collection C'. Note that an x-monotone -curve cannot be self-intersecting. Then, we decompose each curve in -C' into maximal connected subcurves not intersecting any other curve -(or point) in C'. The collection C'' may also contain isolated points, -if the curves of C contain such points. The arrangement induced by the -collection C'' can be conveniently embedded as a planar graph, whose -vertices are associated with curve endpoints or with isolated points, -and whose edges are associated with subcurves. It is easy to see that -A(C) = A(C''). This graph can be represented using a doubly-connected -edge list data-structure (DCEL for short), which consists of -containers of vertices, edges, and faces and maintains the incidence -relations among these objects. - -This package can be used to construct, maintain, alter, and display -arrangements in the plane. Once an arrangement is constructed, the -package can be used to obtain results of various queries on the -arrangement, such as point location. The package also includes generic -implementations of two algorithmic frameworks, that are, computing the -zone of an arrangement, and line-sweeping the plane, the arrangements -is embedded on. These frameworks are used in turn in the -implementations of other operations on arrangements. Computing the -overlay of two arrangements, for example, is based on the sweep-line -framework. - -Arrangements and arrangement components can also be extended to store -additional data. An important extension stores the construction -history of the arrangement, such that it is possible to obtain the -originating curve of an arrangement subcurve.