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:
Sebastian Morr 2014-08-13 13:53:47 +02:00
parent 90d86774dd
commit 187856517f
11 changed files with 531 additions and 270 deletions

View File

@ -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 */

View File

@ -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 */

View File

@ -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 */

View File

@ -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 */

View File

@ -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 */

View File

@ -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

View File

@ -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<typename Kernel::Point_2>`.
\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 Kernel_,
class Container_ = std::vector<typename Kernel_::Point_2> >
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<typename Kernel::Point_2>`.
\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 Kernel_,
class Container_ = std::vector<typename Kernel_::Point_2> >
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<typename Kernel::Point_2>`.
\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 Kernel_,
class Container_ = std::vector<typename Kernel_::Point_2> >
class Greene_convex_decomposition_2 :

View File

@ -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<Kernel,Container>`. The `Container` parameter
is by default `std::vector<typename Kernel::Point_2>`.
\cgalModels `PolygonConvexDecomposition_2`
*/
* \class
* Small-side angle-bisector decomposition strategy.
*/
template <class Kernel_,
class Container_ = std::vector<typename Kernel_::Point_2> >
class Small_side_angle_bisector_decomposition_2

View File

@ -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 <class Kernel, class Container>
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 double& eps)
{
@ -55,7 +52,7 @@ approximated_offset_2 (const Polygon_2<Kernel, Container>& P,
Offset_polygon_2 offset_bound;
std::list<Offset_polygon_2> offset_holes;
approx_offset (P, r,
approx_offset (pgn, r,
offset_bound, std::back_inserter(offset_holes));
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
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).
*/
* 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 <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>& pwh,
@ -96,24 +93,24 @@ approximated_offset_2 (const Polygon_with_holes_2<Kernel, Container>& 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 <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,
approximated_offset_2 (const Polygon_2<Kernel, Container>& pgn,
const typename Kernel::FT& r,
const double& eps,
const DecompositionStrategy& decomp)
const DecompositionStrategy&)
{
typedef Approx_offset_base_2<Kernel, Container> Base;
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;
std::list<Offset_polygon_2> offset_holes;
approx_offset (P, r,
approx_offset (pgn, r,
offset_bound, std::back_inserter(offset_holes));
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
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<Kernel>::Polygon_2.
* \return A past-the-end iterator for the inset polygons.
*/
template <class Kernel, class Container, class 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 double& eps,
OutputIterator oi)
@ -165,7 +158,7 @@ approximated_inset_2 (const Polygon_2<Kernel, Container>& P,
Offset_polygon_2 offset_bound;
std::list<Offset_polygon_2> offset_holes;
oi = approx_offset.inset (P, r,
oi = approx_offset.inset (pgn, r,
oi);
return (oi);

View File

@ -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 <class Kernel, class Container>
@ -65,33 +62,26 @@ minkowski_sum_reduced_convolution_2 (const Polygon_2<Kernel,Container>& 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 <class Kernel, class Container>
Polygon_with_holes_2<Kernel,Container>
minkowski_sum_full_convolution_2 (const Polygon_2<Kernel,Container>& P,
const Polygon_2<Kernel,Container>& Q)
minkowski_sum_full_convolution_2 (const Polygon_2<Kernel,Container>& pgn1,
const Polygon_2<Kernel,Container>& pgn2)
{
Minkowski_sum_by_convolution_2<Kernel, Container> mink_sum;
Polygon_2<Kernel,Container> sum_bound;
std::list<Polygon_2<Kernel,Container> > 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<Kernel,Container> (sum_bound,
sum_holes.begin(),
@ -99,49 +89,40 @@ minkowski_sum_full_convolution_2 (const Polygon_2<Kernel,Container>& 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 <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)
minkowski_sum_2 (const Polygon_2<Kernel,Container>& pgn1,
const Polygon_2<Kernel,Container>& 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 <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,
minkowski_sum_2 (const Polygon_2<Kernel,Container>& pgn1,
const Polygon_2<Kernel,Container>& pgn2,
const DecompositionStrategy&)
{
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;
sum = mink_sum (P, Q);
sum = mink_sum (pgn1, pgn2);
return (sum);
}

View File

@ -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 <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,
Container>& pgn,
const typename ConicTraits::Rat_kernel::FT& r,
const ConicTraits& )
{
@ -56,7 +52,7 @@ offset_polygon_2 (const Polygon_2<typename ConicTraits::Rat_kernel,
Offset_polygon_2 offset_bound;
std::list<Offset_polygon_2> offset_holes;
exact_offset (P, r,
exact_offset (pgn, r,
offset_bound, std::back_inserter(offset_holes));
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
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).
*/
* 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 <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,
@ -98,25 +93,24 @@ offset_polygon_2 (const Polygon_with_holes_2<typename ConicTraits::Rat_kernel,
}
/*!
\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.
*/
* 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
* 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 decomp A functor for decomposing polygons.
* \return The offset 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,
Container>& pgn,
const typename ConicTraits::Rat_kernel::FT& r,
const DecompositionStrategy& decomp,
const ConicTraits& traits)
const DecompositionStrategy&,
const ConicTraits& )
{
typedef Exact_offset_base_2<ConicTraits, Container> Base;
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;
std::list<Offset_polygon_2> offset_holes;
exact_offset (P, r,
exact_offset (pgn, r,
offset_bound, std::back_inserter(offset_holes));
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
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.
*/
* Compute 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 oi An output iterator for the inset polygons.
* Its value-type must be Gps_traits_2<ConicTraits>::Polygon_2.
* \return A past-the-end iterator for the inset polygons.
*/
template <class ConicTraits, class Container, class OutputIterator>
OutputIterator
inset_polygon_2 (const Polygon_2<typename ConicTraits::Rat_kernel,
Container>& P,
Container>& pgn,
const typename ConicTraits::Rat_kernel::FT& r,
const ConicTraits& traits,
const ConicTraits& ,
OutputIterator oi)
{
typedef Exact_offset_base_2<ConicTraits, Container> Base;
@ -165,7 +154,7 @@ inset_polygon_2 (const Polygon_2<typename ConicTraits::Rat_kernel,
Base base;
Exact_offset_2 exact_offset (base);
oi = exact_offset.inset (P, r,
oi = exact_offset.inset (pgn, r,
oi);
return (oi);