30 std::vector<VECTOR2I>* aIntersectionPoints =
nullptr )
32 SEG segment( p1, p2 );
39 if( aIntersectionPoints )
41 size_t startCount = aIntersectionPoints->size();
44 std::visit( visitor, geom1 );
46 return aIntersectionPoints->size() > startCount;
50 std::vector<VECTOR2I> intersectionPoints;
53 std::visit( visitor, geom1 );
55 return intersectionPoints.size() > 0;
63 std::vector<VECTOR2I>& aIntersectionPoints )
65 if( p1 == p2 || p1 == q2 || q1 == p2 || q1 == q2 )
68 SEG segment1( p1, q1 );
69 SEG segment2( p2, q2 );
74 size_t startCount = aIntersectionPoints.size();
77 std::visit( visitor, geom1 );
79 return aIntersectionPoints.size() > startCount;
94 if( a->
GetType() == CREEP_SHAPE::TYPE::UNDEFINED )
100 if( a->
GetType() == CREEP_SHAPE::TYPE::CIRCLE )
118 if( a->
GetType() == CREEP_SHAPE::TYPE::POINT )
121 if( a->
GetType() == CREEP_SHAPE::TYPE::CIRCLE )
129 double aMaxSquaredWeight )
const
131 std::vector<PATH_CONNECTION>
result;
133 double weight = ( this->
GetPos() - aS2.
GetPos() ).SquaredEuclideanNorm();
135 if( weight > aMaxSquaredWeight )
141 pc.
weight = sqrt( weight );
149 double aMaxSquaredWeight )
const
151 std::vector<PATH_CONNECTION>
result;
159 double pointToCenterDistanceSquared = ( pointPos - circleCenter ).SquaredEuclideanNorm();
160 double weightSquared = pointToCenterDistanceSquared - (float)
radius * (
float)
radius;
162 if( weightSquared > aMaxSquaredWeight )
166 direction1 = direction1.
Resize( 1 );
170 double radiusSquared = double(
radius ) * double(
radius );
172 double distance = sqrt( pointToCenterDistanceSquared );
173 double value1 = radiusSquared /
distance;
174 double value2 = sqrt( radiusSquared - value1 * value1 );
180 pc.
weight = sqrt( weightSquared );
182 resultPoint = direction1 * value1 + direction2 * value2 + circleCenter;
183 pc.
a2.
x = int( resultPoint.
x );
184 pc.
a2.
y = int( resultPoint.
y );
187 resultPoint = direction1 * value1 - direction2 * value2 + circleCenter;
188 pc.
a2.
x = int( resultPoint.
x );
189 pc.
a2.
y = int( resultPoint.
y );
198 std::pair<bool, bool>
result;
215 double pointAngle = testAngle.
AsRadians();
218 bool connectToEndPoint;
220 connectToEndPoint = ( cos( startAngle ) * newPoint.
x + sin( startAngle ) * newPoint.
y >= R );
223 connectToEndPoint &= ( cos( endAngle ) * newPoint.
x + sin( endAngle ) * newPoint.
y <= R );
225 connectToEndPoint |= ( cos( endAngle ) * newPoint.
x + sin( endAngle ) * newPoint.
y <= R )
226 && ( pointAngle >= endAngle || pointAngle <= startAngle );
228 result.first = !connectToEndPoint;
230 connectToEndPoint = ( cos( endAngle ) * newPoint.
x + sin( endAngle ) * newPoint.
y >= R );
233 connectToEndPoint &= ( cos( startAngle ) * newPoint.
x + sin( startAngle ) * newPoint.
y <= R );
235 connectToEndPoint |= ( cos( startAngle ) * newPoint.
x + sin( startAngle ) * newPoint.
y <= R )
236 && ( pointAngle >= endAngle || pointAngle <= startAngle );
238 result.second = !connectToEndPoint;
244 double aMaxSquaredWeight )
const
246 std::vector<PATH_CONNECTION>
result;
252 std::pair<bool, bool> behavesLikeCircle;
255 if( behavesLikeCircle.first && behavesLikeCircle.second )
258 return this->
Paths( csc, aMaxWeight, aMaxSquaredWeight );
261 if( behavesLikeCircle.first )
264 std::vector<PATH_CONNECTION> paths = this->
Paths( csc, aMaxWeight, aMaxSquaredWeight );
266 if( paths.size() > 1 )
267 result.push_back( paths[1] );
277 if( behavesLikeCircle.second )
280 std::vector<PATH_CONNECTION> paths = this->
Paths( csc, aMaxWeight, aMaxSquaredWeight );
282 if( paths.size() > 1 )
283 result.push_back( paths[0] );
297 double aMaxSquaredWeight )
const
299 std::vector<PATH_CONNECTION>
result;
307 double centerDistance = ( circleCenter - arcCenter ).EuclideanNorm();
309 if( centerDistance + arcRadius < circleRadius )
347 double aMaxSquaredWeight )
const
349 std::vector<PATH_CONNECTION>
result;
355 double centerDistance = ( circleCenter - arcCenter ).EuclideanNorm();
357 if( centerDistance + arcRadius < circleRadius )
369 aMaxWeight, aMaxSquaredWeight ) )
378 .
Paths( aS2, aMaxWeight, aMaxSquaredWeight ) )
391 double aMaxSquaredWeight )
const
393 std::vector<PATH_CONNECTION>
result;
398 VECTOR2D distSquared(
double( ( p2 - p1 ).x ),
double( ( p2 - p1 ).y ) );
404 double Rdiff = abs( R1 - R2 );
405 double Rsum = R1 + R2;
408 double weightSquared1 = weightSquared - Rdiff * Rdiff;
410 double weightSquared2 = weightSquared - Rsum * Rsum;
412 if( weightSquared1 <= aMaxSquaredWeight )
415 direction1 = direction1.
Resize( 1 );
418 double D = sqrt( weightSquared );
419 double ratio1 = ( R1 - R2 ) /
D;
420 double ratio2 = sqrt( 1 - ratio1 * ratio1 );
424 pc.
weight = sqrt( weightSquared1 );
426 pc.
a1 = p1 + direction1 * R1 * ratio1 + direction2 * R1 * ratio2;
427 pc.
a2 = p2 + direction1 * R2 * ratio1 + direction2 * R2 * ratio2;
431 pc.
a1 = p1 + direction1 * R1 * ratio1 - direction2 * R1 * ratio2;
432 pc.
a2 = p2 + direction1 * R2 * ratio1 - direction2 * R2 * ratio2;
436 if( weightSquared2 <= aMaxSquaredWeight )
439 direction1 = direction1.
Resize( 1 );
442 double D = sqrt( weightSquared );
443 double ratio1 = ( R1 + R2 ) /
D;
444 double ratio2 = sqrt( 1 - ratio1 * ratio1 );
448 pc.
weight = sqrt( weightSquared2 );
450 pc.
a1 = p1 + direction1 * R1 * ratio1 + direction2 * R1 * ratio2;
451 pc.
a2 = p2 - direction1 * R2 * ratio1 - direction2 * R2 * ratio2;
455 pc.
a1 = p1 + direction1 * R1 * ratio1 - direction2 * R1 * ratio2;
456 pc.
a2 = p2 - direction1 * R2 * ratio1 + direction2 * R2 * ratio2;
472 switch( p1->GetType() )
474 case CREEP_SHAPE::TYPE::POINT:
AddNode( GRAPH_NODE::TYPE::POINT, p1, p1->GetPos() );
break;
475 case CREEP_SHAPE::TYPE::CIRCLE:
AddNode( GRAPH_NODE::TYPE::CIRCLE, p1, p1->GetPos() );
break;
476 case CREEP_SHAPE::TYPE::ARC:
AddNode( GRAPH_NODE::TYPE::ARC, p1, p1->GetPos() );
break;
486 std::vector<CREEP_SHAPE*> newVector;
545 std::vector<VECTOR2I> points;
548 for(
auto p : points )
566 double tolerance = 10;
595 if(
n1->m_type == GRAPH_NODE::TYPE::VIRTUAL ||
n2->m_type == GRAPH_NODE::TYPE::VIRTUAL )
599 &&
n1->m_parent ==
n2->m_parent
600 &&
n1->m_parent->GetType() == CREEP_SHAPE::TYPE::CIRCLE )
607 if( R1.
Cross( R2 ) > 0 )
619 aShapes.push_back( s );
624 &&
n1->m_parent ==
n2->m_parent
625 &&
n1->m_parent->GetType() == CREEP_SHAPE::TYPE::ARC )
634 if( R1.
Cross( R2 ) > 0 )
649 EDA_ANGLE midAngle = arc->AngleBetweenStartAndEnd( mid );
651 if( midAngle > arc->GetEndAngle() )
660 aShapes.push_back( s );
668 aShapes.push_back( s );
699 EDA_ANGLE maxAngle = angle1 > angle2 ? angle1 : angle2;
702 skipAngle += skipAngle;
703 EDA_ANGLE pointAngle = maxAngle - skipAngle;
713 pc.
a1 = maxAngle == angle2 ? a1->m_pos : a2->m_pos;
719 pc.
a2 = maxAngle == angle2 ? a2->m_pos : a1->m_pos;
722 std::shared_ptr<GRAPH_CONNECTION> gc = aG.
AddConnection( gnt, maxAngle == angle2 ? a2 : a1, pc );
725 gc->m_forceStraightLine =
true;
738 VECTOR2D distI( a1->m_pos - a2->m_pos );
739 VECTOR2D distD(
double( distI.
x ),
double( distI.
y ) );
751 pc.
weight = std::max( weight, 0.0 );
772 double weight = abs(
m_radius * ( angle2 - angle1 ).AsRadians() );
801 double aMaxSquaredWeight )
const
803 std::vector<PATH_CONNECTION>
result;
806 double halfWidth = this->
GetWidth() / 2;
810 double length = ( start -
end ).EuclideanNorm();
811 double projectedPos = cos( trackAngle.
AsRadians() ) * ( pointPos.
x - start.
x )
812 + sin( trackAngle.
AsRadians() ) * ( pointPos.
y - start.
y );
816 if( projectedPos <= 0 )
818 newPoint = start + ( pointPos - start ).Resize( halfWidth );
820 else if( projectedPos >= length )
822 newPoint =
end + ( pointPos -
end ).Resize( halfWidth );
826 double posOnSegment = ( start - pointPos ).SquaredEuclideanNorm()
827 - (
end - pointPos ).SquaredEuclideanNorm();
828 posOnSegment = posOnSegment / ( 2 * length ) + length / 2;
830 newPoint = start + (
end - start ).Resize( posOnSegment );
831 newPoint += ( pointPos - newPoint ).Resize( halfWidth );
834 double weightSquared = ( pointPos - newPoint ).SquaredEuclideanNorm();
836 if( weightSquared > aMaxSquaredWeight )
842 pc.
weight = sqrt( weightSquared );
850 double aMaxSquaredWeight )
const
852 std::vector<PATH_CONNECTION>
result;
855 double halfWidth = this->
GetWidth() / 2;
859 double length = ( start -
end ).EuclideanNorm();
862 double weightSquared = std::numeric_limits<double>::infinity();
863 VECTOR2I PointOnTrack, PointOnCircle;
867 double projectedPos1 = cos( trackAngle.
AsRadians() ) * ( circleCenter.
x - start.
x )
868 + sin( trackAngle.
AsRadians() ) * ( circleCenter.
y - start.
y );
869 double projectedPos2 = projectedPos1 + circleRadius;
870 projectedPos1 = projectedPos1 - circleRadius;
872 double trackSide = (
end - start ).Cross( circleCenter - start ) > 0 ? 1 : -1;
874 if( ( projectedPos1 < 0 && projectedPos2 < 0 ) )
882 else if( ( projectedPos1 > length && projectedPos2 > length ) )
890 else if( ( projectedPos1 >= 0 ) && ( projectedPos1 <= length ) && ( projectedPos2 >= 0 )
891 && ( projectedPos2 <= length ) )
894 PointOnTrack = start;
895 PointOnTrack += (
end - start ).Resize( projectedPos1 );
896 PointOnTrack += (
end - start ).Perpendicular().
Resize( halfWidth ) * trackSide;
897 PointOnCircle = circleCenter - (
end - start ).Resize( circleRadius );
898 weightSquared = ( PointOnCircle - PointOnTrack ).SquaredEuclideanNorm();
900 if( weightSquared < aMaxSquaredWeight )
903 pc.
a1 = PointOnTrack;
904 pc.
a2 = PointOnCircle;
905 pc.
weight = sqrt( weightSquared );
909 PointOnTrack = start;
910 PointOnTrack += (
end - start ).Resize( projectedPos2 );
911 PointOnTrack += (
end - start ).Perpendicular().
Resize( halfWidth ) * trackSide;
912 PointOnCircle = circleCenter + (
end - start ).Resize( circleRadius );
915 pc.
a1 = PointOnTrack;
916 pc.
a2 = PointOnCircle;
921 else if( ( ( projectedPos1 >= 0 ) && ( projectedPos1 <= length ) )
922 && ( ( projectedPos2 > length ) || projectedPos2 < 0 ) )
925 std::vector<PATH_CONNECTION> pcs = csc.
Paths( aS2, aMaxWeight, aMaxSquaredWeight );
930 result.push_back( pcs.at( trackSide == 1 ? 1 : 0 ) );
933 PointOnTrack = start;
934 PointOnTrack += (
end - start ).Resize( projectedPos1 );
935 PointOnTrack += (
end - start ).Perpendicular().
Resize( halfWidth ) * trackSide;
936 PointOnCircle = circleCenter - (
end - start ).Resize( circleRadius );
937 weightSquared = ( PointOnCircle - PointOnTrack ).SquaredEuclideanNorm();
939 if( weightSquared < aMaxSquaredWeight )
942 pc.
a1 = PointOnTrack;
943 pc.
a2 = PointOnCircle;
944 pc.
weight = sqrt( weightSquared );
949 else if( ( ( projectedPos2 >= 0 ) && ( projectedPos2 <= length ) )
950 && ( ( projectedPos1 > length ) || projectedPos1 < 0 ) )
953 std::vector<PATH_CONNECTION> pcs = csc.
Paths( aS2, aMaxWeight, aMaxSquaredWeight );
958 result.push_back( pcs.at( trackSide == 1 ? 0 : 1 ) );
960 PointOnTrack = start;
961 PointOnTrack += (
end - start ).Resize( projectedPos2 );
962 PointOnTrack += (
end - start ).Perpendicular().
Resize( halfWidth ) * trackSide;
963 PointOnCircle = circleCenter + (
end - start ).Resize( circleRadius );
964 weightSquared = ( PointOnCircle - PointOnTrack ).SquaredEuclideanNorm();
966 if( weightSquared < aMaxSquaredWeight )
969 pc.
a1 = PointOnTrack;
970 pc.
a2 = PointOnCircle;
971 pc.
weight = sqrt( weightSquared );
982 double aMaxSquaredWeight )
const
984 std::vector<PATH_CONNECTION>
result;
1008 if( !
segmentIntersectsArc( pc.a1, pc.a2, beArcPos, beArcRadius, beArcStartAngle, beArcEndAngle ) )
1014 if( !
segmentIntersectsArc( pc.a1, pc.a2, beArcPos, beArcRadius, beArcStartAngle, beArcEndAngle ) )
1024 double aMaxSquaredWeight )
const
1026 std::vector<PATH_CONNECTION>
result;
1049 if( !
segmentIntersectsArc( pc.a1, pc.a2, beArcPos, beArcRadius, beArcStartAngle, beArcEndAngle ) )
1055 if( !
segmentIntersectsArc( pc.a1, pc.a2, beArcPos, beArcRadius, beArcStartAngle, beArcEndAngle ) )
1065 double aMaxSquaredWeight )
const
1067 std::vector<PATH_CONNECTION>
result;
1096 double aMaxSquaredWeight )
const
1098 std::vector<PATH_CONNECTION>
result;
1121 if( !
segmentIntersectsArc( pc.a1, pc.a2, beArcPos, beArcRadius, beArcStartAngle, beArcEndAngle ) )
1127 if( !
segmentIntersectsArc( pc.a1, pc.a2, beArcPos, beArcRadius, beArcStartAngle, beArcEndAngle ) )
1137 double aMaxSquaredWeight )
const
1139 std::vector<PATH_CONNECTION>
result;
1144 double weight = (
center - point ).EuclideanNorm() - R;
1146 if( weight > aMaxWeight )
1150 pc.
weight = std::max( weight, 0.0 );
1160 double aMaxSquaredWeight )
const
1162 std::vector<PATH_CONNECTION>
result;
1169 if( ( C1 - C2 ).SquaredEuclideanNorm() < ( R1 - R2 ) * ( R1 - R2 ) )
1175 double weight = ( C1 - C2 ).EuclideanNorm() - R1 - R2;
1177 if( weight > aMaxWeight || weight < 0 )
1181 pc.
weight = std::max( weight, 0.0 );
1182 pc.
a1 = ( C2 - C1 ).Resize( R1 ) + C1;
1183 pc.
a2 = ( C1 - C2 ).Resize( R2 ) + C2;
1190 double aMaxSquaredWeight )
const
1192 std::vector<PATH_CONNECTION>
result;
1196 double halfWidth = this->
GetWidth() / 2;
1198 EDA_ANGLE trackAngle( s_end - s_start );
1201 double length = ( s_start - s_end ).EuclideanNorm();
1202 double projectedPos = cos( trackAngle.
AsRadians() ) * ( pointPos.
x - s_start.
x )
1203 + sin( trackAngle.
AsRadians() ) * ( pointPos.
y - s_start.
y );
1205 if( ( projectedPos <= 0 ) || ( s_start == s_end ) )
1208 return csc.
Paths( aS2, aMaxWeight, aMaxSquaredWeight );
1211 if( projectedPos >= length )
1214 return csc.
Paths( aS2, aMaxWeight, aMaxSquaredWeight );
1218 double trackSide = ( s_end - s_start ).Cross( pointPos - s_start ) > 0 ? 1 : -1;
1221 pc.
a1 = s_start + ( s_end - s_start ).Resize( projectedPos )
1222 + ( s_end - s_start ).Perpendicular().
Resize( halfWidth ) * trackSide;
1223 pc.
a2 = ( pc.
a1 - pointPos ).Resize(
radius ) + pointPos;
1224 pc.
weight = ( pc.
a2 - pc.
a1 ).SquaredEuclideanNorm();
1226 if( pc.
weight <= aMaxSquaredWeight )
1237 double aMaxSquaredWeight )
const
1239 std::vector<PATH_CONNECTION>
result;
1244 double circleRadius = this->
GetRadius();
1252 if( ( circlePos - arcPos ).EuclideanNorm() > arcRadius + circleRadius )
1254 const std::vector<PATH_CONNECTION>& pcs = this->
Paths( csc, aMaxWeight, aMaxSquaredWeight );
1256 if( pcs.size() == 1 )
1262 result.push_back( pcs[0] );
1274 std::vector<PATH_CONNECTION> pcs1 = this->
Paths( csc1, aMaxWeight, aMaxSquaredWeight );
1275 std::vector<PATH_CONNECTION> pcs2 = this->
Paths( csc2, aMaxWeight, aMaxSquaredWeight );
1279 if( !bestPath || ( ( bestPath->
weight > pc.weight ) && ( pc.weight > 0 ) ) )
1285 if( !bestPath || ( ( bestPath->
weight > pc.weight ) && ( pc.weight > 0 ) ) )
1293 if( ( circlePos - arcPos ).SquaredEuclideanNorm() < arcRadius * arcRadius )
1295 if( circlePos != arcPos )
1301 pc3.
weight = std::max( arcRadius - ( circlePos - arcPos ).EuclideanNorm() - circleRadius, 0.0 );
1302 pc3.
a1 = circlePos + ( circlePos - arcPos ).Resize( circleRadius );
1303 pc3.
a2 = arcPos + ( circlePos - arcPos ).Resize( arcRadius - aS2.
GetWidth() / 2 );
1311 if( bestPath && bestPath->
weight > 0 )
1313 result.push_back( *bestPath );
1321 double aMaxSquaredWeight )
const
1323 std::vector<PATH_CONNECTION>
result;
1327 double halfWidth1 = this->
GetWidth() / 2;
1331 double halfWidth2 = aS2.
GetWidth() / 2;
1336 std::vector<PATH_CONNECTION> pcs;
1337 pcs = this->
Paths( csc, aMaxWeight, aMaxSquaredWeight );
1339 if( pcs.size() < 1 )
1345 if( pcs.size() > 0 )
1347 circlePoint = pcs[0].a1;
1351 if( testAngle < aS2.
GetEndAngle() && pcs.size() > 0 )
1353 result.push_back( pcs[0] );
1363 if( !bestPath || ( bestPath->
weight > pc.weight ) )
1369 if( !bestPath || ( bestPath->
weight > pc.weight ) )
1378 if( !bestPath || ( bestPath->
weight > pc.weight ) )
1385 if( !bestPath || ( bestPath->
weight > pc.weight ) )
1390 result.push_back( *bestPath );
1409 t = std::max( 0.0, std::min( 1.0, t ) );
1411 return A + ( AB * t );
1417 double aMaxSquaredWeight )
const
1419 std::vector<PATH_CONNECTION>
result;
1423 double halfWidth1 = this->
GetWidth() / 2;
1428 double halfWidth2 = aS2.
GetWidth() / 2;
1436 double dist1 = ( P1 -
C ).SquaredEuclideanNorm();
1437 double dist2 = ( P2 -
D ).SquaredEuclideanNorm();
1438 double dist3 = ( P3 -
A ).SquaredEuclideanNorm();
1439 double dist4 = ( P4 -
B ).SquaredEuclideanNorm();
1442 double min_dist = dist1;
1446 if( dist2 < min_dist )
1453 if( dist3 < min_dist )
1460 if( dist4 < min_dist )
1469 pc.
a1 = closest1 + ( closest2 - closest1 ).Resize( halfWidth1 );
1470 pc.
a2 = closest2 + ( closest1 - closest2 ).Resize( halfWidth2 );
1471 pc.
weight = std::max( sqrt( min_dist ) - halfWidth1 - halfWidth2, 0.0 );
1473 if( pc.
weight <= aMaxWeight )
1481 double aMaxSquaredWeight )
const
1483 std::vector<PATH_CONNECTION>
result;
1489 double dist = ( center1 - center2 ).EuclideanNorm();
1491 if( dist > aMaxWeight || dist == 0 )
1494 double weight = sqrt( dist * dist - R2 * R2 ) - R1;
1495 double theta = asin( R2 / dist );
1496 double psi = acos( R2 / dist );
1498 if( weight > aMaxWeight )
1502 pc.
weight = std::max( weight, 0.0 );
1509 pStart =
VECTOR2I( R1 * cos( theta + circleAngle ), R1 * sin( theta + circleAngle ) );
1511 pEnd =
VECTOR2I( -R2 * cos( psi - circleAngle ), R2 * sin( psi - circleAngle ) );
1518 pStart =
VECTOR2I( R1 * cos( -theta + circleAngle ), R1 * sin( -theta + circleAngle ) );
1520 pEnd =
VECTOR2I( -R2 * cos( -psi - circleAngle ), R2 * sin( -psi - circleAngle ) );
1532 double aMaxSquaredWeight )
const
1534 std::vector<PATH_CONNECTION>
result;
1550 if( ( point - arcCenter ).SquaredEuclideanNorm() >
radius *
radius )
1553 return circle.Paths( aS2, aMaxWeight, aMaxSquaredWeight );
1558 pc.
weight = std::max( (
radius - width / 2 ) - ( point - arcCenter ).EuclideanNorm(), 0.0 );
1559 pc.
a1 = ( point - arcCenter ).Resize(
radius - width / 2 ) + arcCenter;
1572 if( ( point - this->
GetStartPoint() ).SquaredEuclideanNorm()
1573 > ( point - this->
GetEndPoint() ).SquaredEuclideanNorm() )
1583 return circle.Paths( aS2, aMaxWeight, aMaxSquaredWeight );
1591 double aMaxSquaredWeight )
const
1593 std::vector<PATH_CONNECTION>
result;
1602 bestPath.
weight = std::numeric_limits<double>::infinity();
1611 for(
const std::vector<PATH_CONNECTION>& pcs : { csc1.
Paths( csc2, aMaxWeight, aMaxSquaredWeight ),
1612 this->
Paths( csc2, aMaxWeight, aMaxSquaredWeight ),
1613 csc1.
Paths( aS2, aMaxWeight, aMaxSquaredWeight ) } )
1625 for(
const std::vector<PATH_CONNECTION>& pcs : { this->
Paths( csc5, aMaxWeight, aMaxSquaredWeight ),
1626 this->
Paths( csc6, aMaxWeight, aMaxSquaredWeight ),
1627 csc3.
Paths( aS2, aMaxWeight, aMaxSquaredWeight ),
1628 csc4.
Paths( aS2, aMaxWeight, aMaxSquaredWeight ) } )
1632 if( bestPath.
weight > pc.weight )
1637 if( bestPath.
weight != std::numeric_limits<double>::infinity() )
1638 result.push_back( bestPath );
1645 std::vector<VECTOR2I>* aIntersectPoints )
1647 SEG segment( p1, p2 );
1650 std::vector<VECTOR2I> intersectionPoints;
1655 std::visit( visitor, geom1 );
1657 if( aIntersectPoints )
1659 for(
VECTOR2I& point : intersectionPoints )
1660 aIntersectPoints->push_back( point );
1663 return intersectionPoints.size() > 0;
1667 const std::vector<BOARD_ITEM*>& aBe,
1668 const std::vector<const BOARD_ITEM*>& aDontTestAgainst,
1669 int aMinGrooveWidth )
1671 std::vector<VECTOR2I> intersectionPoints;
1672 bool TestGrooveWidth = aMinGrooveWidth > 0;
1676 if( count( aDontTestAgainst.begin(), aDontTestAgainst.end(), be ) > 0 )
1688 intersectionPoints );
1690 if( intersects && !TestGrooveWidth )
1703 bool intersects =
false;
1709 if( intersects && !TestGrooveWidth )
1717 std::vector<VECTOR2I> points;
1720 if( points.size() < 2 )
1723 VECTOR2I prevPoint = points.back();
1725 bool intersects =
false;
1733 if( intersects && !TestGrooveWidth )
1746 if( intersects && !TestGrooveWidth )
1762 if( intersects && !TestGrooveWidth )
1773 if( intersectionPoints.size() <= 0 )
1776 if( intersectionPoints.size() % 2 != 0 )
1779 int minx = intersectionPoints[0].x;
1780 int maxx = intersectionPoints[0].x;
1781 int miny = intersectionPoints[0].y;
1782 int maxy = intersectionPoints[0].y;
1784 for(
const VECTOR2I& v : intersectionPoints )
1786 minx = v.x < minx ? v.x : minx;
1787 maxx = v.x > maxx ? v.x : maxx;
1788 miny = v.x < miny ? v.x : miny;
1789 maxy = v.x > maxy ? v.x : maxy;
1792 if( abs( maxx - minx ) > abs( maxy - miny ) )
1794 std::sort( intersectionPoints.begin(), intersectionPoints.end(),
1802 std::sort( intersectionPoints.begin(), intersectionPoints.end(),
1809 int GVSquared = aMinGrooveWidth * aMinGrooveWidth;
1811 for(
size_t i = 0; i < intersectionPoints.size(); i += 2 )
1813 if( intersectionPoints[i].SquaredDistance( intersectionPoints[i + 1] ) > GVSquared )
1823 double maxWeight = aMaxWeight;
1824 double maxWeightSquared = maxWeight * maxWeight;
1825 std::vector<PATH_CONNECTION>
result;
1844 if( cuarc1 && cuarc2 )
1845 return cuarc1->
Paths( *cuarc2, maxWeight, maxWeightSquared );
1846 if( cuarc1 && cucircle2 )
1847 return cuarc1->
Paths( *cucircle2, maxWeight, maxWeightSquared );
1848 if( cuarc1 && cusegment2 )
1849 return cuarc1->
Paths( *cusegment2, maxWeight, maxWeightSquared );
1850 if( cucircle1 && cuarc2 )
1851 return cucircle1->
Paths( *cuarc2, maxWeight, maxWeightSquared );
1852 if( cucircle1 && cucircle2 )
1853 return cucircle1->
Paths( *cucircle2, maxWeight, maxWeightSquared );
1854 if( cucircle1 && cusegment2 )
1855 return cucircle1->
Paths( *cusegment2, maxWeight, maxWeightSquared );
1856 if( cusegment1 && cuarc2 )
1857 return cusegment1->
Paths( *cuarc2, maxWeight, maxWeightSquared );
1858 if( cusegment1 && cucircle2 )
1859 return cusegment1->
Paths( *cucircle2, maxWeight, maxWeightSquared );
1860 if( cusegment1 && cusegment2 )
1861 return cusegment1->
Paths( *cusegment2, maxWeight, maxWeightSquared );
1866 if( cuarc1 && bearc2 )
1867 return cuarc1->
Paths( *bearc2, maxWeight, maxWeightSquared );
1868 if( cuarc1 && becircle2 )
1869 return cuarc1->
Paths( *becircle2, maxWeight, maxWeightSquared );
1870 if( cuarc1 && bepoint2 )
1871 return cuarc1->
Paths( *bepoint2, maxWeight, maxWeightSquared );
1872 if( cucircle1 && bearc2 )
1873 return cucircle1->
Paths( *bearc2, maxWeight, maxWeightSquared );
1874 if( cucircle1 && becircle2 )
1875 return cucircle1->
Paths( *becircle2, maxWeight, maxWeightSquared );
1876 if( cucircle1 && bepoint2 )
1877 return cucircle1->
Paths( *bepoint2, maxWeight, maxWeightSquared );
1878 if( cusegment1 && bearc2 )
1879 return cusegment1->
Paths( *bearc2, maxWeight, maxWeightSquared );
1880 if( cusegment1 && becircle2 )
1881 return cusegment1->
Paths( *becircle2, maxWeight, maxWeightSquared );
1882 if( cusegment1 && bepoint2 )
1883 return cusegment1->
Paths( *bepoint2, maxWeight, maxWeightSquared );
1887 if( cuarc2 && bearc1 )
1888 return bearc1->
Paths( *cuarc2, maxWeight, maxWeightSquared );
1889 if( cuarc2 && becircle1 )
1890 return becircle1->
Paths( *cuarc2, maxWeight, maxWeightSquared );
1891 if( cuarc2 && bepoint1 )
1892 return bepoint1->
Paths( *cuarc2, maxWeight, maxWeightSquared );
1893 if( cucircle2 && bearc1 )
1894 return bearc1->
Paths( *cucircle2, maxWeight, maxWeightSquared );
1895 if( cucircle2 && becircle1 )
1896 return becircle1->
Paths( *cucircle2, maxWeight, maxWeightSquared );
1897 if( cucircle2 && bepoint1 )
1898 return bepoint1->
Paths( *cucircle2, maxWeight, maxWeightSquared );
1899 if( cusegment2 && bearc1 )
1900 return bearc1->
Paths( *cusegment2, maxWeight, maxWeightSquared );
1901 if( cusegment2 && becircle1 )
1902 return becircle1->
Paths( *cusegment2, maxWeight, maxWeightSquared );
1903 if( cusegment2 && bepoint1 )
1904 return bepoint1->
Paths( *cusegment2, maxWeight, maxWeightSquared );
1909 if( bearc1 && bearc2 )
1910 return bearc1->
Paths( *bearc2, maxWeight, maxWeightSquared );
1911 if( bearc1 && becircle2 )
1912 return bearc1->
Paths( *becircle2, maxWeight, maxWeightSquared );
1913 if( bearc1 && bepoint2 )
1914 return bearc1->
Paths( *bepoint2, maxWeight, maxWeightSquared );
1915 if( becircle1 && bearc2 )
1916 return becircle1->
Paths( *bearc2, maxWeight, maxWeightSquared );
1917 if( becircle1 && becircle2 )
1918 return becircle1->
Paths( *becircle2, maxWeight, maxWeightSquared );
1919 if( becircle1 && bepoint2 )
1920 return becircle1->
Paths( *bepoint2, maxWeight, maxWeightSquared );
1921 if( bepoint1 && bearc2 )
1922 return bepoint1->
Paths( *bearc2, maxWeight, maxWeightSquared );
1923 if( bepoint1 && becircle2 )
1924 return bepoint1->
Paths( *becircle2, maxWeight, maxWeightSquared );
1925 if( bepoint1 && bepoint2 )
1926 return bepoint1->
Paths( *bepoint2, maxWeight, maxWeightSquared );
1932 std::vector<std::shared_ptr<GRAPH_CONNECTION>>& aResult )
1934 if( !aFrom || !aTo )
1941 std::unordered_map<GRAPH_NODE*, double> distances;
1942 std::unordered_map<GRAPH_NODE*, GRAPH_NODE*> previous;
1946 double distLeft = distances[
left];
1947 double distRight = distances[
right];
1949 if( distLeft == distRight )
1951 return distLeft > distRight;
1953 std::priority_queue<GRAPH_NODE*, std::vector<GRAPH_NODE*>,
decltype( cmp )> pq( cmp );
1956 for(
const std::shared_ptr<GRAPH_NODE>& node :
m_nodes )
1958 if( node !=
nullptr )
1959 distances[node.get()] = std::numeric_limits<double>::infinity();
1962 distances[aFrom.get()] = 0.0;
1963 distances[aTo.get()] = std::numeric_limits<double>::infinity();
1964 pq.push( aFrom.get() );
1967 while( !pq.empty() )
1972 if( current == aTo.get() )
1978 for(
const std::shared_ptr<GRAPH_CONNECTION>& connection : current->
m_node_conns )
1980 GRAPH_NODE* neighbor = ( connection->n1 ).get() == current ? ( connection->n2 ).get()
1981 : ( connection->n1 ).get();
1987 if( connection->m_path.weight < 0.0 )
1989 wxLogTrace(
"CREEPAGE",
"Negative weight connection found. Ignoring connection." );
1993 double alt = distances[current] + connection->m_path.weight;
1995 if( alt < distances[neighbor] )
1997 distances[neighbor] = alt;
1998 previous[neighbor] = current;
1999 pq.push( neighbor );
2004 double pathWeight = distances[aTo.get()];
2007 if( pathWeight == std::numeric_limits<double>::infinity() )
2008 return std::numeric_limits<double>::infinity();
2013 while( step != aFrom.get() )
2017 for(
const std::shared_ptr<GRAPH_CONNECTION>& node_conn : step->
m_node_conns )
2019 if( ( ( node_conn->n1 ).get() == prevNode && ( node_conn->n2 ).get() == step )
2020 || ( ( node_conn->n1 ).get() == step && ( node_conn->n2 ).get() == prevNode ) )
2022 aResult.push_back( node_conn );
2040 switch( aShape.
Type() )
2054 newshape =
dynamic_cast<CREEP_SHAPE*
>( cucircle );
2068 start = arc.
GetP0();
2074 start = arc.
GetP1();
2088 int nbShapes =
static_cast<const SHAPE_COMPOUND*
>( &aShape )->Shapes().size();
2089 for(
const SHAPE* subshape : (
static_cast<const SHAPE_COMPOUND*
>( &aShape )->Shapes() ) )
2094 if( !( ( subshape->Type() ==
SH_RECT ) && ( nbShapes == 5 ) ) )
2095 Addshape( *subshape, aConnectTo, aParent );
2106 const SEG object = *it;
2108 Addshape( segment, aConnectTo, aParent );
2122 Addshape( segment, aConnectTo, aParent );
2148 std::shared_ptr<GRAPH_NODE> gnShape =
nullptr;
2152 switch( aShape.
Type() )
2163 gnShape->m_net = aConnectTo->m_net;
2164 std::shared_ptr<GRAPH_CONNECTION> gc =
AddConnection( gnShape, aConnectTo );
2167 gc->m_path.m_show =
false;
2178 std::vector<std::shared_ptr<GRAPH_NODE>> nodes;
2179 std::mutex nodes_lock;
2182 std::copy_if(
m_nodes.begin(),
m_nodes.end(), std::back_inserter( nodes ),
2183 [&](
const std::shared_ptr<GRAPH_NODE>& gn )
2185 return gn && gn->m_parent && gn->m_connectDirectly && ( gn->m_type != GRAPH_NODE::TYPE::VIRTUAL );
2188 std::sort( nodes.begin(), nodes.end(),
2189 [](
const std::shared_ptr<GRAPH_NODE>& gn1,
const std::shared_ptr<GRAPH_NODE>& gn2 )
2191 return gn1->m_parent < gn2->m_parent
2192 || ( gn1->m_parent == gn2->m_parent && gn1->m_net < gn2->m_net );
2196 std::unordered_map<const BOARD_ITEM*, std::unordered_map<int, std::vector<std::shared_ptr<GRAPH_NODE>>>> parent_net_groups;
2197 std::vector<const BOARD_ITEM*> parent_keys;
2199 for(
const auto& gn : nodes )
2201 const BOARD_ITEM* parent = gn->m_parent->GetParent();
2203 if( parent_net_groups[parent].
empty() )
2204 parent_keys.push_back( parent );
2206 parent_net_groups[parent][gn->m_net].push_back( gn );
2210 std::vector<std::pair<std::shared_ptr<GRAPH_NODE>, std::shared_ptr<GRAPH_NODE>>> work_items;
2212 for(
size_t i = 0; i < parent_keys.size(); ++i )
2214 for(
size_t j = i + 1; j < parent_keys.size(); ++j )
2216 const auto& group1_nets = parent_net_groups[parent_keys[i]];
2217 const auto& group2_nets = parent_net_groups[parent_keys[j]];
2219 for(
const auto& [net1, nodes1] : group1_nets )
2221 for(
const auto& [net2, nodes2] : group2_nets )
2226 bool all_conductive_1 = std::all_of( nodes1.begin(), nodes1.end(),
2229 return n->m_parent->IsConductive();
2232 bool all_conductive_2 = std::all_of( nodes2.begin(), nodes2.end(),
2235 return n->m_parent->IsConductive();
2238 if( all_conductive_1 && all_conductive_2 )
2243 for(
const auto& gn1 : nodes1 )
2245 for(
const auto& gn2 : nodes2 )
2246 work_items.push_back( { gn1, gn2 } );
2253 auto processWorkItems =
2254 [&](
size_t idx ) ->
bool
2256 auto& [gn1, gn2] = work_items[idx];
2260 std::vector<const BOARD_ITEM*> IgnoreForTest =
2262 gn1->m_parent->GetParent(), gn2->m_parent->GetParent()
2271 std::shared_ptr<GRAPH_NODE> connect1 = gn1, connect2 = gn2;
2272 std::lock_guard<std::mutex> lock( nodes_lock );
2275 if( gn1->m_parent->GetType() != CREEP_SHAPE::TYPE::POINT )
2278 gnt1->m_connectDirectly =
false;
2281 if( gn1->m_parent->IsConductive() )
2283 if( std::shared_ptr<GRAPH_CONNECTION> gc =
AddConnection( gn1, gnt1 ) )
2284 gc->m_path.m_show =
false;
2289 if( gn2->m_parent->GetType() != CREEP_SHAPE::TYPE::POINT )
2292 gnt2->m_connectDirectly =
false;
2295 if( gn2->m_parent->IsConductive() )
2297 if( std::shared_ptr<GRAPH_CONNECTION> gc =
AddConnection( gn2, gnt2 ) )
2298 gc->m_path.m_show =
false;
2310 if(
tp.get_tasks_total() >=
tp.get_thread_count() - 4 )
2312 for(
size_t ii = 0; ii < work_items.size(); ii++ )
2313 processWorkItems( ii );
2317 auto ret =
tp.submit_loop( 0, work_items.size(), processWorkItems );
2319 for(
size_t ii = 0; ii < ret.size(); ii++ )
2326 while( r.wait_for( std::chrono::milliseconds( 100 ) ) != std::future_status::ready ){}
2334 std::vector<std::shared_ptr<GRAPH_CONNECTION>> toRemove;
2337 for( std::shared_ptr<GRAPH_CONNECTION>& gc :
m_connections )
2339 if( gc && ( gc->m_path.weight > aWeightLimit ) )
2340 toRemove.push_back( gc );
2344 for(
const std::shared_ptr<GRAPH_CONNECTION>& gc : toRemove )
2354 for( std::shared_ptr<GRAPH_NODE> gn : { aGc->n1, aGc->n2 } )
2358 gn->m_node_conns.erase( aGc );
2360 if( gn->m_node_conns.empty() && aDelete )
2363 [&gn](
const std::shared_ptr<GRAPH_NODE>& node )
2365 return node.get() == gn.get();
2388 std::shared_ptr<GRAPH_NODE> gn =
FindNode( aType, parent, pos );
2393 gn = std::make_shared<GRAPH_NODE>( aType, parent, pos );
2403 std::shared_ptr<GRAPH_NODE> gn = std::make_shared<GRAPH_NODE>( GRAPH_NODE::TYPE::VIRTUAL,
nullptr );
2411 std::shared_ptr<GRAPH_NODE>& aN2,
2417 wxASSERT_MSG( ( aN1 != aN2 ),
"Creepage: a connection connects a node to itself" );
2419 std::shared_ptr<GRAPH_CONNECTION> gc = std::make_shared<GRAPH_CONNECTION>( aN1, aN2, aPc );
2421 aN1->m_node_conns.insert( gc );
2422 aN2->m_node_conns.insert( gc );
2429 std::shared_ptr<GRAPH_NODE>& aN2 )
2446 auto it =
m_nodeset.find( std::make_shared<GRAPH_NODE>( aType, aParent, aPos ) );
2459 virtualNode->m_net = aNetCode;
2463 for(
PAD*
pad : footprint->Pads() )
2465 if(
pad->GetNetCode() != aNetCode || !
pad->IsOnLayer( aLayer ) )
2468 if( std::shared_ptr<SHAPE> padShape =
pad->GetEffectiveShape( aLayer ) )
2475 if( track->GetNetCode() != aNetCode || !track->IsOnLayer( aLayer ) )
2478 if( std::shared_ptr<SHAPE> shape = track->GetEffectiveShape() )
2479 Addshape( *shape, virtualNode, track );
2485 if( zone->GetNetCode() != aNetCode || !zone->IsOnLayer( aLayer ) )
2488 if( std::shared_ptr<SHAPE> shape = zone->GetEffectiveShape( aLayer ) )
2489 Addshape( *shape, virtualNode, zone );
2492 const DRAWINGS drawings =
m_board.Drawings();
2496 if( drawing->IsConnected() )
2504 Addshape( *shape, virtualNode, bci );
Creepage: a board edge arc.
std::pair< bool, bool > IsThereATangentPassingThroughPoint(const BE_SHAPE_POINT aPoint) const
EDA_ANGLE GetStartAngle() const override
int GetRadius() const override
BE_SHAPE_ARC(VECTOR2I aPos, int aRadius, EDA_ANGLE aStartAngle, EDA_ANGLE aEndAngle, VECTOR2D aStartPoint, VECTOR2D aEndPoint)
VECTOR2I GetStartPoint() const override
std::vector< PATH_CONNECTION > Paths(const BE_SHAPE_POINT &aS2, double aMaxWeight, double aMaxSquaredWeight) const override
void ConnectChildren(std::shared_ptr< GRAPH_NODE > &a1, std::shared_ptr< GRAPH_NODE > &a2, CREEPAGE_GRAPH &aG) const override
EDA_ANGLE GetEndAngle() const override
VECTOR2I GetEndPoint() const override
EDA_ANGLE AngleBetweenStartAndEnd(const VECTOR2I aPoint) const
Creepage: a board edge circle.
int GetRadius() const override
BE_SHAPE_CIRCLE(VECTOR2I aPos=VECTOR2I(0, 0), int aRadius=0)
void ShortenChildDueToGV(std::shared_ptr< GRAPH_NODE > &a1, std::shared_ptr< GRAPH_NODE > &a2, CREEPAGE_GRAPH &aG, double aNormalWeight) const
std::vector< PATH_CONNECTION > Paths(const BE_SHAPE_POINT &aS2, double aMaxWeight, double aMaxSquaredWeight) const override
void ConnectChildren(std::shared_ptr< GRAPH_NODE > &a1, std::shared_ptr< GRAPH_NODE > &a2, CREEPAGE_GRAPH &aG) const override
Creepage: a board edge point.
BE_SHAPE_POINT(VECTOR2I aPos)
void ConnectChildren(std::shared_ptr< GRAPH_NODE > &a1, std::shared_ptr< GRAPH_NODE > &a2, CREEPAGE_GRAPH &aG) const override
std::vector< PATH_CONNECTION > Paths(const BE_SHAPE_POINT &aS2, double aMaxWeight, double aMaxSquaredWeight) const override
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
virtual bool IsOnLayer(PCB_LAYER_ID aLayer) const
Test to see if this object is on the given layer.
virtual std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING aFlash=FLASHING::DEFAULT) const
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
Represent basic circle geometry with utility geometry functions.
A graph with nodes and connections for creepage calculation.
std::shared_ptr< GRAPH_NODE > AddNode(GRAPH_NODE::TYPE aType, CREEP_SHAPE *aParent=nullptr, const VECTOR2I &aPos=VECTOR2I())
std::shared_ptr< GRAPH_CONNECTION > AddConnection(std::shared_ptr< GRAPH_NODE > &aN1, std::shared_ptr< GRAPH_NODE > &aN2, const PATH_CONNECTION &aPc)
void SetTarget(double aTarget)
double Solve(std::shared_ptr< GRAPH_NODE > &aFrom, std::shared_ptr< GRAPH_NODE > &aTo, std::vector< std::shared_ptr< GRAPH_CONNECTION > > &aResult)
void Addshape(const SHAPE &aShape, std::shared_ptr< GRAPH_NODE > &aConnectTo, BOARD_ITEM *aParent=nullptr)
std::vector< CREEP_SHAPE * > m_shapeCollection
void TransformEdgeToCreepShapes()
std::shared_ptr< GRAPH_NODE > AddNodeVirtual()
void TransformCreepShapesToNodes(std::vector< CREEP_SHAPE * > &aShapes)
void Trim(double aWeightLimit)
SHAPE_POLY_SET * m_boardOutline
void RemoveDuplicatedShapes()
std::vector< BOARD_ITEM * > m_boardEdge
double m_creepageTargetSquared
std::unordered_set< std::shared_ptr< GRAPH_NODE >, GraphNodeHash, GraphNodeEqual > m_nodeset
void GeneratePaths(double aMaxWeight, PCB_LAYER_ID aLayer)
std::vector< std::shared_ptr< GRAPH_NODE > > m_nodes
std::vector< std::shared_ptr< GRAPH_CONNECTION > > m_connections
std::shared_ptr< GRAPH_NODE > AddNetElements(int aNetCode, PCB_LAYER_ID aLayer, int aMaxCreepage)
void RemoveConnection(const std::shared_ptr< GRAPH_CONNECTION > &, bool aDelete=false)
std::shared_ptr< GRAPH_NODE > FindNode(GRAPH_NODE::TYPE aType, CREEP_SHAPE *aParent, const VECTOR2I &aPos)
A class used to represent the shapes for creepage calculation.
CREEP_SHAPE::TYPE GetType() const
void SetParent(BOARD_ITEM *aParent)
virtual int GetRadius() const
virtual void ConnectChildren(std::shared_ptr< GRAPH_NODE > &a1, std::shared_ptr< GRAPH_NODE > &a2, CREEPAGE_GRAPH &aG) const
Creepage: a conductive arc.
VECTOR2I GetStartPoint() const override
EDA_ANGLE AngleBetweenStartAndEnd(const VECTOR2I aPoint) const
VECTOR2I GetEndPoint() const override
EDA_ANGLE GetStartAngle() const override
CU_SHAPE_ARC(VECTOR2I aPos, double aRadius, EDA_ANGLE aStartAngle, EDA_ANGLE aEndAngle, VECTOR2D aStartPoint, VECTOR2D aEndPoint)
int GetRadius() const override
EDA_ANGLE GetEndAngle() const override
std::vector< PATH_CONNECTION > Paths(const BE_SHAPE_POINT &aS2, double aMaxWeight, double aMaxSquaredWeight) const override
Creepage: a conductive circle.
int GetRadius() const override
CU_SHAPE_CIRCLE(VECTOR2I aPos, double aRadius=0)
std::vector< PATH_CONNECTION > Paths(const BE_SHAPE_POINT &aS2, double aMaxWeight, double aMaxSquaredWeight) const override
Creepage: a conductive segment.
std::vector< PATH_CONNECTION > Paths(const BE_SHAPE_POINT &aS2, double aMaxWeight, double aMaxSquaredWeight) const override
VECTOR2I GetStart() const
CU_SHAPE_SEGMENT(VECTOR2I aStart, VECTOR2I aEnd, double aWidth=0)
void SetCenter(const VECTOR2I &aCenter)
VECTOR2I getCenter() const
void CalcArcAngles(EDA_ANGLE &aStartAngle, EDA_ANGLE &aEndAngle) const
Calc arc start and end angles such that aStartAngle < aEndAngle.
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
void SetStart(const VECTOR2I &aStart)
void DupPolyPointsList(std::vector< VECTOR2I > &aBuffer) const
Duplicate the list of corners in a std::vector<VECTOR2I>.
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
void SetEnd(const VECTOR2I &aEnd)
void SetArcGeometry(const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd)
Set the three controlling points for an arc.
VECTOR2I GetArcMid() const
std::shared_ptr< GRAPH_NODE > n2
void GetShapes(std::vector< PCB_SHAPE > &aShapes)
std::shared_ptr< GRAPH_NODE > n1
std::set< std::shared_ptr< GRAPH_CONNECTION > > m_node_conns
VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
const VECTOR2I & GetArcMid() const
int GetWidth() const override
const VECTOR2I & GetP1() const
const VECTOR2I & GetP0() const
SHAPE_TYPE Type() const
Return the type of the shape.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
const VECTOR2I & CLastPoint() const
Return the last point in the line chain.
const std::vector< VECTOR2I > & CPoints() const
Represent a set of closed polygons.
CONST_SEGMENT_ITERATOR CIterateSegmentsWithHoles() const
Return an iterator object, for the aOutline-th outline in the set (with holes).
const VECTOR2I & GetPosition() const
const VECTOR2I GetSize() const
const SEG & GetSeg() const
int GetWidth() const override
An abstract shape on 2D plane.
constexpr extended_type Cross(const VECTOR2< T > &aVector) const
Compute cross product of self with aVector.
constexpr extended_type SquaredEuclideanNorm() const
Compute the squared euclidean norm of the vector, which is defined as (x ** 2 + y ** 2).
T EuclideanNorm() const
Compute the Euclidean norm of the vector, which is defined as sqrt(x ** 2 + y ** 2).
constexpr VECTOR2< T > Perpendicular() const
Compute the perpendicular vector.
constexpr extended_type Dot(const VECTOR2< T > &aVector) const
Compute dot product of self with aVector.
VECTOR2< T > Resize(T aNewLength) const
Return a vector of the same direction, but length specified in aNewLength.
Handle a list of polygons defining a copper zone.
static bool empty(const wxTextEntryBase *aCtrl)
VECTOR2I closestPointOnSegment(const VECTOR2I &A, const VECTOR2I &B, const VECTOR2I &P)
bool SegmentIntersectsBoard(const VECTOR2I &aP1, const VECTOR2I &aP2, const std::vector< BOARD_ITEM * > &aBe, const std::vector< const BOARD_ITEM * > &aDontTestAgainst, int aMinGrooveWidth)
std::vector< PATH_CONNECTION > GetPaths(CREEP_SHAPE *aS1, CREEP_SHAPE *aS2, double aMaxWeight)
bool segmentIntersectsArc(const VECTOR2I &p1, const VECTOR2I &p2, const VECTOR2I ¢er, double radius, EDA_ANGLE startAngle, EDA_ANGLE endAngle, std::vector< VECTOR2I > *aIntersectionPoints=nullptr)
bool compareShapes(const CREEP_SHAPE *a, const CREEP_SHAPE *b)
bool segments_intersect(const VECTOR2I &p1, const VECTOR2I &q1, const VECTOR2I &p2, const VECTOR2I &q2, std::vector< VECTOR2I > &aIntersectionPoints)
bool areEquivalent(const CREEP_SHAPE *a, const CREEP_SHAPE *b)
bool segmentIntersectsCircle(const VECTOR2I &p1, const VECTOR2I &p2, const VECTOR2I ¢er, double radius, std::vector< VECTOR2I > *aIntersectPoints)
static constexpr EDA_ANGLE ANGLE_0
static constexpr EDA_ANGLE ANGLE_360
@ RECTANGLE
Use RECTANGLE instead of RECT to avoid collision in a Windows header.
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.
PCB_LAYER_ID
A quick note on layer IDs:
static float distance(const SFVEC2UI &a, const SFVEC2UI &b)
@ SH_POLY_SET
set of polygons (with holes, etc.)
@ SH_RECT
axis-aligned rectangle
@ SH_LINE_CHAIN
line chain (polyline)
@ SH_COMPOUND
compound shape, consisting of multiple simple shapes
A visitor that visits INTERSECTABLE_GEOM variant objects with another (which is held as state: m_othe...
SHAPE_CIRCLE circle(c.m_circle_center, c.m_circle_radius)
wxString result
Test unit parsing edge cases and error handling.
thread_pool & GetKiCadThreadPool()
Get a reference to the current thread pool.
BS::thread_pool< 0 > thread_pool
VECTOR2< int32_t > VECTOR2I
VECTOR2< double > VECTOR2D