39concept SetOperandConcept =
40 shapeRank<std::remove_cvref_t<T>> >= 0 &&
41 shapeRank<std::remove_cvref_t<T>> < shapeRank<PolygonSet<Point<>, NoLabel>> &&
54concept SetBooleanOperandConcept = PolygonalRegionConcept<T>;
68concept SetMinkowskiOperandConcept =
69 SetBooleanOperandConcept<T> || is_segment_v<T> || is_oriented_segment_v<T> ||
70 is_polyline_v<T> || is_monotone_chain_v<T>;
82template <
class ResultNumber,
class Component,
class Operand>
83concept ComponentDistanceL1Concept =
84 requires(
const Component& component,
const Operand& operand) {
85 component.template distanceL1<ResultNumber>(operand);
89template <
class ResultNumber,
class Component,
class Operand>
90concept ComponentDistanceLInfConcept =
91 requires(
const Component& component,
const Operand& operand) {
92 component.template distanceLInf<ResultNumber>(operand);
97template <
class Po
intType = Po
int<>,
class Label>
105template <PolygonWithHolesConcept Component>
108template <std::ranges::input_range ComponentRange>
109 requires detail::is_polygon_with_holes_v<std::ranges::range_value_t<ComponentRange>>
113template <std::ranges::input_range ComponentRange>
114 requires detail::is_polygon_with_holes_v<std::ranges::range_value_t<ComponentRange>>
164template <
class Po
intType_,
class TLabel>
171 class VertexIterator;
174 static_assert(detail::is_point_v<PointType>,
"PolygonSet requires pgl::Point vertices");
190 components_.push_back(std::move(
component));
209 template <std::ranges::input_range ComponentRange>
210 requires detail::is_polygon_with_holes_v<std::ranges::range_value_t<ComponentRange>>
231 template <Po
intConcept OtherPo
intType,
class OtherLabelType>
232 requires(std::constructible_from<PointType, const OtherPointType&>)
248 template <
class A = LabelType>
249 requires(detail::has_label_v<A>)
264 return components_.size();
272 assert(index < components_.size());
273 return components_[index];
277 [[nodiscard]]
constexpr const std::vector<ComponentType>&
components()
const {
282 [[nodiscard]]
constexpr auto begin()
const {
return components_.begin(); }
285 [[nodiscard]]
constexpr auto cbegin()
const {
return components_.cbegin(); }
288 [[nodiscard]]
constexpr auto end()
const {
return components_.end(); }
291 [[nodiscard]]
constexpr auto cend()
const {
return components_.cend(); }
307 const auto position = std::lower_bound(components_.begin(), components_.end(),
component);
308 if (position != components_.end() && *position ==
component) {
311 components_.insert(position, std::move(
component));
326 assert(index < components_.size());
327 components_.erase(components_.begin() +
static_cast<std::ptrdiff_t
>(index));
342 const auto position = std::lower_bound(components_.begin(), components_.end(),
component);
343 if (position == components_.end() || !(*position ==
component)) {
346 components_.erase(position);
353 std::size_t total = 0;
354 for (
const auto&
component : components_) {
362 for (
const auto&
component : components_) {
378 std::size_t total = 0;
379 for (
const auto&
component : components_) {
386 [[nodiscard]]
constexpr std::vector<PointType>
vertices()
const {
387 std::vector<PointType> result;
389 for (
const auto&
component : components_) {
411 return VertexIterator(
this, 0);
416 return VertexIterator(
this, components_.size());
420 [[nodiscard]]
constexpr std::vector<EdgeType>
edges()
const {
421 std::vector<EdgeType> result;
423 for (
const auto&
component : components_) {
425 result.push_back(
edge);
437 [[nodiscard]]
constexpr std::vector<OrientedSegment<PointType>>
orientedEdges()
const {
438 std::vector<OrientedSegment<PointType>> result;
440 for (
const auto&
component : components_) {
442 result.push_back(
edge);
453 if (
auto cmp = components_.size() <=> other.components_.size(); cmp != 0) {
456 for (std::size_t i = 0; i < components_.size(); ++i) {
457 if (
auto cmp = components_[i] <=> other.components_[i]; cmp != 0) {
461 return std::strong_ordering::equal;
466 if (components_.size() != other.components_.size()) {
469 for (std::size_t i = 0; i < components_.size(); ++i) {
470 if (!(components_[i] == other.components_[i])) {
478 template<AnyShapeConcept OtherShape>
479 [[nodiscard]]
constexpr bool samePointSet(
const OtherShape& other)
const;
485 [[nodiscard]]
constexpr bool empty()
const {
486 return components_.empty();
500 using Exact = detail::promoted_number_t<NumberType>;
510 [[nodiscard]]
constexpr bool isPoint()
const {
511 return components_.size() == 1 && components_[0].isPoint();
516 return components_.size() == 1 && components_[0].isSegment();
536 template <
class Rational = pgl::Rational<pgl::BigInt>>
538 for (
const auto&
component : components_) {
565 template <
class Rational = pgl::Rational<pgl::BigInt>>
584 for (
const auto&
component : components_) {
607 template <
class ResultNumber = division_result_t<NumberType>>
624 template <
class ResultNumber = NumberType>
625 [[nodiscard]]
constexpr ResultNumber
twiceArea()
const {
626 ResultNumber total{};
627 for (
const auto&
component : components_) {
637 template <
class ResultNumber = division_result_t<NumberType>>
638 [[nodiscard]]
constexpr auto area()
const {
639 ResultNumber result =
static_cast<ResultNumber
>(
twiceArea());
640 return result / ResultNumber(2);
654 template <
class ResultNumber = division_result_t<NumberType>>
658 template <
class ResultNumber = division_result_t<NumberType>>
673 template <
class ResultNumber = division_result_t<NumberType>>
686 std::vector<PointType> hullPoints;
688 for (
const auto&
component : components_) {
690 hullPoints.push_back(
vertex);
703 std::vector<PointType> hullPoints;
705 for (
const auto&
component : components_) {
707 hullPoints.push_back(
vertex);
739 template <
class ResultNumber = gr
id_number_t<
typename Po
intType_::NumberType>>
740 requires(detail::extended_integral<ResultNumber> || std::same_as<ResultNumber, BigInt>)
745 template <std::
floating_po
int ResultNumber =
double>
773 template <
class SegmentRange>
827 template <
class ResultNumber = gr
id_number_t<
typename Po
intType_::NumberType>>
828 requires(std::signed_integral<ResultNumber>)
856 template <
class ResultNumber = division_result_t<NumberType>, detail::SetBooleanOperandConcept OtherShape>
869 template <
class ResultNumber = division_result_t<NumberType>, HalfplaneIntersectionConcept OtherIntersection>
879 template <
class ResultNumber = division_result_t<NumberType>, HalfplaneConcept OtherHalfplane>
891 template <
class ResultNumber = division_result_t<NumberType>, detail::SetBooleanOperandConcept OtherShape>
903 template <
class ResultNumber = division_result_t<NumberType>, detail::SetBooleanOperandConcept OtherShape>
913 template <
class ResultNumber = division_result_t<NumberType>, detail::SetBooleanOperandConcept OtherShape>
926 template <
class ResultNumber = division_result_t<NumberType>, HalfplaneIntersectionConcept OtherIntersection>
931 template <
class ResultNumber = division_result_t<NumberType>, HalfplaneConcept OtherHalfplane>
951 template <
class ResultNumber = division_result_t<NumberType>, detail::SetBooleanOperandConcept OtherShape>
952 [[nodiscard]] std::vector<std::variant<Point<ResultNumber, typename PointType::LabelType>,
969 template <
class ResultNumber = division_result_t<NumberType>, HalfplaneIntersectionConcept OtherIntersection>
970 [[nodiscard]] std::vector<std::variant<Point<ResultNumber, typename PointType::LabelType>,
976 template <
class ResultNumber = division_result_t<NumberType>, HalfplaneConcept OtherHalfplane>
977 [[nodiscard]] std::vector<std::variant<Point<ResultNumber, typename PointType::LabelType>,
983 template <
class ResultNumber = NumberType,
class EmptyPo
int>
1021 template <detail::SetOperandConcept OtherShape>
1029 template <detail::SetOperandConcept OtherShape>
1043 template <detail::SetOperandConcept OtherShape>
1044 [[nodiscard]]
bool contains(
const OtherShape& other)
const;
1053 template <detail::SetOperandConcept OtherShape>
1063 template <SegmentConcept OtherSegment>
1073 template <detail::SetOperandConcept OtherShape>
1086 template <detail::SetOperandConcept OtherShape>
1087 [[nodiscard]]
bool separates(
const OtherShape& other)
const;
1090 template <detail::SetOperandConcept OtherShape>
1091 [[nodiscard]]
bool crosses(
const OtherShape& other)
const;
1099 template <PolygonSetConcept OtherSet>
1103 template <PolygonSetConcept OtherSet>
1107 template <PolygonSetConcept OtherSet>
1108 [[nodiscard]]
bool contains(
const OtherSet& other)
const;
1111 template <PolygonSetConcept OtherSet>
1115 template <PolygonSetConcept OtherSet>
1119 template <PolygonSetConcept OtherSet>
1123 template <PolygonSetConcept OtherSet>
1124 [[nodiscard]]
bool crosses(
const OtherSet& other)
const;
1131 template <
class EmptyPo
int>
1137 template <
class EmptyPo
int>
1143 template <
class EmptyPo
int>
1149 template <
class EmptyPo
int>
1155 template <
class EmptyPo
int>
1161 template <
class EmptyPo
int>
1167 template <
class EmptyPo
int>
1177 template <Po
intConcept OtherPo
int>
1181 template <Po
intConcept OtherPo
int>
1185 template <Po
intConcept OtherPo
int>
1189 template <Po
intConcept OtherPo
int>
1193 template <Po
intConcept OtherPo
int>
1197 template <Po
intConcept OtherPo
int>
1201 template <Po
intConcept OtherPo
int>
1225 template <
class ResultNumber = division_result_t<NumberType>, detail::SetOperandConcept OtherShape>
1229 template <
class ResultNumber = division_result_t<NumberType>, PolygonSetConcept OtherSet>
1244 template <
class ResultNumber = NumberType, BoundedPolygonalConcept OtherShape>
1245 requires detail::ClosestPairConcept<PolygonSet<PointType_, TLabel>, OtherShape>
1264 template <
class ResultNumber = division_result_t<NumberType>,
class OtherShape>
1265 requires detail::ClosestPointsPairConcept<PolygonSet<PointType_, TLabel>, OtherShape>
1275 template <
class ResultNumber = division_result_t<NumberType>, detail::SetOperandConcept OtherShape>
1276 requires detail::ComponentDistanceL1Concept<ResultNumber, PolygonWithHoles<PointType_>, OtherShape>
1280 template <
class ResultNumber = division_result_t<NumberType>, PolygonSetConcept OtherSet>
1284 template <
class ResultNumber = division_result_t<NumberType>, detail::SetOperandConcept OtherShape>
1285 requires detail::ComponentDistanceLInfConcept<ResultNumber, PolygonWithHoles<PointType_>, OtherShape>
1289 template <
class ResultNumber = division_result_t<NumberType>, PolygonSetConcept OtherSet>
1307 template <
class ResultNumber = division_result_t<NumberType>, Po
intConcept OtherPo
int>
1313 template <
class ResultNumber = division_result_t<NumberType>, Po
intConcept OtherPo
int>
1330 template <
class ResultNumber = division_result_t<NumberType>, Po
intConcept OtherPo
int>
1349 template <
class ResultNumber = division_result_t<NumberType>, Po
intConcept OtherPo
int>
1366 template <
class ResultNumber = division_result_t<NumberType>, Po
intConcept OtherPo
int>
1375 template <
class ResultNumber =
double, Po
intConcept OtherPo
int>
1384 template <
class ResultNumber =
double, Po
intConcept OtherPo
int>
1434 template <
class OtherShape>
1460 template <
class OtherShape>
1495 template <
class ResultNumber = division_result_t<NumberType>,
class OtherShape>
1531 template <
class ResultNumber = division_result_t<NumberType>,
1532 detail::SetMinkowskiOperandConcept OtherShape>
1540 template <
class TranslationNumber,
class TranslationLabel>
1550 template <
class TranslationNumber,
class TranslationLabel>
1552 return *
this += (-translation);
1562 template <
class Scalar>
1573 template <
class Scalar>
1590 auto saved = label_;
1592 label_ = std::move(saved);
1602 template <
class OtherNumber>
1604 return mappedComponents(
1609 template <
class OtherNumber>
1611 auto saved = label_;
1613 label_ = std::move(saved);
1617 template <
class OtherNumber>
1619 return mappedComponents(
1624 template <
class OtherNumber>
1626 auto saved = label_;
1628 label_ = std::move(saved);
1632 template <
class OtherNumber>
1634 return mappedComponents(
1639 template <
class OtherNumber>
1641 auto saved = label_;
1643 label_ = std::move(saved);
1647 template <
class OtherNumber>
1649 return mappedComponents(
1654 template <
class OtherNumber>
1656 auto saved = label_;
1658 label_ = std::move(saved);
1680 assert(set !=
nullptr);
1702 : set(set_arg), component(component_arg) {
1709 constexpr void enterComponent() {
1710 const std::size_t count = set ==
nullptr ? 0 : set->components_.size();
1712 :
typename ComponentType::VertexIterator{};
1718 constexpr void skipExhausted() {
1719 const std::size_t count = set ==
nullptr ? 0 : set->components_.size();
1720 while (component < count && inner == set->components_[component].
verticesEnd()) {
1727 std::size_t component = 0;
1728 typename ComponentType::VertexIterator inner{};
1738 template <
class ComponentRelation>
1739 constexpr bool anyComponent(ComponentRelation&& relation)
const {
1740 for (
const auto&
component : components_) {
1763 template <
class OtherSegment>
1764 bool segmentIn(
const OtherSegment& segment,
bool boundaryOnly)
const;
1770 template <
class OtherChain>
1771 bool chainIn(
const OtherChain& chain,
bool boundaryOnly)
const;
1806 template <
class OtherRegion>
1807 bool regionIn(
const OtherRegion& region)
const;
1818 template <
class ComponentDistance>
1819 auto minOverComponents(ComponentDistance&& distance)
const {
1820 using ResultNumber = std::decay_t<decltype(distance(std::declval<const ComponentType&>()))>;
1821 ResultNumber best{};
1822 bool seeded =
false;
1823 for (
const auto&
component : components_) {
1824 const ResultNumber current = distance(
component);
1825 if (!seeded || current < best) {
1841 template <
class ComponentTransform>
1842 constexpr PolygonSet mappedComponents(ComponentTransform&& transform)
const {
1844 result.components_.reserve(components_.size());
1845 for (
const auto&
component : components_) {
1846 result.components_.push_back(transform(
component));
1852 std::vector<ComponentType> components_{};
1853 [[no_unique_address]]
mutable LabelType label_{};
1858 mutable Rectangle<PointType> bbox_{};
1862 mutable signed char pinched_ = -1;
1868 static constexpr std::size_t hashUnset_ = pgl::detail::numeric_limits<std::size_t>::max();
1869 mutable std::size_t hash_ = hashUnset_;
1872 template <
class OtherPo
intType,
class OtherLabelType>
1875 constexpr void resetCache()
const {
1890 constexpr void normalize() {
1891 std::erase_if(components_,
1893 std::sort(components_.begin(), components_.end());
1894 components_.erase(std::unique(components_.begin(), components_.end()), components_.end());
1905template <
class Po
intType,
class LabelType,
class TranslationNumber,
class TranslationLabel>
1908 return set + (-translation);
1911template <
class Po
intType,
class LabelType,
class Scalar>
1912 requires(!detail::is_point_v<Scalar> && !TransformationConcept<Scalar>)
1917 if constexpr (detail::has_label_v<LabelType>) {
1918 result.
label() = LabelType{};
1923template <
class Scalar,
class Po
intType,
class LabelType>
1924 requires(!detail::is_point_v<Scalar> && !TransformationConcept<Scalar>)
1926 return set * scalar;
1929template <
class Po
intType,
class LabelType,
class Scalar>
1930 requires(!detail::is_point_v<Scalar> && !TransformationConcept<Scalar>)
1935 if constexpr (detail::has_label_v<LabelType>) {
1936 result.
label() = LabelType{};
1941template <
class Po
intType,
class LabelType>
friend struct PolygonSet
Definition polygonset.hpp:1699
constexpr VertexIterator()=default
PointType value_type
Definition polygonset.hpp:1673
value_type reference
Definition polygonset.hpp:1675
constexpr value_type operator*() const
Definition polygonset.hpp:1679
std::ptrdiff_t difference_type
Definition polygonset.hpp:1674
constexpr VertexIterator operator++(int)
Definition polygonset.hpp:1690
std::forward_iterator_tag iterator_category
Definition polygonset.hpp:1671
constexpr VertexIterator & operator++()
Definition polygonset.hpp:1684
constexpr bool operator==(const VertexIterator &other) const =default
std::forward_iterator_tag iterator_concept
Definition polygonset.hpp:1672
Bounded polygonal primitives, convex or not.
Definition forward.hpp:373
Shape pairs whose Minkowski sum Pangolin can represent.
Definition forward.hpp:476
Definition arrangement.hpp:67
@ edge
Definition bitmatrix.hpp:37
@ vertex
Definition bitmatrix.hpp:37
constexpr auto operator-(const Point< LeftNumber, LeftLabel > &left, const Point< RightNumber, RightLabel > &right)
Translates a point by the opposite of another point.
Definition transformations.hpp:130
PolygonSet() -> PolygonSet< Point<>, NoLabel >
Definition polygonset.hpp:1699
Shape(const std::variant< T, Ts... > &) -> Shape< detail::shape_point_type_t< T > >
std::ostream & operator<<(std::ostream &stream, const Point< Number, Label > &point)
Streams a point as (x,y) or label:(x,y).
Definition io.hpp:27
Closed convex polygon stored by its vertices.
Definition convex.hpp:170
constexpr Segment< PointType > diameter() const
Returns a segment realizing the diameter (the farthest vertex pair).
Definition measures.hpp:696
The empty set of points in the plane.
Definition emptyshape.hpp:33
Sentinel type used when a point carries no extra label.
Definition point.hpp:31
Two-dimensional point with optional label payload.
Definition point.hpp:129
Set of closed regions with pairwise disjoint interiors.
Definition polygonset.hpp:165
bool isSimple() const
Tests whether every ring of every component is simple.
Definition polygonset.hpp:537
std::vector< Convex< PointType > > convexCovering() const
Covers this set with a greedily selected set of convex polygons.
Definition triangulation.hpp:6967
constexpr Point< ResultNumber > centroid() const
Computes the area-weighted centroid of the set.
Definition measures.hpp:1184
friend struct PolygonSet
Definition polygonset.hpp:1873
bool contains(const Shape< OtherPoint > &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:3660
constexpr bool intersects(const EmptyShape< EmptyPoint > &) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition polygonset.hpp:1150
auto triangulation() const
Builds the constrained Delaunay triangulation of this set.
Definition triangulation.hpp:6951
constexpr auto cbegin() const
Returns a constant iterator to the first component.
Definition polygonset.hpp:285
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > regularizedIntersection(const OtherHalfplane &other) const
Returns the regularized intersection of the two shapes (A ∩ B).
constexpr EmptyShape< EmptyPoint > intersection(const EmptyShape< EmptyPoint > &) const
Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
Definition polygonset.hpp:984
constexpr std::vector< EdgeType > edges() const
Returns the boundary edges of every ring of every component.
Definition polygonset.hpp:420
constexpr ResultNumber twiceArea() const
Computes twice the area of the set.
Definition polygonset.hpp:625
constexpr Rectangle< Point< ResultNumber > > fbox() const
Computes the floating-point bounding box of the set.
Definition bounding.hpp:487
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > symmetricDifference(const OtherShape &other) const
Returns the regularized symmetric difference of the two shapes (A △ B).
constexpr bool operator==(const PolygonSet &other) const
Checks equality of two sets.
Definition polygonset.hpp:465
typename PointType::NumberType NumberType
Definition polygonset.hpp:167
constexpr bool eraseComponent(const ComponentType &component)
Erases the component equal to the given region, if the set has one.
Definition polygonset.hpp:341
bool contains(const OtherSet &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:3647
auto squaredDistance(const OtherShape &other) const
Computes the squared Euclidean distance to the other shape.
Definition distance.hpp:2025
constexpr PolygonSet(const PolygonSet< OtherPointType, OtherLabelType > &other)
Converts a set with compatible vertex type.
Definition polygonset.hpp:233
constexpr void addComponent(ComponentType component)
Adds a component, keeping the canonical order.
Definition polygonset.hpp:303
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > difference(const OtherHalfplane &other) const
Returns the regularized set difference of the two shapes (A ∖ B).
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > difference(const OtherShape &other) const
Returns the regularized set difference of the two shapes (A ∖ B).
auto regularizedIntersection(const Shape< OtherPoint > &other) const
Re-dispatches a regularized intersection through a runtime shape.
Definition polygonset.hpp:1314
constexpr bool interiorContains(const EmptyShape< EmptyPoint > &) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition polygonset.hpp:1138
constexpr Point< ResultNumber > verticesCentroid() const
Computes the centroid of the vertex set over every ring of every component.
Definition measures.hpp:1166
constexpr Segment< PointType > diameter() const
Returns a segment realizing the diameter (the farthest vertex pair).
Definition polygonset.hpp:685
constexpr PolygonSet()=default
Creates the empty set (no components).
constexpr PolygonSet scaledDownX(const OtherNumber scalar) const
Returns the set with its x-coordinates multiplied by scalar.
Definition polygonset.hpp:1633
bool boundaryContains(const Shape< OtherPoint > &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:2155
constexpr Convex< PointType > convexHull() const
Returns the convex hull of the set's vertices.
Definition polygonset.hpp:702
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > minkowskiSum(const OtherShape &other) const
Returns the regularized Minkowski sum of the two shapes (A ⊕ B), as a set of regions.
constexpr PolygonSet(ComponentType component)
Creates a set with a single component.
Definition polygonset.hpp:188
bool interiorsIntersect(const Shape< OtherPoint > &other) const
Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
Definition interiorsintersect.hpp:2782
bool intersects(const Shape< OtherPoint > &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:2251
Polygon< PointType > PolygonType
Definition polygonset.hpp:172
std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Polyline< Point< ResultNumber, typename PointType::LabelType > >, PolygonWithHoles< Point< ResultNumber, typename PointType::LabelType > > > > intersection(const OtherShape &other) const
Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
bool isConnected() const
Tests whether the set is connected as a point set.
Definition separates.hpp:5799
constexpr bool isSegment() const
Tests whether the set covers exactly one segment of positive length.
Definition polygonset.hpp:515
bool isRegular() const
Tests whether the set is the closure of its own interior (A = closure(A°)).
Definition polygonset.hpp:583
constexpr auto begin() const
Returns a constant iterator to the first component.
Definition polygonset.hpp:282
bool interiorsIntersect(const OtherShape &other) const
Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
Definition interiorsintersect.hpp:2764
Segment< PointType > EdgeType
Definition polygonset.hpp:173
constexpr bool crosses(const EmptyShape< EmptyPoint > &) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition polygonset.hpp:1168
constexpr auto minkowskiErosion(const OtherShape &other) const
Returns the Minkowski erosion of this shape by another (A ⊖ B).
Definition minkowskierosion.hpp:640
auto squaredDistance(const OtherSet &other) const
Computes the squared Euclidean distance to the other shape.
Definition distance.hpp:2033
constexpr auto minkowskiSum(const OtherShape &other) const
Returns the Minkowski sum of this shape and another (A ⊕ B).
Definition minkowski.hpp:807
constexpr bool hasHoles() const
Tests whether any component has a hole.
Definition polygonset.hpp:361
std::vector< Point< ResultNumber, typename PointType::LabelType > > latticePoints() const
Returns the integer points the set contains.
Definition lattice.hpp:703
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > regularizedUnion(const OtherShape &other) const
Returns the regularized union of the two shapes (A ∪ B).
auto closestSegments(const OtherShape &other) const
Returns the pair of elements realizing the distance, nothing when the shapes meet.
Definition closest.hpp:440
constexpr auto operator<=>(const PolygonSet &other) const
Compares two sets by component count, then lexicographically.
Definition polygonset.hpp:452
bool interiorContains(const OtherShape &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:2583
bool separates(const OtherSet &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:5892
auto difference(const Shape< OtherPoint > &other) const
Returns the regularized set difference of the two shapes (A ∖ B), re-dispatching through the wrapper'...
Definition polygonset.hpp:1350
constexpr void eraseComponent(std::size_t index)
Erases the component at the given index.
Definition polygonset.hpp:325
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > regularizedIntersection(const OtherShape &other) const
Returns the regularized intersection of the two shapes (A ∩ B).
constexpr PolygonSet(ComponentRange &&components, bool trusted=false)
Creates a set from a range of components.
Definition polygonset.hpp:211
constexpr std::size_t vertexCount() const
Returns the total number of vertices over every ring of every component.
Definition polygonset.hpp:377
constexpr auto distanceL1(const Shape< OtherPoint > &other) const
Returns the Manhattan (L1) distance to the given shape, using symmetry to re-dispatch through the wra...
Definition polygonset.hpp:1376
PolygonSet< Point< ResultNumber, typename PointType_::LabelType > > minkowskiErosion(const OtherShape &other) const
Returns the regularized Minkowski erosion of this shape by a bounded polygonal one (A ⊖ B),...
Definition minkowskierosion.hpp:724
constexpr bool empty() const
Tests whether the set has no components at all.
Definition polygonset.hpp:485
constexpr void scaleUpX(const OtherNumber scalar)
Scales the set's x-coordinates up in place.
Definition polygonset.hpp:1610
auto distanceLInf(const OtherShape &other) const
Computes the squared Euclidean distance to the other shape.
Definition distancelinf.hpp:1620
constexpr bool isPoint() const
Tests whether the set covers exactly one point.
Definition polygonset.hpp:510
bool crosses(const Shape< OtherPoint > &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:1302
auto regularizedUnion(const Shape< OtherPoint > &other) const
Returns the regularized union of the two shapes (A ∪ B), re-dispatching through the wrapper's own reg...
Definition polygonset.hpp:1331
constexpr bool isUndefined() const
Tests whether the set is degenerate without covering a point or a segment (which includes the empty s...
Definition polygonset.hpp:523
bool intersects(const OtherSet &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:2240
constexpr void rotate90(int k)
Rotates the set by 90k degrees around the origin in place.
Definition polygonset.hpp:1589
auto triangulation(const SegmentRange &segments) const
Builds the constrained Delaunay triangulation of this set with the given interior constraint segments...
Definition triangulation.hpp:6957
constexpr PolygonSet & operator-=(const Point< TranslationNumber, TranslationLabel > &translation)
Translates the set in place by the opposite vector.
Definition polygonset.hpp:1551
constexpr PolygonSet & operator+=(const Point< TranslationNumber, TranslationLabel > &translation)
Translates the set in place.
Definition polygonset.hpp:1541
constexpr void scaleDownY(const OtherNumber scalar)
Scales the set's y-coordinates down in place.
Definition polygonset.hpp:1655
bool interiorContainsInterior(const OtherSegment &other) const
Tests whether this shape's interior contains the segment's interior.
Definition interiorcontains.hpp:2591
PointType PointType
Definition polygonset.hpp:166
constexpr const std::vector< ComponentType > & components() const
Definition polygonset.hpp:277
constexpr A & label() const
Returns the set label.
Definition polygonset.hpp:250
std::vector< Convex< PointType > > convexPartition() const
Cuts this set into convex pieces with disjoint interiors.
Definition triangulation.hpp:6962
bool intersects(const OtherShape &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:2234
bool crosses(const OtherShape &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:1286
std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Polyline< Point< ResultNumber, typename PointType::LabelType > >, PolygonWithHoles< Point< ResultNumber, typename PointType::LabelType > > > > intersection(const OtherIntersection &other) const
Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > difference(const OtherIntersection &other) const
Returns the regularized set difference of the two shapes (A ∖ B).
auto closestPoints(const OtherShape &other) const
Returns the pair of points realizing the distance, nothing when the shapes meet.
Definition closest.hpp:447
constexpr const ComponentType & component(std::size_t index) const
Definition polygonset.hpp:271
constexpr bool samePointSet(const OtherShape &other) const
Tests whether another shape defines exactly the same point set.
Definition samepointset.hpp:2037
constexpr bool interiorsIntersect(const EmptyShape< EmptyPoint > &) const
Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
Definition polygonset.hpp:1156
constexpr PolygonSet scaledUpY(const OtherNumber scalar) const
Returns the set with its x-coordinates multiplied by scalar.
Definition polygonset.hpp:1618
constexpr VertexIterator verticesEnd() const
Returns an iterator past the last vertex of the last component.
Definition polygonset.hpp:415
bool crosses(const OtherSet &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:1296
bool interiorContains(const OtherSet &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:2599
constexpr bool boundaryContains(const EmptyShape< EmptyPoint > &) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition polygonset.hpp:1144
constexpr bool separates(const EmptyShape< EmptyPoint > &) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition polygonset.hpp:1162
constexpr void scaleDownX(const OtherNumber scalar)
Scales the set's x-coordinates down in place.
Definition polygonset.hpp:1640
bool contains(const OtherShape &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:3564
auto distanceLInf(const OtherSet &other) const
Computes the squared Euclidean distance to the other shape.
Definition distancelinf.hpp:1628
bool separates(const Shape< OtherPoint > &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:5898
constexpr bool isDegenerate() const
Tests whether the set has zero area.
Definition polygonset.hpp:499
constexpr bool contains(const EmptyShape< EmptyPoint > &) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition polygonset.hpp:1132
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > regularized() const
Returns the set without its slits (closure(A°)).
auto asBitMatrix() const
Rasterizes this set into a BitMatrix, one bit per covered cell.
Definition bitmatrix.hpp:2712
constexpr auto area() const
Computes the area of the set.
Definition polygonset.hpp:638
constexpr std::vector< PointType > vertices() const
Returns the vertices of every ring of every component.
Definition polygonset.hpp:386
constexpr void scaleUpY(const OtherNumber scalar)
Scales the set's y-coordinates up in place.
Definition polygonset.hpp:1625
constexpr auto cend() const
Returns a constant iterator past the last component.
Definition polygonset.hpp:291
bool interiorsIntersect(const OtherSet &other) const
Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
Definition interiorsintersect.hpp:2771
bool isPinched() const
Tests whether two components touch each other anywhere.
Definition contains.hpp:3368
constexpr std::size_t componentCount() const
Returns the number of components.
Definition polygonset.hpp:263
constexpr auto verticesView() const
Returns a lazy view over the vertices of every ring of every component, without allocating a vector.
Definition polygonset.hpp:405
bool interiorContains(const Shape< OtherPoint > &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:2610
constexpr std::size_t holeCount() const
Returns the total number of holes over all components.
Definition polygonset.hpp:352
bool isValid() const
Tests the structural contract: every component valid, component interiors pairwise disjoint,...
Definition intersections.hpp:1248
PolygonWithHoles< PointType > ComponentType
Definition polygonset.hpp:169
constexpr PolygonSet scaledUpX(const OtherNumber scalar) const
Returns the set with its x-coordinates multiplied by scalar.
Definition polygonset.hpp:1603
constexpr auto distanceLInf(const Shape< OtherPoint > &other) const
Returns the Chebyshev (L∞) distance to the given shape, using symmetry to re-dispatch through the wra...
Definition polygonset.hpp:1385
Point< ResultNumber > pointInside() const
Returns a point strictly inside the set.
Definition triangulation.hpp:6975
bool boundaryContains(const OtherSet &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:2144
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > regularizedIntersection(const OtherIntersection &other) const
Returns the regularized intersection of the two shapes (A ∩ B).
auto distanceL1(const OtherSet &other) const
Computes the squared Euclidean distance to the other shape.
Definition distancel1.hpp:1639
constexpr auto intersection(const Shape< OtherPoint > &other) const
Returns the intersection of the two shapes (A ∩ B), re-dispatching through the wrapper's own intersec...
Definition polygonset.hpp:1308
auto symmetricDifference(const Shape< OtherPoint > &other) const
Returns the regularized symmetric difference of the two shapes (A △ B), re-dispatching through the wr...
Definition polygonset.hpp:1367
constexpr auto end() const
Returns a constant iterator past the last component.
Definition polygonset.hpp:288
constexpr std::vector< OrientedSegment< PointType > > orientedEdges() const
Returns the boundary edges directed so the set lies to the left.
Definition polygonset.hpp:437
TLabel LabelType
Definition polygonset.hpp:168
constexpr PolygonSet scaledDownY(const OtherNumber scalar) const
Returns the set with its x-coordinates multiplied by scalar.
Definition polygonset.hpp:1648
std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Polyline< Point< ResultNumber, typename PointType::LabelType > >, PolygonWithHoles< Point< ResultNumber, typename PointType::LabelType > > > > intersection(const OtherHalfplane &other) const
Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
constexpr VertexIterator verticesBegin() const
Returns an iterator to the first vertex of the first component.
Definition polygonset.hpp:410
auto distanceL1(const OtherShape &other) const
Computes the squared Euclidean distance to the other shape.
Definition distancel1.hpp:1631
constexpr const Rectangle< PointType > & bbox() const
Computes the bounding box of the set.
Definition bounding.hpp:469
constexpr PolygonSet rotated90(int k) const
Returns the set rotated by 90k degrees around the origin.
Definition polygonset.hpp:1584
bool boundaryContains(const OtherShape &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:2104
bool separates(const OtherShape &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:5849
Closed region bounded by one outer simple polygon minus disjoint polygonal holes.
Definition polygonwithholes.hpp:89
constexpr bool isDegenerate() const
Tests whether the region has zero area.
Definition polygonwithholes.hpp:441
Closed simple polygon stored by its vertices.
Definition polygon.hpp:59
Open polygonal chain stored in traversal order; may self-intersect.
Definition polyline.hpp:69
Axis-aligned rectangle stored by minimum and maximum corners.
Definition rectangle.hpp:75
Unoriented closed segment between two endpoints plus optional segment label.
Definition segment.hpp:58
Runtime variant wrapper over the supported primitive shapes.
Definition shape.hpp:160