mirror of https://github.com/CGAL/cgal
Revert "Move the package's documentation commentss to the actual headers"
This reverts commit 843fd4b053.
Reason: Internal classes get documented, few packages do inline
documentation, this should be fixed CGAL-wide sometime.
Conflicts:
Minkowski_sum_2/include/CGAL/minkowski_sum_2.h
This commit is contained in:
parent
90d86774dd
commit
187856517f
|
|
@ -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<typename Kernel::Point_2>`.
|
||||||
|
|
||||||
|
\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<Kernel,Container> 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<typename Kernel::Point_2>`.
|
||||||
|
|
||||||
|
\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<Kernel,Container> 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<typename Kernel::Point_2>`.
|
||||||
|
|
||||||
|
\cgalModels `PolygonConvexDecomposition_2`
|
||||||
|
|
||||||
|
\sa `CGAL::optimal_convex_partition_2()`
|
||||||
|
|
||||||
|
*/
|
||||||
|
template< typename Kernel, typename Container >
|
||||||
|
class Optimal_convex_decomposition_2 {
|
||||||
|
public:
|
||||||
|
|
||||||
|
typedef CGAL::Polygon_2<Kernel,Container> Polygon_2;
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
}; /* end Optimal_convex_decomposition_2 */
|
||||||
|
} /* end namespace CGAL */
|
||||||
|
|
@ -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<Kernel,Container>`. The `Container` parameter
|
||||||
|
is by default `std::vector<typename Kernel::Point_2>`.
|
||||||
|
|
||||||
|
\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 */
|
||||||
|
|
@ -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<class Kernel, class Container, class OutputIterator>
|
||||||
|
OutputIterator
|
||||||
|
approximated_inset_2 (const Polygon_2<Kernel, Container>& 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<class Kernel, class Container>
|
||||||
|
typename Gps_circle_segment_traits_2<Kernel>::Polygon_with_holes_2
|
||||||
|
approximated_offset_2 (const Polygon_2<Kernel, Container>& 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 <I>not</I> unbounded (it has a valid outer boundary).
|
||||||
|
*/
|
||||||
|
template<class Kernel, class Container>
|
||||||
|
typename Gps_circle_segment_traits_2<Kernel>::Polygon_with_holes_2
|
||||||
|
approximated_offset_2 (const Polygon_with_holes_2<Kernel, Container>& 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<class Kernel, class Container,
|
||||||
|
class DecompositionStrategy>
|
||||||
|
typename Gps_circle_segment_traits_2<Kernel>::Polygon_with_holes_2
|
||||||
|
approximated_offset_2 (const Polygon_2<Kernel, Container>& P,
|
||||||
|
const typename Kernel::FT& r,
|
||||||
|
const double& eps,
|
||||||
|
const DecompositionStrategy& decomp);
|
||||||
|
|
||||||
|
} /* namespace CGAL */
|
||||||
|
|
@ -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<class Kernel, class Container>
|
||||||
|
Polygon_with_holes_2<Kernel,Container>
|
||||||
|
minkowski_sum_2 (const Polygon_2<Kernel,Container>& P,
|
||||||
|
const Polygon_2<Kernel,Container>& 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<class Kernel, class Container,
|
||||||
|
class DecompositionStrategy>
|
||||||
|
Polygon_with_holes_2<Kernel,Container>
|
||||||
|
minkowski_sum_2 (const Polygon_2<Kernel,Container>& P,
|
||||||
|
const Polygon_2<Kernel,Container>& Q,
|
||||||
|
const DecompositionStrategy& decomp);
|
||||||
|
|
||||||
|
} /* namespace CGAL */
|
||||||
|
|
@ -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<class ConicTraits, class Container, class OutputIterator>
|
||||||
|
OutputIterator inset_polygon_2
|
||||||
|
(const Polygon_2<typename ConicTraits::Rat_kernel,
|
||||||
|
Container>& 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<class ConicTraits, class Container>
|
||||||
|
typename Gps_traits_2<ConicTraits>::Polygon_with_holes_2
|
||||||
|
offset_polygon_2
|
||||||
|
(const Polygon_2<typename ConicTraits::Rat_kernel,
|
||||||
|
Container>& 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 <I>not</I> unbounded (it has a valid outer boundary).
|
||||||
|
*/
|
||||||
|
template<class ConicTraits, class Container>
|
||||||
|
typename Gps_traits_2<ConicTraits>::Polygon_with_holes_2
|
||||||
|
offset_polygon_2
|
||||||
|
(const Polygon_with_holes_2<typename ConicTraits::Rat_kernel,
|
||||||
|
Container>& 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<class ConicTraits, class Container,
|
||||||
|
class DecompositionStrategy>
|
||||||
|
typename Gps_traits_2<ConicTraits>::Polygon_with_holes_2
|
||||||
|
offset_polygon_2
|
||||||
|
(const Polygon_2<typename ConicTraits::Rat_kernel,
|
||||||
|
Container>& P,
|
||||||
|
const typename ConicTraits::Rat_kernel::FT& r,
|
||||||
|
const DecompositionStrategy& decomp,
|
||||||
|
const ConicTraits& traits);
|
||||||
|
|
||||||
|
} /* namespace CGAL */
|
||||||
|
|
@ -1,6 +1,9 @@
|
||||||
@INCLUDE = ${CGAL_DOC_PACKAGE_DEFAULTS}
|
@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
|
|
||||||
|
|
|
||||||
|
|
@ -26,26 +26,10 @@
|
||||||
namespace CGAL {
|
namespace CGAL {
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\ingroup PkgMinkowskiSum2
|
* \class
|
||||||
|
* The O(n^4) optimal strategy for decomposing a polygon into convex
|
||||||
\anchor mink_refopt_decomp
|
* sub-polygons.
|
||||||
|
*/
|
||||||
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<typename Kernel::Point_2>`.
|
|
||||||
|
|
||||||
\cgalModels `PolygonConvexDecomposition_2`
|
|
||||||
|
|
||||||
\sa `CGAL::optimal_convex_partition_2()`
|
|
||||||
|
|
||||||
*/
|
|
||||||
template <class Kernel_,
|
template <class Kernel_,
|
||||||
class Container_ = std::vector<typename Kernel_::Point_2> >
|
class Container_ = std::vector<typename Kernel_::Point_2> >
|
||||||
class Optimal_convex_decomposition_2 :
|
class Optimal_convex_decomposition_2 :
|
||||||
|
|
@ -61,29 +45,10 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\ingroup PkgMinkowskiSum2Classes
|
* \class
|
||||||
|
* Hertel and Mehlhorn's O(n) approximation strategy for decomposing a
|
||||||
\anchor mink_refHM_decomp
|
* polygon into convex sub-polygons.
|
||||||
|
*/
|
||||||
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<typename Kernel::Point_2>`.
|
|
||||||
|
|
||||||
\cgalModels `PolygonConvexDecomposition_2`
|
|
||||||
|
|
||||||
\sa `CGAL::approx_convex_partition_2()`
|
|
||||||
|
|
||||||
*/
|
|
||||||
template <class Kernel_,
|
template <class Kernel_,
|
||||||
class Container_ = std::vector<typename Kernel_::Point_2> >
|
class Container_ = std::vector<typename Kernel_::Point_2> >
|
||||||
class Hertel_Mehlhorn_convex_decomposition_2 :
|
class Hertel_Mehlhorn_convex_decomposition_2 :
|
||||||
|
|
@ -99,26 +64,10 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\ingroup PkgMinkowskiSum2
|
* \class
|
||||||
|
* Greene's O(n log(n)) approximation strategy for decomposing a polygon into
|
||||||
\anchor mink_refGreene_decomp
|
* convex sub-polygons.
|
||||||
|
*/
|
||||||
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<typename Kernel::Point_2>`.
|
|
||||||
|
|
||||||
\cgalModels `PolygonConvexDecomposition_2`
|
|
||||||
|
|
||||||
\sa `CGAL::greene_approx_convex_partition_2()`
|
|
||||||
|
|
||||||
*/
|
|
||||||
template <class Kernel_,
|
template <class Kernel_,
|
||||||
class Container_ = std::vector<typename Kernel_::Point_2> >
|
class Container_ = std::vector<typename Kernel_::Point_2> >
|
||||||
class Greene_convex_decomposition_2 :
|
class Greene_convex_decomposition_2 :
|
||||||
|
|
|
||||||
|
|
@ -28,29 +28,9 @@
|
||||||
namespace CGAL {
|
namespace CGAL {
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\ingroup PkgMinkowskiSum2
|
* \class
|
||||||
|
* Small-side angle-bisector decomposition strategy.
|
||||||
\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<Kernel,Container>`. The `Container` parameter
|
|
||||||
is by default `std::vector<typename Kernel::Point_2>`.
|
|
||||||
|
|
||||||
\cgalModels `PolygonConvexDecomposition_2`
|
|
||||||
|
|
||||||
*/
|
|
||||||
template <class Kernel_,
|
template <class Kernel_,
|
||||||
class Container_ = std::vector<typename Kernel_::Point_2> >
|
class Container_ = std::vector<typename Kernel_::Point_2> >
|
||||||
class Small_side_angle_bisector_decomposition_2
|
class Small_side_angle_bisector_decomposition_2
|
||||||
|
|
|
||||||
|
|
@ -27,22 +27,19 @@
|
||||||
namespace CGAL {
|
namespace CGAL {
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\ingroup PkgMinkowskiSum2
|
* Approximate the offset of a given simple polygon by a given radius,
|
||||||
|
* using the convolution method.
|
||||||
Provides a guaranteed approximation of the offset of the given polygon
|
* Note that as the input polygon may not be convex, its offset may not be
|
||||||
`P` by a given radius `r` - namely, the function computes the
|
* simply connected. The result is therefore represented as a polygon with
|
||||||
Minkowski sum \f$ P \oplus B_r\f$, where \f$ B_r\f$ is a disc of radius
|
* holes.
|
||||||
`r` centered at the origin.
|
* \param pgn The polygon.
|
||||||
The function actually outputs a set \f$ S\f$ that contains the Minkowski sum,
|
* \param r The offset radius.
|
||||||
such that the approximation error is bounded by `eps`.
|
* \param eps The approximation-error bound.
|
||||||
Note that as the input polygon may not be convex, its offset may not be a
|
* \return The approximated offset polygon.
|
||||||
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 <class Kernel, class Container>
|
template <class Kernel, class Container>
|
||||||
typename Gps_circle_segment_traits_2<Kernel>::Polygon_with_holes_2
|
typename Gps_circle_segment_traits_2<Kernel>::Polygon_with_holes_2
|
||||||
approximated_offset_2 (const Polygon_2<Kernel, Container>& P,
|
approximated_offset_2 (const Polygon_2<Kernel, Container>& pgn,
|
||||||
const typename Kernel::FT& r,
|
const typename Kernel::FT& r,
|
||||||
const double& eps)
|
const double& eps)
|
||||||
{
|
{
|
||||||
|
|
@ -55,7 +52,7 @@ approximated_offset_2 (const Polygon_2<Kernel, Container>& P,
|
||||||
Offset_polygon_2 offset_bound;
|
Offset_polygon_2 offset_bound;
|
||||||
std::list<Offset_polygon_2> offset_holes;
|
std::list<Offset_polygon_2> offset_holes;
|
||||||
|
|
||||||
approx_offset (P, r,
|
approx_offset (pgn, r,
|
||||||
offset_bound, std::back_inserter(offset_holes));
|
offset_bound, std::back_inserter(offset_holes));
|
||||||
|
|
||||||
return (typename Gps_circle_segment_traits_2<Kernel>::Polygon_with_holes_2
|
return (typename Gps_circle_segment_traits_2<Kernel>::Polygon_with_holes_2
|
||||||
|
|
@ -63,16 +60,16 @@ approximated_offset_2 (const Polygon_2<Kernel, Container>& P,
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\ingroup PkgMinkowskiSum2
|
* Approximate the offset of a given polygon with holes by a given radius,
|
||||||
|
* using the convolution method.
|
||||||
Provides a guaranteed approximation of offset the given polygon with holes
|
* The result is represented as a polygon with holes whose edges are line
|
||||||
`pwh` by a given radius `r`, such that the approximation error is bounded
|
* segments and circular arcs.
|
||||||
by `eps`. It does so by offsetting outer boundary of `pwh` and insetting
|
* \param pwh The polygon with holes.
|
||||||
its holes.
|
* \param r The offset radius.
|
||||||
The result is represented as a generalized polygon with holes, such that the edges
|
* \param eps The approximation-error bound.
|
||||||
of the polygon correspond to line segment and circular arcs.
|
* \pre The polygon is bounded (has a valid outer boundary).
|
||||||
\pre `pwh` is <I>not</I> unbounded (it has a valid outer boundary).
|
* \return The approximated offset polygon.
|
||||||
*/
|
*/
|
||||||
template <class Kernel, class Container>
|
template <class Kernel, class Container>
|
||||||
typename Gps_circle_segment_traits_2<Kernel>::Polygon_with_holes_2
|
typename Gps_circle_segment_traits_2<Kernel>::Polygon_with_holes_2
|
||||||
approximated_offset_2 (const Polygon_with_holes_2<Kernel, Container>& pwh,
|
approximated_offset_2 (const Polygon_with_holes_2<Kernel, Container>& pwh,
|
||||||
|
|
@ -96,24 +93,24 @@ approximated_offset_2 (const Polygon_with_holes_2<Kernel, Container>& pwh,
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\ingroup PkgMinkowskiSum2
|
* 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
|
||||||
Provides a guaranteed approximation of the offset of the given polygon
|
* offsets.
|
||||||
`P` by a radius `r`, as described above.
|
* Note that as the input polygon may not be convex, its offset may not be
|
||||||
If the input polygon `P` is not convex, the function
|
* simply connected. The result is therefore represented as a polygon with
|
||||||
decomposes it into convex sub-polygons \f$ P_1, \ldots, P_k\f$ and computes
|
* holes.
|
||||||
the union of the sub-offsets (namely \f$ \bigcup_{i}{(P_i \oplus B_r)}\f$).
|
* \param pgn The polygon.
|
||||||
The decomposition is performed using the given decomposition strategy
|
* \param r The offset radius.
|
||||||
`decomp`, which must be an instance of a class that models the
|
* \param eps The approximation-error bound.
|
||||||
concept `PolygonConvexDecomposition`.
|
* \param decomp A functor for decomposing polygons.
|
||||||
\pre `P` is a simple polygon.
|
* \return The approximated offset polygon.
|
||||||
*/
|
*/
|
||||||
template <class Kernel, class Container, class DecompositionStrategy>
|
template <class Kernel, class Container, class DecompositionStrategy>
|
||||||
typename Gps_circle_segment_traits_2<Kernel>::Polygon_with_holes_2
|
typename Gps_circle_segment_traits_2<Kernel>::Polygon_with_holes_2
|
||||||
approximated_offset_2 (const Polygon_2<Kernel, Container>& P,
|
approximated_offset_2 (const Polygon_2<Kernel, Container>& pgn,
|
||||||
const typename Kernel::FT& r,
|
const typename Kernel::FT& r,
|
||||||
const double& eps,
|
const double& eps,
|
||||||
const DecompositionStrategy& decomp)
|
const DecompositionStrategy&)
|
||||||
{
|
{
|
||||||
typedef Approx_offset_base_2<Kernel, Container> Base;
|
typedef Approx_offset_base_2<Kernel, Container> Base;
|
||||||
typedef Offset_by_decomposition_2<Base, DecompositionStrategy>
|
typedef Offset_by_decomposition_2<Base, DecompositionStrategy>
|
||||||
|
|
@ -125,7 +122,7 @@ approximated_offset_2 (const Polygon_2<Kernel, Container>& P,
|
||||||
Offset_polygon_2 offset_bound;
|
Offset_polygon_2 offset_bound;
|
||||||
std::list<Offset_polygon_2> offset_holes;
|
std::list<Offset_polygon_2> offset_holes;
|
||||||
|
|
||||||
approx_offset (P, r,
|
approx_offset (pgn, r,
|
||||||
offset_bound, std::back_inserter(offset_holes));
|
offset_bound, std::back_inserter(offset_holes));
|
||||||
|
|
||||||
return (typename Gps_circle_segment_traits_2<Kernel>::Polygon_with_holes_2
|
return (typename Gps_circle_segment_traits_2<Kernel>::Polygon_with_holes_2
|
||||||
|
|
@ -133,25 +130,21 @@ approximated_offset_2 (const Polygon_2<Kernel, Container>& P,
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\ingroup PkgMinkowskiSum2
|
* Approximate the inset of a given simple polygon by a given radius, using
|
||||||
|
* the convolution method.
|
||||||
Provides a guaranteed approximation of the inset, or inner offset, of
|
* Note that as the input polygon may not be convex, its inset may not be
|
||||||
the given polygon `P` by a given radius `r`. Namely, the
|
* simply connected. The result is therefore represented as a set of polygons.
|
||||||
function computes the set of points inside the polygon whose distance
|
* \param pgn The polygon.
|
||||||
from \f$ P\f$'s boundary is at least \f$ r\f$:
|
* \param r The inset radius.
|
||||||
\f$ \{ p \in P \;|\; {\rm dist}(p, \partial P) \geq r \}\f$,
|
* \param eps The approximation-error bound.
|
||||||
with the approximation error bounded by `eps`.
|
* \param oi An output iterator for the inset polygons.
|
||||||
Note that as the input polygon may not be convex, its inset may comprise
|
* Its value-type must be
|
||||||
several disconnected components. The result is therefore represented as a
|
* Gps_circle_segment_traits_2<Kernel>::Polygon_2.
|
||||||
sequence of generalized polygons, whose edges are either line segments or
|
* \return A past-the-end iterator for the inset polygons.
|
||||||
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 <class Kernel, class Container, class OutputIterator>
|
template <class Kernel, class Container, class OutputIterator>
|
||||||
OutputIterator
|
OutputIterator
|
||||||
approximated_inset_2 (const Polygon_2<Kernel, Container>& P,
|
approximated_inset_2 (const Polygon_2<Kernel, Container>& pgn,
|
||||||
const typename Kernel::FT& r,
|
const typename Kernel::FT& r,
|
||||||
const double& eps,
|
const double& eps,
|
||||||
OutputIterator oi)
|
OutputIterator oi)
|
||||||
|
|
@ -165,7 +158,7 @@ approximated_inset_2 (const Polygon_2<Kernel, Container>& P,
|
||||||
Offset_polygon_2 offset_bound;
|
Offset_polygon_2 offset_bound;
|
||||||
std::list<Offset_polygon_2> offset_holes;
|
std::list<Offset_polygon_2> offset_holes;
|
||||||
|
|
||||||
oi = approx_offset.inset (P, r,
|
oi = approx_offset.inset (pgn, r,
|
||||||
oi);
|
oi);
|
||||||
|
|
||||||
return (oi);
|
return (oi);
|
||||||
|
|
|
||||||
|
|
@ -31,18 +31,15 @@
|
||||||
namespace CGAL {
|
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
|
||||||
Computes the Minkowski sum \f$ P \oplus Q\f$ of the two given polygons.
|
* extracts those loops of the convolution which are part of the Minkowsi
|
||||||
The function computes the reduced convolution of the two polygons and
|
* sum. This method works very efficiently, regardless of whether `P` and
|
||||||
extracts those loops of the convolution which are part of the Minkowsi
|
* `Q` are convex or non-convex.
|
||||||
sum. This method works very efficiently, regardless of whether `P` and
|
* Note that as the input polygons may not be convex, their Minkowski
|
||||||
`Q` are convex or non-convex.
|
* sum may not be a simple polygon. The result is therefore represented
|
||||||
Note that as the input polygons may not be convex, their Minkowski
|
* as a polygon with holes.
|
||||||
sum may not be a simple polygon. The result is therefore represented
|
* \pre Both `P` and `Q` are simple, counterclockwise-oriented polygons.
|
||||||
as a polygon with holes.
|
|
||||||
|
|
||||||
\pre Both `P` and `Q` are simple, counterclockwise-oriented polygons.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
template <class Kernel, class Container>
|
template <class Kernel, class Container>
|
||||||
|
|
@ -65,33 +62,26 @@ minkowski_sum_reduced_convolution_2 (const Polygon_2<Kernel,Container>& pgn1,
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\ingroup PkgMinkowskiSum2
|
* Compute the Minkowski sum of two simple polygons using the convolution
|
||||||
|
* method.
|
||||||
Computes the Minkowski sum \f$ P \oplus Q\f$ of the two given polygons.
|
* Note that as the input polygons may not be convex, their Minkowski sum may
|
||||||
The function computes the convolution cycles of the two polygons and
|
* not be a simple polygon. The result is therefore represented as a polygon
|
||||||
extract the regions having positive winding number with respect to these
|
* with holes.
|
||||||
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 <class Kernel, class Container>
|
template <class Kernel, class Container>
|
||||||
Polygon_with_holes_2<Kernel,Container>
|
Polygon_with_holes_2<Kernel,Container>
|
||||||
minkowski_sum_full_convolution_2 (const Polygon_2<Kernel,Container>& P,
|
minkowski_sum_full_convolution_2 (const Polygon_2<Kernel,Container>& pgn1,
|
||||||
const Polygon_2<Kernel,Container>& Q)
|
const Polygon_2<Kernel,Container>& pgn2)
|
||||||
{
|
{
|
||||||
Minkowski_sum_by_convolution_2<Kernel, Container> mink_sum;
|
Minkowski_sum_by_convolution_2<Kernel, Container> mink_sum;
|
||||||
Polygon_2<Kernel,Container> sum_bound;
|
Polygon_2<Kernel,Container> sum_bound;
|
||||||
std::list<Polygon_2<Kernel,Container> > sum_holes;
|
std::list<Polygon_2<Kernel,Container> > sum_holes;
|
||||||
|
|
||||||
if (P.size() > Q.size())
|
if (pgn1.size() > pgn2.size())
|
||||||
mink_sum (P, Q, sum_bound, std::back_inserter(sum_holes));
|
mink_sum (pgn1, pgn2, sum_bound, std::back_inserter(sum_holes));
|
||||||
else
|
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<Kernel,Container> (sum_bound,
|
return (Polygon_with_holes_2<Kernel,Container> (sum_bound,
|
||||||
sum_holes.begin(),
|
sum_holes.begin(),
|
||||||
|
|
@ -99,49 +89,40 @@ minkowski_sum_full_convolution_2 (const Polygon_2<Kernel,Container>& P,
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\ingroup PkgMinkowskiSum2
|
* Compute the Minkowski sum of two simple polygons using the reduced
|
||||||
|
* convolution method.
|
||||||
Computes the Minkowski sum \f$ P \oplus Q\f$ of the two given polygons
|
* Note that as the input polygons may not be convex, their Minkowski sum may
|
||||||
using the reduced convolution method.
|
* not be a simple polygon. The result is therefore represented as a polygon
|
||||||
Note that as the input polygons may not be convex, their Minkowski
|
* with holes.
|
||||||
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()`
|
||||||
\pre Both `P` and `Q` are simple, counterclockwise-oriented polygons.
|
|
||||||
|
|
||||||
\sa `CGAL::minkowski_sum_reduced_convolution_2()`
|
|
||||||
\sa `CGAL::minkowski_sum_full_convolution_2()`
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
template <class Kernel, class Container>
|
template <class Kernel, class Container>
|
||||||
Polygon_with_holes_2<Kernel,Container>
|
Polygon_with_holes_2<Kernel,Container>
|
||||||
minkowski_sum_2 (const Polygon_2<Kernel,Container>& P,
|
minkowski_sum_2 (const Polygon_2<Kernel,Container>& pgn1,
|
||||||
const Polygon_2<Kernel,Container>& Q)
|
const Polygon_2<Kernel,Container>& pgn2)
|
||||||
{
|
{
|
||||||
return minkowski_sum_reduced_convolution_2(P, Q);
|
return minkowski_sum_reduced_convolution_2(pgn1, pgn2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\ingroup PkgMinkowskiSum2
|
* Compute the Minkowski sum of two simple polygons by decomposing each
|
||||||
|
* polygon to convex sub-polygons and computing the union of the pairwise
|
||||||
Computes the Minkowski sum \f$ P \oplus Q\f$ of the two given polygons.
|
* Minkowski sums of the sub-polygons.
|
||||||
If the input polygons `P` and `Q` are not convex, the function
|
* Note that as the input polygons may not be convex, their Minkowski sum may
|
||||||
decomposes them into convex sub-polygons \f$ P_1, \ldots, P_k\f$ and
|
* not be a simple polygon. The result is therefore represented as a polygon
|
||||||
\f$ Q_1, \ldots, Q_{\ell}\f$ and computes the union of pairwise sub-sums
|
* with holes.
|
||||||
(namely \f$ \bigcup_{i,j}{(P_i \oplus Q_j)}\f$).
|
* \param pgn1 The first polygon.
|
||||||
The decomposition is performed using the given decomposition strategy
|
* \param pgn2 The second polygon.
|
||||||
`decomp`, which must be an instance of a class that models the
|
* \param decomp A functor for decomposing polygons.
|
||||||
concept `PolygonConvexDecomposition`.
|
* \param sum Output: The resulting polygon with holes, representing the sum.
|
||||||
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 <class Kernel, class Container, class DecompositionStrategy>
|
template <class Kernel, class Container, class DecompositionStrategy>
|
||||||
Polygon_with_holes_2<Kernel,Container>
|
Polygon_with_holes_2<Kernel,Container>
|
||||||
minkowski_sum_2 (const Polygon_2<Kernel,Container>& P,
|
minkowski_sum_2 (const Polygon_2<Kernel,Container>& pgn1,
|
||||||
const Polygon_2<Kernel,Container>& Q,
|
const Polygon_2<Kernel,Container>& pgn2,
|
||||||
const DecompositionStrategy&)
|
const DecompositionStrategy&)
|
||||||
{
|
{
|
||||||
Minkowski_sum_by_decomposition_2<DecompositionStrategy,Container> mink_sum;
|
Minkowski_sum_by_decomposition_2<DecompositionStrategy,Container> mink_sum;
|
||||||
|
|
@ -150,7 +131,7 @@ minkowski_sum_2 (const Polygon_2<Kernel,Container>& P,
|
||||||
|
|
||||||
Polygon_with_holes_2 sum;
|
Polygon_with_holes_2 sum;
|
||||||
|
|
||||||
sum = mink_sum (P, Q);
|
sum = mink_sum (pgn1, pgn2);
|
||||||
|
|
||||||
return (sum);
|
return (sum);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,23 +27,19 @@
|
||||||
namespace CGAL {
|
namespace CGAL {
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\ingroup PkgMinkowskiSum2
|
* Compute the offset of a given simple polygon by a given radius,
|
||||||
|
* using the convolution method.
|
||||||
Computes the offset of the given polygon `P` by a given radius
|
* Note that as the input polygon may not be convex, its offset may not be
|
||||||
`r` - namely, the function computes the Minkowski sum
|
* simply connected. The result is therefore represented as a polygon with
|
||||||
\f$ P \oplus B_r\f$, where \f$ B_r\f$ is a disc of radius `r` centered at the
|
* holes.
|
||||||
origin.
|
* \param pgn The polygon.
|
||||||
Note that as the input polygon may not be convex, its offset may not be a
|
* \param r The offset radius.
|
||||||
simple polygon. The result is therefore represented as a generalized
|
* \return The offset polygon.
|
||||||
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 <class ConicTraits, class Container>
|
template <class ConicTraits, class Container>
|
||||||
typename Gps_traits_2<ConicTraits>::Polygon_with_holes_2
|
typename Gps_traits_2<ConicTraits>::Polygon_with_holes_2
|
||||||
offset_polygon_2 (const Polygon_2<typename ConicTraits::Rat_kernel,
|
offset_polygon_2 (const Polygon_2<typename ConicTraits::Rat_kernel,
|
||||||
Container>& P,
|
Container>& pgn,
|
||||||
const typename ConicTraits::Rat_kernel::FT& r,
|
const typename ConicTraits::Rat_kernel::FT& r,
|
||||||
const ConicTraits& )
|
const ConicTraits& )
|
||||||
{
|
{
|
||||||
|
|
@ -56,7 +52,7 @@ offset_polygon_2 (const Polygon_2<typename ConicTraits::Rat_kernel,
|
||||||
Offset_polygon_2 offset_bound;
|
Offset_polygon_2 offset_bound;
|
||||||
std::list<Offset_polygon_2> offset_holes;
|
std::list<Offset_polygon_2> offset_holes;
|
||||||
|
|
||||||
exact_offset (P, r,
|
exact_offset (pgn, r,
|
||||||
offset_bound, std::back_inserter(offset_holes));
|
offset_bound, std::back_inserter(offset_holes));
|
||||||
|
|
||||||
return (typename Gps_traits_2<ConicTraits>::Polygon_with_holes_2
|
return (typename Gps_traits_2<ConicTraits>::Polygon_with_holes_2
|
||||||
|
|
@ -64,16 +60,15 @@ offset_polygon_2 (const Polygon_2<typename ConicTraits::Rat_kernel,
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\ingroup PkgMinkowskiSum2
|
* Compute the offset of a given polygon with holes by a given radius,
|
||||||
|
* using the convolution method.
|
||||||
Computes the offset of the given polygon with holes `pwh` by a given
|
* The result is represented as a polygon with holes whose edges are line
|
||||||
radius `r`. It does so by offsetting outer boundary of `pwh` and
|
* segments and circular arcs.
|
||||||
insetting its holes.
|
* \param pwh The polygon with holes.
|
||||||
The result is represented as a generalized polygon with holes, such that the
|
* \param r The offset radius.
|
||||||
edges of the polygon correspond to line segments and circular arcs, both are
|
* \pre The polygon is bounded (has a valid outer boundary).
|
||||||
special types of conic arcs, as represented by the `traits` class.
|
* \return The offset polygon.
|
||||||
\pre `pwh` is <I>not</I> unbounded (it has a valid outer boundary).
|
*/
|
||||||
*/
|
|
||||||
template <class ConicTraits, class Container>
|
template <class ConicTraits, class Container>
|
||||||
typename Gps_traits_2<ConicTraits>::Polygon_with_holes_2
|
typename Gps_traits_2<ConicTraits>::Polygon_with_holes_2
|
||||||
offset_polygon_2 (const Polygon_with_holes_2<typename ConicTraits::Rat_kernel,
|
offset_polygon_2 (const Polygon_with_holes_2<typename ConicTraits::Rat_kernel,
|
||||||
|
|
@ -98,25 +93,24 @@ offset_polygon_2 (const Polygon_with_holes_2<typename ConicTraits::Rat_kernel,
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\ingroup PkgMinkowskiSum2
|
* Compute the offset of a given simple polygon by a given radius,
|
||||||
|
* by decomposing it to convex sub-polygons and computing the union of their
|
||||||
Computes the exact representation of the offset of the given polygon
|
* offsets.
|
||||||
`P` by a radius `r`, as described above.
|
* Note that as the input polygon may not be convex, its offset may not be
|
||||||
If `P` is not convex, the function decomposes it into convex
|
* simply connected. The result is therefore represented as a polygon with
|
||||||
sub-polygons \f$ P_1, \ldots, P_k\f$ and computes the union of sub-offsets
|
* holes.
|
||||||
(namely \f$ \bigcup_{i}{(P_i \oplus B_r)}\f$).
|
* \param pgn The polygon.
|
||||||
The decomposition is performed using the given decomposition strategy
|
* \param r The offset radius.
|
||||||
`decomp`, which must be an instance of a class that models the
|
* \param decomp A functor for decomposing polygons.
|
||||||
concept `PolygonConvexDecomposition`.
|
* \return The offset polygon.
|
||||||
\pre `P` is a simple polygon.
|
*/
|
||||||
*/
|
|
||||||
template <class ConicTraits, class Container, class DecompositionStrategy>
|
template <class ConicTraits, class Container, class DecompositionStrategy>
|
||||||
typename Gps_traits_2<ConicTraits>::Polygon_with_holes_2
|
typename Gps_traits_2<ConicTraits>::Polygon_with_holes_2
|
||||||
offset_polygon_2 (const Polygon_2<typename ConicTraits::Rat_kernel,
|
offset_polygon_2 (const Polygon_2<typename ConicTraits::Rat_kernel,
|
||||||
Container>& P,
|
Container>& pgn,
|
||||||
const typename ConicTraits::Rat_kernel::FT& r,
|
const typename ConicTraits::Rat_kernel::FT& r,
|
||||||
const DecompositionStrategy& decomp,
|
const DecompositionStrategy&,
|
||||||
const ConicTraits& traits)
|
const ConicTraits& )
|
||||||
{
|
{
|
||||||
typedef Exact_offset_base_2<ConicTraits, Container> Base;
|
typedef Exact_offset_base_2<ConicTraits, Container> Base;
|
||||||
typedef Offset_by_decomposition_2<Base, DecompositionStrategy>
|
typedef Offset_by_decomposition_2<Base, DecompositionStrategy>
|
||||||
|
|
@ -128,7 +122,7 @@ offset_polygon_2 (const Polygon_2<typename ConicTraits::Rat_kernel,
|
||||||
Offset_polygon_2 offset_bound;
|
Offset_polygon_2 offset_bound;
|
||||||
std::list<Offset_polygon_2> offset_holes;
|
std::list<Offset_polygon_2> offset_holes;
|
||||||
|
|
||||||
exact_offset (P, r,
|
exact_offset (pgn, r,
|
||||||
offset_bound, std::back_inserter(offset_holes));
|
offset_bound, std::back_inserter(offset_holes));
|
||||||
|
|
||||||
return (typename Gps_traits_2<ConicTraits>::Polygon_with_holes_2
|
return (typename Gps_traits_2<ConicTraits>::Polygon_with_holes_2
|
||||||
|
|
@ -136,27 +130,22 @@ offset_polygon_2 (const Polygon_2<typename ConicTraits::Rat_kernel,
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\ingroup PkgMinkowskiSum2
|
* Compute the inset of a given simple polygon by a given radius, using the
|
||||||
|
* convolution method.
|
||||||
Computes the inset, or inner offset, of the given polygon `P` by a
|
* Note that as the input polygon may not be convex, its inset may not be
|
||||||
given radius `r` - namely, the function computes the set of points
|
* simply connected. The result is therefore represented as a set of polygons.
|
||||||
inside the polygon whose distance from \f$ P\f$'s boundary is at least \f$ r\f$:
|
* \param pgn The polygon.
|
||||||
\f$ \{ p \in P \;|\; {\rm dist}(p, \partial P) \geq r \}\f$.
|
* \param r The inset radius.
|
||||||
Note that as the input polygon may not be convex, its inset may comprise
|
* \param oi An output iterator for the inset polygons.
|
||||||
several disconnected components. The result is therefore represented as a
|
* Its value-type must be Gps_traits_2<ConicTraits>::Polygon_2.
|
||||||
sequence of generalized polygons, such that the edges of each polygon
|
* \return A past-the-end iterator for the inset polygons.
|
||||||
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 <class ConicTraits, class Container, class OutputIterator>
|
template <class ConicTraits, class Container, class OutputIterator>
|
||||||
OutputIterator
|
OutputIterator
|
||||||
inset_polygon_2 (const Polygon_2<typename ConicTraits::Rat_kernel,
|
inset_polygon_2 (const Polygon_2<typename ConicTraits::Rat_kernel,
|
||||||
Container>& P,
|
Container>& pgn,
|
||||||
const typename ConicTraits::Rat_kernel::FT& r,
|
const typename ConicTraits::Rat_kernel::FT& r,
|
||||||
const ConicTraits& traits,
|
const ConicTraits& ,
|
||||||
OutputIterator oi)
|
OutputIterator oi)
|
||||||
{
|
{
|
||||||
typedef Exact_offset_base_2<ConicTraits, Container> Base;
|
typedef Exact_offset_base_2<ConicTraits, Container> Base;
|
||||||
|
|
@ -165,7 +154,7 @@ inset_polygon_2 (const Polygon_2<typename ConicTraits::Rat_kernel,
|
||||||
Base base;
|
Base base;
|
||||||
Exact_offset_2 exact_offset (base);
|
Exact_offset_2 exact_offset (base);
|
||||||
|
|
||||||
oi = exact_offset.inset (P, r,
|
oi = exact_offset.inset (pgn, r,
|
||||||
oi);
|
oi);
|
||||||
|
|
||||||
return (oi);
|
return (oi);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue