KiCad PCB EDA Suite
PNS::MEANDERED_LINE Class Reference

Class MEANDERED_LINE. More...

#include <pns_meander.h>

Public Member Functions

 MEANDERED_LINE ()
 
 MEANDERED_LINE (MEANDER_PLACER_BASE *aPlacer, bool aIsDual=false)
 Constructor. More...
 
 ~MEANDERED_LINE ()
 
void AddCorner (const VECTOR2I &aA, const VECTOR2I &aB=VECTOR2I(0, 0))
 Function AddCorner() More...
 
void AddMeander (MEANDER_SHAPE *aShape)
 Function AddMeander() More...
 
void Clear ()
 Function Clear() More...
 
void SetWidth (int aWidth)
 Function SetWidth() More...
 
void MeanderSegment (const SEG &aSeg, int aBaseIndex=0)
 Function MeanderSegment() More...
 
void SetBaselineOffset (int aOffset)
 Function SetBaselineOffset() More...
 
std::vector< MEANDER_SHAPE * > & Meanders ()
 Function Meanders() More...
 
bool CheckSelfIntersections (MEANDER_SHAPE *aShape, int aClearance)
 Function CheckSelfIntersections() More...
 
const MEANDER_SETTINGSSettings () const
 Function Settings() More...
 

Private Attributes

VECTOR2I m_last
 
MEANDER_PLACER_BASEm_placer
 
std::vector< MEANDER_SHAPE * > m_meanders
 
bool m_dual
 
int m_width
 
int m_baselineOffset
 

Detailed Description

Class MEANDERED_LINE.

Represents a set of meanders fitted over a single or two lines.

Definition at line 395 of file pns_meander.h.

Constructor & Destructor Documentation

PNS::MEANDERED_LINE::MEANDERED_LINE ( )
inline

Definition at line 398 of file pns_meander.h.

References m_baselineOffset, m_dual, m_placer, and m_width.

399  {
400  // Do not leave unitialized members, and keep static analyser quiet:
401  m_placer = NULL;
402  m_dual = false;
403  m_width = 0;
404  m_baselineOffset = 0;
405  }
MEANDER_PLACER_BASE * m_placer
Definition: pns_meander.h:509
PNS::MEANDERED_LINE::MEANDERED_LINE ( MEANDER_PLACER_BASE aPlacer,
bool  aIsDual = false 
)
inline

Constructor.

Parameters
aPlacerthe meander placer instance
aIsDualwhen true, the meanders are generated for two coupled lines

Definition at line 413 of file pns_meander.h.

References m_baselineOffset, and m_width.

413  :
414  m_placer( aPlacer ),
415  m_dual( aIsDual )
416  {
417  // Do not leave unitialized members, and keep static analyser quiet:
418  m_width = 0;
419  m_baselineOffset = 0;
420  }
MEANDER_PLACER_BASE * m_placer
Definition: pns_meander.h:509
PNS::MEANDERED_LINE::~MEANDERED_LINE ( )
inline

Definition at line 422 of file pns_meander.h.

References Clear().

423  {
424  Clear();
425  }
void Clear()
Function Clear()

Member Function Documentation

void PNS::MEANDERED_LINE::AddCorner ( const VECTOR2I aA,
const VECTOR2I aB = VECTOR2I( 0, 0 ) 
)

Function AddCorner()

Creates a dummy meander shape representing a line corner. Used to define the starts/ends of meandered segments.

Parameters
aAcorner point of the 1st line
aBcorner point of the 2nd line (if m_dual == true)

Definition at line 573 of file pns_meander.cpp.

References m_dual, m_last, m_meanders, m_placer, m_width, and PNS::MEANDER_SHAPE::MakeCorner().

Referenced by MeanderSegment(), and PNS::DP_MEANDER_PLACER::Move().

574 {
575  MEANDER_SHAPE* m = new MEANDER_SHAPE( m_placer, m_width, m_dual );
576 
577  m->MakeCorner( aA, aB );
578  m_last = aA;
579 
580  m_meanders.push_back( m );
581 }
MEANDER_PLACER_BASE * m_placer
Definition: pns_meander.h:509
std::vector< MEANDER_SHAPE * > m_meanders
Definition: pns_meander.h:510
void PNS::MEANDERED_LINE::AddMeander ( MEANDER_SHAPE aShape)

Function AddMeander()

Adds a new meander shape the the meandered line.

Parameters
aShapethe meander shape to add

Definition at line 596 of file pns_meander.cpp.

References SEG::B, PNS::MEANDER_SHAPE::BaseSegment(), m_last, and m_meanders.

Referenced by MeanderSegment().

597 {
598  m_last = aShape->BaseSegment().B;
599  m_meanders.push_back( aShape );
600 }
std::vector< MEANDER_SHAPE * > m_meanders
Definition: pns_meander.h:510
bool PNS::MEANDERED_LINE::CheckSelfIntersections ( MEANDER_SHAPE aShape,
int  aClearance 
)

Function CheckSelfIntersections()

Checks if the given shape is intersecting with any other meander in the current line.

Parameters
aShapethe shape to check
aClearanceclearance value
Returns
true, if the meander shape is not colliding

Definition at line 420 of file pns_meander.cpp.

References SEG::ApproxParallel(), PNS::MEANDER_SHAPE::BaseSegment(), PNS::MEANDER_SHAPE::CLine(), SHAPE_LINE_CHAIN::Collide(), SHAPE_LINE_CHAIN::CSegment(), m_meanders, PNS::MT_CORNER, PNS::MT_EMPTY, SHAPE_LINE_CHAIN::SegmentCount(), and PNS::MEANDER_SHAPE::Type().

Referenced by PNS::MEANDER_PLACER::CheckFit(), and PNS::DP_MEANDER_PLACER::CheckFit().

421 {
422  for( int i = m_meanders.size() - 1; i >= 0; i-- )
423  {
424  MEANDER_SHAPE* m = m_meanders[i];
425 
426  if( m->Type() == MT_EMPTY || m->Type() == MT_CORNER )
427  continue;
428 
429  const SEG& b1 = aShape->BaseSegment();
430  const SEG& b2 = m->BaseSegment();
431 
432  if( b1.ApproxParallel( b2 ) )
433  continue;
434 
435  int n = m->CLine( 0 ).SegmentCount();
436 
437  for( int j = n - 1; j >= 0; j-- )
438  if( aShape->CLine( 0 ).Collide( m->CLine( 0 ) .CSegment( j ), aClearance ) )
439  return false;
440  }
441 
442  return true;
443 }
std::vector< MEANDER_SHAPE * > m_meanders
Definition: pns_meander.h:510
Definition: seg.h:36
bool ApproxParallel(const SEG &aSeg) const
Definition: seg.h:253
void PNS::MEANDERED_LINE::Clear ( )

Function Clear()

Clears the line geometry, removing all corners and meanders.

Definition at line 603 of file pns_meander.cpp.

References m_meanders.

Referenced by ~MEANDERED_LINE().

604 {
605  for( MEANDER_SHAPE* m : m_meanders )
606  {
607  delete m;
608  }
609 
610  m_meanders.clear( );
611 }
std::vector< MEANDER_SHAPE * > m_meanders
Definition: pns_meander.h:510
std::vector<MEANDER_SHAPE*>& PNS::MEANDERED_LINE::Meanders ( )
inline

Function Meanders()

Returns
set of meander shapes for this line

Definition at line 483 of file pns_meander.h.

References m_meanders.

Referenced by PNS::DP_MEANDER_PLACER::Move(), and PNS::MEANDER_PLACER_BASE::tuneLineLength().

484  {
485  return m_meanders;
486  }
std::vector< MEANDER_SHAPE * > m_meanders
Definition: pns_meander.h:510
void PNS::MEANDERED_LINE::MeanderSegment ( const SEG aSeg,
int  aBaseIndex = 0 
)

Function MeanderSegment()

Fits maximum amplitude meanders on a given segment and adds to the current line.

Parameters
aSegthe base segment to meander
aBaseIndexindex of the base segment in the original line

Definition at line 46 of file pns_meander.cpp.

References SEG::A, AddCorner(), AddMeander(), SEG::B, SEG::Contains(), PNS::MEANDER_SHAPE::cornerRadius(), EuclideanNorm(), PNS::MEANDER_SHAPE::Fit(), SEG::Length(), m_baselineOffset, m_dual, m_last, m_placer, PNS::MEANDER_SETTINGS::m_step, m_width, PNS::MT_CHECK_FINISH, PNS::MT_CHECK_START, PNS::MT_FINISH, PNS::MT_SINGLE, PNS::MT_TURN, VECTOR2< T >::Resize(), PNS::MEANDER_SHAPE::SetBaseIndex(), PNS::MEANDER_SHAPE::SetBaselineOffset(), Settings(), and PNS::MEANDER_SHAPE::spacing().

Referenced by PNS::DP_MEANDER_PLACER::Move().

47 {
48  double base_len = aBase.Length();
49 
51 
52  bool side = true;
53  VECTOR2D dir( aBase.B - aBase.A );
54 
55  if( !m_dual )
56  AddCorner( aBase.A );
57 
58  bool turning = false;
59  bool started = false;
60 
61  m_last = aBase.A;
62 
63  do
64  {
65  MEANDER_SHAPE m( m_placer, m_width, m_dual );
66 
67  m.SetBaselineOffset( m_baselineOffset );
68  m.SetBaseIndex( aBaseIndex );
69 
70  double thr = (double) m.spacing();
71 
72  bool fail = false;
73  double remaining = base_len - ( m_last - aBase.A ).EuclideanNorm();
74 
75  if( remaining < Settings( ).m_step )
76  break;
77 
78  if( remaining > 3.0 * thr )
79  {
80  if( !turning )
81  {
82  for( int i = 0; i < 2; i++ )
83  {
84  if( m.Fit( MT_CHECK_START, aBase, m_last, i ) )
85  {
86  turning = true;
87  AddMeander( new MEANDER_SHAPE( m ) );
88  side = !i;
89  started = true;
90  break;
91  }
92  }
93 
94  if( !turning )
95  {
96  fail = true;
97 
98  for( int i = 0; i < 2; i++ )
99  {
100  if( m.Fit( MT_SINGLE, aBase, m_last, i ) )
101  {
102  AddMeander( new MEANDER_SHAPE( m ) );
103  fail = false;
104  started = false;
105  side = !i;
106  break;
107  }
108  }
109  }
110  } else {
111  bool rv = m.Fit( MT_CHECK_FINISH, aBase, m_last, side );
112 
113  if( rv )
114  {
115  m.Fit( MT_TURN, aBase, m_last, side );
116  AddMeander( new MEANDER_SHAPE( m ) );
117  started = true;
118  } else {
119  m.Fit( MT_FINISH, aBase, m_last, side );
120  started = false;
121  AddMeander( new MEANDER_SHAPE( m ) );
122  turning = false;
123  }
124 
125  side = !side;
126  }
127  } else if( started )
128  {
129  bool rv = m.Fit( MT_FINISH, aBase, m_last, side );
130  if( rv )
131  AddMeander( new MEANDER_SHAPE( m ) );
132 
133  break;
134 
135  } else {
136  fail = true;
137  }
138 
139  remaining = base_len - ( m_last - aBase.A ).EuclideanNorm( );
140 
141  if( remaining < Settings( ).m_step )
142  break;
143 
144  if( fail )
145  {
146  MEANDER_SHAPE tmp( m_placer, m_width, m_dual );
147  tmp.SetBaselineOffset( m_baselineOffset );
148  tmp.SetBaseIndex( aBaseIndex );
149 
150  int nextP = tmp.spacing() - 2 * tmp.cornerRadius() + Settings().m_step;
151  VECTOR2I pn = m_last + dir.Resize( nextP );
152 
153  if( aBase.Contains( pn ) && !m_dual )
154  {
155  AddCorner( pn );
156  } else
157  break;
158  }
159 
160 
161  } while( true );
162 
163  if( !m_dual )
164  AddCorner( aBase.B );
165 }
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:112
VECTOR2< T > Resize(T aNewLength) const
Function Resize returns a vector of the same direction, but length specified in aNewLength.
Definition: vector2d.h:387
MEANDER_PLACER_BASE * m_placer
Definition: pns_meander.h:509
void AddCorner(const VECTOR2I &aA, const VECTOR2I &aB=VECTOR2I(0, 0))
Function AddCorner()
int m_step
amplitude/spacing adjustment step
Definition: pns_meander.h:82
void AddMeander(MEANDER_SHAPE *aShape)
Function AddMeander()
const MEANDER_SETTINGS & Settings() const
Function Settings()
Definition: pns_meander.cpp:40
Class SHAPE_LINE_CHAIN.
void PNS::MEANDERED_LINE::SetBaselineOffset ( int  aOffset)
inline

Function SetBaselineOffset()

Sets the parallel offset between the base segment and the meandered line. Used for dual menaders (diff pair) only.

Parameters
aOffsetthe offset

Definition at line 473 of file pns_meander.h.

References m_baselineOffset.

Referenced by PNS::DP_MEANDER_PLACER::Move().

474  {
475  m_baselineOffset = aOffset;
476  }
const MEANDER_SETTINGS & PNS::MEANDERED_LINE::Settings ( ) const

Function Settings()

Returns
the current meandering settings.

Definition at line 40 of file pns_meander.cpp.

References m_placer, and PNS::MEANDER_PLACER_BASE::MeanderSettings().

Referenced by MeanderSegment().

41 {
42  return m_placer->MeanderSettings();
43 }
MEANDER_PLACER_BASE * m_placer
Definition: pns_meander.h:509
virtual const MEANDER_SETTINGS & MeanderSettings() const
Function MeanderSettings()
void PNS::MEANDERED_LINE::SetWidth ( int  aWidth)
inline

Function SetWidth()

Sets the line width.

Definition at line 457 of file pns_meander.h.

References m_width.

Referenced by PNS::DP_MEANDER_PLACER::Move().

458  {
459  m_width = aWidth;
460  }

Member Data Documentation

int PNS::MEANDERED_LINE::m_baselineOffset
private

Definition at line 514 of file pns_meander.h.

Referenced by MEANDERED_LINE(), MeanderSegment(), and SetBaselineOffset().

bool PNS::MEANDERED_LINE::m_dual
private

Definition at line 512 of file pns_meander.h.

Referenced by AddCorner(), MEANDERED_LINE(), and MeanderSegment().

VECTOR2I PNS::MEANDERED_LINE::m_last
private

Definition at line 507 of file pns_meander.h.

Referenced by AddCorner(), AddMeander(), and MeanderSegment().

std::vector<MEANDER_SHAPE*> PNS::MEANDERED_LINE::m_meanders
private

Definition at line 510 of file pns_meander.h.

Referenced by AddCorner(), AddMeander(), CheckSelfIntersections(), Clear(), and Meanders().

MEANDER_PLACER_BASE* PNS::MEANDERED_LINE::m_placer
private

Definition at line 509 of file pns_meander.h.

Referenced by AddCorner(), MEANDERED_LINE(), MeanderSegment(), and Settings().

int PNS::MEANDERED_LINE::m_width
private

Definition at line 513 of file pns_meander.h.

Referenced by AddCorner(), MEANDERED_LINE(), MeanderSegment(), and SetWidth().


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