CGAL 5.3 - 2D Straight Skeleton and Polygon Offsetting
CGAL::Polygon_offset_builder_2< StraightSkeleton_, Traits_, Container_ > Class Template Reference

#include <CGAL/Polygon_offset_builder_2.h>

Definition

The class Polygon_offset_builder_2 encapsulates the construction of inward offset contours of a 2D simple polygon with holes.

The construction is based on the straight skeleton of the interior of the polygon.

Template Parameters
StraightSkeleton_must be a model of the StraightSkeleton_2.
Traits_must be a model of the StraightSkeletonBuilderTraits_2.
Container_must be a model of the SequenceContainer.
See also
PolygonOffsetBuilderTraits_2
Polygon_offset_builder_traits_2
Examples:
Straight_skeleton_2/Low_level_API.cpp.

Types

typedef StraightSkeleton_ Ss
 The straight skeleton (first template parameter)
 
typedef Container_ Container
 The container of 2D vertices that represents each offset contour generated by the algorithm (third template parameter)
 
typedef Traits::FT FT
 The model of FieldWithSqrt used to specify the desired offset distance, provided by the geometric traits Traits.
 

Creation

 Polygon_offset_builder_2 (const Ss &ss, const Traits &traits=Traits())
 Constructs the builder class using the given Straight Skeleton instance.
 

Methods

template<class OutputIterator >
OutputIterator construct_offset_contours (FT t, OutputIterator out)
 Given the straight skeleton passed in the constructor which corresponds to the interior of a non-degenerate strictly-simple polygon with holes P, returns all the offset contours of P at the Euclidean distance t. More...
 

Member Function Documentation

◆ construct_offset_contours()

template<typename StraightSkeleton_ , typename Traits_ , typename Container_ >
template<class OutputIterator >
OutputIterator CGAL::Polygon_offset_builder_2< StraightSkeleton_, Traits_, Container_ >::construct_offset_contours ( FT  t,
OutputIterator  out 
)

Given the straight skeleton passed in the constructor which corresponds to the interior of a non-degenerate strictly-simple polygon with holes P, returns all the offset contours of P at the Euclidean distance t.

Such offset contours are polygons in the interior of P. Provided exact constructions are used, these polygons are strictly simple. For any offset distance t there are 0, 1, or more offset contours.

For any given input polygon, its offset polygons at a certain distance are composed of several contours. This method returns all such contours in an unspecified order and with no parental relationship between them (that is why it is called construct_offset_contours() and not construct_offset_polygons()).

Those offset contours in the resulting sequence which are oriented counter-clockwise are outer contours and those oriented clockwise are holes. It is up to the user to match each hole to its parent in order to reconstruct the parent-hole relationship of the conceptual output. It is sufficient to test each hole against each parent as there won't be a hole inside a hole, a parent inside any other contour, or a hole inside more than one parent. The recommended insideness test is to perform a regularized Boolean set operation. The function do_intersect() from Chapter 2D Regularized Boolean Set-Operations will work fine in our case since it is guaranteed that no hole would cross halfway outside any parent (in the presence of such cases, subtracting the parent from the hole works better as it correctly rejects halfway holes).

You can call construct_offset_contours() with different offset distances (there is no need to construct the builder again). If you call it with an offset distance so large that there are no offset contours at that distance, no contour is inserted into the output sequence and the returned iterator will be equal to out.

If there are degenerate, or nearly degenerate vertices; that is, vertices whose internal or external angle approaches 0, numerical overflow may prevent some of the polygon contours to be constructed. If that happens, the failed contour just won't be added into the resulting sequence.

Template Parameters
OutputIteratormust be a model of the OutputIterator category whose value_type is a boost::shared_ptr holding the dynamically allocated instances of type Container.
Parameters
tthe offset value
outan output iterator. For each resulting offset contour, a default constructed instance of Container type, is dynamically allocated and each offset vertex is added to it. A boost::shared_ptr holding onto the dynamically allocated container is inserted into the output sequence via the OutputIterator out.
Returns
an OutputIterator past-the-end of the resulting sequence, which contains each offset contour generated.
Precondition
t > 0