Use arcs instead of line approximation for Miter shape

TODO:

* The resulting line chain is broken with the arcs, and
this appears to be some subsequent issue I was not able to pin down.
* The requirement of a correction factor is not clear to me
This commit is contained in:
Thomas Pointhuber 2020-10-28 14:57:55 +01:00 committed by Jon Evans
parent cc956695ae
commit fe8fbf1d5d
2 changed files with 2 additions and 25 deletions

View File

@ -206,29 +206,9 @@ SHAPE_LINE_CHAIN MEANDER_SHAPE::makeMiterShape( VECTOR2D aP, VECTOR2D aDir, bool
{ {
case MEANDER_STYLE_ROUND: case MEANDER_STYLE_ROUND:
{ {
const int ArcSegments = Settings().m_cornerArcSegments; VECTOR2D center = aP + dir_v * ( aSide ? -1.0 : 1.0 );
double radius = (double) aDir.EuclideanNorm(); lc.Append( SHAPE_ARC( center, aP, ( aSide ? -90 : 90 ) ) );
double angleStep = M_PI / 2.0 / (double) ArcSegments;
double correction = 12.0 * radius * ( 1.0 - cos( angleStep / 2.0 ) );
if( !m_dual )
correction = 0.0;
else if( radius < m_meanCornerRadius )
correction = 0.0;
VECTOR2D dir_uu = dir_u.Resize( radius - correction );
VECTOR2D dir_vv = dir_v.Resize( radius - correction );
VECTOR2D shift = dir_u.Resize( correction );
for( int i = ArcSegments - 1; i >= 0; i-- )
{
double alpha = (double) i / (double) ( ArcSegments - 1 ) * M_PI / 2.0;
p = aP + shift + dir_uu * cos( alpha ) + dir_vv * ( aSide ? -1.0 : 1.0 ) * ( 1.0 - sin( alpha ) );
lc.Append( ( int ) p.x, ( int ) p.y );
}
} }
break; break;

View File

@ -70,7 +70,6 @@ public:
m_cornerStyle = MEANDER_STYLE_ROUND; m_cornerStyle = MEANDER_STYLE_ROUND;
m_cornerRadiusPercentage = 100; m_cornerRadiusPercentage = 100;
m_lengthTolerance = 100000; m_lengthTolerance = 100000;
m_cornerArcSegments = 8;
} }
///< Minimum meandering amplitude. ///< Minimum meandering amplitude.
@ -91,8 +90,6 @@ public:
int m_cornerRadiusPercentage; int m_cornerRadiusPercentage;
///< Allowable tuning error. ///< Allowable tuning error.
int m_lengthTolerance; int m_lengthTolerance;
///< Number of line segments for arc approximation.
int m_cornerArcSegments;
///< Target skew value for diff pair de-skewing. ///< Target skew value for diff pair de-skewing.
int m_targetSkew; int m_targetSkew;
}; };