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

Go to the source code of this file.

Classes

class  SHAPE
 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

◆ SHAPE_TYPE

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 43 of file shape.h.

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

Function Documentation

◆ CollideShapes()

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

Definition at line 376 of file shape_collisions.cpp.

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

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().