KiCad PCB EDA Suite
class_module.cpp File Reference
#include <fctsys.h>
#include <gr_basic.h>
#include <confirm.h>
#include <refdes_utils.h>
#include <bitmaps.h>
#include <unordered_set>
#include <pcb_edit_frame.h>
#include <class_board.h>
#include <class_edge_mod.h>
#include <class_module.h>
#include <view/view.h>

Go to the source code of this file.

Classes

struct  MODULE_DESC
 

Macros

#define ARC_ERROR_MAX   0.02 /* error max in mm to approximate a arc by segments */
 

Functions

static double polygonArea (SHAPE_POLY_SET &aPolySet)
 
static void addRect (SHAPE_POLY_SET &aPolySet, wxRect aRect)
 
bool ConvertOutlineToPolygon (std::vector< DRAWSEGMENT * > &aSegList, SHAPE_POLY_SET &aPolygons, wxString *aErrorText, unsigned int aTolerance, wxPoint *aErrorLocation=nullptr)
 Function ConvertOutlineToPolygon build a polygon (with holes) from a DRAWSEGMENT list, which is expected to be a outline, therefore a closed main outline with perhaps closed inner outlines. More...
 

Variables

static struct MODULE_DESC _MODULE_DESC
 

Macro Definition Documentation

◆ ARC_ERROR_MAX

#define ARC_ERROR_MAX   0.02 /* error max in mm to approximate a arc by segments */

Function Documentation

◆ addRect()

static void addRect ( SHAPE_POLY_SET aPolySet,
wxRect  aRect 
)
static

Definition at line 1483 of file class_module.cpp.

1484 {
1485  aPolySet.NewOutline();
1486 
1487  aPolySet.Append( aRect.GetX(), aRect.GetY() );
1488  aPolySet.Append( aRect.GetX()+aRect.width, aRect.GetY() );
1489  aPolySet.Append( aRect.GetX()+aRect.width, aRect.GetY()+aRect.height );
1490  aPolySet.Append( aRect.GetX(), aRect.GetY()+aRect.height );
1491 }
int NewOutline()
Creates a new empty polygon in the set and returns its index
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Appends a vertex at the end of the given outline/hole (default: the last outline)

References SHAPE_POLY_SET::Append(), and SHAPE_POLY_SET::NewOutline().

Referenced by MODULE::CoverageRatio().

◆ ConvertOutlineToPolygon()

bool ConvertOutlineToPolygon ( std::vector< DRAWSEGMENT * > &  aSegList,
SHAPE_POLY_SET aPolygons,
wxString *  aErrorText,
unsigned int  aTolerance,
wxPoint aErrorLocation 
)

Function ConvertOutlineToPolygon build a polygon (with holes) from a DRAWSEGMENT list, which is expected to be a outline, therefore a closed main outline with perhaps closed inner outlines.

These closed inner outlines are considered as holes in the main outline

Parameters
aSegListthe initial list of drawsegments (only lines, circles and arcs).
aPolygonswill contain the complex polygon.
aToleranceis the max distance between points that is still accepted as connected (internal units)
aErrorTextis a wxString to return error message.
aErrorLocationis the optional position of the error in the outline

Definition at line 185 of file convert_drawsegment_list_to_polygon.cpp.

187 {
188  if( aSegList.size() == 0 )
189  return true;
190 
191  wxString msg;
192 
193  // Make a working copy of aSegList, because the list is modified during calculations
194  std::vector< DRAWSEGMENT* > segList = aSegList;
195 
196  DRAWSEGMENT* graphic;
197  wxPoint prevPt;
198 
199  // Find edge point with minimum x, this should be in the outer polygon
200  // which will define the perimeter polygon polygon.
201  wxPoint xmin = wxPoint( INT_MAX, 0 );
202  int xmini = 0;
203 
204  for( size_t i = 0; i < segList.size(); i++ )
205  {
206  graphic = (DRAWSEGMENT*) segList[i];
207 
208  switch( graphic->GetShape() )
209  {
210  case S_RECT:
211  case S_SEGMENT:
212  {
213  if( graphic->GetStart().x < xmin.x )
214  {
215  xmin = graphic->GetStart();
216  xmini = i;
217  }
218 
219  if( graphic->GetEnd().x < xmin.x )
220  {
221  xmin = graphic->GetEnd();
222  xmini = i;
223  }
224  }
225  break;
226 
227  case S_ARC:
228  // Freerouter does not yet understand arcs, so approximate
229  // an arc with a series of short lines and put those
230  // line segments into the !same! PATH.
231  {
232  wxPoint pstart = graphic->GetArcStart();
233  wxPoint center = graphic->GetCenter();
234  double angle = -graphic->GetAngle();
235  double radius = graphic->GetRadius();
236  int steps = GetArcToSegmentCount( radius, ARC_LOW_DEF, angle / 10.0 );
237  wxPoint pt;
238 
239  for( int step = 1; step<=steps; ++step )
240  {
241  double rotation = ( angle * step ) / steps;
242 
243  pt = pstart;
244 
245  RotatePoint( &pt, center, rotation );
246 
247  if( pt.x < xmin.x )
248  {
249  xmin = pt;
250  xmini = i;
251  }
252  }
253  }
254  break;
255 
256  case S_CIRCLE:
257  {
258  wxPoint pt = graphic->GetCenter();
259 
260  // pt has minimum x point
261  pt.x -= graphic->GetRadius();
262 
263  // when the radius <= 0, this is a mal-formed circle. Skip it
264  if( graphic->GetRadius() > 0 && pt.x < xmin.x )
265  {
266  xmin = pt;
267  xmini = i;
268  }
269  }
270  break;
271 
272  case S_CURVE:
273  {
274  graphic->RebuildBezierToSegmentsPointsList( graphic->GetWidth() );
275 
276  for( unsigned int jj = 0; jj < graphic->GetBezierPoints().size(); jj++ )
277  {
278  wxPoint pt = graphic->GetBezierPoints()[jj];
279 
280  if( pt.x < xmin.x )
281  {
282  xmin = pt;
283  xmini = i;
284  }
285  }
286  }
287  break;
288 
289  case S_POLYGON:
290  {
291  const auto poly = graphic->GetPolyShape();
292  MODULE* module = aSegList[0]->GetParentModule();
293  double orientation = module ? module->GetOrientation() : 0.0;
294  VECTOR2I offset = module ? module->GetPosition() : VECTOR2I( 0, 0 );
295 
296  for( auto iter = poly.CIterate(); iter; iter++ )
297  {
298  auto pt = *iter;
299  RotatePoint( pt, orientation );
300  pt += offset;
301 
302  if( pt.x < xmin.x )
303  {
304  xmin.x = pt.x;
305  xmin.y = pt.y;
306  xmini = i;
307  }
308  }
309  }
310  break;
311  default:
312  break;
313  }
314  }
315 
316  // Grab the left most point, assume its on the board's perimeter, and see if we
317  // can put enough graphics together by matching endpoints to formulate a cohesive
318  // polygon.
319 
320  graphic = (DRAWSEGMENT*) segList[xmini];
321 
322  // The first DRAWSEGMENT is in 'graphic', ok to remove it from 'items'
323  segList.erase( segList.begin() + xmini );
324 
325  // Output the outline perimeter as polygon.
326  if( graphic->GetShape() == S_CIRCLE )
327  {
328  TransformCircleToPolygon( aPolygons, graphic->GetCenter(), graphic->GetRadius(), aTolerance );
329  }
330  else if( graphic->GetShape() == S_RECT )
331  {
332  std::vector<wxPoint> pts;
333  graphic->GetRectCorners( &pts );
334 
335  aPolygons.NewOutline();
336 
337  for( const wxPoint& pt : pts )
338  aPolygons.Append( pt );
339  }
340  else if( graphic->GetShape() == S_POLYGON )
341  {
342  MODULE* module = graphic->GetParentModule(); // NULL for items not in footprints
343  double orientation = module ? module->GetOrientation() : 0.0;
344  VECTOR2I offset = module ? module->GetPosition() : VECTOR2I( 0, 0 );
345 
346  aPolygons.NewOutline();
347 
348  for( auto it = graphic->GetPolyShape().CIterate( 0 ); it; it++ )
349  {
350  auto pt = *it;
351  RotatePoint( pt, orientation );
352  pt += offset;
353  aPolygons.Append( pt );
354  }
355  }
356  else
357  {
358  // Polygon start point. Arbitrarily chosen end of the
359  // segment and build the poly from here.
360 
361  wxPoint startPt = wxPoint( graphic->GetEnd() );
362  prevPt = graphic->GetEnd();
363  aPolygons.NewOutline();
364  aPolygons.Append( prevPt );
365 
366  // Do not append the other end point yet of this 'graphic', this first
367  // 'graphic' might be an arc or a curve.
368 
369  for(;;)
370  {
371  switch( graphic->GetShape() )
372  {
373  case S_SEGMENT:
374  {
375  wxPoint nextPt;
376 
377  // Use the line segment end point furthest away from
378  // prevPt as we assume the other end to be ON prevPt or
379  // very close to it.
380 
381  if( close_st( prevPt, graphic->GetStart(), graphic->GetEnd() ) )
382  nextPt = graphic->GetEnd();
383  else
384  nextPt = graphic->GetStart();
385 
386  aPolygons.Append( nextPt );
387  prevPt = nextPt;
388  }
389  break;
390 
391  case S_ARC:
392  // We do not support arcs in polygons, so approximate
393  // an arc with a series of short lines and put those
394  // line segments into the !same! PATH.
395  {
396  wxPoint pstart = graphic->GetArcStart();
397  wxPoint pend = graphic->GetArcEnd();
398  wxPoint pcenter = graphic->GetCenter();
399  double angle = -graphic->GetAngle();
400  double radius = graphic->GetRadius();
401  int steps = GetArcToSegmentCount( radius, aTolerance, angle / 10.0 );
402 
403  if( !close_enough( prevPt, pstart, aTolerance ) )
404  {
405  wxASSERT( close_enough( prevPt, graphic->GetArcEnd(), aTolerance ) );
406 
407  angle = -angle;
408  std::swap( pstart, pend );
409  }
410 
411  wxPoint nextPt;
412 
413  for( int step = 1; step<=steps; ++step )
414  {
415  double rotation = ( angle * step ) / steps;
416  nextPt = pstart;
417  RotatePoint( &nextPt, pcenter, rotation );
418 
419  aPolygons.Append( nextPt );
420  }
421 
422  prevPt = nextPt;
423  }
424  break;
425 
426  case S_CURVE:
427  // We do not support Bezier curves in polygons, so approximate
428  // with a series of short lines and put those
429  // line segments into the !same! PATH.
430  {
431  wxPoint nextPt;
432  bool reverse = false;
433 
434  // Use the end point furthest away from
435  // prevPt as we assume the other end to be ON prevPt or
436  // very close to it.
437 
438  if( close_st( prevPt, graphic->GetStart(), graphic->GetEnd() ) )
439  nextPt = graphic->GetEnd();
440  else
441  {
442  nextPt = graphic->GetStart();
443  reverse = true;
444  }
445 
446  if( reverse )
447  {
448  for( int jj = graphic->GetBezierPoints().size()-1; jj >= 0; jj-- )
449  aPolygons.Append( graphic->GetBezierPoints()[jj] );
450  }
451  else
452  {
453  for( size_t jj = 0; jj < graphic->GetBezierPoints().size(); jj++ )
454  aPolygons.Append( graphic->GetBezierPoints()[jj] );
455  }
456 
457  prevPt = nextPt;
458  }
459  break;
460 
461  default:
462  if( aErrorText )
463  {
464  msg.Printf( "Unsupported DRAWSEGMENT type %s.",
465  BOARD_ITEM::ShowShape( graphic->GetShape() ) );
466 
467  *aErrorText << msg << "\n";
468  }
469 
470  if( aErrorLocation )
471  *aErrorLocation = graphic->GetPosition();
472 
473  return false;
474  }
475 
476  // Get next closest segment.
477 
478  graphic = findPoint( prevPt, segList, aTolerance );
479 
480  // If there are no more close segments, check if the board
481  // outline polygon can be closed.
482 
483  if( !graphic )
484  {
485  if( close_enough( startPt, prevPt, aTolerance ) )
486  {
487  // Close the polygon back to start point
488  // aPolygons.Append( startPt ); // not needed
489  }
490  else
491  {
492  if( aErrorText )
493  {
494  msg.Printf( _( "Unable to find segment with an endpoint of (%s, %s)." ),
495  StringFromValue( EDA_UNITS::MILLIMETRES, prevPt.x, true ),
496  StringFromValue( EDA_UNITS::MILLIMETRES, prevPt.y, true ) );
497 
498  *aErrorText << msg << "\n";
499  }
500 
501  if( aErrorLocation )
502  *aErrorLocation = prevPt;
503 
504  return false;
505  }
506  break;
507  }
508  }
509  }
510 
511  while( segList.size() )
512  {
513  // emit a signal layers keepout for every interior polygon left...
514  int hole = aPolygons.NewHole();
515 
516  graphic = (DRAWSEGMENT*) segList[0];
517  segList.erase( segList.begin() );
518 
519  // Both circles and polygons on the edge cuts layer are closed items that
520  // do not connect to other elements, so we process them independently
521  if( graphic->GetShape() == S_POLYGON )
522  {
523  MODULE* module = graphic->GetParentModule(); // NULL for items not in footprints
524  double orientation = module ? module->GetOrientation() : 0.0;
525  VECTOR2I offset = module ? module->GetPosition() : VECTOR2I( 0, 0 );
526 
527  for( auto it = graphic->GetPolyShape().CIterate(); it; it++ )
528  {
529  auto val = *it;
530  RotatePoint( val, orientation );
531  val += offset;
532 
533  aPolygons.Append( val, -1, hole );
534  }
535  }
536  else if( graphic->GetShape() == S_CIRCLE )
537  {
538  // make a circle by segments;
539  wxPoint center = graphic->GetCenter();
540  double angle = 3600.0;
541  wxPoint start = center;
542  int radius = graphic->GetRadius();
543  int steps = std::max<int>( 4, GetArcToSegmentCount( radius, aTolerance, 360.0 ) );
544  wxPoint nextPt;
545 
546  start.x += radius;
547 
548  for( int step = 0; step < steps; ++step )
549  {
550  double rotation = ( angle * step ) / steps;
551  nextPt = start;
552  RotatePoint( &nextPt.x, &nextPt.y, center.x, center.y, rotation );
553  aPolygons.Append( nextPt, -1, hole );
554  }
555  }
556  else if( graphic->GetShape() == S_RECT )
557  {
558  std::vector<wxPoint> pts;
559  graphic->GetRectCorners( &pts );
560 
561  for( const wxPoint& pt : pts )
562  aPolygons.Append( pt, -1, hole );
563  }
564  else
565  {
566  // Polygon start point. Arbitrarily chosen end of the
567  // segment and build the poly from here.
568 
569  wxPoint startPt( graphic->GetEnd() );
570  prevPt = graphic->GetEnd();
571  aPolygons.Append( prevPt, -1, hole );
572 
573  // do not append the other end point yet, this first 'graphic' might be an arc
574  for(;;)
575  {
576  switch( graphic->GetShape() )
577  {
578  case S_SEGMENT:
579  {
580  wxPoint nextPt;
581 
582  // Use the line segment end point furthest away from
583  // prevPt as we assume the other end to be ON prevPt or
584  // very close to it.
585 
586  if( close_st( prevPt, graphic->GetStart(), graphic->GetEnd() ) )
587  {
588  nextPt = graphic->GetEnd();
589  }
590  else
591  {
592  nextPt = graphic->GetStart();
593  }
594 
595  prevPt = nextPt;
596  aPolygons.Append( prevPt, -1, hole );
597  }
598  break;
599 
600  case S_ARC:
601  // Freerouter does not yet understand arcs, so approximate
602  // an arc with a series of short lines and put those
603  // line segments into the !same! PATH.
604  {
605  wxPoint pstart = graphic->GetArcStart();
606  wxPoint pend = graphic->GetArcEnd();
607  wxPoint pcenter = graphic->GetCenter();
608  double angle = -graphic->GetAngle();
609  int radius = graphic->GetRadius();
610  int steps = GetArcToSegmentCount( radius, aTolerance, angle / 10.0 );
611 
612  if( !close_enough( prevPt, pstart, aTolerance ) )
613  {
614  wxASSERT( close_enough( prevPt, graphic->GetArcEnd(), aTolerance ) );
615 
616  angle = -angle;
617  std::swap( pstart, pend );
618  }
619 
620  wxPoint nextPt;
621 
622  for( int step = 1; step <= steps; ++step )
623  {
624  double rotation = ( angle * step ) / steps;
625 
626  nextPt = pstart;
627  RotatePoint( &nextPt, pcenter, rotation );
628 
629  aPolygons.Append( nextPt, -1, hole );
630  }
631 
632  prevPt = nextPt;
633  }
634  break;
635 
636  case S_CURVE:
637  // We do not support Bezier curves in polygons, so approximate
638  // with a series of short lines and put those
639  // line segments into the !same! PATH.
640  {
641  wxPoint nextPt;
642  bool reverse = false;
643 
644  // Use the end point furthest away from
645  // prevPt as we assume the other end to be ON prevPt or
646  // very close to it.
647 
648  if( close_st( prevPt, graphic->GetStart(), graphic->GetEnd() ) )
649  nextPt = graphic->GetEnd();
650  else
651  {
652  nextPt = graphic->GetStart();
653  reverse = true;
654  }
655 
656  if( reverse )
657  {
658  for( int jj = graphic->GetBezierPoints().size()-1; jj >= 0; jj-- )
659  aPolygons.Append( graphic->GetBezierPoints()[jj], -1, hole );
660  }
661  else
662  {
663  for( size_t jj = 0; jj < graphic->GetBezierPoints().size(); jj++ )
664  aPolygons.Append( graphic->GetBezierPoints()[jj], -1, hole );
665  }
666 
667  prevPt = nextPt;
668  }
669  break;
670 
671  default:
672  if( aErrorText )
673  {
674  msg.Printf( "Unsupported DRAWSEGMENT type %s.",
675  BOARD_ITEM::ShowShape( graphic->GetShape() ) );
676 
677  *aErrorText << msg << "\n";
678  }
679 
680  if( aErrorLocation )
681  *aErrorLocation = graphic->GetPosition();
682 
683  return false;
684  }
685 
686  // Get next closest segment.
687 
688  graphic = findPoint( prevPt, segList, aTolerance );
689 
690  // If there are no more close segments, check if polygon
691  // can be closed.
692 
693  if( !graphic )
694  {
695  if( close_enough( startPt, prevPt, aTolerance ) )
696  {
697  // Close the polygon back to start point
698  // aPolygons.Append( startPt, -1, hole ); // not needed
699  }
700  else
701  {
702  if( aErrorText )
703  {
704  msg.Printf( _( "Unable to find segment with an endpoint of (%s, %s)." ),
705  StringFromValue( EDA_UNITS::MILLIMETRES, prevPt.x, true ),
706  StringFromValue( EDA_UNITS::MILLIMETRES, prevPt.y, true ) );
707 
708  *aErrorText << msg << "\n";
709  }
710 
711  if( aErrorLocation )
712  *aErrorLocation = prevPt;
713 
714  return false;
715  }
716  break;
717  }
718  }
719  }
720  }
721 
722  // All of the silliness that follows is to work around the segment iterator
723  // while checking for collisions.
724  // TODO: Implement proper segment and point iterators that follow std
725  for( auto seg1 = aPolygons.IterateSegmentsWithHoles(); seg1; seg1++ )
726  {
727  auto seg2 = seg1;
728 
729  for( ++seg2; seg2; seg2++ )
730  {
731  // Check for exact overlapping segments. This is not viewed
732  // as an intersection below
733  if( *seg1 == *seg2 ||
734  ( ( *seg1 ).A == ( *seg2 ).B && ( *seg1 ).B == ( *seg2 ).A ) )
735  {
736  if( aErrorLocation )
737  {
738  aErrorLocation->x = ( *seg1 ).A.x;
739  aErrorLocation->y = ( *seg1 ).A.y;
740  }
741 
742  return false;
743  }
744 
745  if( auto pt = seg1.Get().Intersect( seg2.Get(), true ) )
746  {
747  if( aErrorLocation )
748  {
749  aErrorLocation->x = pt->x;
750  aErrorLocation->y = pt->y;
751  }
752 
753  return false;
754  }
755  }
756  }
757 
758  return true;
759 }
int NewHole(int aOutline=-1)
Creates a new hole in a given outline
static wxString ShowShape(STROKE_T aShape)
Function ShowShape converts the enum STROKE_T integer value to a wxString.
double GetOrientation() const
Definition: class_module.h:221
wxPoint GetArcStart() const
wxPoint GetArcEnd() const
SEGMENT_ITERATOR IterateSegmentsWithHoles()
Returns an iterator object, for all outlines in the set (with holes)
STROKE_T GetShape() const
polygon (not yet used for tracks, but could be in microwave apps)
void RebuildBezierToSegmentsPointsList(int aMinSegLen)
Rebuild the m_BezierPoints vertex list that approximate the Bezier curve by a list of segments Has me...
usual segment : line with rounded ends
const std::vector< wxPoint > & GetBezierPoints() const
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:208
VECTOR2< int > VECTOR2I
Definition: vector2d.h:594
const wxPoint & GetEnd() const
Function GetEnd returns the ending point of the graphic.
bool close_st(const wxPoint &aReference, const wxPoint &aFirst, const wxPoint &aSecond)
Function close_st is a local method of qualifying if either the start of end point of a segment is cl...
wxPoint GetPosition() const override
segment with non rounded ends
Arcs (with rounded ends)
MODULE * GetParentModule() const
Function GetParentModule returns a pointer to the parent module, or NULL if DRAWSEGMENT does not belo...
int GetRadius() const
Function GetRadius returns the radius of this item Has meaning only for arc and circle.
SHAPE_POLY_SET & GetPolyShape()
Bezier Curve.
bool close_enough(const wxPoint &aLeft, const wxPoint &aRight, unsigned aLimit)
Function close_enough is a local and tunable method of qualifying the proximity of two points.
int NewOutline()
Creates a new empty polygon in the set and returns its index
CONST_ITERATOR CIterate(int aFirst, int aLast, bool aIterateHoles=false) const
int GetWidth() const
double GetAngle() const
#define _(s)
Definition: 3d_actions.cpp:33
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
static DRAWSEGMENT * findPoint(const wxPoint &aPoint, std::vector< DRAWSEGMENT * > &aList, unsigned aLimit)
Searches for a DRAWSEGMENT matching a given end point or start point in a list, and if found,...
void TransformCircleToPolygon(SHAPE_POLY_SET &aCornerBuffer, wxPoint aCenter, int aRadius, int aError)
Function TransformCircleToPolygon convert a circle to a polygon, using multiple straight lines.
const wxPoint & GetStart() const
Function GetStart returns the starting point of the graphic.
wxPoint GetPosition() const override
Definition: class_module.h:216
void GetRectCorners(std::vector< wxPoint > *pts) const
int GetArcToSegmentCount(int aRadius, int aErrorMax, double aArcAngleDegree)
wxString StringFromValue(EDA_UNITS aUnits, double aValue, bool aAddUnitSymbol, bool aUseMils, EDA_DATA_TYPE aType)
Function StringFromValue returns the string from aValue according to units (inch, mm ....
Definition: base_units.cpp:233
wxPoint GetCenter() const override
Function GetCenter()
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Appends a vertex at the end of the given outline/hole (default: the last outline)

References _, PNS::angle(), SHAPE_POLY_SET::Append(), SHAPE_POLY_SET::CIterate(), close_enough(), close_st(), findPoint(), DRAWSEGMENT::GetAngle(), DRAWSEGMENT::GetArcEnd(), DRAWSEGMENT::GetArcStart(), GetArcToSegmentCount(), DRAWSEGMENT::GetBezierPoints(), DRAWSEGMENT::GetCenter(), DRAWSEGMENT::GetEnd(), MODULE::GetOrientation(), DRAWSEGMENT::GetParentModule(), DRAWSEGMENT::GetPolyShape(), DRAWSEGMENT::GetPosition(), MODULE::GetPosition(), DRAWSEGMENT::GetRadius(), DRAWSEGMENT::GetRectCorners(), DRAWSEGMENT::GetShape(), DRAWSEGMENT::GetStart(), DRAWSEGMENT::GetWidth(), SHAPE_POLY_SET::IterateSegmentsWithHoles(), MILLIMETRES, SHAPE_POLY_SET::NewHole(), SHAPE_POLY_SET::NewOutline(), DRAWSEGMENT::RebuildBezierToSegmentsPointsList(), RotatePoint(), S_ARC, S_CIRCLE, S_CURVE, S_POLYGON, S_RECT, S_SEGMENT, BOARD_ITEM::ShowShape(), StringFromValue(), TransformCircleToPolygon(), wxPoint::x, and wxPoint::y.

Referenced by BuildBoardPolygonOutlines(), and MODULE::BuildPolyCourtyard().

◆ polygonArea()

static double polygonArea ( SHAPE_POLY_SET aPolySet)
static

Definition at line 1467 of file class_module.cpp.

1468 {
1469  double area = 0.0;
1470  for( int ii = 0; ii < aPolySet.OutlineCount(); ii++ )
1471  {
1472  SHAPE_LINE_CHAIN& outline = aPolySet.Outline( ii );
1473  // Ensure the curr outline is closed, to calculate area
1474  outline.SetClosed( true );
1475 
1476  area += outline.Area();
1477  }
1478 
1479  return area;
1480 }
int OutlineCount() const
Returns the number of outlines in the set
void SetClosed(bool aClosed)
Function SetClosed()
SHAPE_LINE_CHAIN & Outline(int aIndex)
Returns the reference to aIndex-th outline in the set
SHAPE_LINE_CHAIN.

References SHAPE_LINE_CHAIN::Area(), SHAPE_POLY_SET::Outline(), SHAPE_POLY_SET::OutlineCount(), and SHAPE_LINE_CHAIN::SetClosed().

Referenced by MODULE::CoverageRatio().

Variable Documentation

◆ _MODULE_DESC

struct MODULE_DESC _MODULE_DESC
static