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_CONVEX, SH_POLY_SET, SH_COMPOUND
}
 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_CONVEX 

circle

SH_POLY_SET 

convex polygon

SH_COMPOUND 

any polygon (with holes, etc.)

compound shape, consisting of multiple simple shapes

Definition at line 41 of file shape.h.

42 {
43  SH_RECT = 0,
44  SH_SEGMENT,
46  SH_CIRCLE,
47  SH_CONVEX,
48  SH_POLY_SET,
50 };
any polygon (with holes, etc.)
Definition: shape.h:49
line chain (polyline)
Definition: shape.h:46
convex 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 324 of file shape_collisions.cpp.

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

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

325 {
326  switch( aA->Type() )
327  {
328  case SH_RECT:
329  switch( aB->Type() )
330  {
331  case SH_RECT:
332  return CollCase<SHAPE_RECT, SHAPE_RECT>( aA, aB, aClearance, aNeedMTV, aMTV );
333 
334  case SH_CIRCLE:
335  return CollCase<SHAPE_RECT, SHAPE_CIRCLE>( aA, aB, aClearance, aNeedMTV, aMTV );
336 
337  case SH_LINE_CHAIN:
338  return CollCase<SHAPE_RECT, SHAPE_LINE_CHAIN>( aA, aB, aClearance, aNeedMTV, aMTV );
339 
340  case SH_SEGMENT:
341  return CollCase<SHAPE_RECT, SHAPE_SEGMENT>( aA, aB, aClearance, aNeedMTV, aMTV );
342 
343  case SH_CONVEX:
344  return CollCase<SHAPE_RECT, SHAPE_CONVEX>( aA, aB, aClearance, aNeedMTV, aMTV );
345 
346  default:
347  break;
348  }
349  break;
350 
351  case SH_CIRCLE:
352  switch( aB->Type() )
353  {
354  case SH_RECT:
355  return CollCaseReversed<SHAPE_CIRCLE, SHAPE_RECT>( aA, aB, aClearance, aNeedMTV, aMTV );
356 
357  case SH_CIRCLE:
358  return CollCase<SHAPE_CIRCLE, SHAPE_CIRCLE>( aA, aB, aClearance, aNeedMTV, aMTV );
359 
360  case SH_LINE_CHAIN:
361  return CollCase<SHAPE_CIRCLE, SHAPE_LINE_CHAIN>( aA, aB, aClearance, aNeedMTV, aMTV );
362 
363  case SH_SEGMENT:
364  return CollCase<SHAPE_CIRCLE, SHAPE_SEGMENT>( aA, aB, aClearance, aNeedMTV, aMTV );
365 
366  case SH_CONVEX:
367  return CollCase<SHAPE_CIRCLE, SHAPE_CONVEX>( aA, aB, aClearance, aNeedMTV, aMTV );
368 
369  default:
370  break;
371  }
372  break;
373 
374  case SH_LINE_CHAIN:
375  switch( aB->Type() )
376  {
377  case SH_RECT:
378  return CollCase<SHAPE_RECT, SHAPE_LINE_CHAIN>( aB, aA, aClearance, aNeedMTV, aMTV );
379 
380  case SH_CIRCLE:
381  return CollCase<SHAPE_CIRCLE, SHAPE_LINE_CHAIN>( aB, aA, aClearance, aNeedMTV, aMTV );
382 
383  case SH_LINE_CHAIN:
384  return CollCase<SHAPE_LINE_CHAIN, SHAPE_LINE_CHAIN>( aA, aB, aClearance, aNeedMTV, aMTV );
385 
386  case SH_SEGMENT:
387  return CollCase<SHAPE_LINE_CHAIN, SHAPE_SEGMENT>( aA, aB, aClearance, aNeedMTV, aMTV );
388 
389  case SH_CONVEX:
390  return CollCase<SHAPE_LINE_CHAIN, SHAPE_CONVEX>( aA, aB, aClearance, aNeedMTV, aMTV );
391 
392  default:
393  break;
394  }
395  break;
396 
397  case SH_SEGMENT:
398  switch( aB->Type() )
399  {
400  case SH_RECT:
401  return CollCase<SHAPE_RECT, SHAPE_SEGMENT>( aB, aA, aClearance, aNeedMTV, aMTV );
402 
403  case SH_CIRCLE:
404  return CollCaseReversed<SHAPE_SEGMENT, SHAPE_CIRCLE>( aA, aB, aClearance, aNeedMTV, aMTV );
405 
406  case SH_LINE_CHAIN:
407  return CollCase<SHAPE_LINE_CHAIN, SHAPE_SEGMENT>( aB, aA, aClearance, aNeedMTV, aMTV );
408 
409  case SH_SEGMENT:
410  return CollCase<SHAPE_SEGMENT, SHAPE_SEGMENT>( aA, aB, aClearance, aNeedMTV, aMTV );
411 
412  case SH_CONVEX:
413  return CollCase<SHAPE_CONVEX, SHAPE_SEGMENT>( aB, aA, aClearance, aNeedMTV, aMTV );
414 
415  default:
416  break;
417  }
418  break;
419 
420  case SH_CONVEX:
421  switch( aB->Type() )
422  {
423  case SH_RECT:
424  return CollCase<SHAPE_RECT, SHAPE_CONVEX>( aB, aA, aClearance, aNeedMTV, aMTV );
425 
426  case SH_CIRCLE:
427  return CollCase<SHAPE_CIRCLE, SHAPE_CONVEX>( aB, aA, aClearance, aNeedMTV, aMTV );
428 
429  case SH_LINE_CHAIN:
430  return CollCase<SHAPE_LINE_CHAIN, SHAPE_CONVEX>( aB, aA, aClearance, aNeedMTV, aMTV );
431 
432  case SH_SEGMENT:
433  return CollCase<SHAPE_CONVEX, SHAPE_SEGMENT>( aA, aB, aClearance, aNeedMTV, aMTV );
434 
435  case SH_CONVEX:
436  return CollCase<SHAPE_CONVEX, SHAPE_CONVEX>( aA, aB, aClearance, aNeedMTV, aMTV );
437 
438  default:
439  break;
440  }
441  break;
442 
443  default:
444  break;
445  }
446 
447  bool unsupported_collision = true;
448  (void) unsupported_collision; // make gcc quiet
449 
450  assert( unsupported_collision == false );
451 
452  return false;
453 }
line chain (polyline)
Definition: shape.h:46
SHAPE_TYPE Type() const
Function Type()
Definition: shape.h:82
line segment
Definition: shape.h:45
Definition: shape.h:43
circle
Definition: shape.h:47
axis-aligned rectangle
Definition: shape.h:44