From df47c1c4e9a602e61410dd98ab870bc99e1e616b Mon Sep 17 00:00:00 2001 From: Tomasz Wlostowski Date: Mon, 25 Oct 2021 17:36:04 +0200 Subject: [PATCH] pcbnew: use doubles to pass line widths in the DXF importer as they are expressed in DXF's units and can case severe rounding errors when passed as ints --- pcbnew/import_gfx/dxf_import_plugin.cpp | 8 ++++---- pcbnew/import_gfx/dxf_import_plugin.h | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pcbnew/import_gfx/dxf_import_plugin.cpp b/pcbnew/import_gfx/dxf_import_plugin.cpp index b9b0cbac64..110625318f 100644 --- a/pcbnew/import_gfx/dxf_import_plugin.cpp +++ b/pcbnew/import_gfx/dxf_import_plugin.cpp @@ -1201,7 +1201,7 @@ void DXF_IMPORT_PLUGIN::addPoint( const DL_PointData& aData ) void DXF_IMPORT_PLUGIN::insertLine( const VECTOR2D& aSegStart, - const VECTOR2D& aSegEnd, int aWidth ) + const VECTOR2D& aSegEnd, double aWidth ) { VECTOR2D origin( SCALE_FACTOR( aSegStart.x ), SCALE_FACTOR( aSegStart.y ) ); VECTOR2D end( SCALE_FACTOR( aSegEnd.x ), SCALE_FACTOR( aSegEnd.y ) ); @@ -1216,7 +1216,7 @@ void DXF_IMPORT_PLUGIN::insertLine( const VECTOR2D& aSegStart, void DXF_IMPORT_PLUGIN::insertArc( const VECTOR2D& aSegStart, const VECTOR2D& aSegEnd, - double aBulge, int aWidth ) + double aBulge, double aWidth ) { VECTOR2D segment_startpoint( SCALE_FACTOR( aSegStart.x ), SCALE_FACTOR( aSegStart.y ) ); VECTOR2D segment_endpoint( SCALE_FACTOR( aSegEnd.x ), SCALE_FACTOR( aSegEnd.y ) ); @@ -1297,7 +1297,7 @@ void DXF_IMPORT_PLUGIN::insertArc( const VECTOR2D& aSegStart, const VECTOR2D& aS #include "tinysplinecpp.h" -void DXF_IMPORT_PLUGIN::insertSpline( int aWidth ) +void DXF_IMPORT_PLUGIN::insertSpline( double aWidth ) { #if 0 // Debug only wxLogMessage("spl deg %d kn %d ctr %d fit %d", @@ -1450,4 +1450,4 @@ VECTOR3D DXF_IMPORT_PLUGIN::ocsToWcs( const DXF_ARBITRARY_AXIS& arbitraryAxis, V z = point.x * worldZ.x + point.y * worldZ.y + point.z * worldZ.z; return VECTOR3D( x, y, z ); -} \ No newline at end of file +} diff --git a/pcbnew/import_gfx/dxf_import_plugin.h b/pcbnew/import_gfx/dxf_import_plugin.h index e5f7b2e53a..ad4c1e9ee9 100644 --- a/pcbnew/import_gfx/dxf_import_plugin.h +++ b/pcbnew/import_gfx/dxf_import_plugin.h @@ -373,12 +373,12 @@ private: DXF_IMPORT_STYLE* getImportStyle( const std::string& aStyleName ); // Functions to aid in the creation of a Polyline. - void insertLine( const VECTOR2D& aSegStart, const VECTOR2D& aSegEnd, int aWidth ); + void insertLine( const VECTOR2D& aSegStart, const VECTOR2D& aSegEnd, double aWidth ); void insertArc( const VECTOR2D& aSegStart, const VECTOR2D& aSegEnd, - double aBulge, int aWidth ); + double aBulge, double aWidth ); // Add a dxf spline (stored in m_curr_entity) to the board, after conversion to segments. - void insertSpline( int aWidth ); + void insertSpline( double aWidth ); // Methods from DL_CreationAdapter: // They are something like"call back" functions,