KiCad PCB EDA Suite
PNS::MEANDERED_LINE Class Reference

Represent a set of meanders fitted over a single or two lines. More...

#include <pns_meander.h>

Public Member Functions

 MEANDERED_LINE ()
 
 MEANDERED_LINE (MEANDER_PLACER_BASE *aPlacer, bool aIsDual=false)
 
 ~MEANDERED_LINE ()
 
void AddCorner (const VECTOR2I &aA, const VECTOR2I &aB=VECTOR2I(0, 0))
 Create a dummy meander shape representing a line corner. More...
 
void AddMeander (MEANDER_SHAPE *aShape)
 Add a new meander shape to the meandered line. More...
 
void Clear ()
 Clear the line geometry, removing all corners and meanders. More...
 
void SetWidth (int aWidth)
 Set the line width. More...
 
void MeanderSegment (const SEG &aSeg, int aBaseIndex=0)
 Fit maximum amplitude meanders on a given segment and adds to the current line. More...
 
void SetBaselineOffset (int aOffset)
 Set the parallel offset between the base segment and the meandered line. More...
 
std::vector< MEANDER_SHAPE * > & Meanders ()
 
bool CheckSelfIntersections (MEANDER_SHAPE *aShape, int aClearance)
 Check if the given shape is intersecting with any other meander in the current line. More...
 
const MEANDER_SETTINGSSettings () const
 

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

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

Definition at line 375 of file pns_meander.h.

Constructor & Destructor Documentation

◆ MEANDERED_LINE() [1/2]

PNS::MEANDERED_LINE::MEANDERED_LINE ( )
inline

Definition at line 378 of file pns_meander.h.

379  {
380  // Do not leave uninitialized members, and keep static analyzer quiet:
381  m_placer = nullptr;
382  m_dual = false;
383  m_width = 0;
384  m_baselineOffset = 0;
385  }
MEANDER_PLACER_BASE * m_placer
Definition: pns_meander.h:473

References m_baselineOffset, m_dual, m_placer, and m_width.

◆ MEANDERED_LINE() [2/2]

PNS::MEANDERED_LINE::MEANDERED_LINE ( MEANDER_PLACER_BASE aPlacer,
bool  aIsDual = false 
)
inline
Parameters
aPlacerthe meander placer instance
aIsDualwhen true, the meanders are generated for two coupled lines

Definition at line 391 of file pns_meander.h.

391  :
392  m_placer( aPlacer ),
393  m_dual( aIsDual )
394  {
395  // Do not leave uninitialized members, and keep static analyzer quiet:
396  m_width = 0;
397  m_baselineOffset = 0;
398  }
MEANDER_PLACER_BASE * m_placer
Definition: pns_meander.h:473

References m_baselineOffset, and m_width.

◆ ~MEANDERED_LINE()

PNS::MEANDERED_LINE::~MEANDERED_LINE ( )
inline

Definition at line 400 of file pns_meander.h.

401  {
402  Clear();
403  }
void Clear()
Clear the line geometry, removing all corners and meanders.

References Clear().

Member Function Documentation

◆ AddCorner()

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

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

538 {
539  MEANDER_SHAPE* m = new MEANDER_SHAPE( m_placer, m_width, m_dual );
540 
541  m->MakeCorner( aA, aB );
542  m_last = aA;
543 
544  m_meanders.push_back( m );
545 }
MEANDER_PLACER_BASE * m_placer
Definition: pns_meander.h:473
std::vector< MEANDER_SHAPE * > m_meanders
Definition: pns_meander.h:474

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

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

◆ AddMeander()

void PNS::MEANDERED_LINE::AddMeander ( MEANDER_SHAPE aShape)

Add a new meander shape to the meandered line.

Parameters
aShapethe meander shape to add

Definition at line 560 of file pns_meander.cpp.

561 {
562  m_last = aShape->BaseSegment().B;
563  m_meanders.push_back( aShape );
564 }
std::vector< MEANDER_SHAPE * > m_meanders
Definition: pns_meander.h:474

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

Referenced by MeanderSegment().

◆ CheckSelfIntersections()

bool PNS::MEANDERED_LINE::CheckSelfIntersections ( MEANDER_SHAPE aShape,
int  aClearance 
)

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

385 {
386  for( int i = m_meanders.size() - 1; i >= 0; i-- )
387  {
388  MEANDER_SHAPE* m = m_meanders[i];
389 
390  if( m->Type() == MT_EMPTY || m->Type() == MT_CORNER )
391  continue;
392 
393  const SEG& b1 = aShape->BaseSegment();
394  const SEG& b2 = m->BaseSegment();
395 
396  if( b1.ApproxParallel( b2 ) )
397  continue;
398 
399  int n = m->CLine( 0 ).SegmentCount();
400 
401  for( int j = n - 1; j >= 0; j-- )
402  if( aShape->CLine( 0 ).Collide( m->CLine( 0 ) .CSegment( j ), aClearance ) )
403  return false;
404  }
405 
406  return true;
407 }
std::vector< MEANDER_SHAPE * > m_meanders
Definition: pns_meander.h:474
bool ApproxParallel(const SEG &aSeg) const
Definition: seg.h:290
Definition: seg.h:40

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

◆ Clear()

void PNS::MEANDERED_LINE::Clear ( )

Clear the line geometry, removing all corners and meanders.

Definition at line 567 of file pns_meander.cpp.

568 {
569  for( MEANDER_SHAPE* m : m_meanders )
570  {
571  delete m;
572  }
573 
574  m_meanders.clear( );
575 }
std::vector< MEANDER_SHAPE * > m_meanders
Definition: pns_meander.h:474

References m_meanders.

Referenced by ~MEANDERED_LINE().

◆ Meanders()

std::vector<MEANDER_SHAPE*>& PNS::MEANDERED_LINE::Meanders ( )
inline
Returns
set of meander shapes for this line.

Definition at line 451 of file pns_meander.h.

452  {
453  return m_meanders;
454  }
std::vector< MEANDER_SHAPE * > m_meanders
Definition: pns_meander.h:474

References m_meanders.

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

◆ MeanderSegment()

void PNS::MEANDERED_LINE::MeanderSegment ( const SEG aSeg,
int  aBaseIndex = 0 
)

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

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

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::MEANDER_PLACER::doMove(), and PNS::DP_MEANDER_PLACER::Move().

◆ SetBaselineOffset()

void PNS::MEANDERED_LINE::SetBaselineOffset ( int  aOffset)
inline

Set the parallel offset between the base segment and the meandered line.

Used for dual meanders (diff pair) only.

Parameters
aOffsetthe offset.

Definition at line 443 of file pns_meander.h.

444  {
445  m_baselineOffset = aOffset;
446  }

References m_baselineOffset.

Referenced by PNS::MEANDER_PLACER::doMove(), and PNS::DP_MEANDER_PLACER::Move().

◆ Settings()

const MEANDER_SETTINGS & PNS::MEANDERED_LINE::Settings ( ) const
Returns
the current meandering settings.

Definition at line 39 of file pns_meander.cpp.

40 {
41  return m_placer->MeanderSettings();
42 }
MEANDER_PLACER_BASE * m_placer
Definition: pns_meander.h:473
virtual const MEANDER_SETTINGS & MeanderSettings() const
Return the current meandering configuration.

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

Referenced by MeanderSegment().

◆ SetWidth()

void PNS::MEANDERED_LINE::SetWidth ( int  aWidth)
inline

Set the line width.

Definition at line 429 of file pns_meander.h.

430  {
431  m_width = aWidth;
432  }

References m_width.

Referenced by PNS::MEANDER_PLACER::doMove(), and PNS::DP_MEANDER_PLACER::Move().

Member Data Documentation

◆ m_baselineOffset

int PNS::MEANDERED_LINE::m_baselineOffset
private

Definition at line 478 of file pns_meander.h.

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

◆ m_dual

bool PNS::MEANDERED_LINE::m_dual
private

Definition at line 476 of file pns_meander.h.

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

◆ m_last

VECTOR2I PNS::MEANDERED_LINE::m_last
private

Definition at line 471 of file pns_meander.h.

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

◆ m_meanders

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

Definition at line 474 of file pns_meander.h.

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

◆ m_placer

MEANDER_PLACER_BASE* PNS::MEANDERED_LINE::m_placer
private

Definition at line 473 of file pns_meander.h.

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

◆ m_width

int PNS::MEANDERED_LINE::m_width
private

Definition at line 477 of file pns_meander.h.

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


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