KiCad PCB EDA Suite
PNS::SOLID Class Reference

#include <pns_solid.h>

Inheritance diagram for PNS::SOLID:
PNS::ITEM

Public Types

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

Supported item types

More...
 

Public Member Functions

 SOLID ()
 
 ~SOLID ()
 
 SOLID (const SOLID &aSolid)
 
ITEMClone () const override
 Function Clone() More...
 
const SHAPEShape () const override
 Function Shape() More...
 
const SHAPE_LINE_CHAIN Hull (int aClearance=0, int aWalkaroundThickness=0) const override
 
void SetShape (SHAPE *shape)
 
const VECTOR2IPos () const
 
void SetPos (const VECTOR2I &aCenter)
 
virtual VECTOR2I Anchor (int aN) const override
 
virtual int AnchorCount () const override
 
VECTOR2I Offset () const
 
void SetOffset (const VECTOR2I &aOffset)
 
PnsKind Kind () const
 Function Kind() More...
 
bool OfKind (int aKindMask) const
 Function OfKind() More...
 
const std::string KindStr () const
 Function KindStr() More...
 
void SetParent (BOARD_CONNECTED_ITEM *aParent)
 Function SetParent() More...
 
BOARD_CONNECTED_ITEMParent () const
 Function Parent() More...
 
void SetNet (int aNet)
 Function SetNet() More...
 
int Net () const
 Function Net() More...
 
void SetLayers (const LAYER_RANGE &aLayers)
 Function SetLayers() More...
 
void SetLayer (int aLayer)
 Function SetLayer() More...
 
const LAYER_RANGELayers () const
 Function Layers() More...
 
virtual int Layer () const
 Function Layer() More...
 
bool LayersOverlap (const ITEM *aOther) const
 Function LayersOverlap() More...
 
void SetOwner (NODE *aOwner)
 Functon SetOwner() More...
 
bool BelongsTo (NODE *aNode) const
 Function BelongsTo() More...
 
NODEOwner () const
 Function Owner() More...
 
virtual bool Collide (const ITEM *aOther, int aClearance, bool aNeedMTV, VECTOR2I &aMTV, bool aDifferentNetsOnly=true) const
 Function Collide() More...
 
bool Collide (const ITEM *aOther, int aClearance, bool aDifferentNetsOnly=true) const
 Function Collide() More...
 
virtual void Mark (int aMarker)
 
virtual void Unmark (int aMarker=-1)
 
virtual int Marker () const
 
virtual void SetRank (int aRank)
 
virtual int Rank () const
 
bool IsLocked () const
 

Static Public Member Functions

static bool ClassOf (const ITEM *aItem)
 

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
 

Private Attributes

VECTOR2I m_pos
 
SHAPEm_shape
 
VECTOR2I m_offset
 

Detailed Description

Definition at line 35 of file pns_solid.h.

Member Enumeration Documentation

enum PNS::ITEM::PnsKind
inherited

Supported item types

Enumerator
SOLID_T 
LINE_T 
JOINT_T 
SEGMENT_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  VIA_T = 16,
66  DIFF_PAIR_T = 32,
67  ANY_T = 0xff
68  };

Constructor & Destructor Documentation

PNS::SOLID::SOLID ( )
inline

Definition at line 38 of file pns_solid.h.

References PNS::ITEM::m_movable.

Referenced by Clone().

38  : ITEM( SOLID_T ), m_shape( NULL )
39  {
40  m_movable = false;
41  }
bool m_movable
Definition: pns_item.h:352
ITEM(PnsKind aKind)
Definition: pns_item.h:70
SHAPE * m_shape
Definition: pns_solid.h:106
PNS::SOLID::~SOLID ( )
inline

Definition at line 43 of file pns_solid.h.

References m_shape.

44  {
45  delete m_shape;
46  }
SHAPE * m_shape
Definition: pns_solid.h:106
PNS::SOLID::SOLID ( const SOLID aSolid)
inline

Definition at line 48 of file pns_solid.h.

References SHAPE::Clone(), m_pos, and m_shape.

48  :
49  ITEM( aSolid )
50  {
51  m_shape = aSolid.m_shape->Clone();
52  m_pos = aSolid.m_pos;
53  }
ITEM(PnsKind aKind)
Definition: pns_item.h:70
SHAPE * m_shape
Definition: pns_solid.h:106
virtual SHAPE * Clone() const
Function Clone()
Definition: shape.h:93
VECTOR2I m_pos
Definition: pns_solid.h:105

Member Function Documentation

virtual VECTOR2I PNS::SOLID::Anchor ( int  aN) const
inlineoverridevirtual

Reimplemented from PNS::ITEM.

Definition at line 84 of file pns_solid.h.

References m_pos.

85  {
86  return m_pos;
87  }
VECTOR2I m_pos
Definition: pns_solid.h:105
virtual int PNS::SOLID::AnchorCount ( ) const
inlineoverridevirtual

Reimplemented from PNS::ITEM.

Definition at line 89 of file pns_solid.h.

90  {
91  return 1;
92  }
bool PNS::ITEM::BelongsTo ( NODE aNode) const
inlineinherited

Function BelongsTo()

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

Definition at line 249 of file pns_item.h.

References PNS::ITEM::m_owner.

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

250  {
251  return m_owner == aNode;
252  }
NODE * m_owner
Definition: pns_item.h:349
static bool PNS::SOLID::ClassOf ( const ITEM aItem)
inlinestatic

Definition at line 55 of file pns_solid.h.

References PNS::ITEM::Kind(), and PNS::ITEM::SOLID_T.

56  {
57  return aItem && SOLID_T == aItem->Kind();
58  }
ITEM * PNS::SOLID::Clone ( ) const
overridevirtual

Function Clone()

Returns a deep copy of the item

Implements PNS::ITEM.

Definition at line 76 of file pns_solid.cpp.

References SOLID().

77 {
78  ITEM* solid = new SOLID( *this );
79  return solid;
80 }
ITEM(PnsKind aKind)
Definition: pns_item.h:70
bool PNS::ITEM::Collide ( const ITEM aOther,
int  aClearance,
bool  aNeedMTV,
VECTOR2I aMTV,
bool  aDifferentNetsOnly = true 
) const
virtualinherited

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 44 of file pns_item.cpp.

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

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

46 {
47  if( collideSimple( aOther, aClearance, aNeedMTV, aMTV, aDifferentNetsOnly ) )
48  return true;
49 
50  // special case for "head" line with a via attached at the end.
51  if( aOther->m_kind == LINE_T )
52  {
53  const LINE* line = static_cast<const LINE*>( aOther );
54 
55  if( line->EndsWithVia() )
56  return collideSimple( &line->Via(), aClearance - line->Width() / 2, aNeedMTV, aMTV, aDifferentNetsOnly );
57  }
58 
59  return false;
60 }
bool collideSimple(const ITEM *aOther, int aClearance, bool aNeedMTV, VECTOR2I &aMTV, bool aDifferentNetsOnly) const
Definition: pns_item.cpp:27
bool PNS::ITEM::Collide ( const ITEM aOther,
int  aClearance,
bool  aDifferentNetsOnly = true 
) const
inlineinherited

Function Collide()

A shortcut for ITEM::Colllide() without MTV stuff.

Definition at line 283 of file pns_item.h.

References PNS::ITEM::Collide(), and dummy().

284  {
285  VECTOR2I dummy;
286 
287  return Collide( aOther, aClearance, false, dummy, aDifferentNetsOnly );
288  }
virtual bool Collide(const ITEM *aOther, int aClearance, bool aNeedMTV, VECTOR2I &aMTV, bool aDifferentNetsOnly=true) const
Function Collide()
Definition: pns_item.cpp:44
static LIB_PART * dummy()
Used when a LIB_PART is not found in library to draw a dummy shape This component is a 400 mils squar...
const SHAPE_LINE_CHAIN PNS::SOLID::Hull ( int  aClearance = 0,
int  aWalkaroundThickness = 0 
) const
overridevirtual

Reimplemented from PNS::ITEM.

Definition at line 35 of file pns_solid.cpp.

References PNS::ConvexHull(), SHAPE_CIRCLE::GetCenter(), SHAPE_RECT::GetPosition(), SHAPE_CIRCLE::GetRadius(), SHAPE_RECT::GetSize(), m_shape, PNS::OctagonalHull(), PNS::SegmentHull(), SH_CIRCLE, SH_CONVEX, SH_RECT, SH_SEGMENT, and SHAPE::Type().

36 {
37  int cl = aClearance + ( aWalkaroundThickness + 1 )/ 2;
38 
39  switch( m_shape->Type() )
40  {
41  case SH_RECT:
42  {
43  SHAPE_RECT* rect = static_cast<SHAPE_RECT*>( m_shape );
44  return OctagonalHull( rect->GetPosition(), rect->GetSize(), cl + 1, 0.2 * cl );
45  }
46 
47  case SH_CIRCLE:
48  {
49  SHAPE_CIRCLE* circle = static_cast<SHAPE_CIRCLE*>( m_shape );
50  int r = circle->GetRadius();
51  return OctagonalHull( circle->GetCenter() - VECTOR2I( r, r ), VECTOR2I( 2 * r, 2 * r ),
52  cl + 1, 0.52 * ( r + cl ) );
53  }
54 
55  case SH_SEGMENT:
56  {
57  SHAPE_SEGMENT* seg = static_cast<SHAPE_SEGMENT*>( m_shape );
58  return SegmentHull( *seg, aClearance, aWalkaroundThickness );
59  }
60 
61  case SH_CONVEX:
62  {
63  SHAPE_CONVEX* convex = static_cast<SHAPE_CONVEX*>( m_shape );
64 
65  return ConvexHull( *convex, cl );
66  }
67 
68  default:
69  break;
70  }
71 
72  return SHAPE_LINE_CHAIN();
73 }
const VECTOR2I GetCenter() const
Definition: shape_circle.h:84
int GetRadius() const
Definition: shape_circle.h:79
Class SHAPE_CONVEX.
Definition: shape_convex.h:42
VECTOR2< int > VECTOR2I
Definition: vector2d.h:590
const SHAPE_LINE_CHAIN SegmentHull(const SHAPE_SEGMENT &aSeg, int aClearance, int aWalkaroundThickness)
Definition: pns_utils.cpp:53
SHAPE * m_shape
Definition: pns_solid.h:106
const VECTOR2I & GetPosition() const
Function GetPosition()
Definition: shape_rect.h:100
const SHAPE_LINE_CHAIN ConvexHull(const SHAPE_CONVEX &aConvex, int aClearance)
Function ConvexHull()
Definition: pns_utils.cpp:101
const SHAPE_LINE_CHAIN OctagonalHull(const VECTOR2I &aP0, const VECTOR2I &aSize, int aClearance, int aChamfer)
Various utility functions.
Definition: pns_utils.cpp:33
line chain (polyline)
Definition: shape.h:46
SHAPE_TYPE Type() const
Function Type()
Definition: shape.h:82
Class SHAPE_LINE_CHAIN.
Definition: shape.h:43
circle
Definition: shape.h:47
const VECTOR2I GetSize() const
Function GetSize()
Definition: shape_rect.h:110
axis-aligned rectangle
Definition: shape.h:44
bool PNS::ITEM::IsLocked ( ) const
inlineinherited

Definition at line 336 of file pns_item.h.

References PNS::ITEM::Marker(), and PNS::MK_LOCKED.

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

337  {
338  return Marker() & MK_LOCKED;
339  }
virtual int Marker() const
Definition: pns_item.h:311
const std::string PNS::ITEM::KindStr ( ) const
inherited

Function KindStr()

Returns the kind of the item, as string

Definition at line 63 of file pns_item.cpp.

References PNS::ITEM::JOINT_T, PNS::ITEM::LINE_T, PNS::ITEM::m_kind, PNS::ITEM::SEGMENT_T, PNS::ITEM::SOLID_T, and PNS::ITEM::VIA_T.

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

64 {
65  switch( m_kind )
66  {
67  case LINE_T:
68  return "line";
69 
70  case SEGMENT_T:
71  return "segment";
72 
73  case VIA_T:
74  return "via";
75 
76  case JOINT_T:
77  return "joint";
78 
79  case SOLID_T:
80  return "solid";
81 
82  default:
83  return "unknown";
84  }
85 }
PnsKind m_kind
Definition: pns_item.h:346
virtual int PNS::ITEM::Layer ( ) const
inlinevirtualinherited

Function Layer()

Returns the item's layer, for single-layered items only.

Reimplemented in PNS::SEGMENT.

Definition at line 217 of file pns_item.h.

References PNS::ITEM::Layers(), and LAYER_RANGE::Start().

Referenced by PNS::OPTIMIZER::fanoutCleanup(), and PNS::OPTIMIZER::runSmartPads().

218  {
219  return Layers().Start();
220  }
const LAYER_RANGE & Layers() const
Function Layers()
Definition: pns_item.h:207
int Start() const
Definition: pns_layerset.h:83
bool PNS::ITEM::LayersOverlap ( const ITEM aOther) const
inlineinherited

Function LayersOverlap()

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

Definition at line 228 of file pns_item.h.

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

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

229  {
230  return Layers().Overlaps( aOther->Layers() );
231  }
const LAYER_RANGE & Layers() const
Function Layers()
Definition: pns_item.h:207
bool Overlaps(const LAYER_RANGE &aOther) const
Definition: pns_layerset.h:68
virtual void PNS::ITEM::Mark ( int  aMarker)
inlinevirtualinherited

Reimplemented in PNS::LINE.

Definition at line 301 of file pns_item.h.

References PNS::ITEM::m_marker.

Referenced by PNS::SHOVE::ShoveDraggingVia().

302  {
303  m_marker = aMarker;
304  }
int m_marker
Definition: pns_item.h:354
virtual int PNS::ITEM::Marker ( ) const
inlinevirtualinherited

Reimplemented in PNS::LINE.

Definition at line 311 of file pns_item.h.

References PNS::ITEM::m_marker.

Referenced by PNS::ITEM::IsLocked(), PNS::LOGGER::Log(), PNS::SHOVE::pushVia(), and ROUTER_PREVIEW_ITEM::Update().

312  {
313  return m_marker;
314  }
int m_marker
Definition: pns_item.h:354
VECTOR2I PNS::SOLID::Offset ( ) const
inline

Definition at line 94 of file pns_solid.h.

References m_offset.

Referenced by PNS::OPTIMIZER::smartPadsSingle().

95  {
96  return m_offset;
97  }
VECTOR2I m_offset
Definition: pns_solid.h:107
NODE* PNS::ITEM::Owner ( ) const
inlineinherited

Function Owner()

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

Definition at line 259 of file pns_item.h.

References PNS::ITEM::m_owner.

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

259 { return m_owner; }
NODE * m_owner
Definition: pns_item.h:349
BOARD_CONNECTED_ITEM* PNS::ITEM::Parent ( ) const
inlineinherited

Function Parent()

Returns the corresponding parent object in the host application's model.

Definition at line 157 of file pns_item.h.

References PNS::ITEM::m_parent.

Referenced by PNS_PCBNEW_RULE_RESOLVER::DpNetPair(), PNS_KICAD_IFACE::HideItem(), PNS_PCBNEW_RULE_RESOLVER::localPadClearance(), ROUTER_TOOL::prepareInteractive(), and PNS_KICAD_IFACE::RemoveItem().

158  {
159  return m_parent;
160  }
BOARD_CONNECTED_ITEM * m_parent
Definition: pns_item.h:348
const VECTOR2I& PNS::SOLID::Pos ( ) const
inline

Definition at line 74 of file pns_solid.h.

References m_pos.

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

75  {
76  return m_pos;
77  }
VECTOR2I m_pos
Definition: pns_solid.h:105
virtual int PNS::ITEM::Rank ( ) const
inlinevirtualinherited

Reimplemented in PNS::LINE.

Definition at line 321 of file pns_item.h.

References PNS::ITEM::m_rank.

Referenced by PNS::LOGGER::Log(), PNS::SHOVE::onCollidingVia(), and PNS::SHOVE::shoveIteration().

322  {
323  return m_rank;
324  }
int m_rank
Definition: pns_item.h:355
void PNS::ITEM::SetLayer ( int  aLayer)
inlineinherited

Function SetLayer()

Sets the layers spanned by the item to a single layer aLayer.

Definition at line 197 of file pns_item.h.

References PNS::ITEM::m_layers.

Referenced by PNS::LINE_PLACER::initPlacement(), PNS::DIFF_PAIR_PLACER::propagateDpHeadForces(), PNS::DIFF_PAIR_PLACER::routeHead(), and PNS::DIFF_PAIR::updateLine().

198  {
199  m_layers = LAYER_RANGE( aLayer, aLayer );
200  }
LAYER_RANGE m_layers
Definition: pns_item.h:350
Class LAYER_RANGE.
Definition: pns_layerset.h:32
void PNS::ITEM::SetLayers ( const LAYER_RANGE aLayers)
inlineinherited

Function SetLayers()

Sets the layers spanned by the item to aLayers.

Definition at line 187 of file pns_item.h.

References PNS::ITEM::m_layers.

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

188  {
189  m_layers = aLayers;
190  }
LAYER_RANGE m_layers
Definition: pns_item.h:350
void PNS::ITEM::SetNet ( int  aNet)
inlineinherited
void PNS::SOLID::SetOffset ( const VECTOR2I aOffset)
inline

Definition at line 99 of file pns_solid.h.

References m_offset.

100  {
101  m_offset = aOffset;
102  }
VECTOR2I m_offset
Definition: pns_solid.h:107
void PNS::ITEM::SetOwner ( NODE aOwner)
inlineinherited

Functon SetOwner()

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

Definition at line 239 of file pns_item.h.

References PNS::ITEM::m_owner.

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

240  {
241  m_owner = aOwner;
242  }
NODE * m_owner
Definition: pns_item.h:349
void PNS::ITEM::SetParent ( BOARD_CONNECTED_ITEM aParent)
inlineinherited

Function SetParent()

Sets the corresponding parent object in the host application's model.

Definition at line 147 of file pns_item.h.

References PNS::ITEM::m_parent.

Referenced by PNS_KICAD_IFACE::AddItem().

148  {
149  m_parent = aParent;
150  }
BOARD_CONNECTED_ITEM * m_parent
Definition: pns_item.h:348
void PNS::SOLID::SetPos ( const VECTOR2I aCenter)
inline

Definition at line 79 of file pns_solid.h.

References m_pos.

80  {
81  m_pos = aCenter;
82  }
VECTOR2I m_pos
Definition: pns_solid.h:105
virtual void PNS::ITEM::SetRank ( int  aRank)
inlinevirtualinherited

Reimplemented in PNS::LINE.

Definition at line 316 of file pns_item.h.

References PNS::ITEM::m_rank.

317  {
318  m_rank = aRank;
319  }
int m_rank
Definition: pns_item.h:355
void PNS::SOLID::SetShape ( SHAPE shape)
inline

Definition at line 66 of file pns_solid.h.

References m_shape.

67  {
68  if( m_shape )
69  delete m_shape;
70 
71  m_shape = shape;
72  }
SHAPE * m_shape
Definition: pns_solid.h:106
const SHAPE* PNS::SOLID::Shape ( ) const
inlineoverridevirtual

Function Shape()

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

Reimplemented from PNS::ITEM.

Definition at line 62 of file pns_solid.h.

References m_shape.

Referenced by PNS::LOGGER::Log().

62 { return m_shape; }
SHAPE * m_shape
Definition: pns_solid.h:106
virtual void PNS::ITEM::Unmark ( int  aMarker = -1)
inlinevirtualinherited

Reimplemented in PNS::LINE.

Definition at line 306 of file pns_item.h.

References PNS::ITEM::m_marker.

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

307  {
308  m_marker &= ~aMarker;
309  }
int m_marker
Definition: pns_item.h:354

Member Data Documentation

PnsKind PNS::ITEM::m_kind
protectedinherited
bool PNS::ITEM::m_movable
protectedinherited

Definition at line 352 of file pns_item.h.

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

VECTOR2I PNS::SOLID::m_offset
private

Definition at line 107 of file pns_solid.h.

Referenced by Offset(), and SetOffset().

NODE* PNS::ITEM::m_owner
protectedinherited
BOARD_CONNECTED_ITEM* PNS::ITEM::m_parent
protectedinherited

Definition at line 348 of file pns_item.h.

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

VECTOR2I PNS::SOLID::m_pos
private

Definition at line 105 of file pns_solid.h.

Referenced by Anchor(), Pos(), SetPos(), and SOLID().

SHAPE* PNS::SOLID::m_shape
private

Definition at line 106 of file pns_solid.h.

Referenced by Hull(), SetShape(), Shape(), SOLID(), and ~SOLID().

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

Definition at line 56 of file pns_item.h.

Referenced by PNS::ITEM::ITEM().


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