Horizon
Public Member Functions | Protected Types | Protected Attributes | List of all members
SHAPE Class Referenceabstract

Class SHAPE. More...

#include <shape.h>

Inheritance diagram for SHAPE:
SHAPE_ARC SHAPE_CIRCLE SHAPE_LINE_CHAIN SHAPE_RECT SHAPE_SEGMENT SHAPE_SIMPLE

Public Member Functions

 SHAPE (SHAPE_TYPE aType)
 Constructor. More...
 
SHAPE_TYPE Type () const
 Function Type() More...
 
virtual SHAPEClone () const
 Function Clone() More...
 
virtual bool Collide (const VECTOR2I &aP, int aClearance=0) const
 Function Collide() More...
 
virtual bool Collide (const SHAPE *aShape, int aClearance, VECTOR2I &aMTV) const
 Function Collide() More...
 
virtual bool Collide (const SHAPE *aShape, int aClearance=0) const
 
virtual bool Collide (const SEG &aSeg, int aClearance=0) const =0
 Function Collide() More...
 
virtual const BOX2I BBox (int aClearance=0) const =0
 Function BBox() More...
 
virtual VECTOR2I Centre () const
 Function Centre() More...
 
virtual void Move (const VECTOR2I &aVector)=0
 
virtual bool IsSolid () const =0
 
virtual bool Parse (std::stringstream &aStream)
 
virtual const std::string Format () const
 

Protected Types

typedef VECTOR2I::extended_type ecoord
 

Protected Attributes

SHAPE_TYPE m_type
 

type of our shape


 

Detailed Description

Class SHAPE.

Represents an abstract shape on 2D plane.

Constructor & Destructor Documentation

◆ SHAPE()

SHAPE::SHAPE ( SHAPE_TYPE  aType)
inline

Constructor.

Creates an empty shape of type aType

Member Function Documentation

◆ BBox()

virtual const BOX2I SHAPE::BBox ( int  aClearance = 0) const
pure virtual

Function BBox()

Computes 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.

Implemented in SHAPE_SIMPLE, SHAPE_SEGMENT, SHAPE_RECT, SHAPE_LINE_CHAIN, SHAPE_CIRCLE, and SHAPE_ARC.

◆ Centre()

virtual VECTOR2I SHAPE::Centre ( ) const
inlinevirtual

Function Centre()

Computes a center-of-mass of the shape

Returns
the center-of-mass point

◆ Clone()

virtual SHAPE* SHAPE::Clone ( ) const
inlinevirtual

Function Clone()

Returns a dynamically allocated copy of the shape

Return values
copyof the shape

Reimplemented in SHAPE_SIMPLE, SHAPE_SEGMENT, SHAPE_RECT, SHAPE_LINE_CHAIN, SHAPE_CIRCLE, and SHAPE_ARC.

◆ Collide() [1/3]

virtual bool SHAPE::Collide ( const SEG aSeg,
int  aClearance = 0 
) const
pure virtual

Function Collide()

Checks if the boundary of shape (this) lies closer to the segment aSeg than aClearance, indicating a collision.

Returns
true, if there is a collision.

Implemented in SHAPE_SIMPLE, SHAPE_SEGMENT, SHAPE_RECT, SHAPE_LINE_CHAIN, SHAPE_CIRCLE, and SHAPE_ARC.

◆ Collide() [2/3]

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

Function Collide()

Checks 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
Returns
true, if there is a collision.

◆ Collide() [3/3]

virtual bool SHAPE::Collide ( const VECTOR2I aP,
int  aClearance = 0 
) const
inlinevirtual

Function Collide()

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

Returns
true, if there is a collision.

Reimplemented in SHAPE_SEGMENT, SHAPE_LINE_CHAIN, and SHAPE_ARC.

◆ Type()

SHAPE_TYPE SHAPE::Type ( ) const
inline

Function Type()

Returns the type of the shape.

Return values
thetype

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