本文整理汇总了C++中PNS_LINE::ClipToNearestObstacle方法的典型用法代码示例。如果您正苦于以下问题:C++ PNS_LINE::ClipToNearestObstacle方法的具体用法?C++ PNS_LINE::ClipToNearestObstacle怎么用?C++ PNS_LINE::ClipToNearestObstacle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PNS_LINE
的用法示例。
在下文中一共展示了PNS_LINE::ClipToNearestObstacle方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rhWalkOnly
bool PNS_LINE_PLACER::rhWalkOnly( const VECTOR2I& aP, PNS_LINE& aNewHead )
{
PNS_LINE initTrack( m_head );
PNS_LINE walkFull;
int effort = 0;
bool rv = true, viaOk;
viaOk = buildInitialLine( aP, initTrack );
PNS_WALKAROUND walkaround( m_currentNode, Router() );
walkaround.SetSolidsOnly( false );
walkaround.SetIterationLimit( Settings().WalkaroundIterationLimit() );
PNS_WALKAROUND::WALKAROUND_STATUS wf = walkaround.Route( initTrack, walkFull, false );
switch( Settings().OptimizerEffort() )
{
case OE_LOW:
effort = 0;
break;
case OE_MEDIUM:
case OE_FULL:
effort = PNS_OPTIMIZER::MERGE_SEGMENTS;
break;
}
if( Settings().SmartPads() )
effort |= PNS_OPTIMIZER::SMART_PADS;
if( wf == PNS_WALKAROUND::STUCK )
{
walkFull = walkFull.ClipToNearestObstacle( m_currentNode );
rv = true;
}
else if( m_placingVia && viaOk )
{
walkFull.AppendVia( makeVia( walkFull.CPoint( -1 ) ) );
}
PNS_OPTIMIZER::Optimize( &walkFull, effort, m_currentNode );
if( m_currentNode->CheckColliding( &walkFull ) )
{
aNewHead = m_head;
return false;
}
m_head = walkFull;
aNewHead = walkFull;
return rv;
}
示例2: singleStep
PNS_WALKAROUND::WalkaroundStatus PNS_WALKAROUND::singleStep( PNS_LINE& aPath,
bool aWindingDirection )
{
optional<PNS_OBSTACLE>& current_obs =
aWindingDirection ? m_currentObstacle[0] : m_currentObstacle[1];
bool& prev_recursive = aWindingDirection ? m_recursiveCollision[0] : m_recursiveCollision[1];
if( !current_obs )
return DONE;
SHAPE_LINE_CHAIN path_pre[2], path_walk[2], path_post[2];
VECTOR2I last = aPath.GetCLine().CPoint( -1 );
if( ( current_obs->hull ).PointInside( last ) )
{
m_recursiveBlockageCount++;
if( m_recursiveBlockageCount < 3 )
aPath.GetLine().Append( current_obs->hull.NearestPoint( last ) );
else
{
aPath = aPath.ClipToNearestObstacle( m_world );
return STUCK;
}
}
aPath.NewWalkaround( current_obs->hull, path_pre[0], path_walk[0],
path_post[0], aWindingDirection );
aPath.NewWalkaround( current_obs->hull, path_pre[1], path_walk[1],
path_post[1], !aWindingDirection );
int len_pre = path_walk[0].Length();
int len_alt = path_walk[1].Length();
PNS_LINE walk_path( aPath, path_walk[1] );
bool alt_collides = m_world->CheckColliding( &walk_path,
m_solids_only ? PNS_ITEM::SOLID : PNS_ITEM::ANY );
SHAPE_LINE_CHAIN pnew;
if( !m_forceSingleDirection && len_alt < len_pre && !alt_collides && !prev_recursive )
{
pnew = path_pre[1];
pnew.Append( path_walk[1] );
pnew.Append( path_post[1] );
current_obs = nearestObstacle( PNS_LINE( aPath, path_post[1] ) );
prev_recursive = false;
}
else
{
pnew = path_pre[0];
pnew.Append( path_walk[0] );
pnew.Append( path_post[0] );
current_obs = nearestObstacle( PNS_LINE( aPath, path_walk[0] ) );
if( !current_obs )
{
prev_recursive = false;
current_obs = nearestObstacle( PNS_LINE( aPath, path_post[0] ) );
}
else
prev_recursive = true;
}
pnew.Simplify();
aPath.SetShape( pnew );
return IN_PROGRESS;
}
示例3: singleStep
PNS_WALKAROUND::WALKAROUND_STATUS PNS_WALKAROUND::singleStep( PNS_LINE& aPath,
bool aWindingDirection )
{
optional<PNS_OBSTACLE>& current_obs =
aWindingDirection ? m_currentObstacle[0] : m_currentObstacle[1];
bool& prev_recursive = aWindingDirection ? m_recursiveCollision[0] : m_recursiveCollision[1];
if( !current_obs )
return DONE;
SHAPE_LINE_CHAIN path_pre[2], path_walk[2], path_post[2];
VECTOR2I last = aPath.CPoint( -1 );
if( ( current_obs->m_hull ).PointInside( last ) || ( current_obs->m_hull ).PointOnEdge( last ) )
{
m_recursiveBlockageCount++;
if( m_recursiveBlockageCount < 3 )
aPath.Line().Append( current_obs->m_hull.NearestPoint( last ) );
else
{
aPath = aPath.ClipToNearestObstacle( m_world );
return DONE;
}
}
aPath.Walkaround( current_obs->m_hull, path_pre[0], path_walk[0],
path_post[0], aWindingDirection );
aPath.Walkaround( current_obs->m_hull, path_pre[1], path_walk[1],
path_post[1], !aWindingDirection );
#ifdef DEBUG
m_logger.NewGroup( aWindingDirection ? "walk-cw" : "walk-ccw", m_iteration );
m_logger.Log( &path_walk[0], 0, "path-walk" );
m_logger.Log( &path_pre[0], 1, "path-pre" );
m_logger.Log( &path_post[0], 4, "path-post" );
m_logger.Log( ¤t_obs->m_hull, 2, "hull" );
m_logger.Log( current_obs->m_item, 3, "item" );
#endif
int len_pre = path_walk[0].Length();
int len_alt = path_walk[1].Length();
PNS_LINE walk_path( aPath, path_walk[1] );
bool alt_collides = m_world->CheckColliding( &walk_path, m_itemMask );
SHAPE_LINE_CHAIN pnew;
if( !m_forceSingleDirection && len_alt < len_pre && !alt_collides && !prev_recursive )
{
pnew = path_pre[1];
pnew.Append( path_walk[1] );
pnew.Append( path_post[1] );
if( !path_post[1].PointCount() || !path_walk[1].PointCount() )
current_obs = nearestObstacle( PNS_LINE( aPath, path_pre[1] ) );
else
current_obs = nearestObstacle( PNS_LINE( aPath, path_post[1] ) );
prev_recursive = false;
}
else
{
pnew = path_pre[0];
pnew.Append( path_walk[0] );
pnew.Append( path_post[0] );
if( !path_post[0].PointCount() || !path_walk[0].PointCount() )
current_obs = nearestObstacle( PNS_LINE( aPath, path_pre[0] ) );
else
current_obs = nearestObstacle( PNS_LINE( aPath, path_walk[0] ) );
if( !current_obs )
{
prev_recursive = false;
current_obs = nearestObstacle( PNS_LINE( aPath, path_post[0] ) );
}
else
prev_recursive = true;
}
pnew.Simplify();
aPath.SetShape( pnew );
return IN_PROGRESS;
}