Pangolin
Header-only C++20 plane computational geometry library
Loading...
Searching...
No Matches
polygonwithholes.hpp
Go to the documentation of this file.
1#pragma once
2
4
5#include <algorithm>
6#include <cassert>
7#include <compare>
8#include <concepts>
9#include <cstddef>
10#include <iterator>
11#include <optional>
12#include <ostream>
13#include <ranges>
14#include <type_traits>
15#include <utility>
16#include <variant>
17#include <vector>
18
19
20namespace pgl {
21
22template <class PointType = Point<>, class Label>
23struct PolygonWithHoles;
24
26
27template <PolygonConcept OuterPolygon>
29
30template <PolygonConcept OuterPolygon>
32
33template <PolygonConcept OuterPolygon, std::ranges::input_range HoleRange>
34 requires detail::is_polygon_v<std::ranges::range_value_t<HoleRange>>
36
37template <PolygonConcept OuterPolygon, std::ranges::input_range HoleRange>
38 requires detail::is_polygon_v<std::ranges::range_value_t<HoleRange>>
40
41
88template <class PointType_, class TLabel>
90 using PointType = PointType_;
91 using NumberType = typename PointType::NumberType;
92 using LabelType = TLabel;
95 static_assert(detail::is_point_v<PointType>, "PolygonWithHoles requires pgl::Point vertices");
96
97 class VertexIterator;
98
102 constexpr PolygonWithHoles() = default;
103
110 : outer_(std::move(outer)) {}
111
127 template <std::ranges::input_range HoleRange>
128 requires detail::is_polygon_v<std::ranges::range_value_t<HoleRange>>
129 constexpr PolygonWithHoles(PolygonType outer, HoleRange&& holes, bool trusted = false)
130 : outer_(std::move(outer)) {
131 for (const auto& hole : holes) {
132 holes_.emplace_back(hole);
133 }
134 if (!trusted) {
135 normalize();
136 }
137 }
138
150 template <PointConcept OtherPointType, class OtherLabelType>
151 requires(std::constructible_from<PointType, const OtherPointType&>)
153 : outer_(other.outer()) {
154 holes_.reserve(other.holeCount());
155 for (const auto& hole : other.holes()) {
156 holes_.emplace_back(hole);
157 }
158 }
159
168 template <class A = LabelType>
169 requires(detail::has_label_v<A>)
170 constexpr A& label() const {
171 return label_;
172 }
173
174 // -------------------------------------------------------------------------
175 // Ring access
176
178 [[nodiscard]] constexpr const PolygonType& outer() const {
179 return outer_;
180 }
181
183 [[nodiscard]] constexpr std::size_t holeCount() const {
184 return holes_.size();
185 }
186
188 [[nodiscard]] constexpr bool hasHoles() const {
189 return !holes_.empty();
190 }
191
196 [[nodiscard]] constexpr const PolygonType& hole(std::size_t index) const {
197 assert(index < holes_.size());
198 return holes_[index];
199 }
200
202 [[nodiscard]] constexpr const std::vector<PolygonType>& holes() const {
203 return holes_;
204 }
205
207 [[nodiscard]] constexpr auto begin() const { return holes_.begin(); }
208
210 [[nodiscard]] constexpr auto cbegin() const { return holes_.cbegin(); }
211
213 [[nodiscard]] constexpr auto end() const { return holes_.end(); }
214
216 [[nodiscard]] constexpr auto cend() const { return holes_.cend(); }
217
227 constexpr void addHole(PolygonType hole) {
228 if (hole.isDegenerate()) {
229 return;
230 }
231 const auto position = std::lower_bound(holes_.begin(), holes_.end(), hole);
232 holes_.insert(position, std::move(hole));
233 resetCache();
234 }
235
246 constexpr void eraseHole(std::size_t index) {
247 assert(index < holes_.size());
248 holes_.erase(holes_.begin() + static_cast<std::ptrdiff_t>(index));
249 resetCache();
250 }
251
262 constexpr bool eraseHole(const PolygonType& hole) {
263 const auto position = std::lower_bound(holes_.begin(), holes_.end(), hole);
264 if (position == holes_.end() || !(*position == hole)) {
265 return false;
266 }
267 holes_.erase(position);
268 resetCache();
269 return true;
270 }
271
279 [[nodiscard]] constexpr std::size_t vertexCount() const {
280 std::size_t total = outer_.size();
281 for (const auto& hole : holes_) {
282 total += hole.size();
283 }
284 return total;
285 }
286
297 [[nodiscard]] constexpr std::size_t chainCount() const {
298 std::size_t total = outer_.chainCount();
299 for (const auto& hole : holes_) {
300 total += hole.chainCount();
301 }
302 return total;
303 }
304
306 [[nodiscard]] constexpr std::vector<PointType> vertices() const {
307 std::vector<PointType> result;
308 result.reserve(vertexCount());
309 for (const auto& vertex : outer_) {
310 result.push_back(vertex);
311 }
312 for (const auto& hole : holes_) {
313 for (const auto& vertex : hole) {
314 result.push_back(vertex);
315 }
316 }
317 return result;
318 }
319
328 [[nodiscard]] constexpr auto verticesView() const {
329 return std::ranges::subrange(verticesBegin(), verticesEnd());
330 }
331
333 [[nodiscard]] constexpr VertexIterator verticesBegin() const {
334 return VertexIterator(this, 0);
335 }
336
338 [[nodiscard]] constexpr VertexIterator verticesEnd() const {
339 return VertexIterator(this, 1 + holes_.size());
340 }
341
343 [[nodiscard]] constexpr std::vector<EdgeType> edges() const {
344 std::vector<EdgeType> result;
345 result.reserve(vertexCount());
346 for (const auto& edge : outer_.edgesView()) {
347 result.push_back(edge);
348 }
349 for (const auto& hole : holes_) {
350 for (const auto& edge : hole.edgesView()) {
351 result.push_back(edge);
352 }
353 }
354 return result;
355 }
356
364 [[nodiscard]] constexpr std::vector<OrientedSegment<PointType>> orientedEdges() const {
365 std::vector<OrientedSegment<PointType>> result;
366 result.reserve(vertexCount());
367 for (const auto& edge : outer_.orientedEdgesView()) {
368 result.push_back(edge);
369 }
370 for (const auto& hole : holes_) {
371 for (const auto& edge : hole.orientedEdgesView()) {
372 result.emplace_back(edge.target(), edge.source());
373 }
374 }
375 return result;
376 }
377
386 [[nodiscard]] constexpr PolygonSet<PointType> asPolygonSet() const {
387 return PolygonSet<PointType>(*this);
388 }
389
390 // -------------------------------------------------------------------------
391 // Value semantics
392
394 [[nodiscard]] constexpr auto operator<=>(const PolygonWithHoles& other) const {
395 if (auto cmp = outer_ <=> other.outer_; cmp != 0) {
396 return cmp;
397 }
398 if (auto cmp = holes_.size() <=> other.holes_.size(); cmp != 0) {
399 return cmp;
400 }
401 for (std::size_t i = 0; i < holes_.size(); ++i) {
402 if (auto cmp = holes_[i] <=> other.holes_[i]; cmp != 0) {
403 return cmp;
404 }
405 }
406 return std::strong_ordering::equal;
407 }
408
410 [[nodiscard]] constexpr bool operator==(const PolygonWithHoles& other) const {
411 if (!(outer_ == other.outer_) || holes_.size() != other.holes_.size()) {
412 return false;
413 }
414 for (std::size_t i = 0; i < holes_.size(); ++i) {
415 if (!(holes_[i] == other.holes_[i])) {
416 return false;
417 }
418 }
419 return true;
420 }
421
423 template<AnyShapeConcept OtherShape>
424 [[nodiscard]] constexpr bool samePointSet(const OtherShape& other) const;
425
426 // -------------------------------------------------------------------------
427 // State queries
428
430 [[nodiscard]] constexpr bool empty() const {
431 return outer_.size() == 0;
432 }
433
441 [[nodiscard]] constexpr bool isDegenerate() const {
442 using Exact = detail::promoted_number_t<NumberType>;
443 return twiceArea<Exact>() == Exact(0);
444 }
445
452 [[nodiscard]] constexpr bool isPoint() const {
453 return outer_.isPoint();
454 }
455
457 [[nodiscard]] constexpr bool isSegment() const {
458 return outer_.isSegment();
459 }
460
465 [[nodiscard]] constexpr bool isUndefined() const {
466 return !isPoint() && !isSegment() && isDegenerate();
467 }
468
477 template <class Rational = pgl::Rational<pgl::BigInt>>
478 [[nodiscard]] bool isSimple() const {
479 if (!outer_.template isSimple<Rational>()) {
480 return false;
481 }
482 for (const auto& hole : holes_) {
483 if (!hole.template isSimple<Rational>()) {
484 return false;
485 }
486 }
487 return true;
488 }
489
507 template <class Rational = pgl::Rational<pgl::BigInt>>
508 [[nodiscard]] bool isValid() const;
509
532 [[nodiscard]] bool isRegular() const;
533
558 template <class ResultNumber = division_result_t<NumberType>>
560 regularized() const;
561
562 // -------------------------------------------------------------------------
563 // Measures
564
576 template <class ResultNumber = NumberType>
577 [[nodiscard]] constexpr ResultNumber twiceArea() const {
578 ResultNumber total = outer_.template twiceArea<ResultNumber>();
579 for (const auto& hole : holes_) {
580 total -= hole.template twiceArea<ResultNumber>();
581 }
582 return total;
583 }
584
589 template <class ResultNumber = division_result_t<NumberType>>
590 [[nodiscard]] constexpr auto area() const {
591 ResultNumber result = static_cast<ResultNumber>(twiceArea());
592 return result / ResultNumber(2);
593 }
594
606 template <class ResultNumber = division_result_t<NumberType>>
607 [[nodiscard]] constexpr Point<ResultNumber> centroid() const;
608
610 template <class ResultNumber = division_result_t<NumberType>>
611 [[nodiscard]] constexpr Point<ResultNumber> verticesCentroid() const;
612
631 template <class ResultNumber = division_result_t<NumberType>>
632 [[nodiscard]] Point<ResultNumber> pointInside() const;
633
642 template <class OtherShape>
643 [[nodiscard]] bool pointInsideInteriorContainedIn(const OtherShape& shape) const;
644
655 auto triangulation() const;
656
666 template <class SegmentRange>
667 auto triangulation(const SegmentRange& segments) const;
668
688 [[nodiscard]] Graph<PointType> visibilityGraph() const;
689
703
723
739 [[nodiscard]] std::vector<PointType> visibleVertices(const PointType& query) const;
740
752 [[nodiscard]] std::vector<PointType> clearlyVisibleVertices(const PointType& query) const;
753
774 template <class ResultNumber = division_result_t<NumberType>>
776 const PointType& query) const;
777
795 [[nodiscard]] std::vector<Convex<PointType>> convexPartition() const;
796
808 [[nodiscard]] std::vector<Convex<PointType>> convexCovering() const;
809
831 template <class ResultNumber = grid_number_t<typename PointType_::NumberType>>
832 requires(std::signed_integral<ResultNumber>)
833 [[nodiscard]] auto asBitMatrix() const;
834
848 template <class ResultNumber = division_result_t<NumberType>, PolygonConcept OtherPolygon>
850 difference(const OtherPolygon& other) const;
851
853 template <class ResultNumber = division_result_t<NumberType>, ConvexConcept OtherConvex>
855 difference(const OtherConvex& other) const;
856
858 template <class ResultNumber = division_result_t<NumberType>, TriangleConcept OtherTriangle>
860 difference(const OtherTriangle& other) const;
861
863 template <class ResultNumber = division_result_t<NumberType>, RectangleConcept OtherRectangle>
865 difference(const OtherRectangle& other) const;
866
868 template <class ResultNumber = division_result_t<NumberType>, PolygonWithHolesConcept OtherRegion>
870 difference(const OtherRegion& other) const;
871
881 template <class ResultNumber = division_result_t<NumberType>, PolygonSetConcept OtherSet>
883 difference(const OtherSet& other) const;
884
907 template <class ResultNumber = division_result_t<NumberType>, HalfplaneIntersectionConcept OtherIntersection>
909 difference(const OtherIntersection& other) const;
910
920 template <class ResultNumber = division_result_t<NumberType>, HalfplaneConcept OtherHalfplane>
922 difference(const OtherHalfplane& other) const;
923
936 template <class ResultNumber = division_result_t<NumberType>, PolygonConcept OtherPolygon>
938 regularizedUnion(const OtherPolygon& other) const;
939
941 template <class ResultNumber = division_result_t<NumberType>, ConvexConcept OtherConvex>
943 regularizedUnion(const OtherConvex& other) const;
944
946 template <class ResultNumber = division_result_t<NumberType>, TriangleConcept OtherTriangle>
948 regularizedUnion(const OtherTriangle& other) const;
949
951 template <class ResultNumber = division_result_t<NumberType>, RectangleConcept OtherRectangle>
953 regularizedUnion(const OtherRectangle& other) const;
954
956 template <class ResultNumber = division_result_t<NumberType>, PolygonWithHolesConcept OtherRegion>
958 regularizedUnion(const OtherRegion& other) const;
959
970 template <class ResultNumber = division_result_t<NumberType>, PolygonSetConcept OtherSet>
971 [[nodiscard]] auto regularizedUnion(const OtherSet& other) const {
972 return other.template regularizedUnion<ResultNumber>(*this);
973 }
974
982 template <class ResultNumber = NumberType, PointConcept OtherPoint>
983 [[nodiscard]] constexpr std::optional<Point<ResultNumber, typename PointType::LabelType>>
984 intersection(const OtherPoint& other) const;
985
1009 template <class ResultNumber = division_result_t<NumberType>, SegmentConcept OtherSegment>
1010 [[nodiscard]] constexpr std::vector<std::variant<Point<ResultNumber, typename PointType::LabelType>,
1012 intersection(const OtherSegment& other) const;
1013
1021 template <class ResultNumber = division_result_t<NumberType>, OrientedSegmentConcept OtherOrientedSegment>
1022 [[nodiscard]] constexpr std::vector<std::variant<Point<ResultNumber, typename PointType::LabelType>,
1024 intersection(const OtherOrientedSegment& other) const;
1025
1039 template <class ResultNumber = division_result_t<NumberType>, LineConcept OtherLine>
1040 [[nodiscard]] constexpr std::vector<std::variant<Point<ResultNumber, typename PointType::LabelType>,
1042 intersection(const OtherLine& other) const;
1043
1051 template <class ResultNumber = division_result_t<NumberType>, OrientedLineConcept OtherOrientedLine>
1052 [[nodiscard]] constexpr std::vector<std::variant<Point<ResultNumber, typename PointType::LabelType>,
1054 intersection(const OtherOrientedLine& other) const;
1055
1068 template <class ResultNumber = division_result_t<NumberType>, RayConcept OtherRay>
1069 [[nodiscard]] constexpr std::vector<std::variant<Point<ResultNumber, typename PointType::LabelType>,
1071 intersection(const OtherRay& other) const;
1072
1090 template <class ResultNumber = division_result_t<NumberType>, PolylineConcept OtherPolyline>
1091 [[nodiscard]] constexpr auto intersection(const OtherPolyline& other) const;
1092
1106 template <class ResultNumber = division_result_t<NumberType>, MonotoneChainConcept OtherChain>
1107 [[nodiscard]] constexpr auto intersection(const OtherChain& other) const;
1108
1136 template <class ResultNumber = division_result_t<NumberType>, PolygonConcept OtherPolygon>
1137 [[nodiscard]] std::vector<std::variant<Point<ResultNumber, typename PointType::LabelType>,
1140 intersection(const OtherPolygon& other) const;
1141
1143 template <class ResultNumber = division_result_t<NumberType>, ConvexConcept OtherConvex>
1144 [[nodiscard]] std::vector<std::variant<Point<ResultNumber, typename PointType::LabelType>,
1147 intersection(const OtherConvex& other) const;
1148
1150 template <class ResultNumber = division_result_t<NumberType>, TriangleConcept OtherTriangle>
1151 [[nodiscard]] std::vector<std::variant<Point<ResultNumber, typename PointType::LabelType>,
1154 intersection(const OtherTriangle& other) const;
1155
1157 template <class ResultNumber = division_result_t<NumberType>, RectangleConcept OtherRectangle>
1158 [[nodiscard]] std::vector<std::variant<Point<ResultNumber, typename PointType::LabelType>,
1161 intersection(const OtherRectangle& other) const;
1162
1164 template <class ResultNumber = division_result_t<NumberType>, PolygonWithHolesConcept OtherRegion>
1165 [[nodiscard]] std::vector<std::variant<Point<ResultNumber, typename PointType::LabelType>,
1168 intersection(const OtherRegion& other) const;
1169
1184 template <class ResultNumber = division_result_t<NumberType>, HalfplaneIntersectionConcept OtherIntersection>
1185 [[nodiscard]] std::vector<std::variant<Point<ResultNumber, typename PointType::LabelType>,
1188 intersection(const OtherIntersection& other) const;
1189
1197 template <class ResultNumber = division_result_t<NumberType>, HalfplaneConcept OtherHalfplane>
1198 [[nodiscard]] std::vector<std::variant<Point<ResultNumber, typename PointType::LabelType>,
1201 intersection(const OtherHalfplane& other) const;
1202
1228 template <class ResultNumber = division_result_t<NumberType>, PolygonConcept OtherPolygon>
1230 regularizedIntersection(const OtherPolygon& other) const;
1231
1233 template <class ResultNumber = division_result_t<NumberType>, ConvexConcept OtherConvex>
1235 regularizedIntersection(const OtherConvex& other) const;
1236
1238 template <class ResultNumber = division_result_t<NumberType>, TriangleConcept OtherTriangle>
1240 regularizedIntersection(const OtherTriangle& other) const;
1241
1243 template <class ResultNumber = division_result_t<NumberType>, RectangleConcept OtherRectangle>
1245 regularizedIntersection(const OtherRectangle& other) const;
1246
1248 template <class ResultNumber = division_result_t<NumberType>, PolygonWithHolesConcept OtherRegion>
1250 regularizedIntersection(const OtherRegion& other) const;
1251
1267 template <class ResultNumber = division_result_t<NumberType>, HalfplaneIntersectionConcept OtherIntersection>
1269 regularizedIntersection(const OtherIntersection& other) const;
1270
1285 template <class ResultNumber = division_result_t<NumberType>, HalfplaneConcept OtherHalfplane>
1287 regularizedIntersection(const OtherHalfplane& other) const;
1288
1290 template <class ResultNumber = NumberType, class EmptyPoint>
1291 [[nodiscard]] constexpr EmptyShape<EmptyPoint> intersection(const EmptyShape<EmptyPoint>&) const {
1292 return {};
1293 }
1294
1307 template <class ResultNumber = division_result_t<NumberType>, PolygonConcept OtherPolygon>
1309 symmetricDifference(const OtherPolygon& other) const;
1310
1312 template <class ResultNumber = division_result_t<NumberType>, ConvexConcept OtherConvex>
1314 symmetricDifference(const OtherConvex& other) const;
1315
1317 template <class ResultNumber = division_result_t<NumberType>, TriangleConcept OtherTriangle>
1319 symmetricDifference(const OtherTriangle& other) const;
1320
1322 template <class ResultNumber = division_result_t<NumberType>, RectangleConcept OtherRectangle>
1324 symmetricDifference(const OtherRectangle& other) const;
1325
1327 template <class ResultNumber = division_result_t<NumberType>, PolygonWithHolesConcept OtherRegion>
1329 symmetricDifference(const OtherRegion& other) const;
1330
1341 template <class ResultNumber = division_result_t<NumberType>, PolygonSetConcept OtherSet>
1342 [[nodiscard]] auto symmetricDifference(const OtherSet& other) const {
1343 return other.template symmetricDifference<ResultNumber>(*this);
1344 }
1345
1373 template <class ResultNumber = division_result_t<NumberType>, PolygonConcept OtherPolygon>
1375 minkowskiSum(const OtherPolygon& other) const;
1376
1378 template <class ResultNumber = division_result_t<NumberType>, ConvexConcept OtherConvex>
1380 minkowskiSum(const OtherConvex& other) const;
1381
1383 template <class ResultNumber = division_result_t<NumberType>, TriangleConcept OtherTriangle>
1385 minkowskiSum(const OtherTriangle& other) const;
1386
1388 template <class ResultNumber = division_result_t<NumberType>, RectangleConcept OtherRectangle>
1390 minkowskiSum(const OtherRectangle& other) const;
1391
1393 template <class ResultNumber = division_result_t<NumberType>, PolygonWithHolesConcept OtherRegion>
1395 minkowskiSum(const OtherRegion& other) const;
1396
1405 template <class ResultNumber = division_result_t<NumberType>, PolylineConcept OtherPolyline>
1407 minkowskiSum(const OtherPolyline& other) const;
1408
1419 template <class ResultNumber = division_result_t<NumberType>, MonotoneChainConcept OtherChain>
1421 minkowskiSum(const OtherChain& other) const;
1422
1435 template <class ResultNumber = division_result_t<NumberType>, SegmentConcept OtherSegment>
1437 minkowskiSum(const OtherSegment& other) const;
1438
1445 template <class ResultNumber = division_result_t<NumberType>, OrientedSegmentConcept OtherSegment>
1447 minkowskiSum(const OtherSegment& other) const;
1448
1459 template <class ResultNumber = division_result_t<NumberType>, PolygonSetConcept OtherSet>
1461 minkowskiSum(const OtherSet& other) const;
1462
1477 template <class OtherShape>
1479 [[nodiscard]] constexpr auto minkowskiSum(const OtherShape& other) const;
1480
1504 template <class OtherShape>
1506 [[nodiscard]] constexpr auto minkowskiErosion(const OtherShape& other) const;
1507
1539 template <class ResultNumber = division_result_t<NumberType>, class OtherShape>
1543 minkowskiErosion(const OtherShape& other) const;
1544
1551 [[nodiscard]] constexpr Segment<PointType> diameter() const {
1552 return outer_.diameter();
1553 }
1554
1561 [[nodiscard]] constexpr Convex<PointType> convexHull() const {
1562 return outer_.convexHull();
1563 }
1564
1571 [[nodiscard]] constexpr const Rectangle<PointType>& bbox() const {
1572 return outer_.bbox();
1573 }
1574
1593 template <class ResultNumber = grid_number_t<typename PointType_::NumberType>>
1594 requires(detail::extended_integral<ResultNumber> || std::same_as<ResultNumber, BigInt>)
1597
1599 template <std::floating_point ResultNumber = double>
1600 [[nodiscard]] constexpr Rectangle<Point<ResultNumber>> fbox() const {
1601 return outer_.template fbox<ResultNumber>();
1602 }
1603
1604 // -------------------------------------------------------------------------
1605 // Predicates against a point
1606 //
1607 // Direct rewritings of A = outer \ ⋃ hole°:
1608 // contains(p) outer contains p, and no hole contains p strictly
1609 // interiorContains(p) outer contains p strictly, and no hole contains p
1610 // boundaryContains(p) p lies on the outer ring or on some hole ring
1611
1621 template <PointConcept OtherPoint>
1622 [[nodiscard]] constexpr bool contains(const OtherPoint& point) const;
1623
1629 template <PointConcept OtherPoint>
1630 [[nodiscard]] constexpr bool interiorContains(const OtherPoint& point) const;
1631
1640 template <PointConcept OtherPoint>
1641 [[nodiscard]] constexpr bool boundaryContains(const OtherPoint& point) const;
1642
1648 template <PointConcept OtherPoint>
1649 [[nodiscard]] constexpr bool intersects(const OtherPoint& point) const {
1650 return contains(point);
1651 }
1652
1659 template <PointConcept OtherPoint>
1660 [[nodiscard]] constexpr bool interiorsIntersect(const OtherPoint&) const {
1661 return false;
1662 }
1663
1664 // -------------------------------------------------------------------------
1665 // Predicates against a segment
1666 //
1667 // Rewritings of A = outer \ ⋃ hole°, using the fact that a segment is
1668 // connected and that every point of every ring boundary belongs to A:
1669 // contains(S) S ⊆ outer, and no hole interior meets S
1670 // interiorContains(S) S ⊆ outer°, and no hole meets S at all
1671 // intersects(S) S meets a ring boundary, or an endpoint decides
1672 // boundaryContains(S) S ⊆ A with no piece reaching the interior
1673
1682 template <SegmentConcept OtherSegment>
1683 [[nodiscard]] constexpr bool contains(const OtherSegment& other) const;
1684
1686 template <OrientedSegmentConcept OtherOrientedSegment>
1687 [[nodiscard]] constexpr bool contains(const OtherOrientedSegment& other) const;
1688
1696 template <SegmentConcept OtherSegment>
1697 [[nodiscard]] constexpr bool interiorContains(const OtherSegment& other) const;
1698
1708 template <SegmentConcept OtherSegment>
1709 [[nodiscard]] constexpr bool interiorContainsInterior(const OtherSegment& other) const;
1710
1712 template <OrientedSegmentConcept OtherOrientedSegment>
1713 [[nodiscard]] constexpr bool interiorContains(const OtherOrientedSegment& other) const;
1714
1722 template <SegmentConcept OtherSegment>
1723 [[nodiscard]] constexpr bool boundaryContains(const OtherSegment& other) const;
1724
1726 template <OrientedSegmentConcept OtherOrientedSegment>
1727 [[nodiscard]] constexpr bool boundaryContains(const OtherOrientedSegment& other) const;
1728
1734 template <SegmentConcept OtherSegment>
1735 [[nodiscard]] constexpr bool intersects(const OtherSegment& other) const;
1736
1738 template <OrientedSegmentConcept OtherOrientedSegment>
1739 [[nodiscard]] constexpr bool intersects(const OtherOrientedSegment& other) const;
1740
1751 template <SegmentConcept OtherSegment>
1752 [[nodiscard]] constexpr bool interiorsIntersect(const OtherSegment& other) const;
1753
1755 template <OrientedSegmentConcept OtherOrientedSegment>
1756 [[nodiscard]] constexpr bool interiorsIntersect(const OtherOrientedSegment& other) const;
1757
1758 // -------------------------------------------------------------------------
1759 // Predicates against a line, an oriented line, a ray, and a half-plane
1760 //
1761 // All four operands are unbounded, which decides two of the five relations
1762 // outright:
1763 // contains/interiorContains/boundaryContains only a degenerate operand
1764 // intersects(B) outer.intersects(B)
1765 //
1766 // The second line needs no hole bookkeeping: an unbounded connected shape
1767 // that reaches the bounded outer polygon has to leave it again, so it meets
1768 // ∂outer, and every point of ∂outer belongs to the region because hole
1769 // interiors never reach it.
1770
1777 template <LineConcept OtherLine>
1778 [[nodiscard]] constexpr bool contains(const OtherLine& other) const;
1779
1781 template <OrientedLineConcept OtherOrientedLine>
1782 [[nodiscard]] constexpr bool contains(const OtherOrientedLine& other) const;
1783
1785 template <RayConcept OtherRay>
1786 [[nodiscard]] constexpr bool contains(const OtherRay& other) const;
1787
1789 template <HalfplaneConcept OtherHalfplane>
1790 [[nodiscard]] constexpr bool contains(const OtherHalfplane& other) const;
1791
1797 template <LineConcept OtherLine>
1798 [[nodiscard]] constexpr bool interiorContains(const OtherLine& other) const;
1799
1801 template <OrientedLineConcept OtherOrientedLine>
1802 [[nodiscard]] constexpr bool interiorContains(const OtherOrientedLine& other) const;
1803
1805 template <RayConcept OtherRay>
1806 [[nodiscard]] constexpr bool interiorContains(const OtherRay& other) const;
1807
1809 template <HalfplaneConcept OtherHalfplane>
1810 [[nodiscard]] constexpr bool interiorContains(const OtherHalfplane& other) const;
1811
1817 template <LineConcept OtherLine>
1818 [[nodiscard]] constexpr bool boundaryContains(const OtherLine& other) const;
1819
1821 template <OrientedLineConcept OtherOrientedLine>
1822 [[nodiscard]] constexpr bool boundaryContains(const OtherOrientedLine& other) const;
1823
1825 template <RayConcept OtherRay>
1826 [[nodiscard]] constexpr bool boundaryContains(const OtherRay& other) const;
1827
1829 template <HalfplaneConcept OtherHalfplane>
1830 [[nodiscard]] constexpr bool boundaryContains(const OtherHalfplane& other) const;
1831
1837 template <LineConcept OtherLine>
1838 [[nodiscard]] constexpr bool intersects(const OtherLine& other) const;
1839
1841 template <OrientedLineConcept OtherOrientedLine>
1842 [[nodiscard]] constexpr bool intersects(const OtherOrientedLine& other) const;
1843
1845 template <RayConcept OtherRay>
1846 [[nodiscard]] constexpr bool intersects(const OtherRay& other) const;
1847
1849 template <HalfplaneConcept OtherHalfplane>
1850 [[nodiscard]] constexpr bool intersects(const OtherHalfplane& other) const;
1851
1862 template <LineConcept OtherLine>
1863 [[nodiscard]] constexpr bool interiorsIntersect(const OtherLine& other) const;
1864
1866 template <OrientedLineConcept OtherOrientedLine>
1867 [[nodiscard]] constexpr bool interiorsIntersect(const OtherOrientedLine& other) const;
1868
1870 template <RayConcept OtherRay>
1871 [[nodiscard]] constexpr bool interiorsIntersect(const OtherRay& other) const;
1872
1885 template <HalfplaneConcept OtherHalfplane>
1886 [[nodiscard]] constexpr bool interiorsIntersect(const OtherHalfplane& other) const;
1887
1888 // -------------------------------------------------------------------------
1889 // Predicates against a bounded shape with area: a rectangle, a triangle, a
1890 // convex polygon, a simple polygon, and another region with holes.
1891 //
1892 // All five are closed, connected, and — when they have any area — the
1893 // closure of their own interior, which is what lets the rewritings of
1894 // A = outer ∖ ⋃ hole° stay in terms of the operand itself:
1895 // contains(B) B ⊆ outer, and no hole interior meets B
1896 // interiorContains(B) B ⊆ outer°, and no hole meets B at all
1897 // boundaryContains(B) only a B without area, edge by edge
1898 // intersects(B) B meets a ring, or one point of B decides
1899 // interiorsIntersect(B) an edge of B reaches A°, or a domain triangle
1900 // of A meets B°
1901 //
1902 // The last one is the only one that cannot be read off the rings: A° is
1903 // neither simply connected nor even connected, so the witness arguments the
1904 // simply connected shapes use do not carry over. See @ref
1905 // areaInteriorsIntersect.
1906
1918 template <RectangleConcept OtherRectangle>
1919 [[nodiscard]] constexpr bool contains(const OtherRectangle& other) const;
1920
1922 template <TriangleConcept OtherTriangle>
1923 [[nodiscard]] constexpr bool contains(const OtherTriangle& other) const;
1924
1926 template <ConvexConcept OtherConvex>
1927 [[nodiscard]] constexpr bool contains(const OtherConvex& other) const;
1928
1930 template <PolygonConcept OtherPolygon>
1931 [[nodiscard]] constexpr bool contains(const OtherPolygon& other) const;
1932
1934 template <PolygonWithHolesConcept OtherRegion>
1935 [[nodiscard]] constexpr bool contains(const OtherRegion& other) const;
1936
1945 template <RectangleConcept OtherRectangle>
1946 [[nodiscard]] constexpr bool interiorContains(const OtherRectangle& other) const;
1947
1949 template <TriangleConcept OtherTriangle>
1950 [[nodiscard]] constexpr bool interiorContains(const OtherTriangle& other) const;
1951
1953 template <ConvexConcept OtherConvex>
1954 [[nodiscard]] constexpr bool interiorContains(const OtherConvex& other) const;
1955
1957 template <PolygonConcept OtherPolygon>
1958 [[nodiscard]] constexpr bool interiorContains(const OtherPolygon& other) const;
1959
1961 template <PolygonWithHolesConcept OtherRegion>
1962 [[nodiscard]] constexpr bool interiorContains(const OtherRegion& other) const;
1963
1971 template <RectangleConcept OtherRectangle>
1972 [[nodiscard]] constexpr bool boundaryContains(const OtherRectangle& other) const;
1973
1975 template <TriangleConcept OtherTriangle>
1976 [[nodiscard]] constexpr bool boundaryContains(const OtherTriangle& other) const;
1977
1979 template <ConvexConcept OtherConvex>
1980 [[nodiscard]] constexpr bool boundaryContains(const OtherConvex& other) const;
1981
1983 template <PolygonConcept OtherPolygon>
1984 [[nodiscard]] constexpr bool boundaryContains(const OtherPolygon& other) const;
1985
1987 template <PolygonWithHolesConcept OtherRegion>
1988 [[nodiscard]] constexpr bool boundaryContains(const OtherRegion& other) const;
1989
1995 template <RectangleConcept OtherRectangle>
1996 [[nodiscard]] constexpr bool intersects(const OtherRectangle& other) const;
1997
1999 template <TriangleConcept OtherTriangle>
2000 [[nodiscard]] constexpr bool intersects(const OtherTriangle& other) const;
2001
2003 template <ConvexConcept OtherConvex>
2004 [[nodiscard]] constexpr bool intersects(const OtherConvex& other) const;
2005
2007 template <PolygonConcept OtherPolygon>
2008 [[nodiscard]] constexpr bool intersects(const OtherPolygon& other) const;
2009
2011 template <PolygonWithHolesConcept OtherRegion>
2012 [[nodiscard]] constexpr bool intersects(const OtherRegion& other) const;
2013
2029 template <RectangleConcept OtherRectangle>
2030 [[nodiscard]] bool interiorsIntersect(const OtherRectangle& other) const;
2031
2033 template <TriangleConcept OtherTriangle>
2034 [[nodiscard]] bool interiorsIntersect(const OtherTriangle& other) const;
2035
2037 template <ConvexConcept OtherConvex>
2038 [[nodiscard]] bool interiorsIntersect(const OtherConvex& other) const;
2039
2041 template <PolygonConcept OtherPolygon>
2042 [[nodiscard]] bool interiorsIntersect(const OtherPolygon& other) const;
2043
2045 template <PolygonWithHolesConcept OtherRegion>
2046 [[nodiscard]] bool interiorsIntersect(const OtherRegion& other) const;
2047
2048 // -------------------------------------------------------------------------
2049 // Predicates against a polygonal chain: a monotone chain and a polyline.
2050 //
2051 // Both are one-dimensional and are exactly the union of their edges, so the
2052 // four set-level relations are settled edge by edge with no hole bookkeeping
2053 // of their own — the segment overloads already carry it. Only
2054 // interiorsIntersect needs the chain's own convention: its relative interior
2055 // is the chain minus its two extreme points, i.e. the open edges together
2056 // with the vertices between them.
2057
2066 template <MonotoneChainConcept OtherChain>
2067 [[nodiscard]] constexpr bool contains(const OtherChain& other) const;
2068
2070 template <PolylineConcept OtherPolyline>
2071 [[nodiscard]] constexpr bool contains(const OtherPolyline& other) const;
2072
2074 template <MonotoneChainConcept OtherChain>
2075 [[nodiscard]] constexpr bool interiorContains(const OtherChain& other) const;
2076
2078 template <PolylineConcept OtherPolyline>
2079 [[nodiscard]] constexpr bool interiorContains(const OtherPolyline& other) const;
2080
2082 template <MonotoneChainConcept OtherChain>
2083 [[nodiscard]] constexpr bool boundaryContains(const OtherChain& other) const;
2084
2086 template <PolylineConcept OtherPolyline>
2087 [[nodiscard]] constexpr bool boundaryContains(const OtherPolyline& other) const;
2088
2090 template <MonotoneChainConcept OtherChain>
2091 [[nodiscard]] constexpr bool intersects(const OtherChain& other) const;
2092
2094 template <PolylineConcept OtherPolyline>
2095 [[nodiscard]] constexpr bool intersects(const OtherPolyline& other) const;
2096
2107 template <MonotoneChainConcept OtherChain>
2108 [[nodiscard]] constexpr bool interiorsIntersect(const OtherChain& other) const;
2109
2111 template <PolylineConcept OtherPolyline>
2112 [[nodiscard]] constexpr bool interiorsIntersect(const OtherPolyline& other) const;
2113
2114 // -------------------------------------------------------------------------
2115 // Predicates against a disk
2116 //
2117 // A disk is closed, bounded, connected, and — unless it has degenerated —
2118 // the closure of its own interior. That last property is what the area
2119 // operands of §3 could not assume, and having it back brings the direct
2120 // per-hole rewriting of A = outer ∖ ⋃ hole° with it:
2121 // contains(D) outer contains D, and no hole interior meets D
2122 // interiorContains(D) outer° contains D, and no hole meets D at all
2123 // The disk has no edges, though, so interiorsIntersect has no boundary scan
2124 // to fall back on and goes to the triangulated domain directly.
2125
2140 template <DiskConcept OtherDisk>
2141 [[nodiscard]] constexpr bool contains(const OtherDisk& other) const;
2142
2144 template <DiskConcept OtherDisk>
2145 [[nodiscard]] constexpr bool interiorContains(const OtherDisk& other) const;
2146
2148 template <DiskConcept OtherDisk>
2149 [[nodiscard]] constexpr bool boundaryContains(const OtherDisk& other) const;
2150
2152 template <DiskConcept OtherDisk>
2153 [[nodiscard]] constexpr bool intersects(const OtherDisk& other) const;
2154
2164 template <DiskConcept OtherDisk>
2165 [[nodiscard]] bool interiorsIntersect(const OtherDisk& other) const;
2166
2167 // -------------------------------------------------------------------------
2168 // Predicates against a half-plane intersection
2169 //
2170 // The operand is convex and closed but need not be bounded, which splits the
2171 // work in two. The three containment relations want a bounded operand — the
2172 // region is bounded — and a bounded, non-degenerate half-plane intersection
2173 // is a convex polygon, so they hand it to the area path as one. A degenerate
2174 // one is a point, a segment, a ray, or a line, and goes to the overload for
2175 // that carrier. intersects and interiorsIntersect keep the unbounded case:
2176 // the first by the ring-contact argument the other operands use, the second
2177 // by clipping the operand to the region's bounding box first, which changes
2178 // no answer because the region interior lies strictly inside that box.
2179
2186 template <HalfplaneIntersectionConcept OtherIntersection>
2187 [[nodiscard]] constexpr bool contains(const OtherIntersection& other) const;
2188
2190 template <HalfplaneIntersectionConcept OtherIntersection>
2191 [[nodiscard]] constexpr bool interiorContains(const OtherIntersection& other) const;
2192
2194 template <HalfplaneIntersectionConcept OtherIntersection>
2195 [[nodiscard]] constexpr bool boundaryContains(const OtherIntersection& other) const;
2196
2198 template <HalfplaneIntersectionConcept OtherIntersection>
2199 [[nodiscard]] constexpr bool intersects(const OtherIntersection& other) const;
2200
2209 template <HalfplaneIntersectionConcept OtherIntersection>
2210 [[nodiscard]] bool interiorsIntersect(const OtherIntersection& other) const;
2211
2212 // -------------------------------------------------------------------------
2213 // Cut predicates
2214 //
2215 // `A.separates(B)` asks whether `B ∖ A` is disconnected, and
2216 // `A.crosses(B)` whether each shape separates the other. Both are collected
2217 // here rather than split per operand family because a region settles every
2218 // one of them the same way — the cell engine of implementation/
2219 // separates.hpp, which assumes nothing about either operand — while a
2220 // region without holes forwards to its outer polygon throughout.
2221 //
2222 // A region is connected however its rings meet — its complement is a
2223 // disjoint union of simply connected open sets, which encloses nothing —
2224 // so `B ∖ A` comes apart only when the removal genuinely severs it. What
2225 // does change against the simply connected operands is what suffices to
2226 // sever: a region is cut by a single point at a pinch, or by a segment run
2227 // from one hole to another, neither of which can cut a polygon.
2228
2230 template <PointConcept OtherPoint>
2231 [[nodiscard]] bool separates(const OtherPoint& other) const;
2232
2234 template <SegmentConcept OtherSegment>
2235 [[nodiscard]] bool separates(const OtherSegment& other) const;
2236
2238 template <OrientedSegmentConcept OtherOrientedSegment>
2239 [[nodiscard]] bool separates(const OtherOrientedSegment& other) const;
2240
2242 template <LineConcept OtherLine>
2243 [[nodiscard]] bool separates(const OtherLine& other) const;
2244
2246 template <OrientedLineConcept OtherOrientedLine>
2247 [[nodiscard]] bool separates(const OtherOrientedLine& other) const;
2248
2250 template <RayConcept OtherRay>
2251 [[nodiscard]] bool separates(const OtherRay& other) const;
2252
2254 template <HalfplaneConcept OtherHalfplane>
2255 [[nodiscard]] bool separates(const OtherHalfplane& other) const;
2256
2258 template <RectangleConcept OtherRectangle>
2259 [[nodiscard]] bool separates(const OtherRectangle& other) const;
2260
2262 template <TriangleConcept OtherTriangle>
2263 [[nodiscard]] bool separates(const OtherTriangle& other) const;
2264
2266 template <ConvexConcept OtherConvex>
2267 [[nodiscard]] bool separates(const OtherConvex& other) const;
2268
2270 template <PolygonConcept OtherPolygon>
2271 [[nodiscard]] bool separates(const OtherPolygon& other) const;
2272
2274 template <PolygonWithHolesConcept OtherRegion>
2275 [[nodiscard]] bool separates(const OtherRegion& other) const;
2276
2278 template <MonotoneChainConcept OtherChain>
2279 [[nodiscard]] bool separates(const OtherChain& other) const;
2280
2282 template <PolylineConcept OtherPolyline>
2283 [[nodiscard]] bool separates(const OtherPolyline& other) const;
2284
2293 template <DiskConcept OtherDisk>
2294 [[nodiscard]] bool separates(const OtherDisk& other) const;
2295
2297 template <HalfplaneIntersectionConcept OtherIntersection>
2298 [[nodiscard]] bool separates(const OtherIntersection& other) const;
2299
2301 template <PointConcept OtherPoint>
2302 [[nodiscard]] bool crosses(const OtherPoint& other) const;
2303
2305 template <SegmentConcept OtherSegment>
2306 [[nodiscard]] bool crosses(const OtherSegment& other) const;
2307
2309 template <OrientedSegmentConcept OtherOrientedSegment>
2310 [[nodiscard]] bool crosses(const OtherOrientedSegment& other) const;
2311
2313 template <LineConcept OtherLine>
2314 [[nodiscard]] bool crosses(const OtherLine& other) const;
2315
2317 template <OrientedLineConcept OtherOrientedLine>
2318 [[nodiscard]] bool crosses(const OtherOrientedLine& other) const;
2319
2321 template <RayConcept OtherRay>
2322 [[nodiscard]] bool crosses(const OtherRay& other) const;
2323
2325 template <HalfplaneConcept OtherHalfplane>
2326 [[nodiscard]] bool crosses(const OtherHalfplane& other) const;
2327
2329 template <RectangleConcept OtherRectangle>
2330 [[nodiscard]] bool crosses(const OtherRectangle& other) const;
2331
2333 template <TriangleConcept OtherTriangle>
2334 [[nodiscard]] bool crosses(const OtherTriangle& other) const;
2335
2337 template <ConvexConcept OtherConvex>
2338 [[nodiscard]] bool crosses(const OtherConvex& other) const;
2339
2341 template <PolygonConcept OtherPolygon>
2342 [[nodiscard]] bool crosses(const OtherPolygon& other) const;
2343
2345 template <PolygonWithHolesConcept OtherRegion>
2346 [[nodiscard]] bool crosses(const OtherRegion& other) const;
2347
2349 template <MonotoneChainConcept OtherChain>
2350 [[nodiscard]] bool crosses(const OtherChain& other) const;
2351
2353 template <PolylineConcept OtherPolyline>
2354 [[nodiscard]] bool crosses(const OtherPolyline& other) const;
2355
2357 template <DiskConcept OtherDisk>
2358 [[nodiscard]] bool crosses(const OtherDisk& other) const;
2359
2361 template <HalfplaneIntersectionConcept OtherIntersection>
2362 [[nodiscard]] bool crosses(const OtherIntersection& other) const;
2363
2364 // -------------------------------------------------------------------------
2365 // Distances
2366 //
2367 // The region is closed, so whenever it misses the other shape the nearest
2368 // pair is realized on ∂A — the minimum over the edges of every ring.
2369
2386 template <class ResultNumber = division_result_t<NumberType>, PointConcept OtherPoint>
2387 [[nodiscard]] constexpr auto squaredDistance(const OtherPoint& point) const;
2388
2390 template <class ResultNumber = division_result_t<NumberType>, SegmentConcept OtherSegment>
2391 [[nodiscard]] constexpr auto squaredDistance(const OtherSegment& other) const;
2392
2394 template <class ResultNumber = division_result_t<NumberType>, OrientedSegmentConcept OtherOrientedSegment>
2395 [[nodiscard]] constexpr auto squaredDistance(const OtherOrientedSegment& other) const;
2396
2398 template <class ResultNumber = division_result_t<NumberType>, LineConcept OtherLine>
2399 [[nodiscard]] constexpr auto squaredDistance(const OtherLine& other) const;
2400
2402 template <class ResultNumber = division_result_t<NumberType>, OrientedLineConcept OtherOrientedLine>
2403 [[nodiscard]] constexpr auto squaredDistance(const OtherOrientedLine& other) const;
2404
2406 template <class ResultNumber = division_result_t<NumberType>, RayConcept OtherRay>
2407 [[nodiscard]] constexpr auto squaredDistance(const OtherRay& other) const;
2408
2410 template <class ResultNumber = division_result_t<NumberType>, HalfplaneConcept OtherHalfplane>
2411 [[nodiscard]] constexpr auto squaredDistance(const OtherHalfplane& other) const;
2412
2414 template <class ResultNumber = division_result_t<NumberType>, RectangleConcept OtherRectangle>
2415 [[nodiscard]] constexpr auto squaredDistance(const OtherRectangle& other) const;
2416
2418 template <class ResultNumber = division_result_t<NumberType>, TriangleConcept OtherTriangle>
2419 [[nodiscard]] constexpr auto squaredDistance(const OtherTriangle& other) const;
2420
2422 template <class ResultNumber = division_result_t<NumberType>, ConvexConcept OtherConvex>
2423 [[nodiscard]] constexpr auto squaredDistance(const OtherConvex& other) const;
2424
2426 template <class ResultNumber = division_result_t<NumberType>, PolygonConcept OtherPolygon>
2427 [[nodiscard]] constexpr auto squaredDistance(const OtherPolygon& other) const;
2428
2430 template <class ResultNumber = division_result_t<NumberType>, PolygonWithHolesConcept OtherRegion>
2431 [[nodiscard]] constexpr auto squaredDistance(const OtherRegion& other) const;
2432
2434 template <class ResultNumber = division_result_t<NumberType>, MonotoneChainConcept OtherChain>
2435 [[nodiscard]] constexpr auto squaredDistance(const OtherChain& other) const;
2436
2438 template <class ResultNumber = division_result_t<NumberType>, PolylineConcept OtherPolyline>
2439 [[nodiscard]] constexpr auto squaredDistance(const OtherPolyline& other) const;
2440
2442 template <class ResultNumber = division_result_t<NumberType>, HalfplaneIntersectionConcept OtherIntersection>
2443 [[nodiscard]] constexpr auto squaredDistance(const OtherIntersection& other) const;
2444
2452 template <class ResultNumber = double, DiskConcept OtherDisk>
2453 [[nodiscard]] detail::floating_result_t<ResultNumber> squaredDistance(const OtherDisk& other) const;
2454
2467 template <class ResultNumber = NumberType, BoundedPolygonalConcept OtherShape>
2468 requires detail::ClosestPairConcept<PolygonWithHoles<PointType_, TLabel>, OtherShape>
2469 [[nodiscard]] constexpr auto closestSegments(const OtherShape& other) const;
2470
2487 template <class ResultNumber = division_result_t<NumberType>, class OtherShape>
2488 requires detail::ClosestPointsPairConcept<PolygonWithHoles<PointType_, TLabel>, OtherShape>
2489 [[nodiscard]] constexpr auto closestPoints(const OtherShape& other) const;
2490
2492 template <class ResultNumber = division_result_t<NumberType>, PointConcept OtherPoint>
2493 [[nodiscard]] constexpr auto distanceL1(const OtherPoint& point) const;
2494
2496 template <class ResultNumber = division_result_t<NumberType>, SegmentConcept OtherSegment>
2497 [[nodiscard]] constexpr auto distanceL1(const OtherSegment& other) const;
2498
2500 template <class ResultNumber = division_result_t<NumberType>, OrientedSegmentConcept OtherOrientedSegment>
2501 [[nodiscard]] constexpr auto distanceL1(const OtherOrientedSegment& other) const;
2502
2504 template <class ResultNumber = division_result_t<NumberType>, LineConcept OtherLine>
2505 [[nodiscard]] constexpr auto distanceL1(const OtherLine& other) const;
2506
2508 template <class ResultNumber = division_result_t<NumberType>, OrientedLineConcept OtherOrientedLine>
2509 [[nodiscard]] constexpr auto distanceL1(const OtherOrientedLine& other) const;
2510
2512 template <class ResultNumber = division_result_t<NumberType>, RayConcept OtherRay>
2513 [[nodiscard]] constexpr auto distanceL1(const OtherRay& other) const;
2514
2516 template <class ResultNumber = division_result_t<NumberType>, HalfplaneConcept OtherHalfplane>
2517 [[nodiscard]] constexpr auto distanceL1(const OtherHalfplane& other) const;
2518
2520 template <class ResultNumber = division_result_t<NumberType>, RectangleConcept OtherRectangle>
2521 [[nodiscard]] constexpr auto distanceL1(const OtherRectangle& other) const;
2522
2524 template <class ResultNumber = division_result_t<NumberType>, TriangleConcept OtherTriangle>
2525 [[nodiscard]] constexpr auto distanceL1(const OtherTriangle& other) const;
2526
2528 template <class ResultNumber = division_result_t<NumberType>, ConvexConcept OtherConvex>
2529 [[nodiscard]] constexpr auto distanceL1(const OtherConvex& other) const;
2530
2532 template <class ResultNumber = division_result_t<NumberType>, PolygonConcept OtherPolygon>
2533 [[nodiscard]] constexpr auto distanceL1(const OtherPolygon& other) const;
2534
2536 template <class ResultNumber = division_result_t<NumberType>, PolygonWithHolesConcept OtherRegion>
2537 [[nodiscard]] constexpr auto distanceL1(const OtherRegion& other) const;
2538
2540 template <class ResultNumber = division_result_t<NumberType>, MonotoneChainConcept OtherChain>
2541 [[nodiscard]] constexpr auto distanceL1(const OtherChain& other) const;
2542
2544 template <class ResultNumber = division_result_t<NumberType>, PolylineConcept OtherPolyline>
2545 [[nodiscard]] constexpr auto distanceL1(const OtherPolyline& other) const;
2546
2548 template <class ResultNumber = division_result_t<NumberType>, HalfplaneIntersectionConcept OtherIntersection>
2549 [[nodiscard]] constexpr auto distanceL1(const OtherIntersection& other) const;
2550
2552 template <class ResultNumber = division_result_t<NumberType>, PointConcept OtherPoint>
2553 [[nodiscard]] constexpr auto distanceLInf(const OtherPoint& point) const;
2554
2556 template <class ResultNumber = division_result_t<NumberType>, SegmentConcept OtherSegment>
2557 [[nodiscard]] constexpr auto distanceLInf(const OtherSegment& other) const;
2558
2560 template <class ResultNumber = division_result_t<NumberType>, OrientedSegmentConcept OtherOrientedSegment>
2561 [[nodiscard]] constexpr auto distanceLInf(const OtherOrientedSegment& other) const;
2562
2564 template <class ResultNumber = division_result_t<NumberType>, LineConcept OtherLine>
2565 [[nodiscard]] constexpr auto distanceLInf(const OtherLine& other) const;
2566
2568 template <class ResultNumber = division_result_t<NumberType>, OrientedLineConcept OtherOrientedLine>
2569 [[nodiscard]] constexpr auto distanceLInf(const OtherOrientedLine& other) const;
2570
2572 template <class ResultNumber = division_result_t<NumberType>, RayConcept OtherRay>
2573 [[nodiscard]] constexpr auto distanceLInf(const OtherRay& other) const;
2574
2576 template <class ResultNumber = division_result_t<NumberType>, HalfplaneConcept OtherHalfplane>
2577 [[nodiscard]] constexpr auto distanceLInf(const OtherHalfplane& other) const;
2578
2580 template <class ResultNumber = division_result_t<NumberType>, RectangleConcept OtherRectangle>
2581 [[nodiscard]] constexpr auto distanceLInf(const OtherRectangle& other) const;
2582
2584 template <class ResultNumber = division_result_t<NumberType>, TriangleConcept OtherTriangle>
2585 [[nodiscard]] constexpr auto distanceLInf(const OtherTriangle& other) const;
2586
2588 template <class ResultNumber = division_result_t<NumberType>, ConvexConcept OtherConvex>
2589 [[nodiscard]] constexpr auto distanceLInf(const OtherConvex& other) const;
2590
2592 template <class ResultNumber = division_result_t<NumberType>, PolygonConcept OtherPolygon>
2593 [[nodiscard]] constexpr auto distanceLInf(const OtherPolygon& other) const;
2594
2596 template <class ResultNumber = division_result_t<NumberType>, PolygonWithHolesConcept OtherRegion>
2597 [[nodiscard]] constexpr auto distanceLInf(const OtherRegion& other) const;
2598
2600 template <class ResultNumber = division_result_t<NumberType>, MonotoneChainConcept OtherChain>
2601 [[nodiscard]] constexpr auto distanceLInf(const OtherChain& other) const;
2602
2604 template <class ResultNumber = division_result_t<NumberType>, PolylineConcept OtherPolyline>
2605 [[nodiscard]] constexpr auto distanceLInf(const OtherPolyline& other) const;
2606
2608 template <class ResultNumber = division_result_t<NumberType>, HalfplaneIntersectionConcept OtherIntersection>
2609 [[nodiscard]] constexpr auto distanceLInf(const OtherIntersection& other) const;
2610
2611 // -------------------------------------------------------------------------
2612 // A set of regions
2613 //
2614 // The first shape to outrank a region, and so the first operand a region
2615 // forwards the symmetric relations to rather than answering itself. The
2616 // asymmetric ones are answered here: a set is the union of its components,
2617 // so a region holds it exactly when it holds every one of them.
2618
2620 template <PolygonSetConcept OtherSet>
2621 [[nodiscard]] constexpr bool contains(const OtherSet& other) const {
2622 for (const auto& component : other) {
2623 if (!contains(component)) {
2624 return false;
2625 }
2626 }
2627 return true;
2628 }
2629
2631 template <PolygonSetConcept OtherSet>
2632 [[nodiscard]] constexpr bool boundaryContains(const OtherSet& other) const {
2633 for (const auto& component : other) {
2634 if (!boundaryContains(component)) {
2635 return false;
2636 }
2637 }
2638 return true;
2639 }
2640
2642 template <PolygonSetConcept OtherSet>
2643 [[nodiscard]] constexpr bool interiorContains(const OtherSet& other) const {
2644 for (const auto& component : other) {
2645 if (!interiorContains(component)) {
2646 return false;
2647 }
2648 }
2649 return true;
2650 }
2651
2660 template <PolygonSetConcept OtherSet>
2661 [[nodiscard]] bool separates(const OtherSet& other) const;
2662
2669 template <class OtherShape>
2670 requires(!PointConcept<OtherShape> &&
2671 detail::shapeRank<OtherShape> > detail::shapeRank<PolygonWithHoles>)
2672 [[nodiscard]] constexpr bool intersects(const OtherShape& other) const {
2673 return other.intersects(*this);
2674 }
2675
2682 template <class OtherShape>
2683 requires(!PointConcept<OtherShape> &&
2684 detail::shapeRank<OtherShape> > detail::shapeRank<PolygonWithHoles>)
2685 [[nodiscard]] constexpr bool interiorsIntersect(const OtherShape& other) const {
2686 return other.interiorsIntersect(*this);
2687 }
2688
2690 template <class OtherShape>
2691 requires(!PointConcept<OtherShape> &&
2692 detail::shapeRank<OtherShape> > detail::shapeRank<PolygonWithHoles>)
2693 [[nodiscard]] constexpr bool crosses(const OtherShape& other) const {
2694 return other.crosses(*this);
2695 }
2696
2698 template <class ResultNumber = division_result_t<NumberType>, class OtherShape>
2699 requires(!PointConcept<OtherShape> &&
2700 (detail::shapeRank<OtherShape> > detail::shapeRank<PolygonWithHoles>) &&
2701 requires(const OtherShape& o, const PolygonWithHoles& self) {
2702 o.template intersection<ResultNumber>(self);
2703 })
2704 [[nodiscard]] auto intersection(const OtherShape& other) const {
2705 return other.template intersection<ResultNumber>(*this);
2706 }
2707
2709 template <class ResultNumber = division_result_t<NumberType>, class OtherShape>
2710 requires(!PointConcept<OtherShape> &&
2711 (detail::shapeRank<OtherShape> > detail::shapeRank<PolygonWithHoles>) &&
2712 requires(const OtherShape& o, const PolygonWithHoles& self) {
2714 })
2715 [[nodiscard]] constexpr auto regularizedIntersection(const OtherShape& other) const {
2716 return other.template regularizedIntersection<ResultNumber>(*this);
2717 }
2718
2720 template <class ResultNumber = division_result_t<NumberType>, class OtherShape>
2721 requires((detail::shapeRank<OtherShape> > detail::shapeRank<PolygonWithHoles>) &&
2722 requires(const OtherShape& o, const PolygonWithHoles& self) {
2723 o.template squaredDistance<ResultNumber>(self);
2724 })
2725 [[nodiscard]] constexpr auto squaredDistance(const OtherShape& other) const {
2726 return other.template squaredDistance<ResultNumber>(*this);
2727 }
2728
2730 template <class ResultNumber = division_result_t<NumberType>, class OtherShape>
2731 requires((detail::shapeRank<OtherShape> > detail::shapeRank<PolygonWithHoles>) &&
2732 requires(const OtherShape& o, const PolygonWithHoles& self) {
2733 o.template distanceL1<ResultNumber>(self);
2734 })
2735 [[nodiscard]] constexpr auto distanceL1(const OtherShape& other) const {
2736 return other.template distanceL1<ResultNumber>(*this);
2737 }
2738
2740 template <class ResultNumber = division_result_t<NumberType>, class OtherShape>
2741 requires((detail::shapeRank<OtherShape> > detail::shapeRank<PolygonWithHoles>) &&
2742 requires(const OtherShape& o, const PolygonWithHoles& self) {
2743 o.template distanceLInf<ResultNumber>(self);
2744 })
2745 [[nodiscard]] constexpr auto distanceLInf(const OtherShape& other) const {
2746 return other.template distanceLInf<ResultNumber>(*this);
2747 }
2748
2749 // -------------------------------------------------------------------------
2750 // The empty set is a subset of every shape, so its containment relations
2751 // are true and its intersection relations are false.
2752
2754 template <class EmptyPoint>
2755 [[nodiscard]] constexpr bool contains(const EmptyShape<EmptyPoint>&) const {
2756 return true;
2757 }
2758
2760 template <class EmptyPoint>
2761 [[nodiscard]] constexpr bool interiorContains(const EmptyShape<EmptyPoint>&) const {
2762 return true;
2763 }
2764
2766 template <class EmptyPoint>
2767 [[nodiscard]] constexpr bool boundaryContains(const EmptyShape<EmptyPoint>&) const {
2768 return true;
2769 }
2770
2772 template <class EmptyPoint>
2773 [[nodiscard]] constexpr bool intersects(const EmptyShape<EmptyPoint>&) const {
2774 return false;
2775 }
2776
2778 template <class EmptyPoint>
2779 [[nodiscard]] constexpr bool interiorsIntersect(const EmptyShape<EmptyPoint>&) const {
2780 return false;
2781 }
2782
2784 template <class EmptyPoint>
2785 [[nodiscard]] constexpr bool separates(const EmptyShape<EmptyPoint>&) const {
2786 return false;
2787 }
2788
2790 template <class EmptyPoint>
2791 [[nodiscard]] constexpr bool crosses(const EmptyShape<EmptyPoint>&) const {
2792 return false;
2793 }
2794
2795 // -------------------------------------------------------------------------
2796 // Runtime Shape argument: visit the wrapped alternative and re-dispatch to
2797 // the matching per-shape overload (defined in the implementation layer).
2798
2800 template <PointConcept OtherPoint>
2801 [[nodiscard]] constexpr bool contains(const Shape<OtherPoint>& other) const;
2802
2804 template <PointConcept OtherPoint>
2805 [[nodiscard]] constexpr bool interiorContains(const Shape<OtherPoint>& other) const;
2806
2808 template <PointConcept OtherPoint>
2809 [[nodiscard]] constexpr bool boundaryContains(const Shape<OtherPoint>& other) const;
2810
2812 template <PointConcept OtherPoint>
2813 [[nodiscard]] constexpr bool intersects(const Shape<OtherPoint>& other) const;
2814
2816 template <PointConcept OtherPoint>
2817 [[nodiscard]] constexpr bool interiorsIntersect(const Shape<OtherPoint>& other) const;
2818
2820 template <PointConcept OtherPoint>
2821 [[nodiscard]] constexpr bool separates(const Shape<OtherPoint>& other) const;
2822
2824 template <PointConcept OtherPoint>
2825 [[nodiscard]] constexpr bool crosses(const Shape<OtherPoint>& other) const;
2826
2842 template <class ResultNumber = division_result_t<NumberType>, PointConcept OtherPoint>
2843 [[nodiscard]] constexpr auto intersection(const Shape<OtherPoint>& other) const {
2844 return other.template intersection<ResultNumber>(*this);
2845 }
2846
2848 template <class ResultNumber = division_result_t<NumberType>, PointConcept OtherPoint>
2849 [[nodiscard]] auto regularizedIntersection(const Shape<OtherPoint>& other) const {
2850 return other.template regularizedIntersection<ResultNumber>(*this);
2851 }
2852
2865 template <class ResultNumber = division_result_t<NumberType>, PointConcept OtherPoint>
2866 [[nodiscard]] auto regularizedUnion(const Shape<OtherPoint>& other) const {
2867 return other.template regularizedUnion<ResultNumber>(*this);
2868 }
2869
2884 template <class ResultNumber = division_result_t<NumberType>, PointConcept OtherPoint>
2885 [[nodiscard]] auto difference(const Shape<OtherPoint>& other) const {
2886 return Shape<OtherPoint>(*this).template difference<ResultNumber>(other);
2887 }
2888
2901 template <class ResultNumber = division_result_t<NumberType>, PointConcept OtherPoint>
2902 [[nodiscard]] auto symmetricDifference(const Shape<OtherPoint>& other) const {
2903 return other.template symmetricDifference<ResultNumber>(*this);
2904 }
2905
2910 template <class ResultNumber = double, PointConcept OtherPoint>
2911 [[nodiscard]] constexpr auto distanceL1(const Shape<OtherPoint>& other) const {
2912 return other.template distanceL1<ResultNumber>(*this);
2913 }
2914
2919 template <class ResultNumber = double, PointConcept OtherPoint>
2920 [[nodiscard]] constexpr auto distanceLInf(const Shape<OtherPoint>& other) const {
2921 return other.template distanceLInf<ResultNumber>(*this);
2922 }
2923
2924 // -------------------------------------------------------------------------
2925 // Transformations
2926
2928 template <class TranslationNumber, class TranslationLabel>
2930 outer_ += translation;
2931 for (auto& hole : holes_) {
2932 hole += translation;
2933 }
2934 resetCache();
2935 return *this;
2936 }
2937
2939 template <class TranslationNumber, class TranslationLabel>
2941 return *this += (-translation);
2942 }
2943
2950 template <class Scalar>
2951 requires(!detail::is_point_v<Scalar> && !TransformationConcept<Scalar>)
2952 constexpr PolygonWithHoles& operator*=(const Scalar& scalar) {
2953 outer_ *= scalar;
2954 for (auto& hole : holes_) {
2955 hole *= scalar;
2956 }
2957 normalize();
2958 return *this;
2959 }
2960
2962 template <class Scalar>
2963 requires(!detail::is_point_v<Scalar> && !TransformationConcept<Scalar>)
2964 constexpr PolygonWithHoles& operator/=(const Scalar& scalar) {
2965 outer_ /= scalar;
2966 for (auto& hole : holes_) {
2967 hole /= scalar;
2968 }
2969 normalize();
2970 return *this;
2971 }
2972
2974 [[nodiscard]] constexpr PolygonWithHoles rotated90(int k) const {
2975 PolygonWithHoles result;
2976 result.outer_ = outer_.rotated90(k);
2977 result.holes_.reserve(holes_.size());
2978 for (const auto& hole : holes_) {
2979 result.holes_.push_back(hole.rotated90(k));
2980 }
2981 result.normalize();
2982 return result;
2983 }
2984
2986 constexpr void rotate90(int k) {
2987 auto saved = label_;
2988 *this = rotated90(k);
2989 label_ = std::move(saved);
2990 }
2991
3000 template <class OtherNumber>
3001 [[nodiscard]] constexpr PolygonWithHoles scaledUpX(const OtherNumber scalar) const {
3002 return scaledRings([scalar](const PolygonType& ring) { return ring.scaledUpX(scalar); });
3003 }
3004
3006 template <class OtherNumber>
3007 constexpr void scaleUpX(const OtherNumber scalar) {
3008 auto saved = label_;
3009 *this = scaledUpX(scalar);
3010 label_ = std::move(saved);
3011 }
3012
3014 template <class OtherNumber>
3015 [[nodiscard]] constexpr PolygonWithHoles scaledUpY(const OtherNumber scalar) const {
3016 return scaledRings([scalar](const PolygonType& ring) { return ring.scaledUpY(scalar); });
3017 }
3018
3020 template <class OtherNumber>
3021 constexpr void scaleUpY(const OtherNumber scalar) {
3022 auto saved = label_;
3023 *this = scaledUpY(scalar);
3024 label_ = std::move(saved);
3025 }
3026
3028 template <class OtherNumber>
3029 [[nodiscard]] constexpr PolygonWithHoles scaledDownX(const OtherNumber scalar) const {
3030 return scaledRings([scalar](const PolygonType& ring) { return ring.scaledDownX(scalar); });
3031 }
3032
3034 template <class OtherNumber>
3035 constexpr void scaleDownX(const OtherNumber scalar) {
3036 auto saved = label_;
3037 *this = scaledDownX(scalar);
3038 label_ = std::move(saved);
3039 }
3040
3042 template <class OtherNumber>
3043 [[nodiscard]] constexpr PolygonWithHoles scaledDownY(const OtherNumber scalar) const {
3044 return scaledRings([scalar](const PolygonType& ring) { return ring.scaledDownY(scalar); });
3045 }
3046
3048 template <class OtherNumber>
3049 constexpr void scaleDownY(const OtherNumber scalar) {
3050 auto saved = label_;
3051 *this = scaledDownY(scalar);
3052 label_ = std::move(saved);
3053 }
3054
3064 public:
3065 using iterator_category = std::forward_iterator_tag;
3066 using iterator_concept = std::forward_iterator_tag;
3068 using difference_type = std::ptrdiff_t;
3070
3071 constexpr VertexIterator() = default;
3072
3073 constexpr value_type operator*() const {
3074 assert(region != nullptr);
3075 return currentRing()[index];
3076 }
3077
3079 ++index;
3080 skipExhausted();
3081 return *this;
3082 }
3083
3085 VertexIterator copy(*this);
3086 ++(*this);
3087 return copy;
3088 }
3089
3090 constexpr bool operator==(const VertexIterator& other) const = default;
3091
3092 private:
3093 friend struct PolygonWithHoles;
3094
3095 constexpr VertexIterator(const PolygonWithHoles* region_arg, std::size_t ring_arg)
3096 : region(region_arg), ring(ring_arg) {
3097 skipExhausted();
3098 }
3099
3100 constexpr const PolygonType& currentRing() const {
3101 return ring == 0 ? region->outer_ : region->holes_[ring - 1];
3102 }
3103
3104 // Steps over rings with no vertices, so `index` always addresses a real
3105 // vertex and the past-the-end state is exactly `ring == 1 + holes`.
3106 // Only an empty outer boundary can trigger this — addHole() drops
3107 // degenerate rings — but the guard costs nothing and keeps begin() and
3108 // end() comparing equal for a region with no vertices at all.
3109 constexpr void skipExhausted() {
3110 const std::size_t rings = region == nullptr ? 0 : 1 + region->holes_.size();
3111 while (ring < rings && index == currentRing().size()) {
3112 ++ring;
3113 index = 0;
3114 }
3115 }
3116
3117 const PolygonWithHoles* region = nullptr;
3118 std::size_t ring = 0;
3119 std::size_t index = 0;
3120 };
3121
3122 private:
3130 template <class RingTransform>
3131 constexpr PolygonWithHoles scaledRings(RingTransform&& transform) const {
3132 PolygonWithHoles result;
3133 result.outer_ = transform(outer_);
3134 result.holes_.reserve(holes_.size());
3135 for (const auto& hole : holes_) {
3136 result.holes_.push_back(transform(hole));
3137 }
3138 result.normalize();
3139 return result;
3140 }
3141
3149 template <class EdgePredicate>
3150 constexpr bool anyBoundaryEdge(EdgePredicate&& predicate) const {
3151 for (const auto& edge : outer_.edgesView()) {
3152 if (predicate(edge)) {
3153 return true;
3154 }
3155 }
3156 for (const auto& hole : holes_) {
3157 for (const auto& edge : hole.edgesView()) {
3158 if (predicate(edge)) {
3159 return true;
3160 }
3161 }
3162 }
3163 return false;
3164 }
3165
3182 template <class OtherLinear, class ContactNumber>
3183 constexpr bool linearInteriorsIntersect(const OtherLinear& other,
3184 std::vector<Point<ContactNumber>> contacts,
3185 const Point<ContactNumber>& tail,
3186 const Point<ContactNumber>& head) const;
3187
3206 constexpr bool isSolidVertex(const PointType& vertex) const;
3207
3218 template <class OtherArea>
3219 constexpr bool outerInteriorContains(const OtherArea& other) const;
3220
3230 template <class OtherArea>
3231 constexpr bool areaContains(const OtherArea& other) const;
3232
3234 template <class OtherArea>
3235 constexpr bool areaInteriorContains(const OtherArea& other) const;
3236
3238 template <class OtherArea>
3239 constexpr bool areaBoundaryContains(const OtherArea& other) const;
3240
3242 template <class OtherArea>
3243 constexpr bool areaIntersects(const OtherArea& other) const;
3244
3246 template <class OtherArea>
3247 bool areaInteriorsIntersect(const OtherArea& other) const;
3248
3258 template <class OtherChain, class EdgeRelation>
3259 constexpr bool chainRelation(const OtherChain& other, bool all, EdgeRelation&& relation) const;
3260
3268 template <class OtherIntersection>
3269 static constexpr auto asConvexOperand(const OtherIntersection& other);
3270
3279 template <class OtherIntersection, class Relation>
3280 constexpr bool degenerateIntersectionRelation(const OtherIntersection& other,
3281 Relation&& relation) const;
3282
3290 template <class ResultNumber, class OtherShape>
3291 constexpr ResultNumber edgeMinSquaredDistance(const OtherShape& other) const;
3292
3294 template <class ResultNumber, class OtherShape>
3295 constexpr ResultNumber edgeMinDistanceL1(const OtherShape& other) const;
3296
3298 template <class ResultNumber, class OtherShape>
3299 constexpr ResultNumber edgeMinDistanceLInf(const OtherShape& other) const;
3300
3301 PolygonType outer_{};
3302 std::vector<PolygonType> holes_{};
3303 [[no_unique_address]] mutable LabelType label_{};
3304
3305 // Memoized hash, computed lazily by std::hash<PolygonWithHoles>, with the
3306 // same sentinel scheme as Polygon: hashUnset_ means "not yet computed", and
3307 // the one true hash colliding with it is remapped so the sentinel is never
3308 // stored as a real value.
3309 static constexpr std::size_t hashUnset_ = pgl::detail::numeric_limits<std::size_t>::max();
3310 mutable std::size_t hash_ = hashUnset_;
3311 friend struct std::hash<PolygonWithHoles>;
3312
3313 template <class OtherPointType, class OtherLabelType>
3314 friend struct PolygonWithHoles;
3315
3316 constexpr void resetCache() const {
3317 hash_ = hashUnset_;
3318 }
3319
3327 constexpr void normalize() {
3328 std::erase_if(holes_, [](const PolygonType& hole) { return hole.isDegenerate(); });
3329 std::sort(holes_.begin(), holes_.end());
3330 resetCache();
3331 }
3332};
3333
3334// `region + point` is the translating Minkowski sum, spelled by the generic
3335// operator+ in implementation/minkowski.hpp like every other shape's: writing a
3336// second one here would shadow it and, holding the region's own point type,
3337// would silently truncate a translation that does not fit it.
3338
3340template <class PointType, class LabelType, class TranslationNumber, class TranslationLabel>
3342 const Point<TranslationNumber, TranslationLabel>& translation) {
3343 return region + (-translation);
3344}
3345
3346template <class PointType, class LabelType, class Scalar>
3347 requires(!detail::is_point_v<Scalar> && !TransformationConcept<Scalar>)
3348constexpr auto operator*(const PolygonWithHoles<PointType, LabelType>& region, const Scalar& scalar) {
3349 using ResultPointType = Point<decltype(std::declval<PointType>().x() * scalar), typename PointType::LabelType>;
3351 result *= scalar;
3352 if constexpr (detail::has_label_v<LabelType>) {
3353 result.label() = LabelType{};
3354 }
3355 return result;
3356}
3357
3358template <class Scalar, class PointType, class LabelType>
3359 requires(!detail::is_point_v<Scalar> && !TransformationConcept<Scalar>)
3360constexpr auto operator*(const Scalar& scalar, const PolygonWithHoles<PointType, LabelType>& region) {
3361 return region * scalar;
3362}
3363
3364template <class PointType, class LabelType, class Scalar>
3365 requires(!detail::is_point_v<Scalar> && !TransformationConcept<Scalar>)
3366constexpr auto operator/(const PolygonWithHoles<PointType, LabelType>& region, const Scalar& scalar) {
3367 using ResultPointType = Point<decltype(std::declval<PointType>().x() / scalar), typename PointType::LabelType>;
3369 result /= scalar;
3370 if constexpr (detail::has_label_v<LabelType>) {
3371 result.label() = LabelType{};
3372 }
3373 return result;
3374}
3375
3376template <class PointType, class LabelType>
3377std::ostream& operator<<(std::ostream& stream, const PolygonWithHoles<PointType, LabelType>& region);
3378
3379} // namespace pgl
Undirected simple graph stored as adjacency sets.
Definition graph.hpp:38
constexpr bool operator==(const VertexIterator &other) const =default
std::ptrdiff_t difference_type
Definition polygonwithholes.hpp:3068
PointType value_type
Definition polygonwithholes.hpp:3067
friend struct PolygonWithHoles
Definition polygonwithholes.hpp:3093
value_type reference
Definition polygonwithholes.hpp:3069
constexpr VertexIterator & operator++()
Definition polygonwithholes.hpp:3078
constexpr value_type operator*() const
Definition polygonwithholes.hpp:3073
std::forward_iterator_tag iterator_concept
Definition polygonwithholes.hpp:3066
constexpr VertexIterator operator++(int)
Definition polygonwithholes.hpp:3084
std::forward_iterator_tag iterator_category
Definition polygonwithholes.hpp:3065
Bounded polygonal primitives, convex or not.
Definition forward.hpp:373
Shape pairs whose Minkowski sum Pangolin can represent.
Definition forward.hpp:476
Definition forward.hpp:306
Definition forward.hpp:324
Public declaration of pgl::HalfplaneIntersection.
Definition arrangement.hpp:67
@ edge
Definition bitmatrix.hpp:37
@ vertex
Definition bitmatrix.hpp:37
Point() -> Point< int >
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
Shape(const std::variant< T, Ts... > &) -> Shape< detail::shape_point_type_t< T > >
PolygonWithHoles() -> PolygonWithHoles< Point<>, NoLabel >
Definition polygonwithholes.hpp:3093
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 Convex< PointType > convexHull() const
Returns the convex hull of the polygon's vertices.
Definition convex.hpp:521
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
Closed region bounded by one outer simple polygon minus disjoint polygonal holes.
Definition polygonwithholes.hpp:89
constexpr auto intersection(const OtherPolyline &other) const
Returns the intersection with an open polyline (A ∩ B), a sequence of points and segments sorted by l...
Definition intersection.hpp:3109
constexpr bool boundaryContains(const OtherSet &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition polygonwithholes.hpp:2632
constexpr bool interiorsIntersect(const OtherSegment &other) const
Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
Definition interiorsintersect.hpp:2419
constexpr auto squaredDistance(const OtherPolyline &other) const
Computes the squared Euclidean distance to the other shape.
Definition distance.hpp:1977
constexpr const Rectangle< PointType > & bbox() const
Computes the bounding box of the region.
Definition polygonwithholes.hpp:1571
bool separates(const OtherDisk &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:5600
bool separates(const OtherSegment &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:5473
constexpr bool intersects(const OtherPolyline &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition intersects.hpp:2155
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > regularizedUnion(const OtherPolygon &other) const
Returns the regularized union of the two shapes (A ∪ B).
constexpr ResultNumber twiceArea() const
Computes twice the area of the region.
Definition polygonwithholes.hpp:577
constexpr auto distanceLInf(const OtherLine &other) const
Computes the squared Euclidean distance to the other shape.
Definition distancelinf.hpp:1500
constexpr auto distanceLInf(const OtherChain &other) const
Computes the squared Euclidean distance to the other shape.
Definition distancelinf.hpp:1581
constexpr bool contains(const EmptyShape< EmptyPoint > &) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition polygonwithholes.hpp:2755
constexpr bool interiorContains(const OtherLine &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:2287
constexpr PolygonSet< PointType > asPolygonSet() const
Returns the region as a one-component set of regions.
Definition polygonwithholes.hpp:386
constexpr bool contains(const OtherConvex &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:3094
constexpr bool interiorsIntersect(const OtherPoint &) const
Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
Definition polygonwithholes.hpp:1660
constexpr bool interiorContainsInterior(const OtherSegment &other) const
Tests whether this shape's interior contains the segment's interior.
Definition interiorcontains.hpp:2258
constexpr bool contains(const OtherRay &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:3004
constexpr auto distanceLInf(const OtherHalfplane &other) const
Computes the squared Euclidean distance to the other shape.
Definition distancelinf.hpp:1527
constexpr bool interiorContains(const OtherOrientedSegment &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:2280
bool crosses(const OtherPolyline &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:1250
constexpr auto distanceL1(const OtherChain &other) const
Computes the squared Euclidean distance to the other shape.
Definition distancel1.hpp:1592
constexpr bool interiorContains(const OtherIntersection &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition interiorcontains.hpp:2420
bool separates(const OtherPolyline &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:5591
Segment< PointType > EdgeType
Definition polygonwithholes.hpp:94
bool interiorsIntersect(const OtherConvex &other) const
Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
Definition interiorsintersect.hpp:2655
constexpr auto squaredDistance(const OtherIntersection &other) const
Computes the squared Euclidean distance to the other shape.
Definition distance.hpp:1989
bool crosses(const OtherConvex &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:1226
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > difference(const OtherTriangle &other) const
Returns the regularized set difference of the two shapes (A ∖ B).
constexpr PolygonWithHoles rotated90(int k) const
Returns the region rotated by 90k degrees around the origin.
Definition polygonwithholes.hpp:2974
constexpr std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > intersection(const OtherSegment &other) const
Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
constexpr bool isDegenerate() const
Tests whether the region has zero area.
Definition polygonwithholes.hpp:441
bool interiorsIntersect(const OtherRegion &other) const
Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
Definition interiorsintersect.hpp:2667
constexpr PolygonWithHoles & operator-=(const Point< TranslationNumber, TranslationLabel > &translation)
Translates the region in place by the opposite vector.
Definition polygonwithholes.hpp:2940
constexpr bool boundaryContains(const OtherConvex &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:1896
constexpr auto minkowskiSum(const OtherShape &other) const
Returns the Minkowski sum of this shape and another (A ⊕ B).
Definition minkowski.hpp:806
bool crosses(const OtherRay &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:1198
constexpr void eraseHole(std::size_t index)
Erases the hole at the given index.
Definition polygonwithholes.hpp:246
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 polygonwithholes.hpp:2866
constexpr bool interiorContains(const OtherHalfplane &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:2305
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > difference(const OtherSet &other) const
Returns the regularized set difference of the two shapes (A ∖ B).
detail::floating_result_t< ResultNumber > squaredDistance(const OtherDisk &other) const
Computes the squared Euclidean distance to a disk.
Definition distance.hpp:2002
constexpr bool interiorContains(const OtherSet &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition polygonwithholes.hpp:2643
bool crosses(const OtherChain &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:1244
constexpr bool intersects(const OtherPolygon &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:2135
PolygonWithHoles< Point< ResultNumber, typename PointType::LabelType > > minkowskiSum(const OtherRegion &other) const
Returns the regularized Minkowski sum of the two shapes (A ⊕ B).
constexpr auto squaredDistance(const OtherOrientedSegment &other) const
Computes the squared Euclidean distance to the other shape.
Definition distance.hpp:1875
TLabel LabelType
Definition polygonwithholes.hpp:92
constexpr PolygonWithHoles(const PolygonWithHoles< OtherPointType, OtherLabelType > &other)
Converts a region with compatible vertex type.
Definition polygonwithholes.hpp:152
constexpr bool interiorsIntersect(const OtherShape &other) const
Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
Definition polygonwithholes.hpp:2685
PolygonWithHoles< Point< ResultNumber, typename PointType::LabelType > > minkowskiSum(const OtherSegment &other) const
Returns the regularized Minkowski sum of the two shapes (A ⊕ B).
constexpr const PolygonType & hole(std::size_t index) const
Definition polygonwithholes.hpp:196
bool isRegular() const
Tests whether the region is the closure of its own interior (A = closure(A°)).
Definition intersections.hpp:1230
constexpr auto distanceL1(const OtherRay &other) const
Computes the squared Euclidean distance to the other shape.
Definition distancel1.hpp:1529
constexpr PolygonWithHoles & operator+=(const Point< TranslationNumber, TranslationLabel > &translation)
Translates the region in place.
Definition polygonwithholes.hpp:2929
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > symmetricDifference(const OtherRectangle &other) const
Returns the regularized symmetric difference of the two shapes (A △ B).
bool interiorsIntersect(const OtherDisk &other) const
Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
Definition interiorsintersect.hpp:2701
constexpr void scaleUpY(const OtherNumber scalar)
Scales the region's y-coordinates up in place.
Definition polygonwithholes.hpp:3021
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > regularizedIntersection(const OtherPolygon &other) const
Returns the regularized intersection of the two shapes (A ∩ B).
constexpr bool boundaryContains(const OtherOrientedLine &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:1843
constexpr std::vector< PointType > vertices() const
Returns the vertices of every ring, outer boundary first.
Definition polygonwithholes.hpp:306
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > symmetricDifference(const OtherPolygon &other) const
Returns the regularized symmetric difference of the two shapes (A △ B).
constexpr auto distanceLInf(const OtherTriangle &other) const
Computes the squared Euclidean distance to the other shape.
Definition distancelinf.hpp:1545
constexpr VertexIterator verticesBegin() const
Returns an iterator to the first vertex of the outer boundary.
Definition polygonwithholes.hpp:333
constexpr auto distanceLInf(const OtherConvex &other) const
Computes the squared Euclidean distance to the other shape.
Definition distancelinf.hpp:1554
constexpr auto regularizedIntersection(const OtherShape &other) const
Forwards a regularized intersection to the higher-ranked shape.
Definition polygonwithholes.hpp:2715
constexpr PolygonWithHoles scaledUpX(const OtherNumber scalar) const
Returns the region with its x-coordinates multiplied by scalar.
Definition polygonwithholes.hpp:3001
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > symmetricDifference(const OtherConvex &other) const
Returns the regularized symmetric difference of the two shapes (A △ B).
constexpr PolygonWithHoles scaledUpY(const OtherNumber scalar) const
Returns the region with its x-coordinates multiplied by scalar.
Definition polygonwithholes.hpp:3015
auto asBitMatrix() const
Rasterizes this region into a BitMatrix, one bit per covered cell.
Definition bitmatrix.hpp:2705
constexpr bool boundaryContains(const OtherSegment &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:1816
constexpr bool intersects(const OtherRectangle &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:2113
constexpr auto distanceLInf(const OtherPoint &point) const
Computes the squared Euclidean distance to the other shape.
Definition distancelinf.hpp:1473
constexpr void scaleUpX(const OtherNumber scalar)
Scales the region's x-coordinates up in place.
Definition polygonwithholes.hpp:3007
constexpr auto area() const
Computes the area of the region.
Definition polygonwithholes.hpp:590
constexpr std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > intersection(const OtherOrientedSegment &other) const
Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
PolygonWithHoles< Point< ResultNumber, typename PointType::LabelType > > minkowskiSum(const OtherPolyline &other) const
Returns the regularized Minkowski sum of the two shapes (A ⊕ B).
constexpr auto squaredDistance(const OtherLine &other) const
Computes the squared Euclidean distance to the other shape.
Definition distance.hpp:1884
constexpr bool intersects(const OtherTriangle &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:2123
std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Polyline< Point< ResultNumber, typename PointType::LabelType > >, PolygonWithHoles< Point< ResultNumber, typename PointType::LabelType > > > > intersection(const OtherTriangle &other) const
Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
typename PointType::NumberType NumberType
Definition polygonwithholes.hpp:91
friend struct PolygonWithHoles
Definition polygonwithholes.hpp:3314
auto symmetricDifference(const OtherSet &other) const
Returns the regularized symmetric difference of the two shapes (A △ B).
Definition polygonwithholes.hpp:1342
constexpr bool contains(const OtherLine &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:2992
constexpr bool intersects(const OtherOrientedSegment &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:2049
bool crosses(const OtherRectangle &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:1210
bool separates(const OtherRectangle &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:5533
bool separates(const OtherTriangle &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:5543
constexpr bool interiorContains(const EmptyShape< EmptyPoint > &) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition polygonwithholes.hpp:2761
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > difference(const OtherRectangle &other) const
Returns the regularized set difference of the two shapes (A ∖ B).
constexpr bool boundaryContains(const OtherDisk &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition boundarycontains.hpp:1932
constexpr A & label() const
Returns the region label.
Definition polygonwithholes.hpp:170
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 polygonwithholes.hpp:2911
constexpr auto verticesView() const
Returns a lazy view over the vertices of every ring, outer boundary first, without allocating a vecto...
Definition polygonwithholes.hpp:328
constexpr Point< ResultNumber > verticesCentroid() const
Computes the centroid of the vertex set over all rings.
Definition measures.hpp:1109
constexpr bool eraseHole(const PolygonType &hole)
Erases the hole equal to the given polygon, if the region has one.
Definition polygonwithholes.hpp:262
auto regularizedIntersection(const Shape< OtherPoint > &other) const
Re-dispatches a regularized intersection through a runtime shape.
Definition polygonwithholes.hpp:2849
bool crosses(const OtherIntersection &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:1262
constexpr bool interiorsIntersect(const Shape< OtherPoint > &other) const
Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
Definition interiorsintersect.hpp:2747
constexpr std::vector< OrientedSegment< PointType > > orientedEdges() const
Returns the boundary edges directed so the region lies to the left.
Definition polygonwithholes.hpp:364
constexpr bool intersects(const OtherShape &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition polygonwithholes.hpp:2672
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.
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.
constexpr std::optional< Point< ResultNumber, typename PointType::LabelType > > intersection(const OtherPoint &other) const
Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
constexpr auto minkowskiErosion(const OtherShape &other) const
Returns the Minkowski erosion of this shape by another (A ⊖ B).
Definition minkowskierosion.hpp:639
constexpr auto squaredDistance(const OtherConvex &other) const
Computes the squared Euclidean distance to the other shape.
Definition distance.hpp:1938
constexpr auto distanceL1(const OtherPolyline &other) const
Computes the squared Euclidean distance to the other shape.
Definition distancel1.hpp:1601
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > difference(const OtherRegion &other) const
Returns the regularized set difference of the two shapes (A ∖ B).
std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Polyline< Point< ResultNumber, typename PointType::LabelType > >, PolygonWithHoles< Point< ResultNumber, typename PointType::LabelType > > > > intersection(const OtherRectangle &other) const
Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
constexpr bool boundaryContains(const OtherTriangle &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:1890
std::vector< PointType > clearlyVisibleVertices(const PointType &query) const
The region's vertices clearly visible from query.
Definition visibilitygraph.hpp:945
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > regularized() const
Returns the region without its slits (closure(A°)), as a set of regions.
std::vector< Point< ResultNumber, typename PointType::LabelType > > latticePoints() const
Returns the integer points the region contains.
Definition lattice.hpp:687
Point< ResultNumber > pointInside() const
Returns a point strictly inside the region.
Definition triangulation.hpp:6989
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > difference(const OtherHalfplane &other) const
Returns the regularized set difference of the two shapes (A ∖ B).
constexpr auto distanceL1(const OtherConvex &other) const
Computes the squared Euclidean distance to the other shape.
Definition distancel1.hpp:1565
constexpr bool interiorsIntersect(const OtherLine &other) const
Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
Definition interiorsintersect.hpp:2439
PolygonWithHoles< Point< ResultNumber, typename PointType::LabelType > > minkowskiSum(const OtherRectangle &other) const
Returns the regularized Minkowski sum of the two shapes (A ⊕ B).
constexpr bool interiorContains(const OtherSegment &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:2239
bool crosses(const OtherOrientedSegment &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:1180
bool crosses(const OtherRegion &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:1238
constexpr std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > intersection(const OtherRay &other) const
Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
constexpr EmptyShape< EmptyPoint > intersection(const EmptyShape< EmptyPoint > &) const
Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
Definition polygonwithholes.hpp:1291
std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Polyline< Point< ResultNumber, typename PointType::LabelType > >, PolygonWithHoles< Point< ResultNumber, typename PointType::LabelType > > > > intersection(const OtherConvex &other) const
Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
constexpr bool intersects(const OtherPoint &point) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition polygonwithholes.hpp:1649
constexpr bool interiorsIntersect(const EmptyShape< EmptyPoint > &) const
Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
Definition polygonwithholes.hpp:2779
constexpr bool interiorContains(const OtherRay &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:2299
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > regularizedUnion(const OtherTriangle &other) const
Returns the regularized union of the two shapes (A ∪ B).
constexpr auto distanceL1(const OtherSegment &other) const
Computes the squared Euclidean distance to the other shape.
Definition distancel1.hpp:1493
constexpr void scaleDownX(const OtherNumber scalar)
Scales the region's x-coordinates down in place.
Definition polygonwithholes.hpp:3035
constexpr bool isSegment() const
Tests whether the region covers exactly one segment of positive length.
Definition polygonwithholes.hpp:457
constexpr bool intersects(const OtherRay &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:2075
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > regularizedUnion(const OtherRegion &other) const
Returns the regularized union of the two shapes (A ∪ B).
PolygonWithHoles< Point< ResultNumber, typename PointType::LabelType > > minkowskiSum(const OtherPolygon &other) const
Returns the regularized Minkowski sum of the two shapes (A ⊕ B).
constexpr auto squaredDistance(const OtherRectangle &other) const
Computes the squared Euclidean distance to the other shape.
Definition distance.hpp:1920
constexpr Convex< PointType > convexHull() const
Returns the convex hull of the region's vertices.
Definition polygonwithholes.hpp:1561
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > regularizedUnion(const OtherConvex &other) const
Returns the regularized union of the two shapes (A ∪ B).
constexpr bool intersects(const EmptyShape< EmptyPoint > &) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition polygonwithholes.hpp:2773
constexpr bool contains(const OtherSet &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition polygonwithholes.hpp:2621
constexpr bool interiorContains(const OtherPoint &point) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:2223
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > difference(const OtherPolygon &other) const
Returns the regularized set difference of the two shapes (A ∖ B).
constexpr PolygonWithHoles scaledDownX(const OtherNumber scalar) const
Returns the region with its x-coordinates multiplied by scalar.
Definition polygonwithholes.hpp:3029
constexpr bool contains(const OtherIntersection &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:3197
constexpr auto cbegin() const
Returns a constant iterator to the first hole.
Definition polygonwithholes.hpp:210
constexpr void addHole(PolygonType hole)
Adds a hole, keeping the canonical order.
Definition polygonwithholes.hpp:227
Graph< PointType > reducedVisibilityGraph() const
Returns the reduced visibility graph of the region's vertices.
Definition visibilitygraph.hpp:932
bool crosses(const OtherPolygon &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:1232
constexpr bool boundaryContains(const OtherOrientedSegment &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:1829
constexpr auto operator<=>(const PolygonWithHoles &other) const
Compares two regions by outer boundary, then by canonical hole list.
Definition polygonwithholes.hpp:394
constexpr bool crosses(const Shape< OtherPoint > &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:1272
bool crosses(const OtherDisk &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:1256
constexpr bool boundaryContains(const OtherPolyline &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition boundarycontains.hpp:1923
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > regularizedIntersection(const OtherRegion &other) const
Returns the regularized intersection of the two shapes (A ∩ B).
constexpr bool intersects(const OtherConvex &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:2129
constexpr auto end() const
Returns a constant iterator past the last hole.
Definition polygonwithholes.hpp:213
constexpr auto distanceLInf(const OtherRegion &other) const
Computes the squared Euclidean distance to the other shape.
Definition distancelinf.hpp:1572
Graph< PointType > visibilityGraph() const
Returns the visibility graph of the region's vertices.
Definition visibilitygraph.hpp:919
constexpr bool contains(const OtherSegment &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:2961
constexpr bool boundaryContains(const OtherPoint &point) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:1802
constexpr auto squaredDistance(const OtherPolygon &other) const
Computes the squared Euclidean distance to the other shape.
Definition distance.hpp:1947
constexpr bool intersects(const OtherChain &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition intersects.hpp:2149
constexpr bool boundaryContains(const OtherChain &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition boundarycontains.hpp:1916
constexpr bool contains(const OtherHalfplane &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:3010
constexpr auto begin() const
Returns a constant iterator to the first hole.
Definition polygonwithholes.hpp:207
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > regularizedIntersection(const OtherRectangle &other) const
Returns the regularized intersection of the two shapes (A ∩ B).
constexpr auto distanceL1(const OtherOrientedLine &other) const
Computes the squared Euclidean distance to the other shape.
Definition distancel1.hpp:1520
PolygonWithHoles< Point< ResultNumber, typename PointType::LabelType > > minkowskiSum(const OtherTriangle &other) const
Returns the regularized Minkowski sum of the two shapes (A ⊕ B).
std::vector< PointType > visibleVertices(const PointType &query) const
The region's vertices visible from query.
Definition visibilitygraph.hpp:938
bool separates(const OtherOrientedSegment &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:5485
constexpr Point< ResultNumber > centroid() const
Computes the area-weighted centroid of the region.
Definition measures.hpp:1131
constexpr bool boundaryContains(const OtherPolygon &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:1902
constexpr PolygonWithHoles()=default
Creates the empty region (a vertexless outer polygon, no holes).
constexpr bool crosses(const EmptyShape< EmptyPoint > &) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition polygonwithholes.hpp:2791
constexpr bool interiorContains(const Shape< OtherPoint > &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:2563
constexpr std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > intersection(const OtherLine &other) const
Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
constexpr bool boundaryContains(const OtherRay &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:1849
constexpr const PolygonType & outer() const
Definition polygonwithholes.hpp:178
constexpr bool contains(const OtherOrientedLine &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:2998
constexpr bool contains(const OtherPoint &point) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:2945
constexpr bool boundaryContains(const OtherLine &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:1837
constexpr bool interiorsIntersect(const OtherHalfplane &other) const
Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
Definition interiorsintersect.hpp:2478
constexpr auto distanceL1(const OtherRegion &other) const
Computes the squared Euclidean distance to the other shape.
Definition distancel1.hpp:1583
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > difference(const OtherIntersection &other) const
Returns the regularized set difference of the two shapes (A ∖ B).
constexpr VertexIterator verticesEnd() const
Returns an iterator past the last vertex of the last hole.
Definition polygonwithholes.hpp:338
constexpr bool intersects(const OtherDisk &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition intersects.hpp:2165
constexpr bool operator==(const PolygonWithHoles &other) const
Checks equality of two regions.
Definition polygonwithholes.hpp:410
constexpr auto squaredDistance(const OtherRegion &other) const
Computes the squared Euclidean distance to the other shape.
Definition distance.hpp:1959
constexpr std::size_t holeCount() const
Returns the number of holes.
Definition polygonwithholes.hpp:183
constexpr bool interiorContains(const OtherPolygon &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:2372
constexpr auto squaredDistance(const OtherRay &other) const
Computes the squared Euclidean distance to the other shape.
Definition distance.hpp:1902
constexpr bool interiorsIntersect(const OtherPolyline &other) const
Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
Definition interiorsintersect.hpp:2685
constexpr bool samePointSet(const OtherShape &other) const
Tests whether another shape defines exactly the same point set.
Definition samepointset.hpp:2031
constexpr bool contains(const OtherDisk &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:3161
constexpr auto distanceLInf(const OtherShape &other) const
Computes the squared Euclidean distance to the other shape.
Definition polygonwithholes.hpp:2745
constexpr auto cend() const
Returns a constant iterator past the last hole.
Definition polygonwithholes.hpp:216
constexpr bool contains(const OtherPolyline &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:3146
constexpr bool intersects(const OtherLine &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:2060
constexpr bool interiorsIntersect(const OtherRay &other) const
Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
Definition interiorsintersect.hpp:2463
constexpr bool contains(const OtherRectangle &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:3077
auto intersection(const OtherShape &other) const
Forwards an intersection to the higher-ranked shape.
Definition polygonwithholes.hpp:2704
bool pointInsideInteriorContainedIn(const OtherShape &shape) const
Tests whether some point in this shape's relative interior lies in the strict interior of shape.
Definition triangulation.hpp:7024
constexpr bool intersects(const OtherOrientedLine &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:2069
bool separates(const OtherIntersection &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:5612
constexpr auto distanceL1(const OtherTriangle &other) const
Computes the squared Euclidean distance to the other shape.
Definition distancel1.hpp:1556
std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Polyline< Point< ResultNumber, typename PointType::LabelType > >, PolygonWithHoles< Point< ResultNumber, typename PointType::LabelType > > > > intersection(const OtherRegion &other) const
Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
PolygonWithHoles< Point< ResultNumber, typename PointType::LabelType > > minkowskiSum(const OtherChain &other) const
Returns the regularized Minkowski sum of the two shapes (A ⊕ B).
bool separates(const OtherSet &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:5990
constexpr auto closestPoints(const OtherShape &other) const
Returns the pair of points realizing the distance, nothing when the shapes meet.
Definition closest.hpp:433
bool interiorsIntersect(const OtherTriangle &other) const
Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
Definition interiorsintersect.hpp:2649
constexpr bool crosses(const OtherShape &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition polygonwithholes.hpp:2693
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > regularizedIntersection(const OtherTriangle &other) const
Returns the regularized intersection of the two shapes (A ∩ B).
constexpr bool interiorContains(const OtherOrientedLine &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:2293
bool isValid() const
Tests the structural contract: every ring simple, every hole inside the outer boundary,...
Definition intersections.hpp:1189
constexpr bool contains(const OtherChain &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:3140
constexpr auto distanceL1(const OtherOrientedSegment &other) const
Computes the squared Euclidean distance to the other shape.
Definition distancel1.hpp:1502
constexpr bool separates(const EmptyShape< EmptyPoint > &) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition polygonwithholes.hpp:2785
constexpr bool interiorContains(const OtherRectangle &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:2349
constexpr Segment< PointType > diameter() const
Returns a segment realizing the diameter (the farthest vertex pair).
Definition polygonwithholes.hpp:1551
auto difference(const Shape< OtherPoint > &other) const
Returns the regularized set difference of the two shapes (A ∖ B), re-dispatching through the wrapper'...
Definition polygonwithholes.hpp:2885
constexpr bool boundaryContains(const OtherHalfplane &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:1855
constexpr auto distanceL1(const OtherPoint &point) const
Computes the squared Euclidean distance to the other shape.
Definition distancel1.hpp:1484
bool crosses(const OtherHalfplane &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:1204
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > regularizedIntersection(const OtherHalfplane &other) const
Returns the regularized intersection of the two shapes (A ∩ B).
bool separates(const OtherRay &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:5509
bool crosses(const OtherOrientedLine &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:1192
constexpr auto squaredDistance(const OtherSegment &other) const
Computes the squared Euclidean distance to the other shape.
Definition distance.hpp:1866
bool separates(const OtherLine &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:5491
constexpr bool interiorContains(const OtherPolyline &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition interiorcontains.hpp:2393
constexpr auto squaredDistance(const OtherTriangle &other) const
Computes the squared Euclidean distance to the other shape.
Definition distance.hpp:1929
constexpr bool interiorContains(const OtherDisk &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition interiorcontains.hpp:2403
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 polygonwithholes.hpp:2920
constexpr bool boundaryContains(const OtherRegion &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:1908
constexpr auto squaredDistance(const OtherPoint &point) const
Computes the squared Euclidean distance to the other shape.
Definition distance.hpp:1857
constexpr auto distanceLInf(const OtherPolyline &other) const
Computes the squared Euclidean distance to the other shape.
Definition distancelinf.hpp:1590
bool separates(const OtherChain &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:5582
constexpr bool separates(const Shape< OtherPoint > &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:5789
constexpr bool contains(const OtherTriangle &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:3088
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > regularizedIntersection(const OtherIntersection &other) const
Returns the regularized intersection of the two shapes (A ∩ B).
Polygon< PointType > PolygonType
Definition polygonwithholes.hpp:93
constexpr bool interiorContains(const OtherConvex &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:2366
constexpr bool interiorsIntersect(const OtherChain &other) const
Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
Definition interiorsintersect.hpp:2679
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > regularizedIntersection(const OtherConvex &other) const
Returns the regularized intersection of the two shapes (A ∩ B).
std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Polyline< Point< ResultNumber, typename PointType::LabelType > >, PolygonWithHoles< Point< ResultNumber, typename PointType::LabelType > > > > intersection(const OtherPolygon &other) const
Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
constexpr bool intersects(const OtherHalfplane &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:2084
constexpr bool intersects(const OtherRegion &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:2141
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > regularizedUnion(const OtherRectangle &other) const
Returns the regularized union of the two shapes (A ∪ B).
bool interiorsIntersect(const OtherPolygon &other) const
Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
Definition interiorsintersect.hpp:2661
constexpr auto distanceLInf(const OtherPolygon &other) const
Computes the squared Euclidean distance to the other shape.
Definition distancelinf.hpp:1563
bool separates(const OtherHalfplane &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:5521
constexpr auto distanceL1(const OtherIntersection &other) const
Computes the squared Euclidean distance to the other shape.
Definition distancel1.hpp:1610
constexpr bool empty() const
Tests whether the region has no outer boundary at all.
Definition polygonwithholes.hpp:430
constexpr auto distanceLInf(const OtherRectangle &other) const
Computes the squared Euclidean distance to the other shape.
Definition distancelinf.hpp:1536
auto regularizedUnion(const OtherSet &other) const
Returns the regularized union of the two shapes (A ∪ B).
Definition polygonwithholes.hpp:971
bool crosses(const OtherLine &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:1186
Graph< PointType > clearVisibilityGraph() const
Returns the clear visibility graph of the region's vertices.
Definition visibilitygraph.hpp:926
constexpr bool isUndefined() const
Tests whether the region is degenerate without covering a point or a segment (which includes the empt...
Definition polygonwithholes.hpp:465
constexpr auto distanceLInf(const OtherIntersection &other) const
Computes the squared Euclidean distance to the other shape.
Definition distancelinf.hpp:1599
PointType PointType
Definition polygonwithholes.hpp:90
bool crosses(const OtherPoint &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:1168
constexpr auto distanceLInf(const OtherOrientedLine &other) const
Computes the squared Euclidean distance to the other shape.
Definition distancelinf.hpp:1509
constexpr PolygonWithHoles scaledDownY(const OtherNumber scalar) const
Returns the region with its x-coordinates multiplied by scalar.
Definition polygonwithholes.hpp:3043
constexpr bool boundaryContains(const Shape< OtherPoint > &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:2083
constexpr auto distanceL1(const OtherLine &other) const
Computes the squared Euclidean distance to the other shape.
Definition distancel1.hpp:1511
constexpr auto distanceLInf(const OtherRay &other) const
Computes the squared Euclidean distance to the other shape.
Definition distancelinf.hpp:1518
constexpr auto squaredDistance(const OtherOrientedLine &other) const
Computes the squared Euclidean distance to the other shape.
Definition distance.hpp:1893
constexpr bool contains(const OtherPolygon &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:3100
bool separates(const OtherPolygon &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:5555
bool separates(const OtherRegion &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:5567
constexpr auto distanceLInf(const OtherSegment &other) const
Computes the squared Euclidean distance to the other shape.
Definition distancelinf.hpp:1482
constexpr bool interiorContains(const OtherTriangle &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:2360
bool isSimple() const
Tests whether every ring is simple.
Definition polygonwithholes.hpp:478
constexpr std::vector< std::variant< Point< ResultNumber, typename PointType::LabelType >, Segment< Point< ResultNumber, typename PointType::LabelType > > > > intersection(const OtherOrientedLine &other) const
Returns the intersection of the two shapes (A ∩ B), empty when they are disjoint.
constexpr auto distanceL1(const OtherPolygon &other) const
Computes the squared Euclidean distance to the other shape.
Definition distancel1.hpp:1574
constexpr auto distanceL1(const OtherHalfplane &other) const
Computes the squared Euclidean distance to the other shape.
Definition distancel1.hpp:1538
constexpr bool intersects(const OtherIntersection &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition intersects.hpp:2188
auto triangulation(const SegmentRange &segments) const
Builds the constrained Delaunay triangulation of this region with the given interior constraint segme...
Definition triangulation.hpp:6946
constexpr std::size_t chainCount() const
Total number of maximal lexicographically monotone chains over all rings; see Polygon::chainCount.
Definition polygonwithholes.hpp:297
constexpr bool intersects(const Shape< OtherPoint > &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:2217
std::vector< Convex< PointType > > convexPartition() const
Cuts this region into convex pieces with disjoint interiors.
Definition triangulation.hpp:6935
bool interiorsIntersect(const OtherIntersection &other) const
Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
Definition interiorsintersect.hpp:2724
bool interiorsIntersect(const OtherRectangle &other) const
Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
Definition interiorsintersect.hpp:2639
std::vector< Convex< PointType > > convexCovering() const
Covers this region with a greedily selected set of convex polygons.
Definition triangulation.hpp:6940
bool crosses(const OtherTriangle &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:1220
constexpr void rotate90(int k)
Rotates the region by 90k degrees around the origin in place.
Definition polygonwithholes.hpp:2986
constexpr bool boundaryContains(const EmptyShape< EmptyPoint > &) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition polygonwithholes.hpp:2767
constexpr auto distanceLInf(const OtherOrientedSegment &other) const
Computes the squared Euclidean distance to the other shape.
Definition distancelinf.hpp:1491
constexpr auto closestSegments(const OtherShape &other) const
Returns the pair of elements realizing the distance, nothing when the shapes meet.
Definition closest.hpp:426
constexpr auto squaredDistance(const OtherHalfplane &other) const
Computes the squared Euclidean distance to the other shape.
Definition distance.hpp:1911
constexpr void scaleDownY(const OtherNumber scalar)
Scales the region's y-coordinates down in place.
Definition polygonwithholes.hpp:3049
constexpr bool interiorContains(const OtherRegion &other) const
Tests whether this shape's interior contains the other shape (A∖∂A ⊇ B).
Definition interiorcontains.hpp:2378
constexpr const std::vector< PolygonType > & holes() const
Definition polygonwithholes.hpp:202
constexpr std::vector< EdgeType > edges() const
Returns the boundary edges of every ring, outer boundary first.
Definition polygonwithholes.hpp:343
constexpr auto squaredDistance(const OtherChain &other) const
Computes the squared Euclidean distance to the other shape.
Definition distance.hpp:1968
constexpr bool isPoint() const
Tests whether the region covers exactly one point.
Definition polygonwithholes.hpp:452
constexpr bool interiorContains(const OtherChain &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition interiorcontains.hpp:2386
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:722
auto symmetricDifference(const Shape< OtherPoint > &other) const
Returns the regularized symmetric difference of the two shapes (A △ B), re-dispatching through the wr...
Definition polygonwithholes.hpp:2902
constexpr auto distanceL1(const OtherShape &other) const
Computes the squared Euclidean distance to the other shape.
Definition polygonwithholes.hpp:2735
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > symmetricDifference(const OtherTriangle &other) const
Returns the regularized symmetric difference of the two shapes (A △ B).
constexpr PolygonWithHoles(PolygonType outer)
Creates a hole-free region from its outer boundary.
Definition polygonwithholes.hpp:109
constexpr Rectangle< Point< ResultNumber > > fbox() const
Computes the floating-point bounding box of the region.
Definition polygonwithholes.hpp:1600
constexpr PolygonWithHoles(PolygonType outer, HoleRange &&holes, bool trusted=false)
Creates a region from an outer boundary and a range of holes.
Definition polygonwithholes.hpp:129
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > difference(const OtherConvex &other) const
Returns the regularized set difference of the two shapes (A ∖ B).
constexpr auto intersection(const OtherChain &other) const
Returns the intersection with a monotone chain (A ∩ B), a sequence of points and segments sorted by l...
Definition intersection.hpp:3115
constexpr bool contains(const Shape< OtherPoint > &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:3350
constexpr bool boundaryContains(const OtherRectangle &other) const
Tests whether this shape's boundary contains the other shape (∂A ⊇ B).
Definition boundarycontains.hpp:1879
constexpr bool interiorsIntersect(const OtherOrientedLine &other) const
Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
Definition interiorsintersect.hpp:2457
constexpr bool intersects(const OtherSegment &other) const
Tests whether this shape and the other shape intersect (A ∩ B ≠ ∅).
Definition intersects.hpp:2028
constexpr auto squaredDistance(const OtherShape &other) const
Computes the squared Euclidean distance to the other shape.
Definition polygonwithholes.hpp:2725
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 polygonwithholes.hpp:2843
constexpr bool hasHoles() const
Tests whether the region has at least one hole.
Definition polygonwithholes.hpp:188
auto triangulation() const
Builds the constrained Delaunay triangulation of this region.
Definition triangulation.hpp:6930
constexpr auto distanceL1(const OtherRectangle &other) const
Computes the squared Euclidean distance to the other shape.
Definition distancel1.hpp:1547
constexpr bool contains(const OtherRegion &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:3106
bool separates(const OtherPoint &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:5467
constexpr bool interiorsIntersect(const OtherOrientedSegment &other) const
Tests whether the interiors of the shapes intersect (A° ∩ B° ≠ ∅).
Definition interiorsintersect.hpp:2433
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > symmetricDifference(const OtherRegion &other) const
Returns the regularized symmetric difference of the two shapes (A △ B).
bool separates(const OtherOrientedLine &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:5503
PolygonSet< Point< ResultNumber, typename PointType::LabelType > > minkowskiSum(const OtherSet &other) const
Returns the regularized Minkowski sum of the two shapes (A ⊕ B), as a set of regions.
constexpr bool boundaryContains(const OtherIntersection &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition boundarycontains.hpp:1941
bool separates(const OtherConvex &other) const
Tests whether removing this shape disconnects the other shape (B∖A is disconnected).
Definition separates.hpp:5549
Polygon< Point< ResultNumber > > regularizedVisiblePolygon(const PointType &query) const
The part of the region visible from query, regularized.
Definition visibilitygraph.hpp:954
constexpr bool contains(const OtherOrientedSegment &other) const
Tests whether this shape contains the other shape (A ⊇ B).
Definition contains.hpp:2984
constexpr std::size_t vertexCount() const
Returns the total number of vertices over all rings.
Definition polygonwithholes.hpp:279
PolygonWithHoles< Point< ResultNumber, typename PointType::LabelType > > minkowskiSum(const OtherConvex &other) const
Returns the regularized Minkowski sum of the two shapes (A ⊕ B).
bool crosses(const OtherSegment &other) const
Tests whether the two shapes mutually separate each other (each disconnects the other).
Definition crosses.hpp:1174
Closed simple polygon stored by its vertices.
Definition polygon.hpp:59
constexpr Polygon scaledUpY(const OtherNumber scalar) const
Returns the polygon with its y-coordinates multiplied by a factor.
constexpr Polygon scaledDownY(const OtherNumber scalar) const
Returns the polygon with its y-coordinates divided by a divisor.
constexpr Polygon scaledUpX(const OtherNumber scalar) const
Returns the polygon with its x-coordinates multiplied by a factor.
constexpr Polygon rotated90(int k=1) const
Returns the polygon rotated by 90k degrees around the origin.
Definition transformations.hpp:1714
constexpr Polygon scaledDownX(const OtherNumber scalar) const
Returns the polygon with its x-coordinates divided by a divisor.
constexpr bool isDegenerate() const
Checks if the polygon is degenerate (has zero area).
Definition polygon.hpp:319
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
constexpr Rectangle bbox() const
Returns the bounding box of the rectangle.
Definition bounding.hpp:140
Unoriented closed segment between two endpoints plus optional segment label.
Definition segment.hpp:58
constexpr Segment diameter() const
Returns a segment defining the diameter.
Definition measures.hpp:73
Runtime variant wrapper over the supported primitive shapes.
Definition shape.hpp:160