KiCad PCB EDA Suite
PNS::LINE Class Reference

#include <pns_line.h>

Inheritance diagram for PNS::LINE:
PNS::ITEM

Public Types

typedef std::vector< SEGMENT * > SEGMENT_REFS
 
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

 LINE ()
 Constructor Makes an empty line. More...
 
 LINE (const LINE &aOther)
 
 LINE (const LINE &aBase, const SHAPE_LINE_CHAIN &aLine)
 Constructor Copies properties (net, layers, etc.) from a base line and replaces the shape by another. More...
 
 ~LINE ()
 
virtual LINEClone () const override
 Function Clone() More...
 
LINEoperator= (const LINE &aOther)
 
void SetShape (const SHAPE_LINE_CHAIN &aLine)
 

Assigns a shape to the line (a polyline/line chain)

More...
 
const SHAPEShape () const override
 

Returns the shape of the line

More...
 
SHAPE_LINE_CHAINLine ()
 

Modifiable accessor to the underlying shape

More...
 
const SHAPE_LINE_CHAINCLine () const
 

Const accessor to the underlying shape

More...
 
int SegmentCount () const
 

Returns the number of segments in the line

More...
 
int PointCount () const
 

Returns the number of points in the line

More...
 
const VECTOR2ICPoint (int aIdx) const
 

Returns the aIdx-th point of the line

More...
 
const SEG CSegment (int aIdx) const
 

Returns the aIdx-th segment of the line

More...
 
void SetWidth (int aWidth)
 

Sets line width

More...
 
int Width () const
 

Returns line width

More...
 
bool CompareGeometry (const LINE &aOther)
 

Returns true if the line is geometrically identical as line aOther

More...
 
void Reverse ()
 

Reverses the point/vertex order

More...
 
void LinkSegment (SEGMENT *aSeg)
 

Adds a reference to a segment registered in a NODE that is a part of this line.

More...
 
SEGMENT_REFSLinkedSegments ()
 

Returns the list of segments from the owning node that constitute this line (or NULL if the line is not linked)

More...
 
bool IsLinked () const
 
bool IsLinkedChecked () const
 
bool ContainsSegment (SEGMENT *aSeg) const
 

Checks if the segment aSeg is a part of the line.

More...
 
SEGMENTGetLink (int aIndex) const
 
void ClearSegmentLinks ()
 

Erases the linking information. Used to detach the line from the owning node.

More...
 
int LinkCount () const
 

Returns the number of segments that were assembled together to form this line.

More...
 
const LINE ClipToNearestObstacle (NODE *aNode) const
 

Clips the line to the nearest obstacle, traversing from the line's start vertex (0).

More...
 
void ClipVertexRange (int aStart, int aEnd)
 

Clips the line to a given range of vertices.

More...
 
int CountCorners (int aAngles) const
 

Returns the number of corners of angles specified by mask aAngles.

More...
 
bool Walkaround (SHAPE_LINE_CHAIN aObstacle, SHAPE_LINE_CHAIN &aPre, SHAPE_LINE_CHAIN &aWalk, SHAPE_LINE_CHAIN &aPost, bool aCw) const
 

Calculates a line thightly wrapping a convex hull of an obstacle object (aObstacle).

More...
 
bool Walkaround (const SHAPE_LINE_CHAIN &aObstacle, SHAPE_LINE_CHAIN &aPath, bool aCw) const
 
bool Is45Degree () const
 
void ShowLinks () const
 

Prints out all linked segments

More...
 
bool EndsWithVia () const
 
void AppendVia (const VIA &aVia)
 
void RemoveVia ()
 
const VIAVia () const
 
virtual void Mark (int aMarker) override
 
virtual void Unmark (int aMarker=-1) override
 
virtual int Marker () const override
 
void DragSegment (const VECTOR2I &aP, int aIndex, int aSnappingThreshold=0, bool aFreeAngle=false)
 
void DragCorner (const VECTOR2I &aP, int aIndex, int aSnappingThreshold=0, bool aFreeAngle=false)
 
void SetRank (int aRank) override
 
int Rank () const override
 
bool HasLoops () const
 
bool HasLockedSegments () const
 
OPT_BOX2I ChangedArea (const LINE *aOther) const
 
virtual const SHAPE_LINE_CHAIN Hull (int aClearance=0, int aWalkaroundThickness=0) const
 
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...
 
bool InAnyNet () const
 
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 VECTOR2I Anchor (int n) const
 
virtual int AnchorCount () const
 
bool IsLocked () const
 
void SetRoutable (bool aRoutable)
 
bool IsRoutable () 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
 
bool m_routable
 

Private Member Functions

void dragSegment45 (const VECTOR2I &aP, int aIndex, int aSnappingThreshold)
 
void dragCorner45 (const VECTOR2I &aP, int aIndex, int aSnappingThreshold)
 
void dragSegmentFree (const VECTOR2I &aP, int aIndex, int aSnappingThreshold)
 
void dragCornerFree (const VECTOR2I &aP, int aIndex, int aSnappingThreshold)
 
VECTOR2I snapToNeighbourSegments (const SHAPE_LINE_CHAIN &aPath, const VECTOR2I &aP, int aIndex, int aThreshold) const
 
VECTOR2I snapDraggedCorner (const SHAPE_LINE_CHAIN &aPath, const VECTOR2I &aP, int aIndex, int aThreshold) const
 
void copyLinks (const LINE *aParent)
 

Copies m_segmentRefs from the line aParent.

More...
 

Private Attributes

SEGMENT_REFS m_segmentRefs
 

List of segments in the owning NODE (ITEM::m_owner) that constitute this line, or NULL if the line is not a part of any node.

More...
 
SHAPE_LINE_CHAIN m_line
 

The actual shape of the line

More...
 
int m_width
 

our width

More...
 
bool m_hasVia
 

If true, the line ends with a via

More...
 
VIA m_via
 

Via at the end point, if m_hasVia == true

More...
 

Detailed Description

Definition at line 60 of file pns_line.h.

Member Typedef Documentation

◆ SEGMENT_REFS

typedef std::vector<SEGMENT*> PNS::LINE::SEGMENT_REFS

Definition at line 63 of file pns_line.h.

Member Enumeration Documentation

◆ PnsKind

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

◆ LINE() [1/3]

PNS::LINE::LINE ( )
inline

Constructor Makes an empty line.

Definition at line 69 of file pns_line.h.

69  : ITEM( LINE_T )
70  {
71  m_hasVia = false;
72  m_width = 1; // Dummy value
73  }
ITEM(PnsKind aKind)
Definition: pns_item.h:70
bool m_hasVia
If true, the line ends with a via
Definition: pns_line.h:297
int m_width
our width
Definition: pns_line.h:294

References m_hasVia, and m_width.

Referenced by Clone().

◆ LINE() [2/3]

PNS::LINE::LINE ( const LINE aOther)

Definition at line 36 of file pns_line.cpp.

36  :
37  ITEM( aOther ),
38  m_line( aOther.m_line ),
39  m_width( aOther.m_width )
40 {
41  m_net = aOther.m_net;
42  m_movable = aOther.m_movable;
43  m_layers = aOther.m_layers;
44  m_via = aOther.m_via;
45  m_hasVia = aOther.m_hasVia;
46  m_marker = aOther.m_marker;
47  m_rank = aOther.m_rank;
48 
49  copyLinks( &aOther );
50 }
VIA m_via
Via at the end point, if m_hasVia == true
Definition: pns_line.h:300
LAYER_RANGE m_layers
Definition: pns_item.h:367
int m_rank
Definition: pns_item.h:372
bool m_movable
Definition: pns_item.h:369
ITEM(PnsKind aKind)
Definition: pns_item.h:70
int m_marker
Definition: pns_item.h:371
SHAPE_LINE_CHAIN m_line
The actual shape of the line
Definition: pns_line.h:291
void copyLinks(const LINE *aParent)
Copies m_segmentRefs from the line aParent.
Definition: pns_line.cpp:116
bool m_hasVia
If true, the line ends with a via
Definition: pns_line.h:297
int m_net
Definition: pns_item.h:370
int m_width
our width
Definition: pns_line.h:294

References copyLinks(), m_hasVia, PNS::ITEM::m_layers, PNS::ITEM::m_marker, PNS::ITEM::m_movable, PNS::ITEM::m_net, PNS::ITEM::m_rank, and m_via.

◆ LINE() [3/3]

PNS::LINE::LINE ( const LINE aBase,
const SHAPE_LINE_CHAIN aLine 
)
inline

Constructor Copies properties (net, layers, etc.) from a base line and replaces the shape by another.

Definition at line 82 of file pns_line.h.

82  :
83  ITEM( aBase ),
84  m_line( aLine ),
85  m_width( aBase.m_width )
86  {
87  m_net = aBase.m_net;
88  m_layers = aBase.m_layers;
89  m_hasVia = false;
90  }
LAYER_RANGE m_layers
Definition: pns_item.h:367
ITEM(PnsKind aKind)
Definition: pns_item.h:70
SHAPE_LINE_CHAIN m_line
The actual shape of the line
Definition: pns_line.h:291
bool m_hasVia
If true, the line ends with a via
Definition: pns_line.h:297
int m_net
Definition: pns_item.h:370
int m_width
our width
Definition: pns_line.h:294

References m_hasVia, PNS::ITEM::m_layers, and PNS::ITEM::m_net.

◆ ~LINE()

PNS::LINE::~LINE ( )

Definition at line 53 of file pns_line.cpp.

54 {
55 }

Member Function Documentation

◆ Anchor()

virtual VECTOR2I PNS::ITEM::Anchor ( int  n) const
inlinevirtualinherited

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

Definition at line 333 of file pns_item.h.

334  {
335  return VECTOR2I();
336  }
VECTOR2< int > VECTOR2I
Definition: vector2d.h:587

Referenced by PNS::DP_PRIMITIVE_PAIR::CursorOrientation(), PNS::DP_PRIMITIVE_PAIR::DP_PRIMITIVE_PAIR(), and PNS::DIFF_PAIR_PLACER::getDanglingAnchor().

◆ AnchorCount()

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

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

Definition at line 338 of file pns_item.h.

339  {
340  return 0;
341  }

◆ AppendVia()

void PNS::LINE::AppendVia ( const VIA aVia)

Definition at line 776 of file pns_line.cpp.

777 {
778  if( m_line.PointCount() > 1 && aVia.Pos() == m_line.CPoint( 0 ) )
779  {
780  Reverse();
781  }
782 
783  m_hasVia = true;
784  m_via = aVia;
785  m_via.SetNet( m_net );
786 }
VIA m_via
Via at the end point, if m_hasVia == true
Definition: pns_line.h:300
int PointCount() const
Function PointCount()
void SetNet(int aNet)
Function SetNet()
Definition: pns_item.h:169
SHAPE_LINE_CHAIN m_line
The actual shape of the line
Definition: pns_line.h:291
const VECTOR2I & CPoint(int aIndex) const
Function CPoint()
void Reverse()
Reverses the point/vertex order
Definition: pns_line.cpp:768
bool m_hasVia
If true, the line ends with a via
Definition: pns_line.h:297
int m_net
Definition: pns_item.h:370

References SHAPE_LINE_CHAIN::CPoint(), m_hasVia, m_line, PNS::ITEM::m_net, m_via, SHAPE_LINE_CHAIN::PointCount(), PNS::VIA::Pos(), Reverse(), and PNS::ITEM::SetNet().

Referenced by PNS::LINE_PLACER::buildInitialLine(), PNS::SHOVE::onReverseCollidingVia(), PNS::LINE_PLACER::rhShoveOnly(), PNS::LINE_PLACER::rhWalkOnly(), and PNS::DIFF_PAIR::updateLine().

◆ BelongsTo()

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

Function BelongsTo()

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

Definition at line 256 of file pns_item.h.

257  {
258  return m_owner == aNode;
259  }
NODE * m_owner
Definition: pns_item.h:366

References PNS::ITEM::m_owner.

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

◆ ChangedArea()

OPT_BOX2I PNS::LINE::ChangedArea ( const LINE aOther) const

Definition at line 873 of file pns_line.cpp.

874 {
875  BOX2I area;
876  bool areaDefined = false;
877 
878  int i_start = -1;
879  int i_end_self = -1, i_end_other = -1;
880 
881  SHAPE_LINE_CHAIN self( m_line );
882  self.Simplify();
883  SHAPE_LINE_CHAIN other( aOther->m_line );
884  other.Simplify();
885 
886  int np_self = self.PointCount();
887  int np_other = other.PointCount();
888 
889  int n = std::min( np_self, np_other );
890 
891  for( int i = 0; i < n; i++ )
892  {
893  const VECTOR2I p1 = self.CPoint( i );
894  const VECTOR2I p2 = other.CPoint( i );
895 
896  if( p1 != p2 )
897  {
898  if( i != n - 1 )
899  {
900  SEG s = self.CSegment( i );
901 
902  if( !s.Contains( p2 ) )
903  {
904  i_start = i;
905  break;
906  }
907  }
908  else
909  {
910  i_start = i;
911  break;
912  }
913  }
914  }
915 
916  for( int i = 0; i < n; i++ )
917  {
918  const VECTOR2I p1 = self.CPoint( np_self - 1 - i );
919  const VECTOR2I p2 = other.CPoint( np_other - 1 - i );
920 
921  if( p1 != p2 )
922  {
923  i_end_self = np_self - 1 - i;
924  i_end_other = np_other - 1 - i;
925  break;
926  }
927  }
928 
929  if( i_start < 0 )
930  i_start = n;
931 
932  if( i_end_self < 0 )
933  i_end_self = np_self - 1;
934 
935  if( i_end_other < 0 )
936  i_end_other = np_other - 1;
937 
938  for( int i = i_start; i <= i_end_self; i++ )
939  extendBox( area, areaDefined, self.CPoint( i ) );
940 
941  for( int i = i_start; i <= i_end_other; i++ )
942  extendBox( area, areaDefined, other.CPoint( i ) );
943 
944  if( areaDefined )
945  {
946  area.Inflate( std::max( Width(), aOther->Width() ) );
947  return area;
948  }
949 
950  return OPT_BOX2I();
951 }
const VECTOR2I & CPoint(int aIdx) const
Returns the aIdx-th point of the line
Definition: pns_line.h:141
SHAPE_LINE_CHAIN m_line
The actual shape of the line
Definition: pns_line.h:291
SHAPE_LINE_CHAIN & Simplify()
Function Simplify()
bool Contains(const VECTOR2I &aP) const
Definition: seg.cpp:188
Definition: seg.h:36
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:300
#define max(a, b)
Definition: auxiliary.h:86
Class SHAPE_LINE_CHAIN.
static void extendBox(BOX2I &aBox, bool &aDefined, const VECTOR2I &aP)
Definition: pns_line.cpp:859
size_t i
Definition: json11.cpp:597
int Width() const
Returns line width
Definition: pns_line.h:159
OPT< BOX2I > OPT_BOX2I
Definition: box2.h:523
#define min(a, b)
Definition: auxiliary.h:85

References SEG::Contains(), CPoint(), SHAPE_LINE_CHAIN::CPoint(), PNS::extendBox(), i, BOX2< Vec >::Inflate(), m_line, max, min, SHAPE_LINE_CHAIN::PointCount(), SHAPE_LINE_CHAIN::Simplify(), and Width().

Referenced by PNS::ChangedArea().

◆ ClassOf()

static bool PNS::LINE::ClassOf ( const ITEM aItem)
inlinestatic

Definition at line 94 of file pns_line.h.

95  {
96  return aItem && LINE_T == aItem->Kind();
97  }

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

◆ ClearSegmentLinks()

void PNS::LINE::ClearSegmentLinks ( )

Erases the linking information. Used to detach the line from the owning node.

Definition at line 853 of file pns_line.cpp.

854 {
855  m_segmentRefs.clear();
856 }
SEGMENT_REFS m_segmentRefs
List of segments in the owning NODE (ITEM::m_owner) that constitute this line, or NULL if the line is...
Definition: pns_line.h:288

References m_segmentRefs.

Referenced by PNS::DRAGGER::dragMarkObstacles(), PNS::DRAGGER::dragShove(), PNS::DRAGGER::dumbDragVia(), PNS::SHOVE::onCollidingSolid(), PNS::SHOVE::onReverseCollidingVia(), PNS::SHOVE::ProcessSingleLine(), PNS::NODE::Remove(), PNS::SHOVE::ShoveLines(), PNS::SHOVE::ShoveMultiLines(), and PNS::DRAGGER::startDragSegment().

◆ CLine()

◆ ClipToNearestObstacle()

const LINE PNS::LINE::ClipToNearestObstacle ( NODE aNode) const

Clips the line to the nearest obstacle, traversing from the line's start vertex (0).

Returns the clipped line.

Definition at line 327 of file pns_line.cpp.

328 {
329  const int IterationLimit = 5;
330  int i;
331  LINE l( *this );
332 
333  for( i = 0; i < IterationLimit; i++ )
334  {
335  NODE::OPT_OBSTACLE obs = aNode->NearestObstacle( &l );
336 
337  if( obs )
338  {
339  l.RemoveVia();
340  int p = l.Line().Split( obs->m_ipFirst );
341  l.Line().Remove( p + 1, -1 );
342  } else
343  break;
344  }
345 
346  if( i == IterationLimit )
347  l.Line().Clear();
348 
349  return l;
350 }
LINE()
Constructor Makes an empty line.
Definition: pns_line.h:69
size_t i
Definition: json11.cpp:597
OPT< OBSTACLE > OPT_OBSTACLE
Definition: pns_node.h:139

References SHAPE_LINE_CHAIN::Clear(), i, Line(), PNS::NODE::NearestObstacle(), SHAPE_LINE_CHAIN::Remove(), RemoveVia(), and SHAPE_LINE_CHAIN::Split().

Referenced by PNS::LINE_PLACER::rhShoveOnly(), PNS::LINE_PLACER::rhWalkOnly(), and PNS::WALKAROUND::singleStep().

◆ ClipVertexRange()

void PNS::LINE::ClipVertexRange ( int  aStart,
int  aEnd 
)

Clips the line to a given range of vertices.

Definition at line 818 of file pns_line.cpp.

819 {
820  m_line = m_line.Slice( aStart, aEnd );
821 
822  if( IsLinked() ) {
823  assert( m_segmentRefs.size() < INT_MAX );
824  assert( (int) m_segmentRefs.size() >= (aEnd - aStart) );
825 
826  // Note: The range includes aEnd, but we have n-1 segments.
827  std::rotate(
828  m_segmentRefs.begin(),
829  m_segmentRefs.begin() + aStart,
830  m_segmentRefs.begin() + aEnd
831  );
832 
833  m_segmentRefs.resize( aEnd - aStart );
834  }
835 }
const SHAPE_LINE_CHAIN Slice(int aStartIndex, int aEndIndex=-1) const
Function Slice()
SHAPE_LINE_CHAIN m_line
The actual shape of the line
Definition: pns_line.h:291
SEGMENT_REFS m_segmentRefs
List of segments in the owning NODE (ITEM::m_owner) that constitute this line, or NULL if the line is...
Definition: pns_line.h:288
bool IsLinked() const
Definition: pns_line.h:186

References IsLinked(), m_line, m_segmentRefs, and SHAPE_LINE_CHAIN::Slice().

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

◆ Clone()

LINE * PNS::LINE::Clone ( ) const
overridevirtual

Function Clone()

Returns a deep copy of the item

Implements PNS::ITEM.

Definition at line 76 of file pns_line.cpp.

77 {
78  LINE* l = new LINE( *this );
79 
80  return l;
81 }
LINE()
Constructor Makes an empty line.
Definition: pns_line.h:69

References LINE().

Referenced by PNS::ITEM_SET::Add(), and PNS::ITEM_SET::Prepend().

◆ Collide() [1/2]

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.

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

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

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

◆ Collide() [2/2]

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 290 of file pns_item.h.

291  {
292  VECTOR2I dummy;
293 
294  return Collide( aOther, aClearance, false, dummy, aDifferentNetsOnly );
295  }
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
virtual bool Collide(const ITEM *aOther, int aClearance, bool aNeedMTV, VECTOR2I &aMTV, bool aDifferentNetsOnly=true) const
Function Collide()
Definition: pns_item.cpp:44

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

◆ CompareGeometry()

bool PNS::LINE::CompareGeometry ( const LINE aOther)

Returns true if the line is geometrically identical as line aOther

Definition at line 762 of file pns_line.cpp.

763 {
764  return m_line.CompareGeometry( aOther.m_line );
765 }
SHAPE_LINE_CHAIN m_line
The actual shape of the line
Definition: pns_line.h:291
bool CompareGeometry(const SHAPE_LINE_CHAIN &aOther) const

References SHAPE_LINE_CHAIN::CompareGeometry(), and m_line.

◆ ContainsSegment()

bool PNS::LINE::ContainsSegment ( SEGMENT aSeg) const
inline

Checks if the segment aSeg is a part of the line.

Definition at line 197 of file pns_line.h.

198  {
199  return std::find( m_segmentRefs.begin(), m_segmentRefs.end(),
200  aSeg ) != m_segmentRefs.end();
201  }
SEGMENT_REFS m_segmentRefs
List of segments in the owning NODE (ITEM::m_owner) that constitute this line, or NULL if the line is...
Definition: pns_line.h:288

References m_segmentRefs.

◆ copyLinks()

void PNS::LINE::copyLinks ( const LINE aParent)
private

Copies m_segmentRefs from the line aParent.

Definition at line 116 of file pns_line.cpp.

117 {
118  m_segmentRefs = aParent->m_segmentRefs;
119 }
SEGMENT_REFS m_segmentRefs
List of segments in the owning NODE (ITEM::m_owner) that constitute this line, or NULL if the line is...
Definition: pns_line.h:288

References m_segmentRefs.

Referenced by LINE(), and operator=().

◆ CountCorners()

int PNS::LINE::CountCorners ( int  aAngles) const

Returns the number of corners of angles specified by mask aAngles.

Definition at line 136 of file pns_line.cpp.

137 {
138  int count = 0;
139 
140  for( int i = 0; i < m_line.SegmentCount() - 1; i++ )
141  {
142  const SEG seg1 = m_line.CSegment( i );
143  const SEG seg2 = m_line.CSegment( i + 1 );
144 
145  const DIRECTION_45 dir1( seg1 );
146  const DIRECTION_45 dir2( seg2 );
147 
148  DIRECTION_45::AngleType a = dir1.Angle( dir2 );
149 
150  if( a & aAngles )
151  count++;
152  }
153 
154  return count;
155 }
SHAPE_LINE_CHAIN m_line
The actual shape of the line
Definition: pns_line.h:291
Class DIRECTION_45.
Definition: direction45.h:36
int SegmentCount() const
Function SegmentCount()
Definition: seg.h:36
AngleType
Enum AngleType Represents kind of angle formed by vectors heading in two DIRECTION_45s.
Definition: direction45.h:62
const SEG CSegment(int aIndex) const
Function CSegment()
size_t i
Definition: json11.cpp:597

References DIRECTION_45::Angle(), SHAPE_LINE_CHAIN::CSegment(), i, m_line, and SHAPE_LINE_CHAIN::SegmentCount().

Referenced by PNS::LINE_PLACER::mergeHead(), and PNS::OPTIMIZER::smartPadsSingle().

◆ CPoint()

◆ CSegment()

const SEG PNS::LINE::CSegment ( int  aIdx) const
inline

Returns the aIdx-th segment of the line

Definition at line 147 of file pns_line.h.

148  {
149  return m_line.CSegment( aIdx );
150  }
SHAPE_LINE_CHAIN m_line
The actual shape of the line
Definition: pns_line.h:291
const SEG CSegment(int aIndex) const
Function CSegment()

References SHAPE_LINE_CHAIN::CSegment(), and m_line.

Referenced by PNS::SHOVE::checkBumpDirection(), PNS::DIFF_PAIR::EndingPrimitives(), PNS::LINE_PLACER::FixRoute(), PNS::OPTIMIZER::mergeStep(), PNS::LINE_PLACER::optimizeTailHeadTransition(), and PNS::SHOVE::ProcessSingleLine().

◆ DragCorner()

void PNS::LINE::DragCorner ( const VECTOR2I aP,
int  aIndex,
int  aSnappingThreshold = 0,
bool  aFreeAngle = false 
)

Definition at line 475 of file pns_line.cpp.

476 {
477  if( aFreeAngle )
478  {
479  dragCornerFree ( aP, aIndex, aSnappingThreshold );
480  }
481  else
482  {
483  dragCorner45 ( aP, aIndex, aSnappingThreshold );
484  }
485 }
void dragCorner45(const VECTOR2I &aP, int aIndex, int aSnappingThreshold)
Definition: pns_line.cpp:445
void dragCornerFree(const VECTOR2I &aP, int aIndex, int aSnappingThreshold)
Definition: pns_line.cpp:469

References dragCorner45(), and dragCornerFree().

Referenced by PNS::DRAGGER::dragMarkObstacles(), PNS::DRAGGER::dragShove(), and PNS::DRAGGER::dumbDragVia().

◆ dragCorner45()

void PNS::LINE::dragCorner45 ( const VECTOR2I aP,
int  aIndex,
int  aSnappingThreshold 
)
private

Definition at line 445 of file pns_line.cpp.

446 {
447  SHAPE_LINE_CHAIN path;
448 
449  VECTOR2I snapped = snapDraggedCorner( m_line, aP, aIndex, aSnappingThreshold );
450 
451  if( aIndex == 0 )
452  path = dragCornerInternal( m_line.Reverse(), snapped ).Reverse();
453  else if( aIndex == m_line.SegmentCount() )
454  path = dragCornerInternal( m_line, snapped );
455  else
456  {
457  // fixme: awkward behaviour for "outwards" drags
458  path = dragCornerInternal( m_line.Slice( 0, aIndex ), snapped );
459  SHAPE_LINE_CHAIN path_rev = dragCornerInternal( m_line.Slice( aIndex, -1 ).Reverse(),
460  snapped ).Reverse();
461  path.Append( path_rev );
462  }
463 
464  path.Simplify();
465  m_line = path;
466 }
const SHAPE_LINE_CHAIN Slice(int aStartIndex, int aEndIndex=-1) const
Function Slice()
const SHAPE_LINE_CHAIN Reverse() const
Function Reverse()
void Append(int aX, int aY, bool aAllowDuplication=false)
Function Append()
SHAPE_LINE_CHAIN dragCornerInternal(const SHAPE_LINE_CHAIN &aOrigin, const VECTOR2I &aP)
Definition: pns_line.cpp:368
SHAPE_LINE_CHAIN m_line
The actual shape of the line
Definition: pns_line.h:291
SHAPE_LINE_CHAIN & Simplify()
Function Simplify()
void Reverse()
Reverses the point/vertex order
Definition: pns_line.cpp:768
int SegmentCount() const
Function SegmentCount()
Class SHAPE_LINE_CHAIN.
VECTOR2I snapDraggedCorner(const SHAPE_LINE_CHAIN &aPath, const VECTOR2I &aP, int aIndex, int aThreshold) const
Definition: pns_line.cpp:500

References SHAPE_LINE_CHAIN::Append(), PNS::dragCornerInternal(), m_line, Reverse(), SHAPE_LINE_CHAIN::Reverse(), SHAPE_LINE_CHAIN::SegmentCount(), SHAPE_LINE_CHAIN::Simplify(), SHAPE_LINE_CHAIN::Slice(), and snapDraggedCorner().

Referenced by DragCorner().

◆ dragCornerFree()

void PNS::LINE::dragCornerFree ( const VECTOR2I aP,
int  aIndex,
int  aSnappingThreshold 
)
private

Definition at line 469 of file pns_line.cpp.

470 {
471  m_line.Point( aIndex ) = aP;
472  m_line.Simplify();
473 }
SHAPE_LINE_CHAIN m_line
The actual shape of the line
Definition: pns_line.h:291
SHAPE_LINE_CHAIN & Simplify()
Function Simplify()
VECTOR2I & Point(int aIndex)
Function Point()

References m_line, SHAPE_LINE_CHAIN::Point(), and SHAPE_LINE_CHAIN::Simplify().

Referenced by DragCorner().

◆ DragSegment()

void PNS::LINE::DragSegment ( const VECTOR2I aP,
int  aIndex,
int  aSnappingThreshold = 0,
bool  aFreeAngle = false 
)

Definition at line 487 of file pns_line.cpp.

488 {
489  if( aFreeAngle )
490  {
491  assert( false );
492  }
493  else
494  {
495  dragSegment45 ( aP, aIndex, aSnappingThreshold );
496  }
497 }
void dragSegment45(const VECTOR2I &aP, int aIndex, int aSnappingThreshold)
Definition: pns_line.cpp:588

References dragSegment45().

Referenced by PNS::DRAGGER::dragMarkObstacles(), and PNS::DRAGGER::dragShove().

◆ dragSegment45()

void PNS::LINE::dragSegment45 ( const VECTOR2I aP,
int  aIndex,
int  aSnappingThreshold 
)
private

Definition at line 588 of file pns_line.cpp.

589 {
590  SHAPE_LINE_CHAIN path( m_line );
591  VECTOR2I target( aP );
592 
593  SEG guideA[2], guideB[2];
594  int index = aIndex;
595 
596  target = snapToNeighbourSegments( path, aP, aIndex, aSnappingThreshold );
597 
598  if( index == 0 )
599  {
600  path.Insert( 0, path.CPoint( 0 ) );
601  index++;
602  }
603 
604  if( index == path.SegmentCount() - 1 )
605  {
606  path.Insert( path.PointCount() - 1, path.CPoint( -1 ) );
607  }
608 
609  SEG dragged = path.CSegment( index );
610  DIRECTION_45 drag_dir( dragged );
611 
612  SEG s_prev = path.CSegment( index - 1 );
613  SEG s_next = path.CSegment( index + 1 );
614 
615  DIRECTION_45 dir_prev( s_prev );
616  DIRECTION_45 dir_next( s_next );
617 
618  if( dir_prev == drag_dir )
619  {
620  dir_prev = dir_prev.Left();
621  path.Insert( index, path.CPoint( index ) );
622  index++;
623  }
624 
625  if( dir_next == drag_dir )
626  {
627  dir_next = dir_next.Right();
628  path.Insert( index + 1, path.CPoint( index + 1 ) );
629  }
630 
631  s_prev = path.CSegment( index - 1 );
632  s_next = path.CSegment( index + 1 );
633  dragged = path.CSegment( index );
634 
635  const bool lockEndpointA = true;
636  const bool lockEndpointB = true;
637 
638  if( aIndex == 0 )
639  {
640  if( !lockEndpointA )
641  {
642  guideA[0] = guideA[1] = SEG( dragged.A,
643  dragged.A + drag_dir.Right().Right().ToVector() );
644  }
645  else
646  {
647  guideA[0] = SEG( dragged.A, dragged.A + drag_dir.Right().ToVector() );
648  guideA[1] = SEG( dragged.A, dragged.A + drag_dir.Left().ToVector() );
649  }
650  }
651  else
652  {
653  if( dir_prev.Angle( drag_dir ) & (DIRECTION_45::ANG_OBTUSE | DIRECTION_45::ANG_HALF_FULL) )
654  {
655  guideA[0] = SEG( s_prev.A, s_prev.A + drag_dir.Left().ToVector() );
656  guideA[1] = SEG( s_prev.A, s_prev.A + drag_dir.Right().ToVector() );
657  }
658  else
659  guideA[0] = guideA[1] = SEG( dragged.A, dragged.A + dir_prev.ToVector() );
660  }
661 
662  if( aIndex == m_line.SegmentCount() - 1 )
663  {
664  if( !lockEndpointB )
665  {
666  guideB[0] = guideB[1] = SEG( dragged.B,
667  dragged.B + drag_dir.Right().Right().ToVector() );
668  }
669  else
670  {
671  guideB[0] = SEG( dragged.B, dragged.B + drag_dir.Right().ToVector() );
672  guideB[1] = SEG( dragged.B, dragged.B + drag_dir.Left().ToVector() );
673  }
674  }
675  else
676  {
677  if( dir_next.Angle( drag_dir ) & (DIRECTION_45::ANG_OBTUSE | DIRECTION_45::ANG_HALF_FULL) )
678  {
679  guideB[0] = SEG( s_next.B, s_next.B + drag_dir.Left().ToVector() );
680  guideB[1] = SEG( s_next.B, s_next.B + drag_dir.Right().ToVector() );
681  }
682  else
683  guideB[0] = guideB[1] = SEG( dragged.B, dragged.B + dir_next.ToVector() );
684 
685  }
686 
687  SEG s_current( target, target + drag_dir.ToVector() );
688 
689  int best_len = INT_MAX;
690  SHAPE_LINE_CHAIN best;
691 
692  for( int i = 0; i < 2; i++ )
693  {
694  for( int j = 0; j < 2; j++ )
695  {
696  OPT_VECTOR2I ip1 = s_current.IntersectLines( guideA[i] );
697  OPT_VECTOR2I ip2 = s_current.IntersectLines( guideB[j] );
698 
699  SHAPE_LINE_CHAIN np;
700 
701  if( !ip1 || !ip2 )
702  continue;
703 
704  SEG s1( s_prev.A, *ip1 );
705  SEG s2( *ip1, *ip2 );
706  SEG s3( *ip2, s_next.B );
707 
708  OPT_VECTOR2I ip;
709 
710  if( (ip = s1.Intersect( s_next )) )
711  {
712  np.Append( s1.A );
713  np.Append( *ip );
714  np.Append( s_next.B );
715  }
716  else if( (ip = s3.Intersect( s_prev )) )
717  {
718  np.Append( s_prev.A );
719  np.Append( *ip );
720  np.Append( s3.B );
721  }
722  else if( (ip = s1.Intersect( s3 )) )
723  {
724  np.Append( s_prev.A );
725  np.Append( *ip );
726  np.Append( s_next.B );
727  }
728  else
729  {
730  np.Append( s_prev.A );
731  np.Append( *ip1 );
732  np.Append( *ip2 );
733  np.Append( s_next.B );
734  }
735 
736  if( np.Length() < best_len )
737  {
738  best_len = np.Length();
739  best = np;
740  }
741  }
742  }
743 
744  if( !lockEndpointA && aIndex == 0 )
745  best.Remove( 0, 0 );
746  if( !lockEndpointB && aIndex == m_line.SegmentCount() - 1 )
747  best.Remove( -1, -1 );
748 
749  if( m_line.PointCount() == 1 )
750  m_line = best;
751  else if( aIndex == 0 )
752  m_line.Replace( 0, 1, best );
753  else if( aIndex == m_line.SegmentCount() - 1 )
754  m_line.Replace( -2, -1, best );
755  else
756  m_line.Replace( aIndex, aIndex + 1, best );
757 
758  m_line.Simplify();
759 }
int PointCount() const
Function PointCount()
VECTOR2I snapToNeighbourSegments(const SHAPE_LINE_CHAIN &aPath, const VECTOR2I &aP, int aIndex, int aThreshold) const
Definition: pns_line.cpp:542
void Append(int aX, int aY, bool aAllowDuplication=false)
Function Append()
SHAPE_LINE_CHAIN m_line
The actual shape of the line
Definition: pns_line.h:291
SHAPE_LINE_CHAIN & Simplify()
Function Simplify()
OPT< VECTOR2I > OPT_VECTOR2I
Definition: seg.h:34
Class DIRECTION_45.
Definition: direction45.h:36
void Remove(int aStartIndex, int aEndIndex)
Function Remove()
int SegmentCount() const
Function SegmentCount()
Definition: seg.h:36
Class SHAPE_LINE_CHAIN.
size_t i
Definition: json11.cpp:597
VECTOR2I A
Definition: seg.h:44
int Length() const
Function Length()
void Replace(int aStartIndex, int aEndIndex, const VECTOR2I &aP)
Function Replace()
VECTOR2I B
Definition: seg.h:45

References SEG::A, DIRECTION_45::ANG_HALF_FULL, DIRECTION_45::ANG_OBTUSE, DIRECTION_45::Angle(), SHAPE_LINE_CHAIN::Append(), SEG::B, SHAPE_LINE_CHAIN::CPoint(), SHAPE_LINE_CHAIN::CSegment(), i, SHAPE_LINE_CHAIN::Insert(), SEG::Intersect(), DIRECTION_45::Left(), SHAPE_LINE_CHAIN::Length(), m_line, SHAPE_LINE_CHAIN::PointCount(), SHAPE_LINE_CHAIN::Remove(), SHAPE_LINE_CHAIN::Replace(), DIRECTION_45::Right(), SHAPE_LINE_CHAIN::SegmentCount(), SHAPE_LINE_CHAIN::Simplify(), snapToNeighbourSegments(), and DIRECTION_45::ToVector().

Referenced by DragSegment().

◆ dragSegmentFree()

void PNS::LINE::dragSegmentFree ( const VECTOR2I aP,
int  aIndex,
int  aSnappingThreshold 
)
private

◆ EndsWithVia()

◆ GetLink()

SEGMENT* PNS::LINE::GetLink ( int  aIndex) const
inline

Definition at line 203 of file pns_line.h.

204  {
205  return m_segmentRefs[aIndex];
206  }
SEGMENT_REFS m_segmentRefs
List of segments in the owning NODE (ITEM::m_owner) that constitute this line, or NULL if the line is...
Definition: pns_line.h:288

References m_segmentRefs.

Referenced by PNS::LINE_PLACER::removeLoops(), PNS::TOPOLOGY::SimplifyLine(), PNS::MEANDER_SKEW_PLACER::Start(), and PNS::DP_MEANDER_PLACER::Start().

◆ HasLockedSegments()

bool PNS::LINE::HasLockedSegments ( ) const

Definition at line 954 of file pns_line.cpp.

955 {
956  for( const SEGMENT* seg : m_segmentRefs )
957  {
958  if( seg->Marker() & MK_LOCKED )
959  return true;
960  }
961  return false;
962 }
SEGMENT_REFS m_segmentRefs
List of segments in the owning NODE (ITEM::m_owner) that constitute this line, or NULL if the line is...
Definition: pns_line.h:288

References m_segmentRefs, and PNS::MK_LOCKED.

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

◆ HasLoops()

bool PNS::LINE::HasLoops ( ) const

Definition at line 838 of file pns_line.cpp.

839 {
840  for( int i = 0; i < PointCount(); i++ )
841  {
842  for( int j = i + 2; j < PointCount(); j++ )
843  {
844  if( CPoint( i ) == CPoint( j ) )
845  return true;
846  }
847  }
848 
849  return false;
850 }
int PointCount() const
Returns the number of points in the line
Definition: pns_line.h:135
const VECTOR2I & CPoint(int aIdx) const
Returns the aIdx-th point of the line
Definition: pns_line.h:141
size_t i
Definition: json11.cpp:597

References CPoint(), i, and PointCount().

Referenced by PNS::SHOVE::onCollidingSolid(), and PNS::LINE_PLACER::rhShoveOnly().

◆ Hull()

virtual const SHAPE_LINE_CHAIN PNS::ITEM::Hull ( int  aClearance = 0,
int  aWalkaroundThickness = 0 
) const
inlinevirtualinherited

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

Definition at line 112 of file pns_item.h.

113  {
114  return SHAPE_LINE_CHAIN();
115  }
Class SHAPE_LINE_CHAIN.

◆ InAnyNet()

bool PNS::ITEM::InAnyNet ( ) const
inlineinherited

Definition at line 184 of file pns_item.h.

185  {
186  return m_net != UnusedNet;
187  }
static const int UnusedNet
Definition: pns_item.h:56
int m_net
Definition: pns_item.h:370

References PNS::ITEM::m_net, and PNS::ITEM::UnusedNet.

◆ Is45Degree()

bool PNS::LINE::Is45Degree ( ) const

Definition at line 301 of file pns_line.cpp.

302 {
303  for( int i = 0; i < m_line.SegmentCount(); i++ )
304  {
305  const SEG& s = m_line.CSegment( i );
306 
307  if( s.Length() < 10 )
308  continue;
309 
310  double angle = 180.0 / M_PI *
311  atan2( (double) s.B.y - (double) s.A.y,
312  (double) s.B.x - (double) s.A.x );
313 
314  if( angle < 0 )
315  angle += 360.0;
316 
317  double angle_a = fabs( fmod( angle, 45.0 ) );
318 
319  if( angle_a > 1.0 && angle_a < 44.0 )
320  return false;
321  }
322 
323  return true;
324 }
int Length() const
Function Length()
Definition: seg.h:296
SHAPE_LINE_CHAIN m_line
The actual shape of the line
Definition: pns_line.h:291
int SegmentCount() const
Function SegmentCount()
Definition: seg.h:36
const SEG CSegment(int aIndex) const
Function CSegment()
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
size_t i
Definition: json11.cpp:597
VECTOR2I A
Definition: seg.h:44
VECTOR2I B
Definition: seg.h:45

References SEG::A, PNS::angle(), SEG::B, SHAPE_LINE_CHAIN::CSegment(), i, SEG::Length(), m_line, SHAPE_LINE_CHAIN::SegmentCount(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by PNS::LINE_PLACER::routeStep().

◆ IsLinked()

bool PNS::LINE::IsLinked ( ) const
inline

Definition at line 186 of file pns_line.h.

187  {
188  return m_segmentRefs.size() != 0;
189  }
SEGMENT_REFS m_segmentRefs
List of segments in the owning NODE (ITEM::m_owner) that constitute this line, or NULL if the line is...
Definition: pns_line.h:288

References m_segmentRefs.

Referenced by PNS::NODE::Add(), ClipVertexRange(), PNS::TOPOLOGY::followTrivialPath(), IsLinkedChecked(), PNS::DIFF_PAIR::NLine(), PNS::DIFF_PAIR::PLine(), Rank(), PNS::OPTIMIZER::removeCachedSegments(), ShowLinks(), and PNS::TOPOLOGY::SimplifyLine().

◆ IsLinkedChecked()

bool PNS::LINE::IsLinkedChecked ( ) const
inline

Definition at line 191 of file pns_line.h.

192  {
193  return IsLinked() && LinkCount() == SegmentCount();
194  }
int SegmentCount() const
Returns the number of segments in the line
Definition: pns_line.h:129
bool IsLinked() const
Definition: pns_line.h:186
int LinkCount() const
Returns the number of segments that were assembled together to form this line.
Definition: pns_line.h:212

References IsLinked(), LinkCount(), and SegmentCount().

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

◆ IsLocked()

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

Definition at line 343 of file pns_item.h.

344  {
345  return Marker() & MK_LOCKED;
346  }
virtual int Marker() const
Definition: pns_item.h:318

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

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

◆ IsRoutable()

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

Definition at line 353 of file pns_item.h.

354  {
355  return m_routable;
356  }
bool m_routable
Definition: pns_item.h:373

References PNS::ITEM::m_routable.

◆ Kind()

◆ KindStr()

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.

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:363

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().

◆ Layer()

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 224 of file pns_item.h.

225  {
226  return Layers().Start();
227  }
int Start() const
Definition: pns_layerset.h:83
const LAYER_RANGE & Layers() const
Function Layers()
Definition: pns_item.h:214

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

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

◆ Layers()

◆ LayersOverlap()

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 235 of file pns_item.h.

236  {
237  return Layers().Overlaps( aOther->Layers() );
238  }
bool Overlaps(const LAYER_RANGE &aOther) const
Definition: pns_layerset.h:68
const LAYER_RANGE & Layers() const
Function Layers()
Definition: pns_item.h:214

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

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

◆ Line()

◆ LinkCount()

int PNS::LINE::LinkCount ( ) const
inline

Returns the number of segments that were assembled together to form this line.

Definition at line 212 of file pns_line.h.

213  {
214  return m_segmentRefs.size();
215  }
SEGMENT_REFS m_segmentRefs
List of segments in the owning NODE (ITEM::m_owner) that constitute this line, or NULL if the line is...
Definition: pns_line.h:288

References m_segmentRefs.

Referenced by IsLinkedChecked(), and PNS::LINE_PLACER::removeLoops().

◆ LinkedSegments()

SEGMENT_REFS& PNS::LINE::LinkedSegments ( )
inline

Returns the list of segments from the owning node that constitute this line (or NULL if the line is not linked)

Definition at line 181 of file pns_line.h.

182  {
183  return m_segmentRefs;
184  }
SEGMENT_REFS m_segmentRefs
List of segments in the owning NODE (ITEM::m_owner) that constitute this line, or NULL if the line is...
Definition: pns_line.h:288

References m_segmentRefs.

Referenced by PNS::NODE::Dump(), PNS::TOPOLOGY::followTrivialPath(), PNS::SHOVE::popLine(), PNS::SHOVE::ProcessSingleLine(), PNS::NODE::Remove(), PNS::OPTIMIZER::removeCachedSegments(), and PNS::SHOVE::unwindStack().

◆ LinkSegment()

void PNS::LINE::LinkSegment ( SEGMENT aSeg)
inline

Adds a reference to a segment registered in a NODE that is a part of this line.

Definition at line 174 of file pns_line.h.

175  {
176  m_segmentRefs.push_back( aSeg );
177  }
SEGMENT_REFS m_segmentRefs
List of segments in the owning NODE (ITEM::m_owner) that constitute this line, or NULL if the line is...
Definition: pns_line.h:288

References m_segmentRefs.

Referenced by PNS::NODE::Add(), and PNS::NODE::AssembleLine().

◆ Mark()

void PNS::LINE::Mark ( int  aMarker)
overridevirtual

Reimplemented from PNS::ITEM.

Definition at line 84 of file pns_line.cpp.

85 {
86  m_marker = aMarker;
87 
88  for( SEGMENT* s : m_segmentRefs )
89  s->Mark( aMarker );
90 
91 }
int m_marker
Definition: pns_item.h:371
SEGMENT_REFS m_segmentRefs
List of segments in the owning NODE (ITEM::m_owner) that constitute this line, or NULL if the line is...
Definition: pns_line.h:288

References PNS::ITEM::m_marker, and m_segmentRefs.

Referenced by PNS::SHOVE::onCollidingSolid(), PNS::SHOVE::ProcessSingleLine(), PNS::SHOVE::ShoveLines(), and PNS::SHOVE::ShoveMultiLines().

◆ Marker()

int PNS::LINE::Marker ( ) const
overridevirtual

Reimplemented from PNS::ITEM.

Definition at line 103 of file pns_line.cpp.

104 {
105  int marker = m_marker;
106 
107  for( SEGMENT* s : m_segmentRefs )
108  {
109  marker |= s->Marker();
110  }
111 
112  return marker;
113 }
int m_marker
Definition: pns_item.h:371
SEGMENT_REFS m_segmentRefs
List of segments in the owning NODE (ITEM::m_owner) that constitute this line, or NULL if the line is...
Definition: pns_line.h:288

References PNS::ITEM::m_marker, and m_segmentRefs.

Referenced by PNS::SHOVE::onCollidingLine(), PNS::SHOVE::onCollidingSegment(), PNS::SHOVE::onCollidingSolid(), PNS::SHOVE::processHullSet(), PNS::SHOVE::ProcessSingleLine(), PNS::SHOVE::runOptimizer(), and PNS::SEGMENT::SEGMENT().

◆ Net()

◆ OfKind()

◆ operator=()

LINE & PNS::LINE::operator= ( const LINE aOther)

Definition at line 58 of file pns_line.cpp.

59 {
60  m_line = aOther.m_line;
61  m_width = aOther.m_width;
62  m_net = aOther.m_net;
63  m_movable = aOther.m_movable;
64  m_layers = aOther.m_layers;
65  m_via = aOther.m_via;
66  m_hasVia = aOther.m_hasVia;
67  m_marker = aOther.m_marker;
68  m_rank = aOther.m_rank;
69 
70  copyLinks( &aOther );
71 
72  return *this;
73 }
VIA m_via
Via at the end point, if m_hasVia == true
Definition: pns_line.h:300
LAYER_RANGE m_layers
Definition: pns_item.h:367
int m_rank
Definition: pns_item.h:372
bool m_movable
Definition: pns_item.h:369
int m_marker
Definition: pns_item.h:371
SHAPE_LINE_CHAIN m_line
The actual shape of the line
Definition: pns_line.h:291
void copyLinks(const LINE *aParent)
Copies m_segmentRefs from the line aParent.
Definition: pns_line.cpp:116
bool m_hasVia
If true, the line ends with a via
Definition: pns_line.h:297
int m_net
Definition: pns_item.h:370
int m_width
our width
Definition: pns_line.h:294

References copyLinks(), m_hasVia, PNS::ITEM::m_layers, m_line, PNS::ITEM::m_marker, PNS::ITEM::m_movable, PNS::ITEM::m_net, PNS::ITEM::m_rank, m_via, and m_width.

◆ Owner()

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

Function Owner()

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

Definition at line 266 of file pns_item.h.

266 { return m_owner; }
NODE * m_owner
Definition: pns_item.h:366

References PNS::ITEM::m_owner.

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

◆ Parent()

BOARD_CONNECTED_ITEM* PNS::ITEM::Parent ( ) const
inlineinherited

Function Parent()

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

Definition at line 159 of file pns_item.h.

160  {
161  return m_parent;
162  }
BOARD_CONNECTED_ITEM * m_parent
Definition: pns_item.h:365

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().

◆ PointCount()

int PNS::LINE::PointCount ( ) const
inline

◆ Rank()

int PNS::LINE::Rank ( ) const
overridevirtual

Reimplemented from PNS::ITEM.

Definition at line 799 of file pns_line.cpp.

800 {
801  int min_rank = INT_MAX;
802 
803  if( IsLinked() ) {
804  for( SEGMENT *s : m_segmentRefs )
805  {
806  min_rank = std::min( min_rank, s->Rank() );
807  }
808  } else {
809  min_rank = m_rank;
810  }
811 
812  int rank = ( min_rank == INT_MAX ) ? -1 : min_rank;
813 
814  return rank;
815 }
int m_rank
Definition: pns_item.h:372
SEGMENT_REFS m_segmentRefs
List of segments in the owning NODE (ITEM::m_owner) that constitute this line, or NULL if the line is...
Definition: pns_line.h:288
bool IsLinked() const
Definition: pns_line.h:186
#define min(a, b)
Definition: auxiliary.h:85

References IsLinked(), PNS::ITEM::m_rank, m_segmentRefs, and min.

Referenced by PNS::SHOVE::onCollidingLine(), PNS::SHOVE::onCollidingSegment(), PNS::SHOVE::onCollidingSolid(), PNS::SHOVE::onCollidingVia(), PNS::SHOVE::onReverseCollidingVia(), PNS::SEGMENT::SEGMENT(), and PNS::SHOVE::shoveIteration().

◆ RemoveVia()

void PNS::LINE::RemoveVia ( )
inline

Definition at line 251 of file pns_line.h.

251 { m_hasVia = false; }
bool m_hasVia
If true, the line ends with a via
Definition: pns_line.h:297

References m_hasVia.

Referenced by ClipToNearestObstacle(), PNS::LINE_PLACER::initPlacement(), PNS::SHOVE::onReverseCollidingVia(), and PNS::LINE_PLACER::ToggleVia().

◆ Reverse()

void PNS::LINE::Reverse ( )

Reverses the point/vertex order

Definition at line 768 of file pns_line.cpp.

769 {
770  m_line = m_line.Reverse();
771 
772  std::reverse( m_segmentRefs.begin(), m_segmentRefs.end() );
773 }
const SHAPE_LINE_CHAIN Reverse() const
Function Reverse()
SHAPE_LINE_CHAIN m_line
The actual shape of the line
Definition: pns_line.h:291
SEGMENT_REFS m_segmentRefs
List of segments in the owning NODE (ITEM::m_owner) that constitute this line, or NULL if the line is...
Definition: pns_line.h:288
static void reverse(privcurve_t *curve)
Definition: trace.cpp:1025

References m_line, m_segmentRefs, SHAPE_LINE_CHAIN::Reverse(), and reverse().

Referenced by AppendVia(), dragCorner45(), PNS::TOPOLOGY::followTrivialPath(), and PNS::DRAGGER::startDragVia().

◆ SegmentCount()

◆ SetLayer()

void PNS::ITEM::SetLayer ( int  aLayer)
inlineinherited

Function SetLayer()

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

Definition at line 204 of file pns_item.h.

205  {
206  m_layers = LAYER_RANGE( aLayer, aLayer );
207  }
LAYER_RANGE m_layers
Definition: pns_item.h:367
Class LAYER_RANGE.
Definition: pns_layerset.h:32

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().

◆ SetLayers()

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

Function SetLayers()

Sets the layers spanned by the item to aLayers.

Definition at line 194 of file pns_item.h.

195  {
196  m_layers = aLayers;
197  }
LAYER_RANGE m_layers
Definition: pns_item.h:367

References PNS::ITEM::m_layers.

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

◆ SetNet()

void PNS::ITEM::SetNet ( int  aNet)
inlineinherited

◆ SetOwner()

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 246 of file pns_item.h.

247  {
248  m_owner = aOwner;
249  }
NODE * m_owner
Definition: pns_item.h:366

References PNS::ITEM::m_owner.

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

◆ SetParent()

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 149 of file pns_item.h.

150  {
151  m_parent = aParent;
152  }
BOARD_CONNECTED_ITEM * m_parent
Definition: pns_item.h:365

References PNS::ITEM::m_parent.

Referenced by PNS_KICAD_IFACE::AddItem().

◆ SetRank()

void PNS::LINE::SetRank ( int  aRank)
overridevirtual

Reimplemented from PNS::ITEM.

Definition at line 789 of file pns_line.cpp.

790 {
791  m_rank = aRank;
792 
793  for( SEGMENT* s : m_segmentRefs )
794  s->SetRank( aRank );
795 
796 }
int m_rank
Definition: pns_item.h:372
SEGMENT_REFS m_segmentRefs
List of segments in the owning NODE (ITEM::m_owner) that constitute this line, or NULL if the line is...
Definition: pns_line.h:288

References PNS::ITEM::m_rank, and m_segmentRefs.

Referenced by PNS::SHOVE::onCollidingLine(), PNS::SHOVE::onCollidingSegment(), PNS::SHOVE::onCollidingSolid(), PNS::SHOVE::onReverseCollidingVia(), PNS::SHOVE::ShoveLines(), and PNS::SHOVE::ShoveMultiLines().

◆ SetRoutable()

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

Definition at line 348 of file pns_item.h.

349  {
350  m_routable = aRoutable;
351  }
bool m_routable
Definition: pns_item.h:373

References PNS::ITEM::m_routable.

◆ SetShape()

◆ SetWidth()

void PNS::LINE::SetWidth ( int  aWidth)
inline

Sets line width

Definition at line 153 of file pns_line.h.

154  {
155  m_width = aWidth;
156  }
int m_width
our width
Definition: pns_line.h:294

References m_width.

Referenced by PNS::NODE::AssembleLine(), PNS::LINE_PLACER::initPlacement(), and PNS::DIFF_PAIR::updateLine().

◆ Shape()

const SHAPE* PNS::LINE::Shape ( ) const
inlineoverridevirtual

Returns the shape of the line

Reimplemented from PNS::ITEM.

Definition at line 111 of file pns_line.h.

112  {
113  return &m_line;
114  }
SHAPE_LINE_CHAIN m_line
The actual shape of the line
Definition: pns_line.h:291

References m_line.

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

◆ ShowLinks()

void PNS::LINE::ShowLinks ( ) const

Prints out all linked segments

Definition at line 353 of file pns_line.cpp.

354 {
355  if( !IsLinked() )
356  {
357  wxLogTrace( "PNS", "line %p: no links", this );
358  return;
359  }
360 
361  wxLogTrace( "PNS", "line %p: %d linked segs", this, (int) m_segmentRefs.size() );
362 
363  for( int i = 0; i < (int) m_segmentRefs.size(); i++ )
364  wxLogTrace( "PNS", "seg %d: %p\n", i, m_segmentRefs[i] );
365 }
SEGMENT_REFS m_segmentRefs
List of segments in the owning NODE (ITEM::m_owner) that constitute this line, or NULL if the line is...
Definition: pns_line.h:288
size_t i
Definition: json11.cpp:597
bool IsLinked() const
Definition: pns_line.h:186

References i, IsLinked(), and m_segmentRefs.

◆ snapDraggedCorner()

VECTOR2I PNS::LINE::snapDraggedCorner ( const SHAPE_LINE_CHAIN aPath,
const VECTOR2I aP,
int  aIndex,
int  aThreshold 
) const
private

Definition at line 500 of file pns_line.cpp.

502 {
503  int s_start = std::max( aIndex - 2, 0 );
504  int s_end = std::min( aIndex + 2, aPath.SegmentCount() - 1 );
505 
506  int i, j;
507  int best_dist = INT_MAX;
508  VECTOR2I best_snap = aP;
509 
510  if( aThreshold <= 0 )
511  return aP;
512 
513  for( i = s_start; i <= s_end; i++ )
514  {
515  const SEG& a = aPath.CSegment( i );
516 
517  for( j = s_start; j < i; j++ )
518  {
519  const SEG& b = aPath.CSegment( j );
520 
521  if( !( DIRECTION_45( a ).IsObtuse(DIRECTION_45( b ) ) ) )
522  continue;
523 
524  OPT_VECTOR2I ip = a.IntersectLines(b);
525 
526  if( ip )
527  {
528  int dist = ( *ip - aP ).EuclideanNorm();
529 
530  if( dist < aThreshold && dist < best_dist )
531  {
532  best_dist = dist;
533  best_snap = *ip;
534  }
535  }
536  }
537  }
538 
539  return best_snap;
540 }
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:123
static const int dist[10][10]
Definition: ar_matrix.cpp:320
OPT_VECTOR2I IntersectLines(const SEG &aSeg) const
Function IntersectLines()
Definition: seg.h:183
OPT< VECTOR2I > OPT_VECTOR2I
Definition: seg.h:34
Class DIRECTION_45.
Definition: direction45.h:36
int SegmentCount() const
Function SegmentCount()
Definition: seg.h:36
const SEG CSegment(int aIndex) const
Function CSegment()
#define max(a, b)
Definition: auxiliary.h:86
size_t i
Definition: json11.cpp:597
#define min(a, b)
Definition: auxiliary.h:85

References SHAPE_LINE_CHAIN::CSegment(), dist, EuclideanNorm(), i, SEG::IntersectLines(), max, min, and SHAPE_LINE_CHAIN::SegmentCount().

Referenced by dragCorner45().

◆ snapToNeighbourSegments()

VECTOR2I PNS::LINE::snapToNeighbourSegments ( const SHAPE_LINE_CHAIN aPath,
const VECTOR2I aP,
int  aIndex,
int  aThreshold 
) const
private

Definition at line 542 of file pns_line.cpp.

544 {
545  VECTOR2I snap_p[2];
546  DIRECTION_45 dragDir( aPath.CSegment( aIndex ) );
547  int snap_d[2] = { -1, -1 };
548 
549  if( aThreshold == 0 )
550  return aP;
551 
552  if( aIndex >= 2 )
553  {
554  SEG s = aPath.CSegment( aIndex - 2 );
555 
556  if( DIRECTION_45( s ) == dragDir )
557  snap_d[0] = s.LineDistance( aP );
558 
559  snap_p[0] = s.A;
560  }
561 
562  if( aIndex < aPath.SegmentCount() - 2 )
563  {
564  SEG s = aPath.CSegment( aIndex + 2 );
565 
566  if( DIRECTION_45( s ) == dragDir )
567  snap_d[1] = s.LineDistance(aP);
568 
569  snap_p[1] = s.A;
570  }
571 
572  VECTOR2I best = aP;
573  int minDist = INT_MAX;
574 
575  for( int i = 0; i < 2; i++ )
576  {
577  if( snap_d[i] >= 0 && snap_d[i] < minDist && snap_d[i] <= aThreshold )
578  {
579  minDist = snap_d[i];
580  best = snap_p[i];
581  }
582  }
583 
584  return best;
585 }
int LineDistance(const VECTOR2I &aP, bool aDetermineSide=false) const
Function LineDistance()
Definition: seg.h:357
Class DIRECTION_45.
Definition: direction45.h:36
int SegmentCount() const
Function SegmentCount()
Definition: seg.h:36
const SEG CSegment(int aIndex) const
Function CSegment()
size_t i
Definition: json11.cpp:597
VECTOR2I A
Definition: seg.h:44

References SEG::A, SHAPE_LINE_CHAIN::CSegment(), i, SEG::LineDistance(), and SHAPE_LINE_CHAIN::SegmentCount().

Referenced by dragSegment45().

◆ Unmark()

void PNS::LINE::Unmark ( int  aMarker = -1)
overridevirtual

Reimplemented from PNS::ITEM.

Definition at line 94 of file pns_line.cpp.

95 {
96  for( SEGMENT* s : m_segmentRefs )
97  s->Unmark( aMarker );
98 
99  m_marker = 0;
100 }
int m_marker
Definition: pns_item.h:371
SEGMENT_REFS m_segmentRefs
List of segments in the owning NODE (ITEM::m_owner) that constitute this line, or NULL if the line is...
Definition: pns_line.h:288

References PNS::ITEM::m_marker, and m_segmentRefs.

Referenced by PNS::DRAGGER::dragMarkObstacles(), PNS::DRAGGER::dragShove(), and PNS::SHOVE::onCollidingSolid().

◆ Via()

◆ Walkaround() [1/2]

bool PNS::LINE::Walkaround ( SHAPE_LINE_CHAIN  aObstacle,
SHAPE_LINE_CHAIN aPre,
SHAPE_LINE_CHAIN aWalk,
SHAPE_LINE_CHAIN aPost,
bool  aCw 
) const

Calculates a line thightly wrapping a convex hull of an obstacle object (aObstacle).

aPrePath = path from origin to the obstacle aWalkaroundPath = path around the obstacle aPostPath = past from obstacle till the end aCW = whether to walk around in clockwise or counter-clockwise direction.

Definition at line 158 of file pns_line.cpp.

160 {
161  const SHAPE_LINE_CHAIN& line( CLine() );
162 
163  if( line.SegmentCount() < 1 )
164  return false;
165 
166  const auto pFirst = line.CPoint(0);
167  const auto pLast = line.CPoint(-1);
168 
169  if( aObstacle.PointInside( line.CPoint( 0 ) ) || aObstacle.PointInside( line.CPoint( -1 ) ) )
170  {
171  return false;
172  }
173 
175 
176  line.Intersect( aObstacle, ips );
177 
178  auto eFirst = aObstacle.EdgeContainingPoint( pFirst );
179  auto eLast = aObstacle.EdgeContainingPoint( pLast );
180 
181  aWalk.Clear();
182  aPost.Clear();
183 
184  int nearest_dist = INT_MAX;
185  int farthest_dist = 0;
186 
187  SHAPE_LINE_CHAIN::INTERSECTION nearest, farthest;
189 
190  if( eFirst >= 0 )
191  {
192  is.our = line.CSegment(0);
193  is.their = aObstacle.CSegment( eFirst );
194  is.p = pFirst;
195  ips.push_back(is);
196  }
197 
198  if ( eLast >= 0 )
199  {
200  is.our = line.CSegment(-1);
201  is.their = aObstacle.CSegment( eLast );
202  is.p = pLast;
203  ips.push_back(is);
204  }
205 
206  for( int i = 0; i < (int) ips.size(); i++ )
207  {
208  const VECTOR2I p = ips[i].p;
209  int dist = line.PathLength( p );
210 
211  if( dist < 0 )
212  return false;
213 
214  if( dist <= nearest_dist )
215  {
216  nearest_dist = dist;
217  nearest = ips[i];
218  }
219 
220  if( dist >= farthest_dist )
221  {
222  farthest_dist = dist;
223  farthest = ips[i];
224  }
225  }
226 
227  if( ips.size() <= 1 || nearest.p == farthest.p )
228  {
229  aPre = line;
230  return true;
231  }
232 
233  aPre = line.Slice( 0, nearest.our.Index() );
234  aPre.Append( nearest.p );
235  aPre.Simplify();
236 
237  aWalk.Clear();
238  aWalk.SetClosed( false );
239  aWalk.Append( nearest.p );
240 
241  assert( nearest.their.Index() >= 0 );
242  assert( farthest.their.Index() >= 0 );
243 
244  assert( nearest_dist <= farthest_dist );
245 
246  aObstacle.Split( nearest.p );
247  aObstacle.Split( farthest.p );
248 
249  int i_first = aObstacle.Find( nearest.p );
250  int i_last = aObstacle.Find( farthest.p );
251 
252  int i = i_first;
253 
254  if( i_first < 0 || i_last < 0 )
255  return false;
256 
257  while( i != i_last )
258  {
259  aWalk.Append( aObstacle.CPoint( i ) );
260  i += ( aCw ? 1 : -1 );
261 
262  if( i < 0 )
263  i = aObstacle.PointCount() - 1;
264  else if( i == aObstacle.PointCount() )
265  i = 0;
266  }
267 
268  aWalk.Append( farthest.p );
269  aWalk.Simplify();
270 
271  aPost.Clear();
272  aPost.Append( farthest.p );
273  aPost.Append( line.Slice( farthest.our.Index() + 1, -1 ) );
274  aPost.Simplify();
275 
276  return true;
277 }
int Find(const VECTOR2I &aP) const
Function Find()
const SHAPE_LINE_CHAIN & CLine() const
Const accessor to the underlying shape
Definition: pns_line.h:123
int Index() const
Function Index()
Definition: seg.h:314
int Split(const VECTOR2I &aP)
Function Split()
int EdgeContainingPoint(const VECTOR2I &aP, int aAccuracy=0) const
Function EdgeContainingPoint()
std::vector< INTERSECTION > INTERSECTIONS
static const int dist[10][10]
Definition: ar_matrix.cpp:320
const SHAPE_LINE_CHAIN Slice(int aStartIndex, int aEndIndex=-1) const
Function Slice()
VECTOR2I p
point of intersection between our and their.
int PointCount() const
Function PointCount()
void Append(int aX, int aY, bool aAllowDuplication=false)
Function Append()
SHAPE_LINE_CHAIN & Simplify()
Function Simplify()
const VECTOR2I & CPoint(int aIndex) const
Function CPoint()
void SetClosed(bool aClosed)
Function SetClosed()
SEG their
segment belonging from the aOther argument of Intersect()
const SEG CSegment(int aIndex) const
Function CSegment()
Class SHAPE_LINE_CHAIN.
size_t i
Definition: json11.cpp:597
void Clear()
Function Clear() Removes all points from the line chain.
bool PointInside(const VECTOR2I &aPt, int aAccuracy=0, bool aUseBBoxCache=false) const
Function PointInside()
SEG our
segment belonging from the (this) argument of Intersect()

References SHAPE_LINE_CHAIN::Append(), SHAPE_LINE_CHAIN::Clear(), CLine(), SHAPE_LINE_CHAIN::CPoint(), SHAPE_LINE_CHAIN::CSegment(), dist, SHAPE_LINE_CHAIN::EdgeContainingPoint(), SHAPE_LINE_CHAIN::Find(), i, SEG::Index(), SHAPE_LINE_CHAIN::Intersect(), SHAPE_LINE_CHAIN::INTERSECTION::our, SHAPE_LINE_CHAIN::INTERSECTION::p, SHAPE_LINE_CHAIN::PathLength(), SHAPE_LINE_CHAIN::PointCount(), SHAPE_LINE_CHAIN::PointInside(), SHAPE_LINE_CHAIN::SegmentCount(), SHAPE_LINE_CHAIN::SetClosed(), SHAPE_LINE_CHAIN::Simplify(), SHAPE_LINE_CHAIN::Slice(), SHAPE_LINE_CHAIN::Split(), and SHAPE_LINE_CHAIN::INTERSECTION::their.

Referenced by PNS::SHOVE::processHullSet(), PNS::WALKAROUND::singleStep(), Walkaround(), and PNS::SHOVE::walkaroundLoneVia().

◆ Walkaround() [2/2]

bool PNS::LINE::Walkaround ( const SHAPE_LINE_CHAIN aObstacle,
SHAPE_LINE_CHAIN aPath,
bool  aCw 
) const

Definition at line 280 of file pns_line.cpp.

281 {
282  SHAPE_LINE_CHAIN walk, post;
283 
284  if( ! Walkaround( aObstacle, aPath, walk, post, aCw ) )
285  return false;
286 
287  aPath.Append( walk );
288  aPath.Append( post );
289  aPath.Simplify();
290 
291  return true;
292 }
bool Walkaround(SHAPE_LINE_CHAIN aObstacle, SHAPE_LINE_CHAIN &aPre, SHAPE_LINE_CHAIN &aWalk, SHAPE_LINE_CHAIN &aPost, bool aCw) const
Calculates a line thightly wrapping a convex hull of an obstacle object (aObstacle).
Definition: pns_line.cpp:158
void Append(int aX, int aY, bool aAllowDuplication=false)
Function Append()
SHAPE_LINE_CHAIN & Simplify()
Function Simplify()
Class SHAPE_LINE_CHAIN.

References SHAPE_LINE_CHAIN::Append(), SHAPE_LINE_CHAIN::Simplify(), and Walkaround().

◆ Width()

Member Data Documentation

◆ m_hasVia

bool PNS::LINE::m_hasVia
private

If true, the line ends with a via

Definition at line 297 of file pns_line.h.

Referenced by AppendVia(), EndsWithVia(), LINE(), operator=(), and RemoveVia().

◆ m_kind

PnsKind PNS::ITEM::m_kind
protectedinherited

◆ m_layers

◆ m_line

◆ m_marker

◆ m_movable

bool PNS::ITEM::m_movable
protectedinherited

Definition at line 369 of file pns_item.h.

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

◆ m_net

◆ m_owner

NODE* PNS::ITEM::m_owner
protectedinherited

◆ m_parent

BOARD_CONNECTED_ITEM* PNS::ITEM::m_parent
protectedinherited

Definition at line 365 of file pns_item.h.

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

◆ m_rank

◆ m_routable

bool PNS::ITEM::m_routable
protectedinherited

Definition at line 373 of file pns_item.h.

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

◆ m_segmentRefs

SEGMENT_REFS PNS::LINE::m_segmentRefs
private

List of segments in the owning NODE (ITEM::m_owner) that constitute this line, or NULL if the line is not a part of any node.

Definition at line 288 of file pns_line.h.

Referenced by ClearSegmentLinks(), ClipVertexRange(), ContainsSegment(), copyLinks(), GetLink(), HasLockedSegments(), IsLinked(), LinkCount(), LinkedSegments(), LinkSegment(), Mark(), Marker(), Rank(), Reverse(), SetRank(), ShowLinks(), and Unmark().

◆ m_via

VIA PNS::LINE::m_via
private

Via at the end point, if m_hasVia == true

Definition at line 300 of file pns_line.h.

Referenced by AppendVia(), LINE(), operator=(), and Via().

◆ m_width

int PNS::LINE::m_width
private

our width

Definition at line 294 of file pns_line.h.

Referenced by LINE(), operator=(), SetWidth(), and Width().

◆ UnusedNet

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

Definition at line 56 of file pns_item.h.

Referenced by PNS::ITEM::InAnyNet(), and PNS::ITEM::ITEM().


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