libs/kimath: implement BBox() and Size() methods in SHAPE_COMPOUND
This commit is contained in:
parent
c2b9db293f
commit
32bd31a1b8
|
@ -69,11 +69,7 @@ class SHAPE_COMPOUND : public SHAPE
|
|||
|
||||
int Distance( const SEG& aSeg ) const;
|
||||
|
||||
void Move ( const VECTOR2I& aVector ) override
|
||||
{
|
||||
for( auto& item : m_shapes )
|
||||
item->Move( aVector );
|
||||
}
|
||||
void Move ( const VECTOR2I& aVector ) override;
|
||||
|
||||
void AddShape( SHAPE* aShape )
|
||||
{
|
||||
|
@ -86,10 +82,20 @@ class SHAPE_COMPOUND : public SHAPE
|
|||
return m_shapes.empty();
|
||||
}
|
||||
|
||||
int Size() const
|
||||
{
|
||||
return m_shapes.size();
|
||||
}
|
||||
|
||||
void Rotate( double aAngle, const VECTOR2I& aCenter = { 0, 0 } ) override;
|
||||
|
||||
bool IsSolid() const override;
|
||||
|
||||
SHAPE* UniqueSubshape() const
|
||||
{
|
||||
return m_shapes.size() != 1 ? nullptr : m_shapes[0];
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
BOX2I m_cachedBBox;
|
||||
|
|
|
@ -72,18 +72,35 @@ SHAPE_COMPOUND* SHAPE_COMPOUND::Clone() const
|
|||
|
||||
const BOX2I SHAPE_COMPOUND::BBox( int aClearance ) const
|
||||
{
|
||||
BOX2I bb;
|
||||
|
||||
if ( m_shapes.size() < 1 )
|
||||
return bb;
|
||||
|
||||
bb = m_shapes[0]->BBox();
|
||||
|
||||
for( int i = 1; i < m_shapes.size(); i++ )
|
||||
bb.Merge( m_shapes[i]->BBox() );
|
||||
|
||||
return bb;
|
||||
}
|
||||
|
||||
void SHAPE_COMPOUND::Move ( const VECTOR2I& aVector )
|
||||
{
|
||||
for( auto& item : m_shapes )
|
||||
item->Move( aVector );
|
||||
}
|
||||
|
||||
|
||||
int SHAPE_COMPOUND::Distance( const SEG& aSeg ) const
|
||||
{
|
||||
|
||||
assert(false);
|
||||
}
|
||||
|
||||
|
||||
void SHAPE_COMPOUND::Rotate( double aAngle, const VECTOR2I& aCenter )
|
||||
{
|
||||
assert( false );
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue