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.

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.

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.

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 576 of file pns_meander.cpp.

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

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

577 {
578  MEANDER_SHAPE* m = new MEANDER_SHAPE( m_placer, m_width, m_dual );
579 
580  m->MakeCorner( aA, aB );
581  m_last = aA;
582 
583  m_meanders.push_back( m );
584 }
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 599 of file pns_meander.cpp.

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

600 {
601  m_last = aShape->BaseSegment().B;
602  m_meanders.push_back( aShape );
603 }
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 423 of file pns_meander.cpp.

References SEG::ApproxParallel(), PNS::MEANDER_SHAPE::BaseSegment(), PNS::MEANDER_SHAPE::CLine(), SHAPE_LINE_CHAIN::Collide(), SHAPE_LINE_CHAIN::CSegment(), i, 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().

424 {
425  for( int i = m_meanders.size() - 1; i >= 0; i-- )
426  {
427  MEANDER_SHAPE* m = m_meanders[i];
428 
429  if( m->Type() == MT_EMPTY || m->Type() == MT_CORNER )
430  continue;
431 
432  const SEG& b1 = aShape->BaseSegment();
433  const SEG& b2 = m->BaseSegment();
434 
435  if( b1.ApproxParallel( b2 ) )
436  continue;
437 
438  int n = m->CLine( 0 ).SegmentCount();
439 
440  for( int j = n - 1; j >= 0; j-- )
441  if( aShape->CLine( 0 ).Collide( m->CLine( 0 ) .CSegment( j ), aClearance ) )
442  return false;
443  }
444 
445  return true;
446 }
std::vector< MEANDER_SHAPE * > m_meanders
Definition: pns_meander.h:510
Definition: seg.h:36
size_t i
Definition: json11.cpp:597
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 606 of file pns_meander.cpp.

607 {
608  for( MEANDER_SHAPE* m : m_meanders )
609  {
610  delete m;
611  }
612 
613  m_meanders.clear( );
614 }
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.

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, SEG::B, SEG::Contains(), PNS::MEANDER_SHAPE::cornerRadius(), EuclideanNorm(), PNS::MEANDER_SHAPE::Fit(), i, SEG::Length(), PNS::MEANDER_SHAPE::m_baselineOffset, PNS::MEANDER_SHAPE::m_dual, PNS::MEANDER_SHAPE::m_placer, PNS::MEANDER_SETTINGS::m_step, PNS::MEANDER_SHAPE::m_width, PNS::MEANDER_SHAPE::MEANDER_SHAPE(), 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(), PNS::MEANDER_SHAPE::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.
size_t i
Definition: json11.cpp:597
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.

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 PNS::MEANDER_SHAPE::m_placer, and PNS::MEANDER_PLACER_BASE::MeanderSettings().

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.

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.

bool PNS::MEANDERED_LINE::m_dual
private

Definition at line 512 of file pns_meander.h.

VECTOR2I PNS::MEANDERED_LINE::m_last
private

Definition at line 507 of file pns_meander.h.

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

Definition at line 510 of file pns_meander.h.

MEANDER_PLACER_BASE* PNS::MEANDERED_LINE::m_placer
private

Definition at line 509 of file pns_meander.h.

int PNS::MEANDERED_LINE::m_width
private

Definition at line 513 of file pns_meander.h.


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