KiCad PCB EDA Suite
PNS::DP_MEANDER_PLACER Class Reference

Class DP_MEANDER_PLACER. More...

#include <pns_dp_meander_placer.h>

Inheritance diagram for PNS::DP_MEANDER_PLACER:
PNS::MEANDER_PLACER_BASE PNS::PLACEMENT_ALGO PNS::ALGO_BASE

Public Types

enum  TUNING_STATUS { TOO_SHORT = 0, TOO_LONG, TUNED }
 

Result of the length tuning operation

More...
 

Public Member Functions

 DP_MEANDER_PLACER (ROUTER *aRouter)
 
 ~DP_MEANDER_PLACER ()
 
bool Start (const VECTOR2I &aP, ITEM *aStartItem) override
 Function Start() More...
 
bool Move (const VECTOR2I &aP, ITEM *aEndItem) override
 Function Move() More...
 
bool FixRoute (const VECTOR2I &aP, ITEM *aEndItem) override
 Function FixRoute() More...
 
const LINE Trace () const
 
NODECurrentNode (bool aLoopsRemoved=false) const override
 Function CurrentNode() More...
 
const ITEM_SET Traces () override
 Function Traces() More...
 
const VECTOR2ICurrentEnd () const override
 Function CurrentEnd() More...
 
const std::vector< int > CurrentNets () const override
 Function CurrentNets() More...
 
int CurrentLayer () const override
 Function CurrentLayer() More...
 
int totalLength ()
 
const wxString TuningInfo () const override
 Function TuningInfo() More...
 
TUNING_STATUS TuningStatus () const override
 Function TuningStatus() More...
 
bool CheckFit (MEANDER_SHAPE *aShape) override
 Function CheckFit() More...
 
virtual void AmplitudeStep (int aSign)
 Function AmplitudeStep() More...
 
virtual void SpacingStep (int aSign)
 Function SpacingStep() More...
 
virtual const MEANDER_SETTINGSMeanderSettings () const
 Function MeanderSettings() More...
 
virtual void UpdateSettings (const MEANDER_SETTINGS &aSettings)
 
virtual bool ToggleVia (bool aEnabled)
 Function ToggleVia() More...
 
virtual bool IsPlacingVia () const
 Function IsPlacingVia() More...
 
virtual bool SetLayer (int aLayer)
 Function SetLayer() More...
 
virtual void FlipPosture ()
 Function FlipPosture() More...
 
virtual void UpdateSizes (const SIZES_SETTINGS &aSizes)
 Function UpdateSizes() More...
 
virtual void SetOrthoMode (bool aOrthoMode)
 Function SetOrthoMode() More...
 
virtual void GetModifiedNets (std::vector< int > &aNets) const
 Function GetModifiedNets. More...
 
ROUTERRouter () const
 

Returns the instance of our router

More...
 
ROUTING_SETTINGSSettings () const
 

Returns current router settings

More...
 
virtual LOGGERLogger ()
 

Returns the logger object, allowing to dump geometry to a file.

More...
 
void SetDebugDecorator (DEBUG_DECORATOR *aDecorator)
 Function SetDebugDecorator. More...
 
DEBUG_DECORATORDbg () const
 

Protected Member Functions

void cutTunedLine (const SHAPE_LINE_CHAIN &aOrigin, const VECTOR2I &aTuneStart, const VECTOR2I &aCursorPos, SHAPE_LINE_CHAIN &aPre, SHAPE_LINE_CHAIN &aTuned, SHAPE_LINE_CHAIN &aPost)
 Function cutTunedLine() More...
 
void tuneLineLength (MEANDERED_LINE &aTuned, int aElongation)
 Function tuneLineLength() More...
 
int compareWithTolerance (int aValue, int aExpected, int aTolerance=0) const
 Function compareWithTolerance() More...
 

Protected Attributes

int m_currentWidth
 

width of the meandered trace(s)

More...
 
MEANDER_SETTINGS m_settings
 

meandering settings

More...
 
VECTOR2I m_currentEnd
 

current end point

More...
 

Private Member Functions

void meanderSegment (const SEG &aBase)
 
const SEG baselineSegment (const DIFF_PAIR::COUPLED_SEGMENTS &aCoupledSegs)
 
void setWorld (NODE *aWorld)
 
void release ()
 
int origPathLength () const
 

Private Attributes

NODEm_world
 

pointer to world to search colliding items

More...
 
VECTOR2I m_currentStart
 

current routing start point (end of tail, beginning of head)

More...
 
NODEm_currentNode
 

Current world state

More...
 
DIFF_PAIR m_originPair
 
DIFF_PAIR::COUPLED_SEGMENTS_VEC m_coupledSegments
 
LINE m_currentTraceN
 
LINE m_currentTraceP
 
ITEM_SET m_tunedPath
 
ITEM_SET m_tunedPathP
 
ITEM_SET m_tunedPathN
 
SHAPE_LINE_CHAIN m_finalShapeP
 
SHAPE_LINE_CHAIN m_finalShapeN
 
MEANDERED_LINE m_result
 
SEGMENTm_initialSegment
 
int m_lastLength
 
TUNING_STATUS m_lastStatus
 

Friends

class MEANDER_SHAPE
 

Detailed Description

Class DP_MEANDER_PLACER.

Differential Pair length-matching/meandering tool.

Definition at line 49 of file pns_dp_meander_placer.h.

Member Enumeration Documentation

Result of the length tuning operation

Enumerator
TOO_SHORT 
TOO_LONG 
TUNED 

Definition at line 52 of file pns_meander_placer_base.h.

Constructor & Destructor Documentation

PNS::DP_MEANDER_PLACER::DP_MEANDER_PLACER ( ROUTER aRouter)

Definition at line 38 of file pns_dp_meander_placer.cpp.

References m_currentNode, m_initialSegment, m_lastLength, m_lastStatus, m_world, and PNS::MEANDER_PLACER_BASE::TOO_SHORT.

38  :
39  MEANDER_PLACER_BASE( aRouter )
40 {
41  m_world = NULL;
42  m_currentNode = NULL;
43 
44  // Init temporary variables (do not leave uninitialized members)
45  m_initialSegment = NULL;
46  m_lastLength = 0;
48 }
NODE * m_currentNode
Current world state
NODE * m_world
pointer to world to search colliding items
PNS::DP_MEANDER_PLACER::~DP_MEANDER_PLACER ( )

Definition at line 51 of file pns_dp_meander_placer.cpp.

52 {
53 }

Member Function Documentation

void PNS::MEANDER_PLACER_BASE::AmplitudeStep ( int  aSign)
virtualinherited

Function AmplitudeStep()

Increases/decreases the current meandering amplitude by one step.

Parameters
aSigndirection (negative = decrease, positive = increase).

Definition at line 40 of file pns_meander_placer_base.cpp.

References PNS::MEANDER_SETTINGS::m_maxAmplitude, PNS::MEANDER_SETTINGS::m_minAmplitude, PNS::MEANDER_PLACER_BASE::m_settings, PNS::MEANDER_SETTINGS::m_step, and max.

Referenced by LENGTH_TUNER_TOOL::performTuning().

41 {
42  int a = m_settings.m_maxAmplitude + aSign * m_settings.m_step;
44 
46 }
int m_minAmplitude
minimum meandering amplitude
Definition: pns_meander.h:76
int m_step
amplitude/spacing adjustment step
Definition: pns_meander.h:82
MEANDER_SETTINGS m_settings
meandering settings
#define max(a, b)
Definition: auxiliary.h:86
int m_maxAmplitude
maximum meandering amplitude
Definition: pns_meander.h:78
const SEG PNS::DP_MEANDER_PLACER::baselineSegment ( const DIFF_PAIR::COUPLED_SEGMENTS aCoupledSegs)
private

Definition at line 146 of file pns_dp_meander_placer.cpp.

References SEG::A, SEG::B, PNS::DIFF_PAIR::COUPLED_SEGMENTS::coupledN, and PNS::DIFF_PAIR::COUPLED_SEGMENTS::coupledP.

Referenced by Move().

147 {
148  const VECTOR2I a( ( aCoupledSegs.coupledP.A + aCoupledSegs.coupledN.A ) / 2 );
149  const VECTOR2I b( ( aCoupledSegs.coupledP.B + aCoupledSegs.coupledN.B ) / 2 );
150 
151  return SEG( a, b );
152 }
Definition: seg.h:37
bool PNS::DP_MEANDER_PLACER::CheckFit ( MEANDER_SHAPE aShape)
overridevirtual

Function CheckFit()

Checks if it's ok to place the shape aShape (i.e. if it doesn't cause DRC violations or collide with other meanders).

Parameters
aShapethe shape to check
Returns
true if the shape fits

Reimplemented from PNS::MEANDER_PLACER_BASE.

Definition at line 319 of file pns_dp_meander_placer.cpp.

References PNS::NODE::CheckColliding(), PNS::MEANDERED_LINE::CheckSelfIntersections(), PNS::MEANDER_SHAPE::CLine(), m_currentNode, m_originPair, m_result, PNS::MEANDER_PLACER_BASE::m_settings, PNS::MEANDER_SETTINGS::m_spacing, PNS::DIFF_PAIR::NLine(), PNS::DIFF_PAIR::PLine(), and PNS::MEANDER_SHAPE::Width().

320 {
321  LINE l1( m_originPair.PLine(), aShape->CLine( 0 ) );
322  LINE l2( m_originPair.NLine(), aShape->CLine( 1 ) );
323 
324  if( m_currentNode->CheckColliding( &l1 ) )
325  return false;
326 
327  if( m_currentNode->CheckColliding( &l2 ) )
328  return false;
329 
330  int w = aShape->Width();
331  int clearance = w + m_settings.m_spacing;
332 
333  return m_result.CheckSelfIntersections( aShape, clearance );
334 }
const SHAPE_LINE_CHAIN & CLine() const
Const accessor to the underlying shape
Definition: pns_line.h:123
bool CheckSelfIntersections(MEANDER_SHAPE *aShape, int aClearance)
Function CheckSelfIntersections()
NODE * m_currentNode
Current world state
MEANDER_SETTINGS m_settings
meandering settings
OPT_OBSTACLE CheckColliding(const ITEM *aItem, int aKindMask=ITEM::ANY_T)
Function CheckColliding()
Definition: pns_node.cpp:427
int m_spacing
meandering period/spacing (see dialog picture for explanation)
Definition: pns_meander.h:80
int PNS::MEANDER_PLACER_BASE::compareWithTolerance ( int  aValue,
int  aExpected,
int  aTolerance = 0 
) const
protectedinherited

Function compareWithTolerance()

Compares aValue against aExpected with given tolerance.

Definition at line 182 of file pns_meander_placer_base.cpp.

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

183 {
184  if( aValue < aExpected - aTolerance )
185  return -1;
186  else if( aValue > aExpected + aTolerance )
187  return 1;
188  else
189  return 0;
190 }
const VECTOR2I & PNS::DP_MEANDER_PLACER::CurrentEnd ( ) const
overridevirtual

Function CurrentEnd()

Returns the current end of the line(s) being placed/tuned. It may not be equal to the cursor position due to collisions.

Implements PNS::PLACEMENT_ALGO.

Definition at line 351 of file pns_dp_meander_placer.cpp.

References PNS::MEANDER_PLACER_BASE::m_currentEnd.

352 {
353  return m_currentEnd;
354 }
VECTOR2I m_currentEnd
current end point
int PNS::DP_MEANDER_PLACER::CurrentLayer ( ) const
overridevirtual

Function CurrentLayer()

Returns the layer of currently routed track.

Implements PNS::PLACEMENT_ALGO.

Definition at line 357 of file pns_dp_meander_placer.cpp.

References PNS::ITEM::Layers(), m_initialSegment, and LAYER_RANGE::Start().

358 {
359  return m_initialSegment->Layers().Start();
360 }
const LAYER_RANGE & Layers() const
Function Layers()
Definition: pns_item.h:207
int Start() const
Definition: pns_layerset.h:83
const std::vector< int > PNS::DP_MEANDER_PLACER::CurrentNets ( ) const
overridevirtual

Function CurrentNets()

Returns the net code(s) of currently routed track(s).

Implements PNS::PLACEMENT_ALGO.

Definition at line 398 of file pns_dp_meander_placer.cpp.

References m_originPair, PNS::DIFF_PAIR::NetN(), and PNS::DIFF_PAIR::NetP().

399 {
400  std::vector<int> rv;
401  rv.push_back( m_originPair.NetP() );
402  rv.push_back( m_originPair.NetN() );
403  return rv;
404 }
int NetP() const
int NetN() const
NODE * PNS::DP_MEANDER_PLACER::CurrentNode ( bool  aLoopsRemoved = false) const
overridevirtual

Function CurrentNode()

Returns the most recent world state.

Implements PNS::PLACEMENT_ALGO.

Definition at line 62 of file pns_dp_meander_placer.cpp.

References m_currentNode, and m_world.

63 {
64  if( !m_currentNode )
65  return m_world;
66 
67  return m_currentNode;
68 }
NODE * m_currentNode
Current world state
NODE * m_world
pointer to world to search colliding items
void PNS::MEANDER_PLACER_BASE::cutTunedLine ( const SHAPE_LINE_CHAIN aOrigin,
const VECTOR2I aTuneStart,
const VECTOR2I aCursorPos,
SHAPE_LINE_CHAIN aPre,
SHAPE_LINE_CHAIN aTuned,
SHAPE_LINE_CHAIN aPost 
)
protectedinherited

Function cutTunedLine()

Extracts the part of a track to be meandered, depending on the starting point and the cursor position.

Parameters
aOriginthe original line
aTuneStartpoint where we start meandering (start click coorinates)
aCursorPoscurrent cursor position
aPrepart before the beginning of meanders
aTunedpart to be meandered
aPostpart after the end of meanders

Definition at line 64 of file pns_meander_placer_base.cpp.

References SEG::A, SEG::B, SHAPE_LINE_CHAIN::CSegment(), SHAPE_LINE_CHAIN::Find(), SHAPE_LINE_CHAIN::FindSegment(), SHAPE_LINE_CHAIN::NearestPoint(), SHAPE_LINE_CHAIN::Reverse(), SHAPE_LINE_CHAIN::Simplify(), SHAPE_LINE_CHAIN::Slice(), and SHAPE_LINE_CHAIN::Split().

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

70 {
71  VECTOR2I cp ( aCursorPos );
72 
73  if ( cp == aTuneStart ) // we don't like tuning segments with 0 length
74  {
75  int idx = aOrigin.FindSegment( cp );
76  if( idx >= 0 )
77  {
78  const SEG& s = aOrigin.CSegment( idx );
79  cp += (s.B - s.A).Resize(2);
80  } else
81  cp += VECTOR2I (2, 5); // some arbitrary value that is not 45 degrees oriented
82  }
83 
84  VECTOR2I n = aOrigin.NearestPoint( cp );
85  VECTOR2I m = aOrigin.NearestPoint( aTuneStart );
86 
87  SHAPE_LINE_CHAIN l( aOrigin );
88  l.Split( n );
89  l.Split( m );
90 
91  int i_start = l.Find( m );
92  int i_end = l.Find( n );
93 
94  if( i_start > i_end )
95  {
96  l = l.Reverse();
97  i_start = l.Find( m );
98  i_end = l.Find( n );
99  }
100 
101  aPre = l.Slice( 0, i_start );
102  aPost = l.Slice( i_end, -1 );
103  aTuned = l.Slice( i_start, i_end );
104 
105  aTuned.Simplify();
106 }
VECTOR2I & B
Definition: seg.h:52
const VECTOR2I NearestPoint(const VECTOR2I &aP) const
Function NearestPoint()
const SHAPE_LINE_CHAIN Slice(int aStartIndex, int aEndIndex=-1) const
Function Slice()
VECTOR2< int > VECTOR2I
Definition: vector2d.h:590
SHAPE_LINE_CHAIN & Simplify()
Function Simplify()
const SEG CSegment(int aIndex) const
Function CSegment()
VECTOR2I & A
Definition: seg.h:51
int FindSegment(const VECTOR2I &aP) const
Function FindSegment()
Definition: seg.h:37
Class SHAPE_LINE_CHAIN.
bool PNS::DP_MEANDER_PLACER::FixRoute ( const VECTOR2I aP,
ITEM aEndItem 
)
overridevirtual

Function FixRoute()

Commits the currently routed track to the parent node, taking aP as the final end point and aEndItem as the final anchor (if provided).

Returns
true, if route has been commited. May return false if the routing result is violating design rules - in such case, the track is only committed if Settings.CanViolateDRC() is on.

Implements PNS::PLACEMENT_ALGO.

Definition at line 305 of file pns_dp_meander_placer.cpp.

References PNS::NODE::Add(), PNS::ROUTER::CommitRouting(), m_currentNode, m_finalShapeN, m_finalShapeP, m_originPair, PNS::DIFF_PAIR::NLine(), PNS::DIFF_PAIR::PLine(), and PNS::ALGO_BASE::Router().

306 {
307  LINE lP( m_originPair.PLine(), m_finalShapeP );
308  LINE lN( m_originPair.NLine(), m_finalShapeN );
309 
310  m_currentNode->Add( lP );
311  m_currentNode->Add( lN );
312 
314 
315  return true;
316 }
NODE * m_currentNode
Current world state
ROUTER * Router() const
Returns the instance of our router
Definition: pns_algo_base.h:49
void CommitRouting(NODE *aNode)
Definition: pns_router.cpp:324
void Add(std::unique_ptr< SEGMENT > aSegment, bool aAllowRedundant=false)
Function Add()
Definition: pns_node.cpp:596
virtual void PNS::PLACEMENT_ALGO::FlipPosture ( )
inlinevirtualinherited

Function FlipPosture()

Toggles the current posture (straight/diagonal) of the trace head.

Reimplemented in PNS::LINE_PLACER, and PNS::DIFF_PAIR_PLACER.

Definition at line 152 of file pns_placement_algo.h.

153  {
154  }
virtual void PNS::PLACEMENT_ALGO::GetModifiedNets ( std::vector< int > &  aNets) const
inlinevirtualinherited

Function GetModifiedNets.

Returns the net codes of all currently routed trace(s)

Reimplemented in PNS::LINE_PLACER, and PNS::DIFF_PAIR_PLACER.

Definition at line 183 of file pns_placement_algo.h.

184  {
185  }
virtual bool PNS::PLACEMENT_ALGO::IsPlacingVia ( ) const
inlinevirtualinherited

Function IsPlacingVia()

Returns true if the placer is placing a via (or more vias).

Reimplemented in PNS::LINE_PLACER, and PNS::DIFF_PAIR_PLACER.

Definition at line 96 of file pns_placement_algo.h.

97  {
98  return false;
99  }
LOGGER * PNS::ALGO_BASE::Logger ( )
virtualinherited

Returns the logger object, allowing to dump geometry to a file.

Reimplemented in PNS::LINE_PLACER, PNS::WALKAROUND, PNS::DRAGGER, and PNS::SHOVE.

Definition at line 34 of file pns_algo_base.cpp.

35 {
36  return NULL;
37 }
void PNS::DP_MEANDER_PLACER::meanderSegment ( const SEG aBase)
private
const MEANDER_SETTINGS & PNS::MEANDER_PLACER_BASE::MeanderSettings ( ) const
virtualinherited

Function MeanderSettings()

Returns the current meandering configuration.

Returns
the settings

Definition at line 176 of file pns_meander_placer_base.cpp.

References PNS::MEANDER_PLACER_BASE::m_settings.

Referenced by PNS::MEANDER_SHAPE::makeMiterShape(), LENGTH_TUNER_TOOL::meanderSettingsDialog(), PNS::MEANDER_SHAPE::Settings(), and PNS::MEANDERED_LINE::Settings().

177 {
178  return m_settings;
179 }
MEANDER_SETTINGS m_settings
meandering settings
bool PNS::DP_MEANDER_PLACER::Move ( const VECTOR2I aP,
ITEM aEndItem 
)
overridevirtual

Function Move()

Moves the end of the currently routed trace to the point aP, taking aEndItem as anchor (if not NULL). (unless NULL).

Implements PNS::PLACEMENT_ALGO.

Definition at line 165 of file pns_dp_meander_placer.cpp.

References PNS::MEANDERED_LINE::AddCorner(), PNS::DEBUG_DECORATOR::AddLine(), PNS::DEBUG_DECORATOR::AddSegment(), SHAPE_LINE_CHAIN::Append(), baselineSegment(), PNS::NODE::Branch(), PNS::ITEM_SET::CItems(), SHAPE_LINE_CHAIN::Clear(), PNS::DIFF_PAIR::CN(), PNS::MEANDER_PLACER_BASE::compareWithTolerance(), PNS::DIFF_PAIR::CP(), PNS::MEANDER_PLACER_BASE::cutTunedLine(), PNS::ALGO_BASE::Dbg(), m_currentNode, m_currentStart, m_finalShapeN, m_finalShapeP, m_lastLength, m_lastStatus, PNS::MEANDER_SETTINGS::m_lengthTolerance, m_originPair, m_result, PNS::MEANDER_PLACER_BASE::m_settings, PNS::MEANDER_SETTINGS::m_targetLength, m_tunedPathN, m_tunedPathP, m_world, max, PNS::MEANDERED_LINE::Meanders(), PNS::MEANDERED_LINE::MeanderSegment(), PNS::MT_EMPTY, origPathLength(), PNS::pairOrientation(), PNS::MEANDERED_LINE::SetBaselineOffset(), PNS::MEANDERED_LINE::SetWidth(), SHAPE_LINE_CHAIN::Simplify(), PNS::MEANDER_PLACER_BASE::TOO_LONG, PNS::MEANDER_PLACER_BASE::TOO_SHORT, PNS::MEANDER_PLACER_BASE::TUNED, and PNS::MEANDER_PLACER_BASE::tuneLineLength().

166 {
167 // return false;
168 
169  DIFF_PAIR::COUPLED_SEGMENTS_VEC coupledSegments;
170 
171  if( m_currentNode )
172  delete m_currentNode;
173 
175 
176  SHAPE_LINE_CHAIN preP, tunedP, postP;
177  SHAPE_LINE_CHAIN preN, tunedN, postN;
178 
179  cutTunedLine( m_originPair.CP(), m_currentStart, aP, preP, tunedP, postP );
180  cutTunedLine( m_originPair.CN(), m_currentStart, aP, preN, tunedN, postN );
181 
182  DIFF_PAIR tuned( m_originPair );
183 
184  tuned.SetShape( tunedP, tunedN );
185 
186  tuned.CoupledSegmentPairs( coupledSegments );
187 
188  if( coupledSegments.size() == 0 )
189  return false;
190 
191  //Router()->DisplayDebugLine( tuned.CP(), 5, 20000 );
192  //Router()->DisplayDebugLine( tuned.CN(), 4, 20000 );
193 
194  //Router()->DisplayDebugLine( m_originPair.CP(), 5, 20000 );
195  //Router()->DisplayDebugLine( m_originPair.CN(), 4, 20000 );
196 
197  m_result = MEANDERED_LINE( this, true );
198  m_result.SetWidth( tuned.Width() );
199 
200  int offset = ( tuned.Gap() + tuned.Width() ) / 2;
201 
202  if( !pairOrientation( coupledSegments[0] ) )
203  offset *= -1;
204 
205  m_result.SetBaselineOffset( offset );
206 
207  for( const ITEM* item : m_tunedPathP.CItems() )
208  {
209  if( const LINE* l = dyn_cast<const LINE*>( item ) )
210  Dbg()->AddLine( l->CLine(), 5, 10000 );
211  }
212 
213  for( const ITEM* item : m_tunedPathN.CItems() )
214  {
215  if( const LINE* l = dyn_cast<const LINE*>( item ) )
216  Dbg()->AddLine( l->CLine(), 5, 10000 );
217  }
218 
219  int curIndexP = 0, curIndexN = 0;
220 
221  for( const DIFF_PAIR::COUPLED_SEGMENTS& sp : coupledSegments )
222  {
223  SEG base = baselineSegment( sp );
224 
225  Dbg()->AddSegment( base, 3 );
226 
227  while( sp.indexP >= curIndexP )
228  {
229  m_result.AddCorner( tunedP.CPoint( curIndexP ), tunedN.CPoint( curIndexN ) );
230  curIndexP++;
231  }
232 
233  while( sp.indexN >= curIndexN )
234  {
235  m_result.AddCorner( tunedP.CPoint( sp.indexP ), tunedN.CPoint( curIndexN ) );
236  curIndexN++;
237  }
238 
239  m_result.MeanderSegment( base );
240  }
241 
242  while( curIndexP < tunedP.PointCount() )
243  m_result.AddCorner( tunedP.CPoint( curIndexP++ ), tunedN.CPoint( curIndexN ) );
244 
245  while( curIndexN < tunedN.PointCount() )
246  m_result.AddCorner( tunedP.CPoint( -1 ), tunedN.CPoint( curIndexN++ ) );
247 
248  int dpLen = origPathLength();
249 
251 
253  {
255  m_lastLength = dpLen;
256  }
257  else
258  {
259  m_lastLength = dpLen - std::max( tunedP.Length(), tunedN.Length() );
261  }
262 
263  if( m_lastStatus != TOO_LONG )
264  {
265  tunedP.Clear();
266  tunedN.Clear();
267 
268  for( MEANDER_SHAPE* m : m_result.Meanders() )
269  {
270  if( m->Type() != MT_EMPTY )
271  {
272  tunedP.Append( m->CLine( 0 ) );
273  tunedN.Append( m->CLine( 1 ) );
274  }
275  }
276 
277  m_lastLength += std::max( tunedP.Length(), tunedN.Length() );
278 
280 
281  if( comp > 0 )
283  else if( comp < 0 )
285  else
287  }
288 
290  m_finalShapeP.Append( preP );
291  m_finalShapeP.Append( tunedP );
292  m_finalShapeP.Append( postP );
294 
296  m_finalShapeN.Append( preN );
297  m_finalShapeN.Append( tunedN );
298  m_finalShapeN.Append( postN );
300 
301  return true;
302 }
const ENTRIES & CItems() const
Definition: pns_itemset.h:138
void AddCorner(const VECTOR2I &aA, const VECTOR2I &aB=VECTOR2I(0, 0))
Function AddCorner()
DEBUG_DECORATOR * Dbg() const
Definition: pns_algo_base.h:70
NODE * m_currentNode
Current world state
void MeanderSegment(const SEG &aSeg, int aBaseIndex=0)
Function MeanderSegment()
Definition: pns_meander.cpp:46
NODE * m_world
pointer to world to search colliding items
const SHAPE_LINE_CHAIN & CN() const
VECTOR2I m_currentStart
current routing start point (end of tail, beginning of head)
NODE * Branch()
Function Branch()
Definition: pns_node.cpp:109
void Append(int aX, int aY, bool aAllowDuplication=false)
Function Append()
void SetWidth(int aWidth)
Function SetWidth()
Definition: pns_meander.h:457
const SEG baselineSegment(const DIFF_PAIR::COUPLED_SEGMENTS &aCoupledSegs)
SHAPE_LINE_CHAIN & Simplify()
Function Simplify()
virtual void AddLine(const SHAPE_LINE_CHAIN &aLine, int aType=0, int aWidth=0)
std::vector< COUPLED_SEGMENTS > COUPLED_SEGMENTS_VEC
virtual void AddSegment(SEG aS, int aColor)
std::vector< MEANDER_SHAPE * > & Meanders()
Function Meanders()
Definition: pns_meander.h:483
void tuneLineLength(MEANDERED_LINE &aTuned, int aElongation)
Function tuneLineLength()
static bool pairOrientation(const DIFF_PAIR::COUPLED_SEGMENTS &aPair)
Definition: seg.h:37
int compareWithTolerance(int aValue, int aExpected, int aTolerance=0) const
Function compareWithTolerance()
MEANDER_SETTINGS m_settings
meandering settings
int m_lengthTolerance
allowable tuning error
Definition: pns_meander.h:90
#define max(a, b)
Definition: auxiliary.h:86
Class SHAPE_LINE_CHAIN.
void Clear()
Function Clear() Removes all points from the line chain.
int m_targetLength
desired length of the tuned line/diff pair
Definition: pns_meander.h:84
void SetBaselineOffset(int aOffset)
Function SetBaselineOffset()
Definition: pns_meander.h:473
void cutTunedLine(const SHAPE_LINE_CHAIN &aOrigin, const VECTOR2I &aTuneStart, const VECTOR2I &aCursorPos, SHAPE_LINE_CHAIN &aPre, SHAPE_LINE_CHAIN &aTuned, SHAPE_LINE_CHAIN &aPost)
Function cutTunedLine()
const SHAPE_LINE_CHAIN & CP() const
int PNS::DP_MEANDER_PLACER::origPathLength ( ) const
private

Definition at line 124 of file pns_dp_meander_placer.cpp.

References PNS::ITEM_SET::CItems(), m_tunedPathN, m_tunedPathP, and max.

Referenced by Move().

125 {
126  int totalP = 0;
127  int totalN = 0;
128 
129  for( const ITEM* item : m_tunedPathP.CItems() )
130  {
131  if( const LINE* l = dyn_cast<const LINE*>( item ) )
132  totalP += l->CLine().Length();
133 
134  }
135 
136  for( const ITEM* item : m_tunedPathN.CItems() )
137  {
138  if( const LINE* l = dyn_cast<const LINE*>( item ) )
139  totalN += l->CLine().Length();
140  }
141 
142  return std::max( totalP, totalN );
143 }
const ENTRIES & CItems() const
Definition: pns_itemset.h:138
#define max(a, b)
Definition: auxiliary.h:86
void PNS::DP_MEANDER_PLACER::release ( )
private

Definition at line 119 of file pns_dp_meander_placer.cpp.

120 {
121 }
void PNS::ALGO_BASE::SetDebugDecorator ( DEBUG_DECORATOR aDecorator)
inlineinherited

Function SetDebugDecorator.

Assign a debug decorator allowing this algo to draw extra graphics for visual debugging

Definition at line 65 of file pns_algo_base.h.

References PNS::ALGO_BASE::m_debugDecorator.

66  {
67  m_debugDecorator = aDecorator;
68  }
DEBUG_DECORATOR * m_debugDecorator
Definition: pns_algo_base.h:76
virtual bool PNS::PLACEMENT_ALGO::SetLayer ( int  aLayer)
inlinevirtualinherited

Function SetLayer()

Sets the current routing layer.

Reimplemented in PNS::DIFF_PAIR_PLACER, and PNS::LINE_PLACER.

Definition at line 106 of file pns_placement_algo.h.

107  {
108  return false;
109  }
virtual void PNS::PLACEMENT_ALGO::SetOrthoMode ( bool  aOrthoMode)
inlinevirtualinherited

Function SetOrthoMode()

Forces the router to place a straight 90/45 degree trace (with the end as near to the cursor as possible) instead of a standard 135 degree two-segment bend.

Reimplemented in PNS::LINE_PLACER, and PNS::DIFF_PAIR_PLACER.

Definition at line 174 of file pns_placement_algo.h.

175  {
176  }
void PNS::DP_MEANDER_PLACER::setWorld ( NODE aWorld)
private
void PNS::MEANDER_PLACER_BASE::SpacingStep ( int  aSign)
virtualinherited

Function SpacingStep()

Increases/decreases the current meandering spcing by one step.

Parameters
aSigndirection (negative = decrease, positive = increase).

Definition at line 49 of file pns_meander_placer_base.cpp.

References PNS::MEANDER_PLACER_BASE::m_currentWidth, PNS::MEANDER_PLACER_BASE::m_settings, PNS::MEANDER_SETTINGS::m_spacing, PNS::MEANDER_SETTINGS::m_step, and max.

Referenced by LENGTH_TUNER_TOOL::performTuning().

50 {
51  int s = m_settings.m_spacing + aSign * m_settings.m_step;
52  s = std::max( s, 2 * m_currentWidth );
53 
55 }
int m_currentWidth
width of the meandered trace(s)
int m_step
amplitude/spacing adjustment step
Definition: pns_meander.h:82
MEANDER_SETTINGS m_settings
meandering settings
#define max(a, b)
Definition: auxiliary.h:86
int m_spacing
meandering period/spacing (see dialog picture for explanation)
Definition: pns_meander.h:80
bool PNS::DP_MEANDER_PLACER::Start ( const VECTOR2I aP,
ITEM aStartItem 
)
overridevirtual

Function Start()

Starts routing a single track at point aP, taking item aStartItem as anchor (unless NULL).

Implements PNS::PLACEMENT_ALGO.

Definition at line 71 of file pns_dp_meander_placer.cpp.

References PNS::TOPOLOGY::AssembleDiffPair(), PNS::TOPOLOGY::AssembleTrivialPath(), PNS::NODE::Branch(), PNS::DIFF_PAIR::Gap(), PNS::LINE::GetLink(), PNS::ROUTER::GetWorld(), m_currentNode, m_currentStart, PNS::MEANDER_PLACER_BASE::m_currentWidth, m_initialSegment, m_originPair, m_tunedPathN, m_tunedPathP, m_world, SEG::NearestPoint(), PNS::DIFF_PAIR::NLine(), PNS::ITEM::OfKind(), PNS::DIFF_PAIR::PLine(), PNS::NODE::Remove(), PNS::ALGO_BASE::Router(), PNS::SEGMENT::Seg(), PNS::ITEM::SEGMENT_T, PNS::LINE::SegmentCount(), PNS::ROUTER::SetFailureReason(), PNS::DIFF_PAIR::SetGap(), and PNS::DIFF_PAIR::Width().

72 {
73  VECTOR2I p;
74 
75  if( !aStartItem || !aStartItem->OfKind( ITEM::SEGMENT_T ) )
76  {
77  Router()->SetFailureReason( _( "Please select a track whose length you want to tune." ) );
78  return false;
79  }
80 
81  m_initialSegment = static_cast<SEGMENT*>( aStartItem );
82 
83  p = m_initialSegment->Seg().NearestPoint( aP );
84 
85  m_currentNode=NULL;
86  m_currentStart = p;
87 
88  m_world = Router()->GetWorld()->Branch();
89 
90  TOPOLOGY topo( m_world );
91 
92  if( !topo.AssembleDiffPair( m_initialSegment, m_originPair ) )
93  {
94  Router()->SetFailureReason( _( "Unable to find complementary differential pair "
95  "net for length tuning. Make sure the names of the nets belonging "
96  "to a differential pair end with either _N/_P or +/-." ) );
97  return false;
98  }
99 
100  if( m_originPair.Gap() < 0 )
101  m_originPair.SetGap( Router()->Sizes().DiffPairGap() );
102 
103  if( !m_originPair.PLine().SegmentCount() ||
105  return false;
106 
107  m_tunedPathP = topo.AssembleTrivialPath( m_originPair.PLine().GetLink( 0 ) );
108  m_tunedPathN = topo.AssembleTrivialPath( m_originPair.NLine().GetLink( 0 ) );
109 
112 
114 
115  return true;
116 }
int Width() const
NODE * m_currentNode
Current world state
NODE * m_world
pointer to world to search colliding items
VECTOR2I m_currentStart
current routing start point (end of tail, beginning of head)
SEGMENT * GetLink(int aIndex) const
Definition: pns_line.h:203
NODE * Branch()
Function Branch()
Definition: pns_node.cpp:109
NODE * GetWorld() const
Definition: pns_router.h:134
int m_currentWidth
width of the meandered trace(s)
void SetGap(int aGap)
int SegmentCount() const
Returns the number of segments in the line
Definition: pns_line.h:129
int Gap() const
void SetFailureReason(const wxString &aReason)
Definition: pns_router.h:204
ROUTER * Router() const
Returns the instance of our router
Definition: pns_algo_base.h:49
void Remove(SOLID *aSolid)
Function Remove()
Definition: pns_node.cpp:729
const VECTOR2I NearestPoint(const VECTOR2I &aP) const
Function NearestPoint()
Definition: seg.h:397
Struct SEGMENT is a simple container used when filling areas with segments.
Definition: class_zone.h:57
const SEG & Seg() const
Definition: pns_segment.h:93
virtual bool PNS::PLACEMENT_ALGO::ToggleVia ( bool  aEnabled)
inlinevirtualinherited

Function ToggleVia()

Enables/disables a via at the end of currently routed trace.

Reimplemented in PNS::DIFF_PAIR_PLACER, and PNS::LINE_PLACER.

Definition at line 86 of file pns_placement_algo.h.

87  {
88  return false;
89  }
int PNS::DP_MEANDER_PLACER::totalLength ( )
const LINE PNS::DP_MEANDER_PLACER::Trace ( ) const

Definition at line 56 of file pns_dp_meander_placer.cpp.

References m_currentTraceP.

57 {
58  return m_currentTraceP;
59 }
const ITEM_SET PNS::DP_MEANDER_PLACER::Traces ( )
overridevirtual

Function Traces()

Returns all routed/tuned traces.

Implements PNS::PLACEMENT_ALGO.

Definition at line 337 of file pns_dp_meander_placer.cpp.

References PNS::ITEM_SET::Add(), m_currentTraceN, m_currentTraceP, m_finalShapeN, m_finalShapeP, m_originPair, PNS::DIFF_PAIR::NLine(), and PNS::DIFF_PAIR::PLine().

338 {
341 
342  ITEM_SET traces;
343 
344  traces.Add( &m_currentTraceP );
345  traces.Add( &m_currentTraceN );
346 
347  return traces;
348 }
void PNS::MEANDER_PLACER_BASE::tuneLineLength ( MEANDERED_LINE aTuned,
int  aElongation 
)
protectedinherited

Function tuneLineLength()

Takes a set of meanders in aTuned and tunes their length to extend the original line length by aElongation.

Definition at line 109 of file pns_meander_placer_base.cpp.

References PNS::MEANDER_SETTINGS::m_minAmplitude, PNS::MEANDER_PLACER_BASE::m_settings, max, PNS::MEANDERED_LINE::Meanders(), PNS::MT_CORNER, PNS::MT_EMPTY, PNS::MT_FINISH, PNS::MT_SINGLE, and PNS::MT_START.

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

110 {
111  int remaining = aElongation;
112  bool finished = false;
113 
114  for( MEANDER_SHAPE* m : aTuned.Meanders() )
115  {
116  if( m->Type() != MT_CORNER )
117  {
118  if( remaining >= 0 )
119  remaining -= m->MaxTunableLength() - m->BaselineLength();
120 
121  if( remaining < 0 )
122  {
123  if( !finished )
124  {
125  MEANDER_TYPE newType;
126 
127  if( m->Type() == MT_START || m->Type() == MT_SINGLE )
128  newType = MT_SINGLE;
129  else
130  newType = MT_FINISH;
131 
132  m->SetType( newType );
133  m->Recalculate();
134 
135  finished = true;
136  } else {
137  m->MakeEmpty();
138  }
139  }
140  }
141  }
142 
143  remaining = aElongation;
144  int meanderCount = 0;
145 
146  for(MEANDER_SHAPE* m : aTuned.Meanders())
147  {
148  if( m->Type() != MT_CORNER && m->Type() != MT_EMPTY )
149  {
150  if(remaining >= 0)
151  {
152  remaining -= m->MaxTunableLength() - m->BaselineLength();
153  meanderCount ++;
154  }
155  }
156  }
157 
158  int balance = 0;
159 
160  if( meanderCount )
161  balance = -remaining / meanderCount;
162 
163  if( balance >= 0 )
164  {
165  for( MEANDER_SHAPE* m : aTuned.Meanders() )
166  {
167  if( m->Type() != MT_CORNER && m->Type() != MT_EMPTY )
168  {
169  m->Resize( std::max( m->Amplitude() - balance / 2, m_settings.m_minAmplitude ) );
170  }
171  }
172  }
173 }
int m_minAmplitude
minimum meandering amplitude
Definition: pns_meander.h:76
MEANDER_TYPE
Shapes of available meanders.
Definition: pns_meander.h:35
MEANDER_SETTINGS m_settings
meandering settings
#define max(a, b)
Definition: auxiliary.h:86
const wxString PNS::DP_MEANDER_PLACER::TuningInfo ( ) const
overridevirtual

Function TuningInfo()

Returns a string describing the status and length of the tuned traces.

Implements PNS::MEANDER_PLACER_BASE.

Definition at line 363 of file pns_dp_meander_placer.cpp.

References PNS::DIFF_PAIR::Gap(), LengthDoubleToString(), m_lastLength, m_lastStatus, m_originPair, PNS::MEANDER_PLACER_BASE::m_settings, PNS::MEANDER_SETTINGS::m_targetLength, PNS::MEANDER_PLACER_BASE::TOO_LONG, PNS::MEANDER_PLACER_BASE::TOO_SHORT, and PNS::MEANDER_PLACER_BASE::TUNED.

364 {
365  wxString status;
366 
367  switch( m_lastStatus )
368  {
369  case TOO_LONG:
370  status = _( "Too long: " );
371  break;
372  case TOO_SHORT:
373  status = _("Too short: " );
374  break;
375  case TUNED:
376  status = _( "Tuned: " );
377  break;
378  default:
379  return _( "?" );
380  }
381 
382  status += LengthDoubleToString( (double) m_lastLength, false );
383  status += "/";
384  status += LengthDoubleToString( (double) m_settings.m_targetLength, false );
385  status += " (gap: ";
386  status += LengthDoubleToString( (double) m_originPair.Gap(), false );
387  status += ")";
388 
389  return status;
390 }
int Gap() const
wxString LengthDoubleToString(double aValue, bool aConvertToMils)
Function LengthDoubleToString is a helper to convert the double length aValue to a string in inches...
Definition: base_units.cpp:122
MEANDER_SETTINGS m_settings
meandering settings
int m_targetLength
desired length of the tuned line/diff pair
Definition: pns_meander.h:84
DP_MEANDER_PLACER::TUNING_STATUS PNS::DP_MEANDER_PLACER::TuningStatus ( ) const
overridevirtual

Function TuningStatus()

Returns the tuning status (too short, too long, etc.) of the trace(s) being tuned.

Implements PNS::MEANDER_PLACER_BASE.

Definition at line 393 of file pns_dp_meander_placer.cpp.

References m_lastStatus.

394 {
395  return m_lastStatus;
396 }
void PNS::MEANDER_PLACER_BASE::UpdateSettings ( const MEANDER_SETTINGS aSettings)
virtualinherited

Definition at line 58 of file pns_meander_placer_base.cpp.

References PNS::MEANDER_PLACER_BASE::m_settings.

Referenced by LENGTH_TUNER_TOOL::meanderSettingsDialog(), and LENGTH_TUNER_TOOL::performTuning().

59 {
60  m_settings = aSettings;
61 }
MEANDER_SETTINGS m_settings
meandering settings
virtual void PNS::PLACEMENT_ALGO::UpdateSizes ( const SIZES_SETTINGS aSizes)
inlinevirtualinherited

Function UpdateSizes()

Performs on-the-fly update of the width, via diameter & drill size from a settings class. Used to dynamically change these parameters as the track is routed.

Reimplemented in PNS::LINE_PLACER, and PNS::DIFF_PAIR_PLACER.

Definition at line 163 of file pns_placement_algo.h.

164  {
165  }

Friends And Related Function Documentation

friend class MEANDER_SHAPE
friend

Definition at line 110 of file pns_dp_meander_placer.h.

Member Data Documentation

DIFF_PAIR::COUPLED_SEGMENTS_VEC PNS::DP_MEANDER_PLACER::m_coupledSegments
private

Definition at line 134 of file pns_dp_meander_placer.h.

VECTOR2I PNS::MEANDER_PLACER_BASE::m_currentEnd
protectedinherited
NODE* PNS::DP_MEANDER_PLACER::m_currentNode
private

Current world state

Definition at line 131 of file pns_dp_meander_placer.h.

Referenced by CheckFit(), CurrentNode(), DP_MEANDER_PLACER(), FixRoute(), Move(), and Start().

VECTOR2I PNS::DP_MEANDER_PLACER::m_currentStart
private

current routing start point (end of tail, beginning of head)

Definition at line 128 of file pns_dp_meander_placer.h.

Referenced by Move(), and Start().

LINE PNS::DP_MEANDER_PLACER::m_currentTraceN
private

Definition at line 136 of file pns_dp_meander_placer.h.

Referenced by Traces().

LINE PNS::DP_MEANDER_PLACER::m_currentTraceP
private

Definition at line 136 of file pns_dp_meander_placer.h.

Referenced by Trace(), and Traces().

int PNS::MEANDER_PLACER_BASE::m_currentWidth
protectedinherited
SHAPE_LINE_CHAIN PNS::DP_MEANDER_PLACER::m_finalShapeN
private

Definition at line 139 of file pns_dp_meander_placer.h.

Referenced by FixRoute(), Move(), and Traces().

SHAPE_LINE_CHAIN PNS::DP_MEANDER_PLACER::m_finalShapeP
private

Definition at line 139 of file pns_dp_meander_placer.h.

Referenced by FixRoute(), Move(), and Traces().

SEGMENT* PNS::DP_MEANDER_PLACER::m_initialSegment
private

Definition at line 141 of file pns_dp_meander_placer.h.

Referenced by CurrentLayer(), DP_MEANDER_PLACER(), and Start().

int PNS::DP_MEANDER_PLACER::m_lastLength
private

Definition at line 143 of file pns_dp_meander_placer.h.

Referenced by DP_MEANDER_PLACER(), Move(), and TuningInfo().

TUNING_STATUS PNS::DP_MEANDER_PLACER::m_lastStatus
private

Definition at line 144 of file pns_dp_meander_placer.h.

Referenced by DP_MEANDER_PLACER(), Move(), TuningInfo(), and TuningStatus().

DIFF_PAIR PNS::DP_MEANDER_PLACER::m_originPair
private

Definition at line 133 of file pns_dp_meander_placer.h.

Referenced by CheckFit(), CurrentNets(), FixRoute(), Move(), Start(), Traces(), and TuningInfo().

MEANDERED_LINE PNS::DP_MEANDER_PLACER::m_result
private

Definition at line 140 of file pns_dp_meander_placer.h.

Referenced by CheckFit(), and Move().

ITEM_SET PNS::DP_MEANDER_PLACER::m_tunedPath
private

Definition at line 137 of file pns_dp_meander_placer.h.

ITEM_SET PNS::DP_MEANDER_PLACER::m_tunedPathN
private

Definition at line 137 of file pns_dp_meander_placer.h.

Referenced by Move(), origPathLength(), and Start().

ITEM_SET PNS::DP_MEANDER_PLACER::m_tunedPathP
private

Definition at line 137 of file pns_dp_meander_placer.h.

Referenced by Move(), origPathLength(), and Start().

NODE* PNS::DP_MEANDER_PLACER::m_world
private

pointer to world to search colliding items

Definition at line 125 of file pns_dp_meander_placer.h.

Referenced by CurrentNode(), DP_MEANDER_PLACER(), Move(), and Start().


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