diff --git a/Cone_spanners_2/doc/Cone_spanners_2/Concepts/ComputeConeBoundaries_2.h b/Cone_spanners_2/doc/Cone_spanners_2/Concepts/ComputeConeBoundaries_2.h deleted file mode 100644 index ee911b0b688..00000000000 --- a/Cone_spanners_2/doc/Cone_spanners_2/Concepts/ComputeConeBoundaries_2.h +++ /dev/null @@ -1,48 +0,0 @@ -/*! -\ingroup PkgConeBasedSpannersConcepts -\cgalConcept - -The concept `ComputeConeBoundaries_2` describes the set of requirements for the functor that -computes the directions of cone boundaries with a given cone number and a given initial direction -either exactly or inexactly. - -\cgalHasModel `CGAL::Compute_cone_boundaries_2` - -*/ -template -class ComputeConeBoundaries_2 { -public: - -/// \name Types -/// @{ - -/*! The CGAL kernel type used by the functor. - Its requirements are described in the concept `ConeBasedSpannerTraits_2`. -*/ -typedef Traits Kernel_type; - -/// @} - - -/// \name Operator -/// @{ - -/*! \brief The operator(). - * - * Compute the directions of cone boundaries with a given - * cone number and a given initial direction. The results are returned by the reference - * argument: vector \p rays. - * - * \param[in] cone_number The number of cones - * \param[in] initial_direction The direction of the first ray - * \param[out] rays Storing the results, a vector of directions. It should contain no - * elements when passed to this operator. - */ -void operator()(const unsigned int cone_number, - Direction_2& initial_direction, - std::vector& rays); - -/// @} - -}; /* end ComputeConeBoundaries_2 */ - diff --git a/Cone_spanners_2/doc/Cone_spanners_2/Concepts/ConeBasedSpannerTraits_2.h b/Cone_spanners_2/doc/Cone_spanners_2/Concepts/ConeBasedSpannerTraits_2.h deleted file mode 100644 index 98beb51c36f..00000000000 --- a/Cone_spanners_2/doc/Cone_spanners_2/Concepts/ConeBasedSpannerTraits_2.h +++ /dev/null @@ -1,96 +0,0 @@ -/*! -\ingroup PkgConeBasedSpannersConcepts -\cgalConcept - -The concept `ConeBasedSpannerTraits_2` specifies the requirements -for the CGAL kernels that can be used in this package. -Basically, this concept describes all the types and primitives (predicates and construction objects) -that the CGAL kernel should include to make this package work properly. -Simply put, for the exact construction of the cone-based spanners, -the kernel `CGAL::Exact_predicates_exact_constructions_kernel_with_root_of` -should be used; and for the inexact construction, the kernel -`CGAL::Exact_predicates_inexact_constructions_kernel` should be used. - -\cgalHasModel `CGAL::Exact_predicates_exact_constructions_kernel_with_root_of` -\cgalHasModel `CGAL::Exact_predicates_inexact_constructions_kernel` - -*/ - -class ConeBasedSpannerTraits_2 { -public: - -/// \name Types -/// @{ - -/*! -The point type. -*/ -typedef unspecified_type Point_2; - -/*! -The line type. -*/ -typedef unspecified_type Line_2; - -/*! -The direction type. -*/ -typedef unspecified_type Direction_2; - -/*! -The affine transformation type. This is needed to rotate directions. -*/ -typedef unspecified_type Aff_transformation_2; - -/*! -The polynomial type. When the cone angle \f$ \theta \f$ is in the form of -\f$ 2\pi / n \f$, where \f$ n \f$ is a positive integer, \f$ \sin(\theta) \f$ -and \f$ \cos(\theta) \f$ can be represented exactly by roots of polynomials. -Thus, this polynomial type is needed to avoid the computation by calling -sin() and cos(). -*/ -typedef unspecified_type Polynomial; - -/// @} - - -/// \name Functions -/// The following functions are needed to construct cone-based spanners. -/// @{ - -/*! - This function should return the k-th real root of an univariate polynomial, which is defined - by the iterator range, where 'begin' refers to the constant term. - It is needed in calculating cone boundaries exactly. -*/ -NT CGAL::root_of(int k, InputIterator begin, InputIterator end); - -/* - This function should return the square root of the argument `x`. - It is needed in calculating cone boundaries exactly. - -NT CGAL::sqrt(const NT & x); -*/ - -/*! - This functor should return the bisector of the two lines l1 and l2. - And the bisector should have the direction of the vector which is the sum of - the normalized directions of the two lines. - It is needed in constructing Theta graphs, not in constructing Yao graphs. -*/ -Kernel::Line_2 Kernel::ConstructBisector_2::operator() ( const Kernel::Line_2 & l1, - const Kernel::Line_2 & l2 ); - -/*! - This function should return CGAL::LARGER iff the signed distance of p and l - is larger than the signed distance of q and l, CGAL::SMALLER, iff it is smaller, - and CGAL::EQUAL iff both are equal. - It is needed in sorting the points on the plane based on a certain direction. -*/ -Comparison_result CGAL::compare_signed_distance_to_line( - const CGAL::Line_2 &l, - const CGAL::Point_2 &p, - const CGAL::Point_2 &q); -/// @} - -}; /* end ConeBasedSpannerTraits_2 */ diff --git a/Cone_spanners_2/doc/Cone_spanners_2/Concepts/ConstructConeBasedSpanner_2.h b/Cone_spanners_2/doc/Cone_spanners_2/Concepts/ConstructConeBasedSpanner_2.h deleted file mode 100644 index b38e45abc5a..00000000000 --- a/Cone_spanners_2/doc/Cone_spanners_2/Concepts/ConstructConeBasedSpanner_2.h +++ /dev/null @@ -1,97 +0,0 @@ -/*! -\ingroup PkgConeBasedSpannersConcepts -\cgalConcept - -The concept `ConstructConeBasedSpanner_2` describes the set of requirements to be fulfilled by any functor class that -constructs a cone based spanner, such as a Theta graph and a Yao graph, etc. - -\cgalHasModel `CGAL::Construct_theta_graph_2` -\cgalHasModel `CGAL::Construct_yao_graph_2` - -*/ -template -class ConstructConeBasedSpanner_2 { -public: - -/// \name Types -/// @{ - -/*! The CGAL kernel type used by the functor. Its requirements are described in - the concept `ConeBasedSpannerTraits_2`. -*/ -typedef Traits Kernel_type; - -/*! The graph type to store the constructed cone based spanner. - This package requires the use of the `boost::adjacency_list` in the Boost Graph Library as - the graph type. Note that there are seven template parameters for - `boost::adjacency_list`: `OutEdgeList`, `VertexList`, `Directed`, `VertexProperties`, `EdgeProperties`, - `GraphProperties`, `EdgeList`, of which we require the `VertexProperties` be `CGAL::Point_2`, - while other parameters can be chosen freely. Here the CGAL kernel type used by `CGAL::Point_2` is - determined by the first template parameter `Traits`, and we pass `CGAL::Point_2` directly - to `adjacency_list` as bundled properties because this makes our implementation much more - straightforward than using property maps. - For detailed information about bundled properties, please refer to - http://www.boost.org/doc/libs/1_58_0/libs/graph/doc/bundles.html. - If more properties for vertices are needed, they can be added later as external properties using - property maps. -*/ -typedef Graph_ Graph_type; - -/*! The directon type. -*/ - typedef Traits::Direction_2 Direction_2; - -/// @} - - -/// \name Creation -/// @{ - -/*! \brief Constructor. - - \param k Number of cones to divide the plane - \param initial_direction A direction denoting one of the rays dividing the - cones. This allows arbitary rotations of the rays that divide - the plane. (default: positive x-axis) -*/ -Construct_spanner_2(unsigned int k, Direction_2 initial_direction = Direction_2(1,0) ); - -/// @} - -/// \name Operator -/// @{ - -/*! \brief Function operator to construct a cone based spanner. - * - * \tparam PointInputIterator This template parameter is to give the application developer freedom - * in choosing whichever iterator he will use to input the coordinates of the points. - * If omitted, the type of the Iterator can be inferred from the arguments passed to the - * operator(). - * - * \param[in] start An iterator pointing to the first point (vertex). - * \param[in] end Past-the-end iterator. - * \param[out] g The constructed graph object. - */ -template -Graph_& operator()(const PointInputIterator& start, - const PointInputIterator& end, - Graph_& g); - - -/// @} - -/// \name Member Access Functions -/// @{ - -/*! \brief returns the number of cones in this graph. - */ -const unsigned int number_of_cones() const; - -/*! \brief returns the vector of the directions of the rays dividing the plane. - */ -const std::vector& directions() const; - -/// @} - -}; /* end ConstructConeBasedSpanner_2 */ - diff --git a/Cone_spanners_2/doc/Cone_spanners_2/PackageDescription.txt b/Cone_spanners_2/doc/Cone_spanners_2/PackageDescription.txt index 740f1c6b511..a8c60ebd8c9 100644 --- a/Cone_spanners_2/doc/Cone_spanners_2/PackageDescription.txt +++ b/Cone_spanners_2/doc/Cone_spanners_2/PackageDescription.txt @@ -1,7 +1,6 @@ // PRETTY PACKAGE NAME should equal the project title in Doxyfile.in /// \defgroup PkgConeBasedSpanners Cone-Based Spanners Reference -/// \defgroup PkgConeBasedSpannersConcepts Concepts /// \ingroup PkgConeBasedSpanners /*! @@ -34,10 +33,6 @@ generate the data and script files used by Gnuplot to plot the constructed graph \cgalClassifedRefPages -## Concepts ## -- `ConeBasedSpannerTraits_2` -- `ComputeConeBoundaries_2` -- `ConstructConeBasedSpanner_2` ## Functors ## - `CGAL::Compute_cone_boundaries_2` diff --git a/Cone_spanners_2/include/CGAL/Compute_cone_boundaries_2.h b/Cone_spanners_2/include/CGAL/Compute_cone_boundaries_2.h index ac06c818d89..f657df17431 100644 --- a/Cone_spanners_2/include/CGAL/Compute_cone_boundaries_2.h +++ b/Cone_spanners_2/include/CGAL/Compute_cone_boundaries_2.h @@ -47,34 +47,31 @@ namespace CGAL { * \brief The functor for computing the directions of cone boundaries with a given * cone number and a given initial direction. * - * This computation can be either inexact by simply dividing an approximate Pi by the cone number - * (which is quick), or exact by using roots of polynomials (requiring number types such as `CORE::Expr` or `LEDA::Real`, + * This computation can be either inexact by simply dividing an approximate \f$ \pi \f$ by the cone number + * (which is quick), or exact by using roots of polynomials (requiring number types such as `CORE::Expr` or `leda_real`, * which are slow). The inexact computation is done by the general functor definition, * while the exact computation is done by a specialization of this functor. * - * \tparam Traits must be a model of `ConeBasedSpannerTraits_2`. - * Simply put, if this parameter is - * `Exact_predicates_exact_constructions_kernel_with_root_of`, - * the specialization functor will be called; otherwise, the general functor will - * be called. - * * In the construction of cone-based spanners such as Yao graph and Theta graph implemented by this package, * this functor is called first to compute the cone boundaries. * Of course, this functor can also be used in other applications where the plane needs to be divided * into equally-angled cones. * - * \cgalModels `ComputeConeBoundaries_2` + * \tparam Traits_ must be either `CGAL::Exact_predicates_exact_constructions_kernel_with_root_of` or `CGAL::Exact_predicates_inexact_constructions_kernel`. * */ -template +template class Compute_cone_boundaries_2 { public: - /*! Indicate the type of the \cgal kernel. */ - typedef Traits Kernel_type; + /*! the geometric traits class. */ + typedef Traits_ Traits; + + /*! the direction type. */ + typedef typename Traits::Direction_2 Direction_2; private: - typedef typename Traits::Direction_2 Direction_2; + typedef typename Traits::Aff_transformation_2 Transformation; public: @@ -90,6 +87,7 @@ public: * and output them to `result` in the counterclockwise order. * Finally, the past-the-end iterator for the resulting directions is returned. * + * \tparam DirectionOutputIterator an `OutputIterator` with value type `Direction_2`. * \param cone_number The number of cones * \param initial_direction The direction of the first ray * \param result The output iterator @@ -100,7 +98,7 @@ public: DirectionOutputIterator result) { if (cone_number<2) { std::cout << "The number of cones must be larger than 1!" << std::endl; - std::exit(1); + CGAL_assertion(false); } *result++ = initial_direction; diff --git a/Cone_spanners_2/include/CGAL/Construct_theta_graph_2.h b/Cone_spanners_2/include/CGAL/Construct_theta_graph_2.h index 2de27f19cee..552c918b62f 100644 --- a/Cone_spanners_2/include/CGAL/Construct_theta_graph_2.h +++ b/Cone_spanners_2/include/CGAL/Construct_theta_graph_2.h @@ -44,23 +44,31 @@ namespace CGAL { \brief A template functor for constructing Theta graphs with a given set of 2D points and a given initial direction for the cone boundaries. - For the meaning and use of its template parameters, please refer to the concept - `ConstructConeBasedSpanner_2`. - - \cgalModels `ConstructConeBasedSpanner_2` + \tparam Traits_ must be either `CGAL::Exact_predicates_exact_constructions_kernel_with_root_of` or `CGAL::Exact_predicates_inexact_constructions_kernel`. + +\tparam Graph_ is the graph type to store the constructed cone based spanner. + It must be `boost::adjacency_list` with `Traits_::Point_2` as `VertexProperties`. */ -template +template class Construct_theta_graph_2 { public: - /*! Indicate the type of the \cgal kernel. */ - typedef Traits Kernel_type; - /*! Indicate the specific type of `boost::adjacency_list`. */ - typedef Graph_ Graph_type; + + /*! the geometric traits class. */ + typedef Traits_ Traits; + + /*! the specific type of `boost::adjacency_list`. */ + typedef Graph_ Graph; + + /*! the point type */ + typedef typename Traits::Point_2 Point_2; + + /*! the direction type */ + typedef typename Traits::Direction_2 Direction_2; private: - typedef typename Traits::Direction_2 Direction_2; - typedef typename Traits::Point_2 Point_2; + + typedef typename Traits::Line_2 Line_2; typedef typename Traits::Aff_transformation_2 Transformation; typedef Less_by_direction_2 Less_by_direction; @@ -88,7 +96,7 @@ public: { if (k<2) { std::cout << "The number of cones must be larger than 1!" << std::endl; - std::exit(1); + CGAL_assertion(false); } /* Initialize a functor, specialization will happen here depending on the kernel type to @@ -99,7 +107,7 @@ public: } /* \brief Copy constructor. As commented by Michael Hemmer, copy constructor is not needed for - a funtor. + a functor. \param x another Construct_theta_graph_2 object to copy from. Construct_theta_graph_2 (const Construct_theta_graph_2& x) : cone_number(x.cone_number), rays(x.rays) {} @@ -108,9 +116,9 @@ public: /*! \brief Function operator to construct a Theta graph. - \details This operator implements the algorithm for constructing the Theta graph. - For the details of this algorithm, please refer to the user manual. + \details For the details of this algorithm, please refer to the User Manual. + \tparam PointInputIterator an `InputIterator` with value type `Point_2`. \param[in] start An iterator pointing to the first vertex of the input. \param[in] end An iterator pointing to the past-the-end location of the input. \param[out] g The constructed graph object. @@ -143,8 +151,9 @@ public: return cone_number; } - /*! \brief outputs the directions in the vector rays to the iterator `result`. + /*! \brief outputs the set of directions to the iterator `result`. + \tparam DirectionOutputIterator an `OutputIterator` with value type `Direction_2`. \return `result` */ template diff --git a/Cone_spanners_2/include/CGAL/Construct_yao_graph_2.h b/Cone_spanners_2/include/CGAL/Construct_yao_graph_2.h index e629fc93ec7..e50a32b90f1 100644 --- a/Cone_spanners_2/include/CGAL/Construct_yao_graph_2.h +++ b/Cone_spanners_2/include/CGAL/Construct_yao_graph_2.h @@ -42,23 +42,28 @@ namespace CGAL { \brief A template functor for constructing Yao graphs with a given set of 2D points and a given initial direction for the cone boundaries. - For the meaning and use of its template parameters, please refer to the concept - `ConstructConeBasedSpanner_2`. + \tparam Traits_ must be either `CGAL::Exact_predicates_exact_constructions_kernel_with_root_of` or `CGAL::Exact_predicates_inexact_constructions_kernel`. + +\tparam Graph_ is the graph type to store the constructed cone based spanner. + It must be `boost::adjacency_list` with `Traits_::Point_2` as `VertexProperties` - \cgalModels `ConstructConeBasedSpanner_2` */ -template +template class Construct_yao_graph_2 { public: - /*! Indicate the type of the \cgal kernel. */ - typedef Traits Kernel_type; - /*! Indicate the specific type of `boost::adjacency_list`. */ - typedef Graph_ Graph_type; + /*! the geometric traits class. */ + typedef Traits_ Traits; + /*! the specific type of `boost::adjacency_list`. */ + typedef Graph_ Graph; + + /*! the point type */ + typedef typename Traits::Point_2 Point_2; + + /*! the direction type */ + typedef typename Traits::Direction_2 Direction_2; private: - typedef typename Traits::Direction_2 Direction_2; - typedef typename Traits::Point_2 Point_2; typedef typename Traits::Line_2 Line_2; typedef Less_by_direction_2 Less_by_direction; // a type for the set to store vertices sorted by a direction @@ -87,7 +92,7 @@ public: { if (k<2) { std::cout << "The number of cones must be larger than 1!" << std::endl; - std::exit(1); + CGAL_assertion(false); } /* Initialize a functor, specialization will happen here depending on the kernel type to @@ -104,12 +109,12 @@ public: */ /*! - \brief Function operator to construct a Yao graph. + \brief Function operator to construct a Yao graph. - \details This operator implements the algorithm for constructing the Yao graph. - The algorithm implemented is an adaptation from the algorithm for constructing Theta graph. - For more details, please refer to the user manual. + \details For the details of this algorithm, please refer to the User Manual. + \tparam PointInputIterator an `InputIterator` with value type `Point_2`. + \param[in] start An iterator pointing to the first vertex of the input. \param[in] end An iterator pointing to the past-the-end location of the input. \param[out] g The constructed graph object. @@ -142,8 +147,9 @@ public: return cone_number; } - /*! \brief outputs the directions in the vector rays to the iterator `result`. + /*! \brief outputs the set of directions to the iterator `result`. + \tparam DirectionOutputIterator an `OutputIterator` with value type `Direction_2`. \return `result` */ template