PAD::MergePrimitivesAsPolygon(): add option to approximate circles outside the actual shape

When creating a polygon from an arc/circle, the small error due to approximation
can be now inside (when drawing/plotting the shape) or outside the circle
(when building a clearance area) like other pad shapes
Fixes #5313
https://gitlab.com/kicad/code/kicad/issues/5313
This commit is contained in:
jean-pierre charras 2021-04-18 18:54:36 +02:00
parent ae91042544
commit dc3a73a2fb
3 changed files with 15 additions and 6 deletions

View File

@ -1,8 +1,8 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2009-2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2009-2021 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -731,7 +731,7 @@ void PAD::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer,
case PAD_SHAPE_CUSTOM:
{
SHAPE_POLY_SET outline;
MergePrimitivesAsPolygon( &outline, aLayer );
MergePrimitivesAsPolygon( &outline, aLayer, aErrorLoc );
outline.Rotate( -DECIDEG2RAD( m_orient ) );
outline.Move( VECTOR2I( m_pos ) );

View File

@ -279,8 +279,16 @@ public:
* Merge all basic shapes to a #SHAPE_POLY_SET.
*
* @note The results are relative to the pad position, orientation 0.
*
* @param aMergedPolygon will store the final polygon
* @param aLayer is the layer to take in account, as the exact shape can depend on the layer
* @param aErrorLoc is used when a circle (or arc) is approximated by segments
* = ERROR_INSIDE to build a polygon inside the arc/circle (usual shape to raw/plot)
* = ERROR_OUIDE to build a polygon outside the arc/circle
* (for instance when building a clearance area)
*/
void MergePrimitivesAsPolygon( SHAPE_POLY_SET* aMergedPolygon, PCB_LAYER_ID aLayer ) const;
void MergePrimitivesAsPolygon( SHAPE_POLY_SET* aMergedPolygon, PCB_LAYER_ID aLayer,
ERROR_LOC aErrorLoc = ERROR_INSIDE ) const;
/**
* Clear the basic shapes list.

View File

@ -200,7 +200,8 @@ void PAD::addPadPrimitivesToPolygon( SHAPE_POLY_SET* aMergedPolygon, PCB_LAYER_I
}
}
void PAD::MergePrimitivesAsPolygon( SHAPE_POLY_SET* aMergedPolygon, PCB_LAYER_ID aLayer ) const
void PAD::MergePrimitivesAsPolygon( SHAPE_POLY_SET* aMergedPolygon, PCB_LAYER_ID aLayer,
ERROR_LOC aErrorLoc ) const
{
BOARD* board = GetBoard();
int maxError = board ? board->GetDesignSettings().m_MaxError: ARC_HIGH_DEF;
@ -225,7 +226,7 @@ void PAD::MergePrimitivesAsPolygon( SHAPE_POLY_SET* aMergedPolygon, PCB_LAYER_ID
break;
}
addPadPrimitivesToPolygon( aMergedPolygon, aLayer, maxError, ERROR_INSIDE );
addPadPrimitivesToPolygon( aMergedPolygon, aLayer, maxError, aErrorLoc );
}