29#ifndef PCBNEW_CONNECTIVITY_ITEMS_H
30#define PCBNEW_CONNECTIVITY_ITEMS_H
85 return (
m_pos - aSecond.
Pos() ).EuclideanNorm();
143 m_anchors.reserve( std::max( 6, aAnchorCount ) );
151 anchor->SetItem(
nullptr );
156 m_anchors.emplace_back( std::make_shared<CN_ANCHOR>( aPos,
this ) );
211 std::lock_guard<std::mutex> lock(
m_listLock );
274 for(
unsigned int ii = 0; ii <
m_fillPoly->TriangulatedPolyCount(); ++ii )
276 const auto* triangleSet =
m_fillPoly->TriangulatedPolygon( ii );
283 BOX2I bbox = tri.BBox();
284 const int mmin[2] = { bbox.
GetX(), bbox.
GetY() };
287 m_rTree.Insert( mmin, mmax, &tri );
301 int min[2] = { p.
x, p.
y };
302 int max[2] = { p.
x, p.
y };
303 bool collision =
false;
306 [&](
const SHAPE* aShape ) ->
bool
308 if( aShape->Collide( p ) )
317 m_rTree.Search( min, max, visitor );
338 int min[2] = { bbox.
GetX(), bbox.
GetY() };
340 bool collision =
false;
343 [&](
const SHAPE* aShape ) ->
bool
345 if( aRefShape->
Collide( aShape ) )
354 m_rTree.Search( min, max, visitor );
391 std::vector<CN_ITEM*>::iterator
end() {
return m_items.end(); };
393 std::vector<CN_ITEM*>::const_iterator
begin()
const {
return m_items.begin(); }
394 std::vector<CN_ITEM*>::const_iterator
end()
const {
return m_items.end(); }
414 item->SetDirty(
false );
472 std::vector<CN_ITEM*>::iterator
end() {
return m_items.end(); };
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.
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)
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
const std::shared_ptr< CN_CLUSTER > & GetCluster() const
unsigned int Dist(const CN_ANCHOR &aSecond)
void SetCluster(std::shared_ptr< CN_CLUSTER > &aCluster)
const VECTOR2I & Pos() const
int m_tag
Tag for quick connection resolution.
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...
void SetItem(CN_ITEM *aItem)
std::vector< CN_ITEM * >::iterator end()
std::vector< CN_ITEM * > m_items
bool IsConflicting() const
bool Contains(const CN_ITEM *aItem)
std::vector< CN_ITEM * >::iterator begin()
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
bool m_visited
visited flag for the BFS scan
std::vector< CN_ITEM * > m_connected
list of physically touching items
const std::vector< CN_ITEM * > & ConnectedItems() const
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)
std::vector< CN_ITEM * >::iterator begin()
std::vector< CN_ITEM * >::const_iterator begin() const
void SetDirty(bool aDirty=true)
std::vector< CN_ITEM * >::const_iterator end() const
std::vector< CN_ITEM * >::iterator end()
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)
CN_RTREE - Implements an R-tree for fast spatial indexing of connectivity items.
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.
virtual int AnchorCount() const override
bool HasSingleConnection()
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_fillPoly
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
bool IsTeardropArea() const
PCB_LAYER_ID
A quick note on layer IDs: