29#ifndef PCBNEW_CONNECTIVITY_ITEMS_H
30#define PCBNEW_CONNECTIVITY_ITEMS_H
94 return (
m_pos - aSecond.
Pos() ).EuclideanNorm();
121 inline void SetCluster( std::shared_ptr<CN_CLUSTER>& aCluster )
175 m_anchors.reserve( std::max( 6, aAnchorCount ) );
184 m_anchors.emplace_back( std::make_shared<CN_ANCHOR>( aPos,
this ) );
239 std::lock_guard<std::mutex> lock(
m_listLock );
309 BOX2I bbox = tri.BBox();
310 const int mmin[2] = { bbox.
GetX(), bbox.
GetY() };
313 m_rTree.Insert( mmin, mmax, &tri );
324 int min[2] = { p.
x, p.
y };
325 int max[2] = { p.
x, p.
y };
326 bool collision =
false;
329 [&](
const SHAPE* aShape ) ->
bool
331 if( aShape->Collide( p ) )
340 m_rTree.Search( min, max, visitor );
367 int min[2] = { bbox.
GetX(), bbox.
GetY() };
369 bool collision =
false;
372 [&](
const SHAPE* aShape ) ->
bool
374 if( aRefShape->
Collide( aShape ) )
383 m_rTree.Search( min, max, visitor );
451 item->SetDirty(
false );
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
coord_type GetRight() const
coord_type GetBottom() const
CN_ANCHOR represents a physical location that can be connected: a pad or a track/arc/via endpoint.
void SetTag(int aTag)
Decide whether this node can be a ratsnest line target.
CN_ITEM * m_item
Pad or track/arc/via owning the anchor.
static const int TAG_UNCONNECTED
VECTOR2I m_pos
Position of the anchor.
void Move(const VECTOR2I &aPos)
void SetNoLine(bool aEnable)
Return true if this node can be a target for ratsnest lines.
int ConnectedItemsCount() const
std::shared_ptr< CN_CLUSTER > m_cluster
Cluster to which the anchor belongs.
CN_ANCHOR(const VECTOR2I &aPos, CN_ITEM *aItem)
const bool & GetNoLine() const
int GetTag() const
Set tag, common identifier for connected nodes.
const std::shared_ptr< CN_CLUSTER > & GetCluster() const
void SetCluster(std::shared_ptr< CN_CLUSTER > &aCluster)
const VECTOR2I & Pos() const
int m_tag
Tag for quick connection resolution.
const unsigned int Dist(const CN_ANCHOR &aSecond)
Return tag, common identifier for connected nodes.
bool m_noline
Whether it the node can be a target for ratsnest lines.
BOARD_CONNECTED_ITEM * Parent() const
bool IsDangling() const
The anchor point is dangling if the parent is a track and this anchor point is not connected to anoth...
std::vector< CN_ITEM * > m_items
decltype(m_items)::iterator ITER
bool IsConflicting() const
bool Contains(const CN_ITEM *aItem)
wxString OriginNetName() const
std::unordered_map< int, int > m_netRanks
CN_ITEM represents a BOARD_CONNETED_ITEM in the connectivity system (ie: a pad, track/arc/via,...
virtual int Layer() const
Return the item's layer, for single-layered items only.
void SetLayers(const LAYER_RANGE &aLayers)
Set the layers spanned by the item to aLayers.
virtual int AnchorCount() const
std::shared_ptr< CN_ANCHOR > GetAnchorItem(int n) const
bool m_visited
visited flag for the BFS scan
std::vector< CN_ITEM * > m_connected
list of physically touching items
int GetAnchorItemCount() const
const std::vector< CN_ITEM * > & ConnectedItems() const
int Net() const
allow parallel connection threads
void SetValid(bool aValid)
BOARD_CONNECTED_ITEM * m_parent
std::shared_ptr< CN_ANCHOR > AddAnchor(const VECTOR2I &aPos)
BOX2I m_bbox
bounding box for the item
virtual const VECTOR2I GetAnchor(int n) const
LAYER_RANGE m_layers
layer range over which the item exists
bool m_canChangeNet
can the net propagator modify the netcode?
void SetDirty(bool aDirty)
bool CanChangeNet() const
bool m_dirty
used to identify recently added item not yet scanned into the connectivity search
CN_ITEM(BOARD_CONNECTED_ITEM *aParent, bool aCanChangeNet, int aAnchorCount=2)
void SetLayer(int aLayer)
Set the layers spanned by the item to a single layer aLayer.
void SetVisited(bool aVisited)
const LAYER_RANGE & Layers() const
Return the contiguous set of layers spanned by the item.
std::vector< std::shared_ptr< CN_ANCHOR > > m_anchors
bool m_valid
used to identify garbage items (we use lazy removal)
std::vector< std::shared_ptr< CN_ANCHOR > > & Anchors()
BOARD_CONNECTED_ITEM * Parent() const
std::mutex m_listLock
mutex protecting this item's connected_items set to
CN_RTREE< CN_ITEM * > m_index
CN_ITEM * operator[](int aIndex)
decltype(m_items)::const_iterator CONST_ITER
decltype(m_items)::iterator ITER
void SetDirty(bool aDirty=true)
std::vector< CN_ITEM * > m_items
void FindNearby(CN_ITEM *aItem, T aFunc)
void addItemtoTree(CN_ITEM *item)
void SetHasInvalid(bool aInvalid=true)
void RemoveInvalidItems(std::vector< CN_ITEM * > &aGarbage)
void Insert(T aItem)
Function Insert() Inserts an item into the tree.
void Query(const BOX2I &aBounds, const LAYER_RANGE &aRange, Visitor &aVisitor) const
Function Query() Executes a function object aVisitor for each item whose bounding box intersects with...
void RemoveAll()
Function RemoveAll() Removes all items from the RTree.
VECTOR2I ClosestPoint(const VECTOR2I aPt)
virtual int AnchorCount() const override
const SHAPE_LINE_CHAIN & GetOutline() const
CN_ZONE_LAYER(ZONE *aParent, PCB_LAYER_ID aLayer, int aSubpolyIndex)
virtual const VECTOR2I GetAnchor(int n) const override
PCB_LAYER_ID GetLayer() const
RTree< const SHAPE *, int, 2, double > m_rTree
bool Collide(SHAPE *aRefShape) const
std::shared_ptr< SHAPE_POLY_SET > m_triangulatedPoly
bool ContainsPoint(const VECTOR2I &p) const
virtual const BOX2I GetBoundingBox() const
Return the orthogonal bounding box of this object for display purposes.
Represent a contiguous set of PCB layers.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
An abstract shape on 2D plane.
virtual bool Collide(const VECTOR2I &aP, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const
Check if the boundary of shape (this) lies closer to the point aP than aClearance,...
virtual const BOX2I BBox(int aClearance=0) const =0
Compute a bounding box of the shape, with a margin of aClearance a collision.
Handle a list of polygons defining a copper zone.
const std::shared_ptr< SHAPE_POLY_SET > & GetFilledPolysList(PCB_LAYER_ID aLayer) const
std::shared_ptr< CN_ITEM > CN_ITEM_PTR
PCB_LAYER_ID
A quick note on layer IDs: