KiCad PCB EDA Suite
PNS::MEANDER_PLACER Class Reference

Single track length matching/meandering tool. More...

#include <pns_meander_placer.h>

Inheritance diagram for PNS::MEANDER_PLACER:
PNS::MEANDER_PLACER_BASE PNS::PLACEMENT_ALGO PNS::ALGO_BASE PNS::MEANDER_SKEW_PLACER

Public Types

enum  TUNING_STATUS { TOO_SHORT = 0, TOO_LONG, TUNED }
 < Result of the length tuning operation More...
 

Public Member Functions

 MEANDER_PLACER (ROUTER *aRouter)
 
virtual ~MEANDER_PLACER ()
 
virtual bool Start (const VECTOR2I &aP, ITEM *aStartItem) override
 Function Start() More...
 
virtual bool Move (const VECTOR2I &aP, ITEM *aEndItem) override
 Function Move() More...
 
virtual bool FixRoute (const VECTOR2I &aP, ITEM *aEndItem, bool aForceFinish=false) override
 Function FixRoute() More...
 
bool CommitPlacement () override
 
bool AbortPlacement () override
 
bool HasPlacedAnything () const override
 
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...
 
virtual const wxString TuningInfo (EDA_UNITS aUnits) const override
 Return a string describing the status and length of the tuned traces. More...
 
virtual TUNING_STATUS TuningStatus () const override
 Return the tuning status (too short, too long, etc.) of the trace(s) being tuned. More...
 
bool CheckFit (MEANDER_SHAPE *aShape) override
 Checks if it's OK to place the shape aShape (i.e. More...
 
virtual void AmplitudeStep (int aSign)
 Increase/decreases the current meandering amplitude by one step. More...
 
virtual void SpacingStep (int aSign)
 Increase/decrease the current meandering spacing by one step. More...
 
virtual const MEANDER_SETTINGSMeanderSettings () const
 Return the current meandering configuration. More...
 
virtual void UpdateSettings (const MEANDER_SETTINGS &aSettings)
 
int GetTotalPadToDieLength (const LINE &aLine) const
 
virtual bool UnfixRoute ()
 
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
 Return current router settings. More...
 
ROUTING_SETTINGSSettings () const
 Return the logger object, allowing to dump geometry to a file. More...
 
virtual LOGGERLogger ()
 
void SetLogger (LOGGER *aLogger)
 
void SetDebugDecorator (DEBUG_DECORATOR *aDecorator)
 Assign a debug decorator allowing this algo to draw extra graphics for visual debugging. More...
 
DEBUG_DECORATORDbg () const
 
const BOX2IVisibleViewArea () const
 

Protected Member Functions

bool doMove (const VECTOR2I &aP, ITEM *aEndItem, long long int aTargetLength)
 
void setWorld (NODE *aWorld)
 
virtual long long int origPathLength () const
 current routing start point (end of tail, beginning of head) More...
 
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)
 Extract the part of a track to be meandered, depending on the starting point and the cursor position. More...
 
void tuneLineLength (MEANDERED_LINE &aTuned, long long int aElongation)
 Take a set of meanders in aTuned and tunes their length to extend the original line length by aElongation. More...
 
int compareWithTolerance (long long int aValue, long long int aExpected, long long int aTolerance=0) const
 Compare aValue against aExpected with given tolerance. More...
 
VECTOR2I getSnappedStartPoint (LINKED_ITEM *aStartItem, VECTOR2I aStartPoint)
 Pointer to world to search colliding items. More...
 

Protected Attributes

VECTOR2I m_currentStart
 Current world state. More...
 
NODEm_currentNode
 
LINE m_originLine
 
LINE m_currentTrace
 
ITEM_SET m_tunedPath
 
SHAPE_LINE_CHAIN m_finalShape
 
MEANDERED_LINE m_result
 
LINKED_ITEMm_initialSegment
 
long long int m_lastLength
 
TUNING_STATUS m_lastStatus
 
NODEm_world
 Total length added by pad to die size. More...
 
int m_padToDieLenth
 Width of the meandered trace(s). More...
 
int m_currentWidth
 Meander settings. More...
 
MEANDER_SETTINGS m_settings
 The current end point. More...
 
VECTOR2I m_currentEnd
 
DEBUG_DECORATORm_debugDecorator
 
ROUTERm_router
 
LOGGERm_logger
 

Detailed Description

Single track length matching/meandering tool.

Definition at line 47 of file pns_meander_placer.h.

Member Enumeration Documentation

◆ TUNING_STATUS

< Result of the length tuning operation

Enumerator
TOO_SHORT 
TOO_LONG 
TUNED 

Definition at line 51 of file pns_meander_placer_base.h.

Constructor & Destructor Documentation

◆ MEANDER_PLACER()

PNS::MEANDER_PLACER::MEANDER_PLACER ( ROUTER aRouter)

Definition at line 34 of file pns_meander_placer.cpp.

34  :
35  MEANDER_PLACER_BASE( aRouter )
36 {
38 
39  // Init temporary variables (do not leave uninitialized members)
41  m_lastLength = 0;
43 }
TUNING_STATUS m_lastStatus
long long int m_lastLength
LINKED_ITEM * m_initialSegment
#define NULL

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

◆ ~MEANDER_PLACER()

PNS::MEANDER_PLACER::~MEANDER_PLACER ( )
virtual

Definition at line 46 of file pns_meander_placer.cpp.

47 {
48 }

Member Function Documentation

◆ AbortPlacement()

bool PNS::MEANDER_PLACER::AbortPlacement ( )
overridevirtual

Reimplemented from PNS::PLACEMENT_ALGO.

Definition at line 206 of file pns_meander_placer.cpp.

207 {
209  return true;
210 }
void KillChildren()
Definition: pns_node.cpp:1292
NODE * m_world
Total length added by pad to die size.

References PNS::NODE::KillChildren(), and PNS::MEANDER_PLACER_BASE::m_world.

◆ AmplitudeStep()

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

Increase/decreases the current meandering amplitude by one step.

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

Definition at line 44 of file pns_meander_placer_base.cpp.

45 {
46  int a = m_settings.m_maxAmplitude + aSign * m_settings.m_step;
47  a = std::max( a, m_settings.m_minAmplitude );
48 
50 }
int m_minAmplitude
Maximum meandering amplitude.
Definition: pns_meander.h:77
int m_step
Length PadToDie.
Definition: pns_meander.h:83
MEANDER_SETTINGS m_settings
The current end point.
int m_maxAmplitude
Meandering period/spacing (see dialog picture for explanation).
Definition: pns_meander.h:79

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

◆ CheckFit()

bool PNS::MEANDER_PLACER::CheckFit ( MEANDER_SHAPE aShape)
overridevirtual

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 230 of file pns_meander_placer.cpp.

231 {
232  LINE l( m_originLine, aShape->CLine( 0 ) );
233 
234  if( m_currentNode->CheckColliding( &l ) )
235  return false;
236 
237  int w = aShape->Width();
238  int clearance = w + m_settings.m_spacing;
239 
240  return m_result.CheckSelfIntersections( aShape, clearance );
241 }
const SHAPE_LINE_CHAIN & CLine() const
Definition: pns_line.h:137
bool CheckSelfIntersections(MEANDER_SHAPE *aShape, int aClearance)
Check if the given shape is intersecting with any other meander in the current line.
MEANDER_SETTINGS m_settings
The current end point.
OPT_OBSTACLE CheckColliding(const ITEM *aItem, int aKindMask=ITEM::ANY_T)
Check if the item collides with anything else in the world, and if found, returns the obstacle.
Definition: pns_node.cpp:427
int m_spacing
Amplitude/spacing adjustment step.
Definition: pns_meander.h:81

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

◆ CommitPlacement()

bool PNS::MEANDER_PLACER::CommitPlacement ( )
overridevirtual

Reimplemented from PNS::PLACEMENT_ALGO.

Definition at line 219 of file pns_meander_placer.cpp.

220 {
221  if( m_currentNode )
223 
225  return true;
226 }
ROUTER * Router() const
Return current router settings.
Definition: pns_algo_base.h:54
void CommitRouting()
Definition: pns_router.cpp:655
#define NULL

References PNS::ROUTER::CommitRouting(), m_currentNode, NULL, and PNS::ALGO_BASE::Router().

Referenced by FixRoute().

◆ compareWithTolerance()

int PNS::MEANDER_PLACER_BASE::compareWithTolerance ( long long int  aValue,
long long int  aExpected,
long long int  aTolerance = 0 
) const
protectedinherited

Compare aValue against aExpected with given tolerance.

Definition at line 228 of file pns_meander_placer_base.cpp.

230 {
231  if( aValue < aExpected - aTolerance )
232  return -1;
233  else if( aValue > aExpected + aTolerance )
234  return 1;
235  else
236  return 0;
237 }

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

◆ CurrentEnd()

const VECTOR2I & PNS::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 251 of file pns_meander_placer.cpp.

252 {
253  return m_currentEnd;
254 }

References PNS::MEANDER_PLACER_BASE::m_currentEnd.

◆ CurrentLayer()

int PNS::MEANDER_PLACER::CurrentLayer ( ) const
overridevirtual

Function CurrentLayer()

Returns the layer of currently routed track.

Implements PNS::PLACEMENT_ALGO.

Definition at line 256 of file pns_meander_placer.cpp.

257 {
258  return m_initialSegment->Layers().Start();
259 }
LINKED_ITEM * m_initialSegment
int Start() const
Definition: pns_layerset.h:82
const LAYER_RANGE & Layers() const
Definition: pns_item.h:150

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

◆ CurrentNets()

const std::vector<int> PNS::MEANDER_PLACER::CurrentNets ( ) const
inlineoverridevirtual

Function CurrentNets()

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

Implements PNS::PLACEMENT_ALGO.

Definition at line 82 of file pns_meander_placer.h.

83  {
84  return std::vector<int> (1, m_originLine.Net() );
85  }
int Net() const
Definition: pns_item.h:148

References m_originLine, and PNS::ITEM::Net().

◆ CurrentNode()

NODE * PNS::MEANDER_PLACER::CurrentNode ( bool  aLoopsRemoved = false) const
overridevirtual

Function CurrentNode()

Returns the most recent board state.

Implements PNS::PLACEMENT_ALGO.

Definition at line 51 of file pns_meander_placer.cpp.

52 {
53  if( !m_currentNode )
54  return m_world;
55 
56  return m_currentNode;
57 }
NODE * m_world
Total length added by pad to die size.

References m_currentNode, and PNS::MEANDER_PLACER_BASE::m_world.

◆ cutTunedLine()

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

Extract 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 coordinates).
aCursorPoscurrent cursor position.
aPrepart before the beginning of meanders.
aTunedpart to be meandered.
aPostpart after the end of meanders.

Definition at line 68 of file pns_meander_placer_base.cpp.

71 {
72  VECTOR2I cp ( aCursorPos );
73 
74  if( cp == aTuneStart ) // we don't like tuning segments with 0 length
75  {
76  int idx = aOrigin.FindSegment( cp );
77 
78  if( idx >= 0 )
79  {
80  const SEG& s = aOrigin.CSegment( idx );
81  cp += (s.B - s.A).Resize(2);
82  }
83  else
84  {
85  cp += VECTOR2I (2, 5); // some arbitrary value that is not 45 degrees oriented
86  }
87  }
88 
89  VECTOR2I n = aOrigin.NearestPoint( cp, false );
90  VECTOR2I m = aOrigin.NearestPoint( aTuneStart, false );
91 
92  SHAPE_LINE_CHAIN l( aOrigin );
93  l.Split( n );
94  l.Split( m );
95 
96  int i_start = l.Find( m );
97  int i_end = l.Find( n );
98 
99  if( i_start > i_end )
100  {
101  l = l.Reverse();
102  i_start = l.Find( m );
103  i_end = l.Find( n );
104  }
105 
106  aPre = l.Slice( 0, i_start );
107  aPost = l.Slice( i_end, -1 );
108  aTuned = l.Slice( i_start, i_end );
109 
110  aTuned.Simplify();
111 }
int FindSegment(const VECTOR2I &aP) const
Function FindSegment()
SHAPE_LINE_CHAIN & Simplify(bool aRemoveColinear=true)
Function Simplify()
const SHAPE_LINE_CHAIN Slice(int aStartIndex, int aEndIndex=-1) const
Function Slice()
VECTOR2< int > VECTOR2I
Definition: vector2d.h:623
const VECTOR2I NearestPoint(const VECTOR2I &aP, bool aAllowInternalShapePoints=true) const
Finds a point on the line chain that is closest to point aP.
Definition: seg.h:41
const SEG CSegment(int aIndex) const
Function CSegment()
SHAPE_LINE_CHAIN.
VECTOR2I A
Definition: seg.h:49
VECTOR2I B
Definition: seg.h:50

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

◆ Dbg()

◆ doMove()

bool PNS::MEANDER_PLACER::doMove ( const VECTOR2I aP,
ITEM aEndItem,
long long int  aTargetLength 
)
protected

Definition at line 110 of file pns_meander_placer.cpp.

111 {
112  SHAPE_LINE_CHAIN pre, tuned, post;
113 
114  if( m_currentNode )
115  delete m_currentNode;
116 
118 
119  cutTunedLine( m_originLine.CLine(), m_currentStart, aP, pre, tuned, post );
120 
121  m_result = MEANDERED_LINE( this, false );
124 
125  const std::vector<ssize_t>& tunedShapes = tuned.CShapes();
126 
127  for( int i = 0; i < tuned.SegmentCount(); i++ )
128  {
129  if( tunedShapes[i] >= 0 )
130  continue;
131 
132  const SEG s = tuned.CSegment( i );
133  m_result.AddCorner( s.A );
135  m_result.AddCorner( s.B );
136  }
137 
138  long long int lineLen = origPathLength();
139 
140  m_lastLength = lineLen;
142 
143  if( compareWithTolerance( lineLen, aTargetLength, m_settings.m_lengthTolerance ) > 0 )
144  {
146  } else {
147  m_lastLength = lineLen - tuned.Length();
148  tuneLineLength( m_result, aTargetLength - lineLen );
149  }
150 
151  for( const ITEM* item : m_tunedPath.CItems() )
152  {
153  if( const LINE* l = dyn_cast<const LINE*>( item ) )
154  {
155  Dbg()->AddLine( l->CLine(), 5, 30000 );
156  }
157  }
158 
159  if( m_lastStatus != TOO_LONG )
160  {
161  tuned.Clear();
162 
163  for( MEANDER_SHAPE* m : m_result.Meanders() )
164  {
165  if( m->Type() != MT_EMPTY )
166  {
167  tuned.Append ( m->CLine( 0 ) );
168  }
169  }
170 
171  m_lastLength += tuned.Length();
172 
173  int comp = compareWithTolerance( m_lastLength - aTargetLength, 0, m_settings.m_lengthTolerance );
174 
175  if( comp > 0 )
177  else if( comp < 0 )
179  else
181  }
182 
184  m_finalShape.Append( pre );
185  m_finalShape.Append( tuned );
186  m_finalShape.Append( post );
188 
189  return true;
190 }
const SHAPE_LINE_CHAIN & CLine() const
Definition: pns_line.h:137
virtual void AddLine(const SHAPE_LINE_CHAIN &aLine, int aType=0, int aWidth=0, const std::string aName="")
SHAPE_LINE_CHAIN & Simplify(bool aRemoveColinear=true)
Function Simplify()
void AddCorner(const VECTOR2I &aA, const VECTOR2I &aB=VECTOR2I(0, 0))
Create a dummy meander shape representing a line corner.
void MeanderSegment(const SEG &aSeg, int aBaseIndex=0)
Fit maximum amplitude meanders on a given segment and adds to the current line.
Definition: pns_meander.cpp:46
TUNING_STATUS m_lastStatus
long long int m_lastLength
NODE * Branch()
Create a lightweight copy (called branch) of self that tracks the changes (added/removed items) wrs t...
Definition: pns_node.cpp:124
void Append(int aX, int aY, bool aAllowDuplication=false)
Function Append()
void SetWidth(int aWidth)
Set the line width.
Definition: pns_meander.h:426
std::vector< MEANDER_SHAPE * > & Meanders()
Definition: pns_meander.h:448
NODE * m_world
Total length added by pad to die size.
DEBUG_DECORATOR * Dbg() const
Definition: pns_algo_base.h:78
void tuneLineLength(MEANDERED_LINE &aTuned, long long int aElongation)
Take a set of meanders in aTuned and tunes their length to extend the original line length by aElonga...
Definition: seg.h:41
VECTOR2I m_currentStart
Current world state.
MEANDER_SETTINGS m_settings
The current end point.
int m_lengthTolerance
Number of line segments for arc approximation.
Definition: pns_meander.h:93
SHAPE_LINE_CHAIN.
int compareWithTolerance(long long int aValue, long long int aExpected, long long int aTolerance=0) const
Compare aValue against aExpected with given tolerance.
VECTOR2I A
Definition: seg.h:49
const ENTRIES & CItems() const
Definition: pns_itemset.h:139
int Width() const
Return true if the line is geometrically identical as line aOther.
Definition: pns_line.h:156
void Clear()
Function Clear() Removes all points from the line chain.
SHAPE_LINE_CHAIN m_finalShape
void SetBaselineOffset(int aOffset)
Set the parallel offset between the base segment and the meandered line.
Definition: pns_meander.h:440
virtual long long int origPathLength() const
current routing start point (end of tail, beginning of head)
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)
Extract the part of a track to be meandered, depending on the starting point and the cursor position.
VECTOR2I B
Definition: seg.h:50

References SEG::A, PNS::MEANDERED_LINE::AddCorner(), PNS::DEBUG_DECORATOR::AddLine(), SHAPE_LINE_CHAIN::Append(), SEG::B, PNS::NODE::Branch(), PNS::ITEM_SET::CItems(), SHAPE_LINE_CHAIN::Clear(), PNS::LINE::CLine(), PNS::MEANDER_PLACER_BASE::compareWithTolerance(), PNS::MEANDER_PLACER_BASE::cutTunedLine(), PNS::ALGO_BASE::Dbg(), m_currentNode, m_currentStart, m_finalShape, m_lastLength, m_lastStatus, PNS::MEANDER_SETTINGS::m_lengthTolerance, m_originLine, m_result, PNS::MEANDER_PLACER_BASE::m_settings, m_tunedPath, PNS::MEANDER_PLACER_BASE::m_world, PNS::MEANDERED_LINE::Meanders(), PNS::MEANDERED_LINE::MeanderSegment(), PNS::MT_EMPTY, origPathLength(), 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, PNS::MEANDER_PLACER_BASE::tuneLineLength(), and PNS::LINE::Width().

Referenced by PNS::MEANDER_SKEW_PLACER::Move(), and Move().

◆ FixRoute()

bool PNS::MEANDER_PLACER::FixRoute ( const VECTOR2I aP,
ITEM aEndItem,
bool  aForceFinish = false 
)
overridevirtual

Function FixRoute()

Commits the currently routed items 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 193 of file pns_meander_placer.cpp.

194 {
195  if( !m_currentNode )
196  return false;
197 
200  CommitPlacement();
201 
202  return true;
203 }
bool CommitPlacement() override
SHAPE_LINE_CHAIN m_finalShape
bool Add(std::unique_ptr< SEGMENT > aSegment, bool aAllowRedundant=false)
Add an item to the current node.
Definition: pns_node.cpp:615

References PNS::NODE::Add(), CommitPlacement(), m_currentNode, m_currentTrace, m_finalShape, and m_originLine.

◆ FlipPosture()

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 160 of file pns_placement_algo.h.

161  {
162  }

◆ GetModifiedNets()

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 191 of file pns_placement_algo.h.

192  {
193  }

◆ getSnappedStartPoint()

VECTOR2I PNS::MEANDER_PLACER_BASE::getSnappedStartPoint ( LINKED_ITEM aStartItem,
VECTOR2I  aStartPoint 
)
protectedinherited

Pointer to world to search colliding items.

Definition at line 240 of file pns_meander_placer_base.cpp.

241 {
242  if( aStartItem->Kind() == ITEM::SEGMENT_T )
243  {
244  return static_cast<SEGMENT*>( aStartItem )->Seg().NearestPoint( aStartPoint );
245  }
246  else
247  {
248  wxASSERT( aStartItem->Kind() == ITEM::ARC_T );
249  ARC* arc = static_cast<ARC*>( aStartItem );
250 
251  if( ( VECTOR2I( arc->Anchor( 0 ) - aStartPoint ) ).SquaredEuclideanNorm() <=
252  ( VECTOR2I( arc->Anchor( 1 ) - aStartPoint ) ).SquaredEuclideanNorm() )
253  {
254  return arc->Anchor( 0 );
255  }
256  else
257  {
258  return arc->Anchor( 1 );
259  }
260  }
261 }
VECTOR2< int > VECTOR2I
Definition: vector2d.h:623
Definition: track.h:262

References PNS::ITEM::ARC_T, PNS::ITEM::Kind(), and PNS::ITEM::SEGMENT_T.

Referenced by PNS::MEANDER_SKEW_PLACER::Start(), Start(), and PNS::DP_MEANDER_PLACER::Start().

◆ GetTotalPadToDieLength()

int PNS::MEANDER_PLACER_BASE::GetTotalPadToDieLength ( const LINE aLine) const
inherited

Definition at line 184 of file pns_meander_placer_base.cpp.

185 {
186  int length = 0;
187  JOINT start;
188  JOINT end;
189 
190  m_world->FindLineEnds( aLine, start, end );
191 
192  // Extract the length of the pad to die for start and end pads
193  for( auto& link : start.LinkList() )
194  {
195  if( const SOLID* solid = dynamic_cast<const SOLID*>( link.item ) )
196  {
197  // If there are overlapping pads, choose the first with a non-zero length
198  if( solid->GetPadToDie() > 0 )
199  {
200  length += solid->GetPadToDie();
201  break;
202  }
203  }
204  }
205 
206  for( auto& link : end.LinkList() )
207  {
208  if( const SOLID* solid = dynamic_cast<const SOLID*>( link.item ) )
209  {
210  if( solid->GetPadToDie() > 0 )
211  {
212  length += solid->GetPadToDie();
213  break;
214  }
215  }
216  }
217 
218  return length;
219 }
void FindLineEnds(const LINE &aLine, JOINT &aA, JOINT &aB)
Destroy all child nodes. Applicable only to the root node.
Definition: pns_node.cpp:986
NODE * m_world
Total length added by pad to die size.

References PNS::NODE::FindLineEnds(), PNS::JOINT::LinkList(), and PNS::MEANDER_PLACER_BASE::m_world.

Referenced by PNS::MEANDER_SKEW_PLACER::Start(), Start(), and PNS::DP_MEANDER_PLACER::Start().

◆ HasPlacedAnything()

bool PNS::MEANDER_PLACER::HasPlacedAnything ( ) const
overridevirtual

Reimplemented from PNS::PLACEMENT_ALGO.

Definition at line 213 of file pns_meander_placer.cpp.

214 {
215  return m_currentTrace.SegmentCount() > 0;
216 }
int SegmentCount() const
Definition: pns_line.h:139

References m_currentTrace, and PNS::LINE::SegmentCount().

◆ IsPlacingVia()

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 104 of file pns_placement_algo.h.

105  {
106  return false;
107  }

◆ Logger()

LOGGER * PNS::ALGO_BASE::Logger ( )
virtualinherited

Reimplemented in PNS::SHOVE.

Definition at line 34 of file pns_algo_base.cpp.

35 {
36  return NULL;
37 }
#define NULL

References NULL.

Referenced by PNS::LINE_PLACER::rhShoveOnly(), PNS::LINE_PLACER::rhWalkOnly(), PNS::DRAGGER::Start(), and PNS::DRAGGER::tryWalkaround().

◆ MeanderSettings()

const MEANDER_SETTINGS & PNS::MEANDER_PLACER_BASE::MeanderSettings ( ) const
virtualinherited

Return the current meandering configuration.

Returns
the settings

Definition at line 222 of file pns_meander_placer_base.cpp.

223 {
224  return m_settings;
225 }
MEANDER_SETTINGS m_settings
The current end point.

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().

◆ Move()

bool PNS::MEANDER_PLACER::Move ( const VECTOR2I aP,
ITEM aEndItem 
)
overridevirtual

Function Move()

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

Implements PNS::PLACEMENT_ALGO.

Reimplemented in PNS::MEANDER_SKEW_PLACER.

Definition at line 104 of file pns_meander_placer.cpp.

105 {
106  return doMove( aP, aEndItem, m_settings.m_targetLength );
107 }
bool doMove(const VECTOR2I &aP, ITEM *aEndItem, long long int aTargetLength)
MEANDER_SETTINGS m_settings
The current end point.
long long int m_targetLength
Type of corners for the meandered line.
Definition: pns_meander.h:87

References doMove(), PNS::MEANDER_PLACER_BASE::m_settings, and PNS::MEANDER_SETTINGS::m_targetLength.

◆ origPathLength()

long long int PNS::MEANDER_PLACER::origPathLength ( ) const
protectedvirtual

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

Reimplemented in PNS::MEANDER_SKEW_PLACER.

Definition at line 89 of file pns_meander_placer.cpp.

90 {
91  long long int total = m_padToDieLenth;
92  for( const ITEM* item : m_tunedPath.CItems() )
93  {
94  if( const LINE* l = dyn_cast<const LINE*>( item ) )
95  {
96  total += l->CLine().Length();
97  }
98  }
99 
100  return total;
101 }
int m_padToDieLenth
Width of the meandered trace(s).
const ENTRIES & CItems() const
Definition: pns_itemset.h:139

References PNS::ITEM_SET::CItems(), PNS::MEANDER_PLACER_BASE::m_padToDieLenth, and m_tunedPath.

Referenced by doMove().

◆ Router()

◆ SetDebugDecorator()

void PNS::ALGO_BASE::SetDebugDecorator ( DEBUG_DECORATOR aDecorator)
inlineinherited

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

Definition at line 73 of file pns_algo_base.h.

74  {
75  m_debugDecorator = aDecorator;
76  }
DEBUG_DECORATOR * m_debugDecorator
Definition: pns_algo_base.h:86

References PNS::ALGO_BASE::m_debugDecorator.

Referenced by PNS::LINE_PLACER::rhShoveOnly(), PNS::LINE_PLACER::rhWalkOnly(), PNS::SHOVE::SHOVE(), and PNS::DRAGGER::tryWalkaround().

◆ SetLayer()

virtual bool PNS::PLACEMENT_ALGO::SetLayer ( int  aLayer)
inlinevirtualinherited

Function SetLayer()

Sets the current routing layer.

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

Definition at line 114 of file pns_placement_algo.h.

115  {
116  return false;
117  }

◆ SetLogger()

void PNS::ALGO_BASE::SetLogger ( LOGGER aLogger)
inlineinherited

Definition at line 65 of file pns_algo_base.h.

66  {
67  m_logger = aLogger;
68  }
LOGGER * m_logger
Definition: pns_algo_base.h:88

References PNS::ALGO_BASE::m_logger.

Referenced by PNS::LINE_PLACER::rhShoveOnly(), PNS::LINE_PLACER::rhWalkOnly(), and PNS::DRAGGER::tryWalkaround().

◆ SetOrthoMode()

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 182 of file pns_placement_algo.h.

183  {
184  }

◆ Settings()

◆ setWorld()

void PNS::MEANDER_PLACER::setWorld ( NODE aWorld)
protected

◆ SpacingStep()

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

Increase/decrease the current meandering spacing by one step.

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

Definition at line 53 of file pns_meander_placer_base.cpp.

54 {
55  int s = m_settings.m_spacing + aSign * m_settings.m_step;
56  s = std::max( s, 2 * m_currentWidth );
57 
59 }
int m_currentWidth
Meander settings.
int m_step
Length PadToDie.
Definition: pns_meander.h:83
MEANDER_SETTINGS m_settings
The current end point.
int m_spacing
Amplitude/spacing adjustment step.
Definition: pns_meander.h:81

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

◆ Start()

bool PNS::MEANDER_PLACER::Start ( const VECTOR2I aP,
ITEM aStartItem 
)
overridevirtual

Function Start()

Starts placement/drag operation at point aP, taking item aStartItem as anchor (unless NULL).

Implements PNS::PLACEMENT_ALGO.

Reimplemented in PNS::MEANDER_SKEW_PLACER.

Definition at line 60 of file pns_meander_placer.cpp.

61 {
62  if( !aStartItem || !aStartItem->OfKind( ITEM::SEGMENT_T | ITEM::ARC_T ) )
63  {
64  Router()->SetFailureReason( _( "Please select a track whose length you want to tune." ) );
65  return false;
66  }
67 
68  m_initialSegment = static_cast<LINKED_ITEM*>( aStartItem );
69  m_currentNode = nullptr;
71 
72  m_world = Router()->GetWorld()->Branch();
74 
76 
77  TOPOLOGY topo( m_world );
78  m_tunedPath = topo.AssembleTrivialPath( m_initialSegment );
79 
81 
83  m_currentEnd = VECTOR2I( 0, 0 );
84 
85  return true;
86 }
int GetTotalPadToDieLength(const LINE &aLine) const
ROUTER * Router() const
Return current router settings.
Definition: pns_algo_base.h:54
LINKED_ITEM * m_initialSegment
VECTOR2< int > VECTOR2I
Definition: vector2d.h:623
NODE * Branch()
Create a lightweight copy (called branch) of self that tracks the changes (added/removed items) wrs t...
Definition: pns_node.cpp:124
int m_currentWidth
Meander settings.
void Remove(ARC *aArc)
Remove an item from this branch.
Definition: pns_node.cpp:804
const LINE AssembleLine(LINKED_ITEM *aSeg, int *aOriginSegmentIndex=NULL, bool aStopAtLockedJoints=false)
Follow the joint map to assemble a line connecting two non-trivial joints starting from segment aSeg.
Definition: pns_node.cpp:912
NODE * m_world
Total length added by pad to die size.
void SetFailureReason(const wxString &aReason)
Definition: pns_router.h:210
VECTOR2I getSnappedStartPoint(LINKED_ITEM *aStartItem, VECTOR2I aStartPoint)
Pointer to world to search colliding items.
int m_padToDieLenth
Width of the meandered trace(s).
VECTOR2I m_currentStart
Current world state.
#define _(s)
Definition: 3d_actions.cpp:33
int Width() const
Return true if the line is geometrically identical as line aOther.
Definition: pns_line.h:156
NODE * GetWorld() const
Definition: pns_router.h:158

References _, PNS::ITEM::ARC_T, PNS::NODE::AssembleLine(), PNS::TOPOLOGY::AssembleTrivialPath(), PNS::NODE::Branch(), PNS::MEANDER_PLACER_BASE::getSnappedStartPoint(), PNS::MEANDER_PLACER_BASE::GetTotalPadToDieLength(), PNS::ROUTER::GetWorld(), PNS::MEANDER_PLACER_BASE::m_currentEnd, m_currentNode, m_currentStart, PNS::MEANDER_PLACER_BASE::m_currentWidth, m_initialSegment, m_originLine, PNS::MEANDER_PLACER_BASE::m_padToDieLenth, m_tunedPath, PNS::MEANDER_PLACER_BASE::m_world, PNS::ITEM::OfKind(), PNS::NODE::Remove(), PNS::ALGO_BASE::Router(), PNS::ITEM::SEGMENT_T, PNS::ROUTER::SetFailureReason(), and PNS::LINE::Width().

◆ ToggleVia()

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::LINE_PLACER, and PNS::DIFF_PAIR_PLACER.

Definition at line 94 of file pns_placement_algo.h.

95  {
96  return false;
97  }

◆ Traces()

const ITEM_SET PNS::MEANDER_PLACER::Traces ( )
overridevirtual

Function Traces()

Returns all routed/tuned traces.

Implements PNS::PLACEMENT_ALGO.

Definition at line 244 of file pns_meander_placer.cpp.

References m_currentTrace, m_finalShape, and m_originLine.

◆ tuneLineLength()

void PNS::MEANDER_PLACER_BASE::tuneLineLength ( MEANDERED_LINE aTuned,
long long int  aElongation 
)
protectedinherited

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

Definition at line 114 of file pns_meander_placer_base.cpp.

115 {
116  long long int remaining = aElongation;
117  bool finished = false;
118 
119  for( MEANDER_SHAPE* m : aTuned.Meanders() )
120  {
121  if( m->Type() != MT_CORNER )
122  {
123  if( remaining >= 0 )
124  remaining -= m->MaxTunableLength() - m->BaselineLength();
125 
126  if( remaining < 0 )
127  {
128  if( !finished )
129  {
130  MEANDER_TYPE newType;
131 
132  if( m->Type() == MT_START || m->Type() == MT_SINGLE )
133  newType = MT_SINGLE;
134  else
135  newType = MT_FINISH;
136 
137  m->SetType( newType );
138  m->Recalculate();
139 
140  finished = true;
141  }
142  else
143  {
144  m->MakeEmpty();
145  }
146  }
147  }
148  }
149 
150  remaining = aElongation;
151  int meanderCount = 0;
152 
153  for( MEANDER_SHAPE* m : aTuned.Meanders() )
154  {
155  if( m->Type() != MT_CORNER && m->Type() != MT_EMPTY )
156  {
157  if(remaining >= 0)
158  {
159  remaining -= m->MaxTunableLength() - m->BaselineLength();
160  meanderCount ++;
161  }
162  }
163  }
164 
165  long long int balance = 0;
166 
167  if( meanderCount )
168  balance = -remaining / meanderCount;
169 
170  if( balance >= 0 )
171  {
172  for( MEANDER_SHAPE* m : aTuned.Meanders() )
173  {
174  if( m->Type() != MT_CORNER && m->Type() != MT_EMPTY )
175  {
176  m->Resize( std::max( m->Amplitude() - balance / 2,
177  (long long int) m_settings.m_minAmplitude ) );
178  }
179  }
180  }
181 }
int m_minAmplitude
Maximum meandering amplitude.
Definition: pns_meander.h:77
MEANDER_TYPE
Shapes of available meanders.
Definition: pns_meander.h:37
MEANDER_SETTINGS m_settings
The current end point.

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

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

◆ TuningInfo()

const wxString PNS::MEANDER_PLACER::TuningInfo ( EDA_UNITS  aUnits) const
overridevirtual

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

Implements PNS::MEANDER_PLACER_BASE.

Reimplemented in PNS::MEANDER_SKEW_PLACER.

Definition at line 262 of file pns_meander_placer.cpp.

263 {
264  wxString status;
265 
266  switch ( m_lastStatus )
267  {
268  case TOO_LONG:
269  status = _( "Too long: " );
270  break;
271  case TOO_SHORT:
272  status = _( "Too short: " );
273  break;
274  case TUNED:
275  status = _( "Tuned: " );
276  break;
277  default:
278  return _( "?" );
279  }
280 
281  status += ::MessageTextFromValue( aUnits, m_lastLength );
282  status += "/";
283  status += ::MessageTextFromValue( aUnits, m_settings.m_targetLength );
284 
285  return status;
286 }
wxString MessageTextFromValue(EDA_UNITS aUnits, int aValue, bool aAddUnitLabel, EDA_DATA_TYPE aType)
Convert a value to a string using double notation.
Definition: base_units.cpp:125
TUNING_STATUS m_lastStatus
long long int m_lastLength
MEANDER_SETTINGS m_settings
The current end point.
#define _(s)
Definition: 3d_actions.cpp:33
long long int m_targetLength
Type of corners for the meandered line.
Definition: pns_meander.h:87

References _, m_lastLength, m_lastStatus, PNS::MEANDER_PLACER_BASE::m_settings, PNS::MEANDER_SETTINGS::m_targetLength, MessageTextFromValue(), PNS::MEANDER_PLACER_BASE::TOO_LONG, PNS::MEANDER_PLACER_BASE::TOO_SHORT, and PNS::MEANDER_PLACER_BASE::TUNED.

◆ TuningStatus()

MEANDER_PLACER::TUNING_STATUS PNS::MEANDER_PLACER::TuningStatus ( ) const
overridevirtual

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

Implements PNS::MEANDER_PLACER_BASE.

Definition at line 289 of file pns_meander_placer.cpp.

290 {
291  return m_lastStatus;
292 }
TUNING_STATUS m_lastStatus

References m_lastStatus.

◆ UnfixRoute()

virtual bool PNS::PLACEMENT_ALGO::UnfixRoute ( )
inlinevirtualinherited

Reimplemented in PNS::LINE_PLACER.

Definition at line 81 of file pns_placement_algo.h.

81 { return false; };

◆ UpdateSettings()

void PNS::MEANDER_PLACER_BASE::UpdateSettings ( const MEANDER_SETTINGS aSettings)
virtualinherited

Definition at line 62 of file pns_meander_placer_base.cpp.

63 {
64  m_settings = aSettings;
65 }
MEANDER_SETTINGS m_settings
The current end point.

References PNS::MEANDER_PLACER_BASE::m_settings.

Referenced by LENGTH_TUNER_TOOL::meanderSettingsDialog().

◆ UpdateSizes()

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 171 of file pns_placement_algo.h.

172  {
173  }

◆ VisibleViewArea()

const BOX2I & PNS::ALGO_BASE::VisibleViewArea ( ) const
inherited

Definition at line 39 of file pns_algo_base.cpp.

40 {
41  auto bb = m_router->VisibleViewArea();
42  return m_router->VisibleViewArea();
43 }
ROUTER * m_router
Definition: pns_algo_base.h:87
const BOX2I & VisibleViewArea() const
Definition: pns_router.h:225

References PNS::ALGO_BASE::m_router, and PNS::ROUTER::VisibleViewArea().

Referenced by PNS::SHOVE::runOptimizer().

Member Data Documentation

◆ m_currentEnd

VECTOR2I PNS::MEANDER_PLACER_BASE::m_currentEnd
protectedinherited

◆ m_currentNode

NODE* PNS::MEANDER_PLACER::m_currentNode
protected

◆ m_currentStart

VECTOR2I PNS::MEANDER_PLACER::m_currentStart
protected

Current world state.

Definition at line 107 of file pns_meander_placer.h.

Referenced by doMove(), PNS::MEANDER_SKEW_PLACER::Start(), and Start().

◆ m_currentTrace

LINE PNS::MEANDER_PLACER::m_currentTrace
protected

Definition at line 113 of file pns_meander_placer.h.

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

◆ m_currentWidth

int PNS::MEANDER_PLACER_BASE::m_currentWidth
protectedinherited

◆ m_debugDecorator

DEBUG_DECORATOR* PNS::ALGO_BASE::m_debugDecorator
protectedinherited

Definition at line 86 of file pns_algo_base.h.

Referenced by PNS::ALGO_BASE::Dbg(), and PNS::ALGO_BASE::SetDebugDecorator().

◆ m_finalShape

SHAPE_LINE_CHAIN PNS::MEANDER_PLACER::m_finalShape
protected

Definition at line 116 of file pns_meander_placer.h.

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

◆ m_initialSegment

LINKED_ITEM* PNS::MEANDER_PLACER::m_initialSegment
protected

◆ m_lastLength

long long int PNS::MEANDER_PLACER::m_lastLength
protected

◆ m_lastStatus

TUNING_STATUS PNS::MEANDER_PLACER::m_lastStatus
protected

◆ m_logger

LOGGER* PNS::ALGO_BASE::m_logger
protectedinherited

Definition at line 88 of file pns_algo_base.h.

Referenced by PNS::ALGO_BASE::SetLogger(), and PNS::WALKAROUND::singleStep().

◆ m_originLine

LINE PNS::MEANDER_PLACER::m_originLine
protected

◆ m_padToDieLenth

◆ m_result

MEANDERED_LINE PNS::MEANDER_PLACER::m_result
protected

Definition at line 117 of file pns_meander_placer.h.

Referenced by CheckFit(), and doMove().

◆ m_router

◆ m_settings

◆ m_tunedPath

ITEM_SET PNS::MEANDER_PLACER::m_tunedPath
protected

Definition at line 114 of file pns_meander_placer.h.

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

◆ m_world


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