37void findIntersections(
const SEG& aSegA,
const SEG& aSegB, std::vector<VECTOR2I>& aIntersections )
43 aIntersections.push_back( *intersection );
47void findIntersections(
const SEG& aSeg,
const LINE& aLine, std::vector<VECTOR2I>& aIntersections )
53 aIntersections.push_back( *intersection );
57void findIntersections(
const SEG& aSeg,
const HALF_LINE& aHalfLine,
58 std::vector<VECTOR2I>& aIntersections )
64 aIntersections.push_back( *intersection );
68void findIntersections(
const SEG& aSeg,
const CIRCLE& aCircle,
69 std::vector<VECTOR2I>& aIntersections )
71 std::vector<VECTOR2I> intersections = aCircle.
Intersect( aSeg );
73 aIntersections.insert( aIntersections.end(), intersections.begin(), intersections.end() );
76void findIntersections(
const SEG& aSeg,
const SHAPE_ARC& aArc,
77 std::vector<VECTOR2I>& aIntersections )
79 std::vector<VECTOR2I> intersections;
83 for(
const VECTOR2I& intersection : intersections )
87 aIntersections.emplace_back( intersection );
92void findIntersections(
const LINE& aLineA,
const LINE& aLineB,
93 std::vector<VECTOR2I>& aIntersections )
99 aIntersections.push_back( *intersection );
103void findIntersections(
const LINE& aLine,
const HALF_LINE& aHalfLine,
104 std::vector<VECTOR2I>& aIntersections )
116 if( aHalfLine.
Contains( *intersection ) )
118 aIntersections.push_back( *intersection );
123 std::vector<VECTOR2I>& aIntersections )
129 aIntersections.push_back( *intersection );
133void findIntersections(
const CIRCLE& aCircle,
const LINE& aLine,
134 std::vector<VECTOR2I>& aIntersections )
138 aIntersections.insert( aIntersections.end(), intersections.begin(), intersections.end() );
141void findIntersections(
const CIRCLE& aCircle,
const HALF_LINE& aHalfLine,
142 std::vector<VECTOR2I>& aIntersections )
146 for(
const VECTOR2I& intersection : intersections )
148 if( aHalfLine.
Contains( intersection ) )
150 aIntersections.push_back( intersection );
155void findIntersections(
const CIRCLE& aCircleA,
const CIRCLE& aCircleB,
156 std::vector<VECTOR2I>& aIntersections )
158 std::vector<VECTOR2I> intersections = aCircleA.
Intersect( aCircleB );
159 aIntersections.insert( aIntersections.end(), intersections.begin(), intersections.end() );
163 std::vector<VECTOR2I>& aIntersections )
165 aArc.
Intersect( aCircle, &aIntersections );
169 std::vector<VECTOR2I>& aIntersections )
171 aArcA.
Intersect( aArcB, &aIntersections );
174void findIntersections(
const SHAPE_ARC& aArc,
const LINE& aLine,
175 std::vector<VECTOR2I>& aIntersections )
177 std::vector<VECTOR2I> intersections;
180 aIntersections.insert( aIntersections.end(), intersections.begin(), intersections.end() );
184 std::vector<VECTOR2I>& aIntersections )
186 std::vector<VECTOR2I> intersections;
189 for(
const VECTOR2I& intersection : intersections )
191 if( aHalfLine.
Contains( intersection ) )
193 aIntersections.push_back( intersection );
202 std::vector<VECTOR2I>& aIntersections ) :
203 m_otherGeometry( aOtherGeometry ), m_intersections( aIntersections )
220 [&](
const auto& otherGeom )
222 using OtherGeomType = std::decay_t<
decltype( otherGeom )>;
224 if constexpr( std::is_same_v<OtherGeomType, BOX2I> )
245 [&](
const auto& otherGeom )
247 using OtherGeomType = std::decay_t<
decltype( otherGeom )>;
249 if constexpr( std::is_same_v<OtherGeomType, SEG>
250 || std::is_same_v<OtherGeomType, LINE>
251 || std::is_same_v<OtherGeomType, CIRCLE>
252 || std::is_same_v<OtherGeomType, SHAPE_ARC> )
257 else if constexpr( std::is_same_v<OtherGeomType, HALF_LINE> )
262 else if constexpr( std::is_same_v<OtherGeomType, BOX2I> )
273 "Unhandled other geometry type" );
283 [&](
const auto& otherGeom )
285 using OtherGeomType = std::decay_t<
decltype( otherGeom )>;
287 if constexpr( std::is_same_v<OtherGeomType, SEG>
288 || std::is_same_v<OtherGeomType, HALF_LINE>
289 || std::is_same_v<OtherGeomType, CIRCLE>
290 || std::is_same_v<OtherGeomType, SHAPE_ARC> )
295 else if constexpr( std::is_same_v<OtherGeomType, LINE> )
300 else if constexpr( std::is_same_v<OtherGeomType, BOX2I> )
311 "Unhandled other geometry type" );
321 [&](
const auto& otherGeom )
323 using OtherGeomType = std::decay_t<
decltype( otherGeom )>;
325 if constexpr( std::is_same_v<OtherGeomType, SEG>
326 || std::is_same_v<OtherGeomType, CIRCLE> )
331 else if constexpr( std::is_same_v<OtherGeomType, SHAPE_ARC>
332 || std::is_same_v<OtherGeomType, LINE>
333 || std::is_same_v<OtherGeomType, HALF_LINE> )
338 else if constexpr( std::is_same_v<OtherGeomType, BOX2I> )
349 "Unhandled other geometry type" );
359 [&](
const auto& otherGeom )
361 using OtherGeomType = std::decay_t<
decltype( otherGeom )>;
363 if constexpr( std::is_same_v<OtherGeomType, SEG>
364 || std::is_same_v<OtherGeomType, CIRCLE>
365 || std::is_same_v<OtherGeomType, SHAPE_ARC> )
370 else if constexpr( std::is_same_v<OtherGeomType, LINE>
371 || std::is_same_v<OtherGeomType, HALF_LINE> )
376 else if constexpr( std::is_same_v<OtherGeomType, BOX2I> )
387 "Unhandled other geometry type" );
402 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.