KiCad PCB EDA Suite
PNS::DP_PRIMITIVE_PAIR Class Reference

DP_PRIMITIVE_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

DP_PRIMITIVE_PAIR.

Stores staring/ending primitives (pads, vias or segments) for a differential pair.

Definition at line 134 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 137 of file pns_diff_pair.h.

137  :
138  m_primP( NULL ), m_primN( NULL ) {};
#define NULL

◆ DP_PRIMITIVE_PAIR() [2/4]

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

Definition at line 61 of file pns_diff_pair.cpp.

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

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

◆ DP_PRIMITIVE_PAIR() [3/4]

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

Definition at line 36 of file pns_diff_pair.cpp.

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

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 53 of file pns_diff_pair.cpp.

54 {
55  m_anchorP = aAnchorP;
56  m_anchorN = aAnchorN;
57  m_primP = m_primN = NULL;
58 }
#define NULL

References m_anchorN, m_anchorP, m_primN, m_primP, and NULL.

◆ ~DP_PRIMITIVE_PAIR()

PNS::DP_PRIMITIVE_PAIR::~DP_PRIMITIVE_PAIR ( )

Definition at line 90 of file pns_diff_pair.cpp.

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

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 106 of file pns_diff_pair.cpp.

107 {
108  if( !aItem->OfKind ( ITEM::SEGMENT_T | ITEM::ARC_T ) )
109  return DIRECTION_45();
110 
111  if( aItem->Anchor( 0 ) == aP )
112  return DIRECTION_45( aItem->Anchor( 0 ) - aItem->Anchor( 1 ) );
113  else
114  return DIRECTION_45( aItem->Anchor( 1 ) - aItem->Anchor( 0 ) );
115 }
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 149 of file pns_diff_pair.h.

149 { 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 148 of file pns_diff_pair.h.

148 { 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 117 of file pns_diff_pair.cpp.

119 {
120  assert( m_primP && m_primN );
121 
122  VECTOR2I aP, aN;
123 
125  {
126  aP = m_primP->Anchor( 1 );
127  aN = m_primN->Anchor( 1 );
128 
129  // If both segments are parallel, use that as the direction. Otherwise, fall back on the
130  // direction perpendicular to the anchor points.
131  const SEG& segP = static_cast<SEGMENT*>( m_primP )->Seg();
132  const SEG& segN = static_cast<SEGMENT*>( m_primN )->Seg();
133 
134  if( ( segP.B != segP.A ) && ( segN.B != segN.A ) && segP.ApproxParallel( segN ) )
135  {
136  aMidpoint = ( aP + aN ) / 2;
137  aDirection = segP.B - segP.A;
138  aDirection = aDirection.Resize( ( aP - aN ).EuclideanNorm() );
139  return;
140  }
141  }
142  else
143  {
144  aP = m_primP->Anchor( 0 );
145  aN = m_primN->Anchor( 0 );
146  }
147 
148  aMidpoint = ( aP + aN ) / 2;
149  aDirection = ( aP - aN ).Perpendicular();
150 
151  if( aDirection.Dot( aCursorPos - aMidpoint ) < 0 )
152  aDirection = -aDirection;
153 }
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:148
bool ApproxParallel(const SEG &aSeg) const
Definition: seg.h:295
virtual VECTOR2I Anchor(int n) const
Definition: pns_item.h:213
Definition: seg.h:41
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:49
bool OfKind(int aKindMask) const
Return true if the item's type matches the mask aKindMask.
Definition: pns_item.h:134
VECTOR2I B
Definition: seg.h:50

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 97 of file pns_diff_pair.cpp.

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

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 162 of file pns_diff_pair.cpp.

163 {
164  return anchorDirection( m_primN, m_anchorN );
165 }
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 156 of file pns_diff_pair.cpp.

157 {
158  return anchorDirection( m_primP, m_anchorP );
159 }
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 164 of file pns_diff_pair.h.

165  {
166  printf( "-- Prim-P %p anchor [%d, %d]\n", m_primP, m_anchorP.x, m_anchorP.y );
167  printf( "-- Prim-N %p anchor [%d, %d]\n", m_primN, m_anchorN.x, m_anchorN.y );
168  }

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 76 of file pns_diff_pair.cpp.

77 {
78  if( aOther.m_primP )
79  m_primP = aOther.m_primP->Clone();
80  if( aOther.m_primN )
81  m_primN = aOther.m_primN->Clone();
82 
83  m_anchorP = aOther.m_anchorP;
84  m_anchorN = aOther.m_anchorN;
85 
86  return *this;
87 }
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 154 of file pns_diff_pair.h.

154 { 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 46 of file pns_diff_pair.cpp.

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

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