Browse Source

Use consistent terminology and types.

pull/18/head
Jeff Young 5 months ago
parent
commit
6757ba8165
  1. 14
      common/io/cadstar/cadstar_archive_parser.cpp
  2. 24
      common/io/cadstar/cadstar_archive_parser.h
  3. 6
      common/io/easyeda/easyeda_parser_base.cpp
  4. 3
      common/io/easyeda/easyeda_parser_base.h
  5. 2
      eeschema/sch_io/eagle/sch_io_eagle.h
  6. 3
      libs/kimath/include/geometry/roundrect.h
  7. 17
      libs/kimath/include/geometry/shape_arc.h
  8. 9
      libs/kimath/include/geometry/shape_line_chain.h
  9. 4
      libs/kimath/include/geometry/shape_poly_set.h
  10. 5
      libs/kimath/src/geometry/roundrect.cpp
  11. 29
      libs/kimath/src/geometry/shape_arc.cpp
  12. 8
      libs/kimath/src/geometry/shape_line_chain.cpp
  13. 12
      libs/kimath/src/geometry/shape_poly_set.cpp
  14. 17
      pcbnew/pcb_io/easyeda/pcb_io_easyeda_parser.cpp
  15. 24
      pcbnew/pcb_io/easyedapro/pcb_io_easyedapro_parser.cpp
  16. 2
      pcbnew/pcb_io/easyedapro/pcb_io_easyedapro_parser.h
  17. 6
      pcbnew/tools/item_modification_routine.cpp

14
common/io/cadstar/cadstar_archive_parser.cpp

@ -484,7 +484,7 @@ void CADSTAR_ARCHIVE_PARSER::VERTEX::Parse( XNODE* aNode, PARSER_CONTEXT* aConte
void CADSTAR_ARCHIVE_PARSER::VERTEX::AppendToChain( SHAPE_LINE_CHAIN* aChainToAppendTo,
const std::function<VECTOR2I( const VECTOR2I& )> aCadstarToKicadPointCallback,
double aAccuracy ) const
int aAccuracy ) const
{
if( Type == VERTEX_TYPE::POINT )
{
@ -598,7 +598,7 @@ void CADSTAR_ARCHIVE_PARSER::SHAPE::Parse( XNODE* aNode, PARSER_CONTEXT* aContex
SHAPE_LINE_CHAIN CADSTAR_ARCHIVE_PARSER::SHAPE::OutlineAsChain(
const std::function<VECTOR2I( const VECTOR2I& )> aCadstarToKicadPointCallback,
double aAccuracy ) const
int aMaxError ) const
{
SHAPE_LINE_CHAIN outline;
@ -606,7 +606,7 @@ SHAPE_LINE_CHAIN CADSTAR_ARCHIVE_PARSER::SHAPE::OutlineAsChain(
return outline;
for( const auto& vertex : Vertices )
vertex.AppendToChain( &outline, aCadstarToKicadPointCallback, aAccuracy );
vertex.AppendToChain( &outline, aCadstarToKicadPointCallback, aMaxError );
if( Type != SHAPE_TYPE::OPENSHAPE )
{
@ -622,14 +622,14 @@ SHAPE_LINE_CHAIN CADSTAR_ARCHIVE_PARSER::SHAPE::OutlineAsChain(
SHAPE_POLY_SET CADSTAR_ARCHIVE_PARSER::SHAPE::ConvertToPolySet(
const std::function<VECTOR2I( const VECTOR2I& )> aCadstarToKicadPointCallback,
double aAccuracy ) const
int aMaxError ) const
{
SHAPE_POLY_SET polyset;
// We shouldn't convert openshapes to polyset!
wxCHECK( Type != SHAPE_TYPE::OPENSHAPE, polyset );
polyset.AddOutline( OutlineAsChain( aCadstarToKicadPointCallback, aAccuracy ) );
polyset.AddOutline( OutlineAsChain( aCadstarToKicadPointCallback, aMaxError ) );
for( const auto& cutout : Cutouts )
{
@ -639,12 +639,12 @@ SHAPE_POLY_SET CADSTAR_ARCHIVE_PARSER::SHAPE::ConvertToPolySet(
continue;
for( const auto& cutoutVertex : cutout.Vertices )
cutoutVertex.AppendToChain( &hole, aCadstarToKicadPointCallback, aAccuracy );
cutoutVertex.AppendToChain( &hole, aCadstarToKicadPointCallback, aMaxError );
hole.SetClosed( true );
// Append after closing, to ensre first and last point remain the same
cutout.Vertices.at( 0 ).AppendToChain( &hole, aCadstarToKicadPointCallback, aAccuracy );
cutout.Vertices.at( 0 ).AppendToChain( &hole, aCadstarToKicadPointCallback, aMaxError );
polyset.AddHole( hole );
}

24
common/io/cadstar/cadstar_archive_parser.h

@ -442,9 +442,10 @@ public:
*/
struct VERTEX : PARSER
{
VERTEX( VERTEX_TYPE aType = VERTEX_TYPE::POINT, POINT aEnd = POINT(),
POINT aCenter = POINT() ) :
Type( aType ), End( aEnd ), Center( aCenter )
VERTEX( VERTEX_TYPE aType = VERTEX_TYPE::POINT, POINT aEnd = POINT(), POINT aCenter = POINT() ) :
Type( aType ),
End( aEnd ),
Center( aCenter )
{}
VERTEX_TYPE Type;
@ -455,12 +456,11 @@ public:
void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
void AppendToChain( SHAPE_LINE_CHAIN* aChainToAppendTo,
const std::function<VECTOR2I( const VECTOR2I& )> aCadstarToKicadPointCallback,
double aAccuracy ) const;
const std::function<VECTOR2I( const VECTOR2I& )> aCadstarToKicadPointCallback,
int aAccuracy ) const;
SHAPE_ARC BuildArc( const VECTOR2I& aPrevPoint,
const std::function<VECTOR2I( const VECTOR2I& )>
aCadstarToKicadPointCallback ) const;
const std::function<VECTOR2I( const VECTOR2I& )> aCadstarToKicadPointCallback ) const;
};
/**
@ -493,13 +493,11 @@ public:
static bool IsShape( XNODE* aNode );
void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
SHAPE_LINE_CHAIN OutlineAsChain( const std::function<VECTOR2I( const VECTOR2I& )>
aCadstarToKicadPointCallback,
double aAccuracy ) const;
SHAPE_LINE_CHAIN OutlineAsChain( const std::function<VECTOR2I( const VECTOR2I& )> aCadstarToKicadPointCallback,
int aAccuracy ) const;
SHAPE_POLY_SET ConvertToPolySet( const std::function<VECTOR2I( const VECTOR2I& )>
aCadstarToKicadPointCallback,
double aAccuracy ) const;
SHAPE_POLY_SET ConvertToPolySet( const std::function<VECTOR2I( const VECTOR2I& )> aCadstarToKicadPointCallback,
int aAccuracy ) const;
};

6
common/io/easyeda/easyeda_parser_base.cpp

@ -108,7 +108,7 @@ void EASYEDA_PARSER_BASE::TransformTextToBaseline( EDA_TEXT* textItem,
std::vector<SHAPE_LINE_CHAIN>
EASYEDA_PARSER_BASE::ParseLineChains( const wxString& data, int aArcMinSegLen, bool aForceClosed )
EASYEDA_PARSER_BASE::ParseLineChains( const wxString& data, int aMaxError, bool aForceClosed )
{
std::vector<SHAPE_LINE_CHAIN> result;
@ -243,7 +243,7 @@ EASYEDA_PARSER_BASE::ParseLineChains( const wxString& data, int aArcMinSegLen, b
arc.ConstructFromStartEndCenter( RelPos( start ), RelPos( end ), RelPos( arcCenter ),
!cw );
chain.Append( arc, aArcMinSegLen );
chain.Append( arc, aMaxError );
prevPt = end;
}
@ -266,7 +266,7 @@ EASYEDA_PARSER_BASE::ParseLineChains( const wxString& data, int aArcMinSegLen, b
BEZIER_POLY converter( ctrlPoints );
std::vector<VECTOR2I> bezierPoints;
converter.GetPoly( bezierPoints, aArcMinSegLen );
converter.GetPoly( bezierPoints, aMaxError );
chain.Append( bezierPoints );

3
common/io/easyeda/easyeda_parser_base.h

@ -62,8 +62,7 @@ public:
void TransformTextToBaseline( EDA_TEXT* textItem, const wxString& baselineAlign );
std::vector<SHAPE_LINE_CHAIN> ParseLineChains( const wxString& aData, int aArcMinSegLen,
bool aForceClosed );
std::vector<SHAPE_LINE_CHAIN> ParseLineChains( const wxString& aData, int aMaxError, bool aForceClosed );
protected:
VECTOR2D m_relOrigin;

2
eeschema/sch_io/eagle/sch_io_eagle.h

@ -78,7 +78,7 @@ struct EAGLE_LIBRARY
class SCH_IO_EAGLE : public SCH_IO
{
public:
const double ARC_ACCURACY = SCH_IU_PER_MM * 0.01; // 0.01mm
const int ARC_ACCURACY = KiROUND( SCH_IU_PER_MM * 0.01 ); // 0.01mm
SCH_IO_EAGLE();
~SCH_IO_EAGLE();

3
libs/kimath/include/geometry/roundrect.h

@ -75,8 +75,7 @@ public:
/**
* Get the polygonal representation of the roundrect.
*/
void TransformToPolygon( SHAPE_POLY_SET& aBuffer, int aError, ERROR_LOC aErrorLoc ) const
/*override */;
void TransformToPolygon( SHAPE_POLY_SET& aBuffer ) const;
private:
SHAPE_RECT m_rect;

17
libs/kimath/include/geometry/shape_arc.h

@ -273,7 +273,7 @@ public:
*
* @return a default accuracy value for ConvertToPolyline() to build the polyline.
*/
static double DefaultAccuracyForPCB(){ return 0.005 * PCB_IU_PER_MM; }
static int DefaultAccuracyForPCB() { return ARC_HIGH_DEF; }
/**
* Construct a SHAPE_LINE_CHAIN of segments from a given arc.
@ -284,14 +284,14 @@ public:
*
* @todo Unify KiCad internal units.
*
* @param aAccuracy maximum divergence from true arc given in internal units.
* @param aEffectiveAccuracy is the actual divergence from true arc given.
* the approximation error is between -aEffectiveAccuracy/2 and +aEffectiveAccuracy/2
* in internal units
* @param aMaxError maximum divergence from true arc given in internal units.
* @param aActualError is the actual divergence from true arc given.
* the approximation error is between -aActualError/2 and
* +aActualError/2 in internal units
* @return a #SHAPE_LINE_CHAIN.
*/
const SHAPE_LINE_CHAIN ConvertToPolyline( double aAccuracy = DefaultAccuracyForPCB(),
double* aEffectiveAccuracy = nullptr ) const;
const SHAPE_LINE_CHAIN ConvertToPolyline( int aMaxError = DefaultAccuracyForPCB(),
int* aActualError = nullptr ) const;
bool operator==( SHAPE_ARC const& aArc ) const
{
@ -299,8 +299,7 @@ public:
&& ( aArc.m_width == m_width );
}
void TransformToPolygon( SHAPE_POLY_SET& aBuffer, int aError,
ERROR_LOC aErrorLoc ) const override;
void TransformToPolygon( SHAPE_POLY_SET& aBuffer, int aMaxError, ERROR_LOC aErrorLoc ) const override;
/**
* @return true if the arc is counter-clockwise.

9
libs/kimath/include/geometry/shape_line_chain.h

@ -334,10 +334,10 @@ public:
/**
* Simplify the line chain by removing colinear adjacent segments and duplicate vertices.
*
* @param aMaxError is the maximum error in internal units. Setting to 0 means that the
* @param aTolerance is the maximum tolerance in internal units. Setting to 0 means that the
* points must be exactly co-linear to be removed.
*/
void Simplify( int aMaxError = 0 );
void Simplify( int aTolerance = 0 );
// legacy function, used by the router. Please do not remove until I'll figure out
// the root cause of rounding errors - Tom
@ -533,7 +533,7 @@ public:
void Append( const SHAPE_LINE_CHAIN& aOtherLine );
void Append( const SHAPE_ARC& aArc );
void Append( const SHAPE_ARC& aArc, double aAccuracy );
void Append( const SHAPE_ARC& aArc, int aMaxError );
void Insert( size_t aVertex, const VECTOR2I& aP );
@ -956,6 +956,9 @@ private:
std::vector<SHAPE_ARC> m_arcs;
// the maxError to use when converting arcs to points
int m_accuracy;
/// is the line chain closed?
bool m_closed;

4
libs/kimath/include/geometry/shape_poly_set.h

@ -643,11 +643,11 @@ public:
* @param aArc The arc to be inserted
* @param aOutline Index of the polygon
* @param aHole Index of the hole (-1 for the main outline)
* @param aAccuracy Accuracy of the arc representation in IU
* @param aMaxError optional; accuracy of the arc representation in IU
* @return the number of points in the arc (including the interpolated points from the arc)
*/
int Append( const SHAPE_ARC& aArc, int aOutline = -1, int aHole = -1,
double aAccuracy = SHAPE_ARC::DefaultAccuracyForPCB() );
std::optional<int> aMaxError = {} );
/**
* Adds a vertex in the globally indexed position \a aGlobalIndex.

5
libs/kimath/src/geometry/roundrect.cpp

@ -52,7 +52,8 @@ SHAPE_ARC MakeSideArcCw180( const SHAPE_RECT& aRect, int aRadius, DIRECTION_45::
ROUNDRECT::ROUNDRECT( SHAPE_RECT aRect, int aRadius ) :
m_rect( std::move( aRect ) ), m_radius( aRadius )
m_rect( std::move( aRect ) ),
m_radius( aRadius )
{
if( m_radius > m_rect.MajorDimension() )
{
@ -79,7 +80,7 @@ ROUNDRECT ROUNDRECT::GetInflated( int aOutset ) const
}
void ROUNDRECT::TransformToPolygon( SHAPE_POLY_SET& aBuffer, int aError, ERROR_LOC aErrorLoc ) const
void ROUNDRECT::TransformToPolygon( SHAPE_POLY_SET& aBuffer ) const
{
const int idx = aBuffer.NewOutline();
SHAPE_LINE_CHAIN& outline = aBuffer.Outline( idx );

29
libs/kimath/src/geometry/shape_arc.cpp

@ -883,8 +883,7 @@ double SHAPE_ARC::GetRadius() const
}
const SHAPE_LINE_CHAIN SHAPE_ARC::ConvertToPolyline( double aAccuracy,
double* aEffectiveAccuracy ) const
const SHAPE_LINE_CHAIN SHAPE_ARC::ConvertToPolyline( int aMaxError, int* aActualError ) const
{
SHAPE_LINE_CHAIN rv;
double r = GetRadius();
@ -893,36 +892,36 @@ const SHAPE_LINE_CHAIN SHAPE_ARC::ConvertToPolyline( double aAccuracy,
EDA_ANGLE ca = GetCentralAngle();
SEG startToEnd( GetP0(), GetP1() );
double halfAccuracy = std::max( 1.0, aAccuracy / 2 );
double halfMaxError = std::max( 1.0, aMaxError / 2.0 );
int n;
// To calculate the arc to segment count, use the external radius instead of the radius.
// for a arc with small radius and large width, the difference can be significant
double external_radius = r+(m_width/2);
double effectiveAccuracy;
double external_radius = r + ( m_width / 2.0 );
double effectiveError;
if( external_radius < halfAccuracy
|| startToEnd.Distance( GetArcMid() ) < halfAccuracy ) // Should be a very rare case
if( external_radius < halfMaxError
|| startToEnd.Distance( GetArcMid() ) < halfMaxError ) // Should be a very rare case
{
// In this case, the arc is approximated by one segment, with a effective error
// between -aAccuracy/2 and +aAccuracy/2, as expected.
// between -aMaxError/2 and +aMaxError/2, as expected.
n = 0;
effectiveAccuracy = external_radius;
effectiveError = external_radius;
}
else
{
n = GetArcToSegmentCount( external_radius, aAccuracy, ca );
n = GetArcToSegmentCount( external_radius, aMaxError, ca );
// Recalculate the effective error of approximation, that can be < aAccuracy
// Recalculate the effective error of approximation, that can be < aMaxError
int seg360 = n * 360.0 / fabs( ca.AsDegrees() );
effectiveAccuracy = CircleToEndSegmentDeltaRadius( external_radius, seg360 );
effectiveError = CircleToEndSegmentDeltaRadius( external_radius, seg360 );
}
// Split the error on either side of the arc. Since we want the start and end points
// to be exactly on the arc, the first and last segments need to be shorter to stay within
// the error band (since segments normally start 1/2 the error band outside the arc).
r += effectiveAccuracy / 2;
r += effectiveError / 2;
n = n * 2;
rv.Append( m_start );
@ -942,8 +941,8 @@ const SHAPE_LINE_CHAIN SHAPE_ARC::ConvertToPolyline( double aAccuracy,
rv.Append( m_end );
if( aEffectiveAccuracy )
*aEffectiveAccuracy = effectiveAccuracy;
if( aActualError )
*aActualError = KiROUND( effectiveError );
return rv;
}

8
libs/kimath/src/geometry/shape_line_chain.cpp

@ -1584,9 +1584,9 @@ void SHAPE_LINE_CHAIN::Append( const SHAPE_ARC& aArc )
}
void SHAPE_LINE_CHAIN::Append( const SHAPE_ARC& aArc, double aAccuracy )
void SHAPE_LINE_CHAIN::Append( const SHAPE_ARC& aArc, int aMaxError )
{
SHAPE_LINE_CHAIN chain = aArc.ConvertToPolyline( aAccuracy );
SHAPE_LINE_CHAIN chain = aArc.ConvertToPolyline( aMaxError );
if( chain.PointCount() > 2 )
{
@ -2533,7 +2533,7 @@ void SHAPE_LINE_CHAIN::RemoveDuplicatePoints()
void SHAPE_LINE_CHAIN::Simplify( int aMaxError )
void SHAPE_LINE_CHAIN::Simplify( int aTolerance )
{
if( PointCount() < 3 )
return;
@ -2574,7 +2574,7 @@ void SHAPE_LINE_CHAIN::Simplify( int aMaxError )
}
// Test if the point is within the allowed error
if( !TestSegmentHit( m_points[test_idx], m_points[start_idx], m_points[end_idx], aMaxError ) )
if( !TestSegmentHit( m_points[test_idx], m_points[start_idx], m_points[end_idx], aTolerance ) )
{
can_simplify = false;
break;

12
libs/kimath/src/geometry/shape_poly_set.cpp

@ -287,7 +287,8 @@ int SHAPE_POLY_SET::Append( int x, int y, int aOutline, int aHole, bool aAllowDu
}
int SHAPE_POLY_SET::Append( const SHAPE_ARC& aArc, int aOutline, int aHole, double aAccuracy )
int SHAPE_POLY_SET::Append( const SHAPE_ARC& aArc, int aOutline, int aHole,
std::optional<int> aMaxError )
{
assert( m_polys.size() );
@ -304,7 +305,10 @@ int SHAPE_POLY_SET::Append( const SHAPE_ARC& aArc, int aOutline, int aHole, doub
assert( aOutline < (int) m_polys.size() );
assert( idx < (int) m_polys[aOutline].size() );
m_polys[aOutline][idx].Append( aArc, aAccuracy );
if( aMaxError.has_value() )
m_polys[aOutline][idx].Append( aArc, aMaxError.value() );
else
m_polys[aOutline][idx].Append( aArc );
return m_polys[aOutline][idx].PointCount();
}
@ -1863,13 +1867,13 @@ void SHAPE_POLY_SET::Simplify()
}
void SHAPE_POLY_SET::SimplifyOutlines( int aMaxError )
void SHAPE_POLY_SET::SimplifyOutlines( int aTolerance )
{
for( POLYGON& paths : m_polys )
{
for( SHAPE_LINE_CHAIN& path : paths )
{
path.Simplify( aMaxError );
path.Simplify( aTolerance );
}
}
}

17
pcbnew/pcb_io/easyeda/pcb_io_easyeda_parser.cpp

@ -434,7 +434,7 @@ void PCB_IO_EASYEDA_PARSER::ParseToBoardItemContainer(
//double textHeight = !arr[4].IsEmpty() ? ConvertSize( arr[4] ) : 0;
std::vector<SHAPE_LINE_CHAIN> lineChains =
ParseLineChains( shapeData, pcbIUScale.mmToIU( 0.01 ), false );
ParseLineChains( shapeData, SHAPE_ARC::DefaultAccuracyForPCB(), false );
std::unique_ptr<PCB_GROUP> group = std::make_unique<PCB_GROUP>( aContainer );
group->SetName( wxS( "Dimension" ) );
@ -464,7 +464,7 @@ void PCB_IO_EASYEDA_PARSER::ParseToBoardItemContainer(
wxString layer = arr[1];
SHAPE_POLY_SET polySet =
ParseLineChains( arr[3].Trim(), pcbIUScale.mmToIU( 0.01 ), true );
ParseLineChains( arr[3].Trim(), SHAPE_ARC::DefaultAccuracyForPCB(), true );
if( layer == wxS( "11" ) ) // Multi-layer (board cutout)
{
@ -539,7 +539,7 @@ void PCB_IO_EASYEDA_PARSER::ParseToBoardItemContainer(
}
SHAPE_POLY_SET polySet =
ParseLineChains( arr[4].Trim(), pcbIUScale.mmToIU( 0.01 ), true );
ParseLineChains( arr[4].Trim(), SHAPE_ARC::DefaultAccuracyForPCB(), true );
for( const SHAPE_POLY_SET::POLYGON& poly : polySet.CPolygons() )
zone->Outline()->AddPolygon( poly );
@ -561,7 +561,7 @@ void PCB_IO_EASYEDA_PARSER::ParseToBoardItemContainer(
for( const nlohmann::json& contourData : polyData )
{
SHAPE_POLY_SET contourPolySet = ParseLineChains(
contourData.get<wxString>(), pcbIUScale.mmToIU( 0.01 ), true );
contourData.get<wxString>(), SHAPE_ARC::DefaultAccuracyForPCB(), true );
SHAPE_POLY_SET currentOutline( contourPolySet.COutline( 0 ) );
@ -741,11 +741,12 @@ void PCB_IO_EASYEDA_PARSER::ParseToBoardItemContainer(
{
if( auto dataStr = get_opt( attributes, "d" ) )
{
int minSegLen = dataStr->size() < 8000 ? pcbIUScale.mmToIU( 0.005 )
: pcbIUScale.mmToIU( 0.05 );
int maxError = SHAPE_ARC::DefaultAccuracyForPCB();
SHAPE_POLY_SET polySet =
ParseLineChains( dataStr->Trim(), minSegLen, true );
if( dataStr->size() >= 8000 )
maxError *= 10;
SHAPE_POLY_SET polySet = ParseLineChains( dataStr->Trim(), maxError, true );
polySet.RebuildHolesFromContours();

24
pcbnew/pcb_io/easyedapro/pcb_io_easyedapro_parser.cpp

@ -459,7 +459,7 @@ PCB_IO_EASYEDAPRO_PARSER::ParsePoly( BOARD_ITEM_CONTAINER* aContainer, nlohmann:
SHAPE_LINE_CHAIN
PCB_IO_EASYEDAPRO_PARSER::ParseContour( nlohmann::json polyData, bool aInFill,
double aArcAccuracy ) const
int aMaxError ) const
{
SHAPE_LINE_CHAIN result;
VECTOR2D prevPt;
@ -478,7 +478,7 @@ PCB_IO_EASYEDAPRO_PARSER::ParseContour( nlohmann::json polyData, bool aInFill,
center.y = ( polyData.at( ++i ) );
double r = ( polyData.at( ++i ) );
TransformCircleToPolygon( result, ScalePos( center ), ScaleSize( r ), ARC_HIGH_DEF,
TransformCircleToPolygon( result, ScalePos( center ), ScaleSize( r ), aMaxError,
ERROR_INSIDE );
}
else if( str == wxS( "R" ) )
@ -498,9 +498,8 @@ PCB_IO_EASYEDAPRO_PARSER::ParseContour( nlohmann::json polyData, bool aInFill,
VECTOR2D kcenter = kstart + ksize / 2;
RotatePoint( kcenter, kstart, EDA_ANGLE( angle, DEGREES_T ) );
TransformRoundChamferedRectToPolygon(
poly, kcenter, ksize, EDA_ANGLE( angle, DEGREES_T ), ScaleSize( cr ), 0, 0,
0, ARC_HIGH_DEF, ERROR_INSIDE );
TransformRoundChamferedRectToPolygon( poly, kcenter, ksize, EDA_ANGLE( angle, DEGREES_T ),
ScaleSize( cr ), 0, 0, 0, aMaxError, ERROR_INSIDE );
result.Append( poly.Outline( 0 ) );
}
@ -531,7 +530,7 @@ PCB_IO_EASYEDAPRO_PARSER::ParseContour( nlohmann::json polyData, bool aInFill,
sarc.ConstructFromStartEndCenter( ScalePos( arcStart ), ScalePos( arcEnd ),
ScalePos( center ), angle >= 0, 0 );
result.Append( sarc, aArcAccuracy );
result.Append( sarc, aMaxError );
prevPt = end;
}
@ -554,7 +553,7 @@ PCB_IO_EASYEDAPRO_PARSER::ParseContour( nlohmann::json polyData, bool aInFill,
BEZIER_POLY converter( ctrlPoints );
std::vector<VECTOR2I> bezierPoints;
converter.GetPoly( bezierPoints, aArcAccuracy );
converter.GetPoly( bezierPoints, aMaxError );
result.Append( bezierPoints );
@ -588,7 +587,7 @@ PCB_IO_EASYEDAPRO_PARSER::ParseContour( nlohmann::json polyData, bool aInFill,
std::unique_ptr<PAD> PCB_IO_EASYEDAPRO_PARSER::createPAD( FOOTPRINT* aFootprint,
const nlohmann::json& line )
const nlohmann::json& line )
{
wxString uuid = line.at( 1 );
@ -729,8 +728,8 @@ std::unique_ptr<PAD> PCB_IO_EASYEDAPRO_PARSER::createPAD( FOOTPRINT*
FOOTPRINT* PCB_IO_EASYEDAPRO_PARSER::ParseFootprint( const nlohmann::json& aProject,
const wxString& aFpUuid,
const std::vector<nlohmann::json>& aLines )
const wxString& aFpUuid,
const std::vector<nlohmann::json>& aLines )
{
std::unique_ptr<FOOTPRINT> footprintPtr = std::make_unique<FOOTPRINT>( m_board );
FOOTPRINT* footprint = footprintPtr.get();
@ -1756,8 +1755,7 @@ void PCB_IO_EASYEDAPRO_PARSER::ParseBoard(
const nlohmann::json& fillData = poured.polyData[dataId];
const double ptScale = 10;
SHAPE_LINE_CHAIN contour =
ParseContour( fillData, false, ARC_HIGH_DEF / ptScale );
SHAPE_LINE_CHAIN contour = ParseContour( fillData, false, ARC_HIGH_DEF / ptScale );
// Scale the fill
for( int i = 0; i < contour.PointCount(); i++ )
@ -1789,7 +1787,7 @@ void PCB_IO_EASYEDAPRO_PARSER::ParseBoard(
const SEG& seg = contour.CSegment( segId );
TransformOvalToPolygon( thermalSpokes, seg.A, seg.B, thermalWidth,
ARC_LOW_DEF, ERROR_INSIDE );
ARC_HIGH_DEF, ERROR_INSIDE );
}
}
}

2
pcbnew/pcb_io/easyedapro/pcb_io_easyedapro_parser.h

@ -86,7 +86,7 @@ public:
bool aInFill ) const;
SHAPE_LINE_CHAIN ParseContour( nlohmann::json polyData, bool aInFill,
double aArcAccuracy = SHAPE_ARC::DefaultAccuracyForPCB() ) const;
int aMaxError = SHAPE_ARC::DefaultAccuracyForPCB() ) const;
private:
BOARD* m_board;

6
pcbnew/tools/item_modification_routine.cpp

@ -869,7 +869,7 @@ void OUTSET_ROUTINE::ProcessItem( BOARD_ITEM& aItem )
// No point doing a SHAPE_RECT as we may need to rotate it
ROUNDRECT rrect( box, radius );
SHAPE_POLY_SET poly;
rrect.TransformToPolygon( poly, 0, ERROR_LOC::ERROR_OUTSIDE );
rrect.TransformToPolygon( poly );
poly.Rotate( pad.GetOrientation(), pad.GetPosition() );
addPoly( poly );
@ -908,20 +908,20 @@ void OUTSET_ROUTINE::ProcessItem( BOARD_ITEM& aItem )
box.Inflate( m_params.outsetDistance );
SHAPE_RECT rect( box );
if( m_params.roundCorners )
{
try
{
ROUNDRECT rrect( rect, m_params.outsetDistance );
SHAPE_POLY_SET poly;
rrect.TransformToPolygon( poly, 0, ERROR_LOC::ERROR_OUTSIDE );
rrect.TransformToPolygon( poly );
addPoly( poly );
}
catch( const KI_PARAM_ERROR& error )
{
DisplayErrorMessage( nullptr, error.What() );
}
}
else
{

Loading…
Cancel
Save