27 #include <unordered_set> 29 #include <unordered_map> 31 #include <boost/optional.hpp> 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 void OverrideClearance(
bool aEnable,
int aNetA = 0,
int aNetB = 0,
int aClearance = 0 ) = 0;
65 virtual void UseDpGap(
bool aUseDpGap ) = 0;
66 virtual int DpCoupledNet(
int aNet ) = 0;
67 virtual int DpNetPolarity(
int aNet ) = 0;
68 virtual bool DpNetPair(
ITEM* aItem,
int& aNetP,
int& aNetN ) = 0;
105 void SetWorld(
const NODE* aNode,
const NODE* aOverride = NULL );
107 virtual bool operator()(
ITEM* aCandidate ) = 0;
111 bool visit(
ITEM* aCandidate );
141 typedef boost::optional<OBSTACLE> OPT_OBSTACLE;
142 typedef std::vector<ITEM*> ITEM_VECTOR;
143 typedef std::vector<OBSTACLE> OBSTACLES;
149 int GetClearance(
const ITEM* aA,
const ITEM* aB )
const;
154 return m_maxClearance;
160 m_maxClearance = aClearance;
166 m_ruleResolver = aFunc;
171 return m_ruleResolver;
177 return m_joints.size();
196 int QueryColliding(
const ITEM* aItem,
197 OBSTACLES& aObstacles,
198 int aKindMask = ITEM::ANY_T,
199 int aLimitCount = -1,
200 bool aDifferentNetsOnly =
true,
201 int aForceClearance = -1 );
203 int QueryColliding(
const ITEM* aItem,
216 OPT_OBSTACLE NearestObstacle(
const LINE* aItem,
217 int aKindMask = ITEM::ANY_T,
218 const std::set<ITEM*>* aRestrictedSet = NULL );
229 OPT_OBSTACLE CheckColliding(
const ITEM* aItem,
230 int aKindMask = ITEM::ANY_T );
242 OPT_OBSTACLE CheckColliding(
const ITEM_SET& aSet,
243 int aKindMask = ITEM::ANY_T );
256 bool CheckColliding(
const ITEM* aItemA,
258 int aKindMask = ITEM::ANY_T,
259 int aForceClearance = -1 );
278 void 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 );
293 void Remove(
SOLID* aSolid );
294 void Remove(
VIA* aVia );
295 void Remove(
SEGMENT* aSegment );
296 void Remove(
ITEM* aItem );
305 void Remove(
LINE& aLine );
314 void Replace(
ITEM* aOldItem, std::unique_ptr< ITEM > aNewItem );
315 void Replace(
LINE& aOldLine,
LINE& aNewLine );
336 const LINE AssembleLine(
SEGMENT* aSeg,
int* aOriginSegmentIndex = NULL,
337 bool aStopAtLockedJoints =
false );
340 void Dump(
bool aLong =
false );
350 void GetUpdatedItems( ITEM_VECTOR& aRemoved, ITEM_VECTOR& aAdded );
359 void Commit(
NODE* aNode );
367 JOINT* FindJoint(
const VECTOR2I& aPos,
int aLayer,
int aNet );
369 void LockJoint(
const VECTOR2I& aPos,
const ITEM* aItem,
bool aLock );
379 return FindJoint( aPos, aItem->
Layers().Start(), aItem->
Net() );
383 void MapConnectivity(
JOINT* aStart, std::vector<JOINT*> & aFoundJoints );
385 ITEM* NearestUnconnectedItem(
JOINT* aStart,
int* aAnchor = NULL,
386 int aKindMask = ITEM::ANY_T);
391 int FindLinesBetweenJoints(
JOINT& aA,
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();
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;
467 void followLine(
SEGMENT* aCurrent,
474 bool aStopAtLockedJoints );
487 std::set<NODE*> m_children;
490 std::unordered_set<ITEM*> m_override;
504 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:83
const NODE * m_node
node we are searching in (either root or a branch)
Definition: pns_node.h:117
Class NODE.
Definition: pns_node.h:138
Definition: pns_itemset.h:39
int m_distFirst
... and the distance thereof
Definition: pns_node.h:93
int m_extraClearance
additional clearance
Definition: pns_node.h:123
int JointCount() const
Returns the number of joints
Definition: pns_node.h:175
Definition: pns_horizon_iface.hpp:26
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:181
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 SetRuleResolver(RULE_RESOLVER *aFunc)
Assigns a clerance resolution function object
Definition: pns_node.h:164
Definition: pns_node.cpp:180
void SetMaxClearance(int aClearance)
Sets the worst-case clerance between any pair of items
Definition: pns_node.h:158
Class JOINT.
Definition: pns_joint.h:43
Struct OBSTACLE_VISITOR.
Definition: pns_node.h:99
int Net() const
Function Net()
Definition: pns_item.h:178
JOINT * FindJoint(const VECTOR2I &aPos, const ITEM *aItem)
Function FindJoint()
Definition: pns_node.h:377
const ITEM * m_item
the item we are looking for collisions with
Definition: pns_node.h:114
SHAPE_LINE_CHAIN m_hull
Hull of the colliding m_item
Definition: pns_node.h:86
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:152
const ITEM * m_head
Item we search collisions with
Definition: pns_node.h:80
VECTOR2I m_ipFirst
First and last intersection point between the head item and the hull of the colliding m_item ...
Definition: pns_node.h:90
const NODE * m_override
node that overrides root entries
Definition: pns_node.h:120
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:208
Struct OBSTACLE.
Definition: pns_node.h:77