Optimize ARC hulls in PNS

If we can't route through the arc opening, then it is effectively a
circle and we can treat it as such.
This commit is contained in:
Seth Hillbrand 2024-05-20 17:21:11 -07:00
parent 83ad0d5fad
commit be0e058807
1 changed files with 17 additions and 7 deletions

View File

@ -64,13 +64,24 @@ const SHAPE_LINE_CHAIN OctagonalHull( const VECTOR2I& aP0, const VECTOR2I& aSize
}
const SHAPE_LINE_CHAIN ArcHull( const SHAPE_ARC& aSeg, int aClearance, int aWalkaroundThickness )
const SHAPE_LINE_CHAIN ArcHull( const SHAPE_ARC& aArc, int aClearance, int aWalkaroundThickness )
{
int d = aSeg.GetWidth() / 2 + aClearance + aWalkaroundThickness / 2
+ SHAPE_ARC::DefaultAccuracyForPCB();
int cl = aClearance + ( aWalkaroundThickness + 1 ) / 2;
// If we can't route through the arc, we might as well treat it as a circle
if( aArc.GetCentralAngle().AsDegrees() > 180.0 && aArc.GetChord().Length() < cl )
{
int r = aArc.GetRadius();
return OctagonalHull( aArc.GetCenter() - VECTOR2I( r, r ),
VECTOR2I( 2 * r, 2 * r ),
cl,
2.0 * ( 1.0 - M_SQRT1_2 ) * ( r + cl ) );
}
int d = aArc.GetWidth() / 2 + cl + SHAPE_ARC::DefaultAccuracyForPCB();
int x = (int) ( 2.0 / ( 1.0 + M_SQRT2 ) * d ) / 2;
auto line = aSeg.ConvertToPolyline();
auto line = aArc.ConvertToPolyline( ARC_LOW_DEF );
SHAPE_LINE_CHAIN s;
s.SetClosed( true );
@ -133,7 +144,6 @@ const SHAPE_LINE_CHAIN ArcHull( const SHAPE_ARC& aSeg, int aClearance, int aWalk
for( int i = reverse_line.size() - 1; i >= 0; i-- )
s.Append( reverse_line[i] );
// make sure the hull outline is always clockwise
// make sure the hull outline is always clockwise
if( s.CSegment( 0 ).Side( line.Segment( 0 ).A ) < 0 )
return s.Reverse();