KiCad PCB EDA Suite
PNS::DP_PRIMITIVE_PAIR Class Reference

Class 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 (ITEM *aItem, const VECTOR2I &aP) const
 

Private Attributes

ITEMm_primP
 
ITEMm_primN
 
VECTOR2I m_anchorP
 
VECTOR2I m_anchorN
 

Detailed Description

Class DP_PRIMITIVE_PAIR.

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

Definition at line 136 of file pns_diff_pair.h.

Constructor & Destructor Documentation

PNS::DP_PRIMITIVE_PAIR::DP_PRIMITIVE_PAIR ( )
inline

Definition at line 139 of file pns_diff_pair.h.

139  :
140  m_primP( NULL ), m_primN( NULL ) {};
PNS::DP_PRIMITIVE_PAIR::DP_PRIMITIVE_PAIR ( const DP_PRIMITIVE_PAIR aOther)

Definition at line 69 of file pns_diff_pair.cpp.

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

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()
PNS::DP_PRIMITIVE_PAIR::DP_PRIMITIVE_PAIR ( ITEM aPrimP,
ITEM aPrimN 
)

Definition at line 44 of file pns_diff_pair.cpp.

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

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:326
PNS::DP_PRIMITIVE_PAIR::DP_PRIMITIVE_PAIR ( const VECTOR2I aAnchorP,
const VECTOR2I aAnchorN 
)

Definition at line 61 of file pns_diff_pair.cpp.

References m_anchorN, m_anchorP, m_primN, and m_primP.

62 {
63  m_anchorP = aAnchorP;
64  m_anchorN = aAnchorN;
65  m_primP = m_primN = NULL;
66 }
PNS::DP_PRIMITIVE_PAIR::~DP_PRIMITIVE_PAIR ( )

Definition at line 98 of file pns_diff_pair.cpp.

References m_primN, and m_primP.

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

Member Function Documentation

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

Definition at line 114 of file pns_diff_pair.cpp.

References SEG::A, SEG::B, PNS::ITEM::OfKind(), PNS::SEGMENT::Seg(), and PNS::ITEM::SEGMENT_T.

Referenced by DirN(), and DirP().

115 {
116  if( !aItem->OfKind ( ITEM::SEGMENT_T ) )
117  return DIRECTION_45();
118 
119  SEGMENT* s = static_cast<SEGMENT*>( aItem );
120 
121  if( s->Seg().A == aP )
122  return DIRECTION_45( s->Seg().A - s->Seg().B );
123  else
124  return DIRECTION_45( s->Seg().B - s->Seg().A );
125 }
Class DIRECTION_45.
Definition: direction45.h:33
const VECTOR2I& PNS::DP_PRIMITIVE_PAIR::AnchorN ( ) const
inline

Definition at line 151 of file pns_diff_pair.h.

References m_anchorN.

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

151 { return m_anchorN; }
const VECTOR2I& PNS::DP_PRIMITIVE_PAIR::AnchorP ( ) const
inline

Definition at line 150 of file pns_diff_pair.h.

References m_anchorP.

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

150 { return m_anchorP; }
void PNS::DP_PRIMITIVE_PAIR::CursorOrientation ( const VECTOR2I aCursorPos,
VECTOR2I aMidpoint,
VECTOR2I aDirection 
) const

Definition at line 127 of file pns_diff_pair.cpp.

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.

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

Definition at line 105 of file pns_diff_pair.cpp.

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

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

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:130
DIRECTION_45 PNS::DP_PRIMITIVE_PAIR::DirN ( ) const

Definition at line 174 of file pns_diff_pair.cpp.

References anchorDirection(), m_anchorN, and m_primN.

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

175 {
176  return anchorDirection( m_primN, m_anchorN );
177 }
DIRECTION_45 anchorDirection(ITEM *aItem, const VECTOR2I &aP) const
DIRECTION_45 PNS::DP_PRIMITIVE_PAIR::DirP ( ) const

Definition at line 168 of file pns_diff_pair.cpp.

References anchorDirection(), m_anchorP, and m_primP.

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

169 {
170  return anchorDirection( m_primP, m_anchorP );
171 }
DIRECTION_45 anchorDirection(ITEM *aItem, const VECTOR2I &aP) const
void PNS::DP_PRIMITIVE_PAIR::dump ( )
inline

Definition at line 166 of file pns_diff_pair.h.

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

167  {
168  printf( "-- Prim-P %p anchor [%d, %d]\n", m_primP, m_anchorP.x, m_anchorP.y );
169  printf( "-- Prim-N %p anchor [%d, %d]\n", m_primN, m_anchorN.x, m_anchorN.y );
170  }
DP_PRIMITIVE_PAIR & PNS::DP_PRIMITIVE_PAIR::operator= ( const DP_PRIMITIVE_PAIR aOther)

Definition at line 84 of file pns_diff_pair.cpp.

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

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()
ITEM* PNS::DP_PRIMITIVE_PAIR::PrimN ( ) const
inline

Definition at line 156 of file pns_diff_pair.h.

References m_primN.

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

156 { return m_primN; }
ITEM* PNS::DP_PRIMITIVE_PAIR::PrimP ( ) const
inline
void PNS::DP_PRIMITIVE_PAIR::SetAnchors ( const VECTOR2I aAnchorP,
const VECTOR2I aAnchorN 
)

Definition at line 54 of file pns_diff_pair.cpp.

References m_anchorN, and m_anchorP.

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

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

Member Data Documentation

VECTOR2I PNS::DP_PRIMITIVE_PAIR::m_anchorN
private

Definition at line 177 of file pns_diff_pair.h.

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

VECTOR2I PNS::DP_PRIMITIVE_PAIR::m_anchorP
private

Definition at line 177 of file pns_diff_pair.h.

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

ITEM* PNS::DP_PRIMITIVE_PAIR::m_primN
private
ITEM* PNS::DP_PRIMITIVE_PAIR::m_primP
private

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