KiCad PCB EDA Suite
PNS::NODE Class Reference

Keep the router "world" - i.e. More...

#include <pns_node.h>

Classes

struct  DEFAULT_OBSTACLE_VISITOR
 

Public Types

typedef OPT< OBSTACLEOPT_OBSTACLE
 
typedef std::vector< ITEM * > ITEM_VECTOR
 
typedef std::vector< OBSTACLEOBSTACLES
 

Public Member Functions

 NODE ()
 
 ~NODE ()
 Return the expected clearance between items a and b. More...
 
int GetClearance (const ITEM *aA, const ITEM *aB) const
 
int GetHoleClearance (const ITEM *aA, const ITEM *aB) const
 
int GetHoleToHoleClearance (const ITEM *aA, const ITEM *aB) const
 Return the pre-set worst case clearance between any pair of items. More...
 
int GetMaxClearance () const
 Set the worst-case clearance between any pair of items. More...
 
void SetMaxClearance (int aClearance)
 Assign a clearance resolution function object. More...
 
void SetRuleResolver (RULE_RESOLVER *aFunc)
 
RULE_RESOLVERGetRuleResolver () const
 Return the number of joints. More...
 
int JointCount () const
 Return the number of nodes in the inheritance chain (wrs to the root node). More...
 
int Depth () const
 
int QueryColliding (const ITEM *aItem, OBSTACLES &aObstacles, int aKindMask=ITEM::ANY_T, int aLimitCount=-1, bool aDifferentNetsOnly=true)
 Find items colliding (closer than clearance) with the item aItem. More...
 
int QueryJoints (const BOX2I &aBox, std::vector< JOINT * > &aJoints, LAYER_RANGE aLayerMask=LAYER_RANGE::All(), int aKindMask=ITEM::ANY_T)
 
OPT_OBSTACLE NearestObstacle (const LINE *aLine, int aKindMask=ITEM::ANY_T, const std::set< ITEM * > *aRestrictedSet=NULL)
 Follow the line in search of an obstacle that is nearest to the starting to the line's starting point. More...
 
OPT_OBSTACLE CheckColliding (const ITEM *aItem, int aKindMask=ITEM::ANY_T)
 Check if the item collides with anything else in the world, and if found, returns the obstacle. More...
 
OPT_OBSTACLE CheckColliding (const ITEM_SET &aSet, int aKindMask=ITEM::ANY_T)
 Check if any item in the set collides with anything else in the world, and if found, returns the obstacle. More...
 
const ITEM_SET HitTest (const VECTOR2I &aPoint) const
 Find all items that contain the point aPoint. More...
 
bool Add (std::unique_ptr< SEGMENT > aSegment, bool aAllowRedundant=false)
 Add an item to the current node. More...
 
void Add (std::unique_ptr< SOLID > aSolid)
 
void Add (std::unique_ptr< VIA > aVia)
 
void Add (std::unique_ptr< ARC > aArc)
 
void Add (LINE &aLine, bool aAllowRedundant=false)
 
void Remove (ARC *aArc)
 Remove an item from this branch. More...
 
void Remove (SOLID *aSolid)
 
void Remove (VIA *aVia)
 
void Remove (SEGMENT *aSegment)
 
void Remove (ITEM *aItem)
 
void Remove (LINE &aLine)
 Removes a line from this branch. More...
 
void Replace (ITEM *aOldItem, std::unique_ptr< ITEM > aNewItem)
 Replace an item with another one. More...
 
void Replace (LINE &aOldLine, LINE &aNewLine)
 
NODEBranch ()
 Create a lightweight copy (called branch) of self that tracks the changes (added/removed items) wrs to the root. More...
 
const LINE AssembleLine (LINKED_ITEM *aSeg, int *aOriginSegmentIndex=NULL, bool aStopAtLockedJoints=false)
 Follow the joint map to assemble a line connecting two non-trivial joints starting from segment aSeg. More...
 
void Dump (bool aLong=false)
 
void GetUpdatedItems (ITEM_VECTOR &aRemoved, ITEM_VECTOR &aAdded)
 Return the list of items removed and added in this branch with respect to the root branch. More...
 
void Commit (NODE *aNode)
 Apply the changes from a given branch (aNode) to the root branch. More...
 
JOINTFindJoint (const VECTOR2I &aPos, int aLayer, int aNet)
 Search for a joint at a given position, layer and belonging to given net. More...
 
void LockJoint (const VECTOR2I &aPos, const ITEM *aItem, bool aLock)
 
JOINTFindJoint (const VECTOR2I &aPos, const ITEM *aItem)
 Search for a joint at a given position, linked to given item. More...
 
int FindLinesBetweenJoints (const JOINT &aA, const JOINT &aB, std::vector< LINE > &aLines)
 Find the joints corresponding to the ends of line aLine. More...
 
void FindLineEnds (const LINE &aLine, JOINT &aA, JOINT &aB)
 Destroy all child nodes. Applicable only to the root node. More...
 
void KillChildren ()
 
void AllItemsInNet (int aNet, std::set< ITEM * > &aItems, int aKindMask=-1)
 
void ClearRanks (int aMarkerMask=MK_HEAD|MK_VIOLATION|MK_HOLE)
 
void RemoveByMarker (int aMarker)
 
ITEMFindItemByParent (const BOARD_ITEM *aParent)
 
bool HasChildren () const
 
NODEGetParent () const
 Check if this branch contains an updated version of the m_item from the root branch. More...
 
bool Overrides (ITEM *aItem) const
 

Private Types

typedef std::unordered_multimap< JOINT::HASH_TAG, JOINT, JOINT::JOINT_TAG_HASHJOINT_MAP
 
typedef JOINT_MAP::value_type TagJointPair
 

Private Member Functions

void Add (std::unique_ptr< ITEM > aItem, bool aAllowRedundant=false)
 
 NODE (const NODE &aB)
 nodes are not copyable More...
 
NODEoperator= (const NODE &aB)
 Try to find matching joint and creates a new one if not found. More...
 
JOINTtouchJoint (const VECTOR2I &aPos, const LAYER_RANGE &aLayers, int aNet)
 Touch a joint and links it to an m_item. More...
 
void linkJoint (const VECTOR2I &aPos, const LAYER_RANGE &aLayers, int aNet, ITEM *aWhere)
 Unlink an item from a joint. More...
 
void unlinkJoint (const VECTOR2I &aPos, const LAYER_RANGE &aLayers, int aNet, ITEM *aWhere)
 Helpers for adding/removing items. More...
 
void addSolid (SOLID *aSeg)
 
void addSegment (SEGMENT *aSeg)
 
void addVia (VIA *aVia)
 
void addArc (ARC *aVia)
 
void removeSolidIndex (SOLID *aSeg)
 
void removeSegmentIndex (SEGMENT *aSeg)
 
void removeViaIndex (VIA *aVia)
 
void removeArcIndex (ARC *aVia)
 
void doRemove (ITEM *aItem)
 
void unlinkParent ()
 
void releaseChildren ()
 
void releaseGarbage ()
 
void rebuildJoint (JOINT *aJoint, ITEM *aItem)
 
bool isRoot () const
 
SEGMENTfindRedundantSegment (const VECTOR2I &A, const VECTOR2I &B, const LAYER_RANGE &lr, int aNet)
 
SEGMENTfindRedundantSegment (SEGMENT *aSeg)
 
ARCfindRedundantArc (const VECTOR2I &A, const VECTOR2I &B, const LAYER_RANGE &lr, int aNet)
 
ARCfindRedundantArc (ARC *aSeg)
 Scan the joint map, forming a line starting from segment (current). More...
 
void followLine (LINKED_ITEM *aCurrent, bool aScanDirection, int &aPos, int aLimit, VECTOR2I *aCorners, LINKED_ITEM **aSegments, bool *aArcReversed, bool &aGuardHit, bool aStopAtLockedJoints)
 

Private Attributes

JOINT_MAP m_joints
 hash table with the joints, linking the items. More...
 
NODEm_parent
 node this node was branched from More...
 
NODEm_root
 root node of the whole hierarchy More...
 
std::set< NODE * > m_children
 list of nodes branched from this one More...
 
std::unordered_set< ITEM * > m_override
 hash of root's items that have been changed in this node More...
 
int m_maxClearance
 worst case item-item clearance More...
 
RULE_RESOLVERm_ruleResolver
 Design rules resolver. More...
 
INDEXm_index
 Geometric/Net index of the items. More...
 
int m_depth
 depth of the node (number of parent nodes in the inheritance chain) More...
 
std::unordered_set< ITEM * > m_garbageItems
 

Detailed Description

Keep the router "world" - i.e.

all the tracks, vias, solids in a hierarchical and indexed way.

Features:

  • spatial-indexed container for PCB item shapes.
  • collision search & clearance checking.
  • assembly of lines connecting joints, finding loops and unique paths.
  • lightweight cloning/branching (for recursive optimization and shove springback).

Definition at line 145 of file pns_node.h.

Member Typedef Documentation

◆ ITEM_VECTOR

typedef std::vector<ITEM*> PNS::NODE::ITEM_VECTOR

Definition at line 149 of file pns_node.h.

◆ JOINT_MAP

typedef std::unordered_multimap<JOINT::HASH_TAG, JOINT, JOINT::JOINT_TAG_HASH> PNS::NODE::JOINT_MAP
private

Definition at line 435 of file pns_node.h.

◆ OBSTACLES

typedef std::vector<OBSTACLE> PNS::NODE::OBSTACLES

Definition at line 150 of file pns_node.h.

◆ OPT_OBSTACLE

Definition at line 148 of file pns_node.h.

◆ TagJointPair

typedef JOINT_MAP::value_type PNS::NODE::TagJointPair
private

Definition at line 437 of file pns_node.h.

Constructor & Destructor Documentation

◆ NODE() [1/2]

PNS::NODE::NODE ( )

Definition at line 50 of file pns_node.cpp.

51 {
52  m_depth = 0;
53  m_root = this;
54  m_parent = NULL;
55  m_maxClearance = 800000; // fixme: depends on how thick traces are.
57  m_index = new INDEX;
58 
59 #ifdef DEBUG
60  allocNodes.insert( this );
61 #endif
62 }
INDEX * m_index
Geometric/Net index of the items.
Definition: pns_node.h:451
NODE * m_root
root node of the whole hierarchy
Definition: pns_node.h:443
int m_depth
depth of the node (number of parent nodes in the inheritance chain)
Definition: pns_node.h:452
RULE_RESOLVER * m_ruleResolver
Design rules resolver.
Definition: pns_node.h:450
#define NULL
int m_maxClearance
worst case item-item clearance
Definition: pns_node.h:449
NODE * m_parent
node this node was branched from
Definition: pns_node.h:442

References m_depth, m_index, m_maxClearance, m_parent, m_root, m_ruleResolver, and NULL.

Referenced by Branch().

◆ ~NODE()

PNS::NODE::~NODE ( )

Return the expected clearance between items a and b.

Definition at line 65 of file pns_node.cpp.

66 {
67  if( !m_children.empty() )
68  {
69  wxLogTrace( "PNS", "attempting to free a node that has kids." );
70  assert( false );
71  }
72 
73 #ifdef DEBUG
74  if( allocNodes.find( this ) == allocNodes.end() )
75  {
76  wxLogTrace( "PNS", "attempting to free an already-free'd node." );
77  assert( false );
78  }
79 
80  allocNodes.erase( this );
81 #endif
82 
83  m_joints.clear();
84 
85  for( ITEM* item : *m_index )
86  {
87  if( item->BelongsTo( this ) )
88  delete item;
89  }
90 
92  unlinkParent();
93 
94  delete m_index;
95 }
std::set< NODE * > m_children
list of nodes branched from this one
Definition: pns_node.h:444
void unlinkParent()
Definition: pns_node.cpp:160
INDEX * m_index
Geometric/Net index of the items.
Definition: pns_node.h:451
void releaseGarbage()
Definition: pns_node.cpp:1265
JOINT_MAP m_joints
hash table with the joints, linking the items.
Definition: pns_node.h:439

References m_children, m_index, m_joints, releaseGarbage(), and unlinkParent().

◆ NODE() [2/2]

PNS::NODE::NODE ( const NODE aB)
private

nodes are not copyable

Member Function Documentation

◆ Add() [1/6]

bool PNS::NODE::Add ( std::unique_ptr< SEGMENT aSegment,
bool  aAllowRedundant = false 
)

Add an item to the current node.

Parameters
aSegmentitem to add.
aAllowRedundantif true, duplicate items are allowed (e.g. a segment or via at the same coordinates as an existing one).
Returns
true if added

Definition at line 613 of file pns_node.cpp.

614 {
615  if( aSegment->Seg().A == aSegment->Seg().B )
616  {
617  wxLogTrace( "PNS", "attempting to add a segment with same end coordinates, ignoring." );
618  return false;
619  }
620 
621  if( !aAllowRedundant && findRedundantSegment( aSegment.get() ) )
622  return false;
623 
624  aSegment->SetOwner( this );
625  addSegment( aSegment.release() );
626 
627  return true;
628 }
void addSegment(SEGMENT *aSeg)
Definition: pns_node.cpp:604
SEGMENT * findRedundantSegment(const VECTOR2I &A, const VECTOR2I &B, const LAYER_RANGE &lr, int aNet)
Definition: pns_node.cpp:1360

References addSegment(), and findRedundantSegment().

Referenced by Add(), Commit(), PNS::COMPONENT_DRAGGER::Drag(), PNS::DRAGGER::dragMarkObstacles(), PNS::DRAGGER::dragShove(), PNS::DRAGGER::dragViaMarkObstacles(), PNS::DRAGGER::dragViaWalkaround(), PNS::MEANDER_PLACER::FixRoute(), PNS::DP_MEANDER_PLACER::FixRoute(), PNS::DIFF_PAIR_PLACER::FixRoute(), PNS::LINE_PLACER::FixRoute(), PNS::DRAGGER::optimizeAndUpdateDraggedLine(), PNS::LINE_PLACER::removeLoops(), Replace(), PNS::SHOVE::runOptimizer(), PNS::SHOVE::ShoveLines(), PNS::SHOVE::ShoveMultiLines(), PNS::TOPOLOGY::SimplifyLine(), PNS::LINE_PLACER::simplifyNewLine(), PNS::LINE_PLACER::SplitAdjacentSegments(), PNS_KICAD_IFACE_BASE::syncGraphicalItem(), PNS_KICAD_IFACE_BASE::syncTextItem(), PNS_KICAD_IFACE_BASE::SyncWorld(), and PNS_KICAD_IFACE_BASE::syncZone().

◆ Add() [2/6]

void PNS::NODE::Add ( std::unique_ptr< SOLID aSolid)

Definition at line 530 of file pns_node.cpp.

531 {
532  aSolid->SetOwner( this );
533  addSolid( aSolid.release() );
534 }
void addSolid(SOLID *aSeg)
Definition: pns_node.cpp:521

References addSolid().

◆ Add() [3/6]

void PNS::NODE::Add ( std::unique_ptr< VIA aVia)

Definition at line 545 of file pns_node.cpp.

546 {
547  aVia->SetOwner( this );
548  addVia( aVia.release() );
549 }
void addVia(VIA *aVia)
Definition: pns_node.cpp:537

References addVia().

◆ Add() [4/6]

void PNS::NODE::Add ( std::unique_ptr< ARC aArc)

Definition at line 640 of file pns_node.cpp.

641 {
642  aArc->SetOwner( this );
643  addArc( aArc.release() );
644 }
void addArc(ARC *aVia)
Definition: pns_node.cpp:631

References addArc().

◆ Add() [5/6]

void PNS::NODE::Add ( LINE aLine,
bool  aAllowRedundant = false 
)

Definition at line 552 of file pns_node.cpp.

553 {
554  assert( !aLine.IsLinked() );
555 
556  SHAPE_LINE_CHAIN& l = aLine.Line();
557 
558  for( size_t i = 0; i < l.ArcCount(); i++ )
559  {
560  auto s = l.Arc( i );
561  ARC* rarc;
562 
563  if( !aAllowRedundant && ( rarc = findRedundantArc( s.GetP0(), s.GetP1(), aLine.Layers(),
564  aLine.Net() ) ) )
565  {
566  aLine.Link( rarc );
567  }
568  else
569  {
570  auto newarc = std::make_unique< ARC >( aLine, s );
571  aLine.Link( newarc.get() );
572  Add( std::move( newarc ), true );
573  }
574  }
575 
576  for( int i = 0; i < l.SegmentCount(); i++ )
577  {
578  if( l.isArc( i ) )
579  continue;
580 
581  SEG s = l.CSegment( i );
582 
583  if( s.A != s.B )
584  {
585  SEGMENT* rseg;
586 
587  if( !aAllowRedundant && ( rseg = findRedundantSegment( s.A, s.B, aLine.Layers(),
588  aLine.Net() ) ) )
589  {
590  // another line could be referencing this segment too :(
591  aLine.Link( rseg );
592  }
593  else
594  {
595  std::unique_ptr<SEGMENT> newseg = std::make_unique<SEGMENT>( aLine, s );
596  aLine.Link( newseg.get() );
597  Add( std::move( newseg ), true );
598  }
599  }
600  }
601 }
const SHAPE_ARC & Arc(size_t aArc) const
SEGMENT * findRedundantSegment(const VECTOR2I &A, const VECTOR2I &B, const LAYER_RANGE &lr, int aNet)
Definition: pns_node.cpp:1360
ARC * findRedundantArc(const VECTOR2I &A, const VECTOR2I &B, const LAYER_RANGE &lr, int aNet)
Definition: pns_node.cpp:1395
Definition: seg.h:41
Definition: track.h:262
SHAPE_LINE_CHAIN.
VECTOR2I A
Definition: seg.h:49
bool Add(std::unique_ptr< SEGMENT > aSegment, bool aAllowRedundant=false)
Add an item to the current node.
Definition: pns_node.cpp:613
VECTOR2I B
Definition: seg.h:50

References SEG::A, Add(), SHAPE_LINE_CHAIN::Arc(), SEG::B, findRedundantArc(), findRedundantSegment(), PNS::LINK_HOLDER::IsLinked(), PNS::ITEM::Layers(), PNS::LINE::Line(), PNS::LINK_HOLDER::Link(), and PNS::ITEM::Net().

◆ Add() [6/6]

void PNS::NODE::Add ( std::unique_ptr< ITEM aItem,
bool  aAllowRedundant = false 
)
private

Definition at line 647 of file pns_node.cpp.

648 {
649  switch( aItem->Kind() )
650  {
651  case ITEM::SOLID_T: Add( ItemCast<SOLID>( std::move( aItem ) ) ); break;
652  case ITEM::SEGMENT_T: Add( ItemCast<SEGMENT>( std::move( aItem ) ), aAllowRedundant ); break;
653  case ITEM::VIA_T: Add( ItemCast<VIA>( std::move( aItem ) ) ); break;
654 
655  case ITEM::ARC_T:
656  //todo(snh): Add redundant search
657  Add( ItemCast<ARC>( std::move( aItem ) ) );
658  break;
659 
660  case ITEM::LINE_T:
661  default:
662  assert( false );
663  }
664 }
bool Add(std::unique_ptr< SEGMENT > aSegment, bool aAllowRedundant=false)
Add an item to the current node.
Definition: pns_node.cpp:613

References Add(), PNS::ITEM::ARC_T, PNS::ITEM::LINE_T, PNS::ITEM::SEGMENT_T, PNS::ITEM::SOLID_T, and PNS::ITEM::VIA_T.

◆ addArc()

void PNS::NODE::addArc ( ARC aVia)
private

Definition at line 631 of file pns_node.cpp.

632 {
633  linkJoint( aArc->Anchor( 0 ), aArc->Layers(), aArc->Net(), aArc );
634  linkJoint( aArc->Anchor( 1 ), aArc->Layers(), aArc->Net(), aArc );
635 
636  m_index->Add( aArc );
637 }
void linkJoint(const VECTOR2I &aPos, const LAYER_RANGE &aLayers, int aNet, ITEM *aWhere)
Unlink an item from a joint.
Definition: pns_node.cpp:1134
INDEX * m_index
Geometric/Net index of the items.
Definition: pns_node.h:451
void Add(ITEM *aItem)
Adds item to the spatial index.
Definition: pns_index.cpp:28

References PNS::INDEX::Add(), PNS::ARC::Anchor(), PNS::ITEM::Layers(), linkJoint(), m_index, and PNS::ITEM::Net().

Referenced by Add().

◆ addSegment()

void PNS::NODE::addSegment ( SEGMENT aSeg)
private

Definition at line 604 of file pns_node.cpp.

605 {
606  linkJoint( aSeg->Seg().A, aSeg->Layers(), aSeg->Net(), aSeg );
607  linkJoint( aSeg->Seg().B, aSeg->Layers(), aSeg->Net(), aSeg );
608 
609  m_index->Add( aSeg );
610 }
void linkJoint(const VECTOR2I &aPos, const LAYER_RANGE &aLayers, int aNet, ITEM *aWhere)
Unlink an item from a joint.
Definition: pns_node.cpp:1134
INDEX * m_index
Geometric/Net index of the items.
Definition: pns_node.h:451
void Add(ITEM *aItem)
Adds item to the spatial index.
Definition: pns_index.cpp:28

References SEG::A, PNS::INDEX::Add(), SEG::B, PNS::ITEM::Layers(), linkJoint(), m_index, PNS::ITEM::Net(), and PNS::SEGMENT::Seg().

Referenced by Add().

◆ addSolid()

void PNS::NODE::addSolid ( SOLID aSeg)
private

Definition at line 521 of file pns_node.cpp.

522 {
523  if( aSolid->IsRoutable() )
524  linkJoint( aSolid->Pos(), aSolid->Layers(), aSolid->Net(), aSolid );
525 
526  m_index->Add( aSolid );
527 }
void linkJoint(const VECTOR2I &aPos, const LAYER_RANGE &aLayers, int aNet, ITEM *aWhere)
Unlink an item from a joint.
Definition: pns_node.cpp:1134
INDEX * m_index
Geometric/Net index of the items.
Definition: pns_node.h:451
void Add(ITEM *aItem)
Adds item to the spatial index.
Definition: pns_index.cpp:28

References PNS::INDEX::Add(), PNS::ITEM::IsRoutable(), PNS::ITEM::Layers(), linkJoint(), m_index, PNS::ITEM::Net(), and PNS::SOLID::Pos().

Referenced by Add().

◆ addVia()

void PNS::NODE::addVia ( VIA aVia)
private

Definition at line 537 of file pns_node.cpp.

538 {
539  linkJoint( aVia->Pos(), aVia->Layers(), aVia->Net(), aVia );
540 
541  m_index->Add( aVia );
542 }
void linkJoint(const VECTOR2I &aPos, const LAYER_RANGE &aLayers, int aNet, ITEM *aWhere)
Unlink an item from a joint.
Definition: pns_node.cpp:1134
INDEX * m_index
Geometric/Net index of the items.
Definition: pns_node.h:451
void Add(ITEM *aItem)
Adds item to the spatial index.
Definition: pns_index.cpp:28

References PNS::INDEX::Add(), PNS::ITEM::Layers(), linkJoint(), m_index, PNS::ITEM::Net(), and PNS::VIA::Pos().

Referenced by Add().

◆ AllItemsInNet()

void PNS::NODE::AllItemsInNet ( int  aNet,
std::set< ITEM * > &  aItems,
int  aKindMask = -1 
)

Definition at line 1306 of file pns_node.cpp.

1307 {
1308  INDEX::NET_ITEMS_LIST* l_cur = m_index->GetItemsForNet( aNet );
1309 
1310  if( l_cur )
1311  {
1312  for( ITEM* item : *l_cur )
1313  {
1314  if( item->OfKind( aKindMask ) && item->IsRoutable() )
1315  aItems.insert( item );
1316  }
1317  }
1318 
1319  if( !isRoot() )
1320  {
1321  INDEX::NET_ITEMS_LIST* l_root = m_root->m_index->GetItemsForNet( aNet );
1322 
1323  if( l_root )
1324  {
1325  for( ITEM* item : *l_root )
1326  {
1327  if( !Overrides( item ) && item->OfKind( aKindMask ) && item->IsRoutable() )
1328  aItems.insert( item );
1329  }
1330  }
1331  }
1332 }
std::list< ITEM * > NET_ITEMS_LIST
Definition: pns_index.h:48
bool Overrides(ITEM *aItem) const
Definition: pns_node.h:379
bool isRoot() const
Definition: pns_node.h:417
INDEX * m_index
Geometric/Net index of the items.
Definition: pns_node.h:451
NODE * m_root
root node of the whole hierarchy
Definition: pns_node.h:443
NET_ITEMS_LIST * GetItemsForNet(int aNet)
Returns list of all items in a given net.
Definition: pns_index.cpp:71

References PNS::INDEX::GetItemsForNet(), isRoot(), m_index, m_root, and Overrides().

Referenced by PNS::TOPOLOGY::AssembleDiffPair(), PNS::DIFF_PAIR_PLACER::FindDpPrimitivePair(), and PNS::TOPOLOGY::NearestUnconnectedItem().

◆ AssembleLine()

const LINE PNS::NODE::AssembleLine ( LINKED_ITEM aSeg,
int *  aOriginSegmentIndex = NULL,
bool  aStopAtLockedJoints = false 
)

Follow the joint map to assemble a line connecting two non-trivial joints starting from segment aSeg.

Parameters
aSegthe initial segment.
aOriginSegmentIndexindex of aSeg in the resulting line.
Returns
the linePrint the contents and joints structure.

Definition at line 912 of file pns_node.cpp.

914 {
915  const int MaxVerts = 1024 * 16;
916 
917  std::array<VECTOR2I, MaxVerts + 1> corners;
918  std::array<LINKED_ITEM*, MaxVerts + 1> segs;
919  std::array<bool, MaxVerts + 1> arcReversed;
920 
921  LINE pl;
922  bool guardHit = false;
923 
924  int i_start = MaxVerts / 2;
925  int i_end = i_start + 1;
926 
927  pl.SetWidth( aSeg->Width() );
928  pl.SetLayers( aSeg->Layers() );
929  pl.SetNet( aSeg->Net() );
930  pl.SetOwner( this );
931 
932  followLine( aSeg, false, i_start, MaxVerts, corners.data(), segs.data(), arcReversed.data(),
933  guardHit, aStopAtLockedJoints );
934 
935  if( !guardHit )
936  {
937  followLine( aSeg, true, i_end, MaxVerts, corners.data(), segs.data(), arcReversed.data(),
938  guardHit, aStopAtLockedJoints );
939  }
940 
941  int n = 0;
942 
943  LINKED_ITEM* prev_seg = NULL;
944  bool originSet = false;
945 
946  for( int i = i_start + 1; i < i_end; i++ )
947  {
948  const VECTOR2I& p = corners[i];
949  LINKED_ITEM* li = segs[i];
950 
951  if( !li || li->Kind() != ITEM::ARC_T )
952  pl.Line().Append( p );
953 
954  if( li && prev_seg != li )
955  {
956  int segIdxIncrement = 1;
957 
958  if( li->Kind() == ITEM::ARC_T )
959  {
960  const ARC* arc = static_cast<const ARC*>( li );
961  const SHAPE_ARC* sa = static_cast<const SHAPE_ARC*>( arc->Shape() );
962 
963  int nSegs = pl.Line().SegmentCount();
964 
965  pl.Line().Append( arcReversed[i] ? sa->Reversed() : *sa );
966 
967  segIdxIncrement = pl.Line().SegmentCount() - nSegs - 1;
968  }
969 
970  pl.Link( li );
971 
972  // latter condition to avoid loops
973  if( li == aSeg && aOriginSegmentIndex && !originSet )
974  {
975  *aOriginSegmentIndex = n;
976  originSet = true;
977  }
978 
979  n += segIdxIncrement;
980  }
981 
982  prev_seg = li;
983  }
984 
985  // Remove duplicate verts, but do NOT remove colinear segments here!
986  pl.Line().Simplify( false );
987 
988  assert( pl.SegmentCount() != 0 );
989 
990  return pl;
991 }
#define NULL
Definition: track.h:262
void followLine(LINKED_ITEM *aCurrent, bool aScanDirection, int &aPos, int aLimit, VECTOR2I *aCorners, LINKED_ITEM **aSegments, bool *aArcReversed, bool &aGuardHit, bool aStopAtLockedJoints)
Definition: pns_node.cpp:863
SHAPE_ARC Reversed() const
Definition: shape_arc.cpp:503

References SHAPE_LINE_CHAIN::Append(), PNS::ITEM::ARC_T, followLine(), PNS::ITEM::Kind(), PNS::ITEM::Layers(), PNS::LINE::Line(), PNS::LINK_HOLDER::Link(), PNS::ITEM::Net(), NULL, SHAPE_ARC::Reversed(), PNS::LINE::SegmentCount(), SHAPE_LINE_CHAIN::SegmentCount(), PNS::ITEM::SetLayers(), PNS::ITEM::SetNet(), PNS::ITEM::SetOwner(), PNS::LINE::SetWidth(), PNS::ARC::Shape(), SHAPE_LINE_CHAIN::Simplify(), and PNS::LINKED_ITEM::Width().

Referenced by PNS::TOPOLOGY::AssembleDiffPair(), PNS::SHOVE::assembleLine(), PNS::TOPOLOGY::AssembleTrivialPath(), Dump(), FindLinesBetweenJoints(), PNS::DRAGGER::findViaFanoutByHandle(), PNS::TOPOLOGY::followTrivialPath(), PNS::LINE_PLACER::removeLoops(), PNS::TOPOLOGY::SimplifyLine(), PNS::LINE_PLACER::simplifyNewLine(), PNS::MEANDER_SKEW_PLACER::Start(), PNS::COMPONENT_DRAGGER::Start(), PNS::MEANDER_PLACER::Start(), PNS::DRAGGER::startDragArc(), and PNS::DRAGGER::startDragSegment().

◆ Branch()

NODE * PNS::NODE::Branch ( )

Create a lightweight copy (called branch) of self that tracks the changes (added/removed items) wrs to the root.

Note
If there are any branches in use, their parents must not be deleted.
Returns
the new branch.

Definition at line 124 of file pns_node.cpp.

125 {
126  NODE* child = new NODE;
127 
128  m_children.insert( child );
129 
130  child->m_depth = m_depth + 1;
131  child->m_parent = this;
132  child->m_ruleResolver = m_ruleResolver;
133  child->m_root = isRoot() ? this : m_root;
135 
136  // Immediate offspring of the root branch needs not copy anything. For the rest, deep-copy
137  // joints, overridden item maps and pointers to stored items.
138  if( !isRoot() )
139  {
140  JOINT_MAP::iterator j;
141 
142  for( ITEM* item : *m_index )
143  child->m_index->Add( item );
144 
145  child->m_joints = m_joints;
146  child->m_override = m_override;
147  }
148 
149 #if 0
150  wxLogTrace( "PNS", "%d items, %d joints, %d overrides",
151  child->m_index->Size(),
152  (int) child->m_joints.size(),
153  (int) child->m_override.size() );
154 #endif
155 
156  return child;
157 }
std::set< NODE * > m_children
list of nodes branched from this one
Definition: pns_node.h:444
bool isRoot() const
Definition: pns_node.h:417
INDEX * m_index
Geometric/Net index of the items.
Definition: pns_node.h:451
NODE * m_root
root node of the whole hierarchy
Definition: pns_node.h:443
int m_depth
depth of the node (number of parent nodes in the inheritance chain)
Definition: pns_node.h:452
RULE_RESOLVER * m_ruleResolver
Design rules resolver.
Definition: pns_node.h:450
std::unordered_set< ITEM * > m_override
hash of root's items that have been changed in this node
Definition: pns_node.h:446
int m_maxClearance
worst case item-item clearance
Definition: pns_node.h:449
JOINT_MAP m_joints
hash table with the joints, linking the items.
Definition: pns_node.h:439

References PNS::INDEX::Add(), isRoot(), m_children, m_depth, m_index, m_joints, m_maxClearance, m_override, m_parent, m_root, m_ruleResolver, NODE(), and PNS::INDEX::Size().

Referenced by PNS::MEANDER_PLACER::doMove(), PNS::COMPONENT_DRAGGER::Drag(), PNS::DRAGGER::dragMarkObstacles(), PNS::DRAGGER::dragWalkaround(), PNS::LINE_PLACER::FixRoute(), PNS::DIFF_PAIR_PLACER::initPlacement(), PNS::LINE_PLACER::initPlacement(), PNS::TOPOLOGY::LeadingRatLine(), PNS::DP_MEANDER_PLACER::Move(), PNS::DIFF_PAIR_PLACER::Move(), PNS::LINE_PLACER::Move(), PNS::SHOVE::SetInitialLine(), PNS::SHOVE::ShoveDraggingVia(), PNS::SHOVE::ShoveLines(), PNS::SHOVE::ShoveMultiLines(), PNS::MEANDER_SKEW_PLACER::Start(), PNS::MEANDER_PLACER::Start(), PNS::DP_MEANDER_PLACER::Start(), PNS::DIFF_PAIR_PLACER::tryWalkDp(), and PNS::LINE_PLACER::UnfixRoute().

◆ CheckColliding() [1/2]

NODE::OPT_OBSTACLE PNS::NODE::CheckColliding ( const ITEM aItem,
int  aKindMask = ITEM::ANY_T 
)

Check if the item collides with anything else in the world, and if found, returns the obstacle.

Parameters
aItemthe item to find collisions with
aKindMaskmask of obstacle types to take into account
Returns
the obstacle, if found, otherwise empty.

Definition at line 425 of file pns_node.cpp.

426 {
427  OBSTACLES obs;
428 
429  obs.reserve( 100 );
430 
431  if( aItemA->Kind() == ITEM::LINE_T )
432  {
433  int n = 0;
434  const LINE* line = static_cast<const LINE*>( aItemA );
435  const SHAPE_LINE_CHAIN& l = line->CLine();
436 
437  for( int i = 0; i < l.SegmentCount(); i++ )
438  {
439  const SEGMENT s( *line, l.CSegment( i ) );
440  n += QueryColliding( &s, obs, aKindMask, 1 );
441 
442  if( n )
443  return OPT_OBSTACLE( obs[0] );
444  }
445 
446  if( line->EndsWithVia() )
447  {
448  n += QueryColliding( &line->Via(), obs, aKindMask, 1 );
449 
450  if( n )
451  return OPT_OBSTACLE( obs[0] );
452  }
453  }
454  else if( QueryColliding( aItemA, obs, aKindMask, 1 ) > 0 )
455  {
456  return OPT_OBSTACLE( obs[0] );
457  }
458 
459  return OPT_OBSTACLE();
460 }
int SegmentCount() const
Function SegmentCount()
int QueryColliding(const ITEM *aItem, OBSTACLES &aObstacles, int aKindMask=ITEM::ANY_T, int aLimitCount=-1, bool aDifferentNetsOnly=true)
Find items colliding (closer than clearance) with the item aItem.
Definition: pns_node.cpp:257
const SEG CSegment(int aIndex) const
Function CSegment()
SHAPE_LINE_CHAIN.
OPT< OBSTACLE > OPT_OBSTACLE
Definition: pns_node.h:148
std::vector< OBSTACLE > OBSTACLES
Definition: pns_node.h:150

References PNS::LINE::CLine(), SHAPE_LINE_CHAIN::CSegment(), PNS::LINE::EndsWithVia(), PNS::ITEM::Kind(), PNS::ITEM::LINE_T, QueryColliding(), SHAPE_LINE_CHAIN::SegmentCount(), and PNS::LINE::Via().

Referenced by PNS::DIFF_PAIR_PLACER::attemptWalk(), PNS::OPTIMIZER::checkColliding(), CheckColliding(), PNS::checkDpColliding(), PNS::MEANDER_PLACER::CheckFit(), PNS::DP_MEANDER_PLACER::CheckFit(), PNS::DRAGGER::dragMarkObstacles(), PNS::DRAGGER::dragViaWalkaround(), PNS::DRAGGER::dragWalkaround(), PNS::OPTIMIZER::fanoutCleanup(), PNS::COMPONENT_DRAGGER::FixRoute(), PNS::LINE_PLACER::FixRoute(), PNS::VIA::PushoutForce(), PNS::SHOVE::reduceSpringback(), PNS::LINE_PLACER::reduceTail(), PNS::DIFF_PAIR_PLACER::rhMarkObstacles(), PNS::LINE_PLACER::rhMarkObstacles(), PNS::DIFF_PAIR_PLACER::rhShoveOnly(), PNS::LINE_PLACER::rhWalkOnly(), PNS::WALKAROUND::Route(), PNS::SHOVE::ShoveLines(), PNS::WALKAROUND::singleStep(), PNS::tightenSegment(), and PNS::verifyDpBypass().

◆ CheckColliding() [2/2]

NODE::OPT_OBSTACLE PNS::NODE::CheckColliding ( const ITEM_SET aSet,
int  aKindMask = ITEM::ANY_T 
)

Check if any item in the set collides with anything else in the world, and if found, returns the obstacle.

Parameters
aSetset of items to find collisions with.
aKindMaskmask of obstacle types to take into account.
Returns
the obstacle, if found, otherwise empty.

Definition at line 411 of file pns_node.cpp.

412 {
413  for( const ITEM* item : aSet.CItems() )
414  {
415  OPT_OBSTACLE obs = CheckColliding( item, aKindMask );
416 
417  if( obs )
418  return obs;
419  }
420 
421  return OPT_OBSTACLE();
422 }
OPT_OBSTACLE CheckColliding(const ITEM *aItem, int aKindMask=ITEM::ANY_T)
Check if the item collides with anything else in the world, and if found, returns the obstacle.
Definition: pns_node.cpp:425
OPT< OBSTACLE > OPT_OBSTACLE
Definition: pns_node.h:148

References CheckColliding(), and PNS::ITEM_SET::CItems().

◆ ClearRanks()

void PNS::NODE::ClearRanks ( int  aMarkerMask = MK_HEAD | MK_VIOLATION | MK_HOLE)

Definition at line 1335 of file pns_node.cpp.

1336 {
1337  for( ITEM* item : *m_index )
1338  {
1339  item->SetRank( -1 );
1340  item->Mark( item->Marker() & ~aMarkerMask );
1341  }
1342 }
INDEX * m_index
Geometric/Net index of the items.
Definition: pns_node.h:451

References m_index.

Referenced by PNS::SHOVE::ShoveDraggingVia(), PNS::SHOVE::ShoveLines(), and PNS::SHOVE::ShoveMultiLines().

◆ Commit()

void PNS::NODE::Commit ( NODE aNode)

Apply the changes from a given branch (aNode) to the root branch.

Calling on a non-root branch will fail. Calling commit also kills all children nodes of the root branch.

Parameters
aNodenode to commit changes from.

Definition at line 1280 of file pns_node.cpp.

1281 {
1282  if( aNode->isRoot() )
1283  return;
1284 
1285  for( ITEM* item : aNode->m_override )
1286  Remove( item );
1287 
1288  for( ITEM* item : *aNode->m_index )
1289  {
1290  item->SetRank( -1 );
1291  item->Unmark();
1292  Add( std::unique_ptr<ITEM>( item ) );
1293  }
1294 
1295  releaseChildren();
1296  releaseGarbage();
1297 }
void releaseChildren()
Definition: pns_node.cpp:1252
void Remove(ARC *aArc)
Remove an item from this branch.
Definition: pns_node.cpp:802
void releaseGarbage()
Definition: pns_node.cpp:1265
bool Add(std::unique_ptr< SEGMENT > aSegment, bool aAllowRedundant=false)
Add an item to the current node.
Definition: pns_node.cpp:613

References Add(), isRoot(), m_index, m_override, releaseChildren(), releaseGarbage(), Remove(), PNS::ITEM::SetRank(), and PNS::ITEM::Unmark().

◆ Depth()

int PNS::NODE::Depth ( ) const
inline

Definition at line 190 of file pns_node.h.

191  {
192  return m_depth;
193  }
int m_depth
depth of the node (number of parent nodes in the inheritance chain)
Definition: pns_node.h:452

References m_depth.

Referenced by PNS::LINE_PLACER::Move().

◆ doRemove()

void PNS::NODE::doRemove ( ITEM aItem)
private

Definition at line 667 of file pns_node.cpp.

668 {
669  // case 1: removing an item that is stored in the root node from any branch:
670  // mark it as overridden, but do not remove
671  if( aItem->BelongsTo( m_root ) && !isRoot() )
672  m_override.insert( aItem );
673 
674  // case 2: the item belongs to this branch or a parent, non-root branch,
675  // or the root itself and we are the root: remove from the index
676  else if( !aItem->BelongsTo( m_root ) || isRoot() )
677  m_index->Remove( aItem );
678 
679  // the item belongs to this particular branch: un-reference it
680  if( aItem->BelongsTo( this ) )
681  {
682  aItem->SetOwner( NULL );
683  m_root->m_garbageItems.insert( aItem );
684  }
685 }
bool isRoot() const
Definition: pns_node.h:417
INDEX * m_index
Geometric/Net index of the items.
Definition: pns_node.h:451
NODE * m_root
root node of the whole hierarchy
Definition: pns_node.h:443
#define NULL
std::unordered_set< ITEM * > m_override
hash of root's items that have been changed in this node
Definition: pns_node.h:446
std::unordered_set< ITEM * > m_garbageItems
Definition: pns_node.h:455
void Remove(ITEM *aItem)
Removes an item from the spatial index.
Definition: pns_index.cpp:46

References PNS::ITEM::BelongsTo(), isRoot(), m_garbageItems, m_index, m_override, m_root, NULL, PNS::INDEX::Remove(), and PNS::ITEM::SetOwner().

Referenced by Remove().

◆ Dump()

void PNS::NODE::Dump ( bool  aLong = false)

Definition at line 1151 of file pns_node.cpp.

1152 {
1153 #if 0
1154  std::unordered_set<SEGMENT*> all_segs;
1156 
1157  for( i = m_items.begin(); i != m_items.end(); i++ )
1158  {
1159  if( (*i)->GetKind() == ITEM::SEGMENT_T )
1160  all_segs.insert( static_cast<SEGMENT*>( *i ) );
1161  }
1162 
1163  if( !isRoot() )
1164  {
1165  for( i = m_root->m_items.begin(); i != m_root->m_items.end(); i++ )
1166  {
1167  if( (*i)->GetKind() == ITEM::SEGMENT_T && !overrides( *i ) )
1168  all_segs.insert( static_cast<SEGMENT*>(*i) );
1169  }
1170  }
1171 
1172  JOINT_MAP::iterator j;
1173 
1174  if( aLong )
1175  {
1176  for( j = m_joints.begin(); j != m_joints.end(); ++j )
1177  {
1178  wxLogTrace( "PNS", "joint : %s, links : %d\n",
1179  j->second.GetPos().Format().c_str(), j->second.LinkCount() );
1180  JOINT::LINKED_ITEMS::const_iterator k;
1181 
1182  for( k = j->second.GetLinkList().begin(); k != j->second.GetLinkList().end(); ++k )
1183  {
1184  const ITEM* m_item = *k;
1185 
1186  switch( m_item->GetKind() )
1187  {
1188  case ITEM::SEGMENT_T:
1189  {
1190  const SEGMENT* seg = static_cast<const SEGMENT*>( m_item );
1191  wxLogTrace( "PNS", " -> seg %s %s\n", seg->GetSeg().A.Format().c_str(),
1192  seg->GetSeg().B.Format().c_str() );
1193  break;
1194  }
1195 
1196  default:
1197  break;
1198  }
1199  }
1200  }
1201  }
1202 
1203  int lines_count = 0;
1204 
1205  while( !all_segs.empty() )
1206  {
1207  SEGMENT* s = *all_segs.begin();
1208  LINE* l = AssembleLine( s );
1209 
1210  LINE::LinkedSegments* seg_refs = l->GetLinkedSegments();
1211 
1212  if( aLong )
1213  wxLogTrace( "PNS", "Line: %s, net %d ", l->GetLine().Format().c_str(), l->GetNet() );
1214 
1215  for( std::vector<SEGMENT*>::iterator j = seg_refs->begin(); j != seg_refs->end(); ++j )
1216  {
1217  wxLogTrace( "PNS", "%s ", (*j)->GetSeg().A.Format().c_str() );
1218 
1219  if( j + 1 == seg_refs->end() )
1220  wxLogTrace( "PNS", "%s\n", (*j)->GetSeg().B.Format().c_str() );
1221 
1222  all_segs.erase( *j );
1223  }
1224 
1225  lines_count++;
1226  }
1227 
1228  wxLogTrace( "PNS", "Local joints: %d, lines : %d \n", m_joints.size(), lines_count );
1229 #endif
1230 }
bool isRoot() const
Definition: pns_node.h:417
NODE * m_root
root node of the whole hierarchy
Definition: pns_node.h:443
const LINE AssembleLine(LINKED_ITEM *aSeg, int *aOriginSegmentIndex=NULL, bool aStopAtLockedJoints=false)
Follow the joint map to assemble a line connecting two non-trivial joints starting from segment aSeg.
Definition: pns_node.cpp:912
JOINT_MAP m_joints
hash table with the joints, linking the items.
Definition: pns_node.h:439

References AssembleLine(), isRoot(), m_joints, m_root, and PNS::ITEM::SEGMENT_T.

◆ FindItemByParent()

ITEM * PNS::NODE::FindItemByParent ( const BOARD_ITEM aParent)

Definition at line 1468 of file pns_node.cpp.

1469 {
1470  if( aParent->IsConnected() )
1471  {
1472  const BOARD_CONNECTED_ITEM* cItem = static_cast<const BOARD_CONNECTED_ITEM*>( aParent );
1473 
1475 
1476  if( l_cur )
1477  {
1478  for( ITEM* item : *l_cur )
1479  {
1480  if( item->Parent() == aParent )
1481  return item;
1482  }
1483  }
1484  }
1485 
1486  return NULL;
1487 }
std::list< ITEM * > NET_ITEMS_LIST
Definition: pns_index.h:48
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
INDEX * m_index
Geometric/Net index of the items.
Definition: pns_node.h:451
#define NULL
NET_ITEMS_LIST * GetItemsForNet(int aNet)
Returns list of all items in a given net.
Definition: pns_index.cpp:71
virtual bool IsConnected() const
Returns information if the object is derived from BOARD_CONNECTED_ITEM.
Definition: board_item.h:136

References PNS::INDEX::GetItemsForNet(), BOARD_CONNECTED_ITEM::GetNetCode(), BOARD_ITEM::IsConnected(), m_index, and NULL.

Referenced by ROUTER_TOOL::InlineBreakTrack(), and ROUTER_TOOL::InlineDrag().

◆ FindJoint() [1/2]

JOINT * PNS::NODE::FindJoint ( const VECTOR2I aPos,
int  aLayer,
int  aNet 
)

Search for a joint at a given position, layer and belonging to given net.

Returns
the joint, if found, otherwise empty.

Definition at line 1035 of file pns_node.cpp.

1036 {
1037  JOINT::HASH_TAG tag;
1038 
1039  tag.net = aNet;
1040  tag.pos = aPos;
1041 
1042  JOINT_MAP::iterator f = m_joints.find( tag ), end = m_joints.end();
1043 
1044  if( f == end && !isRoot() )
1045  {
1046  end = m_root->m_joints.end();
1047  f = m_root->m_joints.find( tag ); // m_root->FindJoint(aPos, aLayer, aNet);
1048  }
1049 
1050  if( f == end )
1051  return NULL;
1052 
1053  while( f != end )
1054  {
1055  if( f->second.Layers().Overlaps( aLayer ) )
1056  return &f->second;
1057 
1058  ++f;
1059  }
1060 
1061  return NULL;
1062 }
bool isRoot() const
Definition: pns_node.h:417
NODE * m_root
root node of the whole hierarchy
Definition: pns_node.h:443
#define NULL
JOINT_MAP m_joints
hash table with the joints, linking the items.
Definition: pns_node.h:439

References isRoot(), m_joints, m_root, PNS::JOINT::HASH_TAG::net, NULL, and PNS::JOINT::HASH_TAG::pos.

Referenced by PNS::TOPOLOGY::AssembleTrivialPath(), PNS::TOPOLOGY::ConnectedJoints(), FindJoint(), FindLineEnds(), PNS::OPTIMIZER::findPadOrVia(), findRedundantArc(), findRedundantSegment(), PNS::findViaByHandle(), PNS::DRAGGER::findViaFanoutByHandle(), followLine(), PNS::TOPOLOGY::followTrivialPath(), PNS::getDanglingAnchor(), PNS::SHOVE::onCollidingSolid(), PNS::SHOVE::onReverseCollidingVia(), PNS::SHOVE::pushOrShoveVia(), removeSolidIndex(), removeViaIndex(), PNS::SHOVE::shoveLineToHullSet(), PNS::LINE_PLACER::SplitAdjacentSegments(), and PNS::COMPONENT_DRAGGER::Start().

◆ FindJoint() [2/2]

JOINT* PNS::NODE::FindJoint ( const VECTOR2I aPos,
const ITEM aItem 
)
inline

Search for a joint at a given position, linked to given item.

Returns
the joint, if found, otherwise empty.Find all lines between a pair of joints. Used by the loop removal procedure.

Definition at line 346 of file pns_node.h.

References FindJoint(), PNS::ITEM::Layers(), PNS::ITEM::Net(), and LAYER_RANGE::Start().

◆ FindLineEnds()

void PNS::NODE::FindLineEnds ( const LINE aLine,
JOINT aA,
JOINT aB 
)

Destroy all child nodes. Applicable only to the root node.

Definition at line 994 of file pns_node.cpp.

995 {
996  aA = *FindJoint( aLine.CPoint( 0 ), &aLine );
997  aB = *FindJoint( aLine.CPoint( -1 ), &aLine );
998 }
JOINT * FindJoint(const VECTOR2I &aPos, int aLayer, int aNet)
Search for a joint at a given position, layer and belonging to given net.
Definition: pns_node.cpp:1035

References PNS::LINE::CPoint(), and FindJoint().

Referenced by FindLinesBetweenJoints(), PNS::MEANDER_PLACER_BASE::GetTotalPadToDieLength(), and PNS::LINE_PLACER::removeLoops().

◆ FindLinesBetweenJoints()

int PNS::NODE::FindLinesBetweenJoints ( const JOINT aA,
const JOINT aB,
std::vector< LINE > &  aLines 
)

Find the joints corresponding to the ends of line aLine.

Definition at line 1001 of file pns_node.cpp.

1002 {
1003  for( ITEM* item : aA.LinkList() )
1004  {
1005  if( item->Kind() == ITEM::SEGMENT_T || item->Kind() == ITEM::ARC_T )
1006  {
1007  LINKED_ITEM* li = static_cast<LINKED_ITEM*>( item );
1008  LINE line = AssembleLine( li );
1009 
1010  if( !line.Layers().Overlaps( aB.Layers() ) )
1011  continue;
1012 
1013  JOINT j_start, j_end;
1014 
1015  FindLineEnds( line, j_start, j_end );
1016 
1017  int id_start = line.CLine().Find( aA.Pos() );
1018  int id_end = line.CLine().Find( aB.Pos() );
1019 
1020  if( id_end < id_start )
1021  std::swap( id_end, id_start );
1022 
1023  if( id_start >= 0 && id_end >= 0 )
1024  {
1025  line.ClipVertexRange( id_start, id_end );
1026  aLines.push_back( line );
1027  }
1028  }
1029  }
1030 
1031  return 0;
1032 }
void FindLineEnds(const LINE &aLine, JOINT &aA, JOINT &aB)
Destroy all child nodes. Applicable only to the root node.
Definition: pns_node.cpp:994
const LINE AssembleLine(LINKED_ITEM *aSeg, int *aOriginSegmentIndex=NULL, bool aStopAtLockedJoints=false)
Follow the joint map to assemble a line connecting two non-trivial joints starting from segment aSeg.
Definition: pns_node.cpp:912

References PNS::ITEM::ARC_T, AssembleLine(), PNS::LINE::CLine(), PNS::LINE::ClipVertexRange(), SHAPE_LINE_CHAIN::Find(), FindLineEnds(), PNS::ITEM::Layers(), PNS::JOINT::LinkList(), LAYER_RANGE::Overlaps(), PNS::JOINT::Pos(), and PNS::ITEM::SEGMENT_T.

Referenced by PNS::LINE_PLACER::removeLoops().

◆ findRedundantArc() [1/2]

ARC * PNS::NODE::findRedundantArc ( const VECTOR2I A,
const VECTOR2I B,
const LAYER_RANGE lr,
int  aNet 
)
private

Definition at line 1395 of file pns_node.cpp.

1397 {
1398  JOINT* jtStart = FindJoint( A, lr.Start(), aNet );
1399 
1400  if( !jtStart )
1401  return nullptr;
1402 
1403  for( ITEM* item : jtStart->LinkList() )
1404  {
1405  if( item->OfKind( ITEM::ARC_T ) )
1406  {
1407  ARC* seg2 = static_cast<ARC*>( item );
1408 
1409  const VECTOR2I a2( seg2->Anchor( 0 ) );
1410  const VECTOR2I b2( seg2->Anchor( 1 ) );
1411 
1412  if( seg2->Layers().Start() == lr.Start()
1413  && ( ( A == a2 && B == b2 ) || ( A == b2 && B == a2 ) ) )
1414  {
1415  return seg2;
1416  }
1417  }
1418  }
1419 
1420  return nullptr;
1421 }
int Start() const
Definition: pns_layerset.h:82
JOINT * FindJoint(const VECTOR2I &aPos, int aLayer, int aNet)
Search for a joint at a given position, layer and belonging to given net.
Definition: pns_node.cpp:1035
Definition: track.h:262

References PNS::ARC::Anchor(), PNS::ITEM::ARC_T, FindJoint(), PNS::ITEM::Layers(), PNS::JOINT::LinkList(), and LAYER_RANGE::Start().

Referenced by Add(), and findRedundantArc().

◆ findRedundantArc() [2/2]

ARC * PNS::NODE::findRedundantArc ( ARC aSeg)
private

Scan the joint map, forming a line starting from segment (current).

Definition at line 1424 of file pns_node.cpp.

1425 {
1426  return findRedundantArc( aArc->Anchor( 0 ), aArc->Anchor( 1 ), aArc->Layers(), aArc->Net() );
1427 }
ARC * findRedundantArc(const VECTOR2I &A, const VECTOR2I &B, const LAYER_RANGE &lr, int aNet)
Definition: pns_node.cpp:1395

References PNS::ARC::Anchor(), findRedundantArc(), PNS::ITEM::Layers(), and PNS::ITEM::Net().

◆ findRedundantSegment() [1/2]

SEGMENT * PNS::NODE::findRedundantSegment ( const VECTOR2I A,
const VECTOR2I B,
const LAYER_RANGE lr,
int  aNet 
)
private

Definition at line 1360 of file pns_node.cpp.

1362 {
1363  JOINT* jtStart = FindJoint( A, lr.Start(), aNet );
1364 
1365  if( !jtStart )
1366  return nullptr;
1367 
1368  for( ITEM* item : jtStart->LinkList() )
1369  {
1370  if( item->OfKind( ITEM::SEGMENT_T ) )
1371  {
1372  SEGMENT* seg2 = (SEGMENT*)item;
1373 
1374  const VECTOR2I a2( seg2->Seg().A );
1375  const VECTOR2I b2( seg2->Seg().B );
1376 
1377  if( seg2->Layers().Start() == lr.Start()
1378  && ( ( A == a2 && B == b2 ) || ( A == b2 && B == a2 ) ) )
1379  {
1380  return seg2;
1381  }
1382  }
1383  }
1384 
1385  return nullptr;
1386 }
int Start() const
Definition: pns_layerset.h:82
JOINT * FindJoint(const VECTOR2I &aPos, int aLayer, int aNet)
Search for a joint at a given position, layer and belonging to given net.
Definition: pns_node.cpp:1035

References SEG::A, SEG::B, FindJoint(), PNS::ITEM::Layers(), PNS::JOINT::LinkList(), PNS::SEGMENT::Seg(), PNS::ITEM::SEGMENT_T, and LAYER_RANGE::Start().

Referenced by Add(), and findRedundantSegment().

◆ findRedundantSegment() [2/2]

SEGMENT * PNS::NODE::findRedundantSegment ( SEGMENT aSeg)
private

Definition at line 1389 of file pns_node.cpp.

1390 {
1391  return findRedundantSegment( aSeg->Seg().A, aSeg->Seg().B, aSeg->Layers(), aSeg->Net() );
1392 }
SEGMENT * findRedundantSegment(const VECTOR2I &A, const VECTOR2I &B, const LAYER_RANGE &lr, int aNet)
Definition: pns_node.cpp:1360

References SEG::A, SEG::B, findRedundantSegment(), PNS::ITEM::Layers(), PNS::ITEM::Net(), and PNS::SEGMENT::Seg().

◆ followLine()

void PNS::NODE::followLine ( LINKED_ITEM aCurrent,
bool  aScanDirection,
int &  aPos,
int  aLimit,
VECTOR2I aCorners,
LINKED_ITEM **  aSegments,
bool *  aArcReversed,
bool &  aGuardHit,
bool  aStopAtLockedJoints 
)
private

Definition at line 863 of file pns_node.cpp.

866 {
867  bool prevReversed = false;
868 
869  const VECTOR2I guard = aCurrent->Anchor( aScanDirection );
870 
871  for( int count = 0 ; ; ++count )
872  {
873  const VECTOR2I p = aCurrent->Anchor( aScanDirection ^ prevReversed );
874  const JOINT* jt = FindJoint( p, aCurrent );
875 
876  assert( jt );
877 
878  aCorners[aPos] = jt->Pos();
879  aSegments[aPos] = aCurrent;
880  aArcReversed[aPos] = false;
881 
882  if( aCurrent->Kind() == ITEM::ARC_T )
883  {
884  if( ( aScanDirection && jt->Pos() == aCurrent->Anchor( 0 ) ) ||
885  ( !aScanDirection && jt->Pos() == aCurrent->Anchor( 1 ) ) )
886  aArcReversed[aPos] = true;
887  }
888 
889  aPos += ( aScanDirection ? 1 : -1 );
890 
891  if( count && guard == p )
892  {
893  if( aPos >= 0 && aPos < aLimit )
894  aSegments[aPos] = NULL;
895 
896  aGuardHit = true;
897  break;
898  }
899 
900  bool locked = aStopAtLockedJoints ? jt->IsLocked() : false;
901 
902  if( locked || !jt->IsLineCorner() || aPos < 0 || aPos == aLimit )
903  break;
904 
905  aCurrent = jt->NextSegment( aCurrent );
906 
907  prevReversed = ( aCurrent && jt->Pos() == aCurrent->Anchor( aScanDirection ) );
908  }
909 }
#define NULL
JOINT * FindJoint(const VECTOR2I &aPos, int aLayer, int aNet)
Search for a joint at a given position, layer and belonging to given net.
Definition: pns_node.cpp:1035

References PNS::ITEM::Anchor(), PNS::ITEM::ARC_T, FindJoint(), PNS::JOINT::IsLineCorner(), PNS::JOINT::IsLocked(), PNS::ITEM::Kind(), locked, PNS::JOINT::NextSegment(), NULL, and PNS::JOINT::Pos().

Referenced by AssembleLine().

◆ GetClearance()

int PNS::NODE::GetClearance ( const ITEM aA,
const ITEM aB 
) const

Definition at line 97 of file pns_node.cpp.

98 {
99  if( !m_ruleResolver )
100  return 100000;
101 
102  return m_ruleResolver->Clearance( aA, aB );
103 }
virtual int Clearance(const ITEM *aA, const ITEM *aB)=0
RULE_RESOLVER * m_ruleResolver
Design rules resolver.
Definition: pns_node.h:450

References PNS::RULE_RESOLVER::Clearance(), and m_ruleResolver.

Referenced by PNS::ITEM::collideSimple(), PNS::SHOVE::getClearance(), PNS::ROUTER::markViolations(), NearestObstacle(), and PNS::VIA::PushoutForce().

◆ GetHoleClearance()

int PNS::NODE::GetHoleClearance ( const ITEM aA,
const ITEM aB 
) const

Definition at line 106 of file pns_node.cpp.

107  {
108  if( !m_ruleResolver )
109  return 0;
110 
111  return m_ruleResolver->HoleClearance( aA, aB );
112  }
RULE_RESOLVER * m_ruleResolver
Design rules resolver.
Definition: pns_node.h:450
virtual int HoleClearance(const ITEM *aA, const ITEM *aB)=0

References PNS::RULE_RESOLVER::HoleClearance(), and m_ruleResolver.

Referenced by PNS::ITEM::collideSimple(), PNS::SHOVE::getHoleClearance(), PNS::ROUTER::markViolations(), and NearestObstacle().

◆ GetHoleToHoleClearance()

int PNS::NODE::GetHoleToHoleClearance ( const ITEM aA,
const ITEM aB 
) const

Return the pre-set worst case clearance between any pair of items.

Definition at line 115 of file pns_node.cpp.

116 {
117  if( !m_ruleResolver )
118  return 0;
119 
120  return m_ruleResolver->HoleToHoleClearance( aA, aB );
121 }
RULE_RESOLVER * m_ruleResolver
Design rules resolver.
Definition: pns_node.h:450
virtual int HoleToHoleClearance(const ITEM *aA, const ITEM *aB)=0

References PNS::RULE_RESOLVER::HoleToHoleClearance(), and m_ruleResolver.

Referenced by PNS::ITEM::collideSimple(), and NearestObstacle().

◆ GetMaxClearance()

int PNS::NODE::GetMaxClearance ( ) const
inline

Set the worst-case clearance between any pair of items.

Definition at line 161 of file pns_node.h.

References m_maxClearance.

◆ GetParent()

NODE* PNS::NODE::GetParent ( void  ) const
inline

Check if this branch contains an updated version of the m_item from the root branch.

Definition at line 373 of file pns_node.h.

References m_parent.

◆ GetRuleResolver()

RULE_RESOLVER* PNS::NODE::GetRuleResolver ( ) const
inline

Return the number of joints.

Definition at line 178 of file pns_node.h.

References m_ruleResolver.

Referenced by PNS::TOPOLOGY::AssembleDiffPair(), and PNS::DIFF_PAIR_PLACER::FindDpPrimitivePair().

◆ GetUpdatedItems()

void PNS::NODE::GetUpdatedItems ( ITEM_VECTOR aRemoved,
ITEM_VECTOR aAdded 
)

Return the list of items removed and added in this branch with respect to the root branch.

Parameters
aRemovedremoved items.
aAddedadded items.

Definition at line 1233 of file pns_node.cpp.

1234 {
1235  if( isRoot() )
1236  return;
1237 
1238  if( m_override.size() )
1239  aRemoved.reserve( m_override.size() );
1240 
1241  if( m_index->Size() )
1242  aAdded.reserve( m_index->Size() );
1243 
1244  for( ITEM* item : m_override )
1245  aRemoved.push_back( item );
1246 
1247  for( INDEX::ITEM_SET::iterator i = m_index->begin(); i != m_index->end(); ++i )
1248  aAdded.push_back( *i );
1249 }
bool isRoot() const
Definition: pns_node.h:417
INDEX * m_index
Geometric/Net index of the items.
Definition: pns_node.h:451
std::unordered_set< ITEM * > m_override
hash of root's items that have been changed in this node
Definition: pns_node.h:446
ITEM_SET::iterator end()
Definition: pns_index.h:118
ITEM_SET::iterator begin()
Definition: pns_index.h:117
int Size() const
Returns number of items stored in the index.
Definition: pns_index.h:115

References PNS::INDEX::begin(), PNS::INDEX::end(), isRoot(), m_index, m_override, and PNS::INDEX::Size().

Referenced by PNS::ROUTER::CommitRouting(), PNS::LINE_PLACER::FixRoute(), PNS_TEST_ENVIRONMENT::ReplayLog(), and PNS::ROUTER::updateView().

◆ HasChildren()

bool PNS::NODE::HasChildren ( ) const
inline

Definition at line 368 of file pns_node.h.

369  {
370  return !m_children.empty();
371  }
std::set< NODE * > m_children
list of nodes branched from this one
Definition: pns_node.h:444

References m_children.

◆ HitTest()

const ITEM_SET PNS::NODE::HitTest ( const VECTOR2I aPoint) const

Find all items that contain the point aPoint.

Parameters
aPointthe point.
Returns
the items.

Definition at line 492 of file pns_node.cpp.

493 {
494  ITEM_SET items;
495 
496  // fixme: we treat a point as an infinitely small circle - this is inefficient.
497  SHAPE_CIRCLE s( aPoint, 0 );
498  HIT_VISITOR visitor( items, aPoint );
499  visitor.SetWorld( this, NULL );
500 
501  m_index->Query( &s, m_maxClearance, visitor );
502 
503  if( !isRoot() ) // fixme: could be made cleaner
504  {
505  ITEM_SET items_root;
506  visitor.SetWorld( m_root, NULL );
507  HIT_VISITOR visitor_root( items_root, aPoint );
508  m_root->m_index->Query( &s, m_maxClearance, visitor_root );
509 
510  for( ITEM* item : items_root.Items() )
511  {
512  if( !Overrides( item ) )
513  items.Add( item );
514  }
515  }
516 
517  return items;
518 }
int Query(const ITEM *aItem, int aMinDistance, Visitor &aVisitor) const
Searches items in the index that are in proximity of aItem.
Definition: pns_index.h:141
bool Overrides(ITEM *aItem) const
Definition: pns_node.h:379
bool isRoot() const
Definition: pns_node.h:417
INDEX * m_index
Geometric/Net index of the items.
Definition: pns_node.h:451
NODE * m_root
root node of the whole hierarchy
Definition: pns_node.h:443
#define NULL
int m_maxClearance
worst case item-item clearance
Definition: pns_node.h:449

References PNS::ITEM_SET::Add(), isRoot(), PNS::ITEM_SET::Items(), m_index, m_maxClearance, m_root, NULL, Overrides(), PNS::INDEX::Query(), and PNS::OBSTACLE_VISITOR::SetWorld().

◆ isRoot()

bool PNS::NODE::isRoot ( ) const
inlineprivate

Definition at line 417 of file pns_node.h.

418  {
419  return m_parent == NULL;
420  }
#define NULL
NODE * m_parent
node this node was branched from
Definition: pns_node.h:442

References m_parent, and NULL.

Referenced by AllItemsInNet(), Branch(), Commit(), doRemove(), Dump(), FindJoint(), GetUpdatedItems(), HitTest(), QueryColliding(), QueryJoints(), releaseGarbage(), touchJoint(), and unlinkParent().

◆ JointCount()

int PNS::NODE::JointCount ( ) const
inline

Return the number of nodes in the inheritance chain (wrs to the root node).

Definition at line 184 of file pns_node.h.

References m_joints.

Referenced by PNS::SHOVE::shoveMainLoop().

◆ KillChildren()

◆ linkJoint()

void PNS::NODE::linkJoint ( const VECTOR2I aPos,
const LAYER_RANGE aLayers,
int  aNet,
ITEM aWhere 
)
private

Unlink an item from a joint.

Definition at line 1134 of file pns_node.cpp.

1135 {
1136  JOINT& jt = touchJoint( aPos, aLayers, aNet );
1137 
1138  jt.Link( aWhere );
1139 }
JOINT & touchJoint(const VECTOR2I &aPos, const LAYER_RANGE &aLayers, int aNet)
Touch a joint and links it to an m_item.
Definition: pns_node.cpp:1072

References PNS::JOINT::Link(), and touchJoint().

Referenced by addArc(), addSegment(), addSolid(), addVia(), and rebuildJoint().

◆ LockJoint()

void PNS::NODE::LockJoint ( const VECTOR2I aPos,
const ITEM aItem,
bool  aLock 
)

Definition at line 1065 of file pns_node.cpp.

1066 {
1067  JOINT& jt = touchJoint( aPos, aItem->Layers(), aItem->Net() );
1068  jt.Lock( aLock );
1069 }
void Lock(bool aLock=true)
Definition: pns_joint.h:244
JOINT & touchJoint(const VECTOR2I &aPos, const LAYER_RANGE &aLayers, int aNet)
Touch a joint and links it to an m_item.
Definition: pns_node.cpp:1072

References PNS::ITEM::Layers(), PNS::JOINT::Lock(), PNS::ITEM::Net(), and touchJoint().

Referenced by PNS::SHOVE::ShoveLines().

◆ NearestObstacle()

NODE::OPT_OBSTACLE PNS::NODE::NearestObstacle ( const LINE aLine,
int  aKindMask = ITEM::ANY_T,
const std::set< ITEM * > *  aRestrictedSet = NULL 
)

Follow the line in search of an obstacle that is nearest to the starting to the line's starting point.

Parameters
aLinethe item to find collisions with
aKindMaskmask of obstacle types to take into account
Returns
the obstacle, if found, otherwise empty.

Definition at line 283 of file pns_node.cpp.

285 {
286  OBSTACLES obstacleList;
287  obstacleList.reserve( 100 );
288 
289  for( int i = 0; i < aLine->CLine().SegmentCount(); i++ )
290  {
291  const SEGMENT s( *aLine, aLine->CLine().CSegment( i ) );
292  QueryColliding( &s, obstacleList, aKindMask );
293  }
294 
295  if( aLine->EndsWithVia() )
296  QueryColliding( &aLine->Via(), obstacleList, aKindMask );
297 
298  if( obstacleList.empty() )
299  return OPT_OBSTACLE();
300 
301  OBSTACLE nearest;
302  nearest.m_item = NULL;
303  nearest.m_distFirst = INT_MAX;
304 
305  auto updateNearest =
306  [&]( VECTOR2I pt, ITEM* obstacle, const SHAPE_LINE_CHAIN& hull, bool isHole )
307  {
308  int dist = aLine->CLine().PathLength( pt );
309 
310  if( dist < nearest.m_distFirst )
311  {
312  nearest.m_distFirst = dist;
313  nearest.m_ipFirst = pt;
314  nearest.m_item = obstacle;
315  nearest.m_hull = hull;
316 
317  obstacle->Mark( isHole ? obstacle->Marker() | MK_HOLE
318  : obstacle->Marker() & ~MK_HOLE );
319  }
320  };
321 
322  SHAPE_LINE_CHAIN obstacleHull;
323  DEBUG_DECORATOR* debugDecorator = ROUTER::GetInstance()->GetInterface()->GetDebugDecorator();
324  std::vector<SHAPE_LINE_CHAIN::INTERSECTION> intersectingPts;
325  int layer = aLine->Layer();
326 
327  for( const OBSTACLE& obstacle : obstacleList )
328  {
329  if( aRestrictedSet && aRestrictedSet->find( obstacle.m_item ) == aRestrictedSet->end() )
330  continue;
331 
332  int clearance = GetClearance( obstacle.m_item, aLine ) + aLine->Width() / 2;
333  obstacleHull = obstacle.m_item->Hull( clearance + PNS_HULL_MARGIN, 0, layer );
334  debugDecorator->AddLine( obstacleHull, 2 );
335 
336  intersectingPts.clear();
337  obstacleHull.Intersect( aLine->CLine(), intersectingPts );
338 
339  for( const SHAPE_LINE_CHAIN::INTERSECTION& ip : intersectingPts )
340  updateNearest( ip.p, obstacle.m_item, obstacleHull, false );
341 
342  if( aLine->EndsWithVia() )
343  {
344  const VIA& via = aLine->Via();
345  // Don't use via.Drill(); it doesn't include the plating thickness
346  int viaHoleRadius = static_cast<const SHAPE_CIRCLE*>( via.Hole() )->GetRadius();
347 
348  int viaClearance = GetClearance( obstacle.m_item, &via ) + via.Diameter() / 2;
349  int holeClearance = GetHoleClearance( obstacle.m_item, &via ) + viaHoleRadius;
350 
351  if( holeClearance > viaClearance )
352  viaClearance = holeClearance;
353 
354  obstacleHull = obstacle.m_item->Hull( viaClearance + PNS_HULL_MARGIN, 0, layer );
355  debugDecorator->AddLine( obstacleHull, 3 );
356 
357  intersectingPts.clear();
358  obstacleHull.Intersect( aLine->CLine(), intersectingPts );
359 
360  for( const SHAPE_LINE_CHAIN::INTERSECTION& ip : intersectingPts )
361  updateNearest( ip.p, obstacle.m_item, obstacleHull, false );
362  }
363 
364  if( obstacle.m_item->Hole() )
365  {
366  clearance = GetHoleClearance( obstacle.m_item, aLine ) + aLine->Width() / 2;
367  obstacleHull = obstacle.m_item->HoleHull( clearance + PNS_HULL_MARGIN, 0, layer );
368  debugDecorator->AddLine( obstacleHull, 4 );
369 
370  intersectingPts.clear();
371  obstacleHull.Intersect( aLine->CLine(), intersectingPts );
372 
373  for( const SHAPE_LINE_CHAIN::INTERSECTION& ip : intersectingPts )
374  updateNearest( ip.p, obstacle.m_item, obstacleHull, true );
375 
376  if( aLine->EndsWithVia() )
377  {
378  const VIA& via = aLine->Via();
379  // Don't use via.Drill(); it doesn't include the plating thickness
380  int viaHoleRadius = static_cast<const SHAPE_CIRCLE*>( via.Hole() )->GetRadius();
381 
382  int viaClearance = GetClearance( obstacle.m_item, &via ) + via.Diameter() / 2;
383  int holeClearance = GetHoleClearance( obstacle.m_item, &via ) + viaHoleRadius;
384  int holeToHole = GetHoleToHoleClearance( obstacle.m_item, &via ) + viaHoleRadius;
385 
386  if( holeClearance > viaClearance )
387  viaClearance = holeClearance;
388 
389  if( holeToHole > viaClearance )
390  viaClearance = holeToHole;
391 
392  obstacleHull = obstacle.m_item->Hull( viaClearance + PNS_HULL_MARGIN, 0, layer );
393  debugDecorator->AddLine( obstacleHull, 5 );
394 
395  intersectingPts.clear();
396  obstacleHull.Intersect( aLine->CLine(), intersectingPts );
397 
398  for( const SHAPE_LINE_CHAIN::INTERSECTION& ip : intersectingPts )
399  updateNearest( ip.p, obstacle.m_item, obstacleHull, true );
400  }
401  }
402  }
403 
404  if( nearest.m_distFirst == INT_MAX )
405  nearest.m_item = obstacleList[0].m_item;
406 
407  return nearest;
408 }
Definition: track.h:343
int Intersect(const SEG &aSeg, INTERSECTIONS &aIp) const
Function Intersect()
int GetHoleToHoleClearance(const ITEM *aA, const ITEM *aB) const
Return the pre-set worst case clearance between any pair of items.
Definition: pns_node.cpp:115
#define PNS_HULL_MARGIN
Definition: pns_line.h:44
int GetHoleClearance(const ITEM *aA, const ITEM *aB) const
Definition: pns_node.cpp:106
int GetClearance(const ITEM *aA, const ITEM *aB) const
Definition: pns_node.cpp:97
#define NULL
int QueryColliding(const ITEM *aItem, OBSTACLES &aObstacles, int aKindMask=ITEM::ANY_T, int aLimitCount=-1, bool aDifferentNetsOnly=true)
Find items colliding (closer than clearance) with the item aItem.
Definition: pns_node.cpp:257
virtual DEBUG_DECORATOR * GetDebugDecorator()=0
SHAPE_LINE_CHAIN.
OPT< OBSTACLE > OPT_OBSTACLE
Definition: pns_node.h:148
std::vector< OBSTACLE > OBSTACLES
Definition: pns_node.h:150
ROUTER_IFACE * GetInterface() const
Definition: pns_router.h:210
static ROUTER * GetInstance()
Definition: pns_router.cpp:79

References PNS::DEBUG_DECORATOR::AddLine(), PNS::LINE::CLine(), SHAPE_LINE_CHAIN::CSegment(), PNS::LINE::EndsWithVia(), GetClearance(), PNS::ROUTER_IFACE::GetDebugDecorator(), GetHoleClearance(), GetHoleToHoleClearance(), PNS::ROUTER::GetInstance(), PNS::ROUTER::GetInterface(), SHAPE_LINE_CHAIN::Intersect(), PNS::ITEM::Layer(), PNS::OBSTACLE::m_distFirst, PNS::OBSTACLE::m_hull, PNS::OBSTACLE::m_ipFirst, PNS::OBSTACLE::m_item, PNS::MK_HOLE, NULL, SHAPE_LINE_CHAIN::PathLength(), PNS_HULL_MARGIN, QueryColliding(), SHAPE_LINE_CHAIN::SegmentCount(), PNS::LINE::Via(), via, and PNS::LINE::Width().

Referenced by PNS::LINE::ClipToNearestObstacle(), PNS::WALKAROUND::nearestObstacle(), PNS::LINE_PLACER::rhMarkObstacles(), and PNS::SHOVE::shoveIteration().

◆ operator=()

NODE& PNS::NODE::operator= ( const NODE aB)
private

Try to find matching joint and creates a new one if not found.

◆ Overrides()

bool PNS::NODE::Overrides ( ITEM aItem) const
inline

Definition at line 379 of file pns_node.h.

380  {
381  return m_override.find( aItem ) != m_override.end();
382  }
std::unordered_set< ITEM * > m_override
hash of root's items that have been changed in this node
Definition: pns_node.h:446

References m_override.

Referenced by AllItemsInNet(), HitTest(), QueryJoints(), and PNS::OBSTACLE_VISITOR::visit().

◆ QueryColliding()

int PNS::NODE::QueryColliding ( const ITEM aItem,
NODE::OBSTACLES aObstacles,
int  aKindMask = ITEM::ANY_T,
int  aLimitCount = -1,
bool  aDifferentNetsOnly = true 
)

Find items colliding (closer than clearance) with the item aItem.

Parameters
aItemitem to check collisions against
aObstaclesset of colliding objects found
aKindMaskmask of obstacle types to take into account
aLimitCountstop looking for collisions after finding this number of colliding items
Returns
number of obstacles found

Definition at line 257 of file pns_node.cpp.

259 {
260  DEFAULT_OBSTACLE_VISITOR visitor( aObstacles, aItem, aKindMask, aDifferentNetsOnly );
261 
262 #ifdef DEBUG
263  assert( allocNodes.find( this ) != allocNodes.end() );
264 #endif
265 
266  visitor.SetCountLimit( aLimitCount );
267  visitor.SetWorld( this, NULL );
268 
269  // first, look for colliding items in the local index
270  m_index->Query( aItem, m_maxClearance, visitor );
271 
272  // if we haven't found enough items, look in the root branch as well.
273  if( !isRoot() && ( visitor.m_matchCount < aLimitCount || aLimitCount < 0 ) )
274  {
275  visitor.SetWorld( m_root, this );
276  m_root->m_index->Query( aItem, m_maxClearance, visitor );
277  }
278 
279  return aObstacles.size();
280 }
int Query(const ITEM *aItem, int aMinDistance, Visitor &aVisitor) const
Searches items in the index that are in proximity of aItem.
Definition: pns_index.h:141
bool isRoot() const
Definition: pns_node.h:417
INDEX * m_index
Geometric/Net index of the items.
Definition: pns_node.h:451
NODE * m_root
root node of the whole hierarchy
Definition: pns_node.h:443
#define NULL
int m_maxClearance
worst case item-item clearance
Definition: pns_node.h:449

References isRoot(), m_index, PNS::NODE::DEFAULT_OBSTACLE_VISITOR::m_matchCount, m_maxClearance, m_root, NULL, PNS::INDEX::Query(), PNS::NODE::DEFAULT_OBSTACLE_VISITOR::SetCountLimit(), and PNS::OBSTACLE_VISITOR::SetWorld().

Referenced by PNS::TOPOLOGY::AssembleCluster(), CheckColliding(), PNS::ROUTER::markViolations(), and NearestObstacle().

◆ QueryJoints()

int PNS::NODE::QueryJoints ( const BOX2I aBox,
std::vector< JOINT * > &  aJoints,
LAYER_RANGE  aLayerMask = LAYER_RANGE::All(),
int  aKindMask = ITEM::ANY_T 
)

Definition at line 1430 of file pns_node.cpp.

1432 {
1433  int n = 0;
1434 
1435  aJoints.clear();
1436 
1437  for( JOINT_MAP::value_type& j : m_joints )
1438  {
1439  if( !j.second.Layers().Overlaps( aLayerMask ) )
1440  continue;
1441 
1442  if( aBox.Contains( j.second.Pos() ) && j.second.LinkCount( aKindMask ) )
1443  {
1444  aJoints.push_back( &j.second );
1445  n++;
1446  }
1447  }
1448 
1449  if( isRoot() )
1450  return n;
1451 
1452  for( JOINT_MAP::value_type& j : m_root->m_joints )
1453  {
1454  if( !Overrides( &j.second ) && j.second.Layers().Overlaps( aLayerMask ) )
1455  {
1456  if( aBox.Contains( j.second.Pos() ) && j.second.LinkCount( aKindMask ) )
1457  {
1458  aJoints.push_back( &j.second );
1459  n++;
1460  }
1461  }
1462  }
1463 
1464  return n;
1465 }
bool Overrides(ITEM *aItem) const
Definition: pns_node.h:379
bool isRoot() const
Definition: pns_node.h:417
NODE * m_root
root node of the whole hierarchy
Definition: pns_node.h:443
bool Contains(const Vec &aPoint) const
Function Contains.
Definition: box2.h:151
JOINT_MAP m_joints
hash table with the joints, linking the items.
Definition: pns_node.h:439

References BOX2< Vec >::Contains(), isRoot(), m_joints, m_root, and Overrides().

Referenced by PNS::KEEP_TOPOLOGY_CONSTRAINT::Check(), and PNS::COMPONENT_DRAGGER::Start().

◆ rebuildJoint()

void PNS::NODE::rebuildJoint ( JOINT aJoint,
ITEM aItem 
)
private

Definition at line 702 of file pns_node.cpp.

703 {
704  // We have to split a single joint (associated with a via or a pad, binding together multiple
705  // layers) into multiple independent joints. As I'm a lazy bastard, I simply delete the
706  // via/solid and all its links and re-insert them.
707 
708  JOINT::LINKED_ITEMS links( aJoint->LinkList() );
709  JOINT::HASH_TAG tag;
710  int net = aItem->Net();
711 
712  tag.net = net;
713  tag.pos = aJoint->Pos();
714 
715  bool split;
716 
717  do
718  {
719  split = false;
720  auto range = m_joints.equal_range( tag );
721 
722  if( range.first == m_joints.end() )
723  break;
724 
725  // find and remove all joints containing the via to be removed
726 
727  for( auto f = range.first; f != range.second; ++f )
728  {
729  if( aItem->LayersOverlap( &f->second ) )
730  {
731  m_joints.erase( f );
732  split = true;
733  break;
734  }
735  }
736  } while( split );
737 
738  // and re-link them, using the former via's link list
739  for( ITEM* link : links )
740  {
741  if( link != aItem )
742  linkJoint( tag.pos, link->Layers(), net, link );
743  }
744 }
void linkJoint(const VECTOR2I &aPos, const LAYER_RANGE &aLayers, int aNet, ITEM *aWhere)
Unlink an item from a joint.
Definition: pns_node.cpp:1134
ITEM_SET::ENTRIES LINKED_ITEMS
Joints are hashed by their position, layers and net.
Definition: pns_joint.h:45
JOINT_MAP m_joints
hash table with the joints, linking the items.
Definition: pns_node.h:439
static std::vector< std::string > split(const std::string &aStr, const std::string &aDelim)
Splits the input string into a vector of output strings.
Definition: kicad_string.h:278

References PNS::ITEM::LayersOverlap(), linkJoint(), PNS::JOINT::LinkList(), m_joints, PNS::ITEM::Net(), PNS::JOINT::Pos(), and split().

Referenced by removeSolidIndex(), and removeViaIndex().

◆ releaseChildren()

void PNS::NODE::releaseChildren ( )
private

Definition at line 1252 of file pns_node.cpp.

1253 {
1254  // copy the kids as the NODE destructor erases the item from the parent node.
1255  std::set<NODE*> kids = m_children;
1256 
1257  for( NODE* node : kids )
1258  {
1259  node->releaseChildren();
1260  delete node;
1261  }
1262 }
std::set< NODE * > m_children
list of nodes branched from this one
Definition: pns_node.h:444

References m_children.

Referenced by Commit(), and KillChildren().

◆ releaseGarbage()

void PNS::NODE::releaseGarbage ( )
private

Definition at line 1265 of file pns_node.cpp.

1266 {
1267  if( !isRoot() )
1268  return;
1269 
1270  for( ITEM* item : m_garbageItems )
1271  {
1272  if( !item->BelongsTo( this ) )
1273  delete item;
1274  }
1275 
1276  m_garbageItems.clear();
1277 }
bool isRoot() const
Definition: pns_node.h:417
std::unordered_set< ITEM * > m_garbageItems
Definition: pns_node.h:455

References isRoot(), and m_garbageItems.

Referenced by Commit(), and ~NODE().

◆ Remove() [1/6]

◆ Remove() [2/6]

void PNS::NODE::Remove ( SOLID aSolid)

Definition at line 781 of file pns_node.cpp.

782 {
783  removeSolidIndex( aSolid );
784  doRemove( aSolid );
785 }
void doRemove(ITEM *aItem)
Definition: pns_node.cpp:667
void removeSolidIndex(SOLID *aSeg)
Definition: pns_node.cpp:755

References doRemove(), and removeSolidIndex().

◆ Remove() [3/6]

void PNS::NODE::Remove ( VIA aVia)

Definition at line 788 of file pns_node.cpp.

789 {
790  removeViaIndex( aVia );
791  doRemove( aVia );
792 }
void doRemove(ITEM *aItem)
Definition: pns_node.cpp:667
void removeViaIndex(VIA *aVia)
Definition: pns_node.cpp:747

References doRemove(), and removeViaIndex().

◆ Remove() [4/6]

void PNS::NODE::Remove ( SEGMENT aSegment)

Definition at line 795 of file pns_node.cpp.

796 {
797  removeSegmentIndex( aSegment );
798  doRemove( aSegment );
799 }
void doRemove(ITEM *aItem)
Definition: pns_node.cpp:667
void removeSegmentIndex(SEGMENT *aSeg)
Definition: pns_node.cpp:688

References doRemove(), and removeSegmentIndex().

◆ Remove() [5/6]

void PNS::NODE::Remove ( ITEM aItem)

Definition at line 809 of file pns_node.cpp.

810 {
811  switch( aItem->Kind() )
812  {
813  case ITEM::ARC_T:
814  Remove( static_cast<ARC*>( aItem ) );
815  break;
816 
817  case ITEM::SOLID_T:
818  Remove( static_cast<SOLID*>( aItem ) );
819  break;
820 
821  case ITEM::SEGMENT_T:
822  Remove( static_cast<SEGMENT*>( aItem ) );
823  break;
824 
825  case ITEM::LINE_T:
826  {
827  LINE* l = static_cast<LINE*>( aItem );
828 
829  for ( LINKED_ITEM* s : l->Links() )
830  Remove( s );
831 
832  break;
833  }
834 
835  case ITEM::VIA_T:
836  Remove( static_cast<VIA*>( aItem ) );
837  break;
838 
839  default:
840  break;
841  }
842 }
void Remove(ARC *aArc)
Remove an item from this branch.
Definition: pns_node.cpp:802

References PNS::ITEM::ARC_T, PNS::ITEM::Kind(), PNS::ITEM::LINE_T, PNS::LINK_HOLDER::Links(), Remove(), PNS::ITEM::SEGMENT_T, PNS::ITEM::SOLID_T, and PNS::ITEM::VIA_T.

◆ Remove() [6/6]

void PNS::NODE::Remove ( LINE aLine)

Removes a line from this branch.

Parameters
aLineitem to remove

Definition at line 845 of file pns_node.cpp.

846 {
847  // LINE does not have a separate remover, as LINEs are never truly a member of the tree
848  std::vector<LINKED_ITEM*>& segRefs = aLine.Links();
849 
850  for( LINKED_ITEM* li : segRefs )
851  {
852  if( li->OfKind( ITEM::SEGMENT_T ) )
853  Remove( static_cast<SEGMENT*>( li ) );
854  else if( li->OfKind( ITEM::ARC_T ) )
855  Remove( static_cast<ARC*>( li ) );
856  }
857 
858  aLine.SetOwner( nullptr );
859  aLine.ClearLinks();
860 }
void Remove(ARC *aArc)
Remove an item from this branch.
Definition: pns_node.cpp:802

References PNS::ITEM::ARC_T, PNS::LINK_HOLDER::ClearLinks(), PNS::LINK_HOLDER::Links(), Remove(), PNS::ITEM::SEGMENT_T, and PNS::ITEM::SetOwner().

◆ removeArcIndex()

void PNS::NODE::removeArcIndex ( ARC aVia)
private

Definition at line 695 of file pns_node.cpp.

696 {
697  unlinkJoint( aArc->Anchor( 0 ), aArc->Layers(), aArc->Net(), aArc );
698  unlinkJoint( aArc->Anchor( 1 ), aArc->Layers(), aArc->Net(), aArc );
699 }
void unlinkJoint(const VECTOR2I &aPos, const LAYER_RANGE &aLayers, int aNet, ITEM *aWhere)
Helpers for adding/removing items.
Definition: pns_node.cpp:1142

References PNS::ARC::Anchor(), PNS::ITEM::Layers(), PNS::ITEM::Net(), and unlinkJoint().

Referenced by Remove().

◆ RemoveByMarker()

void PNS::NODE::RemoveByMarker ( int  aMarker)

Definition at line 1345 of file pns_node.cpp.

1346 {
1347  std::vector<ITEM*> garbage;
1348 
1349  for( ITEM* item : *m_index )
1350  {
1351  if( item->Marker() & aMarker )
1352  garbage.emplace_back( item );
1353  }
1354 
1355  for( ITEM* item : garbage )
1356  Remove( item );
1357 }
INDEX * m_index
Geometric/Net index of the items.
Definition: pns_node.h:451
void Remove(ARC *aArc)
Remove an item from this branch.
Definition: pns_node.cpp:802

References m_index, and Remove().

Referenced by PNS::SHOVE::ShoveLines(), and PNS::SHOVE::ShoveMultiLines().

◆ removeSegmentIndex()

void PNS::NODE::removeSegmentIndex ( SEGMENT aSeg)
private

Definition at line 688 of file pns_node.cpp.

689 {
690  unlinkJoint( aSeg->Seg().A, aSeg->Layers(), aSeg->Net(), aSeg );
691  unlinkJoint( aSeg->Seg().B, aSeg->Layers(), aSeg->Net(), aSeg );
692 }
void unlinkJoint(const VECTOR2I &aPos, const LAYER_RANGE &aLayers, int aNet, ITEM *aWhere)
Helpers for adding/removing items.
Definition: pns_node.cpp:1142

References SEG::A, SEG::B, PNS::ITEM::Layers(), PNS::ITEM::Net(), PNS::SEGMENT::Seg(), and unlinkJoint().

Referenced by Remove().

◆ removeSolidIndex()

void PNS::NODE::removeSolidIndex ( SOLID aSeg)
private

Definition at line 755 of file pns_node.cpp.

756 {
757  if( !aSolid->IsRoutable() )
758  return;
759 
760  // fixme: redundant code
761  JOINT* jt = FindJoint( aSolid->Pos(), aSolid->Layers().Start(), aSolid->Net() );
762  assert( jt );
763  rebuildJoint( jt, aSolid );
764 }
void rebuildJoint(JOINT *aJoint, ITEM *aItem)
Definition: pns_node.cpp:702
JOINT * FindJoint(const VECTOR2I &aPos, int aLayer, int aNet)
Search for a joint at a given position, layer and belonging to given net.
Definition: pns_node.cpp:1035

References FindJoint(), PNS::ITEM::IsRoutable(), PNS::ITEM::Layers(), PNS::ITEM::Net(), PNS::SOLID::Pos(), rebuildJoint(), and LAYER_RANGE::Start().

Referenced by Remove().

◆ removeViaIndex()

void PNS::NODE::removeViaIndex ( VIA aVia)
private

Definition at line 747 of file pns_node.cpp.

748 {
749  JOINT* jt = FindJoint( aVia->Pos(), aVia->Layers().Start(), aVia->Net() );
750  assert( jt );
751  rebuildJoint( jt, aVia );
752 }
void rebuildJoint(JOINT *aJoint, ITEM *aItem)
Definition: pns_node.cpp:702
JOINT * FindJoint(const VECTOR2I &aPos, int aLayer, int aNet)
Search for a joint at a given position, layer and belonging to given net.
Definition: pns_node.cpp:1035

References FindJoint(), PNS::ITEM::Layers(), PNS::ITEM::Net(), PNS::VIA::Pos(), rebuildJoint(), and LAYER_RANGE::Start().

Referenced by Remove().

◆ Replace() [1/2]

void PNS::NODE::Replace ( ITEM aOldItem,
std::unique_ptr< ITEM aNewItem 
)

Replace an item with another one.

Parameters
aOldItemitem to be removed
aNewItemitem add instead

Definition at line 767 of file pns_node.cpp.

768 {
769  Remove( aOldItem );
770  Add( std::move( aNewItem ) );
771 }
void Remove(ARC *aArc)
Remove an item from this branch.
Definition: pns_node.cpp:802
bool Add(std::unique_ptr< SEGMENT > aSegment, bool aAllowRedundant=false)
Add an item to the current node.
Definition: pns_node.cpp:613

References Add(), and Remove().

Referenced by PNS::SHOVE::replaceItems(), and PNS::SHOVE::replaceLine().

◆ Replace() [2/2]

void PNS::NODE::Replace ( LINE aOldLine,
LINE aNewLine 
)

Definition at line 774 of file pns_node.cpp.

775 {
776  Remove( aOldLine );
777  Add( aNewLine );
778 }
void Remove(ARC *aArc)
Remove an item from this branch.
Definition: pns_node.cpp:802
bool Add(std::unique_ptr< SEGMENT > aSegment, bool aAllowRedundant=false)
Add an item to the current node.
Definition: pns_node.cpp:613

References Add(), and Remove().

◆ SetMaxClearance()

void PNS::NODE::SetMaxClearance ( int  aClearance)
inline

Assign a clearance resolution function object.

Definition at line 167 of file pns_node.h.

References m_maxClearance.

Referenced by PNS_KICAD_IFACE_BASE::SyncWorld().

◆ SetRuleResolver()

void PNS::NODE::SetRuleResolver ( RULE_RESOLVER aFunc)
inline

Definition at line 173 of file pns_node.h.

174  {
175  m_ruleResolver = aFunc;
176  }
RULE_RESOLVER * m_ruleResolver
Design rules resolver.
Definition: pns_node.h:450

References m_ruleResolver.

Referenced by PNS_KICAD_IFACE_BASE::SyncWorld().

◆ touchJoint()

JOINT & PNS::NODE::touchJoint ( const VECTOR2I aPos,
const LAYER_RANGE aLayers,
int  aNet 
)
private

Touch a joint and links it to an m_item.

Definition at line 1072 of file pns_node.cpp.

1073 {
1074  JOINT::HASH_TAG tag;
1075 
1076  tag.pos = aPos;
1077  tag.net = aNet;
1078 
1079  // try to find the joint in this node.
1080  JOINT_MAP::iterator f = m_joints.find( tag );
1081 
1082  std::pair<JOINT_MAP::iterator, JOINT_MAP::iterator> range;
1083 
1084  // not found and we are not root? find in the root and copy results here.
1085  if( f == m_joints.end() && !isRoot() )
1086  {
1087  range = m_root->m_joints.equal_range( tag );
1088 
1089  for( f = range.first; f != range.second; ++f )
1090  m_joints.insert( *f );
1091  }
1092 
1093  // now insert and combine overlapping joints
1094  JOINT jt( aPos, aLayers, aNet );
1095 
1096  bool merged;
1097 
1098  do
1099  {
1100  merged = false;
1101  range = m_joints.equal_range( tag );
1102 
1103  if( range.first == m_joints.end() )
1104  break;
1105 
1106  for( f = range.first; f != range.second; ++f )
1107  {
1108  if( aLayers.Overlaps( f->second.Layers() ) )
1109  {
1110  jt.Merge( f->second );
1111  m_joints.erase( f );
1112  merged = true;
1113  break;
1114  }
1115  }
1116  }
1117  while( merged );
1118 
1119  return m_joints.insert( TagJointPair( tag, jt ) )->second;
1120 }
bool Overlaps(const LAYER_RANGE &aOther) const
Definition: pns_layerset.h:67
bool isRoot() const
Definition: pns_node.h:417
NODE * m_root
root node of the whole hierarchy
Definition: pns_node.h:443
JOINT_MAP::value_type TagJointPair
Definition: pns_node.h:437
JOINT_MAP m_joints
hash table with the joints, linking the items.
Definition: pns_node.h:439

References isRoot(), m_joints, m_root, PNS::JOINT::Merge(), PNS::JOINT::HASH_TAG::net, LAYER_RANGE::Overlaps(), and PNS::JOINT::HASH_TAG::pos.

Referenced by linkJoint(), LockJoint(), and unlinkJoint().

◆ unlinkJoint()

void PNS::NODE::unlinkJoint ( const VECTOR2I aPos,
const LAYER_RANGE aLayers,
int  aNet,
ITEM aWhere 
)
private

Helpers for adding/removing items.

Definition at line 1142 of file pns_node.cpp.

1143 {
1144  // fixme: remove dangling joints
1145  JOINT& jt = touchJoint( aPos, aLayers, aNet );
1146 
1147  jt.Unlink( aWhere );
1148 }
JOINT & touchJoint(const VECTOR2I &aPos, const LAYER_RANGE &aLayers, int aNet)
Touch a joint and links it to an m_item.
Definition: pns_node.cpp:1072

References touchJoint(), and PNS::JOINT::Unlink().

Referenced by removeArcIndex(), and removeSegmentIndex().

◆ unlinkParent()

void PNS::NODE::unlinkParent ( )
private

Definition at line 160 of file pns_node.cpp.

161 {
162  if( isRoot() )
163  return;
164 
165  m_parent->m_children.erase( this );
166 }
std::set< NODE * > m_children
list of nodes branched from this one
Definition: pns_node.h:444
bool isRoot() const
Definition: pns_node.h:417
NODE * m_parent
node this node was branched from
Definition: pns_node.h:442

References isRoot(), m_children, and m_parent.

Referenced by ~NODE().

Member Data Documentation

◆ m_children

std::set<NODE*> PNS::NODE::m_children
private

list of nodes branched from this one

Definition at line 444 of file pns_node.h.

Referenced by Branch(), HasChildren(), releaseChildren(), unlinkParent(), and ~NODE().

◆ m_depth

int PNS::NODE::m_depth
private

depth of the node (number of parent nodes in the inheritance chain)

Definition at line 452 of file pns_node.h.

Referenced by Branch(), Depth(), and NODE().

◆ m_garbageItems

std::unordered_set<ITEM*> PNS::NODE::m_garbageItems
private

Definition at line 455 of file pns_node.h.

Referenced by doRemove(), and releaseGarbage().

◆ m_index

INDEX* PNS::NODE::m_index
private

◆ m_joints

JOINT_MAP PNS::NODE::m_joints
private

hash table with the joints, linking the items.

Joints are hashed by their position, layer set and net.

Definition at line 439 of file pns_node.h.

Referenced by Branch(), Dump(), FindJoint(), JointCount(), QueryJoints(), rebuildJoint(), touchJoint(), and ~NODE().

◆ m_maxClearance

int PNS::NODE::m_maxClearance
private

worst case item-item clearance

Definition at line 449 of file pns_node.h.

Referenced by Branch(), GetMaxClearance(), HitTest(), NODE(), QueryColliding(), and SetMaxClearance().

◆ m_override

std::unordered_set<ITEM*> PNS::NODE::m_override
private

hash of root's items that have been changed in this node

Definition at line 446 of file pns_node.h.

Referenced by Branch(), Commit(), doRemove(), GetUpdatedItems(), and Overrides().

◆ m_parent

NODE* PNS::NODE::m_parent
private

node this node was branched from

Definition at line 442 of file pns_node.h.

Referenced by Branch(), GetParent(), isRoot(), NODE(), and unlinkParent().

◆ m_root

NODE* PNS::NODE::m_root
private

root node of the whole hierarchy

Definition at line 443 of file pns_node.h.

Referenced by AllItemsInNet(), Branch(), doRemove(), Dump(), FindJoint(), HitTest(), NODE(), QueryColliding(), QueryJoints(), and touchJoint().

◆ m_ruleResolver

RULE_RESOLVER* PNS::NODE::m_ruleResolver
private

Design rules resolver.

Definition at line 450 of file pns_node.h.

Referenced by Branch(), GetClearance(), GetHoleClearance(), GetHoleToHoleClearance(), GetRuleResolver(), NODE(), and SetRuleResolver().


The documentation for this class was generated from the following files: