Horizon
Loading...
Searching...
No Matches
Public Member Functions | List of all members
SHAPE_RECT Class Reference
Inheritance diagram for SHAPE_RECT:
SHAPE SHAPE_BASE

Public Member Functions

 SHAPE_RECT ()
 Create an empty (0-sized) rectangle.
 
 SHAPE_RECT (int aX0, int aY0, int aW, int aH)
 Create a rectangle defined by top-left corner (aX0, aY0), width aW and height aH.
 
 SHAPE_RECT (const VECTOR2I &aP0, int aW, int aH)
 Create a rectangle defined by top-left corner aP0, width aW and height aH.
 
 SHAPE_RECT (const SHAPE_RECT &aOther)
 
SHAPEClone () const override
 Return a dynamically allocated copy of the shape.
 
const BOX2I BBox (int aClearance=0) const override
 Compute a bounding box of the shape, with a margin of aClearance a collision.
 
int Diagonal () const
 Return length of the diagonal of the rectangle.
 
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, indicating a collision.
 
bool Collide (const SHAPE *aShape, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const override
 
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 point aP than aClearance, indicating a collision.
 
const VECTOR2IGetPosition () const
 
const VECTOR2I GetSize () const
 
const int GetWidth () const
 
const int GetHeight () const
 
void Move (const VECTOR2I &aVector) override
 
void Rotate (double aAngle, const VECTOR2I &aCenter={ 0, 0 }) override
 This function has limited utility for SHAPE_RECT as non-cartesian rotations will distort the rectangle.
 
bool IsSolid () const override
 
const SHAPE_LINE_CHAIN Outline () const
 
virtual const std::string Format () const override
 
- Public Member Functions inherited from SHAPE
 SHAPE (SHAPE_TYPE aType)
 Create an empty shape of type aType.
 
bool IsNull () const
 Return true if the shape is a null shape.
 
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, indicating a collision.
 
virtual VECTOR2I Centre () const
 Compute a center-of-mass of the shape.
 
virtual bool Parse (std::stringstream &aStream)
 
- Public Member Functions inherited from SHAPE_BASE
 SHAPE_BASE (SHAPE_TYPE aType)
 Create an empty shape of type aType.
 
SHAPE_TYPE Type () const
 Return the type of the shape.
 
virtual bool HasIndexableSubshapes () const
 
virtual size_t GetIndexableSubshapeCount () const
 
virtual void GetIndexableSubshapes (std::vector< SHAPE * > &aSubshapes)
 

Additional Inherited Members

- Static Public Attributes inherited from SHAPE
static const int MIN_PRECISION_IU = 4
 This is the minimum precision for all the points in a shape.
 
- Protected Types inherited from SHAPE
typedef VECTOR2I::extended_type ecoord
 
- Protected Attributes inherited from SHAPE_BASE
SHAPE_TYPE m_type
 < type of our shape
 

Member Function Documentation

◆ BBox()

const BOX2I SHAPE_RECT::BBox ( int  aClearance = 0) const
inlineoverridevirtual

Compute a bounding box of the shape, with a margin of aClearance a collision.

Parameters
aClearancehow much the bounding box is expanded wrs to the minimum enclosing rectangle for the shape.
Returns
the bounding box.

Implements SHAPE.

◆ Clone()

SHAPE * SHAPE_RECT::Clone ( ) const
inlineoverridevirtual

Return a dynamically allocated copy of the shape.

Return values
copyof the shape

Reimplemented from SHAPE.

◆ Collide() [1/3]

bool SHAPE_RECT::Collide ( const SEG aSeg,
int  aClearance = 0,
int *  aActual = nullptr,
VECTOR2I aLocation = nullptr 
) const
overridevirtual

Check if the boundary of shape (this) lies closer to the point aP than aClearance, indicating a collision.

Parameters
aActual[out] an optional pointer to an int to store the actual distance in the event of a collision.
aLocation[out] an option pointer to a point to store a nearby location in the event of a collision.
Returns
true, if there is a collision.

Implements SHAPE.

◆ Collide() [2/3]

bool SHAPE_RECT::Collide ( const SHAPE aShape,
int  aClearance,
VECTOR2I aMTV 
) const
inlineoverridevirtual

Check if the boundary of shape (this) lies closer to the shape aShape than aClearance, indicating a collision.

Parameters
aShapeshape to check collision against
aClearanceminimum clearance
aMTVminimum translation vector
aActual[out] an optional pointer to an int to store the actual distance in the event of a collision.
aLocation[out] an option pointer to a point to store a nearby location in the event of a collision.
Returns
true, if there is a collision.

Reimplemented from SHAPE.

◆ Collide() [3/3]

bool SHAPE_RECT::Collide ( const SHAPE aShape,
int  aClearance = 0,
int *  aActual = nullptr,
VECTOR2I aLocation = nullptr 
) const
inlineoverridevirtual

Reimplemented from SHAPE.

◆ Diagonal()

int SHAPE_RECT::Diagonal ( ) const
inline

Return length of the diagonal of the rectangle.

Returns
diagonal length

◆ Format()

const std::string SHAPE_RECT::Format ( ) const
overridevirtual

Reimplemented from SHAPE.

◆ GetHeight()

const int SHAPE_RECT::GetHeight ( ) const
inline
Returns
the height of the rectangle.

◆ GetPosition()

const VECTOR2I & SHAPE_RECT::GetPosition ( ) const
inline
Returns
the top left corner of the rectangle.

◆ GetSize()

const VECTOR2I SHAPE_RECT::GetSize ( ) const
inline
Returns
the size of the rectangle.

◆ GetWidth()

const int SHAPE_RECT::GetWidth ( ) const
inline
Returns
the width of the rectangle.

◆ IsSolid()

bool SHAPE_RECT::IsSolid ( ) const
inlineoverridevirtual

Implements SHAPE.

◆ Move()

void SHAPE_RECT::Move ( const VECTOR2I aVector)
inlineoverridevirtual

Implements SHAPE.

◆ Rotate()

void SHAPE_RECT::Rotate ( double  aAngle,
const VECTOR2I aCenter = { 0, 0 } 
)
inlineoverridevirtual

This function has limited utility for SHAPE_RECT as non-cartesian rotations will distort the rectangle.

If you might need to handle non-90ยบ rotations then the SHAPE_RECT should first be converted to a SHAPE_SIMPLE which can then be free-rotated.

Implements SHAPE.


The documentation for this class was generated from the following files: