KiCad PCB EDA Suite
PNS::DIFF_PAIR Class Reference

Class DIFF_PAIR. More...

#include <pns_diff_pair.h>

Inheritance diagram for PNS::DIFF_PAIR:
PNS::ITEM

Classes

struct  COUPLED_SEGMENTS
 

Public Types

typedef std::vector< COUPLED_SEGMENTSCOUPLED_SEGMENTS_VEC
 
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

 DIFF_PAIR ()
 
 DIFF_PAIR (int aGap)
 
 DIFF_PAIR (const SHAPE_LINE_CHAIN &aP, const SHAPE_LINE_CHAIN &aN, int aGap=0)
 
 DIFF_PAIR (const LINE &aLineP, const LINE &aLineN, int aGap=0)
 
DIFF_PAIRClone () const override
 Function Clone() More...
 
void SetShape (const SHAPE_LINE_CHAIN &aP, const SHAPE_LINE_CHAIN &aN, bool aSwapLanes=false)
 
void SetShape (const DIFF_PAIR &aPair)
 
void SetNets (int aP, int aN)
 
void SetWidth (int aWidth)
 
int Width () const
 
void SetGap (int aGap)
 
int Gap () const
 
void AppendVias (const VIA &aViaP, const VIA &aViaN)
 
void RemoveVias ()
 
bool EndsWithVias () const
 
int NetP () const
 
int NetN () const
 
LINEPLine ()
 
LINENLine ()
 
DP_PRIMITIVE_PAIR EndingPrimitives ()
 
double CoupledLength () const
 
double TotalLength () const
 
double CoupledLengthFactor () const
 
double Skew () const
 
void CoupledSegmentPairs (COUPLED_SEGMENTS_VEC &aPairs) const
 
void Clear ()
 
void Append (const DIFF_PAIR &aOther)
 
bool Empty () const
 
const SHAPE_LINE_CHAINCP () const
 
const SHAPE_LINE_CHAINCN () const
 
bool BuildInitial (const DP_GATEWAY &aEntry, const DP_GATEWAY &aTarget, bool aPrefDiagonal)
 
bool CheckConnectionAngle (const DIFF_PAIR &aOther, int allowedAngles) const
 
int CoupledLength (const SEG &aP, const SEG &aN) const
 
int64_t CoupledLength (const SHAPE_LINE_CHAIN &aP, const SHAPE_LINE_CHAIN &aN) const
 
const RANGED_NUM< int > GapConstraint () 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...
 
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 const SHAPEShape () const
 Function Shape() 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
 
virtual VECTOR2I Anchor (int n) const
 
virtual int AnchorCount () const
 
bool IsLocked () const
 

Static Public Member Functions

static bool ClassOf (const ITEM *aItem)
 
static DIFF_PAIRAssembleDp (LINE *aLine)
 

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 Member Functions

void updateLine (LINE &aLine, const SHAPE_LINE_CHAIN &aShape, int aNet, VIA &aVia)
 

Private Attributes

SHAPE_LINE_CHAIN m_n
 
SHAPE_LINE_CHAIN m_p
 
LINE m_line_p
 
LINE m_line_n
 
VIA m_via_p
 
VIA m_via_n
 
bool m_hasVias
 
int m_net_p
 
int m_net_n
 
int m_width
 
int m_gap
 
int m_viaGap
 
int m_maxUncoupledLength
 
int m_chamferLimit
 
RANGED_NUM< int > m_gapConstraint
 

Detailed Description

Class DIFF_PAIR.

Basic class for a differential pair. Stores two PNS_LINEs (for positive and negative nets, respectively), the gap and coupling constraints.

Definition at line 265 of file pns_diff_pair.h.

Member Typedef Documentation

Definition at line 287 of file pns_diff_pair.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::DIFF_PAIR::DIFF_PAIR ( )
inline

Definition at line 289 of file pns_diff_pair.h.

References m_chamferLimit, m_gap, m_maxUncoupledLength, m_net_n, m_net_p, m_viaGap, and m_width.

289  : ITEM( DIFF_PAIR_T ), m_hasVias( false )
290  {
291  // Initialize some members, to avoid uninitialized variables.
292  m_net_p = 0;
293  m_net_n = 0;;
294  m_width = 0;
295  m_gap = 0;
296  m_viaGap = 0;
298  m_chamferLimit = 0;
299  }
ITEM(PnsKind aKind)
Definition: pns_item.h:70
PNS::DIFF_PAIR::DIFF_PAIR ( int  aGap)
inline

Definition at line 301 of file pns_diff_pair.h.

References m_chamferLimit, m_gap, m_gapConstraint, m_maxUncoupledLength, m_net_n, m_net_p, m_viaGap, and m_width.

301  :
302  ITEM( DIFF_PAIR_T ),
303  m_hasVias( false )
304  {
305  m_gapConstraint = aGap;
306 
307  // Initialize other members, to avoid uninitialized variables.
308  m_net_p = 0;
309  m_net_n = 0;;
310  m_width = 0;
311  m_gap = 0;
312  m_viaGap = 0;
314  m_chamferLimit = 0;
315  }
RANGED_NUM< int > m_gapConstraint
ITEM(PnsKind aKind)
Definition: pns_item.h:70
PNS::DIFF_PAIR::DIFF_PAIR ( const SHAPE_LINE_CHAIN aP,
const SHAPE_LINE_CHAIN aN,
int  aGap = 0 
)
inline

Definition at line 317 of file pns_diff_pair.h.

References m_chamferLimit, m_gap, m_gapConstraint, m_maxUncoupledLength, m_net_n, m_net_p, m_viaGap, and m_width.

317  :
318  ITEM( DIFF_PAIR_T ),
319  m_n( aN ),
320  m_p( aP ),
321  m_hasVias( false )
322  {
323  m_gapConstraint = aGap;
324 
325  // Initialize other members, to avoid uninitialized variables.
326  m_net_p = 0;
327  m_net_n = 0;;
328  m_width = 0;
329  m_gap = 0;
330  m_viaGap = 0;
332  m_chamferLimit = 0;
333  }
RANGED_NUM< int > m_gapConstraint
ITEM(PnsKind aKind)
Definition: pns_item.h:70
SHAPE_LINE_CHAIN m_p
SHAPE_LINE_CHAIN m_n
PNS::DIFF_PAIR::DIFF_PAIR ( const LINE aLineP,
const LINE aLineN,
int  aGap = 0 
)
inline

Definition at line 335 of file pns_diff_pair.h.

References PNS::LINE::CLine(), m_chamferLimit, m_gap, m_gapConstraint, m_maxUncoupledLength, m_n, m_net_n, m_net_p, m_p, m_viaGap, m_width, and PNS::ITEM::Net().

335  :
336  ITEM( DIFF_PAIR_T ),
337  m_line_p( aLineP ),
338  m_line_n( aLineN ),
339  m_hasVias( false )
340  {
341  m_gapConstraint = aGap;
342  m_net_p = aLineP.Net();
343  m_net_n = aLineN.Net();
344  m_p = aLineP.CLine();
345  m_n = aLineN.CLine();
346 
347  // Do not leave unitialized members, and keep static analyser quiet:
348  m_width = 0;
349  m_gap = 0;
350  m_viaGap = 0;
352  m_chamferLimit = 0;
353  }
RANGED_NUM< int > m_gapConstraint
ITEM(PnsKind aKind)
Definition: pns_item.h:70
SHAPE_LINE_CHAIN m_p
SHAPE_LINE_CHAIN m_n

Member Function Documentation

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

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

Definition at line 326 of file pns_item.h.

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

327  {
328  return VECTOR2I();
329  }
VECTOR2< int > VECTOR2I
Definition: vector2d.h:590
virtual int PNS::ITEM::AnchorCount ( ) const
inlinevirtualinherited

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

Definition at line 331 of file pns_item.h.

332  {
333  return 0;
334  }
void PNS::DIFF_PAIR::Append ( const DIFF_PAIR aOther)
inline

Definition at line 466 of file pns_diff_pair.h.

References SHAPE_LINE_CHAIN::Append(), m_n, and m_p.

467  {
468  m_n.Append( aOther.m_n );
469  m_p.Append( aOther.m_p );
470  }
void Append(int aX, int aY, bool aAllowDuplication=false)
Function Append()
SHAPE_LINE_CHAIN m_p
SHAPE_LINE_CHAIN m_n
void PNS::DIFF_PAIR::AppendVias ( const VIA aViaP,
const VIA aViaN 
)
inline

Definition at line 408 of file pns_diff_pair.h.

References m_hasVias, m_via_n, and m_via_p.

Referenced by PNS::DIFF_PAIR_PLACER::routeHead().

409  {
410  m_hasVias = true;
411  m_via_p = aViaP;
412  m_via_n = aViaN;
413  }
static DIFF_PAIR* PNS::DIFF_PAIR::AssembleDp ( LINE aLine)
static
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
bool PNS::DIFF_PAIR::BuildInitial ( const DP_GATEWAY aEntry,
const DP_GATEWAY aTarget,
bool  aPrefDiagonal 
)

Definition at line 215 of file pns_diff_pair.cpp.

References PNS::DP_GATEWAY::AllowedAngles(), PNS::DP_GATEWAY::AnchorN(), PNS::DP_GATEWAY::AnchorP(), DIRECTION_45::ANG_OBTUSE, DIRECTION_45::ANG_STRAIGHT, SHAPE_LINE_CHAIN::Append(), DIRECTION_45::BuildInitialTrace(), CheckConnectionAngle(), PNS::checkGap(), CN(), CP(), PNS::DP_GATEWAY::Entry(), PNS::DP_GATEWAY::HasEntryLines(), SHAPE_LINE_CHAIN::Intersects(), m_gapConstraint, m_n, m_p, PNS::DP_GATEWAY::Reverse(), and SHAPE_LINE_CHAIN::SelfIntersecting().

Referenced by PNS::DP_GATEWAYS::FitGateways().

216 {
217  SHAPE_LINE_CHAIN p = DIRECTION_45().BuildInitialTrace ( aEntry.AnchorP(), aTarget.AnchorP(), aPrefDiagonal );
218  SHAPE_LINE_CHAIN n = DIRECTION_45().BuildInitialTrace ( aEntry.AnchorN(), aTarget.AnchorN(), aPrefDiagonal );
219 
220  int mask = aEntry.AllowedAngles() | DIRECTION_45::ANG_STRAIGHT | DIRECTION_45::ANG_OBTUSE;
221 
222  SHAPE_LINE_CHAIN sum_n, sum_p;
223  m_p = p;
224  m_n = n;
225 
226  if( aEntry.HasEntryLines() )
227  {
228  if( !aEntry.Entry().CheckConnectionAngle( *this, mask ) )
229  return false;
230 
231  sum_p = aEntry.Entry().CP();
232  sum_n = aEntry.Entry().CN();
233  sum_p.Append( p );
234  sum_n.Append( n );
235  }
236  else
237  {
238  sum_p = p;
239  sum_n = n;
240  }
241 
242  mask = aTarget.AllowedAngles() | DIRECTION_45::ANG_STRAIGHT | DIRECTION_45::ANG_OBTUSE;
243 
244  m_p = sum_p;
245  m_n = sum_n;
246 
247  if( aTarget.HasEntryLines() )
248  {
249  DP_GATEWAY t(aTarget) ;
250  t.Reverse();
251 
252  if( !CheckConnectionAngle( t.Entry(), mask ) )
253  return false;
254 
255  sum_p.Append( t.Entry().CP() );
256  sum_n.Append( t.Entry().CN() );
257  }
258 
259  m_p = sum_p;
260  m_n = sum_n;
261 
262  if( !checkGap ( p, n, m_gapConstraint ) )
263  return false;
264 
265  if( p.SelfIntersecting() || n.SelfIntersecting() )
266  return false;
267 
268  if( p.Intersects( n ) )
269  return false;
270 
271  return true;
272 }
static bool checkGap(const SHAPE_LINE_CHAIN &p, const SHAPE_LINE_CHAIN &n, int gap)
RANGED_NUM< int > m_gapConstraint
void Append(int aX, int aY, bool aAllowDuplication=false)
Function Append()
const boost::optional< INTERSECTION > SelfIntersecting() const
Function SelfIntersecting()
bool Intersects(const SHAPE_LINE_CHAIN &aChain) const
SHAPE_LINE_CHAIN m_p
bool CheckConnectionAngle(const DIFF_PAIR &aOther, int allowedAngles) const
Class DIRECTION_45.
Definition: direction45.h:33
SHAPE_LINE_CHAIN m_n
Class SHAPE_LINE_CHAIN.
const SHAPE_LINE_CHAIN BuildInitialTrace(const VECTOR2I &aP0, const VECTOR2I &aP1, bool aStartDiagonal=false) const
Function BuildInitialTrace()
Definition: direction45.h:199
bool PNS::DIFF_PAIR::CheckConnectionAngle ( const DIFF_PAIR aOther,
int  allowedAngles 
) const

Definition at line 275 of file pns_diff_pair.cpp.

References SHAPE_LINE_CHAIN::CSegment(), m_n, m_p, and SHAPE_LINE_CHAIN::SegmentCount().

Referenced by BuildInitial().

276 {
277  bool checkP, checkN;
278 
279  if( m_p.SegmentCount() == 0 || aOther.m_p.SegmentCount() == 0 )
280  checkP = true;
281  else
282  {
283  DIRECTION_45 p0( m_p.CSegment( -1 ) );
284  DIRECTION_45 p1( aOther.m_p.CSegment( 0 ) );
285 
286  checkP = ( p0.Angle( p1 ) & aAllowedAngles ) != 0;
287  }
288 
289  if( m_n.SegmentCount() == 0 || aOther.m_n.SegmentCount() == 0 )
290  checkN = true;
291  else
292  {
293  DIRECTION_45 n0( m_n.CSegment( -1 ) );
294  DIRECTION_45 n1( aOther.m_n.CSegment( 0 ) );
295 
296  checkN = ( n0.Angle( n1 ) & aAllowedAngles ) != 0;
297  }
298 
299  return checkP && checkN;
300 }
const SEG CSegment(int aIndex) const
Function CSegment()
SHAPE_LINE_CHAIN m_p
Class DIRECTION_45.
Definition: direction45.h:33
SHAPE_LINE_CHAIN m_n
int SegmentCount() const
Function SegmentCount()
static bool PNS::DIFF_PAIR::ClassOf ( const ITEM aItem)
inlinestatic

Definition at line 355 of file pns_diff_pair.h.

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

356  {
357  return aItem && DIFF_PAIR_T == aItem->Kind();
358  }
void PNS::DIFF_PAIR::Clear ( )
inline

Definition at line 460 of file pns_diff_pair.h.

References SHAPE_LINE_CHAIN::Clear(), m_n, and m_p.

461  {
462  m_n.Clear();
463  m_p.Clear();
464  }
SHAPE_LINE_CHAIN m_p
SHAPE_LINE_CHAIN m_n
void Clear()
Function Clear() Removes all points from the line chain.
DIFF_PAIR* PNS::DIFF_PAIR::Clone ( ) const
inlineoverridevirtual

Function Clone()

Returns a deep copy of the item

Implements PNS::ITEM.

Definition at line 360 of file pns_diff_pair.h.

360 { assert( false ); return NULL; }
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...
double PNS::DIFF_PAIR::CoupledLength ( ) const

Definition at line 870 of file pns_diff_pair.cpp.

References CoupledSegmentPairs().

Referenced by CoupledLengthFactor(), PNS::OPTIMIZER::mergeDpStep(), and PNS::DIFF_PAIR_PLACER::tryWalkDp().

871 {
872  COUPLED_SEGMENTS_VEC pairs;
873 
874  CoupledSegmentPairs( pairs );
875 
876  double l = 0.0;
877  for( unsigned int i = 0; i < pairs.size(); i++ )
878  l += pairs[i].coupledP.Length();
879 
880  return l;
881 }
std::vector< COUPLED_SEGMENTS > COUPLED_SEGMENTS_VEC
void CoupledSegmentPairs(COUPLED_SEGMENTS_VEC &aPairs) const
int PNS::DIFF_PAIR::CoupledLength ( const SEG aP,
const SEG aN 
) const

Definition at line 904 of file pns_diff_pair.cpp.

References abs, SEG::ApproxParallel(), PNS::commonParallelProjection(), dist, SEG::Distance(), SEG::Length(), m_gapConstraint, m_width, and RANGED_NUM< T >::Matches().

905 {
906  SEG p_clip, n_clip;
907  int64_t dist = std::abs( aP.Distance( aN ) - m_width );
908 
909  if( aP.ApproxParallel( aN ) && m_gapConstraint.Matches( dist ) &&
910  commonParallelProjection ( aP, aN, p_clip, n_clip ) )
911  return p_clip.Length();
912 
913  return 0;
914 }
int Length() const
Function Length()
Definition: seg.h:325
RANGED_NUM< int > m_gapConstraint
static const int dist[10][10]
Definition: dist.cpp:57
#define abs(a)
Definition: auxiliary.h:84
Definition: seg.h:37
bool Matches(const T &aOther) const
Definition: ranged_num.h:43
bool ApproxParallel(const SEG &aSeg) const
Definition: seg.h:286
int Distance(const SEG &aSeg) const
Function Distance()
Definition: seg.h:228
bool commonParallelProjection(SEG n, SEG p, SEG &pClip, SEG &nClip)
int64_t PNS::DIFF_PAIR::CoupledLength ( const SHAPE_LINE_CHAIN aP,
const SHAPE_LINE_CHAIN aN 
) const

Definition at line 845 of file pns_diff_pair.cpp.

References abs, SEG::ApproxParallel(), PNS::commonParallelProjection(), SHAPE_LINE_CHAIN::CSegment(), dist, SEG::Distance(), SEG::Length(), m_gapConstraint, m_width, RANGED_NUM< T >::Matches(), and SHAPE_LINE_CHAIN::SegmentCount().

846 {
847  int64_t total = 0;
848 
849  for( int i = 0; i < aP.SegmentCount(); i++ )
850  {
851  for( int j = 0; j < aN.SegmentCount(); j++ )
852  {
853  SEG sp = aP.CSegment( i );
854  SEG sn = aN.CSegment( j );
855 
856  SEG p_clip, n_clip;
857 
858  int64_t dist = std::abs( sp.Distance(sn) - m_width );
859 
860  if( sp.ApproxParallel( sn ) && m_gapConstraint.Matches( dist ) &&
861  commonParallelProjection( sp, sn, p_clip, n_clip ) )
862  total += p_clip.Length();
863  }
864  }
865 
866  return total;
867 }
int Length() const
Function Length()
Definition: seg.h:325
RANGED_NUM< int > m_gapConstraint
static const int dist[10][10]
Definition: dist.cpp:57
#define abs(a)
Definition: auxiliary.h:84
const SEG CSegment(int aIndex) const
Function CSegment()
Definition: seg.h:37
bool Matches(const T &aOther) const
Definition: ranged_num.h:43
bool ApproxParallel(const SEG &aSeg) const
Definition: seg.h:286
int Distance(const SEG &aSeg) const
Function Distance()
Definition: seg.h:228
int SegmentCount() const
Function SegmentCount()
bool commonParallelProjection(SEG n, SEG p, SEG &pClip, SEG &nClip)
double PNS::DIFF_PAIR::CoupledLengthFactor ( ) const

Definition at line 884 of file pns_diff_pair.cpp.

References CoupledLength(), and TotalLength().

885 {
886  double t = TotalLength();
887 
888  if( t == 0.0 )
889  return 0.0;
890 
891  return CoupledLength() / t;
892 }
double CoupledLength() const
double TotalLength() const
void PNS::DIFF_PAIR::CoupledSegmentPairs ( COUPLED_SEGMENTS_VEC aPairs) const

Definition at line 816 of file pns_diff_pair.cpp.

References abs, SEG::ApproxParallel(), PNS::commonParallelProjection(), SHAPE_LINE_CHAIN::CSegment(), dist, SEG::Distance(), m_gapConstraint, m_n, m_p, m_width, RANGED_NUM< T >::Matches(), SHAPE_LINE_CHAIN::SegmentCount(), and SHAPE_LINE_CHAIN::Simplify().

Referenced by CoupledLength().

817 {
818  SHAPE_LINE_CHAIN p( m_p );
819  SHAPE_LINE_CHAIN n( m_n );
820 
821  p.Simplify();
822  n.Simplify();
823 
824  for( int i = 0; i < p.SegmentCount(); i++ )
825  {
826  for( int j = 0; j < n.SegmentCount(); j++ )
827  {
828  SEG sp = p.CSegment( i );
829  SEG sn = n.CSegment( j );
830 
831  SEG p_clip, n_clip;
832 
833  int64_t dist = std::abs( sp.Distance( sn ) - m_width );
834 
835  if( sp.ApproxParallel( sn ) && m_gapConstraint.Matches( dist ) && commonParallelProjection( sp, sn, p_clip, n_clip ) )
836  {
837  const COUPLED_SEGMENTS spair( p_clip, sp, i, n_clip, sn, j );
838  aPairs.push_back( spair );
839  }
840  }
841  }
842 }
RANGED_NUM< int > m_gapConstraint
static const int dist[10][10]
Definition: dist.cpp:57
#define abs(a)
Definition: auxiliary.h:84
SHAPE_LINE_CHAIN m_p
SHAPE_LINE_CHAIN m_n
Definition: seg.h:37
Class SHAPE_LINE_CHAIN.
bool Matches(const T &aOther) const
Definition: ranged_num.h:43
bool ApproxParallel(const SEG &aSeg) const
Definition: seg.h:286
int Distance(const SEG &aSeg) const
Function Distance()
Definition: seg.h:228
bool commonParallelProjection(SEG n, SEG p, SEG &pClip, SEG &nClip)
bool PNS::DIFF_PAIR::Empty ( ) const
inline

Definition at line 472 of file pns_diff_pair.h.

References m_n, m_p, and SHAPE_LINE_CHAIN::SegmentCount().

473  {
474  return ( m_n.SegmentCount() == 0 ) || ( m_p.SegmentCount() == 0 );
475  }
SHAPE_LINE_CHAIN m_p
SHAPE_LINE_CHAIN m_n
int SegmentCount() const
Function SegmentCount()
DP_PRIMITIVE_PAIR PNS::DIFF_PAIR::EndingPrimitives ( )

Definition at line 748 of file pns_diff_pair.cpp.

References PNS::LINE::CSegment(), m_hasVias, m_via_n, m_via_p, NLine(), and PLine().

Referenced by PNS::DIFF_PAIR_PLACER::FixRoute().

749 {
750  if( m_hasVias )
751  return DP_PRIMITIVE_PAIR( &m_via_p, &m_via_n );
752  else
753  {
754  const LINE lP( PLine() );
755  const LINE lN( NLine() );
756 
757  SEGMENT sP( lP, lP.CSegment( -1 ) );
758  SEGMENT sN( lN, lN.CSegment( -1 ) );
759 
760  DP_PRIMITIVE_PAIR dpair( &sP, &sN );
761  dpair.SetAnchors( sP.Seg().B, sN.Seg().B );
762 
763  return dpair;
764  }
765 }
Struct SEGMENT is a simple container used when filling areas with segments.
Definition: class_zone.h:57
bool PNS::DIFF_PAIR::EndsWithVias ( ) const
inline

Definition at line 420 of file pns_diff_pair.h.

References m_hasVias.

Referenced by PNS::DIFF_PAIR_PLACER::FixRoute().

421  {
422  return m_hasVias;
423  }
int PNS::DIFF_PAIR::Gap ( ) const
inline
const RANGED_NUM<int> PNS::DIFF_PAIR::GapConstraint ( ) const
inline

Definition at line 486 of file pns_diff_pair.h.

References m_gapConstraint.

Referenced by PNS::findCoupledVertices().

487  {
488  return m_gapConstraint;
489  }
RANGED_NUM< int > m_gapConstraint
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 110 of file pns_item.h.

111  {
112  return SHAPE_LINE_CHAIN();
113  }
Class SHAPE_LINE_CHAIN.
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
int PNS::DIFF_PAIR::NetN ( ) const
inline

Definition at line 430 of file pns_diff_pair.h.

References m_net_n.

Referenced by PNS::DIFF_PAIR_PLACER::attemptWalk(), and PNS::DP_MEANDER_PLACER::CurrentNets().

431  {
432  return m_net_n;
433  }
int PNS::DIFF_PAIR::NetP ( ) const
inline

Definition at line 425 of file pns_diff_pair.h.

References m_net_p.

Referenced by PNS::DIFF_PAIR_PLACER::attemptWalk(), and PNS::DP_MEANDER_PLACER::CurrentNets().

426  {
427  return m_net_p;
428  }
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
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::DIFF_PAIR::RemoveVias ( )
inline

Definition at line 415 of file pns_diff_pair.h.

References m_hasVias.

416  {
417  m_hasVias = false;
418  }
void PNS::DIFF_PAIR::SetGap ( int  aGap)
inline
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 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::DIFF_PAIR::SetNets ( int  aP,
int  aN 
)
inline

Definition at line 384 of file pns_diff_pair.h.

References m_net_n, and m_net_p.

Referenced by PNS::DIFF_PAIR_PLACER::routeHead().

385  {
386  m_net_p = aP;
387  m_net_n = aN;
388  }
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
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::DIFF_PAIR::SetShape ( const SHAPE_LINE_CHAIN aP,
const SHAPE_LINE_CHAIN aN,
bool  aSwapLanes = false 
)
inline

Definition at line 364 of file pns_diff_pair.h.

References m_n, and m_p.

Referenced by PNS::DIFF_PAIR_PLACER::attemptWalk(), PNS::DP_GATEWAYS::FitGateways(), PNS::DIFF_PAIR_PLACER::FixRoute(), PNS::OPTIMIZER::mergeDpStep(), and PNS::DIFF_PAIR_PLACER::tryWalkDp().

365  {
366  if( aSwapLanes )
367  {
368  m_p = aN;
369  m_n = aP;
370  }
371  else
372  {
373  m_p = aP;
374  m_n = aN;
375  }
376  }
SHAPE_LINE_CHAIN m_p
SHAPE_LINE_CHAIN m_n
void PNS::DIFF_PAIR::SetShape ( const DIFF_PAIR aPair)
inline

Definition at line 378 of file pns_diff_pair.h.

References m_n, and m_p.

379  {
380  m_p = aPair.m_p;
381  m_n = aPair.m_n;
382  }
SHAPE_LINE_CHAIN m_p
SHAPE_LINE_CHAIN m_n
void PNS::DIFF_PAIR::SetWidth ( int  aWidth)
inline

Definition at line 390 of file pns_diff_pair.h.

References m_width.

Referenced by PNS::TOPOLOGY::AssembleDiffPair(), and PNS::DIFF_PAIR_PLACER::routeHead().

391  {
392  m_width = aWidth;
393  }
virtual const SHAPE* PNS::ITEM::Shape ( ) const
inlinevirtualinherited

Function Shape()

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

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

Definition at line 296 of file pns_item.h.

Referenced by PNS::DP_GATEWAYS::BuildFromPrimitivePair(), PNS::OPTIMIZER::checkColliding(), PNS::ITEM::collideSimple(), PNS::OPTIMIZER::computeBreakouts(), PNS::LOGGER::Log(), PNS::SHOVE::onCollidingVia(), PNS::HIT_VISITOR::operator()(), PNS::INDEX::Query(), and ROUTER_PREVIEW_ITEM::Update().

297  {
298  return NULL;
299  }
double PNS::DIFF_PAIR::Skew ( ) const

Definition at line 810 of file pns_diff_pair.cpp.

References SHAPE_LINE_CHAIN::Length(), m_n, and m_p.

Referenced by PNS::DIFF_PAIR_PLACER::tryWalkDp().

811 {
812  return m_p.Length() - m_n.Length();
813 }
SHAPE_LINE_CHAIN m_p
SHAPE_LINE_CHAIN m_n
int Length() const
Function Length()
double PNS::DIFF_PAIR::TotalLength ( ) const

Definition at line 895 of file pns_diff_pair.cpp.

References SHAPE_LINE_CHAIN::Length(), m_n, and m_p.

Referenced by CoupledLengthFactor().

896 {
897  double lenP = m_p.Length();
898  double lenN = m_n.Length();
899 
900  return (lenN + lenP ) / 2.0;
901 }
SHAPE_LINE_CHAIN m_p
SHAPE_LINE_CHAIN m_n
int Length() const
Function Length()
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
void PNS::DIFF_PAIR::updateLine ( LINE aLine,
const SHAPE_LINE_CHAIN aShape,
int  aNet,
VIA aVia 
)
inlineprivate

Definition at line 492 of file pns_diff_pair.h.

References PNS::LINE::AppendVia(), PNS::ITEM::Layers(), m_hasVias, m_width, PNS::ITEM::SetLayer(), PNS::ITEM::SetNet(), PNS::LINE::SetShape(), and PNS::LINE::SetWidth().

Referenced by NLine(), and PLine().

493  {
494  aLine.SetShape( aShape );
495  aLine.SetWidth( m_width );
496  aLine.SetNet( aNet );
497  aLine.SetLayer( Layers().Start() );
498 
499  if( m_hasVias )
500  aLine.AppendVia( aVia );
501  }
const LAYER_RANGE & Layers() const
Function Layers()
Definition: pns_item.h:207
int PNS::DIFF_PAIR::Width ( ) const
inline

Definition at line 395 of file pns_diff_pair.h.

References m_width.

Referenced by PNS::findCoupledVertices(), and PNS::DP_MEANDER_PLACER::Start().

395 { return m_width; }

Member Data Documentation

int PNS::DIFF_PAIR::m_chamferLimit
private

Definition at line 513 of file pns_diff_pair.h.

Referenced by DIFF_PAIR().

int PNS::DIFF_PAIR::m_gap
private

Definition at line 510 of file pns_diff_pair.h.

Referenced by DIFF_PAIR(), Gap(), and SetGap().

RANGED_NUM<int> PNS::DIFF_PAIR::m_gapConstraint
private
bool PNS::DIFF_PAIR::m_hasVias
private

Definition at line 507 of file pns_diff_pair.h.

Referenced by AppendVias(), EndingPrimitives(), EndsWithVias(), RemoveVias(), and updateLine().

PnsKind PNS::ITEM::m_kind
protectedinherited
LINE PNS::DIFF_PAIR::m_line_n
private

Definition at line 504 of file pns_diff_pair.h.

Referenced by NLine().

LINE PNS::DIFF_PAIR::m_line_p
private

Definition at line 504 of file pns_diff_pair.h.

Referenced by PLine().

int PNS::DIFF_PAIR::m_maxUncoupledLength
private

Definition at line 512 of file pns_diff_pair.h.

Referenced by DIFF_PAIR().

bool PNS::ITEM::m_movable
protectedinherited
int PNS::DIFF_PAIR::m_net_n
private

Definition at line 508 of file pns_diff_pair.h.

Referenced by DIFF_PAIR(), NetN(), NLine(), and SetNets().

int PNS::DIFF_PAIR::m_net_p
private

Definition at line 508 of file pns_diff_pair.h.

Referenced by DIFF_PAIR(), NetP(), PLine(), and SetNets().

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

VIA PNS::DIFF_PAIR::m_via_n
private

Definition at line 505 of file pns_diff_pair.h.

Referenced by AppendVias(), EndingPrimitives(), and NLine().

VIA PNS::DIFF_PAIR::m_via_p
private

Definition at line 505 of file pns_diff_pair.h.

Referenced by AppendVias(), EndingPrimitives(), and PLine().

int PNS::DIFF_PAIR::m_viaGap
private

Definition at line 511 of file pns_diff_pair.h.

Referenced by DIFF_PAIR().

int PNS::DIFF_PAIR::m_width
private
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: