Pcbnew, graphic importer: convert arc with large radius to segment.
Arcs having a too large radius cannot be safely handled. The criteria (not perfect) is radius < INT_MAX/2 to use arcs Fixes #14210 https://gitlab.com/kicad/code/kicad/-/issues/14210
This commit is contained in:
parent
414fca0664
commit
f6f99e45b9
|
@ -116,6 +116,21 @@ void GRAPHICS_IMPORTER_PCBNEW::AddArc( const VECTOR2D& aCenter, const VECTOR2D&
|
||||||
|
|
||||||
arc->SetArcGeometry( MapCoordinate( aStart ), MapCoordinate( mid ), MapCoordinate( end ) );
|
arc->SetArcGeometry( MapCoordinate( aStart ), MapCoordinate( mid ), MapCoordinate( end ) );
|
||||||
|
|
||||||
|
// Ensure the arc can be handled by Pcbnew. Arcs with a too big radius cannot.
|
||||||
|
// The criteria used here is radius < MAX_INT / 2.
|
||||||
|
// this is not perfect, but we do not know the exact final position of the arc, so
|
||||||
|
// we cannot test the coordinate values, because the arc can be moved before being placed.
|
||||||
|
VECTOR2D center = CalcArcCenter( arc->GetStart(), arc->GetEnd(), aAngle );
|
||||||
|
double radius = ( center - arc->GetStart() ).EuclideanNorm();
|
||||||
|
double rd_max_value = std::numeric_limits<VECTOR2I::coord_type>::max() / 2.0;
|
||||||
|
|
||||||
|
if( radius >= rd_max_value )
|
||||||
|
{
|
||||||
|
// Arc cannot be handled: convert it to a segment
|
||||||
|
AddLine( aStart, end, aWidth );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
arc->SetStroke( STROKE_PARAMS( MapLineWidth( aWidth ), PLOT_DASH_TYPE::SOLID ) );
|
arc->SetStroke( STROKE_PARAMS( MapLineWidth( aWidth ), PLOT_DASH_TYPE::SOLID ) );
|
||||||
|
|
||||||
if( arc->Type() == PCB_FP_SHAPE_T )
|
if( arc->Type() == PCB_FP_SHAPE_T )
|
||||||
|
|
Loading…
Reference in New Issue