Browse Source

Reduce excessive epsilon in polygon search algo

Fixes https://gitlab.com/kicad/code/kicad/-/issues/9903
6.0.7
Jon Evans 4 years ago
parent
commit
a9168860e0
  1. 11
      pcbnew/tools/convert_tool.cpp

11
pcbnew/tools/convert_tool.cpp

@ -255,7 +255,9 @@ SHAPE_POLY_SET CONVERT_TOOL::makePolysFromSegs( const std::deque<EDA_ITEM*>& aIt
// TODO: This code has a somewhat-similar purpose to ConvertOutlineToPolygon but is slightly
// different, so this remains a separate algorithm. It might be nice to analyze the dfiferences
// in requirements and refactor this.
const int chainingEpsilon = Millimeter2iu( 0.02 );
// Very tight epsilon used here to account for rounding errors in import, not sloppy drawing
const int chainingEpsilonSquared = SEG::Square( 100 );
SHAPE_POLY_SET poly;
@ -267,15 +269,18 @@ SHAPE_POLY_SET CONVERT_TOOL::makePolysFromSegs( const std::deque<EDA_ITEM*>& aIt
auto closeEnough =
[]( VECTOR2I aLeft, VECTOR2I aRight, unsigned aLimit )
{
return ( aLeft - aRight ).SquaredEuclideanNorm() <= SEG::Square( aLimit );
return ( aLeft - aRight ).SquaredEuclideanNorm() <= aLimit;
};
auto findInsertionPoint =
[&]( VECTOR2I aPoint ) -> VECTOR2I
{
if( connections.count( aPoint ) )
return aPoint;
for( const auto& candidatePair : connections )
{
if( closeEnough( aPoint, candidatePair.first, chainingEpsilon ) )
if( closeEnough( aPoint, candidatePair.first, chainingEpsilonSquared ) )
return candidatePair.first;
}

Loading…
Cancel
Save