Allow more segments for large-arc footprints

When approximating arcs for polygons, we should allow for large radius
arcs/circles without coarsening the arc beyond a limit.  This is a
5.1.x-only patch to address this issue.  It should not be picked to
master as this is already addressed separately by max_error
This commit is contained in:
Seth Hillbrand 2019-06-28 19:23:42 -07:00
parent cabfcbc73c
commit bf1ced4184
1 changed files with 22 additions and 8 deletions

View File

@ -36,8 +36,9 @@
#include <class_drawsegment.h> #include <class_drawsegment.h>
#include <class_edge_mod.h> #include <class_edge_mod.h>
#include <convert_basic_shapes_to_polygon.h> #include <convert_basic_shapes_to_polygon.h>
#include <geometry/shape_rect.h>
#include <geometry/convex_hull.h> #include <geometry/convex_hull.h>
#include <geometry/shape_rect.h>
#include <geometry/geometry_utils.h>
void PAD_CS_PRIMITIVE::ExportTo( DRAWSEGMENT* aTarget ) void PAD_CS_PRIMITIVE::ExportTo( DRAWSEGMENT* aTarget )
@ -193,26 +194,39 @@ bool D_PAD::buildCustomPadPolygon( SHAPE_POLY_SET* aMergedPolygon,
switch( bshape.m_Shape ) switch( bshape.m_Shape )
{ {
case S_SEGMENT: // usual segment : line with rounded ends case S_SEGMENT: // usual segment : line with rounded ends
TransformRoundedEndsSegmentToPolygon( aux_polyset, {
bshape.m_Start, bshape.m_End, aCircleToSegmentsCount, bshape.m_Thickness ); int numSegs = std::max(
GetArcToSegmentCount( bshape.m_Thickness / 2, ARC_HIGH_DEF, 360.0 ),
aCircleToSegmentsCount );
TransformRoundedEndsSegmentToPolygon( aux_polyset, bshape.m_Start, bshape.m_End,
numSegs, bshape.m_Thickness );
break; break;
}
case S_ARC: // Arc with rounded ends case S_ARC: // Arc with rounded ends
TransformArcToPolygon( aux_polyset, {
bshape.m_Start, bshape.m_End, bshape.m_ArcAngle, int numSegs = std::max( GetArcToSegmentCount( bshape.m_Radius, ARC_HIGH_DEF, 360.0 ),
aCircleToSegmentsCount, bshape.m_Thickness ); aCircleToSegmentsCount );
TransformArcToPolygon( aux_polyset, bshape.m_Start, bshape.m_End, bshape.m_ArcAngle,
numSegs, bshape.m_Thickness );
break; break;
}
case S_CIRCLE: // ring or circle case S_CIRCLE: // ring or circle
{
int numSegs = std::max( GetArcToSegmentCount( bshape.m_Radius, ARC_HIGH_DEF, 360.0 ),
aCircleToSegmentsCount );
if( bshape.m_Thickness ) // ring if( bshape.m_Thickness ) // ring
TransformRingToPolygon( aux_polyset, TransformRingToPolygon( aux_polyset,
bshape.m_Start, bshape.m_Radius, bshape.m_Start, bshape.m_Radius,
aCircleToSegmentsCount, bshape.m_Thickness ) ; numSegs, bshape.m_Thickness ) ;
else // Filled circle else // Filled circle
TransformCircleToPolygon( aux_polyset, TransformCircleToPolygon( aux_polyset,
bshape.m_Start, bshape.m_Radius, bshape.m_Start, bshape.m_Radius,
aCircleToSegmentsCount ) ; numSegs ) ;
break; break;
}
case S_POLYGON: // polygon case S_POLYGON: // polygon
if( bshape.m_Poly.size() < 2 ) if( bshape.m_Poly.size() < 2 )