KiCad PCB EDA Suite
pns_meander.cpp
Go to the documentation of this file.
1/*
2 * KiRouter - a push-and-(sometimes-)shove PCB router
3 *
4 * Copyright (C) 2013-2014 CERN
5 * Copyright (C) 2016-2022 KiCad Developers, see AUTHORS.txt for contributors.
6 * Author: Tomasz Wlostowski <[email protected]>
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation, either version 3 of the License, or (at your
11 * option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#include <base_units.h> // God forgive me doing this...
23
24#include "pns_node.h"
25#include "pns_itemset.h"
26#include "pns_meander.h"
28#include "pns_router.h"
29#include "pns_debug_decorator.h"
30
31namespace PNS {
32
34{
35 return m_placer->MeanderSettings();
36}
37
38
40{
41 return m_placer->MeanderSettings();
42}
43
44
45void MEANDERED_LINE::MeanderSegment( const SEG& aBase, bool aSide, int aBaseIndex )
46{
47 double base_len = aBase.Length();
48
50
51 bool singleSided = Settings().m_singleSided;
52 bool side = aSide;
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 {
66
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 auto addSingleIfFits = [&]()
76 {
77 fail = true;
78
79 if( m.Fit( MT_SINGLE, aBase, m_last, side ) )
80 {
81 AddMeander( new MEANDER_SHAPE( m ) );
82 fail = false;
83 started = false;
84 }
85
86 if( fail && !singleSided )
87 {
88 if( m.Fit( MT_SINGLE, aBase, m_last, !side ) )
89 {
90 AddMeander( new MEANDER_SHAPE( m ) );
91 fail = false;
92 started = false;
93 side = !side;
94 }
95 }
96 };
97
98 if( remaining < Settings( ).m_step )
99 break;
100
101 if( !singleSided && remaining > 3.0 * thr )
102 {
103 if( !turning )
104 {
105 for( int i = 0; i < 2; i++ )
106 {
107 bool checkSide = ( i == 0 ) ? side : !side;
108
109 if( m.Fit( MT_CHECK_START, aBase, m_last, checkSide ) )
110 {
111 turning = true;
112 AddMeander( new MEANDER_SHAPE( m ) );
113 side = !checkSide;
114 started = true;
115 break;
116 }
117 }
118
119 if( !turning )
120 addSingleIfFits();
121 }
122 else
123 {
124 bool rv = m.Fit( MT_CHECK_FINISH, aBase, m_last, side );
125
126 if( rv )
127 {
128 m.Fit( MT_TURN, aBase, m_last, side );
129 AddMeander( new MEANDER_SHAPE( m ) );
130 side = !side;
131 started = true;
132 }
133 else
134 {
135 m.Fit( MT_FINISH, aBase, m_last, side );
136 started = false;
137 AddMeander( new MEANDER_SHAPE( m ) );
138 turning = false;
139 }
140 }
141 }
142 else if( !singleSided && started )
143 {
144 bool rv = m.Fit( MT_FINISH, aBase, m_last, side );
145
146 if( rv )
147 AddMeander( new MEANDER_SHAPE( m ) );
148
149 break;
150
151 }
152 else if( !turning && remaining > thr * 2.0 )
153 {
154 addSingleIfFits();
155 }
156 else
157 {
158 fail = true;
159 }
160
161 remaining = base_len - ( m_last - aBase.A ).EuclideanNorm( );
162
163 if( remaining < Settings( ).m_step )
164 break;
165
166 if( fail )
167 {
170 tmp.SetBaseIndex( aBaseIndex );
171
172 int nextP = tmp.spacing() - 2 * tmp.cornerRadius() + Settings().m_step;
173 VECTOR2I pn = m_last + dir.Resize( nextP );
174
175 if( aBase.Contains( pn ) && !m_dual )
176 {
177 AddCorner( pn );
178 } else
179 break;
180 }
181
182
183 } while( true );
184
185 if( !m_dual )
186 AddCorner( aBase.B );
187}
188
189
191{
192 int minAmplitude = Settings().m_minAmplitude;
193
194 // DP meanders don't really support smaller amplitudes
195 minAmplitude = std::max( minAmplitude, std::abs( m_baselineOffset ) * 2 );
196
197 // The path length won't be correct with very small arcs
199 minAmplitude = std::max( minAmplitude, m_width + std::abs( m_baselineOffset ) * 2 );
200
201 return minAmplitude;
202}
203
204
206{
207 // TODO: fix diff-pair meandering so we can use non-100% radii
208 int rPercent = m_dual ? 100 : Settings().m_cornerRadiusPercentage;
209
210 int optCr = (int64_t) spacing() * rPercent / 200;
211 int minCr = std::abs( m_baselineOffset );
212 int maxCr = std::min( m_amplitude / 2, spacing() / 2 );
213
214 int cr = std::clamp( optCr, minCr, maxCr );
215
216 return cr;
217}
218
219
221{
222 if( !m_dual )
223 {
224 return std::max( m_width + m_placer->Clearance(), Settings().m_spacing );
225 }
226 else
227 {
228 int sp = m_width + m_placer->Clearance() + ( 2 * std::abs( m_baselineOffset ) );
229 return std::max( sp, Settings().m_spacing );
230 }
231}
232
233
235 bool aSide )
236{
238
239 if( aDir.EuclideanNorm( ) == 0.0f )
240 {
241 lc.Append( aP );
242 return lc;
243 }
244
245 VECTOR2D dir_u( aDir );
246 VECTOR2D dir_v( aDir.Perpendicular( ) );
247 VECTOR2D p = aP;
248 lc.Append( ( int ) p.x, ( int ) p.y );
249
250 // fixme: refactor
252 {
254 {
255 VECTOR2D center = aP + dir_v * ( aSide ? -1.0 : 1.0 );
256
257 lc.Append( SHAPE_ARC( center, aP, ( aSide ? -ANGLE_90 : ANGLE_90 ) ) );
258 }
259 break;
260
262 {
263 double radius = (double) aDir.EuclideanNorm();
264 double correction = 0;
265
266 if( m_dual && radius > m_meanCornerRadius )
267 correction = (double)( -2 * abs(m_baselineOffset) ) * tan( 22.5 * M_PI / 180.0 );
268
269 VECTOR2D dir_cu = dir_u.Resize( correction );
270 VECTOR2D dir_cv = dir_v.Resize( correction );
271
272 p = aP - dir_cu;
273 lc.Append( ( int ) p.x, ( int ) p.y );
274 p = aP + dir_u + (dir_v + dir_cv) * ( aSide ? -1.0 : 1.0 );
275 lc.Append( ( int ) p.x, ( int ) p.y );
276 }
277 break;
278 }
279
280 p = aP + dir_u + dir_v * ( aSide ? -1.0 : 1.0 );
281 lc.Append( ( int ) p.x, ( int ) p.y );
282
283 return lc;
284}
285
286
287void MEANDER_SHAPE::start( SHAPE_LINE_CHAIN* aTarget, const VECTOR2D& aWhere, const VECTOR2D& aDir )
288{
289 m_currentTarget = aTarget;
291 m_currentTarget->Append( aWhere );
292 m_currentDir = aDir;
293 m_currentPos = aWhere;
294}
295
296
297void MEANDER_SHAPE::forward( int aLength )
298{
299 m_currentPos += m_currentDir.Resize( aLength );
301}
302
303
304void MEANDER_SHAPE::turn( const EDA_ANGLE& aAngle )
305{
306 RotatePoint( m_currentDir, aAngle );
307}
308
309
310void MEANDER_SHAPE::miter( int aRadius, bool aSide )
311{
312 if( aRadius <= 0 )
313 {
314 turn( aSide ? ANGLE_90 : -ANGLE_90 );
315 return;
316 }
317
318 VECTOR2D dir = m_currentDir.Resize( (double) aRadius );
319 SHAPE_LINE_CHAIN lc = makeMiterShape( m_currentPos, dir, aSide );
320
321 m_currentPos = lc.CPoint( -1 );
322 turn( aSide ? ANGLE_90 : -ANGLE_90 );
323
324 m_currentTarget->Append( lc );
325}
326
327
328void MEANDER_SHAPE::uShape( int aSides, int aCorner, int aTop )
329{
330 forward( aSides );
331 miter( aCorner, true );
332 forward( aTop );
333 miter( aCorner, true );
334 forward( aSides );
335}
336
337
339 bool aSide, MEANDER_TYPE aType,
340 int aBaselineOffset )
341{
342 int cr = cornerRadius();
343 int offset = aBaselineOffset;
344 int spc = spacing();
345 int amplitude = m_amplitude;
346 int targetBaseLen = m_targetBaseLen;
347
348 if( aSide )
349 offset *= -1;
350
351 VECTOR2D dir_u_b( aDir.Resize( offset ) );
352 VECTOR2D dir_v_b( dir_u_b.Perpendicular() );
353
354 if( 2 * cr > amplitude )
355 {
356 cr = amplitude / 2;
357 }
358
359 if( 2 * cr > spc )
360 {
361 cr = spc / 2;
362 }
363
364 if( cr - offset < 0 )
365 {
366 cr = offset;
367 }
368
370
371 int sCorner = cr - offset;
372 int uCorner = cr + offset;
373 int startSide = amplitude - 2 * cr + std::abs( offset );
374 int turnSide = amplitude - cr;
375 int top = spc - 2 * cr;
376
378
379 start( &lc, aP + dir_v_b, aDir );
380
381 switch( aType )
382 {
383 case MT_EMPTY:
384 {
385 lc.Append( aP + dir_v_b + aDir );
386 break;
387 }
388 case MT_START:
389 {
390 if( targetBaseLen )
391 top = std::max( top, targetBaseLen - sCorner - uCorner * 2 + offset );
392
393 miter( sCorner, false );
394 uShape( startSide, uCorner, top );
395 forward( std::min( sCorner, uCorner ) );
396 forward( std::abs( offset ) );
397 break;
398 }
399
400 case MT_FINISH:
401 {
402 if( targetBaseLen )
403 top = std::max( top, targetBaseLen - cr - spc );
404
405 start( &lc, aP - dir_u_b, aDir );
406 turn( -ANGLE_90 );
407 forward( std::min( sCorner, uCorner ) );
408 forward( std::abs( offset ) );
409 uShape( startSide, uCorner, top );
410 miter( sCorner, false );
411
412 if( targetBaseLen >= spc + cr )
413 lc.Append( aP + dir_v_b + aDir.Resize( targetBaseLen ) );
414 else
415 lc.Append( aP + dir_v_b + aDir.Resize( 2 * spc - cr ) );
416
417 break;
418 }
419
420 case MT_TURN:
421 {
422 if( targetBaseLen )
423 top = std::max( top, targetBaseLen - uCorner * 2 + offset * 2 );
424
425 start( &lc, aP - dir_u_b, aDir );
426 turn( -ANGLE_90 );
427 forward( std::abs( offset ) );
428 uShape( turnSide, uCorner, top );
429 forward( std::abs( offset ) );
430 break;
431 }
432
433 case MT_SINGLE:
434 {
435 if( targetBaseLen )
436 top = std::max( top, ( targetBaseLen - sCorner * 2 - uCorner * 2 ) / 2 );
437
438 miter( sCorner, false );
439 uShape( startSide, uCorner, top );
440 miter( sCorner, false );
441 lc.Append( aP + dir_v_b + aDir.Resize( 2 * spc ) );
442 break;
443 }
444
445 default: break;
446 }
447
448 if( aSide )
449 {
450 SEG axis( aP, aP + aDir );
451
452 lc.Mirror( axis );
453 }
454
455 return lc;
456}
457
458
460{
461 for( int i = m_meanders.size() - 1; i >= 0; i-- )
462 {
464
465 if( m->Type() == MT_EMPTY || m->Type() == MT_CORNER )
466 continue;
467
468 const SEG& b1 = aShape->BaseSegment();
469 const SEG& b2 = m->BaseSegment();
470
471 if( b1.ApproxParallel( b2 ) )
472 continue;
473
474 int n = m->CLine( 0 ).SegmentCount();
475
476 for( int j = n - 1; j >= 0; j-- )
477 {
478 if( aShape->CLine( 0 ).Collide( m->CLine( 0 ) .CSegment( j ), aClearance ) )
479 return false;
480 }
481 }
482
483 return true;
484}
485
486
487bool MEANDER_SHAPE::Fit( MEANDER_TYPE aType, const SEG& aSeg, const VECTOR2I& aP, bool aSide )
488{
489 const MEANDER_SETTINGS& st = Settings();
490
491 bool checkMode = false;
492 MEANDER_TYPE prim1, prim2;
493
494 if( aType == MT_CHECK_START )
495 {
496 prim1 = MT_START;
497 prim2 = MT_TURN;
498 checkMode = true;
499 }
500 else if( aType == MT_CHECK_FINISH )
501 {
502 prim1 = MT_TURN;
503 prim2 = MT_FINISH;
504 checkMode = true;
505 }
506
507 if( checkMode )
508 {
511
513 m2.SetBaselineOffset( m_baselineOffset );
514
515 bool c1 = m1.Fit( prim1, aSeg, aP, aSide );
516 bool c2 = false;
517
518 if( c1 )
519 c2 = m2.Fit( prim2, aSeg, m1.End(), !aSide );
520
521 if( c1 && c2 )
522 {
523 m_type = prim1;
524 m_shapes[0] = m1.m_shapes[0];
525 m_shapes[1] = m1.m_shapes[1];
526 m_baseSeg =aSeg;
527 m_p0 = aP;
528 m_side = aSide;
529 m_amplitude = m1.Amplitude();
530 m_dual = m1.m_dual;
531 m_baseSeg = m1.m_baseSeg;
535 return true;
536 }
537 else
538 {
539 return false;
540 }
541 }
542
543 int minAmpl = MinAmplitude();
544 int maxAmpl = std::max( st.m_maxAmplitude, minAmpl );
545
546 for( int ampl = maxAmpl; ampl >= minAmpl; ampl -= st.m_step )
547 {
548 m_amplitude = ampl;
549
550 if( m_dual )
551 {
552 m_shapes[0] = genMeanderShape( aP, aSeg.B - aSeg.A, aSide, aType, m_baselineOffset );
553 m_shapes[1] = genMeanderShape( aP, aSeg.B - aSeg.A, aSide, aType, -m_baselineOffset );
554 }
555 else
556 {
557 m_shapes[0] = genMeanderShape( aP, aSeg.B - aSeg.A, aSide, aType, 0 );
558 }
559
560 m_type = aType;
561 m_baseSeg = aSeg;
562 m_p0 = aP;
563 m_side = aSide;
564
566
567 if( m_placer->CheckFit( this ) )
568 return true;
569 }
570
571 return false;
572}
573
574
576{
578 m_dual ? m_baselineOffset : 0 );
579
580 if( m_dual )
583
585}
586
587
588void MEANDER_SHAPE::Resize( int aAmpl )
589{
590 if( aAmpl < 0 )
591 return;
592
593 m_amplitude = aAmpl;
594
595 Recalculate();
596}
597
598
600{
602
604
606 m_amplitude = 0;
607
609
610 if( m_dual )
612}
613
614
615void MEANDERED_LINE::AddCorner( const VECTOR2I& aA, const VECTOR2I& aB )
616{
618
619 m->MakeCorner( aA, aB );
620 m_last = aA;
621
622 m_meanders.push_back( m );
623}
624
625
626void MEANDERED_LINE::AddArc( const SHAPE_ARC& aArc1, const SHAPE_ARC& aArc2 )
627{
629
630 m->MakeArc( aArc1, aArc2 );
631 m_last = aArc1.GetP1();
632
633 m_meanders.push_back( m );
634}
635
636
637void MEANDERED_LINE::AddArcAndPt( const SHAPE_ARC& aArc1, const VECTOR2I& aPt2 )
638{
639 SHAPE_ARC arc2( aPt2, aPt2, aPt2, 0 );
640
641 AddArc( aArc1, arc2 );
642}
643
644
645void MEANDERED_LINE::AddPtAndArc( const VECTOR2I& aPt1, const SHAPE_ARC& aArc2 )
646{
647 SHAPE_ARC arc1( aPt1, aPt1, aPt1, 0 );
648
649 AddArc( arc1, aArc2 );
650}
651
652
653void MEANDER_SHAPE::MakeCorner( const VECTOR2I& aP1, const VECTOR2I& aP2 )
654{
656 m_shapes[0].Clear();
657 m_shapes[1].Clear();
658 m_shapes[0].Append( aP1 );
659 m_shapes[1].Append( aP2 );
660 m_clippedBaseSeg.A = aP1;
661 m_clippedBaseSeg.B = aP1;
662}
663
664
665void MEANDER_SHAPE::MakeArc( const SHAPE_ARC& aArc1, const SHAPE_ARC& aArc2 )
666{
668 m_shapes[0].Clear();
669 m_shapes[1].Clear();
670 m_shapes[0].Append( aArc1 );
671 m_shapes[1].Append( aArc2 );
672 m_clippedBaseSeg.A = aArc1.GetP1();
673 m_clippedBaseSeg.B = aArc1.GetP1();
674}
675
676
678{
679 m_last = aShape->BaseSegment().B;
680 m_meanders.push_back( aShape );
681}
682
683
685{
686 for( MEANDER_SHAPE* m : m_meanders )
687 {
688 delete m;
689 }
690
691 m_meanders.clear( );
692}
693
694
696{
697 return m_clippedBaseSeg.Length();
698}
699
700
701long long int MEANDER_SHAPE::CurrentLength() const
702{
703 return CLine( 0 ).Length();
704}
705
706
708{
709 MEANDER_SHAPE copy = *this;
710
711 copy.SetTargetBaselineLength( BaselineLength() );
712 copy.Resize( copy.MinAmplitude() );
713
714 return copy.CurrentLength();
715}
716
717
719{
720 if( m_dual )
721 {
722 VECTOR2I midpA = ( CLine( 0 ).CPoint( 0 ) + CLine( 1 ).CPoint( 0 ) ) / 2;
723 VECTOR2I midpB = ( CLine( 0 ).CPoint( -1 ) + CLine( 1 ).CPoint( -1 ) ) / 2;
724
727 }
728 else
729 {
732 }
733}
734
735}
void AddMeander(MEANDER_SHAPE *aShape)
Add a new meander shape to the meandered line.
MEANDER_PLACER_BASE * m_placer
Definition: pns_meander.h:537
void AddCorner(const VECTOR2I &aA, const VECTOR2I &aB=VECTOR2I(0, 0))
Create a dummy meander shape representing a line corner.
void Clear()
Clear the line geometry, removing all corners and meanders.
std::vector< MEANDER_SHAPE * > m_meanders
Definition: pns_meander.h:538
void MeanderSegment(const SEG &aSeg, bool aSide, int aBaseIndex=0)
Fit maximum amplitude meanders on a given segment and adds to the current line.
Definition: pns_meander.cpp:45
void AddArc(const SHAPE_ARC &aArc1, const SHAPE_ARC &aArc2=SHAPE_ARC())
Create a dummy meander shape representing an arc corner.
void AddArcAndPt(const SHAPE_ARC &aArc1, const VECTOR2I &aPt2)
Create a dummy meander shape representing an arc corner.
bool CheckSelfIntersections(MEANDER_SHAPE *aShape, int aClearance)
Check if the given shape is intersecting with any other meander in the current line.
const MEANDER_SETTINGS & Settings() const
Definition: pns_meander.cpp:39
void AddPtAndArc(const VECTOR2I &aPt1, const SHAPE_ARC &aArc2)
Create a dummy meander shape representing an arc corner.
virtual bool CheckFit(MEANDER_SHAPE *aShape)
Checks if it's OK to place the shape aShape (i.e.
virtual int Clearance()
Return the clearance of the track(s) being length tuned.
virtual const MEANDER_SETTINGS & MeanderSettings() const
Return the current meandering configuration.
Dimensions for the meandering algorithm.
Definition: pns_meander.h:59
int m_minAmplitude
Maximum meandering amplitude.
Definition: pns_meander.h:78
int m_cornerRadiusPercentage
Place meanders on one side.
Definition: pns_meander.h:99
bool m_singleSided
Allowable tuning error.
Definition: pns_meander.h:102
int m_step
Length PadToDie.
Definition: pns_meander.h:87
MEANDER_STYLE m_cornerStyle
Rounding percentage (0 - 100).
Definition: pns_meander.h:96
int m_maxAmplitude
Meandering period/spacing (see dialog picture for explanation).
Definition: pns_meander.h:81
The geometry of a single meander.
Definition: pns_meander.h:115
MEANDER_TYPE m_type
The placer that placed this meander.
Definition: pns_meander.h:356
int MinAmplitude() const
MEANDER_PLACER_BASE * m_placer
Dual or single line.
Definition: pns_meander.h:359
SEG m_baseSeg
Base segment (clipped).
Definition: pns_meander.h:383
SEG m_clippedBaseSeg
Side (true = right).
Definition: pns_meander.h:386
int Amplitude() const
Definition: pns_meander.h:174
void SetType(MEANDER_TYPE aType)
Set the type of the meander.
Definition: pns_meander.h:142
int m_targetBaseLen
First point of the meandered line.
Definition: pns_meander.h:377
VECTOR2I End() const
Definition: pns_meander.h:229
SHAPE_LINE_CHAIN genMeanderShape(const VECTOR2D &aP, const VECTOR2D &aDir, bool aSide, MEANDER_TYPE aType, int aBaselineOffset=0)
Recalculate the clipped baseline after the parameters of the meander have been changed.
void start(SHAPE_LINE_CHAIN *aTarget, const VECTOR2D &aWhere, const VECTOR2D &aDir)
Move turtle forward by aLength.
void SetBaseIndex(int aIndex)
Set an auxiliary index of the segment being meandered in its original LINE.
Definition: pns_meander.h:158
int m_baselineOffset
Average radius of meander corners (for correction of DP meanders).
Definition: pns_meander.h:371
VECTOR2D m_currentDir
The current turtle position.
Definition: pns_meander.h:398
int m_width
Amplitude of the meander.
Definition: pns_meander.h:365
VECTOR2D m_currentPos
The line the turtle is drawing on.
Definition: pns_meander.h:401
SHAPE_LINE_CHAIN m_shapes[2]
Index of the meandered segment in the base line.
Definition: pns_meander.h:392
long long int CurrentLength() const
bool m_side
The actual shapes (0 used for single, both for dual).
Definition: pns_meander.h:389
void updateBaseSegment()
Return sanitized corner radius value.
SHAPE_LINE_CHAIN makeMiterShape(const VECTOR2D &aP, const VECTOR2D &aDir, bool aSide)
Produce a meander shape of given type.
void MakeArc(const SHAPE_ARC &aArc1, const SHAPE_ARC &aArc2=SHAPE_ARC())
Create a dummy meander shape representing an arc corner.
int m_baseIndex
The current turtle direction.
Definition: pns_meander.h:395
SHAPE_LINE_CHAIN * m_currentTarget
Definition: pns_meander.h:404
bool m_dual
Width of the line.
Definition: pns_meander.h:362
void Recalculate()
Recalculate the line chain representing the meander's shape.
void miter(int aRadius, bool aSide)
Tell the turtle to draw an U-like shape.
long long int MinTunableLength() const
void Resize(int aAmpl)
Change the amplitude of the meander shape to aAmpl and recalculates the resulting line chain.
int m_meanCornerRadius
Minimum length of the base segment to target when resizing.
Definition: pns_meander.h:374
int spacing() const
The type of meander.
int m_amplitude
Offset wrs the base segment (dual only).
Definition: pns_meander.h:368
int cornerRadius() const
Return sanitized spacing value.
void turn(const EDA_ANGLE &aAngle)
Tell the turtle to draw a mitered corner of given radius and turn direction.
void SetBaselineOffset(int aOffset)
Set the parallel offset between the base segment and the meandered line.
Definition: pns_meander.h:308
void forward(int aLength)
Turn the turtle by aAngle.
MEANDER_TYPE Type() const
Definition: pns_meander.h:150
VECTOR2I m_p0
Base segment (unclipped).
Definition: pns_meander.h:380
const MEANDER_SETTINGS & Settings() const
Definition: pns_meander.cpp:33
void MakeEmpty()
Replace the meander with straight bypass line(s), effectively clearing it.
bool Fit(MEANDER_TYPE aType, const SEG &aSeg, const VECTOR2I &aP, bool aSide)
Attempt to fit a meander of a given type onto a segment, avoiding collisions with other board feature...
void uShape(int aSides, int aCorner, int aTop)
Generate a 90-degree circular arc.
const SHAPE_LINE_CHAIN & CLine(int aShape) const
Definition: pns_meander.h:237
int BaselineLength() const
const SEG & BaseSegment() const
Return the base segment the meander was fitted to.
Definition: pns_meander.h:264
void MakeCorner(const VECTOR2I &aP1, const VECTOR2I &aP2=VECTOR2I(0, 0))
Create a dummy meander shape representing a line corner.
Definition: seg.h:42
VECTOR2I A
Definition: seg.h:49
VECTOR2I B
Definition: seg.h:50
int Length() const
Return the length (this).
Definition: seg.h:326
bool ApproxParallel(const SEG &aSeg, int aDistanceThreshold=1) const
Definition: seg.cpp:393
bool Contains(const SEG &aSeg) const
Definition: seg.h:307
VECTOR2I LineProject(const VECTOR2I &aP) const
Compute the perpendicular projection point of aP on a line passing through ends of the segment.
Definition: seg.cpp:302
const VECTOR2I & GetP1() const
Definition: shape_arc.h:113
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
virtual bool Collide(const VECTOR2I &aP, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const override
Check if point aP lies closer to us than aClearance.
void Clear()
Remove all points from the line chain.
void Mirror(bool aX=true, bool aY=false, const VECTOR2I &aRef={ 0, 0 })
Mirror the line points about y or x (or both).
void Append(int aX, int aY, bool aAllowDuplication=false)
Append a new point at the end of the line chain.
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
int SegmentCount() const
Return the number of segments in this line chain.
const SEG CSegment(int aIndex) const
Return a constant copy of the aIndex segment in the line chain.
long long int Length() const
Return length of the line chain in Euclidean metric.
T EuclideanNorm() const
Compute the Euclidean norm of the vector, which is defined as sqrt(x ** 2 + y ** 2).
Definition: vector2d.h:293
VECTOR2< T > Perpendicular() const
Compute the perpendicular vector.
Definition: vector2d.h:307
VECTOR2< T > Resize(T aNewLength) const
Return a vector of the same direction, but length specified in aNewLength.
Definition: vector2d.h:378
static constexpr EDA_ANGLE & ANGLE_90
Definition: eda_angle.h:414
Push and Shove diff pair dimensions (gap) settings dialog.
MEANDER_TYPE
Shapes of available meanders.
Definition: pns_meander.h:37
@ MT_TURN
Definition: pns_meander.h:41
@ MT_CHECK_START
Definition: pns_meander.h:42
@ MT_CHECK_FINISH
Definition: pns_meander.h:43
@ MT_START
Definition: pns_meander.h:39
@ MT_FINISH
Definition: pns_meander.h:40
@ MT_EMPTY
Definition: pns_meander.h:46
@ MT_CORNER
Definition: pns_meander.h:44
@ MT_SINGLE
Definition: pns_meander.h:38
@ MEANDER_STYLE_ROUND
Definition: pns_meander.h:51
@ MEANDER_STYLE_CHAMFER
Definition: pns_meander.h:52
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
Definition: eda_angle.h:401
constexpr double correction
MATRIX3x3D m2(VECTOR3I{ 6, 6, 6 }, { 1, 1, 1 }, { 3, 3, 3 })
Test suite for KiCad math code.
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Definition: trigo.cpp:183
double EuclideanNorm(const VECTOR2I &vector)
Definition: trigo.h:129