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

◆ 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 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

◆ CollideShapes()

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

Definition at line 370 of file shape_collisions.cpp.

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

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