router: first insert intersections, then build graph in Walkaround()

This commit is contained in:
Tomasz Wlostowski 2021-02-23 22:50:30 +01:00
parent 61e75a838b
commit 24574aa2f5
1 changed files with 13 additions and 13 deletions

View File

@ -219,6 +219,19 @@ bool LINE::Walkaround( const SHAPE_LINE_CHAIN& aObstacle, SHAPE_LINE_CHAIN& aPat
return nullptr;
};
// make sure all points that lie on the edge of the hull also exist as vertices in the path
for( int i = 0; i < pnew.PointCount(); i++ )
{
const VECTOR2I &p = pnew.CPoint(i);
if( hnew.PointOnEdge( p ) )
{
SHAPE_LINE_CHAIN::INTERSECTION ip;
ip.p = p;
ips.push_back( ip );
}
}
// insert all intersections found into the new hull/path SLCs
for( auto ip : ips )
{
@ -235,19 +248,6 @@ bool LINE::Walkaround( const SHAPE_LINE_CHAIN& aObstacle, SHAPE_LINE_CHAIN& aPat
}
}
// make sure all points that lie on the edge of the hull also exist as vertices in the path
for( int i = 0; i < pnew.PointCount(); i++ )
{
const VECTOR2I &p = pnew.CPoint(i);
if( hnew.PointOnEdge( p ) )
{
SHAPE_LINE_CHAIN::INTERSECTION ip;
ip.p = p;
ips.push_back( ip );
}
}
// we assume the default orientation of the hulls is clockwise, so just reverse the vertex
// order if the caller wants a counter-clockwise walkaround
if ( !aCw )