geometry: placeholder method for converting compounds to simple polygons [wip]

This commit is contained in:
Tomasz Wlostowski 2020-10-07 15:13:48 +02:00
parent 30f8cc1346
commit 7ffef32ea0
1 changed files with 64 additions and 62 deletions

View File

@ -30,93 +30,95 @@
#include <list> #include <list>
#include <vector> #include <vector>
class SHAPE_SIMPLE;
class SHAPE_COMPOUND : public SHAPE class SHAPE_COMPOUND : public SHAPE
{ {
public: public:
SHAPE_COMPOUND() : SHAPE_COMPOUND() : SHAPE( SH_COMPOUND ), m_dirty( true )
SHAPE( SH_COMPOUND ), {
m_dirty( true ) }
{}
SHAPE_COMPOUND( const std::vector<SHAPE*>& aShapes ); SHAPE_COMPOUND( const std::vector<SHAPE*>& aShapes );
SHAPE_COMPOUND( const SHAPE_COMPOUND& aOther );
~SHAPE_COMPOUND();
SHAPE_COMPOUND* Clone() const override;
const std::string Format() const override;
bool Collide( const SEG& aSeg, int aClearance = 0, int* aActual = nullptr, SHAPE_COMPOUND( const SHAPE_COMPOUND& aOther );
VECTOR2I* aLocation = nullptr ) const override; ~SHAPE_COMPOUND();
bool Collide( const SHAPE* aShape, int aClearance, VECTOR2I* aMTV ) const override SHAPE_COMPOUND* Clone() const override;
{ const std::string Format() const override;
return SHAPE::Collide( aShape, aClearance, aMTV );
}
bool Collide( const SHAPE* aShape, int aClearance = 0, int* aActual = nullptr, bool Collide( const SEG& aSeg, int aClearance = 0, int* aActual = nullptr,
VECTOR2I* aLocation = nullptr ) const override VECTOR2I* aLocation = nullptr ) const override;
{
return SHAPE::Collide( aShape, aClearance, aActual, aLocation );
}
const std::vector<SHAPE*>& Shapes() const bool Collide( const SHAPE* aShape, int aClearance, VECTOR2I* aMTV ) const override
{ {
return m_shapes; return SHAPE::Collide( aShape, aClearance, aMTV );
} }
const BOX2I BBox( int aClearance = 0 ) const override; bool Collide( const SHAPE* aShape, int aClearance = 0, int* aActual = nullptr,
VECTOR2I* aLocation = nullptr ) const override
{
return SHAPE::Collide( aShape, aClearance, aActual, aLocation );
}
int Distance( const SEG& aSeg ) const; const std::vector<SHAPE*>& Shapes() const
{
return m_shapes;
}
void Move ( const VECTOR2I& aVector ) override; const BOX2I BBox( int aClearance = 0 ) const override;
void AddShape( SHAPE* aShape )
{
m_shapes.push_back( aShape );
m_dirty = true;
}
bool Empty() const int Distance( const SEG& aSeg ) const;
{
return m_shapes.empty();
}
int Size() const void Move( const VECTOR2I& aVector ) override;
{
return m_shapes.size(); void AddShape( SHAPE* aShape )
} {
m_shapes.push_back( aShape );
m_dirty = true;
}
bool Empty() const
{
return m_shapes.empty();
}
int Size() const
{
return m_shapes.size();
}
void Rotate( double aAngle, const VECTOR2I& aCenter = { 0, 0 } ) override; void Rotate( double aAngle, const VECTOR2I& aCenter = { 0, 0 } ) override;
bool IsSolid() const override; bool IsSolid() const override;
SHAPE* UniqueSubshape() const SHAPE* UniqueSubshape() const
{ {
return m_shapes.size() != 1 ? nullptr : m_shapes[0]; return m_shapes.size() != 1 ? nullptr : m_shapes[0];
} }
virtual bool HasIndexableSubshapes() const override virtual bool HasIndexableSubshapes() const override
{ {
return true; return true;
} }
virtual size_t GetIndexableSubshapeCount() const override virtual size_t GetIndexableSubshapeCount() const override
{ {
return m_shapes.size(); return m_shapes.size();
} }
virtual void GetIndexableSubshapes( std::vector<SHAPE*>& aSubshapes ) override virtual void GetIndexableSubshapes( std::vector<SHAPE*>& aSubshapes ) override
{ {
aSubshapes = m_shapes; aSubshapes = m_shapes;
} }
private: bool ConvertToSimplePolygon( SHAPE_SIMPLE* aOut ) const;
BOX2I m_cachedBBox; private:
bool m_dirty; BOX2I m_cachedBBox;
std::vector<SHAPE*> m_shapes; bool m_dirty;
std::vector<SHAPE*> m_shapes;
}; };
#endif // __SHAPE_COMPOUND_H #endif // __SHAPE_COMPOUND_H