KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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 if( maxCr > minCr )
215 return std::clamp( optCr, minCr, maxCr );
216 else
217 return maxCr;
218}
219
220
222{
223 if( !m_dual )
224 {
225 return std::max( m_width + m_placer->Clearance(), Settings().m_spacing );
226 }
227 else
228 {
229 int sp = m_width + m_placer->Clearance() + ( 2 * std::abs( m_baselineOffset ) );
230 return std::max( sp, Settings().m_spacing );
231 }
232}
233
234
236 bool aSide )
237{
239
240 if( aDir.EuclideanNorm( ) == 0.0f )
241 {
242 lc.Append( aP );
243 return lc;
244 }
245
246 VECTOR2D dir_u( aDir );
247 VECTOR2D dir_v( aDir.Perpendicular( ) );
248 VECTOR2D p = aP;
249 lc.Append( ( int ) p.x, ( int ) p.y );
250
251 // fixme: refactor
253 {
255 {
256 VECTOR2D center = aP + dir_v * ( aSide ? -1.0 : 1.0 );
257
258 lc.Append( SHAPE_ARC( center, aP, ( aSide ? -ANGLE_90 : ANGLE_90 ) ) );
259 }
260 break;
261
263 {
264 double radius = (double) aDir.EuclideanNorm();
265 double correction = 0;
266
267 if( m_dual && radius > m_meanCornerRadius )
268 correction = (double)( -2 * abs(m_baselineOffset) ) * tan( 22.5 * M_PI / 180.0 );
269
270 VECTOR2D dir_cu = dir_u.Resize( correction );
271 VECTOR2D dir_cv = dir_v.Resize( correction );
272
273 p = aP - dir_cu;
274 lc.Append( ( int ) p.x, ( int ) p.y );
275 p = aP + dir_u + (dir_v + dir_cv) * ( aSide ? -1.0 : 1.0 );
276 lc.Append( ( int ) p.x, ( int ) p.y );
277 }
278 break;
279 }
280
281 p = aP + dir_u + dir_v * ( aSide ? -1.0 : 1.0 );
282 lc.Append( ( int ) p.x, ( int ) p.y );
283
284 return lc;
285}
286
287
288void MEANDER_SHAPE::start( SHAPE_LINE_CHAIN* aTarget, const VECTOR2D& aWhere, const VECTOR2D& aDir )
289{
290 m_currentTarget = aTarget;
292 m_currentTarget->Append( aWhere );
293 m_currentDir = aDir;
294 m_currentPos = aWhere;
295}
296
297
298void MEANDER_SHAPE::forward( int aLength )
299{
300 m_currentPos += m_currentDir.Resize( aLength );
302}
303
304
305void MEANDER_SHAPE::turn( const EDA_ANGLE& aAngle )
306{
307 RotatePoint( m_currentDir, aAngle );
308}
309
310
311void MEANDER_SHAPE::miter( int aRadius, bool aSide )
312{
313 if( aRadius <= 0 )
314 {
315 turn( aSide ? ANGLE_90 : -ANGLE_90 );
316 return;
317 }
318
319 VECTOR2D dir = m_currentDir.Resize( (double) aRadius );
320 SHAPE_LINE_CHAIN lc = makeMiterShape( m_currentPos, dir, aSide );
321
322 m_currentPos = lc.CPoint( -1 );
323 turn( aSide ? ANGLE_90 : -ANGLE_90 );
324
325 m_currentTarget->Append( lc );
326}
327
328
329void MEANDER_SHAPE::uShape( int aSides, int aCorner, int aTop )
330{
331 forward( aSides );
332 miter( aCorner, true );
333 forward( aTop );
334 miter( aCorner, true );
335 forward( aSides );
336}
337
338
340 bool aSide, MEANDER_TYPE aType,
341 int aBaselineOffset )
342{
343 int cr = cornerRadius();
344 int offset = aBaselineOffset;
345 int spc = spacing();
346 int amplitude = m_amplitude;
347 int targetBaseLen = m_targetBaseLen;
348
349 if( aSide )
350 offset *= -1;
351
352 VECTOR2D dir_u_b( aDir.Resize( offset ) );
353 VECTOR2D dir_v_b( dir_u_b.Perpendicular() );
354
355 if( 2 * cr > amplitude )
356 {
357 cr = amplitude / 2;
358 }
359
360 if( 2 * cr > spc )
361 {
362 cr = spc / 2;
363 }
364
365 if( cr - offset < 0 )
366 {
367 cr = offset;
368 }
369
371
372 int sCorner = cr - offset;
373 int uCorner = cr + offset;
374 int startSide = amplitude - 2 * cr + std::abs( offset );
375 int turnSide = amplitude - cr;
376 int top = spc - 2 * cr;
377
379
380 start( &lc, aP + dir_v_b, aDir );
381
382 switch( aType )
383 {
384 case MT_EMPTY:
385 {
386 lc.Append( aP + dir_v_b + aDir );
387 break;
388 }
389 case MT_START:
390 {
391 if( targetBaseLen )
392 top = std::max( top, targetBaseLen - sCorner - uCorner * 2 + offset );
393
394 miter( sCorner, false );
395 uShape( startSide, uCorner, top );
396 forward( std::min( sCorner, uCorner ) );
397 forward( std::abs( offset ) );
398 break;
399 }
400
401 case MT_FINISH:
402 {
403 if( targetBaseLen )
404 top = std::max( top, targetBaseLen - cr - spc );
405
406 start( &lc, aP - dir_u_b, aDir );
407 turn( -ANGLE_90 );
408 forward( std::min( sCorner, uCorner ) );
409 forward( std::abs( offset ) );
410 uShape( startSide, uCorner, top );
411 miter( sCorner, false );
412
413 if( targetBaseLen >= spc + cr )
414 lc.Append( aP + dir_v_b + aDir.Resize( targetBaseLen ) );
415 else
416 lc.Append( aP + dir_v_b + aDir.Resize( 2 * spc - cr ) );
417
418 break;
419 }
420
421 case MT_TURN:
422 {
423 if( targetBaseLen )
424 top = std::max( top, targetBaseLen - uCorner * 2 + offset * 2 );
425
426 start( &lc, aP - dir_u_b, aDir );
427 turn( -ANGLE_90 );
428 forward( std::abs( offset ) );
429 uShape( turnSide, uCorner, top );
430 forward( std::abs( offset ) );
431 break;
432 }
433
434 case MT_SINGLE:
435 {
436 if( targetBaseLen )
437 top = std::max( top, ( targetBaseLen - sCorner * 2 - uCorner * 2 ) / 2 );
438
439 miter( sCorner, false );
440 uShape( startSide, uCorner, top );
441 miter( sCorner, false );
442 lc.Append( aP + dir_v_b + aDir.Resize( 2 * spc ) );
443 break;
444 }
445
446 default: break;
447 }
448
449 if( aSide )
450 {
451 SEG axis( aP, aP + aDir );
452
453 lc.Mirror( axis );
454 }
455
456 return lc;
457}
458
459
461{
462 for( int i = m_meanders.size() - 1; i >= 0; i-- )
463 {
465
466 if( m->Type() == MT_EMPTY || m->Type() == MT_CORNER )
467 continue;
468
469 const SEG& b1 = aShape->BaseSegment();
470 const SEG& b2 = m->BaseSegment();
471
472 if( b1.ApproxParallel( b2 ) )
473 continue;
474
475 int n = m->CLine( 0 ).SegmentCount();
476
477 for( int j = n - 1; j >= 0; j-- )
478 {
479 if( aShape->CLine( 0 ).Collide( m->CLine( 0 ) .CSegment( j ), aClearance ) )
480 return false;
481 }
482 }
483
484 return true;
485}
486
487
488bool MEANDER_SHAPE::Fit( MEANDER_TYPE aType, const SEG& aSeg, const VECTOR2I& aP, bool aSide )
489{
490 const MEANDER_SETTINGS& st = Settings();
491
492 bool checkMode = false;
493 MEANDER_TYPE prim1, prim2;
494
495 if( aType == MT_CHECK_START )
496 {
497 prim1 = MT_START;
498 prim2 = MT_TURN;
499 checkMode = true;
500 }
501 else if( aType == MT_CHECK_FINISH )
502 {
503 prim1 = MT_TURN;
504 prim2 = MT_FINISH;
505 checkMode = true;
506 }
507
508 if( checkMode )
509 {
512
514 m2.SetBaselineOffset( m_baselineOffset );
515
516 bool c1 = m1.Fit( prim1, aSeg, aP, aSide );
517 bool c2 = false;
518
519 if( c1 )
520 c2 = m2.Fit( prim2, aSeg, m1.End(), !aSide );
521
522 if( c1 && c2 )
523 {
524 m_type = prim1;
525 m_shapes[0] = m1.m_shapes[0];
526 m_shapes[1] = m1.m_shapes[1];
527 m_baseSeg =aSeg;
528 m_p0 = aP;
529 m_side = aSide;
530 m_amplitude = m1.Amplitude();
531 m_dual = m1.m_dual;
532 m_baseSeg = m1.m_baseSeg;
536 return true;
537 }
538 else
539 {
540 return false;
541 }
542 }
543
544 int minAmpl = MinAmplitude();
545 int maxAmpl = std::max( st.m_maxAmplitude, minAmpl );
546
547 for( int ampl = maxAmpl; ampl >= minAmpl; ampl -= st.m_step )
548 {
549 m_amplitude = ampl;
550
551 if( m_dual )
552 {
553 m_shapes[0] = genMeanderShape( aP, aSeg.B - aSeg.A, aSide, aType, m_baselineOffset );
554 m_shapes[1] = genMeanderShape( aP, aSeg.B - aSeg.A, aSide, aType, -m_baselineOffset );
555 }
556 else
557 {
558 m_shapes[0] = genMeanderShape( aP, aSeg.B - aSeg.A, aSide, aType, 0 );
559 }
560
561 m_type = aType;
562 m_baseSeg = aSeg;
563 m_p0 = aP;
564 m_side = aSide;
565
567
568 if( m_placer->CheckFit( this ) )
569 return true;
570 }
571
572 return false;
573}
574
575
577{
579 m_dual ? m_baselineOffset : 0 );
580
581 if( m_dual )
584
586}
587
588
589void MEANDER_SHAPE::Resize( int aAmpl )
590{
591 if( aAmpl < 0 )
592 return;
593
594 m_amplitude = aAmpl;
595
596 Recalculate();
597}
598
599
601{
603
605
607 m_amplitude = 0;
608
610
611 if( m_dual )
613}
614
615
616void MEANDERED_LINE::AddCorner( const VECTOR2I& aA, const VECTOR2I& aB )
617{
619
620 m->MakeCorner( aA, aB );
621 m_last = aA;
622
623 m_meanders.push_back( m );
624}
625
626
627void MEANDERED_LINE::AddArc( const SHAPE_ARC& aArc1, const SHAPE_ARC& aArc2 )
628{
630
631 m->MakeArc( aArc1, aArc2 );
632 m_last = aArc1.GetP1();
633
634 m_meanders.push_back( m );
635}
636
637
638void MEANDERED_LINE::AddArcAndPt( const SHAPE_ARC& aArc1, const VECTOR2I& aPt2 )
639{
640 SHAPE_ARC arc2( aPt2, aPt2, aPt2, 0 );
641
642 AddArc( aArc1, arc2 );
643}
644
645
646void MEANDERED_LINE::AddPtAndArc( const VECTOR2I& aPt1, const SHAPE_ARC& aArc2 )
647{
648 SHAPE_ARC arc1( aPt1, aPt1, aPt1, 0 );
649
650 AddArc( arc1, aArc2 );
651}
652
653
654void MEANDER_SHAPE::MakeCorner( const VECTOR2I& aP1, const VECTOR2I& aP2 )
655{
657 m_shapes[0].Clear();
658 m_shapes[1].Clear();
659 m_shapes[0].Append( aP1 );
660 m_shapes[1].Append( aP2 );
661 m_clippedBaseSeg.A = aP1;
662 m_clippedBaseSeg.B = aP1;
663}
664
665
666void MEANDER_SHAPE::MakeArc( const SHAPE_ARC& aArc1, const SHAPE_ARC& aArc2 )
667{
669 m_shapes[0].Clear();
670 m_shapes[1].Clear();
671 m_shapes[0].Append( aArc1 );
672 m_shapes[1].Append( aArc2 );
673 m_clippedBaseSeg.A = aArc1.GetP1();
674 m_clippedBaseSeg.B = aArc1.GetP1();
675}
676
677
679{
680 m_last = aShape->BaseSegment().B;
681 m_meanders.push_back( aShape );
682}
683
684
686{
687 for( MEANDER_SHAPE* m : m_meanders )
688 {
689 delete m;
690 }
691
692 m_meanders.clear( );
693}
694
695
697{
698 return m_clippedBaseSeg.Length();
699}
700
701
702long long int MEANDER_SHAPE::CurrentLength() const
703{
704 return CLine( 0 ).Length();
705}
706
707
709{
710 MEANDER_SHAPE copy = *this;
711
712 copy.SetTargetBaselineLength( BaselineLength() );
713 copy.Resize( copy.MinAmplitude() );
714
715 return copy.CurrentLength();
716}
717
718
720{
721 if( m_dual )
722 {
723 VECTOR2I midpA = ( CLine( 0 ).CPoint( 0 ) + CLine( 1 ).CPoint( 0 ) ) / 2;
724 VECTOR2I midpB = ( CLine( 0 ).CPoint( -1 ) + CLine( 1 ).CPoint( -1 ) ) / 2;
725
728 }
729 else
730 {
733 }
734}
735
736}
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:403
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:312
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:265
VECTOR2< T > Perpendicular() const
Compute the perpendicular vector.
Definition: vector2d.h:279
VECTOR2< T > Resize(T aNewLength) const
Return a vector of the same direction, but length specified in aNewLength.
Definition: vector2d.h:350
static constexpr EDA_ANGLE & ANGLE_90
Definition: eda_angle.h:431
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:418
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