KiCad PCB EDA Suite
PNS::ITEM Class Referenceabstract

ITEM. More...

#include <pns_item.h>

Inheritance diagram for PNS::ITEM:
PNS::JOINT PNS::LINK_HOLDER PNS::LINKED_ITEM PNS::SOLID PNS::VIA PNS::DIFF_PAIR PNS::LINE PNS::ARC PNS::SEGMENT

Public Types

enum  PnsKind {
  SOLID_T = 1, LINE_T = 2, JOINT_T = 4, SEGMENT_T = 8,
  ARC_T = 16, VIA_T = 32, DIFF_PAIR_T = 64, ANY_T = 0xff
}
 

Supported item types

More...
 

Public Member Functions

 ITEM (PnsKind aKind)
 
 ITEM (const ITEM &aOther)
 
virtual ~ITEM ()
 
virtual ITEMClone () const =0
 Function Clone() More...
 
virtual const SHAPE_LINE_CHAIN Hull (int aClearance=0, int aWalkaroundThickness=0, int aLayer=-1) const
 
PnsKind Kind () const
 Function Kind() More...
 
bool OfKind (int aKindMask) const
 Function OfKind() More...
 
std::string KindStr () const
 Function KindStr() More...
 
void SetParent (BOARD_CONNECTED_ITEM *aParent)
 
BOARD_CONNECTED_ITEMParent () const
 
void SetNet (int aNet)
 
int Net () const
 
const LAYER_RANGELayers () const
 
void SetLayers (const LAYER_RANGE &aLayers)
 
void SetLayer (int aLayer)
 
virtual int Layer () const
 
bool LayersOverlap (const ITEM *aOther) const
 Function LayersOverlap() More...
 
NODEOwner () const
 Function Owner() More...
 
void SetOwner (NODE *aOwner)
 Functon SetOwner() More...
 
bool BelongsTo (NODE *aNode) const
 Function BelongsTo() More...
 
virtual bool Collide (const ITEM *aOther, int aClearance, bool aNeedMTV, VECTOR2I *aMTV, const NODE *aParentNode, bool aDifferentNetsOnly=true) const
 Function Collide() More...
 
virtual const SHAPEShape () const
 Function Shape() More...
 
virtual const SHAPEAlternateShape () const
 
virtual void Mark (int aMarker)
 
virtual void Unmark (int aMarker=-1)
 
virtual int Marker () const
 
virtual void SetRank (int aRank)
 
virtual int Rank () const
 
virtual VECTOR2I Anchor (int n) const
 
virtual int AnchorCount () const
 
bool IsLocked () const
 
void SetRoutable (bool aRoutable)
 
bool IsRoutable () const
 

Static Public Attributes

static const int UnusedNet = INT_MAX
 

Protected Attributes

PnsKind m_kind
 
BOARD_CONNECTED_ITEMm_parent
 
NODEm_owner
 
LAYER_RANGE m_layers
 
bool m_movable
 
int m_net
 
int m_marker
 
int m_rank
 
bool m_routable
 

Private Member Functions

bool collideSimple (const ITEM *aOther, int aClearance, bool aNeedMTV, VECTOR2I *aMTV, const NODE *aParentNode, bool aDifferentNetsOnly) const
 

Detailed Description

ITEM.

Base class for PNS router board items. Implements the shared properties of all PCB items - net, spanned layers, geometric shape & refererence to owning model.

Definition at line 53 of file pns_item.h.

Member Enumeration Documentation

◆ PnsKind

Supported item types

Enumerator
SOLID_T 
LINE_T 
JOINT_T 
SEGMENT_T 
ARC_T 
VIA_T 
DIFF_PAIR_T 
ANY_T 

Definition at line 59 of file pns_item.h.

60  {
61  SOLID_T = 1,
62  LINE_T = 2,
63  JOINT_T = 4,
64  SEGMENT_T = 8,
65  ARC_T = 16,
66  VIA_T = 32,
67  DIFF_PAIR_T = 64,
68  ANY_T = 0xff
69  };

Constructor & Destructor Documentation

◆ ITEM() [1/2]

PNS::ITEM::ITEM ( PnsKind  aKind)
inline

Definition at line 71 of file pns_item.h.

72  {
73  m_net = UnusedNet;
74  m_movable = true;
75  m_kind = aKind;
76  m_parent = NULL;
77  m_owner = NULL;
78  m_marker = 0;
79  m_rank = -1;
80  m_routable = true;
81  }
BOARD_CONNECTED_ITEM * m_parent
Definition: pns_item.h:256
NODE * m_owner
Definition: pns_item.h:257
int m_rank
Definition: pns_item.h:263
bool m_movable
Definition: pns_item.h:260
bool m_routable
Definition: pns_item.h:264
static const int UnusedNet
Definition: pns_item.h:56
int m_marker
Definition: pns_item.h:262
#define NULL
int m_net
Definition: pns_item.h:261
PnsKind m_kind
Definition: pns_item.h:254

References m_kind, m_marker, m_movable, m_net, m_owner, m_parent, m_rank, m_routable, NULL, and UnusedNet.

◆ ITEM() [2/2]

PNS::ITEM::ITEM ( const ITEM aOther)
inline

Definition at line 83 of file pns_item.h.

84  {
85  m_layers = aOther.m_layers;
86  m_net = aOther.m_net;
87  m_movable = aOther.m_movable;
88  m_kind = aOther.m_kind;
89  m_parent = aOther.m_parent;
90  m_owner = aOther.m_owner; // fixme: wtf this was null?
91  m_marker = aOther.m_marker;
92  m_rank = aOther.m_rank;
93  m_routable = aOther.m_routable;
94  }
BOARD_CONNECTED_ITEM * m_parent
Definition: pns_item.h:256
NODE * m_owner
Definition: pns_item.h:257
LAYER_RANGE m_layers
Definition: pns_item.h:258
int m_rank
Definition: pns_item.h:263
bool m_movable
Definition: pns_item.h:260
bool m_routable
Definition: pns_item.h:264
int m_marker
Definition: pns_item.h:262
int m_net
Definition: pns_item.h:261
PnsKind m_kind
Definition: pns_item.h:254

References m_kind, m_layers, m_marker, m_movable, m_net, m_owner, m_parent, m_rank, and m_routable.

◆ ~ITEM()

PNS::ITEM::~ITEM ( )
virtual

Definition at line 113 of file pns_item.cpp.

114 {
115 }

Member Function Documentation

◆ AlternateShape()

virtual const SHAPE* PNS::ITEM::AlternateShape ( ) const
inlinevirtual

Reimplemented in PNS::VIA, and PNS::SOLID.

Definition at line 219 of file pns_item.h.

220  {
221  return Shape();
222  }
virtual const SHAPE * Shape() const
Function Shape()
Definition: pns_item.h:214

References Shape().

Referenced by PNS::INDEX::Add(), and collideSimple().

◆ Anchor()

◆ AnchorCount()

virtual int PNS::ITEM::AnchorCount ( ) const
inlinevirtual

Reimplemented in PNS::VIA, PNS::SOLID, PNS::SEGMENT, and PNS::ARC.

Definition at line 236 of file pns_item.h.

237  {
238  return 0;
239  }

◆ BelongsTo()

bool PNS::ITEM::BelongsTo ( NODE aNode) const
inline

Function BelongsTo()

Returns
true if the item is owned by the node aNode.

Definition at line 187 of file pns_item.h.

188  {
189  return m_owner == aNode;
190  }
NODE * m_owner
Definition: pns_item.h:257

References m_owner.

Referenced by PNS::NODE::doRemove().

◆ Clone()

virtual ITEM* PNS::ITEM::Clone ( ) const
pure virtual

◆ Collide()

bool PNS::ITEM::Collide ( const ITEM aOther,
int  aClearance,
bool  aNeedMTV,
VECTOR2I aMTV,
const NODE aParentNode,
bool  aDifferentNetsOnly = true 
) const
virtual

Function Collide()

Checks for a collision (clearance violation) with between us and item aOther. Collision checking takes all PCB stuff into accound (layers, nets, DRC rules). Optionally returns a minimum translation vector for force propagation algorithm.

Parameters
aOtheritem to check collision against
aClearancedesired clearance
aNeedMTVwhen true, the minimum translation vector is calculated
aMTVthe minimum translation vector
Returns
true, if a collision was found.

Definition at line 74 of file pns_item.cpp.

76 {
77  if( collideSimple( aOther, aClearance, aNeedMTV, aMTV, aParentNode, aDifferentNetsOnly ) )
78  return true;
79 
80  // special case for "head" line with a via attached at the end.
81  if( aOther->m_kind == LINE_T )
82  {
83  const LINE* line = static_cast<const LINE*>( aOther );
84  int clearance = aClearance - line->Width() / 2;
85 
86  if( line->EndsWithVia() )
87  {
88  return collideSimple( &line->Via(), clearance, aNeedMTV, aMTV, aParentNode,
89  aDifferentNetsOnly );
90  }
91  }
92 
93  return false;
94 }
bool collideSimple(const ITEM *aOther, int aClearance, bool aNeedMTV, VECTOR2I *aMTV, const NODE *aParentNode, bool aDifferentNetsOnly) const
Definition: pns_item.cpp:31

References collideSimple(), PNS::LINE::EndsWithVia(), LINE_T, m_kind, PNS::LINE::Via(), and PNS::LINE::Width().

Referenced by PNS::NODE::CheckColliding(), PNS::OPTIMIZER::CACHE_VISITOR::operator()(), and PNS::NODE::DEFAULT_OBSTACLE_VISITOR::operator()().

◆ collideSimple()

bool PNS::ITEM::collideSimple ( const ITEM aOther,
int  aClearance,
bool  aNeedMTV,
VECTOR2I aMTV,
const NODE aParentNode,
bool  aDifferentNetsOnly 
) const
private

Definition at line 31 of file pns_item.cpp.

33 {
34  const SHAPE* shapeA = Shape();
35  const SHAPE* shapeB = aOther->Shape();
36 
37  // same nets? no collision!
38  if( aDifferentNetsOnly && m_net == aOther->m_net && m_net >= 0 && aOther->m_net >= 0 )
39  return false;
40 
41  // check if we are not on completely different layers first
42  if( !m_layers.Overlaps( aOther->m_layers ) )
43  return false;
44 
45  if( !aOther->Layers().IsMultilayer()
46  && !ROUTER::GetInstance()->GetInterface()->IsOnLayer( this, aOther->Layer() ) )
47  {
48  if( !AlternateShape() )
49  wxLogError
50  ( "Missing expected Alternate shape for %s at %d %d", m_parent->GetClass(),
51  Anchor( 0 ).x, Anchor( 0 ).y );
52  else
53  shapeA = AlternateShape();
54  }
55 
56  if( !Layers().IsMultilayer()
57  && !ROUTER::GetInstance()->GetInterface()->IsOnLayer( aOther, Layer() ) )
58  {
59  if( !aOther->AlternateShape() )
60  wxLogError
61  ( "Missing expected Alternate shape for %s at %d %d", aOther->Parent()->GetClass(),
62  aOther->Anchor( 0 ).x, aOther->Anchor( 0 ).y );
63  else
64  shapeB = aOther->AlternateShape();
65  }
66 
67  if( aNeedMTV )
68  return shapeA->Collide( shapeB, aClearance, aMTV );
69  else
70  return shapeA->Collide( shapeB, aClearance );
71 }
virtual int Layer() const
Definition: pns_item.h:155
BOARD_CONNECTED_ITEM * m_parent
Definition: pns_item.h:256
bool Overlaps(const LAYER_RANGE &aOther) const
Definition: pns_layerset.h:68
LAYER_RANGE m_layers
Definition: pns_item.h:258
virtual const SHAPE * AlternateShape() const
Definition: pns_item.h:219
virtual const SHAPE * Shape() const
Function Shape()
Definition: pns_item.h:214
SHAPE.
Definition: shape.h:120
int m_net
Definition: pns_item.h:261
virtual VECTOR2I Anchor(int n) const
Definition: pns_item.h:231
virtual wxString GetClass() const =0
Function GetClass returns the class name.
virtual bool IsOnLayer(const PNS::ITEM *aItem, int aLayer)=0
virtual bool Collide(const VECTOR2I &aP, int aClearance=0, int *aActual=nullptr) const
Function Collide()
Definition: shape.h:172
ROUTER_IFACE * GetInterface() const
Definition: pns_router.h:234
static ROUTER * GetInstance()
Definition: pns_router.cpp:85
const LAYER_RANGE & Layers() const
Definition: pns_item.h:151

References AlternateShape(), Anchor(), SHAPE::Collide(), EDA_ITEM::GetClass(), PNS::ROUTER::GetInstance(), PNS::ROUTER::GetInterface(), LAYER_RANGE::IsMultilayer(), PNS::ROUTER_IFACE::IsOnLayer(), Layer(), Layers(), m_layers, m_net, m_parent, LAYER_RANGE::Overlaps(), Parent(), Shape(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by Collide().

◆ Hull()

virtual const SHAPE_LINE_CHAIN PNS::ITEM::Hull ( int  aClearance = 0,
int  aWalkaroundThickness = 0,
int  aLayer = -1 
) const
inlinevirtual

Reimplemented in PNS::VIA, PNS::SEGMENT, PNS::ARC, and PNS::SOLID.

Definition at line 113 of file pns_item.h.

114  {
115  return SHAPE_LINE_CHAIN();
116  }
SHAPE_LINE_CHAIN.

◆ IsLocked()

bool PNS::ITEM::IsLocked ( ) const
inline

Definition at line 241 of file pns_item.h.

242  {
243  return Marker() & MK_LOCKED;
244  }
virtual int Marker() const
Definition: pns_item.h:226

References Marker(), and PNS::MK_LOCKED.

Referenced by ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), ROUTER_TOOL::performDragging(), and PNS::SHOVE::pushOrShoveVia().

◆ IsRoutable()

bool PNS::ITEM::IsRoutable ( ) const
inline

Definition at line 247 of file pns_item.h.

247 { return m_routable; }
bool m_routable
Definition: pns_item.h:264

References m_routable.

Referenced by PNS::NODE::addSolid(), and PNS::NODE::removeSolidIndex().

◆ Kind()

◆ KindStr()

std::string PNS::ITEM::KindStr ( ) const

Function KindStr()

Returns the kind of the item, as string

Definition at line 97 of file pns_item.cpp.

98 {
99  switch( m_kind )
100  {
101  case ARC_T: return "arc";
102  case LINE_T: return "line";
103  case SEGMENT_T: return "segment";
104  case VIA_T: return "via";
105  case JOINT_T: return "joint";
106  case SOLID_T: return "solid";
107  case DIFF_PAIR_T: return "diff-pair";
108  default: return "unknown";
109  }
110 }
PnsKind m_kind
Definition: pns_item.h:254

References ARC_T, DIFF_PAIR_T, JOINT_T, LINE_T, m_kind, SEGMENT_T, SOLID_T, and VIA_T.

Referenced by PNS::TOOL_BASE::pickSingleItem(), and PNS::TOOL_BASE::updateEndItem().

◆ Layer()

virtual int PNS::ITEM::Layer ( ) const
inlinevirtual

◆ Layers()

◆ LayersOverlap()

bool PNS::ITEM::LayersOverlap ( const ITEM aOther) const
inline

Function LayersOverlap()

Returns true if the set of layers spanned by aOther overlaps our layers.

Definition at line 163 of file pns_item.h.

164  {
165  return Layers().Overlaps( aOther->Layers() );
166  }
bool Overlaps(const LAYER_RANGE &aOther) const
Definition: pns_layerset.h:68
const LAYER_RANGE & Layers() const
Definition: pns_item.h:151

References Layers(), and LAYER_RANGE::Overlaps().

Referenced by PNS::SHOVE::onCollidingArc(), PNS::SHOVE::onCollidingSegment(), PNS::SHOVE::ProcessSingleLine(), and PNS::NODE::rebuildJoint().

◆ Mark()

virtual void PNS::ITEM::Mark ( int  aMarker)
inlinevirtual

Reimplemented in PNS::LINE.

Definition at line 224 of file pns_item.h.

224 { m_marker = aMarker; }
int m_marker
Definition: pns_item.h:262

References m_marker.

◆ Marker()

virtual int PNS::ITEM::Marker ( ) const
inlinevirtual

Reimplemented in PNS::LINE.

Definition at line 226 of file pns_item.h.

226 { return m_marker; }
int m_marker
Definition: pns_item.h:262

References m_marker.

Referenced by PNS::ARC::ARC(), IsLocked(), PNS::SHOVE::pushOrShoveVia(), and ROUTER_PREVIEW_ITEM::Update().

◆ Net()

◆ OfKind()

◆ Owner()

NODE* PNS::ITEM::Owner ( ) const
inline

Function Owner()

Returns the owner of this item, or NULL if there's none.

Definition at line 173 of file pns_item.h.

173 { return m_owner; }
NODE * m_owner
Definition: pns_item.h:257

References m_owner.

Referenced by PNS::SIZES_SETTINGS::inheritTrackWidth(), and PNS::LINE_PLACER::Move().

◆ Parent()

◆ Rank()

virtual int PNS::ITEM::Rank ( ) const
inlinevirtual

Reimplemented in PNS::LINE.

Definition at line 229 of file pns_item.h.

229 { return m_rank; }
int m_rank
Definition: pns_item.h:263

References m_rank.

Referenced by PNS::ARC::ARC(), PNS::LINE::LINE(), PNS::SHOVE::onCollidingVia(), and PNS::SHOVE::shoveIteration().

◆ SetLayer()

◆ SetLayers()

void PNS::ITEM::SetLayers ( const LAYER_RANGE aLayers)
inline

Definition at line 152 of file pns_item.h.

152 { m_layers = aLayers; }
LAYER_RANGE m_layers
Definition: pns_item.h:258

References m_layers.

Referenced by PNS::TOPOLOGY::AssembleDiffPair(), PNS::NODE::AssembleLine(), PNS::VIA::Clone(), and PNS::VIA::VIA().

◆ SetNet()

◆ SetOwner()

void PNS::ITEM::SetOwner ( NODE aOwner)
inline

Functon SetOwner()

Sets the node that owns this item. An item can belong to a single NODE or be unowned.

Definition at line 180 of file pns_item.h.

180 { m_owner = aOwner; }
NODE * m_owner
Definition: pns_item.h:257

References m_owner.

Referenced by PNS::NODE::AssembleLine(), PNS::NODE::doRemove(), and PNS::NODE::Remove().

◆ SetParent()

void PNS::ITEM::SetParent ( BOARD_CONNECTED_ITEM aParent)
inline

Definition at line 145 of file pns_item.h.

145 { m_parent = aParent; }
BOARD_CONNECTED_ITEM * m_parent
Definition: pns_item.h:256

References m_parent.

Referenced by PNS_KICAD_IFACE::AddItem().

◆ SetRank()

virtual void PNS::ITEM::SetRank ( int  aRank)
inlinevirtual

Reimplemented in PNS::LINE.

Definition at line 228 of file pns_item.h.

228 { m_rank = aRank; }
int m_rank
Definition: pns_item.h:263

References m_rank.

◆ SetRoutable()

void PNS::ITEM::SetRoutable ( bool  aRoutable)
inline

Definition at line 246 of file pns_item.h.

246 { m_routable = aRoutable; }
bool m_routable
Definition: pns_item.h:264

References m_routable.

◆ Shape()

virtual const SHAPE* PNS::ITEM::Shape ( ) const
inlinevirtual

Function Shape()

Returns the geometrical shape of the item. Used for collision detection & spatial indexing.

Reimplemented in PNS::VIA, PNS::LINE, PNS::ARC, PNS::SOLID, and PNS::SEGMENT.

Definition at line 214 of file pns_item.h.

215  {
216  return NULL;
217  }
#define NULL

References NULL.

Referenced by AlternateShape(), PNS::DP_GATEWAYS::BuildFromPrimitivePair(), PNS_PCBNEW_RULE_RESOLVER::CollideHoles(), collideSimple(), PNS::OPTIMIZER::computeBreakouts(), PNS::OPTIMIZER::customBreakouts(), PNS::SHOVE::onCollidingVia(), PNS::HIT_VISITOR::operator()(), PNS::INDEX::Query(), and ROUTER_PREVIEW_ITEM::Update().

◆ Unmark()

virtual void PNS::ITEM::Unmark ( int  aMarker = -1)
inlinevirtual

Reimplemented in PNS::LINE.

Definition at line 225 of file pns_item.h.

225 { m_marker &= ~aMarker; }
int m_marker
Definition: pns_item.h:262

References m_marker.

Referenced by PNS::DRAGGER::Start().

Member Data Documentation

◆ m_kind

PnsKind PNS::ITEM::m_kind
protected

Definition at line 254 of file pns_item.h.

Referenced by Collide(), ITEM(), Kind(), KindStr(), and OfKind().

◆ m_layers

◆ m_marker

◆ m_movable

bool PNS::ITEM::m_movable
protected

Definition at line 260 of file pns_item.h.

Referenced by ITEM(), PNS::LINE::LINE(), PNS::LINE::operator=(), and PNS::SOLID::SOLID().

◆ m_net

◆ m_owner

NODE* PNS::ITEM::m_owner
protected

Definition at line 257 of file pns_item.h.

Referenced by BelongsTo(), ITEM(), PNS::LINE::operator=(), Owner(), and SetOwner().

◆ m_parent

BOARD_CONNECTED_ITEM* PNS::ITEM::m_parent
protected

Definition at line 256 of file pns_item.h.

Referenced by PNS::VIA::Clone(), collideSimple(), ITEM(), Parent(), and SetParent().

◆ m_rank

◆ m_routable

bool PNS::ITEM::m_routable
protected

Definition at line 264 of file pns_item.h.

Referenced by IsRoutable(), ITEM(), and SetRoutable().

◆ UnusedNet

const int PNS::ITEM::UnusedNet = INT_MAX
static

Definition at line 56 of file pns_item.h.

Referenced by ITEM().


The documentation for this class was generated from the following files: