Pcbnew, graphic importer: do not import 0 length segments and smaller than 20 nm Bezier curves.

Degenerated Bezier curves (i.e. straight lines) are imported as segments.
They create issues in kicad because they are hard to edit and manage.
This commit is contained in:
jean-pierre charras 2022-12-13 20:23:40 +01:00
parent af4e9968fc
commit 88038907fa
1 changed files with 19 additions and 0 deletions

View File

@ -67,6 +67,11 @@ void GRAPHICS_IMPORTER_PCBNEW::AddLine( const VECTOR2D& aOrigin, const VECTOR2D&
line->SetStart( MapCoordinate( aOrigin ) );
line->SetEnd( MapCoordinate( aEnd ) );
// Skip 0 len lines:
if( line->GetStart() == line->GetEnd() )
return;
if( line->Type() == PCB_FP_SHAPE_T )
static_cast<FP_SHAPE*>( line.get() )->SetLocalCoord();
@ -181,6 +186,20 @@ void GRAPHICS_IMPORTER_PCBNEW::AddSpline( const VECTOR2D& aStart, const VECTOR2D
spline->SetEnd( MapCoordinate( aEnd ) );
spline->RebuildBezierToSegmentsPointsList( aWidth );
// If the spline is degenerated (i.e. a segment) add it as segment or discard it if
// null (i.e. very small) length
if( spline->GetBezierPoints().size() <= 2 )
{
spline->SetShape( SHAPE_T::SEGMENT );
int dist = VECTOR2I(spline->GetStart()- spline->GetEnd()).EuclideanNorm();
// segment smaller than MIN_SEG_LEN_ACCEPTABLE_NM nanometers are skipped.
#define MIN_SEG_LEN_ACCEPTABLE_NM 20
if( dist < MIN_SEG_LEN_ACCEPTABLE_NM )
return;
}
if( spline->Type() == PCB_FP_SHAPE_T )
static_cast<FP_SHAPE*>( spline.get() )->SetLocalCoord();