27 #include <unordered_set>
29 #include <unordered_map>
31 #include <core/optional.h>
33 #include <geometry/shape.h>
34 #include <geometry/shape_line_chain.h>
35 #include <geometry/shape_index.h>
38 #include "pns_joint.h"
39 #include "pns_itemset.h"
62 virtual int Clearance(
const ITEM* aA,
const ITEM* aB )
const = 0;
63 virtual int Clearance(
int aNetCode )
const = 0;
64 virtual int DpCoupledNet(
int aNet ) = 0;
65 virtual int DpNetPolarity(
int aNet ) = 0;
66 virtual bool DpNetPair(
ITEM* aItem,
int& aNetP,
int& aNetN ) = 0;
67 virtual std::string NetName(
int aNet ) = 0;
104 void SetWorld(
const NODE* aNode,
const NODE* aOverride = NULL );
106 virtual bool operator()(
ITEM* aCandidate ) = 0;
110 bool visit(
ITEM* aCandidate );
140 typedef OPT<OBSTACLE> OPT_OBSTACLE;
141 typedef std::vector<ITEM*> ITEM_VECTOR;
142 typedef std::vector<OBSTACLE> OBSTACLES;
153 return m_maxClearance;
159 m_maxClearance = aClearance;
165 m_ruleResolver = aFunc;
170 return m_ruleResolver;
176 return m_joints.size();
196 OBSTACLES& aObstacles,
197 int aKindMask = ITEM::ANY_T,
198 int aLimitCount = -1,
199 bool aDifferentNetsOnly =
true,
200 int aForceClearance = -1 );
216 int aKindMask = ITEM::ANY_T,
217 const std::set<ITEM*>* aRestrictedSet = NULL );
229 int aKindMask = ITEM::ANY_T );
242 int aKindMask = ITEM::ANY_T );
257 int aKindMask = ITEM::ANY_T,
258 int aForceClearance = -1 );
278 bool Add( std::unique_ptr< SEGMENT > aSegment,
bool aAllowRedundant =
false );
279 void Add( std::unique_ptr< SOLID > aSolid );
280 void Add( std::unique_ptr< VIA > aVia );
282 void Add(
LINE& aLine,
bool aAllowRedundant =
false );
285 void Add( std::unique_ptr< ITEM > aItem,
bool aAllowRedundant =
false );
314 void Replace(
ITEM* aOldItem, std::unique_ptr< ITEM > aNewItem );
337 bool aStopAtLockedJoints =
false );
340 void Dump(
bool aLong =
false );
369 void LockJoint(
const VECTOR2I& aPos,
const ITEM* aItem,
bool aLock );
383 void MapConnectivity(
JOINT* aStart, std::vector<JOINT*> & aFoundJoints );
385 ITEM* NearestUnconnectedItem(
JOINT* aStart,
int* aAnchor = NULL,
386 int aKindMask = ITEM::ANY_T);
393 std::vector<LINE>& aLines );
401 void AllItemsInNet(
int aNet, std::set<ITEM*>& aItems );
403 void ClearRanks(
int aMarkerMask = MK_HEAD | MK_VIOLATION );
405 int FindByMarker(
int aMarker,
ITEM_SET& aItems );
406 int RemoveByMarker(
int aMarker );
410 bool HasChildren()
const
412 return !m_children.empty();
419 return m_override.find( aItem ) != m_override.end();
423 struct DEFAULT_OBSTACLE_VISITOR;
424 typedef std::unordered_multimap<JOINT::HASH_TAG, JOINT, JOINT::JOINT_TAG_HASH> JOINT_MAP;
425 typedef JOINT_MAP::value_type TagJointPair;
443 void addSolid(
SOLID* aSeg );
444 void addSegment(
SEGMENT* aSeg );
445 void addVia(
VIA* aVia );
447 void removeLine(
LINE& aLine );
448 void removeSolidIndex(
SOLID* aSeg );
449 void removeSegmentIndex(
SEGMENT* aSeg );
450 void removeViaIndex(
VIA* aVia );
452 void doRemove(
ITEM* aItem );
454 void releaseChildren();
455 void releaseGarbage();
459 return m_parent == NULL;
464 SEGMENT* findRedundantSegment( SEGMENT* aSeg );
467 void followLine( SEGMENT* aCurrent,
474 bool aStopAtLockedJoints );
487 std::set<NODE*> m_children;
490 std::unordered_set<ITEM*> m_override;
496 RULE_RESOLVER* m_ruleResolver;
504 std::unordered_set<ITEM*> m_garbageItems;
Definition: pns_line.h:61
OPT_OBSTACLE NearestObstacle(const LINE *aItem, int aKindMask=ITEM::ANY_T, const std::set< ITEM * > *aRestrictedSet=NULL)
Function NearestObstacle()
Definition: pns_node.cpp:303
Struct OBSTACLE.
Definition: pns_node.h:77
int JointCount() const
Returns the number of joints
Definition: pns_node.h:174
const LAYER_RANGE & Layers() const
Function Layers()
Definition: pns_item.h:215
Class LAYER_RANGE.
Definition: pns_layerset.h:33
int FindLinesBetweenJoints(JOINT &aA, JOINT &aB, std::vector< LINE > &aLines)
finds all lines between a pair of joints. Used by the loop removal procedure.
Definition: pns_node.cpp:937
void FindLineEnds(const LINE &aLine, JOINT &aA, JOINT &aB)
finds the joints corresponding to the ends of line aLine
Definition: pns_node.cpp:892
Definition: pns_segment.h:39
int Depth() const
Returns the number of nodes in the inheritance chain (wrs to the root node)
Definition: pns_node.h:180
Class RULE_RESOLVER.
Definition: pns_node.h:58
bool Overrides(ITEM *aItem) const
checks if this branch contains an updated version of the m_item from the root branch.
Definition: pns_node.h:417
void Commit(NODE *aNode)
Function Commit()
Definition: pns_node.cpp:1209
const NODE * m_node
node we are searching in (either root or a branch)
Definition: pns_node.h:116
const LINE AssembleLine(SEGMENT *aSeg, int *aOriginSegmentIndex=NULL, bool aStopAtLockedJoints=false)
Function AssembleLine()
Definition: pns_node.cpp:837
int Net() const
Function Net()
Definition: pns_item.h:180
void SetRuleResolver(RULE_RESOLVER *aFunc)
Assigns a clerance resolution function object
Definition: pns_node.h:163
int m_distFirst
... and the distance thereof
Definition: pns_node.h:92
NODE * Branch()
Function Branch()
Definition: pns_node.cpp:107
Definition: pns_horizon_iface.hpp:28
int GetClearance(const ITEM *aA, const ITEM *aB) const
Returns the expected clearance between items a and b.
Definition: pns_node.cpp:98
void KillChildren()
Destroys all child nodes. Applicable only to the root node.
Definition: pns_node.cpp:1229
const NODE * m_override
node that overrides root entries
Definition: pns_node.h:119
const ITEM * m_head
Item we search collisions with
Definition: pns_node.h:79
JOINT * FindJoint(const VECTOR2I &aPos, int aLayer, int aNet)
Function FindJoint()
Definition: pns_node.cpp:971
void SetMaxClearance(int aClearance)
Sets the worst-case clerance between any pair of items
Definition: pns_node.h:157
Class JOINT.
Definition: pns_joint.h:44
void Dump(bool aLong=false)
Prints the contents and joints structure
Definition: pns_node.cpp:1085
OPT_OBSTACLE CheckColliding(const ITEM *aItem, int aKindMask=ITEM::ANY_T)
Function CheckColliding()
Definition: pns_node.cpp:426
int m_extraClearance
additional clearance
Definition: pns_node.h:122
JOINT * FindJoint(const VECTOR2I &aPos, const ITEM *aItem)
Function FindJoint()
Definition: pns_node.h:377
Struct OBSTACLE_VISITOR.
Definition: pns_node.h:98
Definition: pns_solid.h:36
ITEM * m_item
Item found to be colliding with m_head
Definition: pns_node.h:82
SHAPE_LINE_CHAIN m_hull
Hull of the colliding m_item
Definition: pns_node.h:85
Definition: pns_itemset.h:40
Class ITEM.
Definition: pns_item.h:55
bool Add(std::unique_ptr< SEGMENT > aSegment, bool aAllowRedundant=false)
Function Add()
Definition: pns_node.cpp:597
const ITEM_SET HitTest(const VECTOR2I &aPoint) const
Function HitTest()
Definition: pns_node.cpp:505
void Remove(SOLID *aSolid)
Function Remove()
Definition: pns_node.cpp:732
const ITEM * m_item
the item we are looking for collisions with
Definition: pns_node.h:113
void Replace(ITEM *aOldItem, std::unique_ptr< ITEM > aNewItem)
Function Replace()
Definition: pns_node.cpp:720
int GetMaxClearance() const
Returns the pre-set worst case clearance between any pair of items
Definition: pns_node.h:151
Class NODE.
Definition: pns_node.h:138
Class SHAPE_LINE_CHAIN.
Definition: shape_line_chain.h:50
void GetUpdatedItems(ITEM_VECTOR &aRemoved, ITEM_VECTOR &aAdded)
Function GetUpdatedItems()
Definition: pns_node.cpp:1166
VECTOR2I m_ipFirst
First and last intersection point between the head item and the hull of the colliding m_item
Definition: pns_node.h:89
int QueryColliding(const ITEM *aItem, OBSTACLES &aObstacles, int aKindMask=ITEM::ANY_T, int aLimitCount=-1, bool aDifferentNetsOnly=true, int aForceClearance=-1)
Function QueryColliding()
Definition: pns_node.cpp:277