diff --git a/Minkowski_sum_2/doc/Minkowski_sum_2/CGAL/Polygon_convex_decomposition_2.h b/Minkowski_sum_2/doc/Minkowski_sum_2/CGAL/Polygon_convex_decomposition_2.h new file mode 100644 index 00000000000..eef8d2ea2ba --- /dev/null +++ b/Minkowski_sum_2/doc/Minkowski_sum_2/CGAL/Polygon_convex_decomposition_2.h @@ -0,0 +1,104 @@ +namespace CGAL { + +/*! +\ingroup PkgMinkowskiSum2 + +\anchor mink_refGreene_decomp + +The `Greene_convex_decomposition_2` class implements the approximation algorithm of +Greene for the decomposition of an input polygon into convex +sub-polygons \cgalCite{g-dpcp-83}. This algorithm takes \f$ O(n \log n)\f$ +time and \f$ O(n)\f$ space, where \f$ n\f$ is the size of the input polygon, +and outputs a decomposition whose size is guaranteed to be no more +than four times the size of the optimal decomposition. + +\tparam Kernel must be a geometric kernel that can be used for the polygon. +\tparam Container must be a container that can be used for the polygon. +It is by default `std::vector`. + +\cgalModels `PolygonConvexDecomposition_2` + +\sa `CGAL::greene_approx_convex_partition_2()` + +*/ +template< typename Kernel, typename Container > +class Greene_convex_decomposition_2 { +public: + + typedef CGAL::Polygon_2 Polygon_2; + +/// @} + +}; /* end Greene_convex_decomposition_2 */ +} /* end namespace CGAL */ + +namespace CGAL { + +/*! +\ingroup PkgMinkowskiSum2Classes + +\anchor mink_refHM_decomp + +The `Hertel_Mehlhorn_convex_decomposition_2` class implements the approximation algorithm of Hertel +and Mehlhorn for decomposing a polygon into convex +sub-polygons \cgalCite{hm-ftsp-83}. This algorithm constructs a +triangulation of the input polygon and proceeds by removing +unnecessary triangulation edges. Given the triangulation, the +algorithm requires \f$ O(n)\f$ time and space to construct a convex +decomposition (where \f$ n\f$ is the size of the input polygon), whose +size is guaranteed to be no more than four times the size of the +optimal decomposition. + +\tparam Kernel must be a geometric kernel that can be used for the polygon. +\tparam Container must be a container that can be used for the polygon. +It is by default `std::vector`. + +\cgalModels `PolygonConvexDecomposition_2` + +\sa `CGAL::approx_convex_partition_2()` + +*/ +template< typename Kernel, typename Container > +class Hertel_Mehlhorn_convex_decomposition_2 { +public: + + typedef CGAL::Polygon_2 Polygon_2; + +/// @} + +}; /* end Hertel_Mehlhorn_convex_decomposition_2 */ +} /* end namespace CGAL */ + +namespace CGAL { + +/*! +\ingroup PkgMinkowskiSum2 + +\anchor mink_refopt_decomp + +The `Optimal_convex_decomposition_2` class provides an implementation of Greene's +dynamic programming algorithm for optimal decomposition of a +polygon into convex sub-polygons \cgalCite{g-dpcp-83}. Note that +this algorithm requires \f$ O(n^4)\f$ time and \f$ O(n^3)\f$ space in +the worst case, where \f$ n\f$ is the size of the input polygon. + + +\tparam Kernel must be a geometric kernel that can be used for the polygon. +\tparam Container must be a container that can be used for the polygon. +It is by default `std::vector`. + +\cgalModels `PolygonConvexDecomposition_2` + +\sa `CGAL::optimal_convex_partition_2()` + +*/ +template< typename Kernel, typename Container > +class Optimal_convex_decomposition_2 { +public: + + typedef CGAL::Polygon_2 Polygon_2; + +/// @} + +}; /* end Optimal_convex_decomposition_2 */ +} /* end namespace CGAL */ diff --git a/Minkowski_sum_2/doc/Minkowski_sum_2/CGAL/Small_side_angle_bisector_decomposition_2.h b/Minkowski_sum_2/doc/Minkowski_sum_2/CGAL/Small_side_angle_bisector_decomposition_2.h new file mode 100644 index 00000000000..d507f0ef196 --- /dev/null +++ b/Minkowski_sum_2/doc/Minkowski_sum_2/CGAL/Small_side_angle_bisector_decomposition_2.h @@ -0,0 +1,34 @@ +namespace CGAL { + +/*! +\ingroup PkgMinkowskiSum2 + +\anchor mink_refssab_decomp + +The `Small_side_angle_bisector_decomposition_2` class implements a simple yet efficient heuristic for +decomposing an input polygon into convex sub-polygons. It is based +on the algorithm suggested by Flato and Halperin \cgalCite{fh-recpm-00}, +but without introducing Steiner points. The algorithm operates in two +major steps. In the first step, it tries to subdivide the polygon by +connect two reflex vertices with an edge. When this is not possible any +more, it eliminates the reflex vertices one by one by connecting them +to other convex vertices, such that the new edge best approximates +the angle bisector of the reflex vertex. The algorithm operates in +\f$ O(n^2)\f$ time an takes \f$ O(n)\f$ space at the worst case, where \f$ n\f$ is the +size of the input polygon. + +The `Polygon_2` type defined by the class is simply +`Polygon_2`. The `Container` parameter +is by default `std::vector`. + +\cgalModels `PolygonConvexDecomposition_2` + +*/ +template< typename Kernel, typename Container > +class Small_side_angle_bisector_decomposition_2 { +public: + +/// @} + +}; /* end Small_side_angle_bisector_decomposition_2 */ +} /* end namespace CGAL */ diff --git a/Minkowski_sum_2/doc/Minkowski_sum_2/CGAL/approximated_offset_2.h b/Minkowski_sum_2/doc/Minkowski_sum_2/CGAL/approximated_offset_2.h new file mode 100644 index 00000000000..c6f376b9bae --- /dev/null +++ b/Minkowski_sum_2/doc/Minkowski_sum_2/CGAL/approximated_offset_2.h @@ -0,0 +1,89 @@ +namespace CGAL { + +/*! +\ingroup PkgMinkowskiSum2 + +Provides a guaranteed approximation of the inset, or inner offset, of +the given polygon `P` by a given radius `r`. Namely, the +function computes the set of points inside the polygon whose distance +from \f$ P\f$'s boundary is at least \f$ r\f$: +\f$ \{ p \in P \;|\; {\rm dist}(p, \partial P) \geq r \}\f$, +with the approximation error bounded by `eps`. +Note that as the input polygon may not be convex, its inset may comprise +several disconnected components. The result is therefore represented as a +sequence of generalized polygons, whose edges are either line segments or +circular arcs. +The output sequence is returned via the output iterator `oi`, whose +value-type must be `Gps_circle_segment_traits_2::Polygon_2`. +\pre `P` is a simple polygon. +*/ +template +OutputIterator +approximated_inset_2 (const Polygon_2& pgn, +const typename Kernel::FT& r, +const double& eps, +OutputIterator oi); + +} /* namespace CGAL */ + +namespace CGAL { + +/*! +\ingroup PkgMinkowskiSum2 + +Provides a guaranteed approximation of the offset of the given polygon +`P` by a given radius `r` - namely, the function computes the +Minkowski sum \f$ P \oplus B_r\f$, where \f$ B_r\f$ is a disc of radius +`r` centered at the origin. +The function actually outputs a set \f$ S\f$ that contains the Minkowski sum, +such that the approximation error is bounded by `eps`. +Note that as the input polygon may not be convex, its offset may not be a +simple polygon. The result is therefore represented as a polygon with +holes, whose edges are either line segments or circular arcs. +\pre `P` is a simple polygon. +*/ +template +typename Gps_circle_segment_traits_2::Polygon_with_holes_2 +approximated_offset_2 (const Polygon_2& P, +const typename Kernel::FT& r, +const double& eps); + +/*! +\ingroup PkgMinkowskiSum2 + +Provides a guaranteed approximation of offset the given polygon with holes +`pwh` by a given radius `r`, such that the approximation error is bounded +by `eps`. It does so by offsetting outer boundary of `pwh` and insetting +its holes. +The result is represented as a generalized polygon with holes, such that the edges +of the polygon correspond to line segment and circular arcs. +\pre `pwh` is not unbounded (it has a valid outer boundary). +*/ +template +typename Gps_circle_segment_traits_2::Polygon_with_holes_2 +approximated_offset_2 (const Polygon_with_holes_2& wh, +const typename Kernel::FT& r, +const double& eps); + +/*! +\ingroup PkgMinkowskiSum2 + +Provides a guaranteed approximation of the offset of the given polygon +`P` by a radius `r`, as described above. +If the input polygon `P` is not convex, the function +decomposes it into convex sub-polygons \f$ P_1, \ldots, P_k\f$ and computes +the union of the sub-offsets (namely \f$ \bigcup_{i}{(P_i \oplus B_r)}\f$). +The decomposition is performed using the given decomposition strategy +`decomp`, which must be an instance of a class that models the +concept `PolygonConvexDecomposition`. +\pre `P` is a simple polygon. +*/ +template +typename Gps_circle_segment_traits_2::Polygon_with_holes_2 +approximated_offset_2 (const Polygon_2& P, +const typename Kernel::FT& r, +const double& eps, +const DecompositionStrategy& decomp); + +} /* namespace CGAL */ diff --git a/Minkowski_sum_2/doc/Minkowski_sum_2/CGAL/minkowski_sum_2.h b/Minkowski_sum_2/doc/Minkowski_sum_2/CGAL/minkowski_sum_2.h new file mode 100644 index 00000000000..dcc889942eb --- /dev/null +++ b/Minkowski_sum_2/doc/Minkowski_sum_2/CGAL/minkowski_sum_2.h @@ -0,0 +1,44 @@ +namespace CGAL { + +/*! +\ingroup PkgMinkowskiSum2 + +Computes the Minkowski sum \f$ P \oplus Q\f$ of the two given polygons. +The function computes the convolution cycles of the two polygons and +extract the regions having positive winding number with respect to these +cycles. This method work very efficiently, regardless of whether `P` +and `Q` are convex or non-convex. +Note that as the input polygons may not be convex, their Minkowski +sum may not be a simple polygon. The result is therefore represented +as a polygon with holes. +\pre Both `P` and `Q` are simple polygons. +*/ +template +Polygon_with_holes_2 +minkowski_sum_2 (const Polygon_2& P, +const Polygon_2& Q); + +/*! +\ingroup PkgMinkowskiSum2 + +Computes the Minkowski sum \f$ P \oplus Q\f$ of the two given polygons. +If the input polygons `P` and `Q` are not convex, the function +decomposes them into convex sub-polygons \f$ P_1, \ldots, P_k\f$ and +\f$ Q_1, \ldots, Q_{\ell}\f$ and computes the union of pairwise sub-sums +(namely \f$ \bigcup_{i,j}{(P_i \oplus Q_j)}\f$). +The decomposition is performed using the given decomposition strategy +`decomp`, which must be an instance of a class that models the +concept `PolygonConvexDecomposition`. +Note that as the input polygons may not be convex, their Minkowski +sum may not be a simple polygon. The result is therefore represented +as a polygon with holes. +\pre Both `P` and `Q` are simple polygons. +*/ +template +Polygon_with_holes_2 +minkowski_sum_2 (const Polygon_2& P, +const Polygon_2& Q, +const DecompositionStrategy& decomp); + +} /* namespace CGAL */ diff --git a/Minkowski_sum_2/doc/Minkowski_sum_2/CGAL/offset_polygon_2.h b/Minkowski_sum_2/doc/Minkowski_sum_2/CGAL/offset_polygon_2.h new file mode 100644 index 00000000000..e149088efd5 --- /dev/null +++ b/Minkowski_sum_2/doc/Minkowski_sum_2/CGAL/offset_polygon_2.h @@ -0,0 +1,95 @@ +namespace CGAL { + +/*! +\ingroup PkgMinkowskiSum2 + +Computes the inset, or inner offset, of the given polygon `P` by a +given radius `r` - namely, the function computes the set of points +inside the polygon whose distance from \f$ P\f$'s boundary is at least \f$ r\f$: +\f$ \{ p \in P \;|\; {\rm dist}(p, \partial P) \geq r \}\f$. +Note that as the input polygon may not be convex, its inset may comprise +several disconnected components. The result is therefore represented as a +sequence of generalized polygons, such that the edges of each polygon +correspond to line segments and circular arcs, both are special types of +conic arcs, as represented by the `traits` class. +The output sequence is returned via the output iterator `oi`, whose +value-type must be `Gps_traits_2::Polygon_2`. +\pre `P` is a simple polygon. +*/ +template +OutputIterator inset_polygon_2 +(const Polygon_2& P, +const typename ConicTraits::Rat_kernel::FT& r, +const ConicTraits& traits, +OutputIterator oi); + +} /* namespace CGAL */ + +namespace CGAL { + +/*! +\ingroup PkgMinkowskiSum2 + +Computes the offset of the given polygon `P` by a given radius +`r` - namely, the function computes the Minkowski sum +\f$ P \oplus B_r\f$, where \f$ B_r\f$ is a disc of radius `r` centered at the +origin. +Note that as the input polygon may not be convex, its offset may not be a +simple polygon. The result is therefore represented as a generalized +polygon with holes, such that the edges of the polygon correspond to +line segments and circular arcs, both are special types of conic arcs, +as represented by the `traits` class. +\pre `P` is a simple polygon. +*/ +template +typename Gps_traits_2::Polygon_with_holes_2 +offset_polygon_2 +(const Polygon_2& P, +const typename ConicTraits::Rat_kernel::FT& r, +const ConicTraits& traits); + +/*! +\ingroup PkgMinkowskiSum2 + +Computes the offset of the given polygon with holes `pwh` by a given +radius `r`. It does so by offsetting outer boundary of `pwh` and +insetting its holes. +The result is represented as a generalized polygon with holes, such that the +edges of the polygon correspond to line segments and circular arcs, both are +special types of conic arcs, as represented by the `traits` class. +\pre `pwh` is not unbounded (it has a valid outer boundary). +*/ +template +typename Gps_traits_2::Polygon_with_holes_2 +offset_polygon_2 +(const Polygon_with_holes_2& pwh, +const typename ConicTraits::Rat_kernel::FT& r, +const ConicTraits& traits); + +/*! +\ingroup PkgMinkowskiSum2 + +Computes the exact representation of the offset of the given polygon +`P` by a radius `r`, as described above. +If `P` is not convex, the function decomposes it into convex +sub-polygons \f$ P_1, \ldots, P_k\f$ and computes the union of sub-offsets +(namely \f$ \bigcup_{i}{(P_i \oplus B_r)}\f$). +The decomposition is performed using the given decomposition strategy +`decomp`, which must be an instance of a class that models the +concept `PolygonConvexDecomposition`. +\pre `P` is a simple polygon. +*/ +template +typename Gps_traits_2::Polygon_with_holes_2 +offset_polygon_2 +(const Polygon_2& P, +const typename ConicTraits::Rat_kernel::FT& r, +const DecompositionStrategy& decomp, +const ConicTraits& traits); + +} /* namespace CGAL */ diff --git a/Minkowski_sum_2/doc/Minkowski_sum_2/Doxyfile.in b/Minkowski_sum_2/doc/Minkowski_sum_2/Doxyfile.in index 58c13ebf39d..44c33ed120e 100644 --- a/Minkowski_sum_2/doc/Minkowski_sum_2/Doxyfile.in +++ b/Minkowski_sum_2/doc/Minkowski_sum_2/Doxyfile.in @@ -1,6 +1,9 @@ @INCLUDE = ${CGAL_DOC_PACKAGE_DEFAULTS} -PROJECT_NAME = "CGAL ${CGAL_CREATED_VERSION_NUM} - 2D Minkowski Sums" +PROJECT_NAME = "CGAL ${CGAL_CREATED_VERSION_NUM} - 2D Minkowski Sums" + + +INPUT = ${CMAKE_SOURCE_DIR}/Minkowski_sum_2/doc/Minkowski_sum_2/ + + -INPUT = ${CMAKE_SOURCE_DIR}/Minkowski_sum_2/doc/Minkowski_sum_2/ \ - ${CMAKE_SOURCE_DIR}/Minkowski_sum_2/include diff --git a/Minkowski_sum_2/include/CGAL/Polygon_convex_decomposition_2.h b/Minkowski_sum_2/include/CGAL/Polygon_convex_decomposition_2.h index 0fd0dd8a067..57bdaf3e38c 100644 --- a/Minkowski_sum_2/include/CGAL/Polygon_convex_decomposition_2.h +++ b/Minkowski_sum_2/include/CGAL/Polygon_convex_decomposition_2.h @@ -26,26 +26,10 @@ namespace CGAL { /*! -\ingroup PkgMinkowskiSum2 - -\anchor mink_refopt_decomp - -The `Optimal_convex_decomposition_2` class provides an implementation of Greene's -dynamic programming algorithm for optimal decomposition of a -polygon into convex sub-polygons \cgalCite{g-dpcp-83}. Note that -this algorithm requires \f$ O(n^4)\f$ time and \f$ O(n^3)\f$ space in -the worst case, where \f$ n\f$ is the size of the input polygon. - - -\tparam Kernel must be a geometric kernel that can be used for the polygon. -\tparam Container must be a container that can be used for the polygon. -It is by default `std::vector`. - -\cgalModels `PolygonConvexDecomposition_2` - -\sa `CGAL::optimal_convex_partition_2()` - -*/ + * \class + * The O(n^4) optimal strategy for decomposing a polygon into convex + * sub-polygons. + */ template > class Optimal_convex_decomposition_2 : @@ -61,29 +45,10 @@ public: }; /*! -\ingroup PkgMinkowskiSum2Classes - -\anchor mink_refHM_decomp - -The `Hertel_Mehlhorn_convex_decomposition_2` class implements the approximation algorithm of Hertel -and Mehlhorn for decomposing a polygon into convex -sub-polygons \cgalCite{hm-ftsp-83}. This algorithm constructs a -triangulation of the input polygon and proceeds by removing -unnecessary triangulation edges. Given the triangulation, the -algorithm requires \f$ O(n)\f$ time and space to construct a convex -decomposition (where \f$ n\f$ is the size of the input polygon), whose -size is guaranteed to be no more than four times the size of the -optimal decomposition. - -\tparam Kernel must be a geometric kernel that can be used for the polygon. -\tparam Container must be a container that can be used for the polygon. -It is by default `std::vector`. - -\cgalModels `PolygonConvexDecomposition_2` - -\sa `CGAL::approx_convex_partition_2()` - -*/ + * \class + * Hertel and Mehlhorn's O(n) approximation strategy for decomposing a + * polygon into convex sub-polygons. + */ template > class Hertel_Mehlhorn_convex_decomposition_2 : @@ -99,26 +64,10 @@ public: }; /*! -\ingroup PkgMinkowskiSum2 - -\anchor mink_refGreene_decomp - -The `Greene_convex_decomposition_2` class implements the approximation algorithm of -Greene for the decomposition of an input polygon into convex -sub-polygons \cgalCite{g-dpcp-83}. This algorithm takes \f$ O(n \log n)\f$ -time and \f$ O(n)\f$ space, where \f$ n\f$ is the size of the input polygon, -and outputs a decomposition whose size is guaranteed to be no more -than four times the size of the optimal decomposition. - -\tparam Kernel must be a geometric kernel that can be used for the polygon. -\tparam Container must be a container that can be used for the polygon. -It is by default `std::vector`. - -\cgalModels `PolygonConvexDecomposition_2` - -\sa `CGAL::greene_approx_convex_partition_2()` - -*/ + * \class + * Greene's O(n log(n)) approximation strategy for decomposing a polygon into + * convex sub-polygons. + */ template > class Greene_convex_decomposition_2 : diff --git a/Minkowski_sum_2/include/CGAL/Small_side_angle_bisector_decomposition_2.h b/Minkowski_sum_2/include/CGAL/Small_side_angle_bisector_decomposition_2.h index e70e6a62e2c..56d8cb4a35a 100644 --- a/Minkowski_sum_2/include/CGAL/Small_side_angle_bisector_decomposition_2.h +++ b/Minkowski_sum_2/include/CGAL/Small_side_angle_bisector_decomposition_2.h @@ -28,29 +28,9 @@ namespace CGAL { /*! -\ingroup PkgMinkowskiSum2 - -\anchor mink_refssab_decomp - -The `Small_side_angle_bisector_decomposition_2` class implements a simple yet efficient heuristic for -decomposing an input polygon into convex sub-polygons. It is based -on the algorithm suggested by Flato and Halperin \cgalCite{fh-recpm-00}, -but without introducing Steiner points. The algorithm operates in two -major steps. In the first step, it tries to subdivide the polygon by -connect two reflex vertices with an edge. When this is not possible any -more, it eliminates the reflex vertices one by one by connecting them -to other convex vertices, such that the new edge best approximates -the angle bisector of the reflex vertex. The algorithm operates in -\f$ O(n^2)\f$ time an takes \f$ O(n)\f$ space at the worst case, where \f$ n\f$ is the -size of the input polygon. - -The `Polygon_2` type defined by the class is simply -`Polygon_2`. The `Container` parameter -is by default `std::vector`. - -\cgalModels `PolygonConvexDecomposition_2` - -*/ + * \class + * Small-side angle-bisector decomposition strategy. + */ template > class Small_side_angle_bisector_decomposition_2 diff --git a/Minkowski_sum_2/include/CGAL/approximated_offset_2.h b/Minkowski_sum_2/include/CGAL/approximated_offset_2.h index dac397ff346..7f61553bc44 100644 --- a/Minkowski_sum_2/include/CGAL/approximated_offset_2.h +++ b/Minkowski_sum_2/include/CGAL/approximated_offset_2.h @@ -27,22 +27,19 @@ namespace CGAL { /*! -\ingroup PkgMinkowskiSum2 - -Provides a guaranteed approximation of the offset of the given polygon -`P` by a given radius `r` - namely, the function computes the -Minkowski sum \f$ P \oplus B_r\f$, where \f$ B_r\f$ is a disc of radius -`r` centered at the origin. -The function actually outputs a set \f$ S\f$ that contains the Minkowski sum, -such that the approximation error is bounded by `eps`. -Note that as the input polygon may not be convex, its offset may not be a -simple polygon. The result is therefore represented as a polygon with -holes, whose edges are either line segments or circular arcs. -\pre `P` is a simple polygon. -*/ + * Approximate the offset of a given simple polygon by a given radius, + * using the convolution method. + * Note that as the input polygon may not be convex, its offset may not be + * simply connected. The result is therefore represented as a polygon with + * holes. + * \param pgn The polygon. + * \param r The offset radius. + * \param eps The approximation-error bound. + * \return The approximated offset polygon. + */ template typename Gps_circle_segment_traits_2::Polygon_with_holes_2 -approximated_offset_2 (const Polygon_2& P, +approximated_offset_2 (const Polygon_2& pgn, const typename Kernel::FT& r, const double& eps) { @@ -55,7 +52,7 @@ approximated_offset_2 (const Polygon_2& P, Offset_polygon_2 offset_bound; std::list offset_holes; - approx_offset (P, r, + approx_offset (pgn, r, offset_bound, std::back_inserter(offset_holes)); return (typename Gps_circle_segment_traits_2::Polygon_with_holes_2 @@ -63,16 +60,16 @@ approximated_offset_2 (const Polygon_2& P, } /*! -\ingroup PkgMinkowskiSum2 - -Provides a guaranteed approximation of offset the given polygon with holes -`pwh` by a given radius `r`, such that the approximation error is bounded -by `eps`. It does so by offsetting outer boundary of `pwh` and insetting -its holes. -The result is represented as a generalized polygon with holes, such that the edges -of the polygon correspond to line segment and circular arcs. -\pre `pwh` is not unbounded (it has a valid outer boundary). -*/ + * Approximate the offset of a given polygon with holes by a given radius, + * using the convolution method. + * The result is represented as a polygon with holes whose edges are line + * segments and circular arcs. + * \param pwh The polygon with holes. + * \param r The offset radius. + * \param eps The approximation-error bound. + * \pre The polygon is bounded (has a valid outer boundary). + * \return The approximated offset polygon. + */ template typename Gps_circle_segment_traits_2::Polygon_with_holes_2 approximated_offset_2 (const Polygon_with_holes_2& pwh, @@ -96,24 +93,24 @@ approximated_offset_2 (const Polygon_with_holes_2& pwh, } /*! -\ingroup PkgMinkowskiSum2 - -Provides a guaranteed approximation of the offset of the given polygon -`P` by a radius `r`, as described above. -If the input polygon `P` is not convex, the function -decomposes it into convex sub-polygons \f$ P_1, \ldots, P_k\f$ and computes -the union of the sub-offsets (namely \f$ \bigcup_{i}{(P_i \oplus B_r)}\f$). -The decomposition is performed using the given decomposition strategy -`decomp`, which must be an instance of a class that models the -concept `PolygonConvexDecomposition`. -\pre `P` is a simple polygon. -*/ + * Approximate the offset of a given simple polygon by a given radius, + * by decomposing it to convex sub-polygons and computing the union of their + * offsets. + * Note that as the input polygon may not be convex, its offset may not be + * simply connected. The result is therefore represented as a polygon with + * holes. + * \param pgn The polygon. + * \param r The offset radius. + * \param eps The approximation-error bound. + * \param decomp A functor for decomposing polygons. + * \return The approximated offset polygon. + */ template typename Gps_circle_segment_traits_2::Polygon_with_holes_2 -approximated_offset_2 (const Polygon_2& P, +approximated_offset_2 (const Polygon_2& pgn, const typename Kernel::FT& r, const double& eps, - const DecompositionStrategy& decomp) + const DecompositionStrategy&) { typedef Approx_offset_base_2 Base; typedef Offset_by_decomposition_2 @@ -125,7 +122,7 @@ approximated_offset_2 (const Polygon_2& P, Offset_polygon_2 offset_bound; std::list offset_holes; - approx_offset (P, r, + approx_offset (pgn, r, offset_bound, std::back_inserter(offset_holes)); return (typename Gps_circle_segment_traits_2::Polygon_with_holes_2 @@ -133,25 +130,21 @@ approximated_offset_2 (const Polygon_2& P, } /*! -\ingroup PkgMinkowskiSum2 - -Provides a guaranteed approximation of the inset, or inner offset, of -the given polygon `P` by a given radius `r`. Namely, the -function computes the set of points inside the polygon whose distance -from \f$ P\f$'s boundary is at least \f$ r\f$: -\f$ \{ p \in P \;|\; {\rm dist}(p, \partial P) \geq r \}\f$, -with the approximation error bounded by `eps`. -Note that as the input polygon may not be convex, its inset may comprise -several disconnected components. The result is therefore represented as a -sequence of generalized polygons, whose edges are either line segments or -circular arcs. -The output sequence is returned via the output iterator `oi`, whose -value-type must be `Gps_circle_segment_traits_2::Polygon_2`. -\pre `P` is a simple polygon. -*/ + * Approximate the inset of a given simple polygon by a given radius, using + * the convolution method. + * Note that as the input polygon may not be convex, its inset may not be + * simply connected. The result is therefore represented as a set of polygons. + * \param pgn The polygon. + * \param r The inset radius. + * \param eps The approximation-error bound. + * \param oi An output iterator for the inset polygons. + * Its value-type must be + * Gps_circle_segment_traits_2::Polygon_2. + * \return A past-the-end iterator for the inset polygons. + */ template OutputIterator -approximated_inset_2 (const Polygon_2& P, +approximated_inset_2 (const Polygon_2& pgn, const typename Kernel::FT& r, const double& eps, OutputIterator oi) @@ -165,7 +158,7 @@ approximated_inset_2 (const Polygon_2& P, Offset_polygon_2 offset_bound; std::list offset_holes; - oi = approx_offset.inset (P, r, + oi = approx_offset.inset (pgn, r, oi); return (oi); diff --git a/Minkowski_sum_2/include/CGAL/minkowski_sum_2.h b/Minkowski_sum_2/include/CGAL/minkowski_sum_2.h index 842d7c4c73c..3033aeac944 100644 --- a/Minkowski_sum_2/include/CGAL/minkowski_sum_2.h +++ b/Minkowski_sum_2/include/CGAL/minkowski_sum_2.h @@ -31,18 +31,15 @@ namespace CGAL { /*! -\ingroup PkgMinkowskiSum2 - -Computes the Minkowski sum \f$ P \oplus Q\f$ of the two given polygons. -The function computes the reduced convolution of the two polygons and -extracts those loops of the convolution which are part of the Minkowsi -sum. This method works very efficiently, regardless of whether `P` and -`Q` are convex or non-convex. -Note that as the input polygons may not be convex, their Minkowski -sum may not be a simple polygon. The result is therefore represented -as a polygon with holes. - -\pre Both `P` and `Q` are simple, counterclockwise-oriented polygons. + * Computes the Minkowski sum \f$ P \oplus Q\f$ of the two given polygons. + * The function computes the reduced convolution of the two polygons and + * extracts those loops of the convolution which are part of the Minkowsi + * sum. This method works very efficiently, regardless of whether `P` and + * `Q` are convex or non-convex. + * Note that as the input polygons may not be convex, their Minkowski + * sum may not be a simple polygon. The result is therefore represented + * as a polygon with holes. + * \pre Both `P` and `Q` are simple, counterclockwise-oriented polygons. */ template @@ -65,33 +62,26 @@ minkowski_sum_reduced_convolution_2 (const Polygon_2& pgn1, } /*! -\ingroup PkgMinkowskiSum2 - -Computes the Minkowski sum \f$ P \oplus Q\f$ of the two given polygons. -The function computes the convolution cycles of the two polygons and -extract the regions having positive winding number with respect to these -cycles. This method work very efficiently, regardless of whether `P` -and `Q` are convex or non-convex. -Note that as the input polygons may not be convex, their Minkowski -sum may not be a simple polygon. The result is therefore represented -as a polygon with holes. - -\pre Both `P` and `Q` are simple polygons. -*/ + * Compute the Minkowski sum of two simple polygons using the convolution + * method. + * Note that as the input polygons may not be convex, their Minkowski sum may + * not be a simple polygon. The result is therefore represented as a polygon + * with holes. + */ template Polygon_with_holes_2 -minkowski_sum_full_convolution_2 (const Polygon_2& P, - const Polygon_2& Q) +minkowski_sum_full_convolution_2 (const Polygon_2& pgn1, + const Polygon_2& pgn2) { Minkowski_sum_by_convolution_2 mink_sum; Polygon_2 sum_bound; std::list > sum_holes; - if (P.size() > Q.size()) - mink_sum (P, Q, sum_bound, std::back_inserter(sum_holes)); + if (pgn1.size() > pgn2.size()) + mink_sum (pgn1, pgn2, sum_bound, std::back_inserter(sum_holes)); else - mink_sum (Q, P, sum_bound, std::back_inserter(sum_holes)); + mink_sum (pgn2, pgn1, sum_bound, std::back_inserter(sum_holes)); return (Polygon_with_holes_2 (sum_bound, sum_holes.begin(), @@ -99,49 +89,40 @@ minkowski_sum_full_convolution_2 (const Polygon_2& P, } /*! -\ingroup PkgMinkowskiSum2 - -Computes the Minkowski sum \f$ P \oplus Q\f$ of the two given polygons -using the reduced convolution method. -Note that as the input polygons may not be convex, their Minkowski -sum may not be a simple polygon. The result is therefore represented -as a polygon with holes. - -\pre Both `P` and `Q` are simple, counterclockwise-oriented polygons. - -\sa `CGAL::minkowski_sum_reduced_convolution_2()` -\sa `CGAL::minkowski_sum_full_convolution_2()` + * Compute the Minkowski sum of two simple polygons using the reduced + * convolution method. + * Note that as the input polygons may not be convex, their Minkowski sum may + * not be a simple polygon. The result is therefore represented as a polygon + * with holes. + * + * \sa `CGAL::minkowski_sum_reduced_convolution_2()` + * \sa `CGAL::minkowski_sum_full_convolution_2()` */ template Polygon_with_holes_2 -minkowski_sum_2 (const Polygon_2& P, - const Polygon_2& Q) +minkowski_sum_2 (const Polygon_2& pgn1, + const Polygon_2& pgn2) { - return minkowski_sum_reduced_convolution_2(P, Q); + return minkowski_sum_reduced_convolution_2(pgn1, pgn2); } /*! -\ingroup PkgMinkowskiSum2 - -Computes the Minkowski sum \f$ P \oplus Q\f$ of the two given polygons. -If the input polygons `P` and `Q` are not convex, the function -decomposes them into convex sub-polygons \f$ P_1, \ldots, P_k\f$ and -\f$ Q_1, \ldots, Q_{\ell}\f$ and computes the union of pairwise sub-sums -(namely \f$ \bigcup_{i,j}{(P_i \oplus Q_j)}\f$). -The decomposition is performed using the given decomposition strategy -`decomp`, which must be an instance of a class that models the -concept `PolygonConvexDecomposition`. -Note that as the input polygons may not be convex, their Minkowski -sum may not be a simple polygon. The result is therefore represented -as a polygon with holes. -\pre Both `P` and `Q` are simple polygons. -*/ - + * Compute the Minkowski sum of two simple polygons by decomposing each + * polygon to convex sub-polygons and computing the union of the pairwise + * Minkowski sums of the sub-polygons. + * Note that as the input polygons may not be convex, their Minkowski sum may + * not be a simple polygon. The result is therefore represented as a polygon + * with holes. + * \param pgn1 The first polygon. + * \param pgn2 The second polygon. + * \param decomp A functor for decomposing polygons. + * \param sum Output: The resulting polygon with holes, representing the sum. + */ template Polygon_with_holes_2 -minkowski_sum_2 (const Polygon_2& P, - const Polygon_2& Q, +minkowski_sum_2 (const Polygon_2& pgn1, + const Polygon_2& pgn2, const DecompositionStrategy&) { Minkowski_sum_by_decomposition_2 mink_sum; @@ -150,7 +131,7 @@ minkowski_sum_2 (const Polygon_2& P, Polygon_with_holes_2 sum; - sum = mink_sum (P, Q); + sum = mink_sum (pgn1, pgn2); return (sum); } diff --git a/Minkowski_sum_2/include/CGAL/offset_polygon_2.h b/Minkowski_sum_2/include/CGAL/offset_polygon_2.h index e11a785fe7e..803ace280a6 100644 --- a/Minkowski_sum_2/include/CGAL/offset_polygon_2.h +++ b/Minkowski_sum_2/include/CGAL/offset_polygon_2.h @@ -27,23 +27,19 @@ namespace CGAL { /*! -\ingroup PkgMinkowskiSum2 - -Computes the offset of the given polygon `P` by a given radius -`r` - namely, the function computes the Minkowski sum -\f$ P \oplus B_r\f$, where \f$ B_r\f$ is a disc of radius `r` centered at the -origin. -Note that as the input polygon may not be convex, its offset may not be a -simple polygon. The result is therefore represented as a generalized -polygon with holes, such that the edges of the polygon correspond to -line segments and circular arcs, both are special types of conic arcs, -as represented by the `traits` class. -\pre `P` is a simple polygon. -*/ + * Compute the offset of a given simple polygon by a given radius, + * using the convolution method. + * Note that as the input polygon may not be convex, its offset may not be + * simply connected. The result is therefore represented as a polygon with + * holes. + * \param pgn The polygon. + * \param r The offset radius. + * \return The offset polygon. + */ template typename Gps_traits_2::Polygon_with_holes_2 offset_polygon_2 (const Polygon_2& P, + Container>& pgn, const typename ConicTraits::Rat_kernel::FT& r, const ConicTraits& ) { @@ -56,7 +52,7 @@ offset_polygon_2 (const Polygon_2 offset_holes; - exact_offset (P, r, + exact_offset (pgn, r, offset_bound, std::back_inserter(offset_holes)); return (typename Gps_traits_2::Polygon_with_holes_2 @@ -64,16 +60,15 @@ offset_polygon_2 (const Polygon_2not unbounded (it has a valid outer boundary). -*/ + * Compute the offset of a given polygon with holes by a given radius, + * using the convolution method. + * The result is represented as a polygon with holes whose edges are line + * segments and circular arcs. + * \param pwh The polygon with holes. + * \param r The offset radius. + * \pre The polygon is bounded (has a valid outer boundary). + * \return The offset polygon. + */ template typename Gps_traits_2::Polygon_with_holes_2 offset_polygon_2 (const Polygon_with_holes_2 typename Gps_traits_2::Polygon_with_holes_2 offset_polygon_2 (const Polygon_2& P, + Container>& pgn, const typename ConicTraits::Rat_kernel::FT& r, - const DecompositionStrategy& decomp, - const ConicTraits& traits) + const DecompositionStrategy&, + const ConicTraits& ) { typedef Exact_offset_base_2 Base; typedef Offset_by_decomposition_2 @@ -128,7 +122,7 @@ offset_polygon_2 (const Polygon_2 offset_holes; - exact_offset (P, r, + exact_offset (pgn, r, offset_bound, std::back_inserter(offset_holes)); return (typename Gps_traits_2::Polygon_with_holes_2 @@ -136,27 +130,22 @@ offset_polygon_2 (const Polygon_2::Polygon_2. + * \return A past-the-end iterator for the inset polygons. + */ template OutputIterator inset_polygon_2 (const Polygon_2& P, + Container>& pgn, const typename ConicTraits::Rat_kernel::FT& r, - const ConicTraits& traits, + const ConicTraits& , OutputIterator oi) { typedef Exact_offset_base_2 Base; @@ -165,7 +154,7 @@ inset_polygon_2 (const Polygon_2