48 if( simplified.PointCount() != l.
PointCount() )
63 std::deque<JOINT*> searchQueue;
66 searchQueue.push_back( aStart );
67 processed.insert( aStart );
69 while( !searchQueue.empty() )
71 JOINT* current = searchQueue.front();
72 searchQueue.pop_front();
78 SEGMENT* seg = static_cast<SEGMENT*>( item );
83 if( processed.find(
next ) == processed.end() )
85 processed.insert(
next );
86 searchQueue.push_back(
next );
98 LINE track( *aTrack );
105 tmpNode->Add( track );
107 JOINT* jt = tmpNode->FindJoint( track.
CPoint( -1 ), &track );
122 ITEM* it = topo.NearestUnconnectedItem( jt, &anchor );
127 end = it->Anchor( anchor );
139 std::set<ITEM*> disconnected;
145 for(
ITEM* link : jt->LinkList() )
147 if( disconnected.find( link ) != disconnected.end() )
148 disconnected.erase( link );
152 int best_dist = INT_MAX;
155 for(
ITEM* item : disconnected )
157 if( item->OfKind( aKindMask ) )
159 for(
int i = 0; i < item->AnchorCount(); i++ )
186 aLeft ? aLine->
Links().front() : aLine->
Links().back();
189 assert( jt !=
NULL );
191 aVisited.insert( last );
202 else if( aVisited.find( link ) == aVisited.end() )
203 next_seg = static_cast<SEGMENT*>( link );
213 if( nextAnchor != anchor )
243 std::set<ITEM*> visited;
247 seg = dyn_cast<SEGMENT*> (aStart);
249 if(!seg && (via = dyn_cast<VIA*>( aStart ) ) )
256 for(
const auto& entry : jt->
Links().
Items() )
257 if( ( seg = dyn_cast<SEGMENT*>( entry.item ) ) )
292 int refNet = aStart->
Net();
298 std::set<ITEM*> coupledItems;
303 int minDist = std::numeric_limits<int>::max();
305 if( ( refSeg = dyn_cast<SEGMENT*>( aStart ) ) !=
NULL )
307 for(
ITEM* item : coupledItems )
309 if(
SEGMENT* s = dyn_cast<SEGMENT*>( item ) )
311 if( s->Layers().Start() == refSeg->Layers().Start() && s->Width() == refSeg->Width() )
313 int dist = s->Seg().Distance( refSeg->Seg() );
314 bool isParallel = refSeg->Seg().ApproxParallel( s->Seg() );
319 if( isParallel && isCoupled && dist < minDist )
346 if( refSeg->Seg().ApproxParallel( coupledSeg->
Seg() ) )
349 const VECTOR2I refDir = refSeg->Anchor( 1 ) - refSeg->Anchor( 0 );
350 const VECTOR2I displacement = refSeg->Anchor( 1 ) - coupledSeg->
Anchor( 1 );
364 std::set<ITEM*> visited;
365 std::deque<ITEM*> pending;
367 pending.push_back( aStart );
369 while( !pending.empty() )
372 ITEM* top = pending.front();
376 visited.insert( top );
382 if( visited.find( obs.m_item ) == visited.end() && obs.m_item->Layers().Overlaps( aLayer ) && !( obs.m_item->Marker() &
MK_HEAD ) )
384 visited.insert( obs.m_item );
385 pending.push_back( obs.m_item );
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
const SHAPE_LINE_CHAIN & CLine() const
const JOINT_SET ConnectedJoints(JOINT *aStart)
extended_type Cross(const VECTOR2< T > &aVector) const
Compute cross product of self with aVector.
Base class for PNS router board items.
bool IsTraceWidthChange() const
Link the joint to a given board item (when it's added to the NODE).
bool followTrivialPath(LINE *aLine, bool aLeft, ITEM_SET &aSet, std::set< ITEM * > &aVisited)
SHAPE_LINE_CHAIN & Simplify(bool aRemoveColinear=true)
Function Simplify()
const ITEM_SET ConnectedItems(JOINT *aStart, int aKindMask=ITEM::ANY_T)
void Prepend(const LINE &aLine)
virtual int DpCoupledNet(int aNet)=0
const DIFF_PAIR AssembleDiffPair(SEGMENT *aStart)
ITEM * NearestUnconnectedItem(JOINT *aStart, int *aAnchor=NULL, int aKindMask=ITEM::ANY_T)
Represents a track on a PCB, connecting two non-trivial joints (that is, vias, pads,...
void Add(const LINE &aLine)
NODE * Branch()
Create a lightweight copy (called branch) of self that tracks the changes (added/removed items) wrs t...
const VECTOR2I & Pos() const
void Append(int aX, int aY, bool aAllowDuplication=false)
Function Append()
void Remove(ARC *aArc)
Remove an item from this branch.
const VECTOR2I & CPoint(int aIdx) const
const std::set< ITEM * > AssembleCluster(ITEM *aStart, int aLayer)
void SetShape(const SHAPE_LINE_CHAIN &aLine)
Return the shape of the line.
const VECTOR2I & CPoint(int aIndex) const
Function Point()
Represents a 2D point on a given set of layers and belonging to a certain net, that links together a ...
const ITEM_SET AssembleTrivialPath(ITEM *aStart)
void Reverse()
Clip the line to the nearest obstacle, traversing from the line's start vertex (0).
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.
bool LeadingRatLine(const LINE *aTrack, SHAPE_LINE_CHAIN &aRatLine)
virtual VECTOR2I Anchor(int n) const override
bool IsLinked() const
Check if the segment aLink is a part of the line.
void SetWidth(int aWidth)
const LINKED_ITEMS & LinkList() const
void SetLayers(const LAYER_RANGE &aLayers)
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.
JOINT * FindJoint(const VECTOR2I &aPos, int aLayer, int aNet)
Search for a joint at a given position, layer and belonging to given net.
bool SimplifyLine(LINE *aLine)
RULE_RESOLVER * GetRuleResolver() const
Return the number of joints.
bool commonParallelProjection(SEG p, SEG n, SEG &pClip, SEG &nClip)
void AllItemsInNet(int aNet, std::set< ITEM * > &aItems, int aKindMask=-1)
int Width() const
Return true if the line is geometrically identical as line aOther.
LINKED_ITEM * GetLink(int aIndex) const
Erase the linking information. Used to detach the line from the owning node.
void Clear()
Function Clear() Removes all points from the line chain.
virtual int DpNetPolarity(int aNet)=0
T EuclideanNorm() const
Compute the Euclidean norm of the vector, which is defined as sqrt(x ** 2 + y ** 2).
int LinkCount(int aMask=-1) const
const VECTOR2I & Pos() const
std::vector< OBSTACLE > OBSTACLES
Push and Shove diff pair dimensions (gap) settings dialog.
bool IsNonFanoutVia() const
bool Add(std::unique_ptr< SEGMENT > aSegment, bool aAllowRedundant=false)
Add an item to the current node.
const LAYER_RANGE & Layers() const
std::set< JOINT * > JOINT_SET
Hold an object colliding with another object, along with some useful data about the collision.