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 137 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 140 of file pns_diff_pair.h.

140  :
141  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 69 of file pns_diff_pair.cpp.

70 {
71  m_primP = m_primN = NULL;
72 
73  if( aOther.m_primP )
74  m_primP = aOther.m_primP->Clone();
75 
76  if( aOther.m_primN )
77  m_primN = aOther.m_primN->Clone();
78 
79  m_anchorP = aOther.m_anchorP;
80  m_anchorN = aOther.m_anchorN;
81 }
virtual ITEM * Clone() const =0
Function Clone()
#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 44 of file pns_diff_pair.cpp.

45 {
46  m_primP = aPrimP->Clone();
47  m_primN = aPrimN->Clone();
48 
49  m_anchorP = m_primP->Anchor( 0 );
50  m_anchorN = m_primN->Anchor( 0 );
51 }
virtual ITEM * Clone() const =0
Function Clone()
virtual VECTOR2I Anchor(int n) const
Definition: pns_item.h:226

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

62 {
63  m_anchorP = aAnchorP;
64  m_anchorN = aAnchorN;
65  m_primP = m_primN = NULL;
66 }
#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 98 of file pns_diff_pair.cpp.

99 {
100  delete m_primP;
101  delete m_primN;
102 }

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

115 {
116  if( !aItem->OfKind ( ITEM::SEGMENT_T | ITEM::ARC_T ) )
117  return DIRECTION_45();
118 
119  if( aItem->Anchor( 0 ) == aP )
120  return DIRECTION_45( aItem->Anchor( 0 ) - aItem->Anchor( 1 ) );
121  else
122  return DIRECTION_45( aItem->Anchor( 1 ) - aItem->Anchor( 0 ) );
123 }
DIRECTION_45.
Definition: direction45.h:37

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 152 of file pns_diff_pair.h.

152 { 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 151 of file pns_diff_pair.h.

151 { 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 125 of file pns_diff_pair.cpp.

126 {
127  assert( m_primP && m_primN );
128 
129  VECTOR2I aP, aN, dir, midpoint;
130 
132  {
133  aP = m_primP->Anchor( 1 );
134  aN = m_primN->Anchor( 1 );
135  midpoint = ( aP + aN ) / 2;
136  SEG s = static_cast <SEGMENT*>( m_primP )->Seg();
137 
138  if ( s.B != s.A )
139  {
140  dir = s.B - s.A;
141  }
142  else
143  {
144  dir = VECTOR2I( 0, 1 );
145  }
146 
147  dir = dir.Resize( ( aP - aN ).EuclideanNorm() );
148 
149  }
150  else
151  {
152  aP = m_primP->Anchor( 0 );
153  aN = m_primN->Anchor( 0 );
154  midpoint = ( aP + aN ) / 2;
155  dir = ( aP - aN ).Perpendicular();
156 
157  if ( dir.Dot( aCursorPos - midpoint ) < 0 )
158  dir = -dir;
159  }
160 
161  aMidpoint = midpoint;
162  aDirection = dir;
163 }
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:128
VECTOR2< int > VECTOR2I
Definition: vector2d.h:594
virtual VECTOR2I Anchor(int n) const
Definition: pns_item.h:226
Definition: seg.h:39
VECTOR2< T > Resize(T aNewLength) const
Function Resize returns a vector of the same direction, but length specified in aNewLength.
Definition: vector2d.h:392
extended_type Dot(const VECTOR2< T > &aVector) const
Function Dot() computes dot product of self with aVector.
Definition: vector2d.h:492
VECTOR2I A
Definition: seg.h:47
bool OfKind(int aKindMask) const
Function OfKind()
Definition: pns_item.h:133
VECTOR2I B
Definition: seg.h:48

References SEG::A, PNS::ITEM::Anchor(), 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 105 of file pns_diff_pair.cpp.

106 {
107  if( !m_primP )
108  return false;
109 
110  return m_primP->OfKind( ITEM::SEGMENT_T );
111 }
bool OfKind(int aKindMask) const
Function OfKind()
Definition: pns_item.h:133

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

173 {
174  return anchorDirection( m_primN, m_anchorN );
175 }
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 166 of file pns_diff_pair.cpp.

167 {
168  return anchorDirection( m_primP, m_anchorP );
169 }
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 167 of file pns_diff_pair.h.

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

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

85 {
86  if( aOther.m_primP )
87  m_primP = aOther.m_primP->Clone();
88  if( aOther.m_primN )
89  m_primN = aOther.m_primN->Clone();
90 
91  m_anchorP = aOther.m_anchorP;
92  m_anchorN = aOther.m_anchorN;
93 
94  return *this;
95 }
virtual ITEM * Clone() const =0
Function Clone()

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 157 of file pns_diff_pair.h.

157 { 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 54 of file pns_diff_pair.cpp.

55 {
56  m_anchorP = aAnchorP;
57  m_anchorN = aAnchorN;
58 }

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