33void findIntersections(
const SEG& aSegA,
const SEG& aSegB, std::vector<VECTOR2I>& aIntersections )
39 aIntersections.push_back( *intersection );
43void findIntersections(
const SEG& aSeg,
const LINE& aLine, std::vector<VECTOR2I>& aIntersections )
49 aIntersections.push_back( *intersection );
53void findIntersections(
const SEG& aSeg,
const HALF_LINE& aHalfLine,
54 std::vector<VECTOR2I>& aIntersections )
60 aIntersections.push_back( *intersection );
64void findIntersections(
const SEG& aSeg,
const CIRCLE& aCircle,
65 std::vector<VECTOR2I>& aIntersections )
67 std::vector<VECTOR2I> intersections = aCircle.
Intersect( aSeg );
69 aIntersections.insert( aIntersections.end(), intersections.begin(), intersections.end() );
72void findIntersections(
const SEG& aSeg,
const SHAPE_ARC& aArc,
73 std::vector<VECTOR2I>& aIntersections )
75 std::vector<VECTOR2I> intersections;
79 for(
const VECTOR2I& intersection : intersections )
83 aIntersections.emplace_back( intersection );
88void findIntersections(
const LINE& aLineA,
const LINE& aLineB,
89 std::vector<VECTOR2I>& aIntersections )
95 aIntersections.push_back( *intersection );
99void findIntersections(
const LINE& aLine,
const HALF_LINE& aHalfLine,
100 std::vector<VECTOR2I>& aIntersections )
112 if( aHalfLine.
Contains( *intersection ) )
114 aIntersections.push_back( *intersection );
119 std::vector<VECTOR2I>& aIntersections )
125 aIntersections.push_back( *intersection );
129void findIntersections(
const CIRCLE& aCircle,
const LINE& aLine,
130 std::vector<VECTOR2I>& aIntersections )
134 aIntersections.insert( aIntersections.end(), intersections.begin(), intersections.end() );
137void findIntersections(
const CIRCLE& aCircle,
const HALF_LINE& aHalfLine,
138 std::vector<VECTOR2I>& aIntersections )
142 for(
const VECTOR2I& intersection : intersections )
144 if( aHalfLine.
Contains( intersection ) )
146 aIntersections.push_back( intersection );
151void findIntersections(
const CIRCLE& aCircleA,
const CIRCLE& aCircleB,
152 std::vector<VECTOR2I>& aIntersections )
154 std::vector<VECTOR2I> intersections = aCircleA.
Intersect( aCircleB );
155 aIntersections.insert( aIntersections.end(), intersections.begin(), intersections.end() );
159 std::vector<VECTOR2I>& aIntersections )
161 aArc.
Intersect( aCircle, &aIntersections );
165 std::vector<VECTOR2I>& aIntersections )
167 aArcA.
Intersect( aArcB, &aIntersections );
170void findIntersections(
const SHAPE_ARC& aArc,
const LINE& aLine,
171 std::vector<VECTOR2I>& aIntersections )
173 std::vector<VECTOR2I> intersections;
176 aIntersections.insert( aIntersections.end(), intersections.begin(), intersections.end() );
180 std::vector<VECTOR2I>& aIntersections )
182 std::vector<VECTOR2I> intersections;
185 for(
const VECTOR2I& intersection : intersections )
187 if( aHalfLine.
Contains( intersection ) )
189 aIntersections.push_back( intersection );
198 std::vector<VECTOR2I>& aIntersections ) :
216 [&](
const auto& otherGeom )
218 using OtherGeomType = std::decay_t<
decltype( otherGeom )>;
220 if constexpr( std::is_same_v<OtherGeomType, BOX2I> )
241 [&](
const auto& otherGeom )
243 using OtherGeomType = std::decay_t<
decltype( otherGeom )>;
245 if constexpr( std::is_same_v<OtherGeomType, SEG>
246 || std::is_same_v<OtherGeomType, LINE>
247 || std::is_same_v<OtherGeomType, CIRCLE>
248 || std::is_same_v<OtherGeomType, SHAPE_ARC> )
253 else if constexpr( std::is_same_v<OtherGeomType, HALF_LINE> )
258 else if constexpr( std::is_same_v<OtherGeomType, BOX2I> )
269 "Unhandled other geometry type" );
279 [&](
const auto& otherGeom )
281 using OtherGeomType = std::decay_t<
decltype( otherGeom )>;
283 if constexpr( std::is_same_v<OtherGeomType, SEG>
284 || std::is_same_v<OtherGeomType, HALF_LINE>
285 || std::is_same_v<OtherGeomType, CIRCLE>
286 || std::is_same_v<OtherGeomType, SHAPE_ARC> )
291 else if constexpr( std::is_same_v<OtherGeomType, LINE> )
296 else if constexpr( std::is_same_v<OtherGeomType, BOX2I> )
307 "Unhandled other geometry type" );
317 [&](
const auto& otherGeom )
319 using OtherGeomType = std::decay_t<
decltype( otherGeom )>;
321 if constexpr( std::is_same_v<OtherGeomType, SEG>
322 || std::is_same_v<OtherGeomType, CIRCLE> )
327 else if constexpr( std::is_same_v<OtherGeomType, SHAPE_ARC>
328 || std::is_same_v<OtherGeomType, LINE>
329 || std::is_same_v<OtherGeomType, HALF_LINE> )
334 else if constexpr( std::is_same_v<OtherGeomType, BOX2I> )
345 "Unhandled other geometry type" );
355 [&](
const auto& otherGeom )
357 using OtherGeomType = std::decay_t<
decltype( otherGeom )>;
359 if constexpr( std::is_same_v<OtherGeomType, SEG>
360 || std::is_same_v<OtherGeomType, CIRCLE>
361 || std::is_same_v<OtherGeomType, SHAPE_ARC> )
366 else if constexpr( std::is_same_v<OtherGeomType, LINE>
367 || std::is_same_v<OtherGeomType, HALF_LINE> )
372 else if constexpr( std::is_same_v<OtherGeomType, BOX2I> )
383 "Unhandled other geometry type" );
398 for(
const SEG& seg : segs )
Represent basic circle geometry with utility geometry functions.
std::vector< VECTOR2I > Intersect(const CIRCLE &aCircle) const
Compute the intersection points between this circle and aCircle.
std::vector< VECTOR2I > IntersectLine(const SEG &aLine) const
Compute the intersection points between this circle and aLine.
OPT_VECTOR2I Intersect(const SEG &aSeg) const
const SEG & GetContainedSeg() const
Gets the (one of the infinite number of) segments that the ray passes through.
bool Contains(const VECTOR2I &aPoint) const
const SEG & GetContainedSeg() const
Gets the (one of the infinite number of) segments that the line passes through.
OPT_VECTOR2I Intersect(const SEG &aOther) const
OPT_VECTOR2I Intersect(const SEG &aSeg, bool aIgnoreEndpoints=false, bool aLines=false) const
Compute intersection point of segment (this) with segment aSeg.
bool Contains(const SEG &aSeg) const
int Intersect(const CIRCLE &aArc, std::vector< VECTOR2I > *aIpsBuffer) const
Find intersection points between this arc and a CIRCLE.
int IntersectLine(const SEG &aSeg, std::vector< VECTOR2I > *aIpsBuffer) const
Find intersection points between this arc and aSeg, treating aSeg as an infinite line.
std::variant< LINE, HALF_LINE, SEG, CIRCLE, SHAPE_ARC, BOX2I > INTERSECTABLE_GEOM
A variant type that can hold any of the supported geometry types for intersection calculations.
std::array< SEG, 4 > BoxToSegs(const BOX2I &aBox)
Decompose a BOX2 into four segments.
std::optional< VECTOR2I > OPT_VECTOR2I
Utility functions for working with shapes.
const INTERSECTABLE_GEOM & m_otherGeometry
INTERSECTION_VISITOR(const INTERSECTABLE_GEOM &aOtherGeometry, std::vector< VECTOR2I > &aIntersections)
std::vector< VECTOR2I > & m_intersections
void operator()(const SEG &aSeg) const
A type that is always false.
VECTOR2< int32_t > VECTOR2I