router: more robust nearest obstacle clipping
This commit is contained in:
parent
c48a417dcd
commit
a3edd9706f
|
@ -313,17 +313,26 @@ bool PNS_LINE::Is45Degree()
|
||||||
|
|
||||||
const PNS_LINE PNS_LINE::ClipToNearestObstacle( PNS_NODE* aNode ) const
|
const PNS_LINE PNS_LINE::ClipToNearestObstacle( PNS_NODE* aNode ) const
|
||||||
{
|
{
|
||||||
|
const int IterationLimit = 5;
|
||||||
|
int i;
|
||||||
PNS_LINE l( *this );
|
PNS_LINE l( *this );
|
||||||
|
|
||||||
PNS_NODE::OPT_OBSTACLE obs = aNode->NearestObstacle( &l );
|
for( i = 0; i < IterationLimit; i++ )
|
||||||
|
|
||||||
if( obs )
|
|
||||||
{
|
{
|
||||||
l.RemoveVia();
|
PNS_NODE::OPT_OBSTACLE obs = aNode->NearestObstacle( &l );
|
||||||
int p = l.Line().Split( obs->m_ipFirst );
|
|
||||||
l.Line().Remove( p + 1, -1 );
|
if( obs )
|
||||||
|
{
|
||||||
|
l.RemoveVia();
|
||||||
|
int p = l.Line().Split( obs->m_ipFirst );
|
||||||
|
l.Line().Remove( p + 1, -1 );
|
||||||
|
} else
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( i == IterationLimit )
|
||||||
|
l.Line().Clear();
|
||||||
|
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue