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 index 647ce7cee78..22e86c638ed 100644 --- 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 @@ -3,21 +3,21 @@ namespace CGAL { /*! \ingroup PkgMinkowskiSum2 -Computes the Minkowski sum \f$ P \oplus Q\f$ of the two given polygons. -This method defaults to the reduced convolution method, see below. -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. +Computes the Minkowski sum \f$ P \oplus Q\f$ of two given polygons +(which may have holes). `PolygonType1` and `PolygonType2` can be any combination of: -\pre Both `P` and `Q` are simple, counterclockwise-oriented polygons. +- `Polygon_2` +- `Polygon_with_holes_2` + +This method defaults to the reduced convolution method, see below. \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 PolygonType1& P, + const PolygonType2& Q); /*! \ingroup PkgMinkowskiSum2 @@ -29,17 +29,17 @@ the Minkowsi sum. This method works very efficiently, regardless of whether `P` and `Q` are convex or non-convex. It is usually faster than the full convolution method, except in degenerate cases where the output polygon has many holes. -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. +`PolygonType1` and `PolygonType2` can be any combination of: + +- `Polygon_2` +- `Polygon_with_holes_2` */ template Polygon_with_holes_2 -minkowski_sum_reduced_convolution_2 (const Polygon_2& P, - const Polygon_2& Q); +minkowski_sum_reduced_convolution_2 (const PolygonType1& P, + const PolygonType2& Q); /*! \ingroup PkgMinkowskiSum2 @@ -49,16 +49,16 @@ The function computes the (full) 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. +`PolygonType1` and `PolygonType2` can be any combination of: + +- `Polygon_2` +- `Polygon_with_holes_2` */ template Polygon_with_holes_2 -minkowski_sum_full_convolution_2(const Polygon_2& P, - const Polygon_2& Q, +minkowski_sum_full_convolution_2(const PolygonType1& P, + const PolygonType2& Q, const Kernel& kernel = Kernel()); /*! @@ -72,62 +72,17 @@ decomposes them into convex sub-polygons \f$ P_1, \ldots, P_k\f$ and The decomposition is performed using the given decomposition method `decomp`, which must be an instance of a class template that models the concept `PolygonConvexDecomposition_2`. -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. + +`PolygonType1` and `PolygonType2` can be any combination of: + +- `Polygon_2` +- `Polygon_with_holes_2` */ template Polygon_with_holes_2 -minkowski_sum_2 (const Polygon_2& P, - const Polygon_2& Q, +minkowski_sum_2 (const PolygonType1& P, + const PolygonType2& Q, const PolygonConvexDecomposition_2& decomp, const Gps_segment_traits_2& traits = Gps_segment_traits_2()); -/*! -\ingroup PkgMinkowskiSum2 - -Computes the Minkowski sum \f$ P \oplus Q\f$ of polygon \f$ P\f$ and the -polygon with holes \f$ Q\f$. 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 method -`decomp`, which must be an instance of a class template that models the -concept `PolygonWithHolesConvexDecomposition_2`. -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_2 (const Polygon_2& P, - const Polygon_with_holes_2& Q, - const PolygonWithHolesConvexDecomposition_2& decomp, - const Gps_segment_traits_2& traits = Gps_segment_traits_2()); - -/*! -\ingroup PkgMinkowskiSum2 - -Computes the Minkowski sum \f$ P \oplus Q\f$ of the two given polygons with -holes. 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 method -`decomp`, which must be an instance of a class template that models the -concept `PolygonWithHolesConvexDecomposition_2`. -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_2 (const Polygon_with_holes_2& P, - const Polygon_with_holes_2& Q, - const PolygonWithHolesConvexDecomposition_2& decomp, - const Gps_segment_traits_2& traits = Gps_segment_traits_2()); - } /* namespace CGAL */ diff --git a/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/Hole_filter_2.h b/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/Hole_filter_2.h index 4f472fddd73..dbf8e381216 100644 --- a/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/Hole_filter_2.h +++ b/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/Hole_filter_2.h @@ -6,6 +6,11 @@ namespace CGAL { +/*! \class + * This class applies filter to a polygon with holes, + * by removing all of its holes that cannot possibly contribute + * to the Minkowski sum boundary. + */ template class Hole_filter_2 { diff --git a/Minkowski_sum_2/include/CGAL/minkowski_sum_2.h b/Minkowski_sum_2/include/CGAL/minkowski_sum_2.h index 58ce3f6a81b..cf5762c5db6 100644 --- a/Minkowski_sum_2/include/CGAL/minkowski_sum_2.h +++ b/Minkowski_sum_2/include/CGAL/minkowski_sum_2.h @@ -185,6 +185,49 @@ minkowski_sum_2(const Polygon_2& pgn1, return minkowski_sum_reduced_convolution_2(pgn1, pgn2); } +/*! + * Compute the Minkowski sum of two polygons with holes using the convolution + * method. This function defaults to calling the reduced convolution method, + * as it is more efficient in most cases. + * Note that the result may not be a simple polygon. The result is therefore + * represented as a polygon with holes. + * \param pgn1 (in) The first polygon with holes. + * \param pgn2 (in) The second polygon with holes. + * \return The resulting polygon with holes, representing the sum. + * + * \sa `CGAL::minkowski_sum_reduced_convolution_2()` + * \sa `CGAL::minkowski_sum_full_convolution_2()` + */ +template +Polygon_with_holes_2 +minkowski_sum_2(const Polygon_with_holes_2& pgn1, + const Polygon_with_holes_2& pgn2) +{ + return minkowski_sum_reduced_convolution_2(pgn1, pgn2); +} + +/*! + * Compute the Minkowski sum of a simple polygons and a polygon-with-holes + * using the convolution method. This function defaults to calling the reduced + * convolution method, as it is more efficient in most cases. + * Note that the result may not be a simple polygon. The result is therefore + * represented as a polygon with holes. + * \param pgn1 (in) The polygon. + * \param pgn2 (in) The polygon with holes. + * \return The resulting polygon with holes, representing the sum. + * + * \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& pgn1, + const Polygon_with_holes_2& pgn2) +{ + Polygon_with_holes_2 pgnwh1(pgn1); + return minkowski_sum_reduced_convolution_2(pgnwh1, pgn2); +} + /*! * Compute the Minkowski sum of two simple polygons by decomposing each * polygon to convex sub-polygons and computing the union of the pairwise