本文整理汇总了C++中PNS_LINE类的典型用法代码示例。如果您正苦于以下问题:C++ PNS_LINE类的具体用法?C++ PNS_LINE怎么用?C++ PNS_LINE使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PNS_LINE类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: markViolations
void PNS_ROUTER::markViolations( PNS_NODE* aNode, PNS_ITEMSET& aCurrent,
PNS_NODE::ITEM_VECTOR& aRemoved )
{
for( PNS_ITEM* item : aCurrent.Items() )
{
PNS_NODE::OBSTACLES obstacles;
aNode->QueryColliding( item, obstacles, PNS_ITEM::ANY );
if( item->OfKind( PNS_ITEM::LINE ) )
{
PNS_LINE* l = static_cast<PNS_LINE*>( item );
if( l->EndsWithVia() )
{
PNS_VIA v( l->Via() );
aNode->QueryColliding( &v, obstacles, PNS_ITEM::ANY );
}
}
for( PNS_OBSTACLE& obs : obstacles )
{
int clearance = aNode->GetClearance( item, obs.m_item );
std::unique_ptr<PNS_ITEM> tmp( obs.m_item->Clone() );
tmp->Mark( MK_VIOLATION );
m_iface->DisplayItem( tmp.get(), -1, clearance );
aRemoved.push_back( obs.m_item );
}
}
}
示例2: SHAPE_LINE_CHAIN
bool PNS_LINE_PLACER::buildInitialLine( const VECTOR2I& aP, PNS_LINE& aHead )
{
SHAPE_LINE_CHAIN l;
if( m_p_start == aP )
{
l.Clear();
}
else
{
if( Settings().GetFreeAngleMode() && Settings().Mode() == RM_MarkObstacles )
{
l = SHAPE_LINE_CHAIN( m_p_start, aP );
}
else
{
l = m_direction.BuildInitialTrace( m_p_start, aP );
}
if( l.SegmentCount() > 1 && m_orthoMode )
{
VECTOR2I newLast = l.CSegment( 0 ).LineProject( l.CPoint( -1 ) );
l.Remove( -1, -1 );
l.Point( 1 ) = newLast;
}
}
aHead.SetShape( l );
if( !m_placingVia )
return true;
PNS_VIA v( makeVia( aP ) );
v.SetNet( aHead.Net() );
if( m_currentMode == RM_MarkObstacles )
{
aHead.AppendVia( v );
return true;
}
VECTOR2I force;
VECTOR2I lead = aP - m_p_start;
bool solidsOnly = ( m_currentMode != RM_Walkaround );
if( v.PushoutForce( m_currentNode, lead, force, solidsOnly, 40 ) )
{
SHAPE_LINE_CHAIN line = m_direction.BuildInitialTrace( m_p_start, aP + force );
aHead = PNS_LINE( aHead, line );
v.SetPos( v.Pos() + force );
return true;
}
return false; // via placement unsuccessful
}
示例3: assert
bool PNS_TOPOLOGY::followTrivialPath( PNS_LINE* aLine, bool aLeft, PNS_ITEMSET& aSet, std::set<PNS_ITEM*>& aVisited )
{
VECTOR2I anchor = aLeft ? aLine->CPoint( 0 ) : aLine->CPoint( -1 );
PNS_SEGMENT* last = aLeft ? aLine->LinkedSegments()->front() : aLine->LinkedSegments()->back();
PNS_JOINT* jt = m_world->FindJoint( anchor, aLine );
assert( jt != NULL );
aVisited.insert( last );
if( jt->IsNonFanoutVia() || jt->IsTraceWidthChange() )
{
PNS_ITEM* via = NULL;
PNS_SEGMENT* next_seg = NULL;
for( PNS_ITEM* link : jt->Links().Items() )
{
if( link->OfKind( PNS_ITEM::VIA ) )
via = link;
else if( aVisited.find( link ) == aVisited.end() )
next_seg = static_cast<PNS_SEGMENT*>( link );
}
if( !next_seg )
return false;
PNS_LINE l = m_world->AssembleLine( next_seg );
VECTOR2I nextAnchor = ( aLeft ? l.CLine().CPoint( -1 ) : l.CLine().CPoint( 0 ) );
if( nextAnchor != anchor )
{
l.Reverse();
}
if( aLeft )
{
if( via )
aSet.Prepend( via );
aSet.Prepend( l );
}
else
{
if( via )
aSet.Add( via );
aSet.Add( l );
}
return followTrivialPath( &l, aLeft, aSet, aVisited );
}
return false;
}
示例4: initTrack
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;
}
示例5: removeLoops
void PNS_LINE_PLACER::removeLoops( PNS_NODE* aNode, PNS_LINE& aLatest )
{
if( !aLatest.SegmentCount() )
return;
if( aLatest.CLine().CPoint( 0 ) == aLatest.CLine().CPoint( -1 ) )
return;
std::set<PNS_SEGMENT *> toErase;
aNode->Add( &aLatest, true );
for( int s = 0; s < aLatest.LinkCount(); s++ )
{
PNS_SEGMENT* seg = ( *aLatest.LinkedSegments() )[s];
PNS_LINE ourLine = aNode->AssembleLine( seg );
PNS_JOINT a, b;
std::vector<PNS_LINE> lines;
aNode->FindLineEnds( ourLine, a, b );
if( a == b )
{
aNode->FindLineEnds( aLatest, a, b );
}
aNode->FindLinesBetweenJoints( a, b, lines );
int removedCount = 0;
int total = 0;
for( PNS_LINE& line : lines )
{
total++;
if( !( line.ContainsSegment( seg ) ) && line.SegmentCount() )
{
for( PNS_SEGMENT *ss : *line.LinkedSegments() )
toErase.insert( ss );
removedCount++;
}
}
TRACE( 0, "total segs removed: %d/%d\n", removedCount % total );
}
for( PNS_SEGMENT *s : toErase )
aNode->Remove( s );
aNode->Remove( &aLatest );
}
示例6: simplified
void PNS_LINE_PLACER::simplifyNewLine( PNS_NODE* aNode, PNS_SEGMENT* aLatest )
{
PNS_LINE l = aNode->AssembleLine( aLatest );
SHAPE_LINE_CHAIN simplified( l.CLine() );
simplified.Simplify();
if( simplified.PointCount() != l.PointCount() )
{
PNS_LINE lnew( l );
aNode->Remove( &l );
lnew.SetShape( simplified );
aNode->Add( &lnew );
}
}
示例7: switch
void PNS_LOGGER::Log ( const PNS_ITEM* aItem, int aKind, const std::string aName )
{
m_theLog << "aItem " << aKind << " " << aName << " ";
m_theLog << aItem->Net() << " " << aItem->Layers().Start() << " " <<
aItem->Layers().End() << " " << aItem->Marker() << " " << aItem->Rank();
switch( aItem->Kind() )
{
case PNS_ITEM::LINE:
{
PNS_LINE* l = (PNS_LINE*) aItem;
m_theLog << " line ";
m_theLog << l->Width() << " " << ( l->EndsWithVia() ? 1 : 0 ) << " ";
dumpShape ( l->Shape() );
m_theLog << std::endl;
break;
}
case PNS_ITEM::VIA:
{
m_theLog << " via 0 0 ";
dumpShape ( aItem->Shape() );
m_theLog << std::endl;
break;
}
case PNS_ITEM::SEGMENT:
{
PNS_SEGMENT* s =(PNS_SEGMENT*) aItem;
m_theLog << " line ";
m_theLog << s->Width() << " 0 linechain 2 0 " << s->Seg().A.x << " " <<
s->Seg().A.y << " " << s->Seg().B.x << " " <<s->Seg().B.y << std::endl;
break;
}
case PNS_ITEM::SOLID:
{
PNS_SOLID* s = (PNS_SOLID*) aItem;
m_theLog << " solid 0 0 ";
dumpShape( s->Shape() );
m_theLog << std::endl;
break;
}
default:
break;
}
}
示例8: v
bool PNS_LINE_PLACER::handleViaPlacement( PNS_LINE& aHead )
{
if( !m_placingVia )
return true;
PNS_VIA v ( makeVia ( aHead.CPoint( -1 ) ) );
v.SetNet ( aHead.Net() );
VECTOR2I force;
VECTOR2I lead = aHead.CPoint( -1 ) - aHead.CPoint( 0 );
bool solidsOnly = ( m_currentMode != RM_Walkaround );
if( v.PushoutForce( m_currentNode, lead, force, solidsOnly, 40 ) )
{
SHAPE_LINE_CHAIN line = m_direction.BuildInitialTrace(
aHead.CPoint( 0 ),
aHead.CPoint( -1 ) + force );
aHead = PNS_LINE( aHead, line );
v.SetPos( v.Pos() + force );
return true;
}
return false;
}
示例9: simplified
bool PNS_TOPOLOGY::SimplifyLine( PNS_LINE* aLine )
{
if( !aLine->LinkedSegments() || !aLine->SegmentCount() )
return false;
PNS_SEGMENT* root = ( *aLine->LinkedSegments() )[0];
PNS_LINE l = m_world->AssembleLine( root );
SHAPE_LINE_CHAIN simplified( l.CLine() );
simplified.Simplify();
if( simplified.PointCount() != l.PointCount() )
{
PNS_LINE lnew( l );
m_world->Remove( &l );
lnew.SetShape( simplified );
m_world->Add( &lnew );
return true;
}
return false;
}
示例10: Move
bool PNS_LINE_PLACER::Move( const VECTOR2I& aP, PNS_ITEM* aEndItem )
{
PNS_LINE current;
VECTOR2I p = aP;
int eiDepth = -1;
if( aEndItem && aEndItem->Owner() )
eiDepth = aEndItem->Owner()->Depth();
if( m_lastNode )
{
delete m_lastNode;
m_lastNode = NULL;
}
route( p );
current = Trace();
if( !current.PointCount() )
m_currentEnd = m_p_start;
else
m_currentEnd = current.CLine().CPoint( -1 );
PNS_NODE* latestNode = m_currentNode;
m_lastNode = latestNode->Branch();
if( eiDepth >= 0 && aEndItem && latestNode->Depth() > eiDepth &&
current.SegmentCount() )
{
splitAdjacentSegments( m_lastNode, aEndItem, current.CPoint( -1 ) );
if( Settings().RemoveLoops() )
removeLoops( m_lastNode, ¤t );
}
updateLeadingRatLine();
return true;
}
示例11: DpCoupledNet
bool PNS_TOPOLOGY::AssembleDiffPair( PNS_ITEM* aStart, PNS_DIFF_PAIR& aPair )
{
int refNet = aStart->Net();
int coupledNet = DpCoupledNet( refNet );
if( coupledNet < 0 )
return false;
std::set<PNS_ITEM*> coupledItems;
m_world->AllItemsInNet( coupledNet, coupledItems );
PNS_SEGMENT* coupledSeg = NULL, *refSeg;
int minDist = std::numeric_limits<int>::max();
if( ( refSeg = dyn_cast<PNS_SEGMENT*>( aStart ) ) != NULL )
{
for( PNS_ITEM* item : coupledItems )
{
if( PNS_SEGMENT* s = dyn_cast<PNS_SEGMENT*>( item ) )
{
if( s->Layers().Start() == refSeg->Layers().Start() && s->Width() == refSeg->Width() )
{
int dist = s->Seg().Distance( refSeg->Seg() );
bool isParallel = refSeg->Seg().ApproxParallel( s->Seg() );
SEG p_clip, n_clip;
bool isCoupled = commonParallelProjection( refSeg->Seg(), s->Seg(), p_clip, n_clip );
if( isParallel && isCoupled && dist < minDist )
{
minDist = dist;
coupledSeg = s;
}
}
}
}
}
else
{
return false;
}
if( !coupledSeg )
return false;
PNS_LINE lp = m_world->AssembleLine( refSeg );
PNS_LINE ln = m_world->AssembleLine( coupledSeg );
if( DpNetPolarity( refNet ) < 0 )
{
std::swap( lp, ln );
}
int gap = -1;
if( refSeg->Seg().ApproxParallel( coupledSeg->Seg() ) )
{
// Segments are parallel -> compute pair gap
const VECTOR2I refDir = refSeg->Anchor( 1 ) - refSeg->Anchor( 0 );
const VECTOR2I displacement = refSeg->Anchor( 1 ) - coupledSeg->Anchor( 1 );
gap = (int) std::abs( refDir.Cross( displacement ) / refDir.EuclideanNorm() ) - lp.Width();
}
aPair = PNS_DIFF_PAIR( lp, ln );
aPair.SetWidth( lp.Width() );
aPair.SetLayers( lp.Layers() );
aPair.SetGap( gap );
return true;
}
示例12: Prepend
void PNS_ITEMSET::Prepend( const PNS_LINE& aLine )
{
PNS_LINE* copy = aLine.Clone();
m_items.insert( m_items.begin(), ENTRY( copy, true ) );
}
示例13: walkaround
bool PNS_DIFF_PAIR_PLACER::attemptWalk( PNS_NODE* aNode, PNS_DIFF_PAIR* aCurrent,
PNS_DIFF_PAIR& aWalk, bool aPFirst, bool aWindCw, bool aSolidsOnly )
{
PNS_WALKAROUND walkaround( aNode, Router() );
PNS_WALKAROUND::WALKAROUND_STATUS wf1;
Router()->GetRuleResolver()->OverrideClearance( true,
aCurrent->NetP(), aCurrent->NetN(), aCurrent->Gap() );
walkaround.SetSolidsOnly( aSolidsOnly );
walkaround.SetIterationLimit( Settings().WalkaroundIterationLimit() );
PNS_SHOVE shove( aNode, Router() );
PNS_LINE walkP, walkN;
aWalk = *aCurrent;
int iter = 0;
PNS_DIFF_PAIR cur( *aCurrent );
bool currentIsP = aPFirst;
int mask = aSolidsOnly ? PNS_ITEM::SOLID : PNS_ITEM::ANY;
do
{
PNS_LINE preWalk = ( currentIsP ? cur.PLine() : cur.NLine() );
PNS_LINE preShove = ( currentIsP ? cur.NLine() : cur.PLine() );
PNS_LINE postWalk;
if( !aNode->CheckColliding ( &preWalk, mask ) )
{
currentIsP = !currentIsP;
if( !aNode->CheckColliding( &preShove, mask ) )
break;
else
continue;
}
wf1 = walkaround.Route( preWalk, postWalk, false );
if( wf1 != PNS_WALKAROUND::DONE )
return false;
PNS_LINE postShove( preShove );
shove.ForceClearance( true, cur.Gap() - 2 * PNS_HULL_MARGIN );
PNS_SHOVE::SHOVE_STATUS sh1;
sh1 = shove.ProcessSingleLine( postWalk, preShove, postShove );
if( sh1 != PNS_SHOVE::SH_OK )
return false;
postWalk.Line().Simplify();
postShove.Line().Simplify();
cur.SetShape( postWalk.CLine(), postShove.CLine(), !currentIsP );
currentIsP = !currentIsP;
if( !aNode->CheckColliding( &postShove, mask ) )
break;
iter++;
}
while( iter < 3 );
if( iter == 3 )
return false;
aWalk.SetShape( cur.CP(), cur.CN() );
Router()->GetRuleResolver()->OverrideClearance( false );
return true;
}
示例14: walk_path
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;
}
示例15: Trace
bool PNS_LINE_PLACER::FixRoute( const VECTOR2I& aP, PNS_ITEM* aEndItem )
{
bool realEnd = false;
int lastV;
PNS_LINE pl = Trace();
if( m_currentMode == RM_MarkObstacles &&
!Settings().CanViolateDRC() &&
m_world->CheckColliding( &pl ) )
return false;
const SHAPE_LINE_CHAIN& l = pl.CLine();
if( !l.SegmentCount() )
{
if( pl.EndsWithVia() )
{
m_lastNode->Add( pl.Via().Clone() );
Router()->CommitRouting( m_lastNode );
m_lastNode = NULL;
m_currentNode = NULL;
m_idle = true;
}
return true;
}
VECTOR2I p_pre_last = l.CPoint( -1 );
const VECTOR2I p_last = l.CPoint( -1 );
DIRECTION_45 d_last( l.CSegment( -1 ) );
if( l.PointCount() > 2 )
p_pre_last = l.CPoint( -2 );
if( aEndItem && m_currentNet >= 0 && m_currentNet == aEndItem->Net() )
realEnd = true;
if( realEnd || m_placingVia )
lastV = l.SegmentCount();
else
lastV = std::max( 1, l.SegmentCount() - 1 );
PNS_SEGMENT* lastSeg = NULL;
for( int i = 0; i < lastV; i++ )
{
const SEG& s = pl.CSegment( i );
PNS_SEGMENT* seg = new PNS_SEGMENT( s, m_currentNet );
seg->SetWidth( pl.Width() );
seg->SetLayer( m_currentLayer );
m_lastNode->Add( seg );
lastSeg = seg;
}
if( pl.EndsWithVia() )
m_lastNode->Add( pl.Via().Clone() );
if( realEnd )
simplifyNewLine( m_lastNode, lastSeg );
Router()->CommitRouting( m_lastNode );
m_lastNode = NULL;
m_currentNode = NULL;
if( !realEnd )
{
setInitialDirection( d_last );
m_currentStart = m_placingVia ? p_last : p_pre_last;
m_startItem = NULL;
m_placingVia = false;
m_chainedPlacement = !pl.EndsWithVia();
m_splitSeg = false;
initPlacement();
}
else
{
m_idle = true;
}
return realEnd;
}