KiCad PCB EDA Suite
Loading...
Searching...
No Matches
playground.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2020, 2024 KiCad Developers.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24
25// WARNING - this Tom's crappy PNS hack tool code. Please don't complain about its quality
26// (unless you want to improve it).
27
28#include <pgm_base.h>
30
32#include "label_manager.h"
33
34#include <geometry/shape_arc.h>
35
36#include <pad.h>
37
38std::shared_ptr<PNS_LOG_VIEWER_OVERLAY> overlay;
39
40
41static inline bool collide( const SHAPE_LINE_CHAIN& aLhs, const SHAPE_LINE_CHAIN& aRhs,
42 int aClearance, int* aDistance = nullptr, VECTOR2I* aPt1 = nullptr )
43{
44 wxCHECK( aLhs.PointCount() && aRhs.PointCount(), false );
45
46 VECTOR2I pt1;
47 bool retv = false;
48 int dist = std::numeric_limits<int>::max();
49 int tmp = dist;
50
51 SHAPE_LINE_CHAIN lhs( aLhs );
52 SHAPE_LINE_CHAIN rhs( aRhs );
53
54 lhs.SetClosed( false );
55 lhs.Append( lhs.CPoint( 0 ) );
56 rhs.SetClosed( false );
57 rhs.Append( rhs.CPoint( 0 ) );
58
59 for( int i = 0; i < rhs.SegmentCount(); i ++ )
60 {
61 if( lhs.Collide( rhs.CSegment( i ), tmp, &tmp, &pt1 ) )
62 {
63 retv = true;
64
65 if( tmp < dist )
66 dist = tmp;
67
68 if( aDistance )
69 *aDistance = dist;
70
71 if( aPt1 )
72 *aPt1 = pt1;
73 }
74 }
75
76 return retv;
77}
78
79
80static bool collide( const SHAPE_POLY_SET& aLhs, const SHAPE_LINE_CHAIN& aRhs, int aClearance,
81 int* aDistance = nullptr, VECTOR2I* aPt1 = nullptr )
82{
83 VECTOR2I pt1;
84 bool retv = false;
85 int tmp = std::numeric_limits<int>::max();
86 int dist = tmp;
87
88 for( int i = 0; i < aLhs.OutlineCount(); i++ )
89 {
90 if( collide( aLhs.Outline( i ), aRhs, aClearance, &tmp, &pt1 ) )
91 {
92 retv = true;
93
94 if( tmp < dist )
95 {
96 dist = tmp;
97
98 if( aDistance )
99 *aDistance = dist;
100
101 if( aPt1 )
102 *aPt1 = pt1;
103 }
104 }
105
106 for( int j = 0; j < aLhs.HoleCount( i ); i++ )
107 {
108 if( collide( aLhs.CHole( i, j ), aRhs, aClearance, &tmp, &pt1 ) )
109 {
110 retv = true;
111
112 if( tmp < dist )
113 {
114 dist = tmp;
115
116 if( aDistance )
117 *aDistance = dist;
118
119 if( aPt1 )
120 *aPt1 = pt1;
121 }
122 }
123 }
124 }
125
126 return retv;
127}
128
129
130bool collideArc2Arc( const SHAPE_ARC& a1, const SHAPE_ARC& a2, int clearance, SEG& minDistSeg )
131{
132 SEG mediatrix( a1.GetCenter(), a2.GetCenter() );
133
134 std::vector<VECTOR2I> ips;
135
136 // Basic case - arcs intersect
137 if( a1.Intersect( a2, &ips ) > 0 )
138 {
139 minDistSeg.A = minDistSeg.B = ips[0];
140 return true;
141 }
142
143 // Arcs don't intersect, build a list of points to check
144 std::vector<VECTOR2I> ptsA;
145 std::vector<VECTOR2I> ptsB;
146
147 bool cocentered = ( mediatrix.A == mediatrix.B );
148
149 // 1: Interior points of both arcs, which are on the line segment between the two centres
150 if( !cocentered )
151 {
152 a1.IntersectLine( mediatrix, &ptsA );
153 a2.IntersectLine( mediatrix, &ptsB );
154 }
155
156 // 2: Check arc end points
157 ptsA.push_back( a1.GetP0() );
158 ptsA.push_back( a1.GetP1() );
159 ptsB.push_back( a2.GetP0() );
160 ptsB.push_back( a2.GetP1() );
161
162 // 3: Endpoint of one and "projected" point on the other, which is on the
163 // line segment through that endpoint and the centre of the other arc
164 a1.IntersectLine( SEG( a2.GetP0(), a1.GetCenter() ), &ptsA );
165 a1.IntersectLine( SEG( a2.GetP1(), a1.GetCenter() ), &ptsA );
166
167 a2.IntersectLine( SEG( a1.GetP0(), a2.GetCenter() ), &ptsB );
168 a2.IntersectLine( SEG( a1.GetP1(), a2.GetCenter() ), &ptsB );
169
170 double minDist = std::numeric_limits<double>::max();
171 bool minDistFound = false;
172
173 // @todo performance might be improved by only checking certain points (e.g only check end
174 // points against other end points or their corresponding "projected" points)
175 for( const VECTOR2I& ptA : ptsA )
176 {
177 for( const VECTOR2I& ptB : ptsB )
178 {
179 double dist = ( ptA - ptB ).EuclideanNorm() - a1.GetWidth() / 2.0 - a2.GetWidth() / 2.0;
180
181 if( dist < clearance )
182 {
183 if( !minDistFound || dist < minDist )
184 {
185 minDist = dist;
186 minDistSeg = SEG( ptA, ptB );
187 }
188
189 minDistFound = true;
190 }
191 }
192 }
193
194 return minDistFound;
195}
196
197
198int playground_main_func( int argc, char* argv[] )
199{
200 auto frame = new PNS_LOG_VIEWER_FRAME( nullptr );
201 Pgm().App().SetTopWindow( frame ); // wxApp gets a face.
202 frame->Show();
203
204 struct ARC_DATA
205 {
206 double cx, cy, sx, sy, ca, w;
207 };
208
209 const ARC_DATA test_data [] =
210 {
211 {73.843527, 74.355869, 71.713528, 72.965869, -76.36664803, 0.2},
212 {71.236473, 74.704131, 73.366472, 76.094131, -76.36664803, 0.2},
213 {82.542335, 74.825975, 80.413528, 73.435869, -76.4, 0.2},
214 {76.491192, 73.839894, 78.619999, 75.23, -76.4, 0.2},
215 {89.318807, 74.810106, 87.19, 73.42, -76.4, 0.2},
216 {87.045667, 74.632941, 88.826472, 75.794131, -267.9, 0.2},
217 {94.665667, 73.772941, 96.446472, 74.934131, -267.9, 0.2},
218 {94.750009, 73.74012, 93.6551, 73.025482, -255.5, 0.2},
219 {72.915251, 80.493054, 73.570159, 81.257692, -260.5, 0.2}, // end points clearance false positive
220 {73.063537, 82.295989, 71.968628, 81.581351, -255.5, 0.2},
221 {79.279991, 80.67988, 80.3749, 81.394518, -255.5, 0.2},
222 {79.279991, 80.67988, 80.3749, 81.694518, -255.5, 0.2 },
223 {88.495265, 81.766089, 90.090174, 82.867869, -255.5, 0.2},
224 {86.995265, 81.387966, 89.090174, 82.876887, -255.5, 0.2},
225 {96.149734, 81.792126, 94.99, 83.37, -347.2, 0.2},
226 {94.857156, 81.240589, 95.91, 83.9, -288.5, 0.2},
227 {72.915251, 86.493054, 73.970159, 87.257692, -260.5, 0.2}, // end points clearance #1
228 {73.063537, 88.295989, 71.968628, 87.581351, -255.5, 0.2},
229 {78.915251, 86.393054, 79.970159, 87.157692, 99.5, 0.2}, // end points clearance #2 - false positive
230 {79.063537, 88.295989, 77.968628, 87.581351, -255.5, 0.2},
231 {85.915251, 86.993054, 86.970159, 87.757692, 99.5, 0.2}, // intersection - false negative
232 {86.063537, 88.295989, 84.968628, 87.581351, -255.5, 0.2},
233 {94.6551, 88.295989, 95.6551, 88.295989, 90.0, 0.2 }, // simulating diff pair
234 {94.6551, 88.295989, 95.8551, 88.295989, 90.0, 0.2 },
235 {73.77532, 93.413654, 75.70532, 93.883054, 60.0, 0.1 }, // one arc fully enclosed in other
236 {73.86532, 93.393054, 75.86532, 93.393054, 90.0, 0.3 },
237 {79.87532, 93.413654, 81.64532, 94.113054, 60.0, 0.1 }, // concentric
238 {79.87532, 93.413654, 81.86532, 93.393054, 90.0, 0.3 }
239 };
240
241
242 overlay = frame->GetOverlay();
243
244
245 overlay->SetIsFill( false );
246 overlay->SetLineWidth( 10000 );
247
248 std::vector<SHAPE_ARC> arcs;
249 int n_arcs = sizeof( test_data ) / sizeof( ARC_DATA );
250
251 BOX2I vp;
252
253 for( int i = 0; i < n_arcs; i++ )
254 {
255 const ARC_DATA& d = test_data[i];
256
257 SHAPE_ARC arc( VECTOR2D( pcbIUScale.mmToIU( d.cx ), pcbIUScale.mmToIU( d.cy ) ),
258 VECTOR2D( pcbIUScale.mmToIU( d.sx ), pcbIUScale.mmToIU( d.sy ) ),
259 EDA_ANGLE( d.ca, DEGREES_T ), pcbIUScale.mmToIU( d.w ) );
260
261 arcs.push_back( arc );
262
263 if( i == 0 )
264 vp = arc.BBox();
265 else
266 vp.Merge( arc.BBox() );
267 }
268
269
270 PAD pad1( nullptr );
271 pad1.SetX( pcbIUScale.mmToIU( 84.0 ) );
272 pad1.SetY( pcbIUScale.mmToIU( 66.0 ) );
273 pad1.SetSizeX( pcbIUScale.mmToIU( 7.0 ) );
274 pad1.SetSizeY( pcbIUScale.mmToIU( 7.0 ) );
275 pad1.SetDrillSizeX( pcbIUScale.mmToIU( 3.5 ) );
276 pad1.SetDrillSizeY( pcbIUScale.mmToIU( 3.5 ) );
277 vp.Merge( pad1.GetBoundingBox() );
278
279 PAD pad2( nullptr );
280 pad2.SetX( pcbIUScale.mmToIU( 87.125 ) );
281 pad2.SetY( pcbIUScale.mmToIU( 66.0 ) );
282 pad2.SetSizeX( pcbIUScale.mmToIU( 0.8 ) );
283 pad2.SetSizeY( pcbIUScale.mmToIU( 0.8 ) );
284 pad2.SetDrillSizeX( pcbIUScale.mmToIU( 0.5 ) );
285 pad2.SetDrillSizeY( pcbIUScale.mmToIU( 0.5 ) );
286 vp.Merge( pad2.GetBoundingBox() );
287
288 SHAPE_POLY_SET pad1Outline;
289 SHAPE_POLY_SET pad1Hole;
290
291 pad1.TransformShapeToPolygon( pad1Outline, UNDEFINED_LAYER, 0, 4, ERROR_OUTSIDE );
292 pad1.TransformHoleToPolygon( pad1Hole, 0, 4, ERROR_INSIDE );
293 pad1Outline.AddHole( pad1Hole.Outline( 0 ), 0 );
294
295 SHAPE_POLY_SET pad2Outline;
296
297 // pad2.TransformShapeToPolygon( pad2Outline, UNDEFINED_LAYER, 0, 4, ERROR_OUTSIDE );
298 pad2.TransformHoleToPolygon( pad2Outline, 0, 4, ERROR_INSIDE );
299
300 SHAPE_POLY_SET xorPad1ToPad2 = pad1Outline;
301
302 xorPad1ToPad2.BooleanXor( pad2Outline, SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
303 xorPad1ToPad2.Move( VECTOR2I( pcbIUScale.mmToIU( 10 ), 0 ) );
304
305 SHAPE_POLY_SET andPad1ToPad2 = pad2Outline;
306
307 andPad1ToPad2.BooleanIntersection( pad1Outline, SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
308 andPad1ToPad2.Move( VECTOR2I( pcbIUScale.mmToIU( 20 ), 0 ) );
309
310 std::shared_ptr<SHAPE_SEGMENT> slot = pad2.GetEffectiveHoleShape();
311
312 printf("Read %zu arcs\n", arcs.size() );
313
314 LABEL_MANAGER labelMgr( frame->GetPanel()->GetGAL() );
315 frame->GetPanel()->GetView()->SetViewport( BOX2D( vp.GetOrigin(), vp.GetSize() ) );
316
317 for( int i = 0; i < arcs.size(); i+= 2 )
318 {
319 SEG closestDist;
320 std::vector<VECTOR2I> ips;
321 bool collides = collideArc2Arc( arcs[i], arcs[i+1], 0, closestDist );
322 int ni = arcs[i].Intersect( arcs[i+1], &ips );
323
324 overlay->SetLineWidth( 10000.0 );
325 overlay->SetStrokeColor( GREEN );
326
327 for( int j = 0; j < ni; j++ )
328 overlay->AnnotatedPoint( ips[j], arcs[i].GetWidth() );
329
330 if( collides )
331 {
332 overlay->SetStrokeColor( YELLOW );
333 overlay->Line( closestDist.A, closestDist.B );
334 overlay->SetLineWidth( 10000 );
335 overlay->SetGlyphSize( { 100000, 100000 } );
336 overlay->BitmapText( wxString::Format( "dist=%d", closestDist.Length() ),
337 closestDist.A + VECTOR2I( 0, -arcs[i].GetWidth() ),
339 }
340
341 overlay->SetLineWidth( 10000 );
342 overlay->SetStrokeColor( CYAN );
343 overlay->AnnotatedPoint( arcs[i].GetP0(), arcs[i].GetWidth() / 2 );
344 overlay->AnnotatedPoint( arcs[i + 1].GetP0(), arcs[i + 1].GetWidth() / 2 );
345 overlay->AnnotatedPoint( arcs[i].GetArcMid(), arcs[i].GetWidth() / 2 );
346 overlay->AnnotatedPoint( arcs[i + 1].GetArcMid(), arcs[i + 1].GetWidth() / 2 );
347 overlay->AnnotatedPoint( arcs[i].GetP1(), arcs[i].GetWidth() / 2 );
348 overlay->AnnotatedPoint( arcs[i + 1].GetP1(), arcs[i + 1].GetWidth() / 2 );
349
350
351 overlay->SetStrokeColor( RED );
352 overlay->Arc( arcs[i] );
353 overlay->SetStrokeColor( MAGENTA );
354 overlay->Arc( arcs[i + 1] );
355 }
356
357 overlay->SetLineWidth( 2000 );
358 overlay->SetStrokeColor( CYAN );
359 overlay->AnnotatedPolyset( pad1Outline, "Raw Pads" );
360 overlay->SetStrokeColor( RED );
361 overlay->AnnotatedPolyset( pad2Outline );
362 overlay->SetStrokeColor( CYAN );
363 overlay->AnnotatedPolyset( xorPad1ToPad2, "XOR Pads" );
364 overlay->AnnotatedPolyset( andPad1ToPad2, "AND Pads" );
365
366 wxLogDebug( wxS( "Pad 1 has %d outlines." ),
367 pad1Outline.OutlineCount() );
368
369 wxLogDebug( wxS( "Pad 2 has %d outlines." ),
370 pad2Outline.OutlineCount() );
371
372 VECTOR2I pt1, pt2;
373 int dist = std::numeric_limits<int>::max();
374
375 collide( pad1Outline, pad2Outline.Outline( 0 ), dist, &dist, &pt1 );
376
377 wxLogDebug( wxS( "Nearest distance between pad 1 and pad 2 is %0.6f mm at X=%0.6f mm, "
378 "Y=%0.6f mm." ),
379 pcbIUScale.IUTomm( dist ), pcbIUScale.IUTomm( pt1.x ),
380 pcbIUScale.IUTomm( pt1.y ) );
381
382 overlay->SetStrokeColor( YELLOW );
383 overlay->SetGlyphSize( { 100000, 100000 } );
384 overlay->BitmapText( wxString::Format( "dist=%0.3f mm", pcbIUScale.IUTomm( dist ) ),
385 pt1 + VECTOR2I( 0, -56000 ), ANGLE_HORIZONTAL );
386
387 overlay = nullptr;
388
389 return 0;
390}
391
392
393
394int drawShapes( int argc, char* argv[] )
395{
396 SHAPE_ARC arc( VECTOR2I( 206000000, 140110000 ), VECTOR2I( 201574617, 139229737 ),
397 VECTOR2I( 197822958, 136722959 ), 250000 );
398
399 SHAPE_LINE_CHAIN lc( { /* VECTOR2I( 159600000, 142500000 ), VECTOR2I( 159600000, 142600000 ),
400 VECTOR2I( 166400000, 135800000 ), VECTOR2I( 166400000, 111600000 ),
401 VECTOR2I( 190576804, 111600000 ), VECTOR2I( 192242284, 113265480 ),
402 VECTOR2I( 192255720, 113265480 ),*/
403 VECTOR2I( 203682188, 124691948 ), VECTOR2I( 203682188, 140332188 ),
404 /* VECTOR2I( 206000000, 142650000 ) */ },
405 false );
406
407 auto frame = new PNS_LOG_VIEWER_FRAME( nullptr );
408 Pgm().App().SetTopWindow( frame ); // wxApp gets a face.
409 frame->Show();
410
411 overlay = frame->GetOverlay();
412
413
414 overlay->SetIsFill( false );
415 overlay->SetLineWidth( arc.GetWidth() );
416 overlay->SetStrokeColor( RED );
417 overlay->Arc( arc );
418 overlay->SetLineWidth( arc.GetWidth() / 20 );
419 overlay->SetStrokeColor( GREEN );
420 overlay->Polyline( lc );
421
422 overlay->SetLineWidth( 80000.0 );
423 overlay->SetStrokeColor( CYAN );
424
425 for( int i = 0; i < lc.PointCount(); ++i )
426 {
427 int mult = ( i % 2 ) ? 1 : -1;
428 overlay->AnnotatedPoint( lc.GetPoint( i ), arc.GetWidth() * 2 );
429 overlay->SetGlyphSize( { 800000, 800000 } );
430 overlay->BitmapText( wxString::Format( "x=%d, y=%d",
431 lc.GetPoint( i ).x,
432 lc.GetPoint( i ).y ),
433 lc.GetPoint( i ) + VECTOR2I( 0, mult*arc.GetWidth() * 4 ),
435 }
436
437 arc.Collide( &lc, 100000 );
438
439 BOX2I vp = arc.BBox();
440 vp.Merge( lc.BBox() );
441 vp.Inflate( (800000 + arc.GetWidth() * 4 )*2);
442 frame->GetPanel()->GetView()->SetViewport( BOX2D( vp.GetOrigin(), vp.GetSize() ) );
443
444 overlay = nullptr;
445
446 return 0;
447}
448
449
451 "playground",
452 "Geometry/drawing playground",
454} );
455
456
458 "drawShapes",
459 "drawing shapes",
461} );
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:108
BOX2< VECTOR2D > BOX2D
Definition: box2.h:878
const Vec & GetOrigin() const
Definition: box2.h:200
const SizeVec & GetSize() const
Definition: box2.h:196
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:541
BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
Definition: box2.h:623
Definition: pad.h:53
const BOX2I GetBoundingBox() const override
The bounding box is cached, so this will be efficient most of the time.
Definition: pad.cpp:762
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aMaxError, ERROR_LOC aErrorLoc=ERROR_INSIDE, bool ignoreLineWidth=false) const override
Convert the pad shape to a closed polygon.
Definition: pad.cpp:1800
void SetDrillSizeX(const int aX)
Definition: pad.h:262
void SetY(int y)
Definition: pad.h:242
void SetX(int x)
Definition: pad.h:243
void SetSizeX(const int aX)
Definition: pad.h:252
void SetDrillSizeY(const int aY)
Definition: pad.h:264
std::shared_ptr< SHAPE_SEGMENT > GetEffectiveHoleShape() const override
Return a SHAPE_SEGMENT object representing the pad's hole.
Definition: pad.cpp:525
bool TransformHoleToPolygon(SHAPE_POLY_SET &aBuffer, int aClearance, int aError, ERROR_LOC aErrorLoc=ERROR_INSIDE) const
Build the corner list of the polygonal drill shape in the board coordinate system.
Definition: pad.cpp:1783
void SetSizeY(const int aY)
Definition: pad.h:254
virtual wxApp & App()
Returns a bare naked wxApp which may come from wxPython, SINGLE_TOP, or kicad.exe.
Definition: pgm_base.cpp:181
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
const BOX2I BBox(int aClearance=0) const override
Compute a bounding box of the shape, with a margin of aClearance a collision.
Definition: shape_arc.cpp:371
int GetWidth() const
Definition: shape_arc.h:160
const VECTOR2I & GetP1() const
Definition: shape_arc.h:114
int IntersectLine(const SEG &aSeg, std::vector< VECTOR2I > *aIpsBuffer) const
Find intersection points between this arc and aSeg, treating aSeg as an infinite line.
Definition: shape_arc.cpp:281
bool Collide(const SEG &aSeg, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const override
Check if the boundary of shape (this) lies closer to the segment aSeg than aClearance,...
Definition: shape_arc.cpp:244
int Intersect(const SHAPE_ARC &aArc, std::vector< VECTOR2I > *aIpsBuffer) const
Find intersection points between this arc and aArc.
Definition: shape_arc.cpp:302
const VECTOR2I & GetP0() const
Definition: shape_arc.h:113
const VECTOR2I & GetCenter() const
Definition: shape_arc.cpp:475
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
void SetClosed(bool aClosed)
Mark the line chain as closed (i.e.
int PointCount() const
Return the number of points (vertices) in this line chain.
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 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.
Represent a set of closed polygons.
void BooleanXor(const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
Perform boolean polyset exclusive or For aFastMode meaning, see function booleanOp.
void BooleanIntersection(const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
Perform boolean polyset intersection For aFastMode meaning, see function booleanOp.
int HoleCount(int aOutline) const
Returns the number of holes in a given outline.
int AddHole(const SHAPE_LINE_CHAIN &aHole, int aOutline=-1)
Adds a new hole to the given outline (default: last) and returns its index.
SHAPE_LINE_CHAIN & Outline(int aIndex)
Return the reference to aIndex-th outline in the set.
const SHAPE_LINE_CHAIN & CHole(int aOutline, int aHole) const
int OutlineCount() const
Return the number of outlines in the set.
void Move(const VECTOR2I &aVector) override
static bool Register(const KI_TEST::UTILITY_PROGRAM &aProgInfo)
Register a utility program factory function against an ID string.
@ MAGENTA
Definition: color4d.h:60
@ GREEN
Definition: color4d.h:57
@ CYAN
Definition: color4d.h:58
@ YELLOW
Definition: color4d.h:67
@ RED
Definition: color4d.h:59
@ DEGREES_T
Definition: eda_angle.h:31
static constexpr EDA_ANGLE ANGLE_HORIZONTAL
Definition: eda_angle.h:431
@ ERROR_OUTSIDE
@ ERROR_INSIDE
@ UNDEFINED_LAYER
Definition: layer_ids.h:61
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: pgm_base.cpp:1059
see class PGM_BASE
static bool registered
Definition: playground.cpp:450
int playground_main_func(int argc, char *argv[])
Definition: playground.cpp:198
static bool registered1
Definition: playground.cpp:457
int drawShapes(int argc, char *argv[])
Definition: playground.cpp:394
static bool collide(const SHAPE_LINE_CHAIN &aLhs, const SHAPE_LINE_CHAIN &aRhs, int aClearance, int *aDistance=nullptr, VECTOR2I *aPt1=nullptr)
Definition: playground.cpp:41
bool collideArc2Arc(const SHAPE_ARC &a1, const SHAPE_ARC &a2, int clearance, SEG &minDistSeg)
Definition: playground.cpp:130
std::shared_ptr< PNS_LOG_VIEWER_OVERLAY > overlay
Definition: playground.cpp:38
constexpr double IUTomm(int iu) const
Definition: base_units.h:86
constexpr int mmToIU(double mm) const
Definition: base_units.h:88
double EuclideanNorm(const VECTOR2I &vector)
Definition: trigo.h:128
VECTOR2< double > VECTOR2D
Definition: vector2d.h:601
VECTOR2< int > VECTOR2I
Definition: vector2d.h:602