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;
103 void SetWorld(
const NODE* aNode,
const NODE* aOverride = NULL );
105 virtual bool operator()(
ITEM* aCandidate ) = 0;
109 bool visit(
ITEM* aCandidate );
139 typedef OPT<OBSTACLE> OPT_OBSTACLE;
140 typedef std::vector<ITEM*> ITEM_VECTOR;
141 typedef std::vector<OBSTACLE> OBSTACLES;
152 return m_maxClearance;
158 m_maxClearance = aClearance;
164 m_ruleResolver = aFunc;
169 return m_ruleResolver;
175 return m_joints.size();
195 OBSTACLES& aObstacles,
196 int aKindMask = ITEM::ANY_T,
197 int aLimitCount = -1,
198 bool aDifferentNetsOnly =
true,
199 int aForceClearance = -1 );
215 int aKindMask = ITEM::ANY_T,
216 const std::set<ITEM*>* aRestrictedSet = NULL );
228 int aKindMask = ITEM::ANY_T );
241 int aKindMask = ITEM::ANY_T );
256 int aKindMask = ITEM::ANY_T,
257 int aForceClearance = -1 );
277 bool Add( std::unique_ptr< SEGMENT > aSegment,
bool aAllowRedundant =
false );
278 void Add( std::unique_ptr< SOLID > aSolid );
279 void Add( std::unique_ptr< VIA > aVia );
281 void Add(
LINE& aLine,
bool aAllowRedundant =
false );
284 void Add( std::unique_ptr< ITEM > aItem,
bool aAllowRedundant =
false );
313 void Replace(
ITEM* aOldItem, std::unique_ptr< ITEM > aNewItem );
336 bool aStopAtLockedJoints =
false );
339 void Dump(
bool aLong =
false );
368 void LockJoint(
const VECTOR2I& aPos,
const ITEM* aItem,
bool aLock );
382 void MapConnectivity(
JOINT* aStart, std::vector<JOINT*> & aFoundJoints );
384 ITEM* NearestUnconnectedItem(
JOINT* aStart,
int* aAnchor = NULL,
385 int aKindMask = ITEM::ANY_T);
392 std::vector<LINE>& aLines );
400 void AllItemsInNet(
int aNet, std::set<ITEM*>& aItems );
402 void ClearRanks(
int aMarkerMask = MK_HEAD | MK_VIOLATION );
404 int FindByMarker(
int aMarker,
ITEM_SET& aItems );
405 int RemoveByMarker(
int aMarker );
409 bool HasChildren()
const
411 return !m_children.empty();
418 return m_override.find( aItem ) != m_override.end();
422 struct DEFAULT_OBSTACLE_VISITOR;
423 typedef std::unordered_multimap<JOINT::HASH_TAG, JOINT, JOINT::JOINT_TAG_HASH> JOINT_MAP;
424 typedef JOINT_MAP::value_type TagJointPair;
442 void addSolid(
SOLID* aSeg );
443 void addSegment(
SEGMENT* aSeg );
444 void addVia(
VIA* aVia );
446 void removeLine(
LINE& aLine );
447 void removeSolidIndex(
SOLID* aSeg );
448 void removeSegmentIndex(
SEGMENT* aSeg );
449 void removeViaIndex(
VIA* aVia );
451 void doRemove(
ITEM* aItem );
453 void releaseChildren();
454 void releaseGarbage();
458 return m_parent == NULL;
463 SEGMENT* findRedundantSegment( SEGMENT* aSeg );
466 void followLine( SEGMENT* aCurrent,
473 bool aStopAtLockedJoints );
486 std::set<NODE*> m_children;
489 std::unordered_set<ITEM*> m_override;
495 RULE_RESOLVER* m_ruleResolver;
503 std::unordered_set<ITEM*> m_garbageItems;
Definition: pns_line.h:60
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:75
int JointCount() const
Returns the number of joints
Definition: pns_node.h:173
const LAYER_RANGE & Layers() const
Function Layers()
Definition: pns_item.h:210
Class LAYER_RANGE.
Definition: pns_layerset.h:32
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:935
void FindLineEnds(const LINE &aLine, JOINT &aA, JOINT &aB)
finds the joints corresponding to the ends of line aLine
Definition: pns_node.cpp:890
Definition: pns_segment.h:38
int Depth() const
Returns the number of nodes in the inheritance chain (wrs to the root node)
Definition: pns_node.h:179
Class RULE_RESOLVER.
Definition: pns_node.h:57
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:416
void Commit(NODE *aNode)
Function Commit()
Definition: pns_node.cpp:1207
const LINE AssembleLine(SEGMENT *aSeg, int *aOriginSegmentIndex=NULL, bool aStopAtLockedJoints=false)
Function AssembleLine()
Definition: pns_node.cpp:835
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:162
int m_distFirst
... and the distance thereof
Definition: pns_node.h:91
NODE * Branch()
Function Branch()
Definition: pns_node.cpp:107
const NODE * m_override
node that overrides root entries
Definition: pns_node.h:118
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:1228
JOINT * FindJoint(const VECTOR2I &aPos, int aLayer, int aNet)
Function FindJoint()
Definition: pns_node.cpp:969
void SetMaxClearance(int aClearance)
Sets the worst-case clerance between any pair of items
Definition: pns_node.h:156
Class JOINT.
Definition: pns_joint.h:43
void Dump(bool aLong=false)
Prints the contents and joints structure
Definition: pns_node.cpp:1083
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:121
JOINT * FindJoint(const VECTOR2I &aPos, const ITEM *aItem)
Function FindJoint()
Definition: pns_node.h:376
Struct OBSTACLE_VISITOR.
Definition: pns_node.h:97
Definition: pns_solid.h:35
const ITEM * m_item
the item we are looking for collisions with
Definition: pns_node.h:112
SHAPE_LINE_CHAIN m_hull
Hull of the colliding m_item
Definition: pns_node.h:84
Definition: pns_itemset.h:39
Class ITEM.
Definition: pns_item.h:54
bool Add(std::unique_ptr< SEGMENT > aSegment, bool aAllowRedundant=false)
Function Add()
Definition: pns_node.cpp:595
const NODE * m_node
node we are searching in (either root or a branch)
Definition: pns_node.h:115
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:730
void Replace(ITEM *aOldItem, std::unique_ptr< ITEM > aNewItem)
Function Replace()
Definition: pns_node.cpp:718
int GetMaxClearance() const
Returns the pre-set worst case clearance between any pair of items
Definition: pns_node.h:150
Class NODE.
Definition: pns_node.h:136
Class SHAPE_LINE_CHAIN.
Definition: shape_line_chain.h:47
void GetUpdatedItems(ITEM_VECTOR &aRemoved, ITEM_VECTOR &aAdded)
Function GetUpdatedItems()
Definition: pns_node.cpp:1164
ITEM * m_item
Item found to be colliding with m_head
Definition: pns_node.h:81
VECTOR2I m_ipFirst
First and last intersection point between the head item and the hull of the colliding m_item
Definition: pns_node.h:88
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
const ITEM * m_head
Item we search collisions with
Definition: pns_node.h:78