Add more test cases: simulate zone fill around arc + diff pair meander
This commit is contained in:
parent
f2925dc6cb
commit
318435aedb
|
@ -120,6 +120,13 @@ public:
|
|||
bool Collide( const VECTOR2I& aP, int aClearance = 0, int* aActual = nullptr,
|
||||
VECTOR2I* aLocation = nullptr ) const override;
|
||||
|
||||
|
||||
bool Collide( const SHAPE* aShape, int aClearance = 0, int* aActual = nullptr,
|
||||
VECTOR2I* aLocation = nullptr ) const override
|
||||
{
|
||||
return SHAPE::Collide( aShape, aClearance, aActual, aLocation );
|
||||
}
|
||||
|
||||
bool IsClockwise() const;
|
||||
|
||||
void SetWidth( int aWidth )
|
||||
|
|
|
@ -653,7 +653,7 @@ struct ARC_ARC_COLLIDE_CASE
|
|||
std::string m_ctx_name;
|
||||
ARC_DATA_MM m_arc1;
|
||||
ARC_DATA_MM m_arc2;
|
||||
int m_clearance;
|
||||
double m_clearance;
|
||||
bool m_exp_result;
|
||||
};
|
||||
|
||||
|
@ -714,6 +714,11 @@ static const std::vector<ARC_ARC_COLLIDE_CASE> arc_arc_collide_cases = {
|
|||
{ 86.063537, 88.295989, 84.968628, 87.581351, -255.5, 0.2 },
|
||||
0,
|
||||
true },
|
||||
{ "case 12: Simulated differential pair meander",
|
||||
{ 94.6551, 88.295989, 95.6551, 88.295989, 90.0, 0.1 },
|
||||
{ 94.6551, 88.295989, 95.8551, 88.295989, 90.0, 0.1 },
|
||||
0.1 - SHAPE_ARC::DefaultAccuracyForPCB() / PCB_IU_PER_MM, // remove offset when support for true arc-arc intersection
|
||||
false },
|
||||
};
|
||||
|
||||
|
||||
|
@ -729,27 +734,59 @@ BOOST_AUTO_TEST_CASE( CollideArc )
|
|||
int actual = 0;
|
||||
VECTOR2I location;
|
||||
|
||||
bool result = static_cast<SHAPE*>( &arc1 )->Collide( &arc2, c.m_clearance, &actual,
|
||||
&location );
|
||||
bool result = arc1.Collide( &arc2, PcbMillimeter2iu( c.m_clearance ), &actual, &location );
|
||||
|
||||
BOOST_CHECK_EQUAL( result, c.m_exp_result );
|
||||
|
||||
// Test conversion to polygon
|
||||
/*
|
||||
SHAPE_POLY_SET poly;
|
||||
|
||||
TransformArcToPolygon( poly, wxPoint( arc1.GetP0() ), wxPoint( arc1.GetArcMid() ),
|
||||
wxPoint( arc1.GetP1() ), arc1.GetWidth() * 2,
|
||||
SHAPE_ARC::DefaultAccuracyForPCB(), ERROR_OUTSIDE );
|
||||
|
||||
bool result2 = poly.Collide( &arc1, arc1.GetWidth(), &actual, &location);
|
||||
|
||||
BOOST_CHECK_EQUAL( result2, false );*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE( CollideArcToPolygonApproximation )
|
||||
{
|
||||
SHAPE_ARC arc( VECTOR2I( 73843527, 74355869 ), VECTOR2I( 71713528, 72965869 ), -76.36664803,
|
||||
2000000 );
|
||||
|
||||
// Create a polyset approximation from the arc - error outside (simulating the zone filler)
|
||||
SHAPE_POLY_SET arcBuffer;
|
||||
int clearance = ( arc.GetWidth() * 3 ) / 2;
|
||||
|
||||
TransformArcToPolygon( arcBuffer, wxPoint( arc.GetP0() ), wxPoint( arc.GetArcMid() ),
|
||||
wxPoint( arc.GetP1() ), arc.GetWidth() + 2 * clearance,
|
||||
SHAPE_ARC::DefaultAccuracyForPCB(), ERROR_OUTSIDE );
|
||||
|
||||
BOOST_REQUIRE_EQUAL( arcBuffer.OutlineCount(), 1 );
|
||||
BOOST_CHECK_EQUAL( arcBuffer.HoleCount( 0 ), 0 );
|
||||
|
||||
// Make a reasonably large rectangular outline around the arc shape
|
||||
BOX2I arcbbox = arc.BBox( clearance * 4 );
|
||||
|
||||
SHAPE_LINE_CHAIN zoneOutline( { arcbbox.GetPosition(),
|
||||
arcbbox.GetPosition() + VECTOR2I( arcbbox.GetWidth(), 0 ),
|
||||
arcbbox.GetEnd(),
|
||||
arcbbox.GetEnd() - VECTOR2I( arcbbox.GetWidth(), 0 )
|
||||
},
|
||||
true );
|
||||
|
||||
// Create a synthetic "zone fill" polygon
|
||||
SHAPE_POLY_SET zoneFill;
|
||||
zoneFill.AddOutline( zoneOutline );
|
||||
zoneFill.AddHole( arcBuffer.Outline( 0 ) );
|
||||
|
||||
int actual = 0;
|
||||
VECTOR2I location;
|
||||
|
||||
int tol = SHAPE_ARC::DefaultAccuracyForPCB();
|
||||
|
||||
//@todo remove "- tol" from collision check below once true arc collisions have been implemented
|
||||
BOOST_CHECK_EQUAL( zoneFill.Collide( &arc, clearance - tol, &actual, &location ), false );
|
||||
|
||||
BOOST_CHECK_EQUAL( zoneFill.Collide( &arc, clearance * 2, &actual, &location ), true );
|
||||
|
||||
BOOST_CHECK( KI_TEST::IsWithin( actual, clearance, tol ) );
|
||||
}
|
||||
|
||||
|
||||
struct ARC_TO_POLYLINE_CASE
|
||||
{
|
||||
std::string m_ctx_name;
|
||||
|
|
|
@ -297,6 +297,8 @@ int playground_main_func( int argc, char* argv[] )
|
|||
{79.063537, 88.295989, 77.968628, 87.581351, -255.5, 0.2},
|
||||
{85.915251, 86.993054, 86.970159, 87.757692, 99.5, 0.2}, // intersection - false negative
|
||||
{86.063537, 88.295989, 84.968628, 87.581351, -255.5, 0.2},
|
||||
{94.6551, 88.295989, 95.6551, 88.295989, 90.0, 0.2 }, // simulating diff pair
|
||||
{94.6551, 88.295989, 95.8551, 88.295989, 90.0, 0.2 },
|
||||
};
|
||||
|
||||
|
||||
|
@ -339,6 +341,22 @@ int playground_main_func( int argc, char* argv[] )
|
|||
bool collides = collideArc2Arc( arcs[i], arcs[i+1], 0, closestDist );
|
||||
int ni = intersectArc2Arc( arcs[i], arcs[i+1], ips );
|
||||
|
||||
overlay->SetLineWidth( 10000.0 );
|
||||
overlay->SetStrokeColor( GREEN );
|
||||
|
||||
for( int j = 0; j < ni; j++ )
|
||||
overlay->AnnotatedPoint( ips[j], arcs[i].GetWidth() );
|
||||
|
||||
if( collides )
|
||||
{
|
||||
overlay->SetStrokeColor( YELLOW );
|
||||
overlay->Line( closestDist.A, closestDist.B );
|
||||
overlay->SetLineWidth( 10000.0 );
|
||||
overlay->SetGlyphSize( { 100000.0, 100000.0 } );
|
||||
overlay->BitmapText( wxString::Format( "dist: %d", closestDist.Length() ),
|
||||
closestDist.A + VECTOR2I( 0, -arcs[i].GetWidth() ), 0 );
|
||||
}
|
||||
|
||||
overlay->SetLineWidth( 10000.0 );
|
||||
overlay->SetStrokeColor( CYAN );
|
||||
overlay->AnnotatedPoint( arcs[i].GetP0(), arcs[i].GetWidth() / 2 );
|
||||
|
@ -347,16 +365,7 @@ int playground_main_func( int argc, char* argv[] )
|
|||
overlay->AnnotatedPoint( arcs[i + 1].GetArcMid(), arcs[i + 1].GetWidth() / 2 );
|
||||
overlay->AnnotatedPoint( arcs[i].GetP1(), arcs[i].GetWidth() / 2 );
|
||||
overlay->AnnotatedPoint( arcs[i + 1].GetP1(), arcs[i + 1].GetWidth() / 2 );
|
||||
overlay->SetStrokeColor( GREEN );
|
||||
|
||||
for(int j = 0; j < ni; j++ )
|
||||
overlay->AnnotatedPoint( ips[j], arcs[i].GetWidth() );
|
||||
|
||||
if( collides )
|
||||
{
|
||||
overlay->SetStrokeColor( YELLOW );
|
||||
overlay->Line(closestDist.A, closestDist.B);
|
||||
}
|
||||
|
||||
overlay->SetStrokeColor( RED );
|
||||
overlay->Arc( arcs[i] );
|
||||
|
|
Loading…
Reference in New Issue