Fix silk board edge collision case

First, fix the error limit check in drc_test_provider_edge_clearance.
Then, we rotate the final point incorrectly in SHAPE_ARC::Collide (need
negative angle).  We were not checking this result in the QA, so add the
proper tests
This commit is contained in:
Seth Hillbrand 2025-05-19 17:45:59 -07:00
parent 6ca8078ca4
commit 9bedb6eedb
3 changed files with 26 additions and 11 deletions

View File

@ -786,7 +786,7 @@ bool SHAPE_ARC::Collide( const VECTOR2I& aP, int aClearance, int* aActual,
// because this trucates the distance to an integer before subtracting
dist = KiROUND( radius - sqrt( ( aP - center ).SquaredEuclideanNorm() ) );
nearestPt = center + VECTOR2I( radius, 0 );
RotatePoint( nearestPt, center, angleToPt );
RotatePoint( nearestPt, center, -angleToPt );
}
// If not a 360 degree arc, need to use arc angles to decide if point collides

View File

@ -150,7 +150,7 @@ bool DRC_TEST_PROVIDER_EDGE_CLEARANCE::Run()
if( !reportPhase( _( "Checking copper to board edge clearances..." ) ) )
return false; // DRC cancelled
}
else if( m_drcEngine->IsErrorLimitExceeded( DRCE_SILK_EDGE_CLEARANCE ) )
else if( !m_drcEngine->IsErrorLimitExceeded( DRCE_SILK_EDGE_CLEARANCE ) )
{
if( !reportPhase( _( "Checking silk to board edge clearances..." ) ) )
return false; // DRC cancelled

View File

@ -670,22 +670,25 @@ struct ARC_SEG_COLLIDE_CASE : public KI_TEST::NAMED_CASE
SEG m_seg;
bool m_exp_result;
int m_exp_distance;
VECTOR2I m_collide_point;
};
static const std::vector<ARC_SEG_COLLIDE_CASE> arc_seg_collide_cases = {
{ "0 deg ", { { 0, 0 }, { 100, 0 }, 270.0 }, 0, { { 100, 0 }, { 50, 0 } }, true, 0 },
{ "90 deg ", { { 0, 0 }, { 100, 0 }, 270.0 }, 0, { { 0, 100 }, { 0, 50 } }, true, 0 },
{ "180 deg ", { { 0, 0 }, { 100, 0 }, 270.0 }, 0, { { -100, 0 }, { -50, 0 } }, true, 0 },
{ "270 deg ", { { 0, 0 }, { 100, 0 }, 270.0 }, 0, { { 0, -100 }, { 0, -50 } }, true, 0 },
{ "45 deg ", { { 0, 0 }, { 100, 0 }, 270.0 }, 0, { { 71, 71 }, { 35, 35 } }, true, 0 },
{ "-45 deg ", { { 0, 0 }, { 100, 0 }, 270.0 }, 0, { { 71, -71 }, { 35, -35 } }, false, -1 },
{ "0 deg ", { { 0, 0 }, { 100, 0 }, 270.0 }, 0, { { 100, 0 }, { 50, 0 } }, true, 0, { 100, 0 } },
{ "90 deg ", { { 0, 0 }, { 100, 0 }, 270.0 }, 0, { { 0, 100 }, { 0, 50 } }, true, 0, { 0, 100 } },
{ "180 deg ", { { 0, 0 }, { 100, 0 }, 270.0 }, 0, { { -100, 0 }, { -50, 0 } }, true, 0, { -100, 0 } },
{ "270 deg ", { { 0, 0 }, { 100, 0 }, 270.0 }, 0, { { 0, -100 }, { 0, -50 } }, true, 0, { 0, -100 } },
{ "45 deg ", { { 0, 0 }, { 100, 0 }, 270.0 }, 0, { { 71, 71 }, { 35, 35 } }, true, 0, { 70, 70 } },
{ "-45 deg ", { { 0, 0 }, { 100, 0 }, 270.0 }, 0, { { 71, -71 }, { 35, -35 } }, false, -1, { 0, 0 } },
{ "seg inside arc start", { { 0, 0 }, { 71, -71 }, 90.0 },
10, { { 90, 0 }, { -35, 0 } }, true, 10 },
10, { { 90, 0 }, { -35, 0 } }, true, 10, { 100, 0 } },
{ "seg inside arc end", { { 0, 0 }, { 71, -71 }, 90.0 },
10, { { -35, 0 }, { 90, 0 } }, true, 10 },
10, { { -35, 0 }, { 90, 0 } }, true, 10, { 100, 0 } },
{ "large diameter arc", { { 172367922, 82282076 }, { 162530000, 92120000 }, -45.0 },
433300, { { 162096732, 92331236 }, { 162096732, 78253268 } }, true, 433268 },
433300, { { 162096732, 92331236 }, { 162096732, 78253268 } }, true, 433268, { 162530000, 92120000 } },
{ "upside down collide", { { 26250000, 16520000 }, { 28360000, 16520000 }, 90.0 },
0, { { 27545249, 18303444 }, { 27545249, 18114500 } }, true, 0, { 27545249, 18185662 } }
};
@ -715,6 +718,18 @@ BOOST_DATA_TEST_CASE( CollideSeg, boost::unit_test::data::make( arc_seg_collide_
else
BOOST_CHECK_EQUAL( dist, -1 );
}
BOOST_TEST_CONTEXT( "Test Collide Point" )
{
VECTOR2I collide_point;
int dist = -1;
if( c.m_exp_result )
{
arc.Collide( c.m_seg, c.m_arc_clearance, &dist, &collide_point );
BOOST_CHECK_EQUAL( collide_point, c.m_collide_point );
}
}
}
struct ARC_DATA_MM