25#ifndef __SHAPE_COMPOUND_H
26#define __SHAPE_COMPOUND_H
28#include <geometry/shape.h>
29#include <math/vector2d.h>
52 const std::string Format()
const override;
54 bool Collide(
const SEG& aSeg,
int aClearance = 0,
int* aActual =
nullptr,
55 VECTOR2I* aLocation =
nullptr )
const override;
62 bool Collide(
const SHAPE* aShape,
int aClearance = 0,
int* aActual =
nullptr,
63 VECTOR2I* aLocation =
nullptr )
const override
68 const std::vector<SHAPE*>& Shapes()
const
73 const BOX2I BBox(
int aClearance = 0 )
const override;
75 int Distance(
const SEG& aSeg )
const;
77 void Move(
const VECTOR2I& aVector )
override;
79 void AddShape(
SHAPE* aShape )
82 if( aShape->HasIndexableSubshapes() )
84 std::vector<SHAPE*> subshapes;
85 aShape->GetIndexableSubshapes( subshapes );
87 for(
SHAPE* subshape : subshapes )
94 m_shapes.push_back( aShape );
102 return m_shapes.empty();
107 return m_shapes.size();
110 void Rotate(
double aAngle,
const VECTOR2I& aCenter = { 0, 0 } )
override;
112 bool IsSolid()
const override;
114 SHAPE* UniqueSubshape()
const
116 return m_shapes.size() != 1 ? nullptr : m_shapes[0];
119 virtual bool HasIndexableSubshapes()
const override
124 virtual size_t GetIndexableSubshapeCount()
const override
126 return m_shapes.size();
129 virtual void GetIndexableSubshapes( std::vector<SHAPE*>& aSubshapes )
override
131 aSubshapes = m_shapes;
134 bool ConvertToSimplePolygon(
SHAPE_SIMPLE* aOut )
const;
139 std::vector<SHAPE*> m_shapes;
Definition shape_compound.h:37
const BOX2I BBox(int aClearance=0) const override
Compute a bounding box of the shape, with a margin of aClearance a collision.
Definition shape_compound.cpp:76
void Rotate(double aAngle, const VECTOR2I &aCenter={ 0, 0 }) override
Definition shape_compound.cpp:105
bool Collide(const SHAPE *aShape, int aClearance, VECTOR2I *aMTV) const override
Check if the boundary of shape (this) lies closer to the shape aShape than aClearance,...
Definition shape_compound.h:57
bool Collide(const SEG &aSeg, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const override
Check if the boundary of shape (this) lies closer to the segment aSeg than aClearance,...
Definition shape_compound.cpp:117
SHAPE_COMPOUND * Clone() const override
Return a dynamically allocated copy of the shape.
Definition shape_compound.cpp:70
Represent a simple polygon consisting of a zero-thickness closed chain of connected line segments.
Definition shape_simple.h:42
An abstract shape on 2D plane.
Definition shape.h:117
virtual bool Collide(const VECTOR2I &aP, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const
Check if the boundary of shape (this) lies closer to the point aP than aClearance,...
Definition shape.h:165