← Back to team overview

kicad-developers team mailing list archive

Question about zone to polygon transformation

 

Hi all,

when converting a zone to a polygon, the function
TransformRoundedEndsSegmentToPolygon
is called on each segment of the polygon describing the zone. This is
done to enlarge the polygon. This leads to a large number of polygons
describing the zone.

Why isn't the polygon enlarged using the clipper library?

Attached is a patch which reduces the complexity of the polygons
generated considerably. The patch is untested and not intended to be
merged, it's just to illustrate my question. If the clipper library is
not used here only for historic reasons, I'd create a tested patch in
the coming weeks.

thanks a lot in advance and best regards,
Andreas
diff --git a/pcbnew/board_items_to_polygon_shape_transform.cpp b/pcbnew/board_items_to_polygon_shape_transform.cpp
index 7f64d4e..ba11704 100644
--- a/pcbnew/board_items_to_polygon_shape_transform.cpp
+++ b/pcbnew/board_items_to_polygon_shape_transform.cpp
@@ -361,23 +361,9 @@ void ZONE_CONTAINER::TransformSolidAreasShapesToPolygonSet(
         return;
 
     // add filled areas polygons
-    aCornerBuffer.Append( m_FilledPolysList );
-
-    // add filled areas outlines, which are drawn with thick lines
-    for( int i = 0; i < m_FilledPolysList.OutlineCount(); i++ )
-    {
-        const SHAPE_LINE_CHAIN& path = m_FilledPolysList.COutline( i );
-
-        for( int j = 0; j < path.PointCount(); j++ )
-        {
-            const VECTOR2I& a = path.CPoint( j );
-            const VECTOR2I& b = path.CPoint( j + 1 );
-
-            TransformRoundedEndsSegmentToPolygon( aCornerBuffer, wxPoint( a.x, a.y ), wxPoint( b.x, b.y ),
-                                                    aCircleToSegmentsCount,
-                                                    GetMinThickness() );
-        }
-    }
+    SHAPE_POLY_SET polyList(m_FilledPolysList);
+    polyList.Inflate(GetMinThickness() / 2, aCircleToSegmentsCount);
+    aCornerBuffer.Append( polyList );
 }
 
 /**

Follow ups