CGAL 5.2.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<class OfKPolygon , class FT , class StraightSkeleton , class OfK > | |
std::vector< boost::shared_ptr< OfKPolygon > > | CGAL::create_offset_polygons_2 (FT offset, const StraightSkeleton &s, OfK k=Exact_predicates_inexact_constructions_kernel) |
returns a container with the offset polygons at distance offset obtained from the straight skeleton s . 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_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 HoleIterator , class OfK , class 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 the 2D polygon with holes whose outer boundary is outer_boundary and its holes are given by [holes_begin,holes_end) . 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_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<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 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.
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 . |
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).true
if no error was encountered, and false
otherwise.create_exterior_straight_skeleton_2()
CGAL::Straight_skeleton_builder_2<Traits,Ss,Visitor>
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
.
A temporary straight skeleton is constructed in the limited exterior of the input polygon to obtain the offsets. The construction of this skeleton is the most expensive operation, therefore, to construct offsets at more than one single distance, use the separate functions create_exterior_straight_skeleton_2()
and create_offset_polygons_2()
instead. The exterior skeleton is limited by an outer rectangular frame placed at a margin sufficiently large to allow the offset polygons to be constructed.
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 Straight_skeleton_2<OfK>
.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
.
This is equivalent to arrange_offset_polygons_2(create_exterior_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 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 the 2D polygon with holes whose outer boundary is outer_boundary
and its holes are given by [holes_begin,holes_end)
.
A temporary straight skeleton is constructed in the interior of the input polygon to obtain the offsets. The construction of this skeleton is the most expensive operation, therefore, to construct offsets at more than one single distance, use the separate functions create_interior_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 . |
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 Straight_skeleton_2<OfK>
.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
.
A temporary straight skeleton is constructed in the interior of the input polygon to obtain the offsets. The construction of this skeleton is the most expensive operation, therefore, to construct offsets at more than one single distance, use the separate functions create_interior_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 by OfK and InKPolygon , see Section Polygon Return Type. |
SsK != OfK
the constructed straight skeleton is converted to Straight_skeleton_2<OfK>
.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 Straight_skeleton_2<OfK>
.std::vector< boost::shared_ptr<OfKPolygon> > CGAL::create_offset_polygons_2 | ( | FT | offset, |
const StraightSkeleton & | s, | ||
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 s
.
If s
is the inner skeleton of a polygon with holes, the offset polygons will be generated in its interior. If s
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 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 Straight_skeleton_2<OfK>
.