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;
147 int GetClearance(
const ITEM* aA,
const ITEM* aB )
const;
152 return m_maxClearance;
158 m_maxClearance = aClearance;
164 m_ruleResolver = aFunc;
169 return m_ruleResolver;
175 return m_joints.size();
194 int QueryColliding(
const ITEM* aItem,
195 OBSTACLES& aObstacles,
196 int aKindMask = ITEM::ANY_T,
197 int aLimitCount = -1,
198 bool aDifferentNetsOnly =
true,
199 int aForceClearance = -1 );
201 int QueryColliding(
const ITEM* aItem,
214 OPT_OBSTACLE NearestObstacle(
const LINE* aItem,
215 int aKindMask = ITEM::ANY_T,
216 const std::set<ITEM*>* aRestrictedSet = NULL );
227 OPT_OBSTACLE CheckColliding(
const ITEM* aItem,
228 int aKindMask = ITEM::ANY_T );
240 OPT_OBSTACLE CheckColliding(
const ITEM_SET& aSet,
241 int aKindMask = ITEM::ANY_T );
254 bool CheckColliding(
const ITEM* aItemA,
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 );
292 void Remove(
SOLID* aSolid );
293 void Remove(
VIA* aVia );
294 void Remove(
SEGMENT* aSegment );
295 void Remove(
ITEM* aItem );
304 void Remove(
LINE& aLine );
313 void Replace(
ITEM* aOldItem, std::unique_ptr< ITEM > aNewItem );
314 void Replace(
LINE& aOldLine,
LINE& aNewLine );
335 const LINE AssembleLine(
SEGMENT* aSeg,
int* aOriginSegmentIndex = NULL,
336 bool aStopAtLockedJoints =
false );
339 void Dump(
bool aLong =
false );
349 void GetUpdatedItems( ITEM_VECTOR& aRemoved, ITEM_VECTOR& aAdded );
358 void Commit(
NODE* aNode );
366 JOINT* FindJoint(
const VECTOR2I& aPos,
int aLayer,
int aNet );
368 void LockJoint(
const VECTOR2I& aPos,
const ITEM* aItem,
bool aLock );
378 return FindJoint( aPos, aItem->
Layers().Start(), aItem->
Net() );
382 void MapConnectivity(
JOINT* aStart, std::vector<JOINT*> & aFoundJoints );
384 ITEM* NearestUnconnectedItem(
JOINT* aStart,
int* aAnchor = NULL,
385 int aKindMask = ITEM::ANY_T);
390 int FindLinesBetweenJoints(
JOINT& aA,
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();
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;
466 void followLine(
SEGMENT* aCurrent,
473 bool aStopAtLockedJoints );
486 std::set<NODE*> m_children;
489 std::unordered_set<ITEM*> m_override;
503 std::unordered_set<ITEM*> m_garbageItems;
Class ITEM.
Definition: pns_item.h:54
ITEM * m_item
Item found to be colliding with m_head
Definition: pns_node.h:81
const NODE * m_node
node we are searching in (either root or a branch)
Definition: pns_node.h:115
Class NODE.
Definition: pns_node.h:136
Definition: pns_itemset.h:39
int m_distFirst
... and the distance thereof
Definition: pns_node.h:91
int m_extraClearance
additional clearance
Definition: pns_node.h:121
int JointCount() const
Returns the number of joints
Definition: pns_node.h:173
Definition: pns_horizon_iface.hpp:28
Definition: pns_solid.h:35
Class RULE_RESOLVER.
Definition: pns_node.h:57
Definition: pns_line.h:60
int Depth() const
Returns the number of nodes in the inheritance chain (wrs to the root node)
Definition: pns_node.h:179
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 SetRuleResolver(RULE_RESOLVER *aFunc)
Assigns a clerance resolution function object
Definition: pns_node.h:162
Definition: pns_node.cpp:180
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
Struct OBSTACLE_VISITOR.
Definition: pns_node.h:97
int Net() const
Function Net()
Definition: pns_item.h:180
JOINT * FindJoint(const VECTOR2I &aPos, const ITEM *aItem)
Function FindJoint()
Definition: pns_node.h:376
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
Class SHAPE_LINE_CHAIN.
Definition: shape_line_chain.h:47
int GetMaxClearance() const
Returns the pre-set worst case clearance between any pair of items
Definition: pns_node.h:150
const ITEM * m_head
Item we search collisions with
Definition: pns_node.h:78
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
const NODE * m_override
node that overrides root entries
Definition: pns_node.h:118
Definition: pns_segment.h:38
Definition: pns_algo_base.cpp:26
Class INDEX.
Definition: pns_index.h:46
Class LAYER_RANGE.
Definition: pns_layerset.h:32
const LAYER_RANGE & Layers() const
Function Layers()
Definition: pns_item.h:210
Struct OBSTACLE.
Definition: pns_node.h:75