29#ifndef PCBNEW_CONNECTIVITY_ITEMS_H
30#define PCBNEW_CONNECTIVITY_ITEMS_H
86 return (
m_pos - aSecond.
Pos() ).EuclideanNorm();
143 m_anchors.reserve( std::max( 6, aAnchorCount ) );
152 anchor->SetItem(
nullptr );
157 m_anchors.emplace_back( std::make_shared<CN_ANCHOR>( aPos,
this ) );
176 if( aStartLayer ==
B_Cu )
177 aStartLayer = std::numeric_limits<int>::max();
179 if( aEndLayer ==
B_Cu )
180 aEndLayer = std::numeric_limits<int>::max();
215 if( layer == std::numeric_limits<int>::max() )
238 std::lock_guard<std::mutex> lock(
m_listLock );
298 if(
m_zone->IsTeardropArea() )
301 for(
unsigned int ii = 0; ii <
m_fillPoly->TriangulatedPolyCount(); ++ii )
303 const auto* triangleSet =
m_fillPoly->TriangulatedPolygon( ii );
310 BOX2I bbox = tri.BBox();
311 const int mmin[2] = { bbox.
GetX(), bbox.
GetY() };
314 m_rTree.Insert( mmin, mmax, &tri );
325 if(
m_zone->IsTeardropArea() )
328 int min[2] = { p.
x, p.
y };
329 int max[2] = { p.
x, p.
y };
330 bool collision =
false;
333 [&](
const SHAPE* aShape ) ->
bool
335 if( aShape->Collide( p ) )
344 m_rTree.Search( min, max, visitor );
361 if(
m_zone->IsTeardropArea() )
365 int min[2] = { bbox.
GetX(), bbox.
GetY() };
367 bool collision =
false;
370 [&](
const SHAPE* aShape ) ->
bool
372 if( aRefShape->
Collide( aShape ) )
381 m_rTree.Search( min, max, visitor );
418 std::vector<CN_ITEM*>::iterator
end() {
return m_items.end(); };
420 std::vector<CN_ITEM*>::const_iterator
begin()
const {
return m_items.begin(); }
421 std::vector<CN_ITEM*>::const_iterator
end()
const {
return m_items.end(); }
441 item->SetDirty(
false );
500 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,...
constexpr coord_type GetY() const
constexpr coord_type GetX() const
constexpr coord_type GetRight() const
constexpr coord_type GetBottom() const
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.
virtual int AnchorCount() const
std::vector< CN_ITEM * > m_connected
list of physically touching items
const std::vector< CN_ITEM * > & ConnectedItems() const
int m_start_layer
start layer of the item N.B. B_Cu is set to INT_MAX
void SetValid(bool aValid)
BOARD_CONNECTED_ITEM * m_parent
int m_end_layer
end layer of the item N.B. B_Cu is set to INT_MAX
int StartLayer() const
Return the contiguous set of layers spanned by the item.
std::shared_ptr< CN_ANCHOR > AddAnchor(const VECTOR2I &aPos)
void SetLayers(int aStartLayer, int aEndLayer)
Set the layers spanned by the item to aStartLayer and aEndLayer.
BOX2I m_bbox
bounding box for the item
virtual const VECTOR2I GetAnchor(int n) const
PCB_LAYER_ID GetBoardLayer() const
When using CN_ITEM layers to compare against board items, use this function which correctly remaps th...
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.
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.
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
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
PCB_LAYER_ID
A quick note on layer IDs:
PCB_LAYER_ID ToLAYER_ID(int aLayer)
VECTOR2< int32_t > VECTOR2I