From bc59ed08b4e29d0b8229f3e93d3f3703fff2a2e7 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Fri, 18 Aug 2023 12:58:48 +0200 Subject: [PATCH] EDA_SHAPE::TransformShapeToPolygon() for filled SHAPE_T::POLY: use another algo: previously, for aClearance/width > 0, a seg of segments (width = aClearance*2) was added to the polygon shape. This is acceptable for polygons having not a log of vertices. It does not work fine (bad shape, extremeny long calculation time) if there are a **lot** of vertices. Now the polygonal shape is just inflated by width/2. Much faster and better shape. --- common/eda_shape.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/common/eda_shape.cpp b/common/eda_shape.cpp index 9b50825123..30fa37b63f 100644 --- a/common/eda_shape.cpp +++ b/common/eda_shape.cpp @@ -1562,18 +1562,22 @@ void EDA_SHAPE::TransformShapeToPolygon( SHAPE_POLY_SET& aBuffer, int aClearance if( IsFilled() ) { - aBuffer.NewOutline(); - for( int ii = 0; ii < m_poly.OutlineCount(); ++ii ) { const SHAPE_LINE_CHAIN& poly = m_poly.Outline( ii ); + SHAPE_POLY_SET tmp; + tmp.NewOutline(); for( int jj = 0; jj < (int) poly.GetPointCount(); ++jj ) - aBuffer.Append( poly.GetPoint( jj ) ); + tmp.Append( poly.GetPoint( jj ) ); + + if( width > 0 ) + tmp.Inflate( width/2, SHAPE_POLY_SET::ROUND_ALL_CORNERS, aError, false); + + aBuffer.Append( tmp ); } } - - if( width > 0 || !IsFilled() ) + else { for( int ii = 0; ii < m_poly.OutlineCount(); ++ii ) {