CGAL 5.6.2 - 2D Straight Skeleton and Polygon Offsetting
|
The following functions are used to construct the inward or outward offsets of a polygon.
Up to three different kernels can be used in the offset construction process:
InK
): This is the kernel type of the input polygons. SsK
): This is the kernel used for the construction of the (partial) straight skeleton. It might differ from the Input Kernel for example if the input is based on exact number types, but you wish to speed up the construction of the straight skeleton, using a lighter kernel such as CGAL::Exact_predicates_inexact_constructions_kernel
. OfK
): This is the kernel used for the construction of the offset polygons and is thus the kernel type for the output. When the kernel differs, CGAL::Cartesian_converter
is used to convert from one kernel to the other.
By default, SsK
and OfK
are chosen as CGAL::Exact_predicates_inexact_constructions_kernel
as a compromise between speed and robustness. See also Section Create Offset Polygons from a Polygon (With or Without Holes).
There are two classes of offset construction functions: those that simply return all the offset polygons, and those that also create an arrangement of the polygons to create a polygon with holes. The latter contain _with_holes in the name.
The return type of the offset construction function is thus dediced by whether or not it is a simple polygon or a polygon with holes, and on the dictated output kernel (see Section Kernel Choices). Thus, for an input polygon type InKPolygon
in an offset construction that does not arrange polygons (e.g. create_interior_skeleton_and_offset_polygons_2()
):
InK
of the input polygon type is different from the output kernel type OfK
, then the output polygon type is CGAL::Polygon_2<OfK>
. InK
is equal to the output kernel type OfK
, but the input polygon is a polygon with holes (a model of GeneralPolygonWithHoles_2
), then the return type is InKPolygon::General_polygon_2
. InK
of the input polygon type is equal to the output kernel type OfK
, and the input polygon is a polygon without holes (a model of SequenceContainer
with InK::Point_2
value type), then the return type is InKPolygon
. Similarly, if the return type is a polygon with holes (e.g. create_interior_skeleton_and_offset_polygons_with_holes_2()
, a similar dispatch exists:
InK
of the input polygon type is different from the output kernel type OfK
, then the output polygon type is CGAL::Polygon_with_holes_2<OfK>
. InK
is equal to the output kernel type OfK
, but the input polygon is a polygon with holes (a model of GeneralPolygonWithHoles_2
), then the return type is InKPolygon
. InK
of the input polygon type is equal to the output kernel type OfK
, and the input polygon is a polygon without holes (a model of SequenceContainer
with InK::Point_2
value type), then the return type is CGAL::Polygon_with_holes_2<OfK>
. Functions | |
template<class K , class InputPolygonPtrIterator , class OutputPolygonWithHolesPtrIterator > | |
bool | CGAL::arrange_offset_polygons_2 (InputPolygonPtrIterator begin, InputPolygonPtrIterator end, OutputPolygonWithHolesPtrIterator out, const K &k) |
The function arrange_offset_polygons_2() arranges the sequence of 2D polygons obtained by create_offset_polygons_2() into 2D polygons with holes by determining geometric parent-hole relationships using a simple algorithm based on the particular characteristics of offset polygons. More... | |
template<class InputIterator , class Traits > | |
boost::optional< typename Traits::FT > | CGAL::compute_outer_frame_margin (InputIterator first, InputIterator beyond, typename Traits::FT offset, const Traits &traits=Default_traits) |
computes the separation required between a polygon and the outer frame used to obtain an exterior skeleton suitable for the computation of outer offset polygons at a given distance. More... | |
template<typename OfKPolygon , typename FT , typename StraightSkeleton , typename OfK > | |
std::vector< boost::shared_ptr< OfKPolygon > > | CGAL::create_offset_polygons_2 (FT offset, const StraightSkeleton &ss, OfK k=Exact_predicates_inexact_constructions_kernel()) |
returns a container with the offset polygons at distance offset obtained from the straight skeleton ss . More... | |
template<typename OfKPolygon , typename FT , typename InKPolygon , typename HoleIterator , typename OfK , typename SsK > | |
std::vector< boost::shared_ptr< OfKPolygon > > | CGAL::create_interior_skeleton_and_offset_polygons_2 (FT offset, const InKPolygon &outer_boundary, HoleIterator holes_begin, HoleIterator holes_end, OfK ofk=CGAL::Exact_predicates_inexact_constructions_kernel, SsK ssk=CGAL::Exact_predicates_inexact_constructions_kernel()) |
returns a container with all the inner offset polygons at distance offset of a 2D polygon with holes. More... | |
template<typename OfKPolygon , typename FT , typename InKPolygon , typename OfK , typename SsK > | |
std::vector< boost::shared_ptr< OfKPolygon > > | CGAL::create_interior_skeleton_and_offset_polygons_2 (FT offset, const InKPolygon &poly, OfK ofk=CGAL::Exact_predicates_inexact_constructions_kernel, SsK ssk=CGAL::Exact_predicates_inexact_constructions_kernel()) |
returns a container with all the inner offset polygons at distance offset of the 2D polygon poly . More... | |
template<typename OfKPolygon , typename FT , typename InKPolygon , typename OfK , typename SsK > | |
std::vector< boost::shared_ptr< OfKPolygon > > | CGAL::create_exterior_skeleton_and_offset_polygons_2 (FT offset, const InKPolygon &poly, OfK ofk=Exact_predicates_inexact_constructions_kernel(), SsK ssk=Exact_predicates_inexact_constructions_kernel()) |
returns a container with all the outer offset polygons at distance offset of the 2D polygon poly . More... | |
template<class OfKPolygon , class FT , class InKPolygon , class OfK , class SsK > | |
std::vector< boost::shared_ptr< OfKPolygon > > | CGAL::create_interior_skeleton_and_offset_polygons_with_holes_2 (FT offset, const InKPolygon &poly_with_holes, OfK ofk=CGAL::Exact_predicates_inexact_constructions_kernel, SsK ssk=CGAL::Exact_predicates_inexact_constructions_kernel) |
returns a container with all the inner offset polygons with holes at distance offset of the 2D polygon with holes poly_with_holes . More... | |
template<class OfKPolygon , class FT , class InKPolygon , class OfK , class SsK > | |
std::vector< boost::shared_ptr< OfKPolygon > > | CGAL::create_exterior_skeleton_and_offset_polygons_with_holes_2 (FT offset, const InKPolygon &poly_with_holes, OfK ofk=Exact_predicates_inexact_constructions_kernel(), SsK ssk=Exact_predicates_inexact_constructions_kernel()) |
returns a container with all the outer offset polygons with holes at distance offset of the 2D polygon poly_with_holes . More... | |
template<class OfKPolygon , class FT , class InKPolygon , class OfK , class SsK > | |
std::vector< boost::shared_ptr< OfKPolygon > > | CGAL::create_interior_weighted_skeleton_and_offset_polygons_with_holes_2 (FT offset, const InKPolygon &poly_with_holes, OfK ofk=CGAL::Exact_predicates_inexact_constructions_kernel, SsK ssk=CGAL::Exact_predicates_inexact_constructions_kernel) |
returns a container with all the inner offset polygons with holes at distance offset of the 2D polygon with holes poly_with_holes . More... | |
template<class OfKPolygon , class FT , class InKPolygon , class OfK , class SsK > | |
std::vector< boost::shared_ptr< OfKPolygon > > | CGAL::create_exterior_weighted_skeleton_and_offset_polygons_with_holes_2 (FT offset, const InKPolygon &poly_with_holes, OfK ofk=Exact_predicates_inexact_constructions_kernel(), SsK ssk=Exact_predicates_inexact_constructions_kernel()) |
returns a container with all the outer offset polygons with holes at distance offset of the 2D polygon poly_with_holes . More... | |
template<class Target_skeleton , class Source_skeleton , class Items_converter > | |
boost::shared_ptr< Target_skeleton > | CGAL::convert_straight_skeleton_2 (Source_skeleton const &s, Items_converted const &ic=Items_converter()) |
returns a new straight skeleton data structure with the same combinatorial and geometric data as s using the items converter ic to convert the geometric embedding to the types of the target skeleton. More... | |
bool CGAL::arrange_offset_polygons_2 | ( | InputPolygonPtrIterator | begin, |
InputPolygonPtrIterator | end, | ||
OutputPolygonWithHolesPtrIterator | out, | ||
const K & | k | ||
) |
#include <CGAL/arrange_offset_polygons_2.h>
The function arrange_offset_polygons_2()
arranges the sequence of 2D polygons obtained by create_offset_polygons_2()
into 2D polygons with holes by determining geometric parent-hole relationships using a simple algorithm based on the particular characteristics of offset polygons.
The function determines parent-hole relationships among the polygons given by [begin,end]
creating boost::shared_ptr< GeneralPolygonWithHoles_2 >
objects added to the output sequence given out
. A CLOCKWISE
oriented polygon H
is a hole of a COUNTERCLOCKWISE
polygon P
, iff at least one vertex of H
is ON_BOUNDED_SIDE
of P
.
This function should not be used to arrange arbitrary polygons into polygons with holes unless they meet the requirements specified below.
P
and Q
, there are vertices of P
which are not on the boundary of Q
and are all on the bounded or unbounded side of Q
(but not both).K | must be a model of Kernel . |
InputPolygonPtrIterator | must be a model of InputIterator whose value_type is a smart pointer (such as boost::shared_ptr ) whose element_type is a model of SequenceContainer with value type K::Point_2 . |
OutputPolygonWithHolesPtrIterator | must be a model of OutputIterator whose value_type is a smart pointer (such as boost::shared_ptr ) whose element_type is a model of GeneralPolygonWithHoles_2 . |
true
if no error was encountered, and false
otherwise.boost::optional< typename Traits::FT > CGAL::compute_outer_frame_margin | ( | InputIterator | first, |
InputIterator | beyond, | ||
typename Traits::FT | offset, | ||
const Traits & | traits = Default_traits |
||
) |
#include <CGAL/compute_outer_frame_margin.h>
computes the separation required between a polygon and the outer frame used to obtain an exterior skeleton suitable for the computation of outer offset polygons at a given distance.
Given a non-degenerate strictly-simple 2D polygon whose vertices are passed in the range [first
,beyond
), calculates the largest euclidean distance d
between each input vertex and its corresponding offset vertex at a distance offset
.
If such a distance can be approximately computed, returns an optional<FT>
with the value d + (offset * 1.05)
. If the distance cannot be computed, not even approximately, due to overflow for instance, returns an empty optional<FT>
(an absent result).
This result is the required separation between the input polygon and the rectangular frame used to construct an exterior offset contour at distance offset
(which is done by placing the polygon as a hole of that frame).
Such a separation must be computed in this way because if the frame is too close to the polygon, the inward offset contour from the frame could collide with the outward offset contour of the polygon, resulting in a merged contour offset instead of two contour offsets, one of them corresponding to the frame.
Simply using 2*offset
as the separation is incorrect since offset
is the distance between an offset line and its original, not between an offset vertex and its original. The later, which is calculated by this function and needed to place the frame sufficiently away from the polygon, can be thousands of times larger than offset
.
If the result is absent, any attempt to construct an exterior offset polygon at distance offset
will fail. This will occur whenever the polygon has a vertex with an internal angle approaching 0
(because the offset vertex of a vertex whose internal angle equals 0 is at infinity).
The default traits class Default_traits
is an instance of the class Polygon_offset_builder_traits_2<Kernel>
parameterized on the kernel in which the type InputIterator::value_type
is defined.
Traits | must be a model for PolygonOffsetBuilderTraits_2 . |
InputIterator | must be a model of InputIterator with value_type equivalent to Traits::Point_2 . |
offset > 0
. first
,beyond
) contains the vertices of a non-degenerate strictly-simple 2D polygon.boost::shared_ptr<Target_skeleton> CGAL::convert_straight_skeleton_2 | ( | Source_skeleton const & | s, |
Items_converted const & | ic = Items_converter() |
||
) |
#include <CGAL/Straight_skeleton_converter_2.h>
returns a new straight skeleton data structure with the same combinatorial and geometric data as s
using the items converter ic
to convert the geometric embedding to the types of the target skeleton.
Target_skeleton | must be a model of StraightSkeleton_2 |
Source_skeleton | must be a model of StraightSkeleton_2 |
Items_converter | must be a model of StraightSkeletonItemsConverter_2 |
CGAL::Straight_skeleton_items_converter_2<SrcSs,TgtSs,NTCV>
CGAL::Straight_skeleton_converter_2<SrcSs,TgtSs,ItemsCV>
std::vector< boost::shared_ptr<OfKPolygon> > CGAL::create_exterior_skeleton_and_offset_polygons_2 | ( | FT | offset, |
const InKPolygon & | poly, | ||
OfK | ofk = Exact_predicates_inexact_constructions_kernel() , |
||
SsK | ssk = Exact_predicates_inexact_constructions_kernel() |
||
) |
#include <CGAL/create_offset_polygons_2.h>
returns a container with all the outer offset polygons at distance offset
of the 2D polygon poly
.
The exterior skeleton is limited by an outer rectangular frame placed at a margin sufficiently large to allow the offset polygons to be constructed.
create_exterior_straight_skeleton_2()
and create_offset_polygons_2()
instead.OfK | must be a model of Kernel . It is used to instantiate Polygon_offset_builder_traits_2<OfK> for constructing the offset polygons. |
SsK | must be a model of Kernel . It is used to instantiate Straight_skeleton_builder_traits_2<SsK> for constructing the straight skeleton. |
FT | must be a model of FieldNumberType convertible to OfK::FT and SsK::FT . |
InKPolygon | must be a model of SequenceContainer with value type InK::Point_2 (e.g. Polygon_2<InK> ) or a model of GeneralPolygonWithHoles_2 (e.g. Polygon_with_holes_2<InK> ). |
OfKPolygon | is a polygon without holes type determined from OfK and InKPolygon , see Section Polygon Return Type. |
SsK != OfK
the constructed straight skeleton is converted to CGAL::Straight_skeleton_2<OfK>
.offset
is positive std::vector<boost::shared_ptr<OfKPolygon> > CGAL::create_exterior_skeleton_and_offset_polygons_with_holes_2 | ( | FT | offset, |
const InKPolygon & | poly_with_holes, | ||
OfK | ofk = Exact_predicates_inexact_constructions_kernel() , |
||
SsK | ssk = Exact_predicates_inexact_constructions_kernel() |
||
) |
#include <CGAL/create_offset_polygons_from_polygon_with_holes_2.h>
returns a container with all the outer offset polygons with holes at distance offset
of the 2D polygon poly_with_holes
.
Note that the offset of the outer frame is ignored.
This is equivalent to a call to CGAL::arrange_offset_polygons_2()
on the output of create_exterior_skeleton_and_offset_polygons_2(offset, poly_with_holes, ofk, ssk))
after having filtered out the polygon corresponding to the offset of the outer frame and having reversed the orientation of all other polygons.
OfK | must be a model of Kernel . It is used to instantiate Polygon_offset_builder_traits_2<OfK> for constructing the offset polygons. |
SsK | must be a model of Kernel . It is used to instantiate Straight_skeleton_builder_traits_2<SsK> for constructing the straight skeleton. |
FT | must be a model of FieldNumberType convertible to OfK::FT and SsK::FT . |
InKPolygon | must be a model of SequenceContainer with value type InK::Point_2 (e.g. Polygon_2<InK> ) or a model of GeneralPolygonWithHoles_2 (e.g. Polygon_with_holes_2<InK> ). |
OfKPolygon | is a polygon without holes type determined by OfK and InKPolygon , see Section Polygon Return Type. |
SsK != OfK
the constructed straight skeleton is converted to CGAL::Straight_skeleton_2<OfK>
.std::vector<boost::shared_ptr<OfKPolygon> > CGAL::create_exterior_weighted_skeleton_and_offset_polygons_with_holes_2 | ( | FT | offset, |
const InKPolygon & | poly_with_holes, | ||
OfK | ofk = Exact_predicates_inexact_constructions_kernel() , |
||
SsK | ssk = Exact_predicates_inexact_constructions_kernel() |
||
) |
#include <CGAL/create_weighted_offset_polygons_from_polygon_with_holes_2.h>
returns a container with all the outer offset polygons with holes at distance offset
of the 2D polygon poly_with_holes
.
Note that the offset of the outer frame is ignored.
This is equivalent to a call to CGAL::arrange_offset_polygons_2()
on the output of create_exterior_weighted_skeleton_and_offset_polygons_2(offset, poly_with_holes, ofk, ssk))
after having filtered out the polygon corresponding to the offset of the outer frame and having reversed the orientation of all other polygons.
OfK | must be a model of Kernel . It is used to instantiate Polygon_offset_builder_traits_2<OfK> for constructing the offset polygons. |
SsK | must be a model of Kernel . It is used to instantiate Straight_skeleton_builder_traits_2<SsK> for constructing the straight skeleton. |
FT | must be a model of FieldNumberType convertible to OfK::FT and SsK::FT . |
InKPolygon | must be a model of SequenceContainer with value type InK::Point_2 (e.g. Polygon_2<InK> ) or a model of GeneralPolygonWithHoles_2 (e.g. Polygon_with_holes_2<InK> ). |
OfKPolygon | is a polygon without holes type determined by OfK and InKPolygon , see Section Polygon Return Type. |
SsK != OfK
the constructed weighted straight skeleton is converted to CGAL::Straight_skeleton_2<OfK>
.std::vector< boost::shared_ptr<OfKPolygon> > CGAL::create_interior_skeleton_and_offset_polygons_2 | ( | FT | offset, |
const InKPolygon & | outer_boundary, | ||
HoleIterator | holes_begin, | ||
HoleIterator | holes_end, | ||
OfK | ofk = CGAL::Exact_predicates_inexact_constructions_kernel , |
||
SsK | ssk = CGAL::Exact_predicates_inexact_constructions_kernel() |
||
) |
#include <CGAL/create_offset_polygons_2.h>
returns a container with all the inner offset polygons at distance offset
of a 2D polygon with holes.
The outer boundary is outer_boundary
and its holes are given by [holes_begin,holes_end)
.
create_interior_straight_skeleton_2()
to create the skeleton only once, and then call create_offset_polygons_2()
for each distance.OfK | must be a model of Kernel . It is used to instantiate Polygon_offset_builder_traits_2<OfK> for constructing the offset polygons. |
SsK | must be a model of Kernel . It is used to instantiate Straight_skeleton_builder_traits_2<SsK> for constructing the straight skeleton. |
FT | must be a model of FieldNumberType convertible to OfK::FT and SsK::FT . |
HoleIterator | must be a model of InputIterator with value type being a model of ConstRange with value type SsK::Point_2 . |
InKPolygon | must be a model of SequenceContainer with value type InK::Point_2 (e.g. Polygon_2<InK> ). |
OfKPolygon | is a polygon without holes type determined from OfK and InKPolygon , see Section Polygon Return Type. |
SsK != OfK
the constructed straight skeleton is converted to CGAL::Straight_skeleton_2<OfK>
.outer_boundary
describes a weakly simple, counterclockwise polygon. [holes_begin,holes_end)
is a range of weakly simple, clockwise polygons. std::vector< boost::shared_ptr<OfKPolygon> > CGAL::create_interior_skeleton_and_offset_polygons_2 | ( | FT | offset, |
const InKPolygon & | poly, | ||
OfK | ofk = CGAL::Exact_predicates_inexact_constructions_kernel , |
||
SsK | ssk = CGAL::Exact_predicates_inexact_constructions_kernel() |
||
) |
#include <CGAL/create_offset_polygons_2.h>
returns a container with all the inner offset polygons at distance offset
of the 2D polygon poly
.
create_interior_straight_skeleton_2()
to create the skeleton only once, and then call create_offset_polygons_2()
for each distanceOfK | must be a model of Kernel . It is used to instantiate Polygon_offset_builder_traits_2<OfK> for constructing the offset polygons. |
SsK | must be a model of Kernel . It is used to instantiate Straight_skeleton_builder_traits_2<SsK> for constructing the straight skeleton. |
FT | must be a model of FieldNumberType convertible to OfK::FT and SsK::FT . |
InKPolygon | must be a model of SequenceContainer with value type InK::Point_2 (e.g. Polygon_2<InK> ) or a model of GeneralPolygonWithHoles_2 (e.g. Polygon_with_holes_2<InK> ). |
OfKPolygon | is a polygon without holes type determined by OfK and InKPolygon , see Section Polygon Return Type. |
SsK != OfK
the constructed straight skeleton is converted to CGAL::Straight_skeleton_2<OfK>
.offset
is positive std::vector< boost::shared_ptr< OfKPolygon > > CGAL::create_interior_skeleton_and_offset_polygons_with_holes_2 | ( | FT | offset, |
const InKPolygon & | poly_with_holes, | ||
OfK | ofk = CGAL::Exact_predicates_inexact_constructions_kernel , |
||
SsK | ssk = CGAL::Exact_predicates_inexact_constructions_kernel |
||
) |
#include <CGAL/create_offset_polygons_from_polygon_with_holes_2.h>
returns a container with all the inner offset polygons with holes at distance offset
of the 2D polygon with holes poly_with_holes
.
This is equivalent to arrange_offset_polygons_2(create_interior_skeleton_and_offset_polygons_2(offset, poly_with_holes, ofk, ssk))
.
OfK | must be a model of Kernel . It is used to instantiate Polygon_offset_builder_traits_2<OfK> for constructing the offset polygons. |
SsK | must be a model of Kernel . It is used to instantiate Straight_skeleton_builder_traits_2<SsK> for constructing the straight skeleton. |
FT | must be a model of FieldNumberType convertible to OfK::FT and SsK::FT . |
InKPolygon | must be a model of SequenceContainer with value type InK::Point_2 (e.g. Polygon_2<InK> ) or a model of GeneralPolygonWithHoles_2 (e.g. Polygon_with_holes_2<InK> ). |
OfKPolygon | is a polygon without holes type determined by OfK and InKPolygon , see Section Polygon Return Type. |
SsK != OfK
the constructed straight skeleton is converted to CGAL::Straight_skeleton_2<OfK>
.std::vector< boost::shared_ptr< OfKPolygon > > CGAL::create_interior_weighted_skeleton_and_offset_polygons_with_holes_2 | ( | FT | offset, |
const InKPolygon & | poly_with_holes, | ||
OfK | ofk = CGAL::Exact_predicates_inexact_constructions_kernel , |
||
SsK | ssk = CGAL::Exact_predicates_inexact_constructions_kernel |
||
) |
#include <CGAL/create_weighted_offset_polygons_from_polygon_with_holes_2.h>
returns a container with all the inner offset polygons with holes at distance offset
of the 2D polygon with holes poly_with_holes
.
This is equivalent to arrange_offset_polygons_2(create_interior_weighted_skeleton_and_offset_polygons_2(offset, poly_with_holes, ofk, ssk))
.
OfK | must be a model of Kernel . It is used to instantiate Polygon_offset_builder_traits_2<OfK> for constructing the offset polygons. |
SsK | must be a model of Kernel . It is used to instantiate Straight_skeleton_builder_traits_2<SsK> for constructing the weighted straight skeleton. |
FT | must be a model of FieldNumberType convertible to OfK::FT and SsK::FT . |
InKPolygon | must be a model of SequenceContainer with value type InK::Point_2 (e.g. Polygon_2<InK> ) or a model of GeneralPolygonWithHoles_2 (e.g. Polygon_with_holes_2<InK> ). |
OfKPolygon | is a polygon without holes type determined by OfK and InKPolygon , see Section Polygon Return Type. |
SsK != OfK
the constructed weighted straight skeleton is converted to CGAL::Straight_skeleton_2<OfK>
.std::vector< boost::shared_ptr<OfKPolygon> > CGAL::create_offset_polygons_2 | ( | FT | offset, |
const StraightSkeleton & | ss, | ||
OfK | k = Exact_predicates_inexact_constructions_kernel() |
||
) |
#include <CGAL/create_offset_polygons_2.h>
returns a container with the offset polygons at distance offset
obtained from the straight skeleton ss
.
If ss
is the interior skeleton of a polygon with holes, the offset polygons will be generated in its interior. If ss
is the outer skeleton of a polygon with holes, the offset polygons will be generated in its exterior.
OfK | must be a model of Kernel . It is used to instantiate Polygon_offset_builder_traits_2<OfK> for constructing the offset polygons. |
FT | must be a model of FieldNumberType convertible to OfK::FT . |
StraightSkeleton | is an object of type CGAL::Straight_skeleton_2<SsK> . |
OfKPolygon | is a polygon without holes type determined from OfK , see Section Polygon Return Type. |
SsK != OfK
the constructed straight skeleton is converted to CGAL::Straight_skeleton_2<OfK>
.offset
is positive. ss
is a valid straight skeleton.