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;
565 double tolerance = 10;
596 if(
n1->m_type == GRAPH_NODE::TYPE::VIRTUAL ||
n2->m_type == GRAPH_NODE::TYPE::VIRTUAL )
600 &&
n1->m_parent ==
n2->m_parent
601 &&
n1->m_parent->GetType() == CREEP_SHAPE::TYPE::CIRCLE )
608 if( R1.
Cross( R2 ) > 0 )
620 aShapes.push_back( s );
625 &&
n1->m_parent ==
n2->m_parent
626 &&
n1->m_parent->GetType() == CREEP_SHAPE::TYPE::ARC )
635 if( R1.
Cross( R2 ) > 0 )
650 EDA_ANGLE midAngle = arc->AngleBetweenStartAndEnd( mid );
652 if( midAngle > arc->GetEndAngle() )
661 aShapes.push_back( s );
669 aShapes.push_back( s );
700 EDA_ANGLE maxAngle = angle1 > angle2 ? angle1 : angle2;
703 skipAngle += skipAngle;
704 EDA_ANGLE pointAngle = maxAngle - skipAngle;
714 pc.
a1 = maxAngle == angle2 ? a1->m_pos : a2->m_pos;
720 pc.
a2 = maxAngle == angle2 ? a2->m_pos : a1->m_pos;
723 std::shared_ptr<GRAPH_CONNECTION> gc = aG.
AddConnection( gnt, maxAngle == angle2 ? a2 : a1, pc );
726 gc->m_forceStraightLine =
true;
739 VECTOR2D distI( a1->m_pos - a2->m_pos );
740 VECTOR2D distD(
double( distI.
x ),
double( distI.
y ) );
752 pc.
weight = std::max( weight, 0.0 );
773 double weight = abs(
m_radius * ( angle2 - angle1 ).AsRadians() );
802 double aMaxSquaredWeight )
const
804 std::vector<PATH_CONNECTION>
result;
807 double halfWidth = this->
GetWidth() / 2;
811 double length = ( start -
end ).EuclideanNorm();
812 double projectedPos = cos( trackAngle.
AsRadians() ) * ( pointPos.
x - start.
x )
813 + sin( trackAngle.
AsRadians() ) * ( pointPos.
y - start.
y );
817 if( projectedPos <= 0 )
819 newPoint = start + ( pointPos - start ).Resize( halfWidth );
821 else if( projectedPos >= length )
823 newPoint =
end + ( pointPos -
end ).Resize( halfWidth );
827 double posOnSegment = ( start - pointPos ).SquaredEuclideanNorm()
828 - (
end - pointPos ).SquaredEuclideanNorm();
829 posOnSegment = posOnSegment / ( 2 * length ) + length / 2;
831 newPoint = start + (
end - start ).Resize( posOnSegment );
832 newPoint += ( pointPos - newPoint ).Resize( halfWidth );
835 double weightSquared = ( pointPos - newPoint ).SquaredEuclideanNorm();
837 if( weightSquared > aMaxSquaredWeight )
843 pc.
weight = sqrt( weightSquared );
851 double aMaxSquaredWeight )
const
853 std::vector<PATH_CONNECTION>
result;
856 double halfWidth = this->
GetWidth() / 2;
860 double length = ( start -
end ).EuclideanNorm();
863 double weightSquared = std::numeric_limits<double>::infinity();
864 VECTOR2I PointOnTrack, PointOnCircle;
868 double projectedPos1 = cos( trackAngle.
AsRadians() ) * ( circleCenter.
x - start.
x )
869 + sin( trackAngle.
AsRadians() ) * ( circleCenter.
y - start.
y );
870 double projectedPos2 = projectedPos1 + circleRadius;
871 projectedPos1 = projectedPos1 - circleRadius;
873 double trackSide = (
end - start ).Cross( circleCenter - start ) > 0 ? 1 : -1;
875 if( ( projectedPos1 < 0 && projectedPos2 < 0 ) )
883 else if( ( projectedPos1 > length && projectedPos2 > length ) )
891 else if( ( projectedPos1 >= 0 ) && ( projectedPos1 <= length ) && ( projectedPos2 >= 0 )
892 && ( projectedPos2 <= length ) )
895 PointOnTrack = start;
896 PointOnTrack += (
end - start ).Resize( projectedPos1 );
897 PointOnTrack += (
end - start ).Perpendicular().
Resize( halfWidth ) * trackSide;
898 PointOnCircle = circleCenter - (
end - start ).Resize( circleRadius );
899 weightSquared = ( PointOnCircle - PointOnTrack ).SquaredEuclideanNorm();
901 if( weightSquared < aMaxSquaredWeight )
904 pc.
a1 = PointOnTrack;
905 pc.
a2 = PointOnCircle;
906 pc.
weight = sqrt( weightSquared );
910 PointOnTrack = start;
911 PointOnTrack += (
end - start ).Resize( projectedPos2 );
912 PointOnTrack += (
end - start ).Perpendicular().
Resize( halfWidth ) * trackSide;
913 PointOnCircle = circleCenter + (
end - start ).Resize( circleRadius );
916 pc.
a1 = PointOnTrack;
917 pc.
a2 = PointOnCircle;
922 else if( ( ( projectedPos1 >= 0 ) && ( projectedPos1 <= length ) )
923 && ( ( projectedPos2 > length ) || projectedPos2 < 0 ) )
926 std::vector<PATH_CONNECTION> pcs = csc.
Paths( aS2, aMaxWeight, aMaxSquaredWeight );
931 result.push_back( pcs.at( trackSide == 1 ? 1 : 0 ) );
934 PointOnTrack = start;
935 PointOnTrack += (
end - start ).Resize( projectedPos1 );
936 PointOnTrack += (
end - start ).Perpendicular().
Resize( halfWidth ) * trackSide;
937 PointOnCircle = circleCenter - (
end - start ).Resize( circleRadius );
938 weightSquared = ( PointOnCircle - PointOnTrack ).SquaredEuclideanNorm();
940 if( weightSquared < aMaxSquaredWeight )
943 pc.
a1 = PointOnTrack;
944 pc.
a2 = PointOnCircle;
945 pc.
weight = sqrt( weightSquared );
950 else if( ( ( projectedPos2 >= 0 ) && ( projectedPos2 <= length ) )
951 && ( ( projectedPos1 > length ) || projectedPos1 < 0 ) )
954 std::vector<PATH_CONNECTION> pcs = csc.
Paths( aS2, aMaxWeight, aMaxSquaredWeight );
959 result.push_back( pcs.at( trackSide == 1 ? 0 : 1 ) );
961 PointOnTrack = start;
962 PointOnTrack += (
end - start ).Resize( projectedPos2 );
963 PointOnTrack += (
end - start ).Perpendicular().
Resize( halfWidth ) * trackSide;
964 PointOnCircle = circleCenter + (
end - start ).Resize( circleRadius );
965 weightSquared = ( PointOnCircle - PointOnTrack ).SquaredEuclideanNorm();
967 if( weightSquared < aMaxSquaredWeight )
970 pc.
a1 = PointOnTrack;
971 pc.
a2 = PointOnCircle;
972 pc.
weight = sqrt( weightSquared );
983 double aMaxSquaredWeight )
const
985 std::vector<PATH_CONNECTION>
result;
1009 if( !
segmentIntersectsArc( pc.a1, pc.a2, beArcPos, beArcRadius, beArcStartAngle, beArcEndAngle ) )
1015 if( !
segmentIntersectsArc( pc.a1, pc.a2, beArcPos, beArcRadius, beArcStartAngle, beArcEndAngle ) )
1025 double aMaxSquaredWeight )
const
1027 std::vector<PATH_CONNECTION>
result;
1050 if( !
segmentIntersectsArc( pc.a1, pc.a2, beArcPos, beArcRadius, beArcStartAngle, beArcEndAngle ) )
1056 if( !
segmentIntersectsArc( pc.a1, pc.a2, beArcPos, beArcRadius, beArcStartAngle, beArcEndAngle ) )
1066 double aMaxSquaredWeight )
const
1068 std::vector<PATH_CONNECTION>
result;
1097 double aMaxSquaredWeight )
const
1099 std::vector<PATH_CONNECTION>
result;
1122 if( !
segmentIntersectsArc( pc.a1, pc.a2, beArcPos, beArcRadius, beArcStartAngle, beArcEndAngle ) )
1128 if( !
segmentIntersectsArc( pc.a1, pc.a2, beArcPos, beArcRadius, beArcStartAngle, beArcEndAngle ) )
1138 double aMaxSquaredWeight )
const
1140 std::vector<PATH_CONNECTION>
result;
1145 double weight = (
center - point ).EuclideanNorm() - R;
1147 if( weight > aMaxWeight )
1151 pc.
weight = std::max( weight, 0.0 );
1161 double aMaxSquaredWeight )
const
1163 std::vector<PATH_CONNECTION>
result;
1170 if( ( C1 - C2 ).SquaredEuclideanNorm() < ( R1 - R2 ) * ( R1 - R2 ) )
1176 double weight = ( C1 - C2 ).EuclideanNorm() - R1 - R2;
1178 if( weight > aMaxWeight || weight < 0 )
1182 pc.
weight = std::max( weight, 0.0 );
1183 pc.
a1 = ( C2 - C1 ).Resize( R1 ) + C1;
1184 pc.
a2 = ( C1 - C2 ).Resize( R2 ) + C2;
1191 double aMaxSquaredWeight )
const
1193 std::vector<PATH_CONNECTION>
result;
1197 double halfWidth = this->
GetWidth() / 2;
1199 EDA_ANGLE trackAngle( s_end - s_start );
1202 double length = ( s_start - s_end ).EuclideanNorm();
1203 double projectedPos = cos( trackAngle.
AsRadians() ) * ( pointPos.
x - s_start.
x )
1204 + sin( trackAngle.
AsRadians() ) * ( pointPos.
y - s_start.
y );
1206 if( ( projectedPos <= 0 ) || ( s_start == s_end ) )
1209 return csc.
Paths( aS2, aMaxWeight, aMaxSquaredWeight );
1212 if( projectedPos >= length )
1215 return csc.
Paths( aS2, aMaxWeight, aMaxSquaredWeight );
1219 double trackSide = ( s_end - s_start ).Cross( pointPos - s_start ) > 0 ? 1 : -1;
1222 pc.
a1 = s_start + ( s_end - s_start ).Resize( projectedPos )
1223 + ( s_end - s_start ).Perpendicular().
Resize( halfWidth ) * trackSide;
1224 pc.
a2 = ( pc.
a1 - pointPos ).Resize(
radius ) + pointPos;
1225 pc.
weight = ( pc.
a2 - pc.
a1 ).SquaredEuclideanNorm();
1227 if( pc.
weight <= aMaxSquaredWeight )
1238 double aMaxSquaredWeight )
const
1240 std::vector<PATH_CONNECTION>
result;
1245 double circleRadius = this->
GetRadius();
1253 if( ( circlePos - arcPos ).EuclideanNorm() > arcRadius + circleRadius )
1255 const std::vector<PATH_CONNECTION>& pcs = this->
Paths( csc, aMaxWeight, aMaxSquaredWeight );
1257 if( pcs.size() == 1 )
1263 result.push_back( pcs[0] );
1275 std::vector<PATH_CONNECTION> pcs1 = this->
Paths( csc1, aMaxWeight, aMaxSquaredWeight );
1276 std::vector<PATH_CONNECTION> pcs2 = this->
Paths( csc2, aMaxWeight, aMaxSquaredWeight );
1280 if( !bestPath || ( ( bestPath->
weight > pc.weight ) && ( pc.weight > 0 ) ) )
1286 if( !bestPath || ( ( bestPath->
weight > pc.weight ) && ( pc.weight > 0 ) ) )
1294 if( ( circlePos - arcPos ).SquaredEuclideanNorm() < arcRadius * arcRadius )
1296 if( circlePos != arcPos )
1302 pc3.
weight = std::max( arcRadius - ( circlePos - arcPos ).EuclideanNorm() - circleRadius, 0.0 );
1303 pc3.
a1 = circlePos + ( circlePos - arcPos ).Resize( circleRadius );
1304 pc3.
a2 = arcPos + ( circlePos - arcPos ).Resize( arcRadius - aS2.
GetWidth() / 2 );
1312 if( bestPath && bestPath->
weight > 0 )
1314 result.push_back( *bestPath );
1322 double aMaxSquaredWeight )
const
1324 std::vector<PATH_CONNECTION>
result;
1328 double halfWidth1 = this->
GetWidth() / 2;
1332 double halfWidth2 = aS2.
GetWidth() / 2;
1337 std::vector<PATH_CONNECTION> pcs;
1338 pcs = this->
Paths( csc, aMaxWeight, aMaxSquaredWeight );
1340 if( pcs.size() < 1 )
1346 if( pcs.size() > 0 )
1348 circlePoint = pcs[0].a1;
1352 if( testAngle < aS2.
GetEndAngle() && pcs.size() > 0 )
1354 result.push_back( pcs[0] );
1364 if( !bestPath || ( bestPath->
weight > pc.weight ) )
1370 if( !bestPath || ( bestPath->
weight > pc.weight ) )
1379 if( !bestPath || ( bestPath->
weight > pc.weight ) )
1386 if( !bestPath || ( bestPath->
weight > pc.weight ) )
1391 result.push_back( *bestPath );
1410 t = std::max( 0.0, std::min( 1.0, t ) );
1412 return A + ( AB * t );
1418 double aMaxSquaredWeight )
const
1420 std::vector<PATH_CONNECTION>
result;
1424 double halfWidth1 = this->
GetWidth() / 2;
1429 double halfWidth2 = aS2.
GetWidth() / 2;
1437 double dist1 = ( P1 -
C ).SquaredEuclideanNorm();
1438 double dist2 = ( P2 -
D ).SquaredEuclideanNorm();
1439 double dist3 = ( P3 -
A ).SquaredEuclideanNorm();
1440 double dist4 = ( P4 -
B ).SquaredEuclideanNorm();
1443 double min_dist = dist1;
1447 if( dist2 < min_dist )
1454 if( dist3 < min_dist )
1461 if( dist4 < min_dist )
1470 pc.
a1 = closest1 + ( closest2 - closest1 ).Resize( halfWidth1 );
1471 pc.
a2 = closest2 + ( closest1 - closest2 ).Resize( halfWidth2 );
1472 pc.
weight = std::max( sqrt( min_dist ) - halfWidth1 - halfWidth2, 0.0 );
1474 if( pc.
weight <= aMaxWeight )
1482 double aMaxSquaredWeight )
const
1484 std::vector<PATH_CONNECTION>
result;
1490 double dist = ( center1 - center2 ).EuclideanNorm();
1492 if( dist > aMaxWeight || dist == 0 )
1495 double weight = sqrt( dist * dist - R2 * R2 ) - R1;
1496 double theta = asin( R2 / dist );
1497 double psi = acos( R2 / dist );
1499 if( weight > aMaxWeight )
1503 pc.
weight = std::max( weight, 0.0 );
1510 pStart =
VECTOR2I( R1 * cos( theta + circleAngle ), R1 * sin( theta + circleAngle ) );
1512 pEnd =
VECTOR2I( -R2 * cos( psi - circleAngle ), R2 * sin( psi - circleAngle ) );
1519 pStart =
VECTOR2I( R1 * cos( -theta + circleAngle ), R1 * sin( -theta + circleAngle ) );
1521 pEnd =
VECTOR2I( -R2 * cos( -psi - circleAngle ), R2 * sin( -psi - circleAngle ) );
1533 double aMaxSquaredWeight )
const
1535 std::vector<PATH_CONNECTION>
result;
1551 if( ( point - arcCenter ).SquaredEuclideanNorm() >
radius *
radius )
1554 return circle.Paths( aS2, aMaxWeight, aMaxSquaredWeight );
1559 pc.
weight = std::max( (
radius - width / 2 ) - ( point - arcCenter ).EuclideanNorm(), 0.0 );
1560 pc.
a1 = ( point - arcCenter ).Resize(
radius - width / 2 ) + arcCenter;
1573 if( ( point - this->
GetStartPoint() ).SquaredEuclideanNorm()
1574 > ( point - this->
GetEndPoint() ).SquaredEuclideanNorm() )
1584 return circle.Paths( aS2, aMaxWeight, aMaxSquaredWeight );
1590 double aMaxSquaredWeight )
const
1592 std::vector<PATH_CONNECTION>
result;
1601 bestPath.
weight = std::numeric_limits<double>::infinity();
1610 for(
const std::vector<PATH_CONNECTION>& pcs : { csc1.
Paths( csc2, aMaxWeight, aMaxSquaredWeight ),
1611 this->
Paths( csc2, aMaxWeight, aMaxSquaredWeight ),
1612 csc1.
Paths( aS2, aMaxWeight, aMaxSquaredWeight ) } )
1624 for(
const std::vector<PATH_CONNECTION>& pcs : { this->
Paths( csc5, aMaxWeight, aMaxSquaredWeight ),
1625 this->
Paths( csc6, aMaxWeight, aMaxSquaredWeight ),
1626 csc3.
Paths( aS2, aMaxWeight, aMaxSquaredWeight ),
1627 csc4.
Paths( aS2, aMaxWeight, aMaxSquaredWeight ) } )
1631 if( bestPath.
weight > pc.weight )
1636 if( bestPath.
weight != std::numeric_limits<double>::infinity() )
1637 result.push_back( bestPath );
1644 std::vector<VECTOR2I>* aIntersectPoints )
1646 SEG segment( p1, p2 );
1649 std::vector<VECTOR2I> intersectionPoints;
1654 std::visit( visitor, geom1 );
1656 if( aIntersectPoints )
1658 for(
VECTOR2I& point : intersectionPoints )
1659 aIntersectPoints->push_back( point );
1662 return intersectionPoints.size() > 0;
1666 const std::vector<BOARD_ITEM*>& aBe,
1667 const std::vector<const BOARD_ITEM*>& aDontTestAgainst,
1668 int aMinGrooveWidth )
1670 std::vector<VECTOR2I> intersectionPoints;
1671 bool TestGrooveWidth = aMinGrooveWidth > 0;
1675 if( count( aDontTestAgainst.begin(), aDontTestAgainst.end(), be ) > 0 )
1688 if( intersects && !TestGrooveWidth )
1701 bool intersects =
false;
1707 if( intersects && !TestGrooveWidth )
1717 if( points.size() < 2 )
1720 VECTOR2I prevPoint = points.back();
1722 bool intersects =
false;
1730 if( intersects && !TestGrooveWidth )
1743 if( intersects && !TestGrooveWidth )
1759 if( intersects && !TestGrooveWidth )
1770 if( intersectionPoints.size() <= 0 )
1773 if( intersectionPoints.size() % 2 != 0 )
1776 int minx = intersectionPoints[0].x;
1777 int maxx = intersectionPoints[0].x;
1778 int miny = intersectionPoints[0].y;
1779 int maxy = intersectionPoints[0].y;
1781 for(
const VECTOR2I& v : intersectionPoints )
1783 minx = v.x < minx ? v.x : minx;
1784 maxx = v.x > maxx ? v.x : maxx;
1785 miny = v.x < miny ? v.x : miny;
1786 maxy = v.x > maxy ? v.x : maxy;
1789 if( abs( maxx - minx ) > abs( maxy - miny ) )
1791 std::sort( intersectionPoints.begin(), intersectionPoints.end(),
1799 std::sort( intersectionPoints.begin(), intersectionPoints.end(),
1806 int GVSquared = aMinGrooveWidth * aMinGrooveWidth;
1808 for(
size_t i = 0; i < intersectionPoints.size(); i += 2 )
1810 if( intersectionPoints[i].SquaredDistance( intersectionPoints[i + 1] ) > GVSquared )
1820 double maxWeight = aMaxWeight;
1821 double maxWeightSquared = maxWeight * maxWeight;
1822 std::vector<PATH_CONNECTION>
result;
1841 if( cuarc1 && cuarc2 )
1842 return cuarc1->
Paths( *cuarc2, maxWeight, maxWeightSquared );
1843 if( cuarc1 && cucircle2 )
1844 return cuarc1->
Paths( *cucircle2, maxWeight, maxWeightSquared );
1845 if( cuarc1 && cusegment2 )
1846 return cuarc1->
Paths( *cusegment2, maxWeight, maxWeightSquared );
1847 if( cucircle1 && cuarc2 )
1848 return cucircle1->
Paths( *cuarc2, maxWeight, maxWeightSquared );
1849 if( cucircle1 && cucircle2 )
1850 return cucircle1->
Paths( *cucircle2, maxWeight, maxWeightSquared );
1851 if( cucircle1 && cusegment2 )
1852 return cucircle1->
Paths( *cusegment2, maxWeight, maxWeightSquared );
1853 if( cusegment1 && cuarc2 )
1854 return cusegment1->
Paths( *cuarc2, maxWeight, maxWeightSquared );
1855 if( cusegment1 && cucircle2 )
1856 return cusegment1->
Paths( *cucircle2, maxWeight, maxWeightSquared );
1857 if( cusegment1 && cusegment2 )
1858 return cusegment1->
Paths( *cusegment2, maxWeight, maxWeightSquared );
1863 if( cuarc1 && bearc2 )
1864 return cuarc1->
Paths( *bearc2, maxWeight, maxWeightSquared );
1865 if( cuarc1 && becircle2 )
1866 return cuarc1->
Paths( *becircle2, maxWeight, maxWeightSquared );
1867 if( cuarc1 && bepoint2 )
1868 return cuarc1->
Paths( *bepoint2, maxWeight, maxWeightSquared );
1869 if( cucircle1 && bearc2 )
1870 return cucircle1->
Paths( *bearc2, maxWeight, maxWeightSquared );
1871 if( cucircle1 && becircle2 )
1872 return cucircle1->
Paths( *becircle2, maxWeight, maxWeightSquared );
1873 if( cucircle1 && bepoint2 )
1874 return cucircle1->
Paths( *bepoint2, maxWeight, maxWeightSquared );
1875 if( cusegment1 && bearc2 )
1876 return cusegment1->
Paths( *bearc2, maxWeight, maxWeightSquared );
1877 if( cusegment1 && becircle2 )
1878 return cusegment1->
Paths( *becircle2, maxWeight, maxWeightSquared );
1879 if( cusegment1 && bepoint2 )
1880 return cusegment1->
Paths( *bepoint2, maxWeight, maxWeightSquared );
1884 if( cuarc2 && bearc1 )
1885 return bearc1->
Paths( *cuarc2, maxWeight, maxWeightSquared );
1886 if( cuarc2 && becircle1 )
1887 return becircle1->
Paths( *cuarc2, maxWeight, maxWeightSquared );
1888 if( cuarc2 && bepoint1 )
1889 return bepoint1->
Paths( *cuarc2, maxWeight, maxWeightSquared );
1890 if( cucircle2 && bearc1 )
1891 return bearc1->
Paths( *cucircle2, maxWeight, maxWeightSquared );
1892 if( cucircle2 && becircle1 )
1893 return becircle1->
Paths( *cucircle2, maxWeight, maxWeightSquared );
1894 if( cucircle2 && bepoint1 )
1895 return bepoint1->
Paths( *cucircle2, maxWeight, maxWeightSquared );
1896 if( cusegment2 && bearc1 )
1897 return bearc1->
Paths( *cusegment2, maxWeight, maxWeightSquared );
1898 if( cusegment2 && becircle1 )
1899 return becircle1->
Paths( *cusegment2, maxWeight, maxWeightSquared );
1900 if( cusegment2 && bepoint1 )
1901 return bepoint1->
Paths( *cusegment2, maxWeight, maxWeightSquared );
1906 if( bearc1 && bearc2 )
1907 return bearc1->
Paths( *bearc2, maxWeight, maxWeightSquared );
1908 if( bearc1 && becircle2 )
1909 return bearc1->
Paths( *becircle2, maxWeight, maxWeightSquared );
1910 if( bearc1 && bepoint2 )
1911 return bearc1->
Paths( *bepoint2, maxWeight, maxWeightSquared );
1912 if( becircle1 && bearc2 )
1913 return becircle1->
Paths( *bearc2, maxWeight, maxWeightSquared );
1914 if( becircle1 && becircle2 )
1915 return becircle1->
Paths( *becircle2, maxWeight, maxWeightSquared );
1916 if( becircle1 && bepoint2 )
1917 return becircle1->
Paths( *bepoint2, maxWeight, maxWeightSquared );
1918 if( bepoint1 && bearc2 )
1919 return bepoint1->
Paths( *bearc2, maxWeight, maxWeightSquared );
1920 if( bepoint1 && becircle2 )
1921 return bepoint1->
Paths( *becircle2, maxWeight, maxWeightSquared );
1922 if( bepoint1 && bepoint2 )
1923 return bepoint1->
Paths( *bepoint2, maxWeight, maxWeightSquared );
1929 std::vector<std::shared_ptr<GRAPH_CONNECTION>>& aResult )
1931 if( !aFrom || !aTo )
1938 std::unordered_map<GRAPH_NODE*, double> distances;
1939 std::unordered_map<GRAPH_NODE*, GRAPH_NODE*> previous;
1943 double distLeft = distances[
left];
1944 double distRight = distances[
right];
1946 if( distLeft == distRight )
1948 return distLeft > distRight;
1950 std::priority_queue<GRAPH_NODE*, std::vector<GRAPH_NODE*>,
decltype( cmp )> pq( cmp );
1953 for(
const std::shared_ptr<GRAPH_NODE>& node :
m_nodes )
1955 if( node !=
nullptr )
1956 distances[node.get()] = std::numeric_limits<double>::infinity();
1959 distances[aFrom.get()] = 0.0;
1960 distances[aTo.get()] = std::numeric_limits<double>::infinity();
1961 pq.push( aFrom.get() );
1964 while( !pq.empty() )
1969 if( current == aTo.get() )
1975 for(
const std::shared_ptr<GRAPH_CONNECTION>& connection : current->
m_node_conns )
1977 GRAPH_NODE* neighbor = ( connection->n1 ).get() == current ? ( connection->n2 ).get()
1978 : ( connection->n1 ).get();
1984 if( connection->m_path.weight < 0.0 )
1986 wxLogTrace(
"CREEPAGE",
"Negative weight connection found. Ignoring connection." );
1990 double alt = distances[current] + connection->m_path.weight;
1992 if( alt < distances[neighbor] )
1994 distances[neighbor] = alt;
1995 previous[neighbor] = current;
1996 pq.push( neighbor );
2001 double pathWeight = distances[aTo.get()];
2004 if( pathWeight == std::numeric_limits<double>::infinity() )
2005 return std::numeric_limits<double>::infinity();
2010 while( step != aFrom.get() )
2014 for(
const std::shared_ptr<GRAPH_CONNECTION>& node_conn : step->
m_node_conns )
2016 if( ( ( node_conn->n1 ).get() == prevNode && ( node_conn->n2 ).get() == step )
2017 || ( ( node_conn->n1 ).get() == step && ( node_conn->n2 ).get() == prevNode ) )
2019 aResult.push_back( node_conn );
2037 switch( aShape.
Type() )
2052 newshape =
dynamic_cast<CREEP_SHAPE*
>( cucircle );
2067 start = arc.
GetP0();
2073 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 );
2107 const SEG object = *it;
2109 Addshape( segment, aConnectTo, aParent );
2124 Addshape( segment, aConnectTo, aParent );
2153 std::shared_ptr<GRAPH_NODE> gnShape =
nullptr;
2157 switch( aShape.
Type() )
2168 gnShape->m_net = aConnectTo->m_net;
2169 std::shared_ptr<GRAPH_CONNECTION> gc =
AddConnection( gnShape, aConnectTo );
2172 gc->m_path.m_show =
false;
2183 std::vector<std::shared_ptr<GRAPH_NODE>> nodes;
2184 std::mutex nodes_lock;
2188 std::vector<CREEPAGE_TRACK_ENTRY*> trackEntries;
2196 std::shared_ptr<SHAPE> sh = track->GetEffectiveShape();
2201 entry->
segment =
SEG( track->GetStart(), track->GetEnd() );
2202 entry->
layer = aLayer;
2204 BOX2I bbox = track->GetBoundingBox();
2205 int minCoords[2] = { bbox.
GetX(), bbox.
GetY() };
2207 trackIndex.Insert( minCoords, maxCoords, entry );
2208 trackEntries.push_back( entry );
2214 std::copy_if(
m_nodes.begin(),
m_nodes.end(), std::back_inserter( nodes ),
2215 [&](
const std::shared_ptr<GRAPH_NODE>& gn )
2217 return gn && gn->m_parent && gn->m_connectDirectly && ( gn->m_type != GRAPH_NODE::TYPE::VIRTUAL );
2220 std::sort( nodes.begin(), nodes.end(),
2221 [](
const std::shared_ptr<GRAPH_NODE>& gn1,
const std::shared_ptr<GRAPH_NODE>& gn2 )
2223 return gn1->m_parent < gn2->m_parent
2224 || ( gn1->m_parent == gn2->m_parent && gn1->m_net < gn2->m_net );
2229 std::unordered_map<const BOARD_ITEM*, std::unordered_map<int, std::vector<std::shared_ptr<GRAPH_NODE>>>> parent_net_groups;
2230 std::unordered_map<const BOARD_ITEM*, BOX2I> parent_bboxes;
2231 std::vector<const BOARD_ITEM*> parent_keys;
2233 for(
const auto& gn : nodes )
2235 const BOARD_ITEM* parent = gn->m_parent->GetParent();
2237 if( parent_net_groups[parent].
empty() )
2239 parent_keys.push_back( parent );
2244 parent_net_groups[parent][gn->m_net].push_back( gn );
2248 std::vector<std::pair<std::shared_ptr<GRAPH_NODE>, std::shared_ptr<GRAPH_NODE>>> work_items;
2253 int64_t maxDist =
static_cast<int64_t
>( aMaxWeight );
2261 RTree<ParentEntry*, int, 2, double> parentIndex;
2262 std::vector<ParentEntry> parentEntries;
2265 for(
const auto* parent : parent_keys )
2270 entry.parent = parent;
2271 entry.bbox = parent_bboxes[parent];
2272 parentEntries.push_back( entry );
2277 for( ParentEntry& entry : parentEntries )
2279 int minCoords[2] = { entry.bbox.GetLeft(), entry.bbox.GetTop() };
2280 int maxCoords[2] = { entry.bbox.GetRight(), entry.bbox.GetBottom() };
2281 parentIndex.Insert( minCoords, maxCoords, &entry );
2285 std::mutex work_items_lock;
2287 auto searchParent = [&](
size_t i ) ->
bool
2289 const ParentEntry& entry1 = parentEntries[i];
2291 BOX2I bbox1 = entry1.bbox;
2293 std::vector<std::pair<std::shared_ptr<GRAPH_NODE>, std::shared_ptr<GRAPH_NODE>>> localWorkItems;
2296 int searchMin[2] = { bbox1.
GetLeft() - (int) maxDist, bbox1.
GetTop() - (int) maxDist };
2297 int searchMax[2] = { bbox1.
GetRight() + (int) maxDist, bbox1.
GetBottom() + (int) maxDist };
2299 parentIndex.Search( searchMin, searchMax,
2300 [&]( ParentEntry* entry2 ) ->
bool
2305 if( parent1 >= parent2 )
2309 BOX2I bbox2 = entry2->bbox;
2311 int64_t bboxDistX = 0;
2317 int64_t bboxDistY = 0;
2323 int64_t bboxDistSq = bboxDistX * bboxDistX + bboxDistY * bboxDistY;
2324 if( bboxDistSq > maxDist * maxDist )
2328 auto it1 = parent_net_groups.find( parent1 );
2329 auto it2 = parent_net_groups.find( parent2 );
2331 if( it1 == parent_net_groups.end() || it2 == parent_net_groups.end() )
2334 for(
const auto& [net1, nodes1] : it1->second )
2336 for(
const auto& [net2, nodes2] : it2->second )
2339 if( net1 == net2 && !nodes1.empty() && !nodes2.empty() )
2341 if( nodes1[0]->m_parent->IsConductive()
2342 && nodes2[0]->m_parent->IsConductive() )
2346 for(
const auto& gn1 : nodes1 )
2348 for(
const auto& gn2 : nodes2 )
2350 VECTOR2I pos1 = gn1->m_parent->GetPos();
2351 VECTOR2I pos2 = gn2->m_parent->GetPos();
2352 int r1 = gn1->m_parent->GetRadius();
2353 int r2 = gn2->m_parent->GetRadius();
2355 int64_t centerDistSq = ( pos1 - pos2 ).SquaredEuclideanNorm();
2356 double threshold = aMaxWeight + r1 + r2;
2357 double thresholdSq = threshold * threshold;
2359 if( (
double) centerDistSq > thresholdSq )
2362 localWorkItems.push_back( { gn1, gn2 } );
2372 if( !localWorkItems.empty() )
2374 std::lock_guard<std::mutex> lock( work_items_lock );
2375 work_items.insert( work_items.end(), localWorkItems.begin(), localWorkItems.end() );
2382 if( parentEntries.size() > 100 &&
tp.get_tasks_total() <
tp.get_thread_count() - 4 )
2384 auto ret =
tp.submit_loop( 0, parentEntries.size(), searchParent );
2386 for(
auto& r : ret )
2394 for(
size_t i = 0; i < parentEntries.size(); ++i )
2398 auto processWorkItems =
2399 [&](
size_t idx ) ->
bool
2401 auto& [gn1, gn2] = work_items[idx];
2409 std::vector<const BOARD_ITEM*> IgnoreForTest =
2411 gn1->m_parent->GetParent(), gn2->m_parent->GetParent()
2422 std::shared_ptr<GRAPH_NODE> connect1 = gn1, connect2 = gn2;
2423 std::lock_guard<std::mutex> lock( nodes_lock );
2426 if( gn1->m_parent->GetType() != CREEP_SHAPE::TYPE::POINT )
2429 gnt1->m_connectDirectly =
false;
2432 if( gn1->m_parent->IsConductive() )
2434 if( std::shared_ptr<GRAPH_CONNECTION> gc =
AddConnection( gn1, gnt1 ) )
2435 gc->m_path.m_show =
false;
2440 if( gn2->m_parent->GetType() != CREEP_SHAPE::TYPE::POINT )
2443 gnt2->m_connectDirectly =
false;
2446 if( gn2->m_parent->IsConductive() )
2448 if( std::shared_ptr<GRAPH_CONNECTION> gc =
AddConnection( gn2, gnt2 ) )
2449 gc->m_path.m_show =
false;
2461 if(
tp.get_tasks_total() >=
tp.get_thread_count() - 4 )
2463 for(
size_t ii = 0; ii < work_items.size(); ii++ )
2464 processWorkItems( ii );
2468 auto ret =
tp.submit_loop( 0, work_items.size(), processWorkItems );
2470 for(
size_t ii = 0; ii < ret.size(); ii++ )
2477 while( r.wait_for( std::chrono::milliseconds( 100 ) ) != std::future_status::ready ){}
2489 std::vector<std::shared_ptr<GRAPH_CONNECTION>> toRemove;
2492 for( std::shared_ptr<GRAPH_CONNECTION>& gc :
m_connections )
2494 if( gc && ( gc->m_path.weight > aWeightLimit ) )
2495 toRemove.push_back( gc );
2499 for(
const std::shared_ptr<GRAPH_CONNECTION>& gc : toRemove )
2509 for( std::shared_ptr<GRAPH_NODE> gn : { aGc->n1, aGc->n2 } )
2513 gn->m_node_conns.erase( aGc );
2515 if( gn->m_node_conns.empty() && aDelete )
2518 [&gn](
const std::shared_ptr<GRAPH_NODE>& node )
2520 return node.get() == gn.get();
2543 std::shared_ptr<GRAPH_NODE> gn =
FindNode( aType, parent, pos );
2548 gn = std::make_shared<GRAPH_NODE>( aType, parent, pos );
2558 std::shared_ptr<GRAPH_NODE> gn = std::make_shared<GRAPH_NODE>( GRAPH_NODE::TYPE::VIRTUAL,
nullptr );
2566 std::shared_ptr<GRAPH_NODE>& aN2,
2572 wxASSERT_MSG( ( aN1 != aN2 ),
"Creepage: a connection connects a node to itself" );
2574 std::shared_ptr<GRAPH_CONNECTION> gc = std::make_shared<GRAPH_CONNECTION>( aN1, aN2, aPc );
2576 aN1->m_node_conns.insert( gc );
2577 aN2->m_node_conns.insert( gc );
2584 std::shared_ptr<GRAPH_NODE>& aN2 )
2601 auto it =
m_nodeset.find( std::make_shared<GRAPH_NODE>( aType, aParent, aPos ) );
2614 virtualNode->m_net = aNetCode;
2618 for(
PAD*
pad : footprint->Pads() )
2620 if(
pad->GetNetCode() != aNetCode || !
pad->IsOnLayer( aLayer ) )
2623 if( std::shared_ptr<SHAPE> padShape =
pad->GetEffectiveShape( aLayer ) )
2630 if( track->GetNetCode() != aNetCode || !track->IsOnLayer( aLayer ) )
2633 if( std::shared_ptr<SHAPE> shape = track->GetEffectiveShape() )
2634 Addshape( *shape, virtualNode, track );
2640 if( zone->GetNetCode() != aNetCode || !zone->IsOnLayer( aLayer ) )
2643 if( std::shared_ptr<SHAPE> shape = zone->GetEffectiveShape( aLayer ) )
2644 Addshape( *shape, virtualNode, zone );
2647 const DRAWINGS drawings =
m_board.Drawings();
2651 if( drawing->IsConnected() )
2659 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.
constexpr coord_type GetY() const
constexpr coord_type GetX() const
constexpr coord_type GetLeft() const
constexpr coord_type GetRight() const
constexpr coord_type GetTop() const
constexpr coord_type GetBottom() const
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)
virtual const BOX2I GetBoundingBox() const
Return the orthogonal bounding box of this object for display purposes.
void SetCenter(const VECTOR2I &aCenter)
VECTOR2I getCenter() const
std::vector< VECTOR2I > GetPolyPoints() const
Duplicate the polygon outlines into a flat list of VECTOR2I points.
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)
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)
RTree< CREEPAGE_TRACK_ENTRY *, int, 2, double > TRACK_RTREE
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::priority_thread_pool thread_pool
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
VECTOR2< int32_t > VECTOR2I
VECTOR2< double > VECTOR2D