KiCad PCB EDA Suite
shape.h File Reference
#include <string>
#include <sstream>
#include <math/vector2d.h>
#include <math/box2.h>
#include <geometry/seg.h>

Go to the source code of this file.

Classes

class  SHAPE
 Class SHAPE. More...
 

Enumerations

enum  SHAPE_TYPE {
  SH_RECT = 0, SH_SEGMENT, SH_LINE_CHAIN, SH_CIRCLE,
  SH_SIMPLE, SH_POLY_SET, SH_COMPOUND, SH_ARC
}
 Enum SHAPE_TYPE Lists all supported shapes. More...
 

Functions

bool CollideShapes (const SHAPE *aA, const SHAPE *aB, int aClearance, bool aNeedMTV, VECTOR2I &aMTV)
 

Enumeration Type Documentation

enum SHAPE_TYPE

Enum SHAPE_TYPE Lists all supported shapes.

Enumerator
SH_RECT 
SH_SEGMENT 

axis-aligned rectangle

SH_LINE_CHAIN 

line segment

SH_CIRCLE 

line chain (polyline)

SH_SIMPLE 

circle

SH_POLY_SET 

simple polygon

SH_COMPOUND 

set of polygons (with holes, etc.)

SH_ARC 

compound shape, consisting of multiple simple shapes

circular arc

Definition at line 41 of file shape.h.

42 {
43  SH_RECT = 0,
44  SH_SEGMENT,
46  SH_CIRCLE,
47  SH_SIMPLE,
48  SH_POLY_SET,
49  SH_COMPOUND,
50  SH_ARC
51 };
set of polygons (with holes, etc.)
Definition: shape.h:49
compound shape, consisting of multiple simple shapes
Definition: shape.h:50
line chain (polyline)
Definition: shape.h:46
simple polygon
Definition: shape.h:48
line segment
Definition: shape.h:45
Definition: shape.h:43
circle
Definition: shape.h:47
axis-aligned rectangle
Definition: shape.h:44

Function Documentation

bool CollideShapes ( const SHAPE aA,
const SHAPE aB,
int  aClearance,
bool  aNeedMTV,
VECTOR2I aMTV 
)

Definition at line 372 of file shape_collisions.cpp.

References SH_ARC, SH_CIRCLE, SH_LINE_CHAIN, SH_RECT, SH_SEGMENT, SH_SIMPLE, and SHAPE::Type().

Referenced by SHAPE::Collide(), PNS::SHOVE::onCollidingVia(), and PNS::VIA::PushoutForce().

373 {
374  switch( aA->Type() )
375  {
376  case SH_RECT:
377  switch( aB->Type() )
378  {
379  case SH_RECT:
380  return CollCase<SHAPE_RECT, SHAPE_RECT>( aA, aB, aClearance, aNeedMTV, aMTV );
381 
382  case SH_CIRCLE:
383  return CollCase<SHAPE_RECT, SHAPE_CIRCLE>( aA, aB, aClearance, aNeedMTV, aMTV );
384 
385  case SH_LINE_CHAIN:
386  return CollCase<SHAPE_RECT, SHAPE_LINE_CHAIN>( aA, aB, aClearance, aNeedMTV, aMTV );
387 
388  case SH_SEGMENT:
389  return CollCase<SHAPE_RECT, SHAPE_SEGMENT>( aA, aB, aClearance, aNeedMTV, aMTV );
390 
391  case SH_SIMPLE:
392  return CollCase<SHAPE_RECT, SHAPE_SIMPLE>( aA, aB, aClearance, aNeedMTV, aMTV );
393 
394  case SH_ARC:
395  return CollCaseReversed<SHAPE_RECT, SHAPE_ARC>( aA, aB, aClearance, aNeedMTV, aMTV );
396 
397  default:
398  break;
399  }
400  break;
401 
402  case SH_CIRCLE:
403  switch( aB->Type() )
404  {
405  case SH_RECT:
406  return CollCaseReversed<SHAPE_CIRCLE, SHAPE_RECT>( aA, aB, aClearance, aNeedMTV, aMTV );
407 
408  case SH_CIRCLE:
409  return CollCase<SHAPE_CIRCLE, SHAPE_CIRCLE>( aA, aB, aClearance, aNeedMTV, aMTV );
410 
411  case SH_LINE_CHAIN:
412  return CollCase<SHAPE_CIRCLE, SHAPE_LINE_CHAIN>( aA, aB, aClearance, aNeedMTV, aMTV );
413 
414  case SH_SEGMENT:
415  return CollCase<SHAPE_CIRCLE, SHAPE_SEGMENT>( aA, aB, aClearance, aNeedMTV, aMTV );
416 
417  case SH_SIMPLE:
418  return CollCase<SHAPE_CIRCLE, SHAPE_SIMPLE>( aA, aB, aClearance, aNeedMTV, aMTV );
419 
420  case SH_ARC:
421  return CollCaseReversed<SHAPE_CIRCLE, SHAPE_ARC>( aA, aB, aClearance, aNeedMTV, aMTV );
422 
423  default:
424  break;
425  }
426  break;
427 
428  case SH_LINE_CHAIN:
429  switch( aB->Type() )
430  {
431  case SH_RECT:
432  return CollCase<SHAPE_RECT, SHAPE_LINE_CHAIN>( aB, aA, aClearance, aNeedMTV, aMTV );
433 
434  case SH_CIRCLE:
435  return CollCase<SHAPE_CIRCLE, SHAPE_LINE_CHAIN>( aB, aA, aClearance, aNeedMTV, aMTV );
436 
437  case SH_LINE_CHAIN:
438  return CollCase<SHAPE_LINE_CHAIN, SHAPE_LINE_CHAIN>( aA, aB, aClearance, aNeedMTV, aMTV );
439 
440  case SH_SEGMENT:
441  return CollCase<SHAPE_LINE_CHAIN, SHAPE_SEGMENT>( aA, aB, aClearance, aNeedMTV, aMTV );
442 
443  case SH_SIMPLE:
444  return CollCase<SHAPE_LINE_CHAIN, SHAPE_SIMPLE>( aA, aB, aClearance, aNeedMTV, aMTV );
445 
446  case SH_ARC:
447  return CollCaseReversed<SHAPE_LINE_CHAIN, SHAPE_ARC>( aA, aB, aClearance, aNeedMTV, aMTV );
448 
449  default:
450  break;
451  }
452  break;
453 
454  case SH_SEGMENT:
455  switch( aB->Type() )
456  {
457  case SH_RECT:
458  return CollCase<SHAPE_RECT, SHAPE_SEGMENT>( aB, aA, aClearance, aNeedMTV, aMTV );
459 
460  case SH_CIRCLE:
461  return CollCaseReversed<SHAPE_SEGMENT, SHAPE_CIRCLE>( aA, aB, aClearance, aNeedMTV, aMTV );
462 
463  case SH_LINE_CHAIN:
464  return CollCase<SHAPE_LINE_CHAIN, SHAPE_SEGMENT>( aB, aA, aClearance, aNeedMTV, aMTV );
465 
466  case SH_SEGMENT:
467  return CollCase<SHAPE_SEGMENT, SHAPE_SEGMENT>( aA, aB, aClearance, aNeedMTV, aMTV );
468 
469  case SH_SIMPLE:
470  return CollCase<SHAPE_SIMPLE, SHAPE_SEGMENT>( aB, aA, aClearance, aNeedMTV, aMTV );
471 
472  case SH_ARC:
473  return CollCaseReversed<SHAPE_SEGMENT, SHAPE_ARC>( aA, aB, aClearance, aNeedMTV, aMTV );
474 
475  default:
476  break;
477  }
478  break;
479 
480  case SH_SIMPLE:
481  switch( aB->Type() )
482  {
483  case SH_RECT:
484  return CollCase<SHAPE_RECT, SHAPE_SIMPLE>( aB, aA, aClearance, aNeedMTV, aMTV );
485 
486  case SH_CIRCLE:
487  return CollCase<SHAPE_CIRCLE, SHAPE_SIMPLE>( aB, aA, aClearance, aNeedMTV, aMTV );
488 
489  case SH_LINE_CHAIN:
490  return CollCase<SHAPE_LINE_CHAIN, SHAPE_SIMPLE>( aB, aA, aClearance, aNeedMTV, aMTV );
491 
492  case SH_SEGMENT:
493  return CollCase<SHAPE_SIMPLE, SHAPE_SEGMENT>( aA, aB, aClearance, aNeedMTV, aMTV );
494 
495  case SH_SIMPLE:
496  return CollCase<SHAPE_SIMPLE, SHAPE_SIMPLE>( aA, aB, aClearance, aNeedMTV, aMTV );
497 
498  case SH_ARC:
499  return CollCaseReversed<SHAPE_SIMPLE, SHAPE_ARC>( aA, aB, aClearance, aNeedMTV, aMTV );
500 
501  default:
502  break;
503  }
504  break;
505 
506  case SH_ARC:
507  switch( aB->Type() )
508  {
509  case SH_RECT:
510  return CollCase<SHAPE_ARC, SHAPE_RECT>( aA, aB, aClearance, aNeedMTV, aMTV );
511 
512  case SH_CIRCLE:
513  return CollCase<SHAPE_ARC, SHAPE_CIRCLE>( aA, aB, aClearance, aNeedMTV, aMTV );
514 
515  case SH_LINE_CHAIN:
516  return CollCase<SHAPE_ARC, SHAPE_LINE_CHAIN>( aA, aB, aClearance, aNeedMTV, aMTV );
517 
518  case SH_SEGMENT:
519  return CollCase<SHAPE_ARC, SHAPE_SEGMENT>( aA, aB, aClearance, aNeedMTV, aMTV );
520 
521  case SH_SIMPLE:
522  return CollCase<SHAPE_ARC, SHAPE_SIMPLE>( aA, aB, aClearance, aNeedMTV, aMTV );
523 
524  case SH_ARC:
525  return CollCase<SHAPE_ARC, SHAPE_ARC>( aA, aB, aClearance, aNeedMTV, aMTV );
526 
527  default:
528  break;
529  }
530  break;
531 
532  default:
533  break;
534  }
535 
536  bool unsupported_collision = true;
537  (void) unsupported_collision; // make gcc quiet
538 
539  assert( unsupported_collision == false );
540 
541  return false;
542 }
compound shape, consisting of multiple simple shapes
Definition: shape.h:50
line chain (polyline)
Definition: shape.h:46
SHAPE_TYPE Type() const
Function Type()
Definition: shape.h:83
line segment
Definition: shape.h:45
Definition: shape.h:43
circle
Definition: shape.h:47
axis-aligned rectangle
Definition: shape.h:44