Merge branch 'Aos_2-surface_sweep-efif-old' into Aos_2-surface_sweep-efif

Conflicts:
	.travis.yml
	.travis/packages.txt
	Arrangement_on_surface_2/include/CGAL/Arr_batched_point_location.h
	Arrangement_on_surface_2/include/CGAL/Arr_bounded_planar_topology_traits_2.h
	Arrangement_on_surface_2/include/CGAL/Arr_default_overlay_traits.h
	Arrangement_on_surface_2/include/CGAL/Arr_overlay_2.h
	Arrangement_on_surface_2/include/CGAL/Arr_spherical_topology_traits_2.h
	Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_bounded_planar_batched_pl_helper.h
	Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_bounded_planar_construction_helper.h
	Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_bounded_planar_insertion_helper.h
	Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_bounded_planar_overlay_helper.h
	Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_bounded_planar_topology_traits_2_impl.h
	Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_bounded_planar_vert_decomp_helper.h
	Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_planar_topology_traits_base_2.h
	Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_spherical_batched_pl_helper.h
	Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_spherical_construction_helper.h
	Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_spherical_insertion_helper.h
	Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_spherical_overlay_helper.h
	Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_spherical_vert_decomp_helper.h
	Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_unb_planar_batched_pl_helper.h
	Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_unb_planar_construction_helper.h
	Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_unb_planar_insertion_helper.h
	Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_unb_planar_overlay_helper.h
	Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_unb_planar_topology_traits_2_impl.h
	Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_unb_planar_vert_decomp_helper.h
	Arrangement_on_surface_2/include/CGAL/Arr_unb_planar_topology_traits_2.h
	Arrangement_on_surface_2/include/CGAL/Arr_vertical_decomposition_2.h
	Arrangement_on_surface_2/include/CGAL/Arrangement_2/Arr_default_planar_topology.h
	Arrangement_on_surface_2/include/CGAL/Arrangement_2/Arrangement_on_surface_2_global.h
	Arrangement_on_surface_2/include/CGAL/Arrangement_2/Arrangement_on_surface_2_impl.h
	Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_basic_insertion_traits_2.h
	Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_batched_pl_ss_visitor.h
	Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_construction_ss_visitor.h
	Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_default_overlay_traits_base.h
	Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_insertion_traits_2.h
	Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_no_intersection_insertion_ss_visitor.h
	Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_overlay_ss_visitor.h
	Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_overlay_subcurve.h
	Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_overlay_traits_2.h
	Arrangement_on_surface_2/include/CGAL/Surface_sweep_2/Arr_vert_decomp_ss_visitor.h
	Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Gps_agg_meta_traits.h
	Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Gps_agg_op.h
	Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Gps_agg_op_sweep.h
	Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Gps_agg_op_visitor.h
	Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Gps_polygon_simplifier.h
	Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Gps_polygon_validation.h
	CGAL_ipelets/demo/CGAL_ipelets/arrangement.cpp
	Documentation/doc/Documentation/dependencies
	Installation/include/CGAL/config.h
	Snap_rounding_2/include/CGAL/Snap_rounding_2.h
	Surface_sweep_2/examples/Surface_sweep_2/CMakeLists.txt
	Surface_sweep_2/include/CGAL/Surface_sweep_2/No_intersection_surface_sweep_2_impl.h
	Surface_sweep_2/include/CGAL/Surface_sweep_2/No_overlap_event_base.h
	Surface_sweep_2/include/CGAL/Surface_sweep_2/Surface_sweep_2_utils.h
	Surface_sweep_2/include/CGAL/Surface_sweep_2_algorithms.h
	Sweep_line_2/include/CGAL/Sweep_line_2/Arr_construction_event.h
	Sweep_line_2/include/CGAL/Sweep_line_2/Arr_construction_subcurve.h
	Sweep_line_2/include/CGAL/Sweep_line_2/Arr_insertion_sl_visitor.h
	Sweep_line_2/include/CGAL/Sweep_line_2/Sweep_line_2_visitors.h
	Sweep_line_2/include/CGAL/Sweep_line_2/Sweep_line_curve_pair.h
	Sweep_line_2/include/CGAL/Sweep_line_2/Sweep_line_functors.h
	Sweep_line_2/include/CGAL/Sweep_line_2/Sweep_line_subcurve.h
	Sweep_line_2/include/CGAL/Sweep_line_empty_visitor.h
This commit is contained in:
Efi Fogel 2017-11-16 16:31:52 +02:00
commit 7936109c6c
252 changed files with 8299 additions and 7923 deletions

View File

@ -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

View File

@ -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

View File

@ -17,21 +17,21 @@ typedef CGAL::Arrangement_2<Traits_2> Arrangement_2;
int main ()
{
// Construct the arrangement of five intersecting segments.
Arrangement_2 arr;
std::list<Segment_2> segments;
Arrangement_2 arr;
std::list<Segment_2> 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;

View File

@ -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<X_monotone_curve_2> 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;
}

View File

@ -1,8 +1,7 @@
//! \file examples/Arrangement_on_surface_2/batched_point_location.cpp
// Answering a batched point-location query.
#include <CGAL/Cartesian.h>
#include <CGAL/MP_Float.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Arr_segment_traits_2.h>
#include <CGAL/Arrangement_2.h>
#include <CGAL/Arr_batched_point_location.h>
@ -10,46 +9,48 @@
#include "point_location_utils.h"
typedef CGAL::MP_Float Number_type;
typedef CGAL::Cartesian<Number_type> Kernel;
typedef CGAL::Arr_segment_traits_2<Kernel> Traits_2;
typedef Traits_2::Point_2 Point_2;
typedef CGAL::Arrangement_2<Traits_2> Arrangement_2;
typedef CGAL::Arr_point_location_result<Arrangement_2> Point_location_result;
typedef std::pair<Point_2, Point_location_result::Type> Query_result;
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef CGAL::Arr_segment_traits_2<Kernel> Traits;
typedef Traits::Point_2 Point;
typedef CGAL::Arrangement_2<Traits> Arrangement;
typedef CGAL::Arr_point_location_result<Arrangement> Point_location_result;
typedef std::pair<Point, Point_location_result::Type> 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<Point_2> 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<Query_result> results;
std::list<Point> 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<Query_result> results;
locate(arr, points.begin(), points.end(), std::back_inserter(results));
// Print the results.
std::list<Query_result>::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<Face_const_handle>(&(it->second))) // inside a face
if (const Face_const_handle* f =
boost::get<Face_const_handle>(&(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<Halfedge_const_handle>(&(it->second))) // on an edge
else if (const Halfedge_const_handle* e =
boost::get<Halfedge_const_handle>(&(it->second))) // on an edge
std::cout << "on an edge: " << (*e)->curve() << std::endl;
else if (const Vertex_const_handle* v = boost::get<Vertex_const_handle>(&(it->second))) // on a vertex
else if (const Vertex_const_handle* v =
boost::get<Vertex_const_handle>(&(it->second))) // on a vertex
std::cout << "on "
<< (((*v)->is_isolated()) ? "an isolated" : "a")
<< " vertex: " << (*v)->point() << std::endl;

View File

@ -1,15 +1,13 @@
//! \file examples/Arrangement_on_surface_2/vertical_decomposition.cpp
// Performing vertical decomposition of an arrangement.
#include <CGAL/Cartesian.h>
#include <CGAL/MP_Float.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Arr_segment_traits_2.h>
#include <CGAL/Arrangement_2.h>
#include <CGAL/Arr_vertical_decomposition_2.h>
#include <list>
typedef CGAL::MP_Float Number_type;
typedef CGAL::Cartesian<Number_type> Kernel;
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef CGAL::Arr_segment_traits_2<Kernel> 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_entry> 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)));

View File

@ -25,9 +25,12 @@
#include <CGAL/license/Arrangement_on_surface_2.h>
#include <CGAL/Arrangement_on_surface_2.h>
#include <CGAL/Basic_sweep_line_2.h>
#include <CGAL/No_intersection_surface_sweep_2.h>
#include <CGAL/Arr_point_location/Arr_batched_point_location_traits_2.h>
#include <CGAL/Surface_sweep_2/No_overlap_event.h>
#include <CGAL/Surface_sweep_2/No_overlap_subcurve.h>
#include <CGAL/Surface_sweep_2/Arr_batched_pl_ss_visitor.h>
#include <vector>
#include <boost/mpl/if.hpp>
@ -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<Point_2, Result>,
* and the value-type of OutputIterator is is pair<Point_2, Result>,
* where Result is either
* (i) Object or
* (ii) boost::optional<boost::variant<Vertex_const_handle,
@ -51,35 +55,45 @@ namespace CGAL {
* Face_const_handle> >.
* It represents the arrangement feature containing the point.
*/
template<typename GeomTraits, typename TopTraits,
typename PointsIterator, typename OutputIterator>
template <typename GeometryTraits_2, typename TopologyTraits,
typename PointsIterator, typename OutputIterator>
OutputIterator
locate(const Arrangement_on_surface_2<GeomTraits, TopTraits>& arr,
locate(const Arrangement_on_surface_2<GeometryTraits_2, TopologyTraits>& 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<GeomTraits, TopTraits> Arr;
typedef typename TopTraits::template
Sweep_line_batched_point_location_visitor<OutputIterator>
Bpl_visitor;
typedef Arrangement_on_surface_2<Gt2, Tt> 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<Arr> Bgt2;
typedef Ss2::No_overlap_event<Bgt2, Allocator> Bpl_event;
typedef Ss2::No_overlap_subcurve<Bgt2, Bpl_event, Allocator>
Bpl_curve;
typedef typename Tt::template Batched_point_location_helper<Bpl_event,
Bpl_curve>
Bpl_helper;
typedef Arr_batched_pl_ss_visitor<Bpl_helper, Output_iterator>
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<Bpl_x_monotone_curve_2> xcurves_vec(arr.number_of_edges());
Edge_const_iterator eit;
unsigned int i = 0;
std::vector<Bpl_x_monotone_curve_2> 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<GeomTraits, TopTraits>& arr,
// Go over all isolated vertices and collect their points. To each point
// we attach its vertex handle.
std::vector<Bpl_point_2> iso_pts_vec(arr.number_of_isolated_vertices());
Vertex_const_iterator vit;
std::vector<Bpl_point_2> 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<GeomTraits, TopTraits>& arr,
iso_pts_vec[i++] = Bpl_point_2(vit->point(), iso_v);
}
}
// Obtain a extended traits-class object.
GeomTraits* geom_traits = const_cast<GeomTraits*>(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_<boost::is_same<GeomTraits, Bpl_traits_2>,
const Bpl_traits_2&, Bpl_traits_2>::type
typename boost::mpl::if_<boost::is_same<Gt2, Bgt2>, 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<typename Bpl_visitor::Traits_2, Bpl_visitor,
typename Bpl_visitor::Subcurve,
typename Bpl_visitor::Event>
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<Bpl_visitor>
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

View File

@ -26,8 +26,8 @@
#include <CGAL/license/Arrangement_on_surface_2.h>
/*! \file
*
* Definition of the Arr_bounded_planar_topology_traits_2<GeomTraits> class.
*/
@ -40,56 +40,61 @@
#include <CGAL/Arr_topology_traits/Arr_bounded_planar_vert_decomp_helper.h>
#include <CGAL/Arr_topology_traits/Arr_inc_insertion_zone_visitor.h>
#include <CGAL/use.h>
namespace CGAL {
// Forward declaration:
template <typename GeomTraits_, typename TopTraits_>
template <typename GeometryTraits_2, typename TopTraits_>
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 <typename GeomTraits_,
typename Dcel_ = Arr_default_dcel<GeomTraits_> >
template <typename GeometryTraits_2,
typename Dcel_ = Arr_default_dcel<GeometryTraits_2> >
class Arr_bounded_planar_topology_traits_2 :
public Arr_planar_topology_traits_base_2<GeomTraits_, Dcel_>
public Arr_planar_topology_traits_base_2<GeometryTraits_2, Dcel_>
{
public:
typedef GeometryTraits_2 Geometry_traits_2;
typedef Dcel_ Dcel;
private:
typedef Arr_planar_topology_traits_base_2<GeomTraits_, Dcel_> Base;
typedef Geometry_traits_2 Gt2;
typedef Arr_planar_topology_traits_base_2<Gt2, Dcel_> 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<Geometry_traits_2, Dcel> Self;
typedef Arr_traits_basic_adaptor_2<Geometry_traits_2> Traits_adaptor_2;
typedef Arr_bounded_planar_topology_traits_2<Gt2, Dcel> Self;
typedef Arr_traits_basic_adaptor_2<Gt2> 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<typename T, typename D>
template <typename T, typename D>
struct rebind {
typedef Arr_bounded_planar_topology_traits_2<T, D> 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<Geometry_traits_2, Self> Arr;
typedef Arrangement_on_surface_2<Gt2, Self> Arr;
// Type definition for the constuction sweep-line visitor.
typedef Arr_construction_subcurve<Geometry_traits_2> CSubcurve;
typedef Arr_construction_event<Geometry_traits_2, CSubcurve, Arr>
CEvent;
typedef Arr_bounded_planar_construction_helper<Geometry_traits_2,
Arr,
CEvent,
CSubcurve> 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 <typename Evt, typename Crv>
struct Construction_helper :
public Arr_bounded_planar_construction_helper<Gt2, Arr, Evt, Crv>
{
typedef Arr_bounded_planar_construction_helper<Gt2, Arr, Evt, Crv>
Base;
Construction_helper(Arr* arr) : Base(arr) {}
};
// Type definition for the basic insertion sweep-line visitor.
typedef Arr_basic_insertion_traits_2<Geometry_traits_2, Arr> BInsTraits;
typedef Arr_construction_subcurve<BInsTraits> BISubcurve;
typedef Arr_construction_event<BInsTraits, BISubcurve, Arr>
BIEvent;
typedef Arr_bounded_planar_insertion_helper<BInsTraits, Arr, BIEvent,
BISubcurve> BIHelper;
// Type definition for the no-intersection construction surface-sweep visitor.
template <typename Evt, typename Crv>
struct No_intersection_construction_helper :
public Arr_bounded_planar_construction_helper<Gt2, Arr, Evt, Crv>
{
typedef Arr_bounded_planar_construction_helper<Gt2, Arr, Evt, Crv>
Base;
No_intersection_construction_helper(Arr* arr) : Base(arr) {}
};
// Type definition for the insertion sweep-line visitor.
typedef Arr_insertion_traits_2<Geometry_traits_2, Arr> InsTraits;
typedef Arr_construction_subcurve<InsTraits> ISubcurve;
typedef Arr_construction_event<InsTraits, ISubcurve, Arr>
IEvent;
typedef Arr_bounded_planar_insertion_helper<InsTraits, Arr, IEvent,
ISubcurve> IHelper;
// Type definition for the insertion surface-sweep visitor.
typedef Arr_insertion_traits_2<Gt2, Arr> I_traits;
template <typename Evt, typename Crv>
struct Insertion_helper :
public Arr_bounded_planar_insertion_helper<I_traits, Arr, Evt, Crv>
{
typedef Arr_bounded_planar_insertion_helper<I_traits, Arr, Evt, Crv>
Base;
Insertion_helper(Arr* arr) : Base(arr) {}
};
// Type definition for the batched point-location sweep-line visitor.
typedef Arr_batched_point_location_traits_2<Arr> BplTraits;
typedef Arr_bounded_planar_batched_pl_helper<BplTraits, Arr> BplHelper;
// Type definition for the no-intersection insertion surface-sweep visitor.
typedef Arr_basic_insertion_traits_2<Gt2, Arr> Nxi_traits;
template <typename Evt, typename Crv>
struct No_intersection_insertion_helper :
public Arr_bounded_planar_insertion_helper<Nxi_traits, Arr, Evt, Crv>
{
typedef Arr_bounded_planar_insertion_helper<Nxi_traits, Arr, Evt, Crv>
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<Arr> Bpl_traits;
template <typename Evt, typename Crv>
struct Batched_point_location_helper :
public Arr_bounded_planar_batched_pl_helper<Bpl_traits, Arr, Evt, Crv>
{
typedef Arr_bounded_planar_batched_pl_helper<Bpl_traits, Arr, Evt, Crv>
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<Arr> VdTraits;
typedef Arr_bounded_planar_vert_decomp_helper<VdTraits, Arr> VdHelper;
// Type definition for the overlay sweep-line visitor.
template <class ExGeomTraits_, class ArrangementA_, class ArrangementB_>
struct _Overlay_helper : public Arr_bounded_planar_overlay_helper
<ExGeomTraits_, ArrangementA_, ArrangementB_, Arr,
Arr_construction_event<ExGeomTraits_,
Arr_overlay_subcurve<ExGeomTraits_>,
Arr>,
Arr_overlay_subcurve<ExGeomTraits_> >
typedef Arr_batched_point_location_traits_2<Arr> Vd_traits;
template <typename Evt, typename Crv>
struct Vertical_decomposition_helper :
public Arr_bounded_planar_vert_decomp_helper<Vd_traits, Arr, Evt, Crv>
{
typedef Arr_bounded_planar_overlay_helper
<ExGeomTraits_, ArrangementA_, ArrangementB_, Arr,
Arr_construction_event<ExGeomTraits_,
Arr_overlay_subcurve<ExGeomTraits_>,
Arr>,
Arr_overlay_subcurve<ExGeomTraits_> > 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<Vd_traits, Arr, Evt, Crv>
Base;
Vertical_decomposition_helper(const Arr* arr) : Base(arr) {}
};
// Type definition for the overlay surface-sweep visitor.
template <typename Gt, typename Evt, typename Crv,
typename ArrA, typename ArrB>
struct Overlay_helper :
public Arr_bounded_planar_overlay_helper<Gt, ArrA, ArrB, Arr, Evt, Crv>
{
typedef Arr_bounded_planar_overlay_helper<Gt, ArrA, ArrB, Arr, Evt, Crv>
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 <typename Evt, typename Crv>
using Construction_helper =
Arr_bounded_planar_construction_helper<Gt2, Arr, Evt, Crv>;
// Type definition for the no-intersection construction surface-sweep visitor.
template <typename Evt, typename Crv>
using No_intersection_construction_helper =
Arr_bounded_planar_construction_helper<Gt2, Arr, Evt, Crv>;
// Type definition for the insertion surface-sweep visitor.
typedef Arr_insertion_traits_2<Gt2, Arr> I_traits;
template <typename Evt, typename Crv>
using Insertion_helper =
Arr_bounded_planar_insertion_helper<I_traits, Arr, Evt, Crv>;
// Type definition for the no-intersection insertion surface-sweep visitor.
typedef Arr_basic_insertion_traits_2<Gt2, Arr> Nxi_traits;
template <typename Evt, typename Crv>
using No_intersection_insertion_helper =
Arr_bounded_planar_insertion_helper<Nxi_traits, Arr, Evt, Crv>;
// Type definition for the batched point-location surface-sweep visitor.
typedef Arr_batched_point_location_traits_2<Arr> Bpl_traits;
template <typename Evt, typename Crv>
using Batched_point_location_helper =
Arr_bounded_planar_batched_pl_helper<Bpl_traits, Arr, Evt, Crv>;
// Type definition for the vertical decomposition sweep-line visitor.
typedef Arr_batched_point_location_traits_2<Arr> Vd_traits;
template <typename Evt, typename Crv>
using Vertical_decomposition_helper =
Arr_bounded_planar_vert_decomp_helper<Vd_traits, Arr, Evt, Crv>;
// Type definition for the overlay surface-sweep visitor.
template <typename Gt, typename Evt, typename Crv,
typename ArrA, typename ArrB>
using Overlay_helper =
Arr_bounded_planar_overlay_helper<Gt, ArrA, ArrB, Arr, Evt, Crv>;
#endif
//@}
public:
///! \name Visitor types.
//@{
typedef Arr_construction_sl_visitor<CHelper>
Sweep_line_construction_visitor;
typedef Arr_insertion_sl_visitor<IHelper>
Sweep_line_insertion_visitor;
typedef Sweep_line_construction_visitor
Sweep_line_non_intersecting_construction_visitor;
typedef Arr_basic_insertion_sl_visitor<BIHelper>
Sweep_line_non_intersecting_insertion_visitor;
template <class OutputIterator_>
struct Sweep_line_batched_point_location_visitor :
public Arr_batched_pl_sl_visitor<BplHelper, OutputIterator_>
{
typedef OutputIterator_ Output_iterator;
typedef Arr_batched_pl_sl_visitor<BplHelper, Output_iterator> 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 <class OutputIterator_>
struct Sweep_line_vertical_decomposition_visitor :
public Arr_vert_decomp_sl_visitor<VdHelper, OutputIterator_>
{
typedef OutputIterator_ Output_iterator;
typedef Arr_vert_decomp_sl_visitor<VdHelper, Output_iterator> 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 <class ArrangementA_, class ArrangementB_, class OverlayTraits_>
struct Sweep_line_overlay_visitor :
public Arr_overlay_sl_visitor <
_Overlay_helper<
Arr_overlay_traits_2< Arr_traits_basic_adaptor_2<Geometry_traits_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<Geometry_traits_2>,
ArrangementA_2,
ArrangementB_2> Geom_ovl_traits_2;
typedef _Overlay_helper<Geom_ovl_traits_2, ArrangementA_2, ArrangementB_2>
Ovl_helper;
typedef Arr_overlay_sl_visitor<Ovl_helper, Overlay_traits>
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<Arr>
Zone_insertion_visitor;
Zone_insertion_visitor;
typedef Arr_walk_along_line_point_location<Arr>
Default_point_location_strategy;
Default_point_location_strategy;
typedef Arr_walk_along_line_point_location<Arr>
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 <CGAL/Arr_topology_traits/Arr_bounded_planar_topology_traits_2_impl.h>

View File

@ -15,7 +15,7 @@
// $URL$
// $Id$
// SPDX-License-Identifier: GPL-3.0+
//
//
//
// Author(s) : Ron Wein <wein@post.tau.ac.il>
// Baruch Zukerman <baruchzu@post.tau.ac.il>
@ -25,33 +25,32 @@
#include <CGAL/license/Arrangement_on_surface_2.h>
/*! \file
*
* Definition of default overlay-traits classes.
*/
#include <CGAL/Arr_default_dcel.h>
#include <CGAL/Arr_extended_dcel.h>
#include <CGAL/Sweep_line_2/Arr_default_overlay_traits_base.h>
#include <CGAL/Surface_sweep_2/Arr_default_overlay_traits_base.h>
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 <class Arrangement_>
template <typename Arrangement_>
class Arr_default_overlay_traits :
public _Arr_default_overlay_traits_base<Arrangement_,
Arrangement_,
public _Arr_default_overlay_traits_base<Arrangement_, Arrangement_,
Arrangement_>
{};
/*!
* \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 <class ArrangementA, class ArrangementB, class ArrangementR,
class OverlayFaceData_>
template <typename ArrangementA, typename ArrangementB, typename ArrangementR,
typename OverlayFaceData_>
class Arr_face_overlay_traits :
public _Arr_default_overlay_traits_base<ArrangementA,
ArrangementB,
ArrangementR>
public _Arr_default_overlay_traits_base<ArrangementA, ArrangementB,
ArrangementR>
{
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

View File

@ -18,39 +18,43 @@
//
//
// Author(s) : Baruch Zukerman <baruchzu@post.tau.ac.il>
// Efi Fogel <efif@post.tau.ac.il>
// Efi Fogel <efifogel@gmail.com>
#ifndef CGAL_ARR_OVERLAY_2_H
#define CGAL_ARR_OVERLAY_2_H
#include <CGAL/license/Arrangement_on_surface_2.h>
/*! \file
*
* Definition of the global Arr_overlay_2() function.
*/
#include <boost/optional/optional.hpp>
#include <CGAL/Arrangement_on_surface_2.h>
#include <CGAL/Sweep_line_2.h>
#include <CGAL/Sweep_line_2/Arr_default_overlay_traits_base.h>
#include <vector>
#include <boost/optional/optional.hpp>
#include <boost/mpl/if.hpp>
#include <boost/mpl/or.hpp>
#include <boost/type_traits.hpp>
#include <CGAL/Arrangement_on_surface_2.h>
#include <CGAL/Surface_sweep_2.h>
#include <CGAL/Surface_sweep_2/Arr_default_overlay_traits_base.h>
#include <CGAL/Surface_sweep_2/Arr_overlay_traits_2.h>
#include <CGAL/Surface_sweep_2/Arr_overlay_ss_visitor.h>
#include <CGAL/Surface_sweep_2/Arr_overlay_event.h>
#include <CGAL/Surface_sweep_2/Arr_overlay_subcurve.h>
#include <CGAL/assertions.h>
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 <class GeomTraitsA,
class GeomTraitsB,
class GeomTraitsRes,
class TopTraitsA,
class TopTraitsB,
class TopTraitsRes,
class OverlayTraits>
void overlay(const Arrangement_on_surface_2<GeomTraitsA, TopTraitsA>& arr1,
const Arrangement_on_surface_2<GeomTraitsB, TopTraitsB>& arr2,
Arrangement_on_surface_2<GeomTraitsRes, TopTraitsRes>& arr_res,
OverlayTraits& ovl_tr)
template <typename GeometryTraitsA_2,
typename GeometryTraitsB_2,
typename GeometryTraitsRes_2,
typename TopologyTraitsA,
typename TopologyTraitsB,
typename TopologyTraitsRes,
typename OverlayTraits>
void
overlay(const Arrangement_on_surface_2<GeometryTraitsA_2, TopologyTraitsA>& arr1,
const Arrangement_on_surface_2<GeometryTraitsB_2, TopologyTraitsB>& arr2,
Arrangement_on_surface_2<GeometryTraitsRes_2, TopologyTraitsRes>& arr,
OverlayTraits& ovl_tr)
{
typedef Arrangement_on_surface_2<GeomTraitsA, TopTraitsA> ArrA;
typedef Arrangement_on_surface_2<GeomTraitsB, TopTraitsB> ArrB;
typedef Arrangement_on_surface_2<GeomTraitsRes, TopTraitsRes> 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<Agt2, Att> Arr_a;
typedef Arrangement_on_surface_2<Bgt2, Btt> Arr_b;
typedef Arrangement_on_surface_2<Rgt2, Rtt> Arr_res;
typedef typename Arr_res::Allocator Allocator;
// some type assertions (not all, but better then nothing).
CGAL_static_assertion
((boost::is_convertible<typename GeomTraitsA::Point_2, \
typename GeomTraitsRes::Point_2>::value));
CGAL_static_assertion
((boost::is_convertible<typename GeomTraitsB::Point_2, \
typename GeomTraitsRes::Point_2 >::value));
CGAL_static_assertion
((boost::is_convertible<typename GeomTraitsA::X_monotone_curve_2, \
typename GeomTraitsRes::X_monotone_curve_2>::value));
CGAL_static_assertion
((boost::is_convertible<typename GeomTraitsB::X_monotone_curve_2, \
typename GeomTraitsRes::X_monotone_curve_2>::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<A_point, Res_point>::value));
CGAL_static_assertion((boost::is_convertible<B_point, Res_point>::value));
typedef typename TopTraitsRes::template
Sweep_line_overlay_visitor<ArrA, ArrB, OverlayTraits>
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<A_xcv, Res_xcv>::value));
CGAL_static_assertion((boost::is_convertible<B_xcv, Res_xcv>::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<Rgt2> Gt_adaptor_2;
typedef Arr_overlay_traits_2<Gt_adaptor_2, Arr_a, Arr_b>
Ovl_gt2;
typedef Arr_overlay_event<Ovl_gt2, Arr_res, Allocator>
Ovl_event;
typedef Arr_overlay_subcurve<Ovl_gt2, Ovl_event, Allocator>
Ovl_curve;
typedef typename TopologyTraitsRes::template
Overlay_helper<Ovl_gt2, Ovl_event, Ovl_curve, Arr_a, Arr_b>
Ovl_helper;
typedef Arr_overlay_ss_visitor<Ovl_helper, Overlay_traits>
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<Ovl_x_monotone_curve_2>
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<GeomTraitsA, TopTraitsA>& 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_<boost::is_same< Geom_traits_adaptor_2, Ovl_traits_2>,
const Ovl_traits_2&, Ovl_traits_2>::type
typename boost::mpl::if_<boost::is_same<Gt_adaptor_2, Ovl_gt2>,
const Ovl_gt2&, Ovl_gt2>::type
ex_traits(*traits_adaptor);
Ovl_visitor visitor(&arr1, &arr2, &arr_res, &ovl_tr);
Sweep_line_2<Ovl_traits_2, Ovl_visitor,
typename Ovl_visitor::Subcurve, typename Ovl_visitor::Event>
sweep_line(&ex_traits, &visitor);
Ovl_visitor visitor(&arr1, &arr2, &arr, &ovl_tr);
Ss2::Surface_sweep_2<Ovl_visitor> 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<GeomTraitsA, TopTraitsA>& 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<GeomTraitsA, TopTraitsA>& arr1,
std::vector<Ovl_point_2> 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<Cell_handle_blue>());
}
}
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<Cell_handle_red>(),
boost::make_optional(Cell_handle_blue(v2)));
@ -200,36 +221,43 @@ void overlay(const Arrangement_on_surface_2<GeomTraitsA, TopTraitsA>& 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 <class GeomTraitsA,
class GeomTraitsB,
class GeomTraitsRes,
class TopTraitsA,
class TopTraitsB,
class TopTraitsRes>
void overlay(const Arrangement_on_surface_2<GeomTraitsA, TopTraitsA>& arr1,
const Arrangement_on_surface_2<GeomTraitsB, TopTraitsB>& arr2,
Arrangement_on_surface_2<GeomTraitsRes, TopTraitsRes>& arr_res)
template <typename GeometryTraitsA_2,
typename GeometryTraitsB_2,
typename GeometryTraitsRes_2,
typename TopologyTraitsA,
typename TopologyTraitsB,
typename TopologyTraitsRes>
void
overlay(const Arrangement_on_surface_2<GeometryTraitsA_2, TopologyTraitsA>& arr1,
const Arrangement_on_surface_2<GeometryTraitsB_2, TopologyTraitsB>& arr2,
Arrangement_on_surface_2<GeometryTraitsRes_2, TopologyTraitsRes>& arr)
{
typedef Arrangement_on_surface_2<GeomTraitsA, TopTraitsA> ArrA;
typedef Arrangement_on_surface_2<GeomTraitsA, TopTraitsB> ArrB;
typedef Arrangement_on_surface_2<GeomTraitsRes, TopTraitsRes> ArrRes;
_Arr_default_overlay_traits_base<ArrA, ArrB, ArrRes> 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<Agt2, Att> Arr_a;
typedef Arrangement_on_surface_2<Bgt2, Btt> Arr_b;
typedef Arrangement_on_surface_2<Rgt2, Rtt> Arr_res;
_Arr_default_overlay_traits_base<Arr_a, Arr_b, Arr_res> ovl_traits;
overlay(arr1, arr2, arr, ovl_traits);
}
} //namespace CGAL
} // namespace CGAL
#endif

View File

@ -24,8 +24,8 @@
#include <CGAL/license/Arrangement_on_surface_2.h>
/*! \file
*
* The topology traits for great spherical arcs embedded on a sphere for the
* arrangement package.
*/
@ -35,20 +35,10 @@
#include <CGAL/Arr_default_dcel.h>
#include <CGAL/Arr_naive_point_location.h>
#include <CGAL/Arrangement_2/Arr_traits_adaptor_2.h>
#include <CGAL/Sweep_line_2/Arr_construction_event.h>
#include <CGAL/Sweep_line_2/Arr_construction_subcurve.h>
#include <CGAL/Sweep_line_2/Arr_construction_sl_visitor.h>
#include <CGAL/Sweep_line_2/Arr_basic_insertion_traits_2.h>
#include <CGAL/Sweep_line_2/Arr_basic_insertion_sl_visitor.h>
#include <CGAL/Sweep_line_2/Arr_insertion_traits_2.h>
#include <CGAL/Sweep_line_2/Arr_insertion_sl_visitor.h>
#include <CGAL/Sweep_line_2/Arr_overlay_subcurve.h>
#include <CGAL/Sweep_line_2/Arr_overlay_traits_2.h>
#include <CGAL/Sweep_line_2/Arr_overlay_sl_visitor.h>
#include <CGAL/Sweep_line_2/Arr_batched_pl_sl_visitor.h>
#include <CGAL/Sweep_line_2/Arr_vert_decomp_sl_visitor.h>
#include <CGAL/Surface_sweep_2/Arr_basic_insertion_traits_2.h>
#include <CGAL/Surface_sweep_2/Arr_insertion_traits_2.h>
#include <CGAL/Surface_sweep_2/Arr_overlay_traits_2.h>
#include <CGAL/Arr_point_location/Arr_batched_point_location_traits_2.h>
#include <CGAL/Arr_topology_traits/Arr_spherical_construction_helper.h>
#include <CGAL/Arr_topology_traits/Arr_spherical_insertion_helper.h>
#include <CGAL/Arr_topology_traits/Arr_spherical_overlay_helper.h>
@ -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 <typename GeomTraits_, typename Dcel_ = Arr_default_dcel<GeomTraits_> >
template <typename GeometryTraits_2,
typename Dcel_ = Arr_default_dcel<GeometryTraits_2> >
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<Geometry_traits_2, Dcel> Self;
typedef Arr_traits_basic_adaptor_2<Geometry_traits_2> Traits_adaptor_2;
typedef Arr_spherical_topology_traits_2<Gt2, Dcel> Self;
typedef Arr_traits_basic_adaptor_2<Gt2> 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<Geometry_traits_2, Self> Arr;
typedef Arrangement_on_surface_2<Gt2, Self> Arr;
// Type definition for the constuction sweep-line visitor.
typedef Arr_construction_subcurve<Geometry_traits_2> CSubcurve;
typedef Arr_construction_event<Geometry_traits_2, CSubcurve, Arr>
CEvent;
typedef Arr_spherical_construction_helper<Geometry_traits_2, Arr,
CEvent,CSubcurve> CHelper;
// Type definition for the basic insertion sweep-line visitor.
typedef Arr_basic_insertion_traits_2<Geometry_traits_2, Arr> BInsTraits;
typedef Arr_construction_subcurve<BInsTraits> BISubcurve;
typedef Arr_construction_event<BInsTraits, BISubcurve, Arr> BIEvent;
typedef Arr_spherical_insertion_helper<BInsTraits, Arr, BIEvent, BISubcurve>
BIHelper;
// Type definition for the insertion sweep-line visitor.
typedef Arr_insertion_traits_2<Geometry_traits_2, Arr> InsTraits;
typedef Arr_construction_subcurve<InsTraits> ISubcurve;
typedef Arr_construction_event<InsTraits,ISubcurve,Arr> IEvent;
typedef Arr_spherical_insertion_helper<InsTraits, Arr, IEvent, ISubcurve>
IHelper;
// Type definition for the batched point-location sweep-line visitor.
typedef Arr_batched_point_location_traits_2<Arr> BplTraits;
typedef Arr_spherical_batched_pl_helper<BplTraits, Arr> BplHelper;
// Type definition for the vertical decomposition sweep-line visitor.
typedef Arr_batched_point_location_traits_2<Arr> VdTraits;
typedef Arr_spherical_vert_decomp_helper<VdTraits, Arr> VdHelper;
// Type definition for the overlay sweep-line visitor.
template <typename ExGeomTraits_, typename ArrangementA_,
typename ArrangementB_>
struct _Overlay_helper :
public Arr_spherical_overlay_helper
<ExGeomTraits_, ArrangementA_, ArrangementB_, Arr,
Arr_construction_event<ExGeomTraits_,
Arr_overlay_subcurve<ExGeomTraits_>, Arr>,
Arr_overlay_subcurve<ExGeomTraits_> >
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 <typename Evt, typename Crv>
struct Construction_helper :
public Arr_spherical_construction_helper<Gt2, Arr, Evt, Crv>
{
typedef ExGeomTraits_ Ex_geomt_raits;
typedef ArrangementA_ Arrangement_a;
typedef ArrangementB_ Arrangement_b;
typedef Arr_overlay_subcurve<Ex_geomt_raits> Overlay_subcurve;
typedef Arr_construction_event<Ex_geomt_raits, Overlay_subcurve, Arr>
Construction_event;
typedef Arr_spherical_overlay_helper<Ex_geomt_raits,
Arrangement_a, Arrangement_b, Arr,
Construction_event, 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 Arrangement_a* arr_a, const Arrangement_b* arr_b) :
Base(arr_a, arr_b)
{}
typedef Arr_spherical_construction_helper<Gt2, Arr, Evt, Crv>
Base;
Construction_helper(Arr* arr) : Base(arr) {}
};
// Type definition for the no-intersection construction surface-sweep visitor.
template <typename Evt, typename Crv>
struct No_intersection_construction_helper :
public Arr_spherical_construction_helper<Gt2, Arr, Evt, Crv>
{
typedef Arr_spherical_construction_helper<Gt2, Arr, Evt, Crv>
Base;
No_intersection_construction_helper(Arr* arr) : Base(arr) {}
};
// Type definition for the insertion surface-sweep visitor.
typedef Arr_insertion_traits_2<Gt2, Arr> I_traits;
template <typename Evt, typename Crv>
struct Insertion_helper :
public Arr_spherical_insertion_helper<I_traits, Arr, Evt, Crv>
{
typedef Arr_spherical_insertion_helper<I_traits, Arr, Evt, Crv>
Base;
Insertion_helper(Arr* arr) : Base(arr) {}
};
// Type definition for the no-intersection insertion surface-sweep visitor.
typedef Arr_basic_insertion_traits_2<Gt2, Arr> Nxi_traits;
template <typename Evt, typename Crv>
struct No_intersection_insertion_helper :
public Arr_spherical_insertion_helper<Nxi_traits, Arr, Evt, Crv>
{
typedef Arr_spherical_insertion_helper<Nxi_traits, Arr, Evt, Crv>
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<Arr> Bpl_traits;
template <typename Evt, typename Crv>
struct Batched_point_location_helper :
public Arr_spherical_batched_pl_helper<Bpl_traits, Arr, Evt, Crv>
{
typedef Arr_spherical_batched_pl_helper<Bpl_traits, Arr, Evt, Crv>
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<Arr> Vd_traits;
template <typename Evt, typename Crv>
struct Vertical_decomposition_helper :
public Arr_spherical_vert_decomp_helper<Vd_traits, Arr, Evt, Crv>
{
typedef Arr_spherical_vert_decomp_helper<Vd_traits, Arr, Evt, Crv>
Base;
Vertical_decomposition_helper(const Arr* arr) : Base(arr) {}
};
// Type definition for the overlay surface-sweep visitor.
template <typename Gt, typename Evt, typename Crv,
typename ArrA, typename ArrB>
struct Overlay_helper :
public Arr_spherical_overlay_helper<Gt, ArrA, ArrB, Arr, Evt, Crv>
{
typedef Arr_spherical_overlay_helper<Gt, ArrA, ArrB, Arr, Evt, Crv>
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 <typename Evt, typename Crv>
using Construction_helper =
Arr_spherical_construction_helper<Gt2, Arr, Evt, Crv>;
// Type definition for the no-intersection construction surface-sweep visitor.
template <typename Evt, typename Crv>
using No_intersection_construction_helper =
Arr_spherical_construction_helper<Gt2, Arr, Evt, Crv>;
// Type definition for the insertion surface-sweep visitor.
typedef Arr_insertion_traits_2<Gt2, Arr> I_traits;
template <typename Evt, typename Crv>
using Insertion_helper =
Arr_spherical_insertion_helper<I_traits, Arr, Evt, Crv>;
// Type definition for the no-intersection insertion surface-sweep visitor.
typedef Arr_basic_insertion_traits_2<Gt2, Arr> Nxi_traits;
template <typename Evt, typename Crv>
using No_intersection_insertion_helper =
Arr_spherical_insertion_helper<Nxi_traits, Arr, Evt, Crv>;
// Type definition for the batched point-location surface-sweep visitor.
typedef Arr_batched_point_location_traits_2<Arr> Bpl_traits;
template <typename Evt, typename Crv>
using Batched_point_location_helper =
Arr_spherical_batched_pl_helper<Bpl_traits, Arr, Evt, Crv>;
// Type definition for the vertical decomposition surface-sweep visitor.
typedef Arr_batched_point_location_traits_2<Arr> Vd_traits;
template <typename Evt, typename Crv>
using Vertical_decomposition_helper =
Arr_spherical_vert_decomp_helper<Vd_traits, Arr, Evt, Crv>;
// Type definition for the overlay surface-sweep visitor.
template <typename Gt, typename Evt, typename Crv,
typename ArrA, typename ArrB>
using Overlay_helper =
Arr_spherical_overlay_helper<Gt, ArrA, ArrB, Arr, Evt, Crv>;
#endif
//@}
public:
///! \name Visitor types.
//@{
typedef Arr_construction_sl_visitor<CHelper>
Sweep_line_construction_visitor;
typedef Arr_insertion_sl_visitor<IHelper>
Sweep_line_insertion_visitor;
typedef Sweep_line_construction_visitor
Sweep_line_non_intersecting_construction_visitor;
typedef Arr_basic_insertion_sl_visitor<BIHelper>
Sweep_line_non_intersecting_insertion_visitor;
template <typename OutputIterator_>
struct Sweep_line_batched_point_location_visitor :
public Arr_batched_pl_sl_visitor<BplHelper, OutputIterator_>
{
typedef OutputIterator_ Output_iterator;
typedef Arr_batched_pl_sl_visitor<BplHelper, Output_iterator> 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 <typename OutputIterator_>
struct Sweep_line_vertical_decomposition_visitor :
public Arr_vert_decomp_sl_visitor<VdHelper, OutputIterator_>
{
typedef OutputIterator_ Output_iterator;
typedef Arr_vert_decomp_sl_visitor<VdHelper,Output_iterator> 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 <typename ArrangementA_, typename ArrangementB_,
typename OverlayTraits_>
struct Sweep_line_overlay_visitor :
public Arr_overlay_sl_visitor
<_Overlay_helper<Arr_overlay_traits_2<Geometry_traits_2,ArrangementA_,
ArrangementB_>,
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<Geometry_traits_2,
Arrangement_a,
Arrangement_b> Geom_ovl_traits_2;
typedef _Overlay_helper<Geom_ovl_traits_2, Arrangement_a, Arrangement_b>
Ovl_helper;
typedef Arr_overlay_sl_visitor<Ovl_helper, Overlay_traits> 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<Arr> Zone_insertion_visitor;
typedef Arr_naive_point_location<Arr> 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 <CGAL/Arr_topology_traits/Arr_spherical_topology_traits_2_impl.h>

View File

@ -15,89 +15,80 @@
// $URL$
// $Id$
// SPDX-License-Identifier: GPL-3.0+
//
//
//
// Author(s) : Baruch Zukerman <baruchzu@post.tau.ac.il>
// Ron Wein <wein@post.tau.ac.il>
// Efi Fogel <efif@post.tau.ac.il>
#ifndef CGAL_ARR_BOUNDED_PLANAR_BATCHED_PL_HELPER_H
#define CGAL_ARR_BOUNDED_PLANAR_BATCHED_PL_HELPER_H
#include <CGAL/license/Arrangement_on_surface_2.h>
/*!
/*! \file
*
* Definition of the Arr_bounded_planar_batched_pl_helper class-template.
*/
namespace CGAL {
#include <CGAL/Sweep_line_empty_visitor.h>
/*! \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 Traits_, class Arrangement_>
class Arr_bounded_planar_batched_pl_helper
{
template <typename GeometryTraits_2, typename Arrangement_, typename Event_,
typename Subcurve_>
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<Traits_2> 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

View File

@ -15,70 +15,88 @@
// $URL$
// $Id$
// SPDX-License-Identifier: GPL-3.0+
//
//
//
// Author(s) : Baruch Zukerman <baruchzu@post.tau.ac.il>
// Ron Wein <wein@post.tau.ac.il>
// Efi Fogel <efif@post.tau.ac.il>
#ifndef CGAL_ARR_BOUNDED_PLANAR_CONSTRUCTION_HELPER_H
#define CGAL_ARR_BOUNDED_PLANAR_CONSTRUCTION_HELPER_H
#include <CGAL/license/Arrangement_on_surface_2.h>
/*!
/*! \file
*
* Definition of the Arr_bounded_planar_construction_helper class-template.
*/
#include <CGAL/Sweep_line_empty_visitor.h>
#include <CGAL/Unique_hash_map.h>
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 Traits_, class Arrangement_, class Event_, class Subcurve_>
class Arr_bounded_planar_construction_helper
{
template <typename GeometryTraits_2, typename Arrangement_, typename Event_,
typename Subcurve_>
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<Traits_2,
Subcurve,
Event> 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_handle,
Indices_list> Halfedge_indices_map;
typedef typename Subcurve::Halfedge_indices_list Indices_list;
typedef Unique_hash_map<Halfedge_handle, Indices_list>
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 <typename OtherGeometryTraits_2, typename OtherArrangement,
typename OtherEvent, typename OtherSubcurve>
struct rebind {
typedef Arr_bounded_planar_construction_helper<OtherGeometryTraits_2,
OtherArrangement,
OtherEvent, OtherSubcurve>
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

View File

@ -15,75 +15,68 @@
// $URL$
// $Id$
// SPDX-License-Identifier: GPL-3.0+
//
//
//
// Author(s) : Baruch Zukerman <baruchzu@post.tau.ac.il>
// Ron Wein <wein@post.tau.ac.il>
// Efi Fogel <efif@post.tau.ac.il>
#ifndef CGAL_ARR_BOUNDED_PLANAR_INSERTION_HELPER_H
#define CGAL_ARR_BOUNDED_PLANAR_INSERTION_HELPER_H
#include <CGAL/license/Arrangement_on_surface_2.h>
/*!
/*! \file
*
* Definition of the Arr_bounded_planar_insertion_helper class-template.
*/
#include <CGAL/Sweep_line_2/Arr_construction_sl_visitor.h>
#include <CGAL/Arr_topology_traits/Arr_bounded_planar_construction_helper.h>
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 <class Traits_, class Arrangement_, class Event_, class Subcurve_>
template <typename GeometryTraits_2, typename Arrangement_, typename Event_,
typename Subcurve_>
class Arr_bounded_planar_insertion_helper :
public Arr_bounded_planar_construction_helper<Traits_, Arrangement_,
public Arr_bounded_planar_construction_helper<GeometryTraits_2, Arrangement_,
Event_, Subcurve_>
{
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<Traits_2,
Arrangement_2,
Event,
Subcurve> Base;
typedef Sweep_line_empty_visitor<Traits_2,
Subcurve,
Event> Base_visitor;
typedef Arr_bounded_planar_insertion_helper<Traits_2,
Arrangement_2,
Event,
Subcurve> Self;
typedef Arr_construction_sl_visitor<Self> 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<Gt2, Arrangement_2, Event,
Subcurve> Self;
typedef Arr_bounded_planar_construction_helper<Gt2, Arrangement_2,
Event, Subcurve>
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

View File

@ -15,18 +15,19 @@
// $URL$
// $Id$
// SPDX-License-Identifier: GPL-3.0+
//
//
//
// Author(s) : Baruch Zukerman <baruchzu@post.tau.ac.il>
// Ron Wein <wein@post.tau.ac.il>
// Efi Fogel <efif@post.tau.ac.il>
#ifndef CGAL_ARR_BOUNDED_PLANAR_OVERLAY_HELPER_H
#define CGAL_ARR_BOUNDED_PLANAR_OVERLAY_HELPER_H
#include <CGAL/license/Arrangement_on_surface_2.h>
/*!
/*! \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 Traits_,
class ArrangementRed_,
class ArrangementBlue_,
class Arrangement_,
class Event_,
class Subcurve_>
class Arr_bounded_planar_overlay_helper
{
template <typename GeometryTraits_2,
typename ArrangementRed_2,
typename ArrangementBlue_2,
typename Arrangement_,
typename Event_,
typename Subcurve_>
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<Traits_2,
Arrangement_2,
Event,
Subcurve> Construction_helper;
typedef Arr_bounded_planar_construction_helper<Gt2, Arrangement_2, Event,
Subcurve>
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

View File

@ -25,8 +25,8 @@
#include <CGAL/license/Arrangement_on_surface_2.h>
/*! \file
*
* Member-function definitions for the
* Arr_bounded_planar_topology_traits_2<GeomTraits> class.
*/
@ -36,8 +36,8 @@ namespace CGAL {
//-----------------------------------------------------------------------------
// Assign the contents of another topology-traits class.
//
template <typename GeomTraits_, typename Dcel_>
void Arr_bounded_planar_topology_traits_2<GeomTraits_, Dcel_>::
template <typename GeometryTraits_2, typename Dcel_>
void Arr_bounded_planar_topology_traits_2<GeometryTraits_2, Dcel_>::
assign(const Self& other)
{
// Assign the base class.
@ -50,8 +50,8 @@ assign(const Self& other)
//-----------------------------------------------------------------------------
// Initialize an empty DCEL structure.
//
template <typename GeomTraits_, typename Dcel_>
void Arr_bounded_planar_topology_traits_2<GeomTraits_, Dcel_>::init_dcel()
template <typename GeometryTraits_2, typename Dcel_>
void Arr_bounded_planar_topology_traits_2<GeometryTraits_2, Dcel_>::init_dcel()
{
// Clear the current DCEL.
this->m_dcel.delete_all();
@ -66,8 +66,9 @@ void Arr_bounded_planar_topology_traits_2<GeomTraits_, Dcel_>::init_dcel()
//-----------------------------------------------------------------------------
// Make the necessary updates after the DCEL structure have been updated.
//
template <typename GeomTraits_, typename Dcel_>
void Arr_bounded_planar_topology_traits_2<GeomTraits_, Dcel_>::dcel_updated()
template <typename GeometryTraits_2, typename Dcel_>
void Arr_bounded_planar_topology_traits_2<GeometryTraits_2, Dcel_>::
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<GeomTraits_, Dcel_>::dcel_updated()
CGAL_assertion(unb_face != NULL);
}
} //namespace CGAL
} // namespace CGAL
#endif

View File

@ -15,97 +15,82 @@
// $URL$
// $Id$
// SPDX-License-Identifier: GPL-3.0+
//
//
//
// Author(s) : Ron Wein <wein@post.tau.ac.il>
// Efi Fogel <efif@post.tau.ac.il>
#ifndef CGAL_ARR_BOUNDED_PLANAR_VERT_DEOCMP_HELPER_H
#define CGAL_ARR_BOUNDED_PLANAR_VERT_DEOCMP_HELPER_H
#include <CGAL/license/Arrangement_on_surface_2.h>
/*! \file
*
* Definition of the Arr_bounded_planar_vert_decomp_helper class-template.
*/
namespace CGAL {
#include <CGAL/Sweep_line_empty_visitor.h>
/*! \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 Traits_, class Arrangement_>
class Arr_bounded_planar_vert_decomp_helper
{
template <typename GeometryTraits_2, typename Arrangement_, typename Event_,
typename Subcurve_>
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<Traits_2> 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

View File

@ -25,8 +25,8 @@
#include <CGAL/license/Arrangement_on_surface_2.h>
/*! \file
*
* Definition of the Arr_planar_topology_traits_base_2<GeomTraits> class.
*/
@ -34,23 +34,15 @@
#include <CGAL/Arr_default_dcel.h>
#include <CGAL/Arr_walk_along_line_point_location.h>
#include <CGAL/Arrangement_2/Arr_traits_adaptor_2.h>
#include <CGAL/Sweep_line_2/Arr_construction_event.h>
#include <CGAL/Sweep_line_2/Arr_construction_subcurve.h>
#include <CGAL/Sweep_line_2/Arr_construction_sl_visitor.h>
#include <CGAL/Sweep_line_2/Arr_basic_insertion_traits_2.h>
#include <CGAL/Sweep_line_2/Arr_basic_insertion_sl_visitor.h>
#include <CGAL/Sweep_line_2/Arr_insertion_traits_2.h>
#include <CGAL/Sweep_line_2/Arr_insertion_sl_visitor.h>
#include <CGAL/Sweep_line_2/Arr_overlay_subcurve.h>
#include <CGAL/Sweep_line_2/Arr_overlay_traits_2.h>
#include <CGAL/Sweep_line_2/Arr_overlay_sl_visitor.h>
#include <CGAL/Sweep_line_2/Arr_batched_pl_sl_visitor.h>
#include <CGAL/Sweep_line_2/Arr_vert_decomp_sl_visitor.h>
#include <CGAL/Surface_sweep_2/Arr_basic_insertion_traits_2.h>
#include <CGAL/Surface_sweep_2/Arr_insertion_traits_2.h>
#include <CGAL/Surface_sweep_2/Arr_overlay_traits_2.h>
#include <CGAL/Arr_point_location/Arr_batched_point_location_traits_2.h>
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

View File

@ -19,45 +19,44 @@
// Author(s) : Baruch Zukerman <baruchzu@post.tau.ac.il>
// Ron Wein <wein@post.tau.ac.il>
// Efi Fogel <efif@post.tau.ac.il>
//
#ifndef CGAL_ARR_SPHERICAL_BATCHED_PL_HELPER_H
#define CGAL_ARR_SPHERICAL_BATCHED_PL_HELPER_H
#include <CGAL/license/Arrangement_on_surface_2.h>
/*! \file
*
* Definition of the Arr_spherical_batched_pl_helper class-template.
*/
namespace CGAL {
#include <CGAL/Sweep_line_empty_visitor.h>
/*! \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 Traits_, class Arrangement_>
class Arr_spherical_batched_pl_helper
{
template <typename GeometryTraits_2, typename Arrangement_, typename Event_,
typename Subcurve_>
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<Traits_2> 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

View File

@ -25,48 +25,71 @@
#include <CGAL/license/Arrangement_on_surface_2.h>
/*! \file
*
* Definition of the Arr_spherical_construction_helper class-template.
*/
#include <CGAL/Sweep_line_empty_visitor.h>
#include <CGAL/Arr_accessor.h>
#include <CGAL/Unique_hash_map.h>
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 <typename Traits_, typename Arrangement_, typename Event_,
template <typename GeometryTraits_2, typename Arrangement_, typename Event_,
typename Subcurve_>
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<Traits_2, Subcurve, Event>
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_handle, Indices_list> 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_handle, Indices_list>
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 <typename OtherGeometryTraits_2, typename OtherArrangement,
typename OtherEvent, typename OtherSubcurve>
struct rebind {
typedef Arr_spherical_construction_helper<OtherGeometryTraits_2,
OtherArrangement,
OtherEvent, OtherSubcurve>
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

View File

@ -25,46 +25,43 @@
#include <CGAL/license/Arrangement_on_surface_2.h>
/*! \file
*
* Definition of the Arr_spherical_insertion_helper class-template.
*/
#include <CGAL/Sweep_line_2/Arr_construction_sl_visitor.h>
#include <CGAL/Arr_topology_traits/Arr_spherical_construction_helper.h>
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 <typename Traits_, typename Arrangement_, typename Event_,
template <typename GeometryTraits_2, typename Arrangement_, typename Event_,
typename Subcurve_>
class Arr_spherical_insertion_helper :
public Arr_spherical_construction_helper<Traits_, Arrangement_,
public Arr_spherical_construction_helper<GeometryTraits_2, Arrangement_,
Event_, Subcurve_>
{
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<Gt2, Arrangement_2, Event, Subcurve>
Self;
typedef Arr_spherical_construction_helper<Gt2, Arrangement_2, Event, Subcurve>
Base;
typedef Arr_spherical_construction_helper<Traits_2, Arrangement_2, Event,
Subcurve> Base;
typedef Sweep_line_empty_visitor<Traits_2, Subcurve, Event>
Base_visitor;
typedef Arr_spherical_insertion_helper<Traits_2, Arrangement_2, Event,
Subcurve> Self;
typedef Arr_construction_sl_visitor<Self> 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<Tr, Arr, Evnt, Sbcv>::top_face() const
return this->m_spherical_face;
}
} //namespace CGAL
} // namespace CGAL
#endif

View File

@ -15,7 +15,7 @@
// $URL$
// $Id$
// SPDX-License-Identifier: GPL-3.0+
//
//
//
// Author(s) : Baruch Zukerman <baruchzu@post.tau.ac.il>
// Ron Wein <wein@post.tau.ac.il>
@ -26,8 +26,8 @@
#include <CGAL/license/Arrangement_on_surface_2.h>
/*! \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 Traits_,
class ArrangementRed_,
class ArrangementBlue_,
class Arrangement_,
class Event_,
class Subcurve_>
class Arr_spherical_overlay_helper
{
template <typename GeometryTraits_2,
typename ArrangementRed_2,
typename ArrangementBlue_2,
typename Arrangement_,
typename Event_,
typename Subcurve_>
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<Traits_2, Arrangement_2, Event,
typedef Arr_spherical_construction_helper<Gt2, Arrangement_2, Event,
Subcurve> 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;
}
}
}

View File

@ -24,8 +24,8 @@
#include <CGAL/license/Arrangement_on_surface_2.h>
/*! \file
*
* Member-function definitions for the
* Arr_spherical_topology_traits_2<GeomTraits> 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<const Traits_adaptor_2*>(traits);
m_geom_traits = static_cast<const Gt_adaptor_2*>(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;

View File

@ -15,64 +15,63 @@
// $URL$
// $Id$
// SPDX-License-Identifier: GPL-3.0+
//
//
// Author(s) : Ron Wein <wein@post.tau.ac.il>
// Efi Fogel <efif@post.tau.ac.il>
//
#ifndef CGAL_ARR_SPHERICAL_VERT_DECOMP_HELPER_H
#define CGAL_ARR_SPHERICAL_VERT_DECOMP_HELPER_H
#include <CGAL/license/Arrangement_on_surface_2.h>
/*! \file
*
* Definition of the Arr_spherical_vert_decomp_helper class-template.
*/
namespace CGAL {
#include <CGAL/Sweep_line_empty_visitor.h>
/*! \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 Traits_, class Arrangement_>
class Arr_spherical_vert_decomp_helper
{
template <typename GeometryTraits_2, typename Arrangement_, typename Event_,
typename Subcurve_>
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<Traits_2> 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 <class Tr, class Arr>
void Arr_spherical_vert_decomp_helper<Tr, Arr>::before_sweep()
template <typename Tr, typename Arr, typename Evnt, typename Sbcv>
void Arr_spherical_vert_decomp_helper<Tr, Arr, Evnt, Sbcv>::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<Tr, Arr>::before_sweep()
// A notification invoked after the sweep-line finishes handling the given
// event.
///
template <class Tr, class Arr>
void
Arr_spherical_vert_decomp_helper<Tr, Arr>::after_handle_event (Event *event)
template <typename Tr, typename Arr, typename Evnt, typename Sbcv>
void Arr_spherical_vert_decomp_helper<Tr, Arr, Evnt, Sbcv>::
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<Tr, Arr>::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

View File

@ -18,80 +18,75 @@
//
//
// Author(s) : Baruch Zukerman <baruchzu@post.tau.ac.il>
// Ron Wein <wein@post.tau.ac.il>
// Efi Fogel <efif@post.tau.ac.il>
// Ron Wein <wein@post.tau.ac.il>
// Efi Fogel <efif@post.tau.ac.il>
#ifndef CGAL_ARR_UNB_PLANAR_BATCHED_PL_HELPER_H
#define CGAL_ARR_UNB_PLANAR_BATCHED_PL_HELPER_H
#include <CGAL/license/Arrangement_on_surface_2.h>
/*!
/*! \file
*
* Definition of the Arr_unb_planar_batched_pl_helper class-template.
*/
namespace CGAL {
#include <CGAL/Sweep_line_empty_visitor.h>
/*! \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 Traits_, class Arrangement_>
class Arr_unb_planar_batched_pl_helper
{
template <typename GeometryTraits_2, typename Arrangement_, typename Event_,
typename Subcurve_>
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<Traits_2> 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 <class Tr, class Arr>
void Arr_unb_planar_batched_pl_helper<Tr, Arr>::before_sweep ()
template <typename Tr, typename Arr, typename Event_, typename Subcurve_>
void Arr_unb_planar_batched_pl_helper<Tr, Arr, Event_, Subcurve_>::
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 <class Tr, class Arr>
void Arr_unb_planar_batched_pl_helper<Tr, Arr>::
after_handle_event (Event* event)
template <typename Tr, typename Arr, typename Event_, typename Subcurve_>
void Arr_unb_planar_batched_pl_helper<Tr, Arr, Event_, Subcurve_>::
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

View File

@ -15,85 +15,103 @@
// $URL$
// $Id$
// SPDX-License-Identifier: GPL-3.0+
//
//
//
// Author(s) : Baruch Zukerman <baruchzu@post.tau.ac.il>
// Ron Wein <wein@post.tau.ac.il>
// Efi Fogel <efif@post.tau.ac.il>
// Ron Wein <wein@post.tau.ac.il>
// Efi Fogel <efif@post.tau.ac.il>
#ifndef CGAL_ARR_UNB_PLANAR_CONSTRUCTION_HELPER_H
#define CGAL_ARR_UNB_PLANAR_CONSTRUCTION_HELPER_H
#include <CGAL/license/Arrangement_on_surface_2.h>
/*!
/*! \file
*
* Definition of the Arr_unb_planar_construction_helper class-template.
*/
#include <CGAL/Sweep_line_empty_visitor.h>
#include <CGAL/Arr_accessor.h>
#include <CGAL/Unique_hash_map.h>
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 Traits_, class Arrangement_, class Event_, class Subcurve_>
class Arr_unb_planar_construction_helper
{
template <typename GeometryTraits_2, typename Arrangement_, typename Event_,
typename Subcurve_>
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<Traits_2, Subcurve, Event>
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_handle,
Indices_list> Halfedge_indices_map;
typedef typename Subcurve::Halfedge_indices_list Indices_list;
typedef Unique_hash_map<Halfedge_handle, Indices_list>
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 <typename OtherGeometryTraits_2, typename OtherArrangement,
typename OtherEvent, typename OtherSubcurve>
struct rebind {
typedef Arr_unb_planar_construction_helper<OtherGeometryTraits_2,
OtherArrangement,
OtherEvent, OtherSubcurve>
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<Arrangement_2>
m_arr_access; // An arrangement accessor.
Topology_traits* m_top_traits; // The topology-traits class.
Arr_accessor<Arrangement_2> 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 <class Tr, class Arr, class Evnt, class Sbcv>
template <class Tr, class Arr, class Evnt, class Sbcv>
void Arr_unb_planar_construction_helper<Tr,Arr,Evnt,Sbcv>::before_sweep()
{
// Obtain the four fictitious vertices that form the "corners" of the
@ -192,7 +201,7 @@ void Arr_unb_planar_construction_helper<Tr,Arr,Evnt,Sbcv>::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<Tr,Arr,Evnt,Sbcv>::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<Tr,Arr,Evnt,Sbcv>::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<Tr,Arr,Evnt,Sbcv>::before_sweep()
// A notification invoked before the sweep-line starts handling the given
// event.
//
template <class Tr, class Arr, class Evnt, class Sbcv>
template <class Tr, class Arr, class Evnt, class Sbcv>
void Arr_unb_planar_construction_helper<Tr, Arr, Evnt, Sbcv>::
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

View File

@ -15,75 +15,69 @@
// $URL$
// $Id$
// SPDX-License-Identifier: GPL-3.0+
//
//
//
// Author(s) : Baruch Zukerman <baruchzu@post.tau.ac.il>
// Ron Wein <wein@post.tau.ac.il>
// Efi Fogel <efif@post.tau.ac.il>
// Ron Wein <wein@post.tau.ac.il>
// Efi Fogel <efif@post.tau.ac.il>
#ifndef CGAL_ARR_UNB_PLANAR_INSERTION_HELPER_H
#define CGAL_ARR_UNB_PLANAR_INSERTION_HELPER_H
#include <CGAL/license/Arrangement_on_surface_2.h>
/*!
/*! \file
*
* Definition of the Arr_unb_planar_insertion_helper class-template.
*/
#include <CGAL/Sweep_line_2/Arr_construction_sl_visitor.h>
#include <CGAL/Arr_topology_traits/Arr_unb_planar_construction_helper.h>
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 <class Traits_, class Arrangement_, class Event_, class Subcurve_>
template <typename GeometryTraits_2, typename Arrangement_, typename Event_,
typename Subcurve_>
class Arr_unb_planar_insertion_helper :
public Arr_unb_planar_construction_helper<Traits_, Arrangement_,
public Arr_unb_planar_construction_helper<GeometryTraits_2, Arrangement_,
Event_, Subcurve_>
{
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<Gt2, Arrangement_2, Event, Subcurve>
Self;
typedef Arr_unb_planar_construction_helper<Gt2, Arrangement_2, Event,
Subcurve> 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<Traits_2, Arrangement_2, Event,
Subcurve> Base;
typedef Sweep_line_empty_visitor<Traits_2, Subcurve, Event>
Base_visitor;
typedef Arr_unb_planar_insertion_helper<Traits_2, Arrangement_2, Event,
Subcurve> Self;
typedef Arr_construction_sl_visitor<Self> 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 <class Tr, class Arr, class Evnt, class Sbcv>
void Arr_unb_planar_insertion_helper<Tr,Arr,Evnt,Sbcv>::before_sweep ()
template <class Tr, class Arr, class Evnt, class Sbcv>
void Arr_unb_planar_insertion_helper<Tr,Arr,Evnt,Sbcv>::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<Tr,Arr,Evnt,Sbcv>::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<Tr,Arr,Evnt,Sbcv>::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<Tr,Arr,Evnt,Sbcv>::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<Tr,Arr,Evnt,Sbcv>::before_sweep ()
// A notification invoked before the sweep-line starts handling the given
// event.
//
template <class Tr, class Arr, class Evnt, class Sbcv>
template <class Tr, class Arr, class Evnt, class Sbcv>
void Arr_unb_planar_insertion_helper<Tr,Arr,Evnt,Sbcv>::
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

View File

@ -15,7 +15,7 @@
// $URL$
// $Id$
// SPDX-License-Identifier: GPL-3.0+
//
//
//
// Author(s) : Baruch Zukerman <baruchzu@post.tau.ac.il>
// Ron Wein <wein@post.tau.ac.il>
@ -26,8 +26,8 @@
#include <CGAL/license/Arrangement_on_surface_2.h>
/*!
/*! \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 Traits_,
class ArrangementRed_,
class ArrangementBlue_,
class Arrangement_,
class Event_,
class Subcurve_>
class Arr_unb_planar_overlay_helper
{
template <typename GeometryTraits_2,
typename ArrangementRed_2,
typename ArrangementBlue_2,
typename Arrangement_,
typename Event_,
typename Subcurve_>
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<Traits_2,
Arrangement_2,
Event,
Subcurve> Construction_helper;
typedef Arr_unb_planar_construction_helper<Gt2, Arrangement_2, Event,
Subcurve> 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 <class Tr, class ArrR, class ArrB, class Arr, class Evnt, class Sbcv>
void Arr_unb_planar_overlay_helper<Tr,ArrR,ArrB,Arr,Evnt,Sbcv>::before_sweep ()
template <typename Tr, typename ArrR, typename ArrB, typename Arr,
typename Evnt, typename Sbcv>
void Arr_unb_planar_overlay_helper<Tr, ArrR, ArrB, Arr, Evnt, Sbcv>::
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 <class Tr, class ArrR, class ArrB, class Arr, class Evnt, class Sbcv>
void Arr_unb_planar_overlay_helper<Tr,ArrR,ArrB,Arr,Evnt,Sbcv>::
before_handle_event (Event* e)
template <typename Tr, typename ArrR, typename ArrB, typename Arr,
typename Evnt, typename Sbcv>
void Arr_unb_planar_overlay_helper<Tr, ArrR, ArrB, Arr, Evnt, Sbcv>::
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

View File

@ -25,8 +25,8 @@
#include <CGAL/license/Arrangement_on_surface_2.h>
/*! \file
*
* Member-function definitions for the
* Arr_unb_planar_topology_traits_2<GeomTraits> class.
*/
@ -36,22 +36,22 @@ namespace CGAL {
//-----------------------------------------------------------------------------
// Default constructor.
//
template <class GeomTraits, class Dcel_>
template <typename GeomTraits, typename Dcel_>
Arr_unb_planar_topology_traits_2<GeomTraits, Dcel_>::
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 <class GeomTraits, class Dcel_>
template <typename GeomTraits, typename Dcel_>
Arr_unb_planar_topology_traits_2<GeomTraits, Dcel_>::
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 <class GeomTraits, class Dcel_>
template <typename GeomTraits, typename Dcel_>
void Arr_unb_planar_topology_traits_2<GeomTraits, Dcel_>::
assign(const Self& other)
{
@ -82,7 +82,7 @@ assign(const Self& other)
//-----------------------------------------------------------------------------
// Make the necessary updates after the DCEL structure have been updated.
//
template <class GeomTraits, class Dcel_>
template <typename GeomTraits, typename Dcel_>
void Arr_unb_planar_topology_traits_2<GeomTraits, Dcel_>::dcel_updated ()
{
// Go over the DCEL vertices and locate the four fictitious ones.
@ -147,7 +147,7 @@ void Arr_unb_planar_topology_traits_2<GeomTraits, Dcel_>::dcel_updated ()
//-----------------------------------------------------------------------------
// Initialize an empty DCEL structure.
//
template <class GeomTraits, class Dcel_>
template <typename GeomTraits, typename Dcel_>
void Arr_unb_planar_topology_traits_2<GeomTraits, Dcel_>::init_dcel ()
{
// Clear the current DCEL.
@ -252,7 +252,7 @@ void Arr_unb_planar_topology_traits_2<GeomTraits, Dcel_>::init_dcel ()
//-----------------------------------------------------------------------------
// Check if the given vertex is associated with the given curve end.
//
template <class GeomTraits, class Dcel_>
template <typename GeomTraits, typename Dcel_>
bool Arr_unb_planar_topology_traits_2<GeomTraits, Dcel_>::
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 <class GeomTraits, class Dcel_>
template <typename GeomTraits, typename Dcel_>
CGAL::Object
Arr_unb_planar_topology_traits_2<GeomTraits, Dcel_>::
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 <class GeomTraits, class Dcel_>
template <typename GeomTraits, typename Dcel_>
CGAL::Object Arr_unb_planar_topology_traits_2<GeomTraits, Dcel_>::
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 <class GeomTraits, class Dcel_>
template <typename GeomTraits, typename Dcel_>
typename Arr_unb_planar_topology_traits_2<GeomTraits, Dcel_>::Halfedge*
Arr_unb_planar_topology_traits_2<GeomTraits, Dcel_>::
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 <class GeomTraits, class Dcel_>
template <typename GeomTraits, typename Dcel_>
bool Arr_unb_planar_topology_traits_2<GeomTraits, Dcel_>::
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 <class GeomTraits, class Dcel_>
template <typename GeomTraits, typename Dcel_>
bool Arr_unb_planar_topology_traits_2<GeomTraits, Dcel_>::
is_redundant(const Vertex *v) const
{
@ -529,7 +529,7 @@ is_redundant(const Vertex *v) const
//-----------------------------------------------------------------------------
// Erase the given redundant vertex.
//
template <class GeomTraits, class Dcel_>
template <typename GeomTraits, typename Dcel_>
typename Arr_unb_planar_topology_traits_2<GeomTraits, Dcel_>::Halfedge*
Arr_unb_planar_topology_traits_2<GeomTraits, Dcel_>::
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 <class GeomTraits, class Dcel_>
template <typename GeomTraits, typename Dcel_>
Comparison_result
Arr_unb_planar_topology_traits_2<GeomTraits, Dcel_>::
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 <class GeomTraits, class Dcel_>
template <typename GeomTraits, typename Dcel_>
Comparison_result
Arr_unb_planar_topology_traits_2<GeomTraits, Dcel_>::
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 <class GeomTraits, class Dcel_>
template <typename GeomTraits, typename Dcel_>
Comparison_result
Arr_unb_planar_topology_traits_2<GeomTraits, Dcel_>::
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())

View File

@ -15,7 +15,7 @@
// $URL$
// $Id$
// SPDX-License-Identifier: GPL-3.0+
//
//
//
// Author(s) : Ron Wein <wein@post.tau.ac.il>
// Efi Fogel <efif@post.tau.ac.il>
@ -25,82 +25,71 @@
#include <CGAL/license/Arrangement_on_surface_2.h>
/*! \file
*
* Definition of the Arr_unb_planar_vert_decomp_helper class-template.
*/
namespace CGAL {
#include <CGAL/Sweep_line_empty_visitor.h>
/*! \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 Traits_, class Arrangement_>
class Arr_unb_planar_vert_decomp_helper
{
template <typename Traits_, typename Arrangement_, typename Event_,
typename Subcurve_>
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<Traits_2> 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 <class Tr, class Arr>
void Arr_unb_planar_vert_decomp_helper<Tr, Arr>::before_sweep ()
template <typename Tr, typename Arr, typename Event_, typename Subcurve_>
void Arr_unb_planar_vert_decomp_helper<Tr, Arr, Event_, Subcurve_>::
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<Tr, Arr>::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 <class Tr, class Arr>
void Arr_unb_planar_vert_decomp_helper<Tr, Arr>::
after_handle_event (Event* event)
template <typename Tr, typename Arr, typename Evnt, typename Sbcv>
void Arr_unb_planar_vert_decomp_helper<Tr, Arr, Evnt, Sbcv>::
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

View File

@ -25,8 +25,8 @@
#include <CGAL/license/Arrangement_on_surface_2.h>
/*! \file
*
* Definition of the Arr_unb_planar_topology_traits_2<GeomTraits> class.
*/
@ -43,54 +43,57 @@
namespace CGAL {
// Forward declaration:
template <typename GeomTraits_, typename TopTraits_>
template <typename GeometryTraits_2, typename TopTraits_>
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 <typename GeomTraits_,
typename Dcel_ = Arr_default_dcel<GeomTraits_> >
template <typename GeometryTraits_2,
typename Dcel_ = Arr_default_dcel<GeometryTraits_2> >
class Arr_unb_planar_topology_traits_2 :
public Arr_planar_topology_traits_base_2<GeomTraits_, Dcel_>
public Arr_planar_topology_traits_base_2<GeometryTraits_2, Dcel_>
{
public:
typedef GeometryTraits_2 Geometry_traits_2;
typedef Dcel_ Dcel;
private:
typedef Arr_planar_topology_traits_base_2<GeomTraits_, Dcel_>
Base;
typedef Geometry_traits_2 Gt2;
typedef Arr_planar_topology_traits_base_2<Gt2, Dcel_> 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<Geometry_traits_2, Dcel> Self;
typedef Arr_traits_basic_adaptor_2<Geometry_traits_2> Traits_adaptor_2;
typedef Arr_unb_planar_topology_traits_2<Gt2, Dcel> Self;
typedef Arr_traits_basic_adaptor_2<Gt2> 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<Geometry_traits_2, Self> Arr;
typedef Arrangement_on_surface_2<Gt2, Self> Arr;
// Type definition for the constuction sweep-line visitor.
typedef Arr_construction_subcurve<Geometry_traits_2> CSubcurve;
typedef Arr_construction_event<Geometry_traits_2, CSubcurve, Arr>
CEvent;
typedef Arr_unb_planar_construction_helper<Geometry_traits_2,
Arr,
CEvent,
CSubcurve> CHelper;
// Type definition for the basic insertion sweep-line visitor.
typedef Arr_basic_insertion_traits_2<Geometry_traits_2, Arr> BInsTraits;
typedef Arr_construction_subcurve<BInsTraits> BISubcurve;
typedef Arr_construction_event<BInsTraits, BISubcurve, Arr>
BIEvent;
typedef Arr_unb_planar_insertion_helper<BInsTraits, Arr, BIEvent, BISubcurve>
BIHelper;
// Type definition for the insertion sweep-line visitor.
typedef Arr_insertion_traits_2<Geometry_traits_2, Arr> InsTraits;
typedef Arr_construction_subcurve<InsTraits> ISubcurve;
typedef Arr_construction_event<InsTraits, ISubcurve, Arr>
IEvent;
typedef Arr_unb_planar_insertion_helper<InsTraits, Arr, IEvent, ISubcurve>
IHelper;
// Type definition for the batched point-location sweep-line visitor.
typedef Arr_batched_point_location_traits_2<Arr> BplTraits;
typedef Arr_unb_planar_batched_pl_helper<BplTraits, Arr> BplHelper;
// Type definition for the vertical decomposition sweep-line visitor.
typedef Arr_batched_point_location_traits_2<Arr> VdTraits;
typedef Arr_unb_planar_vert_decomp_helper<VdTraits, Arr> VdHelper;
// Type definition for the overlay sweep-line visitor.
template <class ExGeomTraits_, class ArrangementA_, class ArrangementB_>
struct _Overlay_helper : public Arr_unb_planar_overlay_helper
<ExGeomTraits_, ArrangementA_, ArrangementB_, Arr,
Arr_construction_event<ExGeomTraits_,
Arr_overlay_subcurve<ExGeomTraits_>,
Arr>,
Arr_overlay_subcurve<ExGeomTraits_> >
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 <typename Evt, typename Crv>
struct Construction_helper :
public Arr_unb_planar_construction_helper<Gt2, Arr, Evt, Crv>
{
typedef Arr_unb_planar_overlay_helper
<ExGeomTraits_, ArrangementA_, ArrangementB_, Arr,
Arr_construction_event<ExGeomTraits_,
Arr_overlay_subcurve<ExGeomTraits_>,
Arr>,
Arr_overlay_subcurve<ExGeomTraits_> > 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<Gt2, Arr, Evt, Crv>
Base;
Construction_helper(Arr* arr) : Base(arr) {}
};
// Type definition for the no-intersection construction surface-sweep visitor.
template <typename Evt, typename Crv>
struct No_intersection_construction_helper :
public Arr_unb_planar_construction_helper<Gt2, Arr, Evt, Crv>
{
typedef Arr_unb_planar_construction_helper<Gt2, Arr, Evt, Crv>
Base;
No_intersection_construction_helper(Arr* arr) : Base(arr) {}
};
// Type definition for the insertion surface-sweep visitor.
typedef Arr_insertion_traits_2<Gt2, Arr> I_traits;
template <typename Evt, typename Crv>
struct Insertion_helper :
public Arr_unb_planar_insertion_helper<I_traits, Arr, Evt, Crv>
{
typedef Arr_unb_planar_insertion_helper<I_traits, Arr, Evt, Crv>
Base;
Insertion_helper(Arr* arr) : Base(arr) {}
};
// Type definition for the no-intersection insertion surface-sweep visitor.
typedef Arr_basic_insertion_traits_2<Gt2, Arr> Nxi_traits;
template <typename Evt, typename Crv>
struct No_intersection_insertion_helper :
public Arr_unb_planar_insertion_helper<Nxi_traits, Arr, Evt, Crv>
{
typedef Arr_unb_planar_insertion_helper<Nxi_traits, Arr, Evt, Crv>
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<Arr> Bpl_traits;
template <typename Evt, typename Crv>
struct Batched_point_location_helper :
public Arr_unb_planar_batched_pl_helper<Bpl_traits, Arr, Evt, Crv>
{
typedef Arr_unb_planar_batched_pl_helper<Bpl_traits, Arr, Evt, Crv>
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<Arr> Vd_traits;
template <typename Evt, typename Crv>
struct Vertical_decomposition_helper :
public Arr_unb_planar_vert_decomp_helper<Vd_traits, Arr, Evt, Crv>
{
typedef Arr_unb_planar_vert_decomp_helper<Vd_traits, Arr, Evt, Crv>
Base;
Vertical_decomposition_helper(const Arr* arr) : Base(arr) {}
};
// Type definition for the overlay surface-sweep visitor.
template <typename Gt, typename Evt, typename Crv,
typename ArrA, typename ArrB>
struct Overlay_helper :
public Arr_unb_planar_overlay_helper<Gt, ArrA, ArrB, Arr, Evt, Crv>
{
typedef Arr_unb_planar_overlay_helper<Gt, ArrA, ArrB, Arr, Evt, Crv>
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 <typename Evt, typename Crv>
using Construction_helper =
Arr_unb_planar_construction_helper<Gt2, Arr, Evt, Crv>;
// Type definition for the no-intersection construction surface-sweep visitor.
template <typename Evt, typename Crv>
using No_intersection_construction_helper =
Arr_unb_planar_construction_helper<Gt2, Arr, Evt, Crv>;
// Type definition for the insertion surface-sweep visitor.
typedef Arr_insertion_traits_2<Gt2, Arr> I_traits;
template <typename Evt, typename Crv>
using Insertion_helper =
Arr_unb_planar_insertion_helper<I_traits, Arr, Evt, Crv>;
// Type definition for the no-intersection insertion surface-sweep visitor.
typedef Arr_basic_insertion_traits_2<Gt2, Arr> Nxi_traits;
template <typename Evt, typename Crv>
using No_intersection_insertion_helper =
Arr_unb_planar_insertion_helper<Nxi_traits, Arr, Evt, Crv>;
// Type definition for the batched point-location surface-sweep visitor.
typedef Arr_batched_point_location_traits_2<Arr> Bpl_traits;
template <typename Evt, typename Crv>
using Batched_point_location_helper =
Arr_unb_planar_batched_pl_helper<Bpl_traits, Arr, Evt, Crv>;
// Type definition for the vertical decomposition surface-sweep visitor.
typedef Arr_batched_point_location_traits_2<Arr> Vd_traits;
template <typename Evt, typename Crv>
using Vertical_decomposition_helper =
Arr_unb_planar_vert_decomp_helper<Vd_traits, Arr, Evt, Crv>;
// Type definition for the overlay surface-sweep visitor.
template <typename Gt, typename Evt, typename Crv,
typename ArrA, typename ArrB>
using Overlay_helper =
Arr_unb_planar_overlay_helper<Gt, ArrA, ArrB, Arr, Evt, Crv>;
#endif
//@}
public:
///! \name Visitor types.
//@{
typedef Arr_construction_sl_visitor<CHelper>
Sweep_line_construction_visitor;
typedef Arr_insertion_sl_visitor<IHelper>
Sweep_line_insertion_visitor;
typedef Sweep_line_construction_visitor
Sweep_line_non_intersecting_construction_visitor;
typedef Arr_basic_insertion_sl_visitor<BIHelper>
Sweep_line_non_intersecting_insertion_visitor;
template <class OutputIterator_>
struct Sweep_line_batched_point_location_visitor :
public Arr_batched_pl_sl_visitor<BplHelper, OutputIterator_>
{
typedef OutputIterator_ Output_iterator;
typedef Arr_batched_pl_sl_visitor<BplHelper, Output_iterator> 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 <class OutputIterator_>
struct Sweep_line_vertical_decomposition_visitor :
public Arr_vert_decomp_sl_visitor<VdHelper, OutputIterator_>
{
typedef OutputIterator_ Output_iterator;
typedef Arr_vert_decomp_sl_visitor<VdHelper, Output_iterator>
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 <class ArrangementA_, class ArrangementB_, class OverlayTraits_>
struct Sweep_line_overlay_visitor :
public Arr_overlay_sl_visitor
<_Overlay_helper<Arr_overlay_traits_2<Geometry_traits_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<Geometry_traits_2,
ArrangementA_2,
ArrangementB_2> Geom_ovl_traits_2;
typedef _Overlay_helper<Geom_ovl_traits_2,
ArrangementA_2,
ArrangementB_2> Ovl_helper;
typedef Arr_overlay_sl_visitor<Ovl_helper,
Overlay_traits> 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<Arr>
Zone_insertion_visitor;
Zone_insertion_visitor;
typedef Arr_walk_along_line_point_location<Arr>
Default_point_location_strategy;
Default_point_location_strategy;
typedef Arr_walk_along_line_point_location<Arr>
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 <CGAL/Arr_topology_traits/Arr_unb_planar_topology_traits_2_impl.h>

View File

@ -23,9 +23,12 @@
#include <CGAL/license/Arrangement_on_surface_2.h>
#include <CGAL/Arrangement_on_surface_2.h>
#include <CGAL/Basic_sweep_line_2.h>
#include <CGAL/No_intersection_surface_sweep_2.h>
#include <CGAL/Arr_point_location/Arr_batched_point_location_traits_2.h>
#include <CGAL/Surface_sweep_2/No_overlap_event.h>
#include <CGAL/Surface_sweep_2/No_overlap_subcurve.h>
#include <CGAL/Surface_sweep_2/Arr_vert_decomp_ss_visitor.h>
#include <vector>
#include <boost/mpl/if.hpp>
@ -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<Vertex_const_handle, pair<Object, Object> >, where
* the Object represents a handle to an arrangement feature.
*/
template<typename GeomTraits, typename TopTraits,
typename OutputIterator>
template <typename GeometryTraits_2, typename TopologyTraits,
typename OutputIterator>
OutputIterator
decompose(const Arrangement_on_surface_2<GeomTraits, TopTraits>& arr,
decompose(const Arrangement_on_surface_2<GeometryTraits_2, TopologyTraits>& arr,
OutputIterator oi)
{
// Arrangement types:
typedef Arrangement_on_surface_2<GeomTraits, TopTraits> Arrangement_2;
typedef typename TopTraits::template
Sweep_line_vertical_decomposition_visitor<OutputIterator>
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<Gt2, Tt> 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<Arr> Vgt2;
typedef Ss2::No_overlap_event<Vgt2, Allocator> Vd_event;
typedef Ss2::No_overlap_subcurve<Vgt2, Vd_event, Allocator>
Vd_curve;
typedef typename Tt::template
Vertical_decomposition_helper<Vd_event, Vd_curve> Vd_helper;
typedef Arr_vert_decomp_ss_visitor<Vd_helper, Output_iterator>
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<Vd_x_monotone_curve_2> xcurves_vec (arr.number_of_edges());
Edge_const_iterator eit;
Halfedge_const_handle he;
unsigned int i = 0;
std::vector<Vd_x_monotone_curve_2> 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<Vd_point_2> iso_pts_vec (arr.number_of_isolated_vertices());
Vertex_const_iterator vit;
Vertex_const_handle iso_v;
std::vector<Vd_point_2> 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_<boost::is_same<GeomTraits, Vd_traits_2>,
const Vd_traits_2&, Vd_traits_2>::type
typename boost::mpl::if_<boost::is_same<Gt2, Vgt2>, 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<typename Vd_visitor::Traits_2,
Vd_visitor,
typename Vd_visitor::Subcurve,
typename Vd_visitor::Event>
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<Vd_visitor>
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

View File

@ -15,7 +15,7 @@
// $URL$
// $Id$
// SPDX-License-Identifier: GPL-3.0+
//
//
//
// Author(s): Ron Wein <wein@post.tau.ac.il>
// Eric Berberich <ericb@post.tau.ac.il>
@ -45,8 +45,8 @@ template <class GeomTraits, class Dcel, class Tag>
struct Default_planar_topology_impl {};
template <class GeomTraits, class Dcel>
struct Default_planar_topology_impl< GeomTraits, Dcel,
Arr_all_sides_oblivious_tag>
struct Default_planar_topology_impl<GeomTraits, Dcel,
Arr_all_sides_oblivious_tag>
{
// A topology-traits class that supports only bounded curves:
typedef Arr_bounded_planar_topology_traits_2<GeomTraits, Dcel> Traits;
@ -54,25 +54,24 @@ struct Default_planar_topology_impl< GeomTraits, Dcel,
};
template <class GeomTraits, class Dcel>
struct Default_planar_topology_impl< GeomTraits, Dcel,
Arr_not_all_sides_oblivious_tag>
struct Default_planar_topology_impl<GeomTraits, Dcel,
Arr_not_all_sides_oblivious_tag>
{
// A topology-traits class that supports unbounded curves:
typedef Arr_unb_planar_topology_traits_2<GeomTraits, Dcel> 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 <typename GeomTraits, typename 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
>
{};

View File

@ -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 <CGAL/license/Arrangement_on_surface_2.h>
#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

View File

@ -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<Geometry_traits_2> Traits_adaptor_2;

View File

@ -15,82 +15,104 @@
// $URL$
// $Id$
// SPDX-License-Identifier: GPL-3.0+
//
//
//
// Author(s) : Baruch Zukerman <baruchzu@post.tau.ac.il>
// Ron Wein <wein@post.tau.ac.il>
// Efi Fogel <efif@post.tau.ac.il>
#ifndef CGAL_ARR_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 <CGAL/license/Sweep_line_2.h>
#include <CGAL/license/Arrangement_on_surface_2.h>
/*!
* Definition of the Arr_batched_pl_sl_visitor class-template.
/*! \file
*
* Definition of the Arr_batched_pl_ss_visitor class-template.
*/
#include <CGAL/Arr_point_location_result.h>
#include <CGAL/Object.h>
#include <boost/variant.hpp>
#include <boost/optional.hpp>
#include <CGAL/Surface_sweep_2/Default_visitor_base.h>
#include <CGAL/Default.h>
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 Helper_, class OutputIterator_>
class Arr_batched_pl_sl_visitor : public Helper_::Base_visitor {
template <typename Helper_, typename OutputIterator, typename Visitor_ = Default>
class Arr_batched_pl_ss_visitor :
public Ss2::Default_visitor_base<typename Helper_::Geometry_traits_2,
typename Helper_::Event,
typename Helper_::Subcurve,
typename Helper_::Allocator,
typename Default::Get<
Visitor_,
Arr_batched_pl_ss_visitor<
Helper_, OutputIterator,
Visitor_> >::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<Helper, Output_iterator, Visitor_>
Self;
typedef typename Default::Get<Visitor_, Self>::type Visitor;
typedef typename Ss2::Default_visitor_base<Gt2, Event, Subcurve, Allocator,
Visitor> 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<Arrangement_2> 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<typename T>
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 <class Hlpr, class OutIt>
void Arr_batched_pl_sl_visitor<Hlpr, OutIt>::before_sweep()
template <typename Hlpr, typename OutIt, typename Vis>
void Arr_batched_pl_ss_visitor<Hlpr, OutIt, Vis>::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 <class Hlpr, class OutIt>
bool Arr_batched_pl_sl_visitor<Hlpr, OutIt>::
template <typename Hlpr, typename OutIt, typename Vis>
bool Arr_batched_pl_ss_visitor<Hlpr, OutIt, Vis>::
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

View File

@ -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 <talizvi@post.tau.ac.il>
// Baruch Zukerman <baruchzu@post.tau.ac.il>
// Efi Fogel <efif@post.tau.ac.il>
#ifndef CGAL_ARR_CONSTRUCTION_EVENT_H
#define CGAL_ARR_CONSTRUCTION_EVENT_H
#include <CGAL/license/Arrangement_on_surface_2.h>
/*! \file
*
* Definition of the Arr_construction_event class-template.
*/
#include <CGAL/Surface_sweep_2/Default_event_base.h>
#include <CGAL/Surface_sweep_2/Arr_construction_event_base.h>
#include <CGAL/Surface_sweep_2/Arr_construction_subcurve.h>
#include <CGAL/Surface_sweep_2/Default_subcurve.h>
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 <typename GeometryTraits_2, typename Arrangement_,
typename Allocator_ = CGAL_ALLOCATOR(int),
template <typename, typename>
class SurfaceSweepBaseEvent = Ss2::Default_event_base,
template <typename, typename, typename, typename>
class SurfaceSweepBaseCurve = Ss2::Default_subcurve>
class Arr_construction_event :
public Arr_construction_event_base<
GeometryTraits_2,
Arr_construction_subcurve<GeometryTraits_2,
Arr_construction_event<GeometryTraits_2,
Arrangement_,
Allocator_,
SurfaceSweepBaseEvent,
SurfaceSweepBaseCurve>,
Allocator_,
SurfaceSweepBaseCurve>,
Arrangement_, SurfaceSweepBaseEvent>
{
public:
/*! Construct default. */
Arr_construction_event() {}
};
} // namespace CGAL
#endif

View File

@ -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 <talizvi@post.tau.ac.il>
// Baruch Zukerman <baruchzu@post.tau.ac.il>
// Efi Fogel <efif@post.tau.ac.il>
#ifndef CGAL_ARR_CONSTRUCTION_EVENT_BASE_H
#define CGAL_ARR_CONSTRUCTION_EVENT_BASE_H
#include <CGAL/license/Arrangement_on_surface_2.h>
/*! \file
*
* Definition of the Arr_construction_event_base class-template.
*/
#include <vector>
#include <CGAL/Surface_sweep_2/Default_event_base.h>
#include <CGAL/assertions.h>
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 <typename GeometryTraits_2, typename Subcurve_, typename Arrangement_,
template <typename, typename>
class SurfaceSweepEvent = Ss2::Default_event_base>
class Arr_construction_event_base :
public SurfaceSweepEvent<GeometryTraits_2, Subcurve_>
{
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<Gt2, Subcurve> Base;
typedef Arr_construction_event_base<Gt2, Subcurve, Halfedge_handle,
SurfaceSweepEvent> 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<bool> 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<bool, Subcurve_iterator>
add_curve_to_right(Subcurve* curve, const Gt2* tr)
{
std::pair<bool,Subcurve_iterator> 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<bool, Subcurve_iterator>
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

View File

@ -21,26 +21,31 @@
// Ron Wein <wein@post.tau.ac.il>
// Efi Fogel <efifogel@gmail.com>
#ifndef CGAL_ARR_CONSTRUCTION_SL_VISITOR_H
#define CGAL_ARR_CONSTRUCTION_SL_VISITOR_H
#include <CGAL/license/Sweep_line_2.h>
#ifndef CGAL_ARR_CONSTRUCTION_SS_VISITOR_H
#define CGAL_ARR_CONSTRUCTION_SS_VISITOR_H
#include <CGAL/license/Arrangement_on_surface_2.h>
#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 <vector>
#include <CGAL/Arr_accessor.h>
#include <CGAL/Unique_hash_map.h>
#include <vector>
#include <CGAL/Surface_sweep_2/Default_visitor_base.h>
#include <CGAL/Default.h>
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 <typename Helper_>
class Arr_construction_sl_visitor : public Helper_::Base_visitor {
template <typename Helper_, typename Visitor_ = Default>
class Arr_construction_ss_visitor :
public Ss2::Default_visitor_base<typename Helper_::Geometry_traits_2,
typename Helper_::Event,
typename Helper_::Subcurve,
typename Helper_::Allocator,
typename Default::Get<
Visitor_,
Arr_construction_ss_visitor<
Helper_, Visitor_> >::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<Helper, Visitor_> Self;
typedef typename Default::Get<Visitor_, Self>::type Visitor;
typedef Ss2::Default_visitor_base<Gt2, Event, Subcurve, Allocator, Visitor>
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<unsigned int, Vertex_handle, Integer_hash_function>
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<Event*>((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 <typename Hlpr>
void Arr_construction_sl_visitor<Hlpr>::before_sweep()
template <typename Hlpr, typename Vis>
void Arr_construction_ss_visitor<Hlpr, Vis>::before_sweep()
{ m_helper.before_sweep(); }
//-----------------------------------------------------------------------------
// A notification invoked before the sweep-line starts handling the given
// event.
//
template <class Hlpr>
void Arr_construction_sl_visitor<Hlpr>::before_handle_event(Event* event)
template <class Hlpr, typename Vis>
void Arr_construction_ss_visitor<Hlpr, Vis>::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<Hlpr>::before_handle_event(Event* event)
// A notification invoked after the sweep-line finishes handling the given
// event.
//
template <typename Hlpr>
bool Arr_construction_sl_visitor<Hlpr>::
template <typename Hlpr, typename Vis>
bool Arr_construction_ss_visitor<Hlpr, Vis>::
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 <typename Hlpr>
void Arr_construction_sl_visitor<Hlpr>::
template <typename Hlpr, typename Vis>
void Arr_construction_ss_visitor<Hlpr, Vis>::
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 Hlpr>
typename Arr_construction_sl_visitor<Hlpr>::Halfedge_handle
Arr_construction_sl_visitor<Hlpr>::
template <typename Hlpr, typename Vis>
typename Arr_construction_ss_visitor<Hlpr, Vis>::Halfedge_handle
Arr_construction_ss_visitor<Hlpr, Vis>::
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 Hlpr>
typename Arr_construction_sl_visitor<Hlpr>::Halfedge_handle
Arr_construction_sl_visitor<Hlpr>::
template <typename Hlpr, typename Vis>
typename Arr_construction_ss_visitor<Hlpr, Vis>::Halfedge_handle
Arr_construction_ss_visitor<Hlpr, Vis>::
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 Hlpr>
typename Arr_construction_sl_visitor<Hlpr>::Halfedge_handle
Arr_construction_sl_visitor<Hlpr>::
template <typename Hlpr, typename Vis>
typename Arr_construction_ss_visitor<Hlpr, Vis>::Halfedge_handle
Arr_construction_ss_visitor<Hlpr, Vis>::
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 Hlpr>
typename Arr_construction_sl_visitor<Hlpr>::Halfedge_handle
Arr_construction_sl_visitor<Hlpr>::
template <typename Hlpr, typename Vis>
typename Arr_construction_ss_visitor<Hlpr, Vis>::Halfedge_handle
Arr_construction_ss_visitor<Hlpr, Vis>::
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 Hlpr>
typename Arr_construction_sl_visitor<Hlpr>::Vertex_handle
Arr_construction_sl_visitor<Hlpr>::
template <typename Hlpr, typename Vis>
typename Arr_construction_ss_visitor<Hlpr, Vis>::Vertex_handle
Arr_construction_ss_visitor<Hlpr, Vis>::
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 <typename Hlpr>
void Arr_construction_sl_visitor<Hlpr>::relocate_in_new_face(Halfedge_handle he)
template <typename Hlpr, typename Vis>
void Arr_construction_ss_visitor<Hlpr, Vis>::
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<Hlpr>::relocate_in_new_face(Halfedge_handle he)
//-----------------------------------------------------------------------------
// Map the given subcurve index to the given halfedge handle.
//
template <typename Hlpr>
void Arr_construction_sl_visitor<Hlpr>::
template <typename Hlpr, typename Vis>
void Arr_construction_ss_visitor<Hlpr, Vis>::
_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

View File

@ -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 <talizvi@post.tau.ac.il>
// Baruch Zukerman <baruchzu@post.tau.ac.il>
#ifndef CGAL_ARR_CONSTRUCTION_SUBCURVE_H
#define CGAL_ARR_CONSTRUCTION_SUBCURVE_H
#include <CGAL/license/Arrangement_on_surface_2.h>
/*! \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 <CGAL/Surface_sweep_2/Default_subcurve.h>
#include <CGAL/Default.h>
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 <typename GeometryTraits_2, typename Event_, typename Allocator_,
template <typename, typename, typename, typename>
class SurfaceSweepBaseCurve,
typename Subcurve_>
class Arr_construction_subcurve_base :
public SurfaceSweepBaseCurve<GeometryTraits_2, Event_, Allocator_, Subcurve_>
{
public:
typedef GeometryTraits_2 Geometry_traits_2;
typedef Subcurve_ Subcurve;
typedef Event_ Event;
typedef Allocator_ Allocator;
private:
typedef Geometry_traits_2 Gt2;
typedef SurfaceSweepBaseCurve<Gt2, Event, Allocator, Subcurve>
Base;
public:
typedef typename Gt2::X_monotone_curve_2 X_monotone_curve_2;
typedef Event* Event_ptr;
typedef std::list<unsigned int> 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 <typename SweepEvent>
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 <typename GeometryTraits_2, typename Event_,
typename Allocator_ = CGAL_ALLOCATOR(int),
template <typename, typename, typename, typename>
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<Subcurve_,
Arr_construction_subcurve<GeometryTraits_2, Event_,
Allocator_,
SurfaceSweepBaseCurve,
Subcurve_> >::type>
{
public:
typedef GeometryTraits_2 Geometry_traits_2;
typedef Event_ Event;
typedef Allocator_ Allocator;
private:
typedef Geometry_traits_2 Gt2;
typedef Arr_construction_subcurve<Gt2, Event, Allocator,
SurfaceSweepBaseCurve, Subcurve_>
Self;
typedef typename Default::Get<Subcurve_, Self>::type Subcurve;
typedef Arr_construction_subcurve_base<Gt2, Event, Allocator,
SurfaceSweepBaseCurve, Subcurve>
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

View File

@ -15,25 +15,25 @@
// $URL$
// $Id$
// SPDX-License-Identifier: GPL-3.0+
//
//
//
// Author(s) : Ron Wein <baruchzu@post.tau.ac.il>
// Baruch Zukerman <baruchzu@post.tau.ac.il>
/*! \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 <CGAL/license/Sweep_line_2.h>
#include <CGAL/license/Arrangement_on_surface_2.h>
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.
*/

View File

@ -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 <baruchzu@post.tau.ac.il>
// Ron Wein <wein@post.tau.ac.il>
// Efi Fogel <efif@post.tau.ac.il>
#ifndef CGAL_ARR_INSERTION_SS_VISITOR_H
#define CGAL_ARR_INSERTION_SS_VISITOR_H
#include <CGAL/license/Arrangement_on_surface_2.h>
/*! \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 <CGAL/Surface_sweep_2/Arr_no_intersection_insertion_ss_visitor.h>
#include <CGAL/Default.h>
namespace CGAL {
/*! \class Arr_insertion_ss_visitor
*
* A sweep-line visitor for inserting new curves into an existing arrangement
* embedded on a surface.
*/
template <typename Helper_, typename Visitor_ = Default>
class Arr_insertion_ss_visitor :
public Arr_no_intersection_insertion_ss_visitor<
Helper_,
typename Default::Get<Visitor_,
Arr_insertion_ss_visitor<Helper_, Visitor_> >::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<Helper, Visitor_> Self;
typedef typename Default::Get<Visitor_, Self>::type Visitor;
typedef Arr_no_intersection_insertion_ss_visitor<Helper, 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 <typename Hlpr, typename Vis>
bool Arr_insertion_ss_visitor<Hlpr, Vis>::
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 Hlpr, typename Vis>
typename Arr_insertion_ss_visitor<Hlpr, Vis>::Halfedge_handle
Arr_insertion_ss_visitor<Hlpr, Vis>::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 <typename Hlpr, typename Vis>
void Arr_insertion_ss_visitor<Hlpr, Vis>::
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

View File

@ -15,7 +15,7 @@
// $URL$
// $Id$
// SPDX-License-Identifier: GPL-3.0+
//
//
//
// Author(s) : Baruch Zukerman <baruchzu@post.tau.ac.il>
// Efi Fogel <efif@post.tau.ac.il>
@ -23,61 +23,64 @@
#ifndef CGAL_ARR_INSERTION_TRAITS_2_H
#define CGAL_ARR_INSERTION_TRAITS_2_H
#include <CGAL/license/Sweep_line_2.h>
#include <CGAL/license/Arrangement_on_surface_2.h>
/*!
/*! \file
*
* Defintion of the Arr_insertion_traits_2<Traits,Arrangement> class.
*/
#include <CGAL/Sweep_line_2/Arr_basic_insertion_traits_2.h>
#include <CGAL/Surface_sweep_2/Arr_basic_insertion_traits_2.h>
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 <typename Traits_, typename Arrangement_>
class Arr_insertion_traits_2 :
public Arr_basic_insertion_traits_2<Traits_, Arrangement_>
template <typename GeometryTraits_2, typename Arrangement_2_>
class Arr_insertion_traits_2 :
public Arr_basic_insertion_traits_2<GeometryTraits_2, Arrangement_2_>
{
public:
typedef GeometryTraits_2 Geometry_traits_2;
typedef Arrangement_2_ Arrangement_2;
typedef Traits_ Traits_2;
typedef Arr_basic_insertion_traits_2<Traits_, Arrangement_> Base;
private:
typedef Geometry_traits_2 Gt2;
typedef Arrangement_2 Arr2;
typedef Arr_basic_insertion_traits_2<Gt2, Arr2> 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<Traits_2, Arrangement_>;
friend class Arr_insertion_traits_2<Gt2, Arrangement_2>;
public:
template<typename OutputIterator>
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<Base_point_2, unsigned int> *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<Base_point_2, unsigned int>* 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<Base_x_monotone_curve_2> (&(*oi));
if (base_overlap_cv != NULL)
{
// X_monotone_curve_2
for(; oi != oi_end; ++oi) {
base_overlap_cv = object_cast<Base_x_monotone_curve_2>(&(*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<std::pair<Base_point_2, unsigned int> > (&(*oi));
else {
intersect_p =
object_cast<std::pair<Base_point_2, unsigned int> >(&(*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<Traits_2, Arrangement_>;
friend class Arr_insertion_traits_2<Gt2, Arrangement_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

View File

@ -15,55 +15,75 @@
// $URL$
// $Id$
// SPDX-License-Identifier: GPL-3.0+
//
//
//
// Author(s) : Baruch Zukerman <baruchzu@post.tau.ac.il>
// Ron Wein <wein@post.tau.ac.il>
// Efi Fogel <efif@post.tau.ac.il>
#ifndef CGAL_ARR_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 <CGAL/license/Sweep_line_2.h>
#include <CGAL/license/Arrangement_on_surface_2.h>
/*!
* 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 <CGAL/Surface_sweep_2/Arr_construction_ss_visitor.h>
#include <CGAL/Default.h>
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 <typename Helper_>
class Arr_basic_insertion_sl_visitor : public Helper_::Parent_visitor {
template <typename Helper_, typename Visitor_ = Default>
class Arr_no_intersection_insertion_ss_visitor :
public Arr_construction_ss_visitor<
Helper_,
typename Default::Get<Visitor_, Arr_no_intersection_insertion_ss_visitor<
Helper_, Visitor_> >::type>
{
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<Helper, Visitor_>
Self;
typedef typename Default::Get<Visitor_, Self>::type Visitor;
typedef Arr_construction_ss_visitor<Helper, 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 <typename Hlpr>
void Arr_basic_insertion_sl_visitor<Hlpr>::before_sweep()
template <typename Hlpr, typename Vis>
void Arr_no_intersection_insertion_ss_visitor<Hlpr, Vis>::before_sweep()
{ this->m_helper.before_sweep(); }
//-----------------------------------------------------------------------------
// A notification invoked before the sweep-line starts handling the given
// event.
//
template <typename Hlpr>
void Arr_basic_insertion_sl_visitor<Hlpr>::before_handle_event(Event* event)
template <typename Hlpr, typename Vis>
void Arr_no_intersection_insertion_ss_visitor<Hlpr, Vis>::
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<Hlpr>::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<Hlpr>::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<Hlpr>::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<X_monotone_curve_2&>((*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<Hlpr>::before_handle_event(Event* event)
}
//-----------------------------------------------------------------------------
// A notification invoked when a new subcurve is created.
// Add a new curve.
//
template <typename Hlpr>
void Arr_basic_insertion_sl_visitor<Hlpr>::
add_subcurve(const X_monotone_curve_2& cv, Subcurve* sc)
template <typename Hlpr, typename Vis>
bool Arr_no_intersection_insertion_ss_visitor<Hlpr, Vis>::
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 <typename Hlpr, typename Vis>
void Arr_no_intersection_insertion_ss_visitor<Hlpr, Vis>::
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 Hlpr>
typename Arr_basic_insertion_sl_visitor<Hlpr>::Halfedge_handle
Arr_basic_insertion_sl_visitor<Hlpr>::
template <typename Hlpr, typename Vis>
typename Arr_no_intersection_insertion_ss_visitor<Hlpr, Vis>::Halfedge_handle
Arr_no_intersection_insertion_ss_visitor<Hlpr, Vis>::
insert_in_face_interior(const X_monotone_curve_2& cv, Subcurve* sc)
{
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 Hlpr>
typename Arr_basic_insertion_sl_visitor<Hlpr>::Halfedge_handle
Arr_basic_insertion_sl_visitor<Hlpr>::
template <typename Hlpr, typename Vis>
typename Arr_no_intersection_insertion_ss_visitor<Hlpr, Vis>::Halfedge_handle
Arr_no_intersection_insertion_ss_visitor<Hlpr, Vis>::
insert_from_left_vertex(const X_monotone_curve_2& cv, Halfedge_handle he,
Subcurve* sc)
{
@ -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 Hlpr>
typename Arr_basic_insertion_sl_visitor<Hlpr>::Halfedge_handle
Arr_basic_insertion_sl_visitor<Hlpr>::
template <typename Hlpr, typename Vis>
typename Arr_no_intersection_insertion_ss_visitor<Hlpr, Vis>::Halfedge_handle
Arr_no_intersection_insertion_ss_visitor<Hlpr, Vis>::
insert_from_right_vertex(const X_monotone_curve_2& cv, Halfedge_handle he,
Subcurve* sc)
{
@ -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 Hlpr>
typename Arr_basic_insertion_sl_visitor<Hlpr>::Halfedge_handle
Arr_basic_insertion_sl_visitor<Hlpr>::
template <typename Hlpr, typename Vis>
typename Arr_no_intersection_insertion_ss_visitor<Hlpr, Vis>::Halfedge_handle
Arr_no_intersection_insertion_ss_visitor<Hlpr, Vis>::
insert_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 Hlpr>
typename Arr_basic_insertion_sl_visitor<Hlpr>::Vertex_handle
Arr_basic_insertion_sl_visitor<Hlpr>::
template <typename Hlpr, typename Vis>
typename Arr_no_intersection_insertion_ss_visitor<Hlpr, Vis>::Vertex_handle
Arr_no_intersection_insertion_ss_visitor<Hlpr, Vis>::
insert_isolated_vertex(const Point_2& pt, Status_line_iterator iter)
{
// 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 Hlpr>
typename Arr_basic_insertion_sl_visitor<Hlpr>::Halfedge_handle
Arr_basic_insertion_sl_visitor<Hlpr>::
template <typename Hlpr, typename Vis>
typename Arr_no_intersection_insertion_ss_visitor<Hlpr, Vis>::Halfedge_handle
Arr_no_intersection_insertion_ss_visitor<Hlpr, Vis>::
_insert_in_face_interior(const X_monotone_curve_2& cv, Subcurve* sc)
{
// 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 Hlpr>
typename Arr_basic_insertion_sl_visitor<Hlpr>::Halfedge_handle
Arr_basic_insertion_sl_visitor<Hlpr>::
template <typename Hlpr, typename Vis>
typename Arr_no_intersection_insertion_ss_visitor<Hlpr, Vis>::Halfedge_handle
Arr_no_intersection_insertion_ss_visitor<Hlpr, Vis>::
_insert_from_left_vertex(const X_monotone_curve_2& cv,
Halfedge_handle prev, Subcurve* sc)
{
@ -538,9 +560,9 @@ _insert_from_left_vertex(const X_monotone_curve_2& cv,
//-----------------------------------------------------------------------------
// Perform the actual insertion
//
template <typename Hlpr>
typename Arr_basic_insertion_sl_visitor<Hlpr>::Halfedge_handle
Arr_basic_insertion_sl_visitor<Hlpr>::
template <typename Hlpr, typename Vis>
typename Arr_no_intersection_insertion_ss_visitor<Hlpr, Vis>::Halfedge_handle
Arr_no_intersection_insertion_ss_visitor<Hlpr, Vis>::
_insert_from_right_vertex(const X_monotone_curve_2& cv, Halfedge_handle prev,
Subcurve* sc)
{
@ -575,9 +597,9 @@ _insert_from_right_vertex(const X_monotone_curve_2& cv, Halfedge_handle prev,
//-----------------------------------------------------------------------------
// Perform the actual insertion
//
template <typename Hlpr>
typename Arr_basic_insertion_sl_visitor<Hlpr>::Halfedge_handle
Arr_basic_insertion_sl_visitor<Hlpr>::
template <typename Hlpr, typename Vis>
typename Arr_no_intersection_insertion_ss_visitor<Hlpr, Vis>::Halfedge_handle
Arr_no_intersection_insertion_ss_visitor<Hlpr, Vis>::
_insert_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 Hlpr>
typename Arr_basic_insertion_sl_visitor<Hlpr>::Face_handle
Arr_basic_insertion_sl_visitor<Hlpr>::_ray_shoot_up(Status_line_iterator iter)
template <typename Hlpr, typename Vis>
typename Arr_no_intersection_insertion_ss_visitor<Hlpr, Vis>::Face_handle
Arr_no_intersection_insertion_ss_visitor<Hlpr, Vis>::
_ray_shoot_up(Status_line_iterator iter)
{
// 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<Hlpr>::_ray_shoot_up(Status_line_iterator iter)
return (this->m_helper.top_face());
}
} //namespace CGAL
} // namespace CGAL
#endif

View File

@ -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 <talizvi@post.tau.ac.il>
// Baruch Zukerman <baruchzu@post.tau.ac.il>
// Efi Fogel <efif@post.tau.ac.il>
#ifndef CGAL_ARR_OVERLAY_EVENT_H
#define CGAL_ARR_OVERLAY_EVENT_H
#include <CGAL/license/Arrangement_on_surface_2.h>
/*! \file
*
* Definition of the Arr_construction_event_base class-template.
*/
#include <CGAL/Surface_sweep_2/Arr_construction_event_base.h>
#include <CGAL/Surface_sweep_2/Arr_overlay_subcurve.h>
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 <typename GeometryTraits_2, typename Arrangement_,
typename Allocator_ = CGAL_ALLOCATOR(int)>
class Arr_overlay_event :
public Arr_construction_event_base<GeometryTraits_2,
Arr_overlay_subcurve<GeometryTraits_2,
Arr_overlay_event<
GeometryTraits_2,
Arrangement_,
Allocator_>,
Allocator_>,
Arrangement_>
{
public:
/*! Construct default. */
Arr_overlay_event() {}
};
} // namespace CGAL
#endif

View File

@ -21,14 +21,14 @@
// Ron Wein <wein@post.tau.ac.il>
// Efi Fogel <efif@post.tau.ac.il>
#ifndef CGAL_ARR_OVERLAY_SL_VISITOR_H
#define CGAL_ARR_OVERLAY_SL_VISITOR_H
#include <CGAL/license/Sweep_line_2.h>
#ifndef CGAL_ARR_OVERLAY_SS_VISITOR_H
#define CGAL_ARR_OVERLAY_SS_VISITOR_H
#include <CGAL/license/Arrangement_on_surface_2.h>
/*! \file
* Definition of the Arr_overlay_sl_visitor class-template.
*
* Definition of the Arr_overlay_ss_visitor class-template.
*/
#include <boost/variant.hpp>
@ -37,82 +37,100 @@
#include <boost/variant/apply_visitor.hpp>
#include <CGAL/Arr_tags.h>
#include <CGAL/Sweep_line_2/Arr_construction_sl_visitor.h>
#include <CGAL/Surface_sweep_2/Arr_construction_ss_visitor.h>
#include <CGAL/Unique_hash_map.h>
#include <CGAL/Default.h>
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 <typename OverlayHelper_, typename OverlayTraits_>
class Arr_overlay_sl_visitor : public
Arr_construction_sl_visitor<typename OverlayHelper_::Construction_helper>
template <typename OverlayHelper, typename OverlayTraits,
typename Visitor_ = Default>
class Arr_overlay_ss_visitor :
public Arr_construction_ss_visitor<
typename OverlayHelper::Construction_helper,
typename Default::Get<Visitor_,
Arr_overlay_ss_visitor<OverlayHelper, OverlayTraits,
Visitor_> >::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<Overlay_helper, Overlay_traits, Visitor_>
Self;
typedef typename Default::Get<Visitor_, Self>::type Visitor;
typedef Arr_construction_ss_visitor<Construction_helper, 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<Construction_helper> 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_handle_red, Halfedge_handle_blue>
Halfedge_info;
typedef Unique_hash_map<Halfedge_handle,Halfedge_info> Halfedge_map;
Halfedge_info;
typedef Unique_hash_map<Halfedge_handle, Halfedge_info>
Halfedge_map;
typedef std::pair<Cell_handle_red, Cell_handle_blue> Handle_info;
typedef std::pair<Cell_handle_red, Cell_handle_blue> Handle_info;
typedef boost::unordered_map<Vertex_handle, Handle_info, Handle_hash_function>
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<Left_side_category,
Bottom_side_category>::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 <typename OvlHlpr, typename OvlTr>
void Arr_overlay_sl_visitor<OvlHlpr, OvlTr>::before_sweep()
template <typename OvlHlpr, typename OvlTr, typename Vis>
void Arr_overlay_ss_visitor<OvlHlpr, OvlTr, Vis>::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<OvlHlpr, OvlTr>::before_sweep()
// A notification invoked before the sweep-line starts handling the given
// event.
//
template <typename OvlHlpr, typename OvlTr>
void Arr_overlay_sl_visitor<OvlHlpr, OvlTr>::before_handle_event(Event* event)
template <typename OvlHlpr, typename OvlTr, typename Vis>
void
Arr_overlay_ss_visitor<OvlHlpr, OvlTr, Vis>::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<OvlHlpr, OvlTr>::before_handle_event(Event* event)
// A notification invoked after the sweep-line finishes handling the given
// event.
//
template <typename OvlHlpr, typename OvlTr>
bool Arr_overlay_sl_visitor<OvlHlpr, OvlTr>::
template <typename OvlHlpr, typename OvlTr, typename Vis>
bool Arr_overlay_ss_visitor<OvlHlpr, OvlTr, Vis>::
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 <typename OvlHlpr, typename OvlTr>
void Arr_overlay_sl_visitor<OvlHlpr, OvlTr>::
template <typename OvlHlpr, typename OvlTr, typename Vis>
void Arr_overlay_ss_visitor<OvlHlpr, OvlTr, Vis>::
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 <typename OvlHlpr, typename OvlTr>
void Arr_overlay_sl_visitor<OvlHlpr, OvlTr>::update_event(Event* e,
Subcurve* sc)
template <typename OvlHlpr, typename OvlTr, typename Vis>
void Arr_overlay_ss_visitor<OvlHlpr, OvlTr, Vis>::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<OvlHlpr, OvlTr>::update_event(Event* e,
//-----------------------------------------------------------------------------
// Update an event.
//
template <typename OvlHlpr, typename OvlTr>
void Arr_overlay_sl_visitor<OvlHlpr, OvlTr>::update_event(Event* e,
template <typename OvlHlpr, typename OvlTr, typename Vis>
void
Arr_overlay_ss_visitor<OvlHlpr, OvlTr, Vis>::update_event(Event* e,
const Point_2& p,
bool /* is_new */)
{
@ -536,8 +556,8 @@ void Arr_overlay_sl_visitor<OvlHlpr, OvlTr>::update_event(Event* e,
//-----------------------------------------------------------------------------
// A notification issued when the sweep process has ended.
//
template <typename OvlHlpr, typename OvlTr>
void Arr_overlay_sl_visitor<OvlHlpr, OvlTr>::after_sweep()
template <typename OvlHlpr, typename OvlTr, typename Vis>
void Arr_overlay_ss_visitor<OvlHlpr, OvlTr, Vis>::after_sweep()
{
// Notify boundary vertices:
typename Vertex_map::iterator it;
@ -562,9 +582,9 @@ void Arr_overlay_sl_visitor<OvlHlpr, OvlTr>::after_sweep()
//-----------------------------------------------------------------------------
// Insert the given subcurve in the interior of an arrangement face.
//
template <typename OvlHlpr, typename OvlTr>
typename Arr_overlay_sl_visitor<OvlHlpr, OvlTr>::Halfedge_handle
Arr_overlay_sl_visitor<OvlHlpr, OvlTr>::
template <typename OvlHlpr, typename OvlTr, typename Vis>
typename Arr_overlay_ss_visitor<OvlHlpr, OvlTr, Vis>::Halfedge_handle
Arr_overlay_ss_visitor<OvlHlpr, OvlTr, Vis>::
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 OvlHlpr, typename OvlTr>
typename Arr_overlay_sl_visitor<OvlHlpr, OvlTr>::Halfedge_handle
Arr_overlay_sl_visitor<OvlHlpr, OvlTr>::
template <typename OvlHlpr, typename OvlTr, typename Vis>
typename Arr_overlay_ss_visitor<OvlHlpr, OvlTr, Vis>::Halfedge_handle
Arr_overlay_ss_visitor<OvlHlpr, OvlTr, Vis>::
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 OvlHlpr, typename OvlTr>
typename Arr_overlay_sl_visitor<OvlHlpr, OvlTr>::Halfedge_handle
Arr_overlay_sl_visitor<OvlHlpr, OvlTr>::
template <typename OvlHlpr, typename OvlTr, typename Vis>
typename Arr_overlay_ss_visitor<OvlHlpr, OvlTr, Vis>::Halfedge_handle
Arr_overlay_ss_visitor<OvlHlpr, OvlTr, Vis>::
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 OvlHlpr, typename OvlTr>
typename Arr_overlay_sl_visitor<OvlHlpr, OvlTr>::Halfedge_handle
Arr_overlay_sl_visitor<OvlHlpr, OvlTr>::
template <typename OvlHlpr, typename OvlTr, typename Vis>
typename Arr_overlay_ss_visitor<OvlHlpr, OvlTr, Vis>::Halfedge_handle
Arr_overlay_ss_visitor<OvlHlpr, OvlTr, Vis>::
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 OvlHlpr, typename OvlTr>
typename Arr_overlay_sl_visitor<OvlHlpr, OvlTr>::Vertex_handle
Arr_overlay_sl_visitor<OvlHlpr, OvlTr>::
template <typename OvlHlpr, typename OvlTr, typename Vis>
typename Arr_overlay_ss_visitor<OvlHlpr, OvlTr, Vis>::Vertex_handle
Arr_overlay_ss_visitor<OvlHlpr, OvlTr, Vis>::
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 <typename OvlHlpr, typename OvlTr>
void Arr_overlay_sl_visitor<OvlHlpr, OvlTr>::
template <typename OvlHlpr, typename OvlTr, typename Vis>
void Arr_overlay_ss_visitor<OvlHlpr, OvlTr, Vis>::
_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 <typename OvlHlpr, typename OvlTr>
void Arr_overlay_sl_visitor<OvlHlpr, OvlTr>::
template <typename OvlHlpr, typename OvlTr, typename Vis>
void Arr_overlay_ss_visitor<OvlHlpr, OvlTr, Vis>::
_map_boundary_vertices(Event* event, Vertex_handle v, boost::mpl::bool_<true>)
{
// 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_<true>)
//-----------------------------------------------------------------------------
// Update the boundary vertices map.
//
template <typename OvlHlpr, typename OvlTr>
void Arr_overlay_sl_visitor<OvlHlpr, OvlTr>::
_map_boundary_vertices(Event* /* event */, Vertex_handle /* v */, boost::mpl::bool_<false>)
template <typename OvlHlpr, typename OvlTr, typename Vis>
void Arr_overlay_ss_visitor<OvlHlpr, OvlTr, Vis>::
_map_boundary_vertices(Event* /* event */, Vertex_handle /* v */,
boost::mpl::bool_<false>)
{}
/* 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 <typename OvlHlpr, typename OvlTr>
void Arr_overlay_sl_visitor<OvlHlpr, OvlTr>::
template <typename OvlHlpr, typename OvlTr, typename Vis>
void Arr_overlay_ss_visitor<OvlHlpr, OvlTr, Vis>::
_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 <typename OvlHlpr, typename OvlTr>
void Arr_overlay_sl_visitor<OvlHlpr, OvlTr>::
template <typename OvlHlpr, typename OvlTr, typename Vis>
void Arr_overlay_ss_visitor<OvlHlpr, OvlTr, Vis>::
_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 <typename OvlHlpr, typename OvlTr>
void
Arr_overlay_sl_visitor<OvlHlpr, OvlTr>::_create_edge(Subcurve* sc,
Halfedge_handle new_he)
template <typename OvlHlpr, typename OvlTr, typename Vis>
void Arr_overlay_ss_visitor<OvlHlpr, OvlTr, Vis>::
_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<OvlHlpr, OvlTr>::_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<OvlHlpr, OvlTr>::_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<OvlHlpr, OvlTr>::_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<OvlHlpr, OvlTr>::_create_edge(Subcurve* sc,
}
}
} //namespace CGAL
} // namespace CGAL
#endif

View File

@ -15,7 +15,7 @@
// $URL$
// $Id$
// SPDX-License-Identifier: GPL-3.0+
//
//
//
// Author(s) : Baruch Zukerman <baruchzu@post.tau.ac.il>
// Ron Wein <wein@post.tau.ac.il>
@ -23,52 +23,71 @@
#ifndef CGAL_OVERLAY_SUBCURVE_H
#define CGAL_OVERLAY_SUBCURVE_H
#include <CGAL/license/Sweep_line_2.h>
#include <CGAL/license/Arrangement_on_surface_2.h>
/*! \file
*
* Definition of the Arr_overlay_subcurve class-template.
*/
#include <CGAL/Sweep_line_2/Arr_construction_subcurve.h>
#include <CGAL/Surface_sweep_2/Default_subcurve.h>
#include <CGAL/Surface_sweep_2/Arr_construction_subcurve.h>
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 Traits_>
class Arr_overlay_subcurve : public Arr_construction_subcurve<Traits_>
template <typename GeometryTraits_2, typename Event_,
typename Allocator_ = CGAL_ALLOCATOR(int)>
class Arr_overlay_subcurve :
public Arr_construction_subcurve<GeometryTraits_2, Event_, Allocator_,
Ss2::Default_subcurve,
Arr_overlay_subcurve<GeometryTraits_2,
Event_,
Allocator_> >
{
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<Gt2, Event, Allocator> Self;
typedef Arr_construction_subcurve<Gt2, Event, Allocator, Ss2::Default_subcurve,
Self> Base;
typedef Arr_construction_subcurve<Traits_2> Base;
typedef Arr_overlay_subcurve<Traits_2> 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<Traits_2, Self> 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

View File

@ -15,7 +15,7 @@
// $URL$
// $Id$
// SPDX-License-Identifier: GPL-3.0+
//
//
//
// Author(s) : Baruch Zukerman <baruchzu@post.tau.ac.il>
// Ron Wein <wein@post.tau.ac.il>
@ -24,10 +24,10 @@
#ifndef CGAL_ARR_OVERLAY_TRAITS_2_H
#define CGAL_ARR_OVERLAY_TRAITS_2_H
#include <CGAL/license/Sweep_line_2.h>
#include <CGAL/license/Arrangement_on_surface_2.h>
/*!
/*! \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 <typename GeometryTraits_, typename ArrangementRed_,
typename ArrangementBlue_>
template <typename GeometryTraits_2, typename ArrangementRed_2,
typename ArrangementBlue_2>
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<Traits_2>::Category
Left_side_category;
typedef typename internal::Arr_complete_bottom_side_category<Traits_2>::Category
Bottom_side_category;
typedef typename internal::Arr_complete_top_side_category<Traits_2>::Category
Top_side_category;
typedef typename internal::Arr_complete_right_side_category<Traits_2>::Category
Right_side_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<Gt2>::Category
Bottom_side_category;
typedef typename internal::Arr_complete_top_side_category<Gt2>::Category
Top_side_category;
typedef typename internal::Arr_complete_right_side_category<Gt2>::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<Halfedge_handle_blue, Vertex_handle_blue,
Face_handle_blue> Cell_handle_blue;
typedef boost::optional<Cell_handle_blue> Optional_cell_blue;
template <typename Handle_red>
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 <typename Handle_blue>
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<Traits_2,
Arrangement_red_2, Arrangement_blue_2>;
friend class Arr_overlay_traits_2<Gt2, Ar2, Ab2>;
public:
template<class OutputIterator>
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<std::pair<Base_point_2, unsigned int> >(&(*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<Traits_2,
Arrangement_red_2, Arrangement_blue_2>;
friend class Arr_overlay_traits_2<Gt2, Ar2, Ab2>;
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<Traits_2,
Arrangement_red_2, Arrangement_blue_2>;
friend class Arr_overlay_traits_2<Gt2, Ar2, Ab2>;
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<Traits_2,
Arrangement_red_2, Arrangement_blue_2>;
friend class Arr_overlay_traits_2<Gt2, Ar2, Ab2>;
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<Traits_2,
Arrangement_red_2, Arrangement_blue_2>;
friend class Arr_overlay_traits_2<Gt2, Ar2, Ab2>;
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<Traits_2,
Arrangement_red_2, Arrangement_blue_2>;
friend class Arr_overlay_traits_2<Gt2, Ar2, Ab2>;
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<Traits_2,
Arrangement_red_2, Arrangement_blue_2>;
friend class Arr_overlay_traits_2<Gt2, Ar2, Ab2>;
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<Traits_2,
Arrangement_red_2, Arrangement_blue_2>;
friend class Arr_overlay_traits_2<Gt2, Ar2, Ab2>;
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<Traits_2,
Arrangement_red_2, Arrangement_blue_2>;
friend class Arr_overlay_traits_2<Gt2, Ar2, Ab2>;
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<Traits_2,
Arrangement_red_2, Arrangement_blue_2>;
friend class Arr_overlay_traits_2<Gt2, Ar2, Ab2>;
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<Traits_2,
Arrangement_red_2, Arrangement_blue_2>;
friend class Arr_overlay_traits_2<Gt2, Ar2, Ab2>;
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<Traits_2,
Arrangement_red_2, Arrangement_blue_2>;
friend class Arr_overlay_traits_2<Gt2, Ar2, Ab2>;
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<Traits_2,
Arrangement_red_2, Arrangement_blue_2>;
friend class Arr_overlay_traits_2<Gt2, Ar2, Ab2>;
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<Traits_2,
Arrangement_red_2, Arrangement_blue_2>;
friend class Arr_overlay_traits_2<Gt2, Ar2, Ab2>;
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<Traits_2,
Arrangement_red_2, Arrangement_blue_2>;
friend class Arr_overlay_traits_2<Gt2, Ar2, Ab2>;
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<Traits_2,
Arrangement_red_2, Arrangement_blue_2>;
friend class Arr_overlay_traits_2<Gt2, Ar2, Ab2>;
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<Traits_2,
Arrangement_red_2, Arrangement_blue_2>;
friend class Arr_overlay_traits_2<Gt2, Ar2, Ab2>;
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<Traits_2,
Arrangement_red_2, Arrangement_blue_2>;
friend class Arr_overlay_traits_2<Gt2, Ar2, Ab2>;
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<Traits_2,
Arrangement_red_2, Arrangement_blue_2>;
friend class Arr_overlay_traits_2<Gt2, Ar2, Ab2>;
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<Traits_2,
Arrangement_red_2, Arrangement_blue_2>;
friend class Arr_overlay_traits_2<Gt2, Ar2, Ab2>;
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

View File

@ -18,102 +18,115 @@
//
//
// Author(s) : Ron Wein <wein@post.tau.ac.il>
// Efi Fogel <efifogel@gmail.com>
#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 <CGAL/license/Sweep_line_2.h>
#include <CGAL/license/Arrangement_on_surface_2.h>
/*!
* Definition of the Arr_vert_decomp_sl_visitor class-template.
/*! \file
*
* Definition of the Arr_vert_decomp_ss_visitor class-template.
*/
namespace CGAL {
#include <CGAL/Surface_sweep_2/Default_visitor_base.h>
#include <CGAL/Object.h>
#include <CGAL/Default.h>
/*! \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 Helper_, class OutputIterator_>
class Arr_vert_decomp_sl_visitor :
public Helper_::Base_visitor
template <typename Helper_, typename OutputIterator, typename Visitor_ = Default>
class Arr_vert_decomp_ss_visitor :
public Ss2::Default_visitor_base<typename Helper_::Geometry_traits_2,
typename Helper_::Event,
typename Helper_::Subcurve,
typename Helper_::Allocator,
typename Default::Get<
Visitor_,
Arr_vert_decomp_ss_visitor<
Helper_, OutputIterator,
Visitor_> >::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<Helper, Output_iterator, Visitor_>
Self;
typedef typename Default::Get<Visitor_, Self>::type Visitor;
typedef typename Ss2::Default_visitor_base<Gt2, Event, Subcurve, Allocator,
Visitor> Base;
public:
typedef typename Helper::Arrangement_2 Arrangement_2;
typedef typename Arrangement_2::Vertex_const_handle Vertex_const_handle;
typedef std::pair<CGAL::Object, CGAL::Object> Vert_pair;
typedef std::pair<Vertex_const_handle, Vert_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 <class Hlpr, class OutIt>
void Arr_vert_decomp_sl_visitor<Hlpr, OutIt>::before_sweep ()
template <typename Hlpr, typename OutIt, typename Vis>
void Arr_vert_decomp_ss_visitor<Hlpr, OutIt, Vis>::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 <class Hlpr, class OutIt>
bool Arr_vert_decomp_sl_visitor<Hlpr, OutIt>::after_handle_event
(Event* event,
Status_line_iterator above, bool /* on_above */)
template <class Hlpr, class OutIt, typename Vis>
bool Arr_vert_decomp_ss_visitor<Hlpr, OutIt, Vis>::
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<Hlpr, OutIt>::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<Hlpr, OutIt>::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<Hlpr, OutIt>::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<Hlpr, OutIt>::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<Hlpr, OutIt>::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 <class Hlpr, class OutIt>
void Arr_vert_decomp_sl_visitor<Hlpr, OutIt>::after_sweep ()
template <typename Hlpr, typename OutIt, typename Vis>
void Arr_vert_decomp_ss_visitor<Hlpr, OutIt, Vis>::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

View File

@ -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

View File

@ -18,7 +18,7 @@ int main()
#include <CGAL/Algebraic_kernel_d_1.h> //Algebraic Kernel
#include <CGAL/Arr_rational_function_traits_2.h> //Traits
#include <CGAL/Arrangement_2.h> //Arrangement
#include <CGAL/Sweep_line_2_algorithms.h>
#include <CGAL/Surface_sweep_2_algorithms.h>
#include <boost/foreach.hpp>
typedef CGAL::CORE_arithmetic_kernel::Integer Number_type;

View File

@ -15,16 +15,15 @@
// $URL$
// $Id$
// SPDX-License-Identifier: GPL-3.0+
//
//
//
// Author(s) : Baruch Zukerman <baruchzu@post.tau.ac.il>
#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 <CGAL/license/Boolean_set_operations_2.h>
#include <vector>
#include <boost/mpl/assert.hpp>
#include <CGAL/Boolean_set_operations_2/Gps_traits_decorator.h>
@ -33,7 +32,7 @@
namespace CGAL {
template <class Arrangement_>
template <typename Arrangement_>
class Gps_agg_curve_data : public Curve_with_halfedge<Arrangement_>
{
protected:
@ -41,15 +40,14 @@ protected:
typedef typename Arrangement::Halfedge_handle Halfedge_handle;
typedef Curve_with_halfedge<Arrangement_> 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 <class Arrangement_>
template <typename Arrangement_>
class Gps_agg_meta_traits :
public Gps_traits_decorator<typename Arrangement_::Traits_adaptor_2,
Gps_agg_curve_data<Arrangement_>,
Point_with_vertex<Arrangement_> >
{
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<Traits> Self;
typedef Gps_traits_decorator<Traits,
Gps_agg_curve_data<Arrangement_>,
Point_with_vertex<Arrangement_> >
Base;
public:
typedef typename Gt2::Multiplicity Multiplicity;
typedef Gps_agg_curve_data<Arr> Curve_data;
typedef Point_with_vertex<Arr> 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<Gt2, Curve_data, Point_data>
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<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> >));
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<class OutputIterator>
OutputIterator operator() (const X_monotone_curve_2& cv1,
const X_monotone_curve_2& cv2,
OutputIterator oi) const
template <typename OutputIterator>
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_Point_2, Multiplicity> *base_pt;
const Base_X_monotone_curve_2 *overlap_cv;
const std::pair<Base_Point_2, Multiplicity>* 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<std::pair<Base_Point_2, Multiplicity> >(&(*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<Base_X_monotone_curve_2> (&(*oi));
else {
overlap_cv = object_cast<Base_X_monotone_curve_2>(&(*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

View File

@ -19,130 +19,118 @@
// Author(s) : Baruch Zukerman <baruchzu@post.tau.ac.il>
// Ophir Setter <ophir.setter@cs.tau.ac.il>
#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 <CGAL/license/Boolean_set_operations_2.h>
/*!
\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 <CGAL/Boolean_set_operations_2/Gps_agg_meta_traits.h>
#include <CGAL/Boolean_set_operations_2/Gps_agg_op_sweep.h>
#include <CGAL/Sweep_line_2/Arr_construction_subcurve.h>
#include <CGAL/Sweep_line_2/Arr_construction_event.h>
#include <CGAL/Boolean_set_operations_2/Gps_agg_op_surface_sweep_2.h>
#include <CGAL/Boolean_set_operations_2/Indexed_event.h>
#include <CGAL/Surface_sweep_2/Arr_construction_subcurve.h>
#include <CGAL/Boolean_set_operations_2/Gps_agg_op_visitor.h>
#include <CGAL/Boolean_set_operations_2/Gps_bfs_scanner.h>
//#include <CGAL/Boolean_set_operations_2/Gps_insertion_meta_traits.h>
#include <CGAL/Unique_hash_map.h>
#include <CGAL/Unique_hash_map.h>
#include <CGAL/Arr_accessor.h>
#include <CGAL/iterator.h>
#include <CGAL/iterator.h>
namespace CGAL {
template <class Arrangement_, class Bfs_visitor_>
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<Arrangement_2> 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 <typename Arrangement_, typename BfsVisitor>
class Gps_agg_op {
typedef Arrangement_ Arrangement_2;
typedef BfsVisitor Bfs_visitor;
typedef std::pair<Arrangement_2 *,
std::vector<Vertex_handle> *> Arr_entry;
typedef typename Arrangement_2::Traits_adaptor_2 Geometry_traits_2;
typedef typename Arrangement_2::Topology_traits Topology_traits;
typedef Arr_construction_subcurve<Meta_traits> Subcurve;
typedef Arrangement_2 Arr;
typedef Geometry_traits_2 Gt2;
typedef Topology_traits Tt;
typedef Arr_construction_event<Meta_traits,
Subcurve,
// Halfedge_handle> Base_event;
Arrangement_2> Base_event;
typedef typename Gt2::Curve_const_iterator Curve_const_iterator;
typedef Gps_agg_meta_traits<Arr> Mgt2;
typedef typename Mgt2::Curve_data Curve_data;
typedef typename Mgt2::X_monotone_curve_2 Meta_X_monotone_curve_2;
typedef Indexed_event<Base_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<Meta_traits,
Arrangement_2,
Event,
Subcurve> Visitor;
typedef std::pair<Arr*, std::vector<Vertex_handle> *> Arr_entry;
typedef Gps_agg_op_sweep_line_2<Arrangement_2,
Meta_traits,
Visitor,
Subcurve,
Event> 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<Mgt2, Arr, Allocator> Event;
typedef Arr_construction_subcurve<Mgt2, Event, Allocator>
Subcurve;
typedef typename Tt::template Construction_helper<Event, Subcurve>
Helper_tmp;
typedef typename Helper_tmp::template rebind<Mgt2, Arr, Event, Subcurve>::other
Helper;
typedef Gps_agg_op_visitor<Helper, Arr> Visitor;
typedef Gps_agg_op_surface_sweep_2<Arr, Visitor> Surface_sweep_2;
typedef Unique_hash_map<Halfedge_handle,
unsigned int> Edges_hash;
typedef Unique_hash_map<Halfedge_handle, unsigned int>
Edges_hash;
typedef Unique_hash_map<Face_handle, unsigned int> Faces_hash;
typedef Gps_bfs_scanner<Arr, Bfs_visitor> Bfs_scanner;
typedef Unique_hash_map<Face_handle,
unsigned int> Faces_hash;
typedef Bfs_visitor_ Bfs_visitor;
typedef Gps_bfs_scanner<Arrangement_2, Bfs_visitor> 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<Vertex_handle>& 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<Vertex_handle>& 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_entry>& arr_vec)
void sweep_arrangements(unsigned int lower, unsigned int upper,
unsigned int jump, std::vector<Arr_entry>& arr_vec)
{
std::list<Meta_X_monotone_curve_2> 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

View File

@ -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 <baruchzu@post.tau.ac.il>
// Ron Wein <wein@post.tau.ac.il>
#ifndef CGAL_BSO_2_GSP_AGG_OP_SURFACE_SWEEP_2_H
#define CGAL_BSO_2_GSP_AGG_OP_SURFACE_SWEEP_2_H
#include <vector>
#include <CGAL/license/Boolean_set_operations_2.h>
#include <CGAL/Surface_sweep_2.h>
#include <CGAL/Unique_hash_map.h>
namespace CGAL {
namespace Ss2 = Surface_sweep_2;
template <typename Arrangement_, typename Visitor_>
class Gps_agg_op_surface_sweep_2 : public Ss2::Surface_sweep_2<Visitor_> {
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*, std::vector<Vertex_handle> *> Arr_entry;
typedef Ss2::Surface_sweep_2<Visitor> 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<Subcurve*> 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 <class CurveInputIterator>
void sweep(CurveInputIterator curves_begin, CurveInputIterator curves_end,
unsigned int lower, unsigned int upper, unsigned int jump,
std::vector<Arr_entry>& arr_vec)
{
CGAL_assertion(this->m_queue->empty() && this->m_statusLine.size() == 0);
typedef Unique_hash_map<Vertex_handle, Event*> 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<unsigned int>(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<unsigned int>((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<unsigned int>((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

View File

@ -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 <baruchzu@post.tau.ac.il>
// Ron Wein <wein@post.tau.ac.il>
#ifndef CGAL_GSP_AGG_OP_SWEEP_H
#define CGAL_GSP_AGG_OP_SWEEP_H
#include <CGAL/license/Boolean_set_operations_2.h>
#include <CGAL/Sweep_line_2.h>
#include <CGAL/Unique_hash_map.h>
namespace CGAL {
template <class Arrangement_,
class MetaTraits_,
class SweepVisitor,
class CurveWrap,
class SweepEvent,
typename Allocator = CGAL_ALLOCATOR(int) >
class Gps_agg_op_sweep_line_2 :
public Sweep_line_2<MetaTraits_,
SweepVisitor,
CurveWrap,
SweepEvent,
Allocator>
{
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<Arrangement_2 *,
std::vector<Vertex_handle> *> Arr_entry;
typedef Sweep_line_2<Traits_2,
SweepVisitor,
CurveWrap,
SweepEvent,
Allocator> 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<Subcurve*> 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<class CurveInputIterator>
void sweep (CurveInputIterator curves_begin,
CurveInputIterator curves_end,
unsigned int lower,
unsigned int upper,
unsigned int jump,
std::vector<Arr_entry>& arr_vec)
{
CGAL_assertion (this->m_queue->empty() &&
this->m_statusLine.size() == 0);
typedef Unique_hash_map<Vertex_handle, Event *> 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<unsigned int>(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<unsigned int>((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<unsigned int>((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

View File

@ -15,307 +15,237 @@
// $URL$
// $Id$
// SPDX-License-Identifier: GPL-3.0+
//
//
//
// Author(s) : Baruch Zukerman <baruchzu@post.tau.ac.il>
// Ron Wein <wein@post.tau.ac.il>
#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 <CGAL/license/Boolean_set_operations_2.h>
#include <CGAL/Unique_hash_map.h>
#include <CGAL/Sweep_line_2/Arr_construction_sl_visitor.h>
#include <boost/mpl/if.hpp>
#include <boost/type_traits/is_same.hpp>
#include <CGAL/Unique_hash_map.h>
#include <CGAL/Surface_sweep_2/Arr_construction_ss_visitor.h>
#include <CGAL/Arr_tags.h>
#include <CGAL/Arr_topology_traits/Arr_bounded_planar_construction_helper.h>
#include <CGAL/Arr_topology_traits/Arr_unb_planar_construction_helper.h>
#include <CGAL/Default.h>
namespace CGAL {
template<class Traits, class Arrangement_, class Event,class Subcurve>
template <typename Helper_, typename Arrangement_, typename Visitor_ = Default>
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<Traits,
Arrangement_,
Event,
Subcurve>,
Arr_unb_planar_construction_helper<Traits,
Arrangement_,
Event,
Subcurve>
>::type
>
public Arr_construction_ss_visitor<
Helper_,
typename Default::Get<Visitor_, Gps_agg_op_base_visitor<Helper_,
Arrangement_,
Visitor_> >::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<Traits,
Arrangement,
Event,
Subcurve>,
Arr_unb_planar_construction_helper<Traits,
Arrangement,
Event,
Subcurve>
>::type Construction_helper;
typedef Arr_construction_sl_visitor<Construction_helper> 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<Halfedge_handle, unsigned int> 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<Helper, Arr, Visitor_>
Self;
typedef typename Default::Get<Visitor_, Self>::type Visitor;
typedef Arr_construction_ss_visitor<Helper, 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<Halfedge_handle, unsigned int>
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 BaseEvent_>
class Indexed_event : public BaseEvent_
template <typename Helper_, typename Arrangement_, typename Visitor_ = Default>
class Gps_agg_op_visitor :
public Gps_agg_op_base_visitor<Helper_, Arrangement_,
Gps_agg_op_visitor<Helper_, Arrangement_,
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<Helper, Arr, Visitor_> Self;
typedef typename Default::Get<Visitor_, Self>::type Visitor;
typedef Gps_agg_op_base_visitor<Helper, Arr, 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 Traits, class Arrangement_, class Event, class Subcurve>
class Gps_agg_op_visitor :
public Gps_agg_op_base_visitor<Traits, Arrangement_, Event, Subcurve>
{
protected:
typedef Arrangement_ Arrangement;
typedef Gps_agg_op_base_visitor<Traits,
Arrangement,
Event,
Subcurve> 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<Vertex_handle> *m_vertices_vec; // The vertices, sorted in
// ascending order.
unsigned int m_event_count; // The number of events so far.
std::vector<Vertex_handle>* m_vertices_vec; // The vertices, sorted in
// ascending order.
public:
Gps_agg_op_visitor (Arrangement *arr,
typename Base::Edges_hash* hash,
std::vector<Vertex_handle>* 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<Vertex_handle>* 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<Event*>(this->current_event());
Event *last_event = reinterpret_cast<Event*>((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<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);
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<Event*>(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

View File

@ -19,90 +19,97 @@
//
// Author(s) : Baruch Zukerman <baruchzu@post.tau.ac.il>
#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 <CGAL/license/Boolean_set_operations_2.h>
#include <CGAL/Boolean_set_operations_2/Gps_simplifier_traits.h>
#include <CGAL/Sweep_line_2.h>
#include <CGAL/Sweep_line_2/Arr_construction_subcurve.h>
#include <CGAL/Sweep_line_2/Arr_construction_event.h>
#include <CGAL/Boolean_set_operations_2/Gps_agg_op_visitor.h>
#include <CGAL/Surface_sweep_2.h>
#include <CGAL/Surface_sweep_2/Arr_construction_subcurve.h>
#include <CGAL/Surface_sweep_2/Arr_construction_event.h>
#include <CGAL/Boolean_set_operations_2/Gps_bfs_scanner.h>
#include <CGAL/Boolean_set_operations_2/Gps_bfs_join_visitor.h>
#include <CGAL/Unique_hash_map.h>
#include <CGAL/Arr_accessor.h>
#include <CGAL/iterator.h>
namespace CGAL {
template <class Arrangement_>
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<Traits_2> 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 <typename Arrangement_>
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<Gt2> 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<Meta_traits> Subcurve;
typedef Arr_construction_event<Meta_traits,
Subcurve,
Arrangement_2> Event;
typedef typename Arr::Ccb_halfedge_circulator Ccb_halfedge_circulator;
typedef typename Arr::Allocator Allocator;
typedef Gps_agg_op_base_visitor<Meta_traits,
Arrangement_2,
Event,
Subcurve> 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<Mgt2, Arr, Allocator> Event;
typedef Arr_construction_subcurve<Mgt2, Event, Allocator>
Subcurve;
typedef typename Tt::template Construction_helper<Event, Subcurve>
Helper_tmp;
typedef typename Helper_tmp::template rebind<Mgt2, Arr, Event, Subcurve>::other
Helper;
typedef Gps_agg_op_base_visitor<Helper, Arr> Visitor;
typedef Ss2::Surface_sweep_2<Visitor> Surface_sweep_2;
typedef CGAL::Sweep_line_2<Meta_traits,
Visitor,
Subcurve,
Event> Sweep_line_2;
typedef Unique_hash_map<Halfedge_handle, unsigned int>
Edges_hash;
typedef Unique_hash_map<Halfedge_handle,
unsigned int> Edges_hash;
typedef Unique_hash_map<Face_handle,
unsigned int> Faces_hash;
typedef Gps_bfs_join_visitor<Arrangement_2> Bfs_visitor;
typedef Gps_bfs_scanner<Arrangement_2, Bfs_visitor> Bfs_scanner;
typedef Unique_hash_map<Face_handle, unsigned int> Faces_hash;
typedef Gps_bfs_join_visitor<Arr> Bfs_visitor;
typedef Gps_bfs_scanner<Arr, Bfs_visitor> 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<const Traits_2*>(m_traits)->construct_curves_2_object();
reinterpret_cast<const Gt2*>(m_traits)->construct_curves_2_object();
std::list<Meta_X_monotone_curve_2> curves_list;
std::pair<Curve_const_iterator,
Curve_const_iterator> itr_pair = ctr_curves(pgn);
std::pair<Curve_const_iterator, Curve_const_iterator> 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<unsigned int>(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

View File

@ -22,35 +22,30 @@
// Boris Kozorovitzky <boriskoz@post.tau.ac.il>
// Guy Zucker <guyzucke@post.tau.ac.il>
#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 <CGAL/license/Boolean_set_operations_2.h>
#include <CGAL/Boolean_set_operations_2/Gps_traits_adaptor.h>
#include <CGAL/Boolean_set_operations_2/Gps_default_dcel.h>
#include <CGAL/Boolean_set_operations_2/Gps_on_surface_base_2.h>
#include <CGAL/Arrangement_2/Arr_default_planar_topology.h>
#include <CGAL/Sweep_line_2.h>
#include <CGAL/Sweep_line_2/Sweep_line_event.h>
#include <CGAL/Sweep_line_2/Sweep_line_subcurve.h>
#include <CGAL/Sweep_line_empty_visitor.h>
#include <CGAL/Surface_sweep_2.h>
#include <CGAL/Surface_sweep_2/Default_visitor.h>
#include <CGAL/Arr_default_overlay_traits.h>
#include <CGAL/Arr_naive_point_location.h>
#include <iostream>
#include <list>
#include <iterator>
namespace CGAL {
/*Arrangement is templated with extended face dcel*/
namespace Ss2 = Surface_sweep_2;
template <typename Arrangement_2>
class ValidationOverlayTraits :
class Validation_overlay_traits :
public CGAL::Arr_default_overlay_traits<Arrangement_2>
{
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 <class ArrTraits_>
template <typename GeometryTraits_2, typename Allocator_ = CGAL_ALLOCATOR(int)>
class Gps_polygon_validation_visitor :
public Sweep_line_empty_visitor<ArrTraits_>
public Ss2::Default_visitor<Gps_polygon_validation_visitor<GeometryTraits_2,
Allocator_>,
GeometryTraits_2, Allocator_>
{
public:
typedef GeometryTraits_2 Geometry_traits_2;
typedef Allocator_ Allocator;
private:
typedef ArrTraits_ Traits_2;
typedef Gps_polygon_validation_visitor<Traits_2> 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<Traits_2> Base;
typedef typename Base::Event Event;
typedef typename Base::Subcurve Subcurve;
typedef typename Base::Status_line_iterator SL_iterator;
typedef Basic_sweep_line_2<Traits_2, Self> Sweep_line;
typedef Geometry_traits_2 Gt2;
typedef Gps_polygon_validation_visitor<Gt2, Allocator>
Self;
typedef Ss2::Default_visitor<Self, Gt2, Allocator> 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 <class XCurveIterator>
void sweep(XCurveIterator begin, XCurveIterator end)
{
//Perform the sweep
reinterpret_cast<Sweep_line*>(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<Sweep_line*>(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<Sweep_line*>(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<Sweep_line*>(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<Sweep_line*>(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 <typename Traits_2>
@ -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 <typename Traits_2>
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<Curve_const_iterator,Curve_const_iterator> Cci_pair;
typedef typename Traits_2::Curve_const_iterator Curve_const_iterator;
typedef std::pair<Curve_const_iterator,Curve_const_iterator>
Cci_pair;
// Sweep the boundary curves and look for intersections.
typedef Gps_polygon_validation_visitor<Traits_2> Visitor;
typedef Sweep_line_2<Traits_2, Visitor> Sweep_line;
typedef Gps_polygon_validation_visitor<Traits_2> Visitor;
typedef Ss2::Surface_sweep_2<Visitor> 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 <typename Traits_2>
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<class Traits_2, class PointLocation>
template <typename Traits_2, typename PointLocation>
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<typename Traits_2>
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<Traits_2> Dcel;
// IMPORTATNT! TODO!
// Currently the topology traits is the bounded planar traits. This
@ -490,25 +488,25 @@ template <typename Traits_2>
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<Curve_const_iterator,Curve_const_iterator> 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<Curve_const_iterator,Curve_const_iterator>
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<Traits_2> Visitor;
typedef Sweep_line_2<Traits_2, Visitor> 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<Traits_2> Visitor;
typedef Ss2::Surface_sweep_2<Visitor> 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<X_monotone_curve_2> 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_2> Traits_adapter_2;
typedef typename Traits_2::Curve_const_iterator Curve_const_iterator;
typedef std::pair<Curve_const_iterator,Curve_const_iterator> Cci_pair;
typedef std::pair<Curve_const_iterator,Curve_const_iterator>
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 <class Traits_2>
template <typename Traits_2>
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<Curve_const_iterator,Curve_const_iterator> Cci_pair;
typedef typename Traits_2::Construct_curves_2 Construct_curves_2;
typedef CGAL::Gps_default_dcel<Traits_2> Dcel;
typedef typename Traits_2::Curve_const_iterator Curve_const_iterator;
typedef std::pair<Curve_const_iterator, Curve_const_iterator>
Cci_pair;
typedef typename Traits_2::Construct_curves_2 Construct_curves_2;
typedef CGAL::Gps_default_dcel<Traits_2> 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_2, Dcel>::Traits
Topology_traits;
Topology_traits;
typedef CGAL::Gps_on_surface_base_2<Traits_2, Topology_traits>
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<Curve_const_iterator,Curve_const_iterator>
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<Curve_const_iterator, Curve_const_iterator>
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<Traits_2> Visitor;
typedef Sweep_line_2<Traits_2, Visitor> Sweep_line ;
typedef typename Polygon_set_2::Arrangement_on_surface_2 Arrangement_2;
typedef Gps_polygon_validation_visitor<Traits_2> Visitor;
typedef Ss2::Surface_sweep_2<Visitor> 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<X_monotone_curve_2> 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<Arrangement_2> valOverlayTraits;
Validation_overlay_traits<Arrangement_2> 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

View File

@ -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 <baruchzu@post.tau.ac.il>
// Ron Wein <wein@post.tau.ac.il>
// Efi Fogel <efifogel@gmail.com>
#ifndef CGAL_BSO_2_INDEXED_VISITOR_H
#define CGAL_BSO_2_INDEXED_VISITOR_H
#include <CGAL/license/Boolean_set_operations_2.h>
#include <CGAL/Surface_sweep_2/Arr_construction_event_base.h>
namespace CGAL {
/* \class Indexed_event
*/
template <typename GeometryTraits_2, typename Arrangement_,
typename Allocator_ = CGAL_ALLOCATOR(int)>
class Indexed_event :
public Arr_construction_event_base<
GeometryTraits_2,
Arr_construction_subcurve<GeometryTraits_2,
Indexed_event<GeometryTraits_2,
Arrangement_,
Allocator_>,
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

View File

@ -15,7 +15,7 @@
// $URL$
// $Id$
// SPDX-License-Identifier: LGPL-3.0+
//
//
//
// Author(s) : Sebastien Loriot, Sylvain Pion
@ -29,9 +29,9 @@
#endif
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Arr_circle_segment_traits_2.h>
#include <CGAL/Sweep_line_2_algorithms.h>
#include <CGAL/Surface_sweep_2_algorithms.h>
#include <CGAL/Object.h>
#include <CGAL/CGAL_Ipelet_base.h>
#include <CGAL/CGAL_Ipelet_base.h>
namespace CGAL_argt{
@ -44,7 +44,7 @@ typedef std::list<Curve_2> Curve_list;
typedef std::list<X_monotone_curve_2> 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<Kernel,2>{
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<Segment_2> sg_list;
std::list<Circle_2> cir_list;
std::list<Polygon_2> pol_list;
std::list<Circular_arc_2> arc_list;
read_active_objects(
CGAL::dispatch_or_drop_output<Polygon_2,Circle_2,Segment_2,Circular_arc_2>(
std::back_inserter(pol_list),
@ -87,13 +87,13 @@ void ArrPolyIpelet::protected_run(int fn){
for (std::list<Polygon_2>::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<Segment_2>::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<Circle_2>::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<Circular_arc_2>::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()));

View File

@ -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.

View File

@ -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

View File

@ -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}

View File

@ -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

View File

@ -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 <hoffmann@inf.ethz.ch>
// 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 <boost/config.hpp>
#include <boost/version.hpp>
@ -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 <algorithm>
@ -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

View File

@ -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

View File

@ -5,5 +5,5 @@ Algebraic_foundations
Circulator
Stream_support
Arrangement_on_surface_2
Sweep_line_2
Surface_sweep_2
Spatial_searching

View File

@ -15,9 +15,10 @@
// $URL$
// $Id$
// SPDX-License-Identifier: GPL-3.0+
//
//
//
// author(s) : Eli Packer <elip@post.tau.ac.il>
#ifndef CGAL_SNAP_ROUNDING_2_H
#define CGAL_SNAP_ROUNDING_2_H
@ -29,7 +30,7 @@
#include <CGAL/enum.h>
#include <CGAL/predicates_on_points_2.h>
#include <CGAL/intersection_2.h>
#include <CGAL/Sweep_line_2_algorithms.h>
#include <CGAL/Surface_sweep_2_algorithms.h>
#include <list>
#include <set>
#include <CGAL/Snap_rounding_kd_2.h>
@ -78,7 +79,7 @@ private:
typedef typename Traits::Segment_2 Segment_2;
typedef typename Traits::Point_2 Point_2;
typedef CGAL::Segment_data<Traits> Segment_data;
private:
// p is the center of the hot pixel
Point_2 p;
@ -156,7 +157,7 @@ private:
typedef std::list<Segment_data> Segment_data_list;
typedef CGAL::Hot_pixel_dir_cmp<Traits> Hot_pixel_dir_cmp;
typedef std::set<Hot_pixel *, Hot_pixel_dir_cmp> Hot_pixel_set;
public:
// friend class Segment_data<Traits>;
// friend class Hot_pixel<Traits>;
@ -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<Traits_>::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<Traits_>::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<Traits_>::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<Traits_>::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<Traits_>::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<Traits_>::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<Traits_>::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<Traits_>::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<Traits_>::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<class Traits_>
bool Hot_pixel_dir_cmp<Traits_>::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<Segment_data>::iterator Segment_data_iter;
typedef std::list<Segment_2> Segment_list;
typedef typename std::list<Point_2>::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<Hot_pixel *>::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_pixel *> 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<Hot_pixel *, Hot_pixel_dir_cmp>::iterator
Hot_pixel_iter;
typedef typename std::list<Segment_data>::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<Traits> Segment_data;
typedef CGAL::Multiple_kd_tree<Traits,Hot_pixel *> Multiple_kd_tree;
typedef std::list<Segment_data> Segment_data_list;
Segment_data_list seg_list;
Multiple_kd_tree * mul_kd_tree = NULL;

View File

@ -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 <I>event
points</I>, such that we only have to calculate the intersection
points between two curves when they become contiguous. For more
details on the <I>surface-sweep algorithm</I> 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 */

View File

@ -0,0 +1,3 @@
/*!
\example Surface_sweep_2/plane_sweep.cpp
*/

View File

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

View File

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

@ -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" )

View File

@ -0,0 +1,45 @@
//! \file examples/Arrangement_on_surface_2/plane_sweep.cpp
// Computing intersection points among curves using the surface-sweep alg.
#include <list>
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Arr_segment_traits_2.h>
#include <CGAL/Surface_sweep_2_algorithms.h>
typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
typedef Kernel::Point_2 Point_2;
typedef CGAL::Arr_segment_traits_2<Kernel> 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<Point_2> 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<Point_2>(std::cout, "\n"));
// Compute the non-intersecting sub-segments induced by the input segments.
std::list<Segment_2> 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;
}

View File

@ -17,26 +17,24 @@
// SPDX-License-Identifier: GPL-3.0+
//
// Author(s) : Baruch Zukerman <baruchzu@post.tau.ac.il>
// Efi Fogel <efifogel@gmail.com>
// Efi Fogel <efifogel@gmail.com>
// (based on old version by Tali Zvi)
#ifndef CGAL_BASIC_SWEEP_LINE_2_H
#define CGAL_BASIC_SWEEP_LINE_2_H
#include <CGAL/license/Arrangement_on_surface_2.h>
/*! \file
* Definition of the Basic_sweep_line_2 class.
*
* Definition of the No_intersection_surface_sweep_2 class.
*/
// #include <cstdint>
#include <boost/mpl/assert.hpp>
#include <CGAL/license/Surface_sweep_2.h>
#include <CGAL/assertions.h>
#include <CGAL/memory.h>
#include <CGAL/Sweep_line_2/Sweep_line_functors.h>
#include <CGAL/Sweep_line_2/Sweep_line_subcurve.h>
#include <CGAL/Sweep_line_2/Sweep_line_event.h>
#include <CGAL/Surface_sweep_2/Event_comparer.h>
#include <CGAL/Surface_sweep_2/Curve_comparer.h>
#include <CGAL/Multiset.h>
#include <CGAL/Arrangement_2/Arr_traits_adaptor_2.h>
#include <CGAL/Arr_tags.h>
@ -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 Traits_,
typename Visitor_,
typename Subcurve_ = Sweep_line_subcurve<Traits_>,
typename Event_ = Sweep_line_event<Traits_, Subcurve_>,
typename Allocator_ = CGAL_ALLOCATOR(int)>
class Basic_sweep_line_2 {
template <typename Visitor_>
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_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<Gt2> 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<Traits_adaptor_2, Event> Compare_events;
typedef Multiset<Event*, Compare_events, Allocator> Event_queue;
typedef CGAL::Surface_sweep_2::Event_comparer<Traits_adaptor_2, Event>
Event_comparer;
typedef Multiset<Event*, Event_comparer, Allocator> 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<Traits_2, Subcurve> Base_event;
typedef typename Base_event::Attribute Attribute;
typedef typename Event::Attribute Attribute;
typedef Sweep_line_subcurve<Traits_2> Base_subcurve;
typedef class Curve_comparer<Traits_2, Base_subcurve> Compare_curves;
typedef Multiset<Base_subcurve*,
Compare_curves,
Allocator> Status_line;
typedef class Curve_comparer<Gt2, Event, Subcurve> Compare_curves;
typedef Multiset<Subcurve*, Compare_curves, Allocator>
Status_line;
typedef typename Status_line::iterator Status_line_iterator;
typedef typename Allocator::template rebind<Event> 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 <CGAL/Sweep_line_2/Sweep_line_2_debug.h>
#include <CGAL/Surface_sweep_2/Surface_sweep_2_debug.h>
#endif
} //namespace CGAL
#include <CGAL/Sweep_line_2/Basic_sweep_line_2_impl.h>
#include <CGAL/Surface_sweep_2/No_intersection_surface_sweep_2_impl.h>
#endif

View File

@ -20,26 +20,29 @@
// Efi Fogel <efifogel@gmail.com>
// (based on old version by Tali Zvi)
#ifndef CGAL_SWEEP_LINE_2_H
#define CGAL_SWEEP_LINE_2_H
#include <CGAL/license/Sweep_line_2.h>
#ifndef CGAL_SURFACE_SWEEP_2_H
#define CGAL_SURFACE_SWEEP_2_H
#include <CGAL/license/Surface_sweep_2.h>
/*! \file
* Definition of the Sweep_line_2 class.
*
* Definition of the Surface_sweep_2 class.
*/
#include <list>
#include <CGAL/Object.h>
#include <CGAL/Basic_sweep_line_2.h>
#include <CGAL/Sweep_line_2/Sweep_line_curve_pair.h>
#include <CGAL/No_intersection_surface_sweep_2.h>
#include <CGAL/Surface_sweep_2/Curve_pair.h>
#include <CGAL/Arrangement_2/Open_hash.h>
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 Traits_, typename Visitor_,
typename Subcurve_ = Sweep_line_subcurve<Traits_>,
typename Event_ = Sweep_line_event<Traits_, Subcurve_>,
typename Allocator_ = CGAL_ALLOCATOR(int) >
class Sweep_line_2 :
public Basic_sweep_line_2<Traits_, Visitor_, Subcurve_, Event_, Allocator_>
{
template <typename Visitor_>
class Surface_sweep_2 : public No_intersection_surface_sweep_2<Visitor_> {
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<Traits_2, Visitor, Subcurve, Event, Allocator>
Base;
private:
typedef No_intersection_surface_sweep_2<Visitor> 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*> Subcurve_container;
typedef typename Subcurve_container::iterator Subcurve_iterator;
typedef std::list<Subcurve*> 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<Subcurve> Curve_pair;
typedef CGAL::Curve_pair_hasher<Subcurve> Curve_pair_hasher;
typedef CGAL::Equal_curve_pair<Subcurve> Equal_curve_pair;
typedef CGAL::Surface_sweep_2::Curve_pair<Subcurve> Curve_pair;
typedef CGAL::Surface_sweep_2::Curve_pair_hasher<Subcurve>
Curve_pair_hasher;
typedef CGAL::Surface_sweep_2::Equal_curve_pair<Subcurve>
Equal_curve_pair;
typedef Open_hash<Curve_pair, Curve_pair_hasher, Equal_curve_pair>
Curve_pair_set;
Curve_pair_set;
typedef random_access_input_iterator<std::vector<Object> >
vector_inserter;
typedef std::vector<Object> Object_vector;
typedef random_access_input_iterator<Object_vector> 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 <CGAL/Sweep_line_2/Sweep_line_2_impl.h>
#include <CGAL/Surface_sweep_2/Surface_sweep_2_impl.h>
#endif

View File

@ -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 <talizvi@post.tau.ac.il>
// Baruch Zukerman <baruchzu@post.tau.ac.il>
// Ron Wein <wein@post.tau.ac.il>
// Efi Fogel <efif@post.tau.ac.il>
#ifndef CGAL_SURFACE_SWEEP_2_CURVE_COMPARER_H
#define CGAL_SURFACE_SWEEP_2_CURVE_COMPARER_H
#include <CGAL/license/Surface_sweep_2.h>
/*! \file
*
* Comparison functor of curves used by the surface-sweep algorithm.
*/
#include <CGAL/assertions.h>
#include <CGAL/enum.h>
#include <CGAL/Arr_enums.h>
#include <CGAL/Arrangement_2/Arr_traits_adaptor_2.h>
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 <typename GeometryTraits_2, typename Event_, typename Subcurve_>
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<Gt2> 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

View File

@ -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 <baruchzu@post.tau.ac.il>
// Ron Wein <wein@post.tau.ac.il>
#ifndef CGAL_SURFACE_SWEEP_2_CURVE_PAIR_H
#define CGAL_SURFACE_SWEEP_2_CURVE_PAIR_H
#include <CGAL/license/Surface_sweep_2.h>
#include <CGAL/utility.h>
/*! \file
*
* Definition of the Curve_pair<Subcurve> class template and related functors.
*/
namespace CGAL {
namespace Surface_sweep_2 {
/*! \class
*
* A pair of subcurves.
*/
template <typename Subcurve_>
class Curve_pair {
public:
typedef Subcurve_ Subcurve;
private:
// Data members:
std::pair<Subcurve*, Subcurve*> 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 <typename Subcurve_>
struct Less_curve_pair {
typedef Subcurve_ Subcurve;
typedef class Curve_pair<Subcurve> 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 <typename Subcurve_>
struct Curve_pair_hasher {
typedef Subcurve_ Subcurve;
typedef class Curve_pair<Subcurve> 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<size_t>(pair.first());
const size_t val2 = reinterpret_cast<size_t>(pair.second());
return (((val1 << half_n_bits) | (val1 >> half_n_bits)) ^ val2);
}
};
/*! \struct
* Equaility functor for curve pairs.
*/
template <typename Subcurve_>
struct Equal_curve_pair {
typedef Subcurve_ Subcurve;
typedef class Curve_pair<Subcurve> 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 <typename Container_>
class random_access_input_iterator {
public:
typedef Container_ Container;
typedef typename Container::value_type value_type;
typedef random_access_input_iterator<Container> 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

View File

@ -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 <talizvi@post.tau.ac.il>,
// Baruch Zukerman <baruchzu@post.tau.ac.il>
// Ron Wein <wein@post.tau.ac.il>
// Efi Fogel <efif@gmail.com>
#ifndef CGAL_SURFACE_SWEEP_2_DEFAULT_EVENT_H
#define CGAL_SURFACE_SWEEP_2_DEFAULT_EVENT_H
#include <CGAL/license/Surface_sweep_2.h>
/*! \file
*
* Defintion of the Default_event class.
*/
#include <CGAL/Surface_sweep_2/Default_event_base.h>
#include <CGAL/Surface_sweep_2/Default_subcurve.h>
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 <typename GeometryTraits_2,
typename Allocator_ = CGAL_ALLOCATOR(int)>
class Default_event :
public Default_event_base<GeometryTraits_2,
Default_subcurve<GeometryTraits_2,
Default_event<GeometryTraits_2,
Allocator_>,
Allocator_> >
{
public:
/*! Construct default. */
Default_event() {}
};
} // namespace Surface_sweep_2
} // namespace CGAL
#endif

View File

@ -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 <talizvi@post.tau.ac.il>,
// Baruch Zukerman <baruchzu@post.tau.ac.il>
// Ron Wein <wein@post.tau.ac.il>
// Efi Fogel <efif@gmail.com>
#ifndef CGAL_SURFACE_SWEEP_2_DEFAULT_EVENT_BASE_H
#define CGAL_SURFACE_SWEEP_2_DEFAULT_EVENT_BASE_H
#include <CGAL/license/Surface_sweep_2.h>
/*! \file
*
* Defintion of the Default_event_base class.
*/
#include <CGAL/Surface_sweep_2/No_overlap_event_base.h>
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 <typename GeometryTraits_2, typename Subcurve_>
class Default_event_base :
public No_overlap_event_base<GeometryTraits_2, Subcurve_>
{
public:
typedef GeometryTraits_2 Geometry_traits_2;
typedef Subcurve_ Subcurve;
private:
typedef Geometry_traits_2 Gt2;
typedef No_overlap_event_base<Gt2, Subcurve> 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<bool, Subcurve_iterator>
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<Subcurve*>((*iter)->originating_subcurve1()) == c1) ||
(static_cast<Subcurve*>((*iter)->originating_subcurve2()) == c1))
return false;
if ((*iter == c2) ||
(static_cast<Subcurve*>((*iter)->originating_subcurve1()) == c2) ||
(static_cast<Subcurve*>((*iter)->originating_subcurve2()) == c2))
return true;
}
return true;
}
};
} // namespace Surface_sweep_2
} // namespace CGAL
#endif

View File

@ -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 <talizvi@post.tau.ac.il>,
// Baruch Zukerman <baruchzu@post.tau.ac.il>
// Ron Wein <wein@post.tau.ac.il>
// Efi Fogel <efifogel@gmail.com>
#ifndef CGAL_SURFACE_SWEEP_DEFAULT_SUBCURVE_H
#define CGAL_SURFACE_SWEEP_DEFAULT_SUBCURVE_H
#include <CGAL/license/Surface_sweep_2.h>
/*! \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 <CGAL/Surface_sweep_2/No_overlap_subcurve.h>
#include <CGAL/Multiset.h>
#include <CGAL/assertions.h>
#include <CGAL/Default.h>
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 <typename GeometryTraits_2, typename Event_, typename Allocator_,
typename Subcurve_>
class Default_subcurve_base :
public No_overlap_subcurve<GeometryTraits_2, Event_, Allocator_, Subcurve_>
{
public:
typedef GeometryTraits_2 Geometry_traits_2;
typedef Subcurve_ Subcurve;
typedef Event_ Event;
private:
typedef Geometry_traits_2 Gt2;
typedef No_overlap_subcurve<Gt2, Event, 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 <typename OutputIterator>
OutputIterator all_leaves(OutputIterator oi)
{
if (m_orig_subcurve1 == NULL) {
*oi++ = reinterpret_cast<Subcurve*>(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<Subcurve*> my_leaves;
std::list<Subcurve*> other_leaves;
all_leaves(std::back_inserter(my_leaves));
s->all_leaves(std::back_inserter(other_leaves));
typename std::list<Subcurve*>::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<Subcurve*> my_leaves;
std::list<Subcurve*> other_leaves;
all_leaves(std::back_inserter(my_leaves));
s->all_leaves(std::back_inserter(other_leaves));
typename std::list<Subcurve*>::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 <typename OutputIterator>
OutputIterator distinct_nodes(Subcurve* s, OutputIterator oi)
{
if (m_orig_subcurve1 == NULL) {
Subcurve* subcurve = reinterpret_cast<Subcurve*>(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 <typename GeometryTraits_2, typename Event_,
typename Allocator_ = CGAL_ALLOCATOR(int),
typename Subcurve_ = Default>
class Default_subcurve :
public Default_subcurve_base<GeometryTraits_2, Event_, Allocator_,
typename Default::Get<Subcurve_,
Default_subcurve<
GeometryTraits_2, Event_,
Allocator_,
Subcurve_> >::type>
{
public:
typedef GeometryTraits_2 Geometry_traits_2;
typedef Event_ Event;
typedef Allocator_ Allocator;
private:
typedef Geometry_traits_2 Gt2;
typedef Default_subcurve<Gt2, Event, Allocator, Subcurve_>
Self;
typedef typename Default::Get<Subcurve_, Self>::type Subcurve;
typedef Default_subcurve_base<Gt2, Event, Allocator, Subcurve>
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 <typename Gt2, typename Evt, typename Allocator, typename Scv>
void Default_subcurve<Gt2, Evt, Allocator, Scv>::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

View File

@ -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 <baruchzu@post.tau.ac.il>
// Efi Fogel <efif@post.tau.ac.il>
#ifndef CGAL_SURFACE_SWEEP_2_DEFAULT_VISITOR_H
#define CGAL_SURFACE_SWEEP_2_DEFAULT_VISITOR_H
#include <CGAL/license/Surface_sweep_2.h>
/*! \file
*
* Definition of the Default_visitor class-template.
*/
#include <CGAL/Surface_sweep_2/Default_visitor_base.h>
#include <CGAL/Surface_sweep_2/Default_event.h>
#include <CGAL/Surface_sweep_2/Default_subcurve.h>
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 Visitor_,
typename GeometryTraits_2,
typename Allocator_ = CGAL_ALLOCATOR(int),
typename Event_ = Default_event<GeometryTraits_2, Allocator_>,
typename Subcurve_ = Default_subcurve<GeometryTraits_2, Event_,
Allocator_> >
class Default_visitor : public Default_visitor_base<GeometryTraits_2, Event_,
Subcurve_, Allocator_,
Visitor_>
{
public:
typedef GeometryTraits_2 Geometry_traits_2;
typedef Allocator_ Allocator;
typedef Event_ Event;
typedef Subcurve_ Subcurve;
};
} // namespace Surface_sweep_2
} // namespace CGAL
#endif

View File

@ -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 <baruchzu@post.tau.ac.il>
// Efi Fogel <efif@post.tau.ac.il>
#ifndef CGAL_SURFACE_SWEEP_2_DEFAULT_VISITOR_BASE_H
#define CGAL_SURFACE_SWEEP_2_DEFAULT_VISITOR_BASE_H
#include <CGAL/license/Surface_sweep_2.h>
/*! \file
*
* Definition of the Default_visitor_base class-template.
*/
#include <CGAL/No_intersection_surface_sweep_2.h>
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 <typename GeometryTraits_2, typename Event_, typename Subcurve_,
typename Allocator_, typename Visitor_>
class Default_visitor_base {
public:
typedef GeometryTraits_2 Geometry_traits_2;
typedef Event_ Event;
typedef Subcurve_ Subcurve;
typedef Allocator_ Allocator;
typedef Visitor_ Visitor;
private:
typedef Geometry_traits_2 Gt2;
typedef Default_visitor_base<Gt2, Event, Subcurve, Allocator, Visitor>
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<Visitor> 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

View File

@ -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 <baruchzu@post.tau.ac.il>
// Ron Wein <wein@post.tau.ac.il>
// Efi Fogel <efif@post.tau.ac.il>
#ifndef CGAL_SURFACE_SWEEP_2_DO_INTERIOR_INTERSECT_VISITORS_H
#define CGAL_SURFACE_SWEEP_2_DO_INTERIOR_INTERSECT_VISITORS_H
#include <CGAL/license/Surface_sweep_2.h>
/*! \file
*
* Definition of the basic sweep-line visitors, for the usage of the global
* sweep-line functions.
*/
#include <vector>
#include <CGAL/Surface_sweep_2/Default_visitor.h>
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 <typename GeometryTraits_2,
typename Allocator_ = CGAL_ALLOCATOR(int)>
class Do_interior_intersect_visitor :
public Default_visitor<Do_interior_intersect_visitor<GeometryTraits_2,
Allocator_>,
GeometryTraits_2, Allocator_>
{
public:
typedef GeometryTraits_2 Geometry_traits_2;
typedef Allocator_ Allocator;
private:
typedef Geometry_traits_2 Gt2;
typedef Do_interior_intersect_visitor<Gt2, Allocator> Self;
typedef Default_visitor<Self, Gt2, Allocator> 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 <typename CurveIterator>
void sweep(CurveIterator begin, CurveIterator end)
{
std::vector<X_monotone_curve_2> curves_vec;
std::vector<Point_2> 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 <typename XCurveIterator>
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

View File

@ -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 <talizvi@post.tau.ac.il>
// Baruch Zukerman <baruchzu@post.tau.ac.il>
// Ron Wein <wein@post.tau.ac.il>
// Efi Fogel <efif@post.tau.ac.il>
#ifndef CGAL_SURFACE_SWEEP_2_EVENT_COMPARER_H
#define CGAL_SURFACE_SWEEP_2_EVENT_COMPARER_H
#include <CGAL/license/Surface_sweep_2.h>
/*! \file
*
* Comparison functor of curves used by the surface-sweep algorithm.
*/
#include <CGAL/assertions.h>
#include <CGAL/enum.h>
#include <CGAL/Arr_enums.h>
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 <typename GeometryTraits_2, typename Event_>
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

View File

@ -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 <baruchzu@post.tau.ac.il>
// Ron Wein <wein@post.tau.ac.il>
// Efi Fogel <efif@post.tau.ac.il>
#ifndef CGAL_SURFACE_SWEEP_2_INTERSECTION_POINTS_VISITOR_H
#define CGAL_SURFACE_SWEEP_2_INTERSECTION_POINTS_VISITOR_H
#include <CGAL/license/Surface_sweep_2.h>
/*! \file
*
* Definition of a surface-sweep visitor that reports all intersection points
* among a set of input curves.
*/
#include <vector>
// #include <iterator>
#include <CGAL/Surface_sweep_2/Default_visitor.h>
#include <CGAL/Surface_sweep_2/Surface_sweep_2_utils.h>
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 <typename GeometryTraits_2, typename OutputIterator,
typename Allocator_ = CGAL_ALLOCATOR(int)>
class Intersection_points_visitor :
public Default_visitor<Intersection_points_visitor<GeometryTraits_2,
OutputIterator,
Allocator_>,
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<Gt2, Output_iterator, Allocator>
Self;
typedef Default_visitor<Self, Gt2, Allocator> 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 <typename CurveIterator>
void sweep(CurveIterator begin, CurveIterator end)
{
std::vector<X_monotone_curve_2> curves_vec;
std::vector<Point_2> 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

View File

@ -21,25 +21,25 @@
// Eric Berberich <ericb@post.tau.ac.il>
// (based on old version by Tali Zvi)
#ifndef CGAL_BASIC_SWEEP_LINE_2_IMPL_H
#define CGAL_BASIC_SWEEP_LINE_2_IMPL_H
#include <CGAL/license/Sweep_line_2.h>
#ifndef CGAL_NO_INTERSECTION_SURFACE_SWEEP_2_IMPL_H
#define CGAL_NO_INTERSECTION_SURFACE_SWEEP_2_IMPL_H
#include <CGAL/license/Surface_sweep_2.h>
/*! \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 <typename Tr, typename Vis, typename Subcv, typename Evnt,
typename Alloc>
Basic_sweep_line_2<Tr, Vis, Subcv, Evnt, Alloc>::
Basic_sweep_line_2(Visitor* visitor) :
template <typename Vis>
No_intersection_surface_sweep_2<Vis>::
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 <typename Tr, typename Vis, typename Subcv, typename Evnt,
typename Alloc>
Basic_sweep_line_2<Tr, Vis, Subcv, Evnt, Alloc>::
Basic_sweep_line_2(const Traits_2* traits, Visitor* visitor) :
template <typename Vis>
No_intersection_surface_sweep_2<Vis>::
No_intersection_surface_sweep_2(const Gt2* traits, Visitor* visitor) :
m_traits(static_cast<const Traits_adaptor_2*>(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 <typename Tr, typename Vis, typename Subcv, typename Evnt,
typename Alloc>
Basic_sweep_line_2<Tr, Vis, Subcv, Evnt, Alloc>::~Basic_sweep_line_2()
template <typename Vis>
No_intersection_surface_sweep_2<Vis>::~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<Tr, Vis, Subcv, Evnt, Alloc>::~Basic_sweep_line_2()
//-----------------------------------------------------------------------------
// Stop the sweep-line process.
//
template <typename Tr, typename Vis, typename Subcv, typename Evnt,
typename Alloc>
void Basic_sweep_line_2<Tr, Vis, Subcv, Evnt, Alloc>::stop_sweep()
template <typename Vis>
void No_intersection_surface_sweep_2<Vis>::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<Tr, Vis, Subcv, Evnt, Alloc>::stop_sweep()
//-----------------------------------------------------------------------------
// Deallocate event object..
//
template <typename Tr, typename Vis, typename Subcv, typename Evnt,
typename Alloc>
void Basic_sweep_line_2<Tr, Vis, Subcv, Evnt, Alloc>::
deallocate_event(Event* event)
template <typename Vis>
void No_intersection_surface_sweep_2<Vis>::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 <typename Tr, typename Vis, typename Subcv, typename Evnt,
typename Alloc>
void Basic_sweep_line_2<Tr, Vis, Subcv, Evnt, Alloc>::_sweep()
template <typename Vis>
void No_intersection_surface_sweep_2<Vis>::_sweep()
{
CGAL_SL_PRINT_TEXT("Ordered sequence of ");
CGAL_SL_PRINT(m_queue->size());
@ -210,9 +204,8 @@ void Basic_sweep_line_2<Tr, Vis, Subcv, Evnt, Alloc>::_sweep()
//-----------------------------------------------------------------------------
// Initialize the data structures for the sweep-line algorithm.
//
template <typename Tr, typename Vis, typename Subcv, typename Evnt,
typename Alloc>
void Basic_sweep_line_2<Tr, Vis, Subcv, Evnt, Alloc>::_init_structures()
template <typename Vis>
void No_intersection_surface_sweep_2<Vis>::_init_structures()
{
CGAL_assertion(m_queue->empty());
CGAL_assertion((m_statusLine.size() == 0));
@ -226,9 +219,8 @@ void Basic_sweep_line_2<Tr, Vis, Subcv, Evnt, Alloc>::_init_structures()
//-----------------------------------------------------------------------------
// Complete the sweep (complete the data structures).
//
template <typename Tr, typename Vis, typename Subcv, typename Evnt,
typename Alloc>
void Basic_sweep_line_2<Tr, Vis, Subcv, Evnt, Alloc>::_complete_sweep()
template <typename Vis>
void No_intersection_surface_sweep_2<Vis>::_complete_sweep()
{
CGAL_assertion(m_queue->empty());
CGAL_assertion((m_statusLine.size() == 0));
@ -244,10 +236,9 @@ void Basic_sweep_line_2<Tr, Vis, Subcv, Evnt, Alloc>::_complete_sweep()
//-----------------------------------------------------------------------------
// Initialize an event associated with a point.
//
template <typename Tr, typename Vis, typename Subcv, typename Evnt,
typename Alloc>
void Basic_sweep_line_2<Tr, Vis, Subcv, Evnt, Alloc>::
_init_point(const Point_2& pt, Attribute type)
template <typename Vis>
void No_intersection_surface_sweep_2<Vis>::_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 <typename Tr, typename Vis, typename Subcv, typename Evnt,
typename Alloc>
void Basic_sweep_line_2<Tr, Vis, Subcv, Evnt, Alloc>::
template <typename Vis>
void No_intersection_surface_sweep_2<Vis>::
_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 <typename Tr, typename Vis, typename Subcv, typename Evnt,
typename Alloc>
void Basic_sweep_line_2<Tr, Vis, Subcv, Evnt, Alloc>::
template <typename Vis>
void No_intersection_surface_sweep_2<Vis>::
_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 <typename Tr, typename Vis, typename Subcv, typename Evnt,
typename Alloc>
void Basic_sweep_line_2<Tr, Vis, Subcv, Evnt, Alloc>::_handle_left_curves()
template <typename Vis>
void No_intersection_surface_sweep_2<Vis>::_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<Tr, Vis, Subcv, Evnt, Alloc>::_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<Tr, Vis, Subcv, Evnt, Alloc>::_handle_left_curves()
//-----------------------------------------------------------------------------
// Handle an event that does not have any incident left curves.
//
template <typename Tr, typename Vis, typename Subcv, typename Evnt,
typename Alloc>
void Basic_sweep_line_2<Tr, Vis, Subcv, Evnt, Alloc>::
_handle_event_without_left_curves()
template <typename Vis>
void No_intersection_surface_sweep_2<Vis>::_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 <typename Tr, typename Vis, typename Subcv, typename Evnt,
typename Alloc>
void Basic_sweep_line_2<Tr, Vis, Subcv, Evnt, Alloc>::_sort_left_curves()
template <typename Vis>
void No_intersection_surface_sweep_2<Vis>::_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<Tr, Vis, Subcv, Evnt, Alloc>::_sort_left_curves()
//-----------------------------------------------------------------------------
// Handle the subcurves to the right of the current event point.
//
template <typename Tr, typename Vis, typename Subcv, typename Evnt,
typename Alloc>
void Basic_sweep_line_2<Tr, Vis, Subcv, Evnt, Alloc>::_handle_right_curves()
template <typename Vis>
void No_intersection_surface_sweep_2<Vis>::_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<Tr, Vis, Subcv, Evnt, Alloc>::_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<Tr, Vis, Subcv, Evnt, Alloc>::_handle_right_curves()
//-----------------------------------------------------------------------------
// Add a subcurve to the right of an event point.
//
template <typename Tr, typename Vis, typename Subcv, typename Evnt,
typename Alloc>
bool Basic_sweep_line_2<Tr, Vis, Subcv, Evnt, Alloc>::
template <typename Vis>
bool No_intersection_surface_sweep_2<Vis>::
_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 <typename Tr, typename Vis, typename Subcv, typename Evnt,
typename Alloc>
void Basic_sweep_line_2<Tr, Vis, Subcv, Evnt, Alloc>::
template <typename Vis>
void No_intersection_surface_sweep_2<Vis>::
_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 Tr, typename Vis, typename Subcv, typename Evnt,
typename Alloc>
typename Basic_sweep_line_2<Tr, Vis, Subcv, Evnt, Alloc>::Event*
Basic_sweep_line_2<Tr, Vis, Subcv, Evnt, Alloc>::
_allocate_event(const Point_2& pt, Attribute type,
Arr_parameter_space ps_x, Arr_parameter_space ps_y)
template <typename Vis>
typename No_intersection_surface_sweep_2<Vis>::Event*
No_intersection_surface_sweep_2<Vis>::_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 Tr, typename Vis, typename Subcv, typename Evnt,
typename Alloc>
typename Basic_sweep_line_2<Tr, Vis, Subcv, Evnt, Alloc>::Event*
Basic_sweep_line_2<Tr, Vis, Subcv, Evnt, Alloc>::
template <typename Vis>
typename No_intersection_surface_sweep_2<Vis>::Event*
No_intersection_surface_sweep_2<Vis>::
_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 <typename Tr, typename Vis, typename Subcv, typename Evnt,
typename Alloc>
std::pair<typename Basic_sweep_line_2<Tr, Vis, Subcv, Evnt, Alloc>::Event*,
bool>
Basic_sweep_line_2<Tr, Vis, Subcv, Evnt, Alloc>::
_push_event(const Point_2& pt, Attribute type,
Arr_parameter_space ps_x, Arr_parameter_space ps_y, Subcurve* sc)
template <typename Vis>
std::pair<typename No_intersection_surface_sweep_2<Vis>::Event*, bool>
No_intersection_surface_sweep_2<Vis>::_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 <typename Tr, typename Vis, typename Subcv, typename Evnt,
typename Alloc>
std::pair<typename Basic_sweep_line_2<Tr, Vis, Subcv, Evnt, Alloc>::Event*,
bool>
Basic_sweep_line_2<Tr, Vis, Subcv, Evnt, Alloc>::
_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 <typename Vis>
std::pair<typename No_intersection_surface_sweep_2<Vis>::Event*, bool>
No_intersection_surface_sweep_2<Vis>::_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 <typename Vis>
void No_intersection_surface_sweep_2<Vis>::_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

View File

@ -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 <talizvi@post.tau.ac.il>,
// Baruch Zukerman <baruchzu@post.tau.ac.il>
// Ron Wein <wein@post.tau.ac.il>
// Efi Fogel <efifogel@gmail.com>
#ifndef CGAL_SURFACE_SWEEP_2_NO_OVERLAP_EVENT_H
#define CGAL_SURFACE_SWEEP_2_NO_OVERLAP_EVENT_H
#include <CGAL/license/Surface_sweep_2.h>
/*! \file
*
* Defintion of the No_overlap_event class.
*/
#include <CGAL/Surface_sweep_2/No_overlap_event_base.h>
#include <CGAL/Surface_sweep_2/No_overlap_subcurve.h>
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 <typename GeometryTraits_2,
typename Allocator_ = CGAL_ALLOCATOR(int)>
class No_overlap_event :
public No_overlap_event_base<GeometryTraits_2,
No_overlap_subcurve<GeometryTraits_2,
No_overlap_event<
GeometryTraits_2,
Allocator_>,
Allocator_> >
{
public:
/*! Construct default. */
No_overlap_event() {}
};
} // namespace Surface_sweep_2
} // namespace CGAL
#endif

View File

@ -18,28 +18,27 @@
//
// Author(s) : Tali Zvi <talizvi@post.tau.ac.il>,
// Baruch Zukerman <baruchzu@post.tau.ac.il>
// Ron Wein <wein@post.tau.ac.il>
// Efi Fogel <efif@gmail.com>
// Ron Wein <wein@post.tau.ac.il>
// Efi Fogel <efif@gmail.com>
#ifndef CGAL_SWEEP_LINE_EVENT_H
#define CGAL_SWEEP_LINE_EVENT_H
#include <CGAL/license/Sweep_line_2.h>
#ifndef CGAL_SURFACE_SWEEP_2_NO_OVERLAP_EVENT_BASE_H
#define CGAL_SURFACE_SWEEP_2_NO_OVERLAP_EVENT_BASE_H
#include <CGAL/license/Surface_sweep_2.h>
/*! \file
* Defintion of the Sweep_line_event class.
*
* Defintion of the No_overlap_event_base class.
*/
#include <list>
#include <CGAL/Sweep_line_2/Sweep_line_subcurve.h>
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 <typename Traits_, typename Subcurve_>
class Sweep_line_event {
template <typename GeometryTraits_2, typename Subcurve_>
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<Traits_2>::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<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;
typedef Subcurve_ Subcurve;
//template<typename SC>
//struct SC_container { typedef std::list<SC> other; };
typedef std::list<Subcurve*> 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<char>(ARR_INTERIOR)),
m_ps_y(static_cast<char>(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<bool, Subcurve_iterator>
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<bool, Subcurve_iterator>
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 <typename InputIterator>
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<Subcurve*>(*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<Subcurve*>((*iter)->originating_subcurve1()) == c1) ||
(static_cast<Subcurve*>((*iter)->originating_subcurve2()) == c1))
return false;
if ((*iter == c2) ||
(static_cast<Subcurve*>((*iter)->originating_subcurve1()) == c2) ||
(static_cast<Subcurve*>((*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<typename Traits, typename Subcurve>
void Sweep_line_event<Traits, Subcurve>::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 <typename Traits, typename Subcurve>
void No_overlap_event_base<Traits, Subcurve>::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

View File

@ -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 <talizvi@post.tau.ac.il>,
// Baruch Zukerman <baruchzu@post.tau.ac.il>
// Ron Wein <wein@post.tau.ac.il>
// Efi Fogel <efifogel@gmail.com>
#ifndef CGAL_SURFACE_SWEEP_2_NO_OVERLAP_SUBCURVE_H
#define CGAL_SURFACE_SWEEP_2_NO_OVERLAP_SUBCURVE_H
#include <CGAL/license/Surface_sweep_2.h>
/*! \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 <CGAL/Surface_sweep_2/Curve_comparer.h>
#include <CGAL/Multiset.h>
#include <CGAL/assertions.h>
#include <CGAL/Default.h>
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 <typename GeometryTraits_2, typename Event_, typename Allocator_,
typename Subcurve_>
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<Gt2, Event, Subcurve> Compare_curves;
typedef Multiset<Subcurve*, Compare_curves, Allocator>
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 <typename SweepEvent>
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 <typename GeometryTraits_2, typename Event_,
typename Allocator_ = CGAL_ALLOCATOR(int),
typename Subcurve_ = Default>
class No_overlap_subcurve :
public No_overlap_subcurve_base<
GeometryTraits_2, Event_, Allocator_,
typename Default::Get<Subcurve_,
No_overlap_subcurve<GeometryTraits_2, Event_,
Allocator_, Subcurve_> >::type>
{
public:
typedef GeometryTraits_2 Geometry_traits_2;
typedef Event_ Event;
typedef Allocator_ Allocator;
private:
typedef Geometry_traits_2 Gt2;
typedef No_overlap_subcurve<Gt2, Event, Allocator, Subcurve_>
Self;
typedef typename Default::Get<Subcurve_, Self>::type Subcurve;
typedef No_overlap_subcurve_base<Gt2, Event, Allocator, Subcurve>
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 <typename Gt2, typename Evt, typename Allocator, typename Scv>
void No_overlap_subcurve<Gt2, Evt, Allocator, Scv>::Print() const
{ std::cout << "Curve " << this << " (" << last_curve() << ") "; }
#endif
} // namespace Surface_sweep_2
} // namespace CGAL
#endif

View File

@ -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 <baruchzu@post.tau.ac.il>
// Efi Fogel <efif@post.tau.ac.il>
// (based on old version by Tali Zvi)
#ifndef CGAL_SURFACE_SWEEP_2_SUBCURVES_VISITOR_H
#define CGAL_SURFACE_SWEEP_2_SUBCURVES_VISITOR_H
#include <CGAL/license/Surface_sweep_2.h>
/*! \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 <vector>
#include <CGAL/Surface_sweep_2/Default_visitor.h>
#include <CGAL/Surface_sweep_2/Surface_sweep_2_utils.h>
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 <typename GeometryTraits_2, typename OutputIerator,
typename Allocator_ = CGAL_ALLOCATOR(int)>
class Subcurves_visitor :
public Default_visitor<Subcurves_visitor<GeometryTraits_2, OutputIerator,
Allocator_>,
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<Gt2, Output_ierator, Allocator>
Self;
typedef Default_visitor<Self, Gt2, Allocator> 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 <typename CurveIterator>
void sweep(CurveIterator begin, CurveIterator end)
{
std::vector<X_monotone_curve_2> curves_vec;
std::vector<Point_2> 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

View File

@ -19,23 +19,24 @@
// Author(s) : Baruch Zukerman <baruchzu@post.tau.ac.il>
// Efi Fogel <efifogel@gmail.com>
#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 <CGAL/license/Sweep_line_2.h>
#include <CGAL/license/Surface_sweep_2.h>
#include <CGAL/No_intersection_surface_sweep_2.h>
#include <CGAL/Basic_sweep_line_2.h>
namespace CGAL {
namespace Surface_sweep_2 {
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
// DEBUG UTILITIES //
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
template <typename Tr, typename Visit, typename Crv, typename Evnt,
typename Alloc>
void Basic_sweep_line_2<Tr, Visit, Crv, Evnt, Alloc>::
print_text(const char* text, bool do_eol)
template <typename Vis>
void No_intersection_surface_sweep_2<Vis>::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 <typename Tr, typename Visit, typename Crv, typename Evnt,
typename Alloc>
void Basic_sweep_line_2<Tr, Visit, Crv, Evnt, Alloc>::print_eol()
template <typename Vis>
void No_intersection_surface_sweep_2<Vis>::print_eol()
{
std::cout << std::endl;
m_need_indent = true;
}
template <typename Tr, typename Visit, typename Crv, typename Evnt,
typename Alloc>
void Basic_sweep_line_2<Tr, Visit, Crv, Evnt, Alloc>::increase_indent()
template <typename Vis>
void No_intersection_surface_sweep_2<Vis>::increase_indent()
{ m_indent_size += 2; }
template <typename Tr, typename Visit, typename Crv, typename Evnt,
typename Alloc>
void Basic_sweep_line_2<Tr, Visit, Crv, Evnt, Alloc>::decrease_indent()
template <typename Vis>
void No_intersection_surface_sweep_2<Vis>::decrease_indent()
{ m_indent_size -= 2; }
template <typename Tr, typename Visit, typename Crv, typename Evnt,
typename Alloc>
void Basic_sweep_line_2<Tr, Visit, Crv, Evnt, Alloc>::
print_start(const char* name, bool do_eol)
template <typename Vis>
void No_intersection_surface_sweep_2<Vis>::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 <typename Tr, typename Visit, typename Crv, typename Evnt,
typename Alloc>
void Basic_sweep_line_2<Tr, Visit, Crv, Evnt, Alloc>::
print_end(const char* name, bool do_eol)
template <typename Vis>
void No_intersection_surface_sweep_2<Vis>::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 <typename Tr, typename Visit, typename Crv, typename Evnt,
typename Alloc>
void Basic_sweep_line_2<Tr, Visit, Crv, Evnt, Alloc>::
print_curve(const Base_subcurve* sc)
template <typename Vis>
void No_intersection_surface_sweep_2<Vis>::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 <typename Tr, typename Visit, typename Crv, typename Evnt,
typename Alloc>
void Basic_sweep_line_2<Tr, Visit, Crv, Evnt, Alloc>::PrintEventQueue()
template <typename Vis>
void No_intersection_surface_sweep_2<Vis>::PrintEventQueue()
{
print_text("Event queue: ", true);
Event_queue_iterator iter = m_queue->begin();
@ -108,18 +101,16 @@ void Basic_sweep_line_2<Tr, Visit, Crv, Evnt, Alloc>::PrintEventQueue()
CGAL_SL_DEBUG(std::cout << "--------------------------------" << std::endl;)
}
template <typename Tr, typename Visit, typename Crv, typename Evnt,
typename Alloc>
void Basic_sweep_line_2<Tr, Visit, Crv, Evnt, Alloc>::PrintSubCurves()
template <typename Vis>
void No_intersection_surface_sweep_2<Vis>::PrintSubCurves()
{
print_text("Sub curves: ", true);
for (size_t i = 0; i < m_num_of_subCurves; ++i) m_subCurves[i].Print();
print_eol();
}
template <typename Tr, typename Visit, typename Crv, typename Evnt,
typename Alloc>
void Basic_sweep_line_2<Tr, Visit, Crv, Evnt, Alloc>::PrintStatusLine()
template <typename Vis>
void No_intersection_surface_sweep_2<Vis>::PrintStatusLine()
{
if (m_statusLine.size() == 0) {
print_text("Status line: empty", true);
@ -146,10 +137,9 @@ void Basic_sweep_line_2<Tr, Visit, Crv, Evnt, Alloc>::PrintStatusLine()
print_eol();
}
template <typename Tr, typename Visit, typename Crv, typename Evnt,
typename Alloc>
void Basic_sweep_line_2<Tr, Visit, Crv, Evnt, Alloc>::
PrintOpenBoundaryType (Arr_parameter_space ps_x, Arr_parameter_space ps_y)
template <typename Vis>
void No_intersection_surface_sweep_2<Vis>::
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 <typename Tr, typename Visit, typename Crv, typename Evnt,
typename Alloc>
void Basic_sweep_line_2<Tr, Visit, Crv, Evnt, Alloc>::
PrintEvent(const Event* e)
template <typename Vis>
void No_intersection_surface_sweep_2<Vis>::PrintEvent(const Event* e)
{
if (e->is_closed()) std::cout << e->point();
else {
@ -180,10 +168,8 @@ PrintEvent(const Event* e)
}
}
template <typename Tr, typename Visit, typename Crv, typename Evnt,
typename Alloc>
void Basic_sweep_line_2<Tr, Visit, Crv, Evnt, Alloc>::
print_event_info(const Event* e)
template <typename Vis>
void No_intersection_surface_sweep_2<Vis>::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

View File

@ -20,24 +20,24 @@
// Efi Fogel <efif@post.tau.ac.il>
// (based on old version by Tali Zvi)
#ifndef CGAL_SWEEP_LINE_2_IMPL_H
#define CGAL_SWEEP_LINE_2_IMPL_H
#include <CGAL/license/Sweep_line_2.h>
#ifndef CGAL_SURFACE_SWEEP_2_IMPL_H
#define CGAL_SURFACE_SWEEP_2_IMPL_H
#include <CGAL/license/Surface_sweep_2.h>
/*! \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 <typename Tr, typename Vis, typename Subcv, typename Evnt,
typename Alloc>
void Sweep_line_2<Tr, Vis, Subcv, Evnt, Alloc>::_init_structures()
template <typename Vis>
void Surface_sweep_2<Vis>::_init_structures()
{
// Initailize the structures maintained by the base sweep-line class.
Base::_init_structures();
@ -49,9 +49,8 @@ void Sweep_line_2<Tr, Vis, Subcv, Evnt, Alloc>::_init_structures()
//-----------------------------------------------------------------------------
// Complete the sweep (complete the data structures).
//
template <typename Tr, typename Vis, typename Subcv, typename Evnt,
typename Alloc>
void Sweep_line_2<Tr, Vis, Subcv, Evnt, Alloc>::_complete_sweep()
template <typename Vis>
void Surface_sweep_2<Vis>::_complete_sweep()
{
CGAL_SL_PRINT_START_EOL("completing the sweep");
@ -78,9 +77,8 @@ void Sweep_line_2<Tr, Vis, Subcv, Evnt, Alloc>::_complete_sweep()
//-----------------------------------------------------------------------------
// Handle the subcurves to the left of the current event point.
//
template <typename Tr, typename Vis, typename Subcv, typename Evnt,
typename Alloc>
void Sweep_line_2<Tr, Vis, Subcv, Evnt, Alloc>::_handle_left_curves()
template <typename Vis>
void Surface_sweep_2<Vis>::_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<Tr, Vis, Subcv, Evnt, Alloc>::_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<Subcurve*>(*(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<Tr, Vis, Subcv, Evnt, Alloc>::_handle_left_curves()
//-----------------------------------------------------------------------------
// Handle the subcurves to the right of the current event point.
//
template <typename Tr, typename Vis, typename Subcv, typename Evnt,
typename Alloc>
void Sweep_line_2<Tr, Vis, Subcv, Evnt, Alloc>::_handle_right_curves()
template <typename Vis>
void Surface_sweep_2<Vis>::_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<Tr, Vis, Subcv, Evnt, Alloc>::_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<Subcurve*>(*prev), static_cast<Subcurve*>(*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<Tr, Vis, Subcv, Evnt, Alloc>::_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<Subcurve*>(*currentOne), static_cast<Subcurve*>(*prevOne)))
{
if (!this->m_currentEvent->are_left_neighbours(*currentOne, *prevOne))
_intersect(*prevOne, *currentOne);
}
prevOne = currentOne;
++currentOne;
@ -277,9 +271,7 @@ void Sweep_line_2<Tr, Vis, Subcv, Evnt, Alloc>::_handle_right_curves()
//the next Subcurve at the status line
++slIter;
if (slIter != this->m_statusLine.end())
_intersect(static_cast<Subcurve*>(*prevOne),
static_cast<Subcurve*>(*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<Tr, Vis, Subcv, Evnt, Alloc>::_handle_right_curves()
//-----------------------------------------------------------------------------
// Add a subcurve to the right of an event point.
//
template <typename Tr, typename Vis, typename Subcv, typename Evnt,
typename Alloc>
bool Sweep_line_2<Tr, Vis, Subcv, Evnt, Alloc>::
template <typename Vis>
bool Surface_sweep_2<Vis>::
_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<Base_subcurve*> list_of_sc;
std::list<Subcurve*> list_of_sc;
curve->distinct_nodes(*iter, std::back_inserter(list_of_sc));
typename std::list<Base_subcurve*>::iterator sc_iter;
typename std::list<Subcurve*>::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<Subcurve*>(*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 <typename Tr, typename Vis, typename Subcv, typename Evnt,
typename Alloc>
void Sweep_line_2<Tr, Vis, Subcv, Evnt, Alloc>::
_remove_curve_from_status_line(Subcurve* leftCurve, bool remove_for_good)
template <typename Vis>
void Surface_sweep_2<Vis>::_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<Subcurve*>(*prev),
static_cast<Subcurve*>(*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 <typename Tr, typename Vis, typename Subcv, typename Evnt,
typename Alloc>
void Sweep_line_2<Tr, Vis, Subcv, Evnt, Alloc>::_intersect(Subcurve* c1,
Subcurve* c2)
template <typename Vis>
void Surface_sweep_2<Vis>::_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<Tr, Vis, Subcv, Evnt, Alloc>::_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<float>(m_curves_pair_set.size()) /
m_curves_pair_set.bucket_count();
@ -485,9 +472,7 @@ void Sweep_line_2<Tr, Vis, Subcv, Evnt, Alloc>::_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<Event*>(c1->right_event()) ==
reinterpret_cast<Event*>(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<Tr, Vis, Subcv, Evnt, Alloc>::_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<Tr, Vis, Subcv, Evnt, Alloc>::_intersect(Subcurve* c1,
}
}
const std::pair<Point_2,Multiplicity>* xp_point;
const std::pair<Point_2, Multiplicity>* 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<Tr, Vis, Subcv, Evnt, Alloc>::_intersect(Subcurve* c1,
//-----------------------------------------------------------------------------
// Create an intersection-point event between two curves.
//
template <typename Tr, typename Vis, typename Subcv, typename Evnt,
typename Alloc>
void Sweep_line_2<Tr, Vis, Subcv, Evnt, Alloc>::
_create_intersection_point(const Point_2& xp,
unsigned int multiplicity,
Subcurve*& c1, Subcurve*& c2,
bool is_overlap)
template <typename Vis>
void Surface_sweep_2<Vis>::_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<Event*, bool>& 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 <typename Tr, typename Vis, typename Subcv, typename Evnt,
typename Alloc>
void Sweep_line_2<Tr, Vis, Subcv, Evnt, Alloc>::_fix_overlap_subcurves()
template <typename Vis>
void Surface_sweep_2<Vis>::_fix_overlap_subcurves()
{
CGAL_SL_PRINT_START_EOL("fixing overlap subcurves");
@ -709,8 +692,8 @@ void Sweep_line_2<Tr, Vis, Subcv, Evnt, Alloc>::_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<Tr, Vis, Subcv, Evnt, Alloc>::_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 <typename Tr, typename Vis, typename Subcv, typename Evnt,
typename Alloc>
void Sweep_line_2<Tr, Vis, Subcv, Evnt, Alloc>::
_handle_overlap(Event* event, Subcurve* curve, Event_subcurve_iterator iter,
bool overlap_exist)
template <typename Vis>
void Surface_sweep_2<Vis>::_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<Object> obj_vec;
std::vector<Object> 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<Event*, bool>& 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 <typename Tr, typename Vis, typename Subcv, typename Evnt,
typename Alloc>
void Sweep_line_2<Tr, Vis, Subcv, Evnt, Alloc>::
_fix_finished_overlap_subcurve(Subcurve* sc)
template <typename Vis>
void Surface_sweep_2<Vis>::_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 <typename Vis>
void Surface_sweep_2<Vis>::_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

Some files were not shown because too many files have changed in this diff Show More