KiCad PCB EDA Suite
PNS::DP_PRIMITIVE_PAIR Class Reference

Store starting/ending primitives (pads, vias or segments) for a differential pair. More...

#include <pns_diff_pair.h>

Public Member Functions

 DP_PRIMITIVE_PAIR ()
 
 DP_PRIMITIVE_PAIR (const DP_PRIMITIVE_PAIR &aOther)
 
 DP_PRIMITIVE_PAIR (ITEM *aPrimP, ITEM *aPrimN)
 
 DP_PRIMITIVE_PAIR (const VECTOR2I &aAnchorP, const VECTOR2I &aAnchorN)
 
 ~DP_PRIMITIVE_PAIR ()
 
void SetAnchors (const VECTOR2I &aAnchorP, const VECTOR2I &aAnchorN)
 
const VECTOR2IAnchorP () const
 
const VECTOR2IAnchorN () const
 
DP_PRIMITIVE_PAIRoperator= (const DP_PRIMITIVE_PAIR &aOther)
 
ITEMPrimP () const
 
ITEMPrimN () const
 
bool Directional () const
 
DIRECTION_45 DirP () const
 
DIRECTION_45 DirN () const
 
void CursorOrientation (const VECTOR2I &aCursorPos, VECTOR2I &aMidpoint, VECTOR2I &aDirection) const
 
void dump ()
 

Private Member Functions

DIRECTION_45 anchorDirection (const ITEM *aItem, const VECTOR2I &aP) const
 

Private Attributes

ITEMm_primP
 
ITEMm_primN
 
VECTOR2I m_anchorP
 
VECTOR2I m_anchorN
 

Detailed Description

Store starting/ending primitives (pads, vias or segments) for a differential pair.

Definition at line 119 of file pns_diff_pair.h.

Constructor & Destructor Documentation

◆ DP_PRIMITIVE_PAIR() [1/4]

PNS::DP_PRIMITIVE_PAIR::DP_PRIMITIVE_PAIR ( )
inline

Definition at line 122 of file pns_diff_pair.h.

122  :
123  m_primP( nullptr ), m_primN( nullptr ) {};

◆ DP_PRIMITIVE_PAIR() [2/4]

PNS::DP_PRIMITIVE_PAIR::DP_PRIMITIVE_PAIR ( const DP_PRIMITIVE_PAIR aOther)

Definition at line 62 of file pns_diff_pair.cpp.

63 {
64  m_primP = m_primN = nullptr;
65 
66  if( aOther.m_primP )
67  m_primP = aOther.m_primP->Clone();
68 
69  if( aOther.m_primN )
70  m_primN = aOther.m_primN->Clone();
71 
72  m_anchorP = aOther.m_anchorP;
73  m_anchorN = aOther.m_anchorN;
74 }
virtual ITEM * Clone() const =0
Return a deep copy of the item.

References PNS::ITEM::Clone(), m_anchorN, m_anchorP, m_primN, and m_primP.

◆ DP_PRIMITIVE_PAIR() [3/4]

PNS::DP_PRIMITIVE_PAIR::DP_PRIMITIVE_PAIR ( ITEM aPrimP,
ITEM aPrimN 
)

Definition at line 37 of file pns_diff_pair.cpp.

38 {
39  m_primP = aPrimP->Clone();
40  m_primN = aPrimN->Clone();
41 
42  m_anchorP = m_primP->Anchor( 0 );
43  m_anchorN = m_primN->Anchor( 0 );
44 }
virtual ITEM * Clone() const =0
Return a deep copy of the item.
virtual VECTOR2I Anchor(int n) const
Definition: pns_item.h:215

References PNS::ITEM::Anchor(), PNS::ITEM::Clone(), m_anchorN, m_anchorP, m_primN, and m_primP.

◆ DP_PRIMITIVE_PAIR() [4/4]

PNS::DP_PRIMITIVE_PAIR::DP_PRIMITIVE_PAIR ( const VECTOR2I aAnchorP,
const VECTOR2I aAnchorN 
)

Definition at line 54 of file pns_diff_pair.cpp.

55 {
56  m_anchorP = aAnchorP;
57  m_anchorN = aAnchorN;
58  m_primP = m_primN = nullptr;
59 }

References m_anchorN, m_anchorP, m_primN, and m_primP.

◆ ~DP_PRIMITIVE_PAIR()

PNS::DP_PRIMITIVE_PAIR::~DP_PRIMITIVE_PAIR ( )

Definition at line 91 of file pns_diff_pair.cpp.

92 {
93  delete m_primP;
94  delete m_primN;
95 }

References m_primN, and m_primP.

Member Function Documentation

◆ anchorDirection()

DIRECTION_45 PNS::DP_PRIMITIVE_PAIR::anchorDirection ( const ITEM aItem,
const VECTOR2I aP 
) const
private

Definition at line 107 of file pns_diff_pair.cpp.

108 {
109  if( !aItem->OfKind ( ITEM::SEGMENT_T | ITEM::ARC_T ) )
110  return DIRECTION_45();
111 
112  if( aItem->Anchor( 0 ) == aP )
113  return DIRECTION_45( aItem->Anchor( 0 ) - aItem->Anchor( 1 ) );
114  else
115  return DIRECTION_45( aItem->Anchor( 1 ) - aItem->Anchor( 0 ) );
116 }
Represent route directions & corner angles in a 45-degree metric.
Definition: direction45.h:36

References PNS::ITEM::Anchor(), PNS::ITEM::ARC_T, PNS::ITEM::OfKind(), and PNS::ITEM::SEGMENT_T.

Referenced by DirN(), and DirP().

◆ AnchorN()

const VECTOR2I& PNS::DP_PRIMITIVE_PAIR::AnchorN ( ) const
inline

Definition at line 134 of file pns_diff_pair.h.

134 { return m_anchorN; }

References m_anchorN.

Referenced by PNS::DP_GATEWAYS::buildDpContinuation(), and PNS::DP_GATEWAYS::BuildFromPrimitivePair().

◆ AnchorP()

const VECTOR2I& PNS::DP_PRIMITIVE_PAIR::AnchorP ( ) const
inline

Definition at line 133 of file pns_diff_pair.h.

133 { return m_anchorP; }

References m_anchorP.

Referenced by PNS::DP_GATEWAYS::buildDpContinuation(), and PNS::DP_GATEWAYS::BuildFromPrimitivePair().

◆ CursorOrientation()

void PNS::DP_PRIMITIVE_PAIR::CursorOrientation ( const VECTOR2I aCursorPos,
VECTOR2I aMidpoint,
VECTOR2I aDirection 
) const

Definition at line 119 of file pns_diff_pair.cpp.

121 {
122  assert( m_primP && m_primN );
123 
124  VECTOR2I aP, aN;
125 
127  {
128  aP = m_primP->Anchor( 1 );
129  aN = m_primN->Anchor( 1 );
130 
131  // If both segments are parallel, use that as the direction. Otherwise, fall back on the
132  // direction perpendicular to the anchor points.
133  const SEG& segP = static_cast<SEGMENT*>( m_primP )->Seg();
134  const SEG& segN = static_cast<SEGMENT*>( m_primN )->Seg();
135 
136  if( ( segP.B != segP.A ) && ( segN.B != segN.A ) && segP.ApproxParallel( segN ) )
137  {
138  aMidpoint = ( aP + aN ) / 2;
139  aDirection = segP.B - segP.A;
140  aDirection = aDirection.Resize( ( aP - aN ).EuclideanNorm() );
141  return;
142  }
143  }
144  else
145  {
146  aP = m_primP->Anchor( 0 );
147  aN = m_primN->Anchor( 0 );
148  }
149 
150  aMidpoint = ( aP + aN ) / 2;
151  aDirection = ( aP - aN ).Perpendicular();
152 
153  if( aDirection.Dot( aCursorPos - aMidpoint ) < 0 )
154  aDirection = -aDirection;
155 }
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:146
bool ApproxParallel(const SEG &aSeg) const
Definition: seg.h:290
virtual VECTOR2I Anchor(int n) const
Definition: pns_item.h:215
Definition: seg.h:40
VECTOR2< T > Resize(T aNewLength) const
Return a vector of the same direction, but length specified in aNewLength.
Definition: vector2d.h:404
extended_type Dot(const VECTOR2< T > &aVector) const
Compute dot product of self with aVector.
Definition: vector2d.h:521
VECTOR2I A
Definition: seg.h:48
bool OfKind(int aKindMask) const
Return true if the item's type matches the mask aKindMask.
Definition: pns_item.h:136
VECTOR2I B
Definition: seg.h:49

References SEG::A, PNS::ITEM::Anchor(), SEG::ApproxParallel(), SEG::B, VECTOR2< T >::Dot(), EuclideanNorm(), m_primN, m_primP, PNS::ITEM::OfKind(), VECTOR2< T >::Resize(), and PNS::ITEM::SEGMENT_T.

◆ Directional()

bool PNS::DP_PRIMITIVE_PAIR::Directional ( ) const

Definition at line 98 of file pns_diff_pair.cpp.

99 {
100  if( !m_primP )
101  return false;
102 
103  return m_primP->OfKind( ITEM::SEGMENT_T );
104 }
bool OfKind(int aKindMask) const
Return true if the item's type matches the mask aKindMask.
Definition: pns_item.h:136

References m_primP, PNS::ITEM::OfKind(), and PNS::ITEM::SEGMENT_T.

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

◆ DirN()

DIRECTION_45 PNS::DP_PRIMITIVE_PAIR::DirN ( ) const

Definition at line 164 of file pns_diff_pair.cpp.

165 {
166  return anchorDirection( m_primN, m_anchorN );
167 }
DIRECTION_45 anchorDirection(const ITEM *aItem, const VECTOR2I &aP) const

References anchorDirection(), m_anchorN, and m_primN.

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

◆ DirP()

DIRECTION_45 PNS::DP_PRIMITIVE_PAIR::DirP ( ) const

Definition at line 158 of file pns_diff_pair.cpp.

159 {
160  return anchorDirection( m_primP, m_anchorP );
161 }
DIRECTION_45 anchorDirection(const ITEM *aItem, const VECTOR2I &aP) const

References anchorDirection(), m_anchorP, and m_primP.

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

◆ dump()

void PNS::DP_PRIMITIVE_PAIR::dump ( )
inline

Definition at line 150 of file pns_diff_pair.h.

151  {
152  printf( "-- Prim-P %p anchor [%d, %d]\n", m_primP, m_anchorP.x, m_anchorP.y );
153  printf( "-- Prim-N %p anchor [%d, %d]\n", m_primN, m_anchorN.x, m_anchorN.y );
154  }

References m_anchorN, m_anchorP, m_primN, m_primP, VECTOR2< T >::x, and VECTOR2< T >::y.

◆ operator=()

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

Definition at line 77 of file pns_diff_pair.cpp.

78 {
79  if( aOther.m_primP )
80  m_primP = aOther.m_primP->Clone();
81  if( aOther.m_primN )
82  m_primN = aOther.m_primN->Clone();
83 
84  m_anchorP = aOther.m_anchorP;
85  m_anchorN = aOther.m_anchorN;
86 
87  return *this;
88 }
virtual ITEM * Clone() const =0
Return a deep copy of the item.

References PNS::ITEM::Clone(), m_anchorN, m_anchorP, m_primN, and m_primP.

◆ PrimN()

ITEM* PNS::DP_PRIMITIVE_PAIR::PrimN ( ) const
inline

Definition at line 139 of file pns_diff_pair.h.

139 { return m_primN; }

References m_primN.

Referenced by PNS::DP_GATEWAYS::BuildFromPrimitivePair(), and PNS::DIFF_PAIR_PLACER::Start().

◆ PrimP()

ITEM* PNS::DP_PRIMITIVE_PAIR::PrimP ( ) const
inline

◆ SetAnchors()

void PNS::DP_PRIMITIVE_PAIR::SetAnchors ( const VECTOR2I aAnchorP,
const VECTOR2I aAnchorN 
)

Definition at line 47 of file pns_diff_pair.cpp.

48 {
49  m_anchorP = aAnchorP;
50  m_anchorN = aAnchorN;
51 }

References m_anchorN, and m_anchorP.

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

Member Data Documentation

◆ m_anchorN

VECTOR2I PNS::DP_PRIMITIVE_PAIR::m_anchorN
private

Definition at line 161 of file pns_diff_pair.h.

Referenced by AnchorN(), DirN(), DP_PRIMITIVE_PAIR(), dump(), operator=(), and SetAnchors().

◆ m_anchorP

VECTOR2I PNS::DP_PRIMITIVE_PAIR::m_anchorP
private

Definition at line 161 of file pns_diff_pair.h.

Referenced by AnchorP(), DirP(), DP_PRIMITIVE_PAIR(), dump(), operator=(), and SetAnchors().

◆ m_primN

ITEM* PNS::DP_PRIMITIVE_PAIR::m_primN
private

◆ m_primP

ITEM* PNS::DP_PRIMITIVE_PAIR::m_primP
private

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