diff --git a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/Arrangement_on_surface_2.txt b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/Arrangement_on_surface_2.txt index fb083d8b133..5c373ad3138 100644 --- a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/Arrangement_on_surface_2.txt +++ b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/Arrangement_on_surface_2.txt @@ -5111,8 +5111,8 @@ instantiate the curve-data traits: At this point we do not expose the topology traits concept. The package contains one topology traits, namely, -`Arr_spherical_topology_traits_2`. It can be served as a topology -traits for an arrangement embeded on a sphere. More precisely, for an +`Arr_spherical_topology_traits_2`. It can serve as a topology traits +for an arrangement embeded on a sphere. More precisely, for an arrangement embeded on a sphere defined over a parameter space the left and right boundary sides of which are identified and the top and bottom boundary sides are contracted. diff --git a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arr_spherical_topology_traits_2.h b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arr_spherical_topology_traits_2.h new file mode 100644 index 00000000000..eeed2041379 --- /dev/null +++ b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arr_spherical_topology_traits_2.h @@ -0,0 +1,104 @@ +namespace CGAL { + +/*! \ingroup PkgArrangementOnSurface2Ref + * + * \anchor arr_ref_spherical_topology_traits + * + * This class handles the topology for arrangements of great spherical + * arcs on the sphere embedded on 2D parametric surdace. + * + * The `Arr_spherical_topology_traits_2` template has two parameters: + * + * + * \sa `Arr_default_dcel` + * \sa `CGAL::Arr_geodesic_arc_on_sphere_traits_2` + */ +template > +class Arr_spherical_topology_traits_2 { +public: + /// \name Types + /// @{ + + typedef typename GeometryTraits_2::Point_2 Point_2; + typedef typename GeometryTraits_2::X_monotone_curve_2 X_monotone_curve_2; + + 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 Creation + /// @{ + + /*! Default constructor. */ + Arr_spherical_topology_traits_2(); + + /*! Constructor from a geometry-traits object. + * \param traits the traits. + */ + Arr_spherical_topology_traits_2(const GeometryTraits_2* traits); + + /// @} + + /// \name Accessors + /// @{ + + /*! Obtain the DCEL (const version). */ + const Dcel& dcel() const; + + /*! Obtain the DCEL (non-const version). */ + Dcel& dcel(); + + /*! Obtain the spherical face (const version). */ + const Face* spherical_face() const; + + /*! Obtain the spherical face (non-const version). */ + Face* spherical_face(); + + /*! Obtain the south pole (const version). */ + const Vertex* south_pole() const; + + /*! Obtain the south pole (non-const version). */ + Vertex* south_pole(); + + /*! Obtain the north pole (const version). */ + const Vertex* north_pole() const; + + /*! Obtain the north pole (non-const version). */ + Vertex* north_pole(); + + /*! Obtain a vertex on the line of discontinuity that corresponds to + * the given point (or return NULL if no such vertex exists). + */ + const Vertex* discontinuity_vertex(const Point_2& pt) const; + + /*! Obtain a vertex on the line of discontinuity that corresponds to + * the given point (or return NULL if no such vertex exists). + */ + Vertex* discontinuity_vertex(const Point_2& pt); + + /// @} + + /// \name Modifiers + /// @{ + /// @} +}; + +} diff --git a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/PackageDescription.txt b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/PackageDescription.txt index ff392f23c74..d82ada01e9d 100644 --- a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/PackageDescription.txt +++ b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/PackageDescription.txt @@ -225,6 +225,7 @@ implemented as peripheral classes or as free (global) functions. - `CGAL::Arr_vertex_index_map` - `CGAL::Arr_face_index_map` - `CGAL::Arr_point_location_result` +- `CGAL::Arr_spherical_topology_traits_2` \cgalCRPSection{Macros} - \link CGAL_ARR_POINT_LOCATION_VERSION `CGAL_ARR_POINT_LOCATION_VERSION` \endlink diff --git a/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/dual_with_data.cpp b/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/dual_with_data.cpp index 40ad8492614..99f927f6874 100644 --- a/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/dual_with_data.cpp +++ b/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/dual_with_data.cpp @@ -2,12 +2,16 @@ // Checking whether there are three collinear points in a given input set // using the arrangement of the dual lines. +#include + #include #include #include #include #include +#include "read_objects.h" + typedef CGAL::Cartesian Kernel; typedef CGAL::Arr_linear_traits_2 Linear_traits_2; typedef Linear_traits_2::Point_2 Point_2; @@ -21,56 +25,30 @@ int main(int argc, char *argv[]) { // Get the name of the input file from the command line, or use the default // points.dat file if no command-line parameters are given. - const char * filename = (argc > 1) ? argv[1] : "coll_points.dat"; + const char* filename = (argc > 1) ? argv[1] : "coll_points.dat"; - // Open the input file. - std::ifstream in_file(filename); + std::vector points; - if (! in_file.is_open()) { - std::cerr << "Failed to open " << filename << " ..." << std::endl; - return (1); - } - - // Read the points from the file, and construct their dual lines. - std::vector points; - std::list dual_lines; - - unsigned int n; - in_file >> n; - points.resize(n); - unsigned int k; - for (k = 0; k < n; ++k) { - int px, py; - in_file >> px >> py; - points[k] = Point_2(px, py); - - // The line dual to the point (p_x, p_y) is y = p_x*x - p_y, - // or: p_x*x - y - p_y = 0: - Line_2 dual_line = Line_2(CGAL::Exact_rational(px), - CGAL::Exact_rational(-1), - CGAL::Exact_rational(-py)); - - // Generate the x-monotone curve based on the line and the point index. - dual_lines.push_back(X_monotone_curve_2(dual_line, k)); - } - in_file.close(); + read_objects(filename, std::back_inserter(points)); + std::vector dual_lines(points.size()); + size_t k{0}; + std::transform(points.begin(), points.end(), dual_lines.begin(), + [&](const Point_2& p) { + Line_2 dual_line(p.x(), CGAL::Exact_rational(-1), -(p.y())); + return X_monotone_curve_2(dual_line, k++); + }); // Construct the dual arrangement by aggregately inserting the lines. Arrangement_2 arr; - insert(arr, dual_lines.begin(), dual_lines.end()); // Look for vertices whose degree is greater than 4. - Arrangement_2::Vertex_const_iterator vit; - Arrangement_2::Halfedge_around_vertex_const_circulator circ; - size_t d; - - for (vit = arr.vertices_begin(); vit != arr.vertices_end(); ++vit) { + for (auto vit = arr.vertices_begin(); vit != arr.vertices_end(); ++vit) { if (vit->degree() > 4) { // There should be vit->degree()/2 lines intersecting at the current // vertex. We print their primal points and their indices. - circ = vit->incident_halfedges(); - for (d = 0; d < vit->degree() / 2; d++) { + auto circ = vit->incident_halfedges(); + for (auto d = 0; d < vit->degree() / 2; ++d) { k = circ->curve().data(); // The index of the primal point. std::cout << "Point no. " << k+1 << ": (" << points[k] << "), "; ++circ;