ScummVM API documentation
Sword25::Polygon Class Reference

Eine Polygonklasse. More...

#include <polygon.h>

Inheritance diagram for Sword25::Polygon:
Sword25::Persistable

Public Member Functions

 Polygon ()
 
 Polygon (const Polygon &other)
 
 Polygon (InputPersistenceBlock &reader)
 
 Polygon (int vertexCount_, const Vertex *vertices_)
 
 ~Polygon () override
 
bool init (int vertexCount_, const Vertex *vertices_)
 
bool isCW () const
 
bool isCCW () const
 
bool isPointInPolygon (const Vertex &vertex, bool borderBelongsToPolygon=true) const
 
bool isPointInPolygon (int x, int y, bool borderBelongsToPolygon=true) const
 
Vertex getCentroid () const
 
bool isLineInterior (const Vertex &a, const Vertex &b) const
 
bool isLineExterior (const Vertex &a, const Vertex &b) const
 
void ensureCWOrder ()
 
void ensureCCWOrder ()
 
void reverseVertexOrder ()
 
void operator+= (const Vertex &delta)
 
bool persist (OutputPersistenceBlock &writer) override
 
bool unpersist (InputPersistenceBlock &reader) override
 
Polygonoperator= (const Polygon &p)
 

Public Attributes

int32 vertexCount
 Specifies the number of Vertecies in the Vertecies array.
 
Vertexvertices
 COntains the Vertecies of the polygon.
 

Detailed Description

Eine Polygonklasse.

Constructor & Destructor Documentation

◆ Polygon() [1/4]

Sword25::Polygon::Polygon ( )

Creates an object of type #BS_Polygon, containing 0 Vertecies.

With the method Init(), Vertices can be added in later

◆ Polygon() [2/4]

Sword25::Polygon::Polygon ( const Polygon other)

Copy constructor

◆ Polygon() [3/4]

Sword25::Polygon::Polygon ( InputPersistenceBlock reader)

Creates a polygon using persisted data

◆ Polygon() [4/4]

Sword25::Polygon::Polygon ( int  vertexCount_,
const Vertex vertices_ 
)

Creaes an object of type #BS_Polygon, and assigns Vertices to it

Parameters
VertexCountThe number of vertices being passed
VerteciesAn array of BS_Vertex objects representing the vertices in the polygon.
Remarks
The Vertecies that define a polygon must not have any self-intersections. If the polygon does have self-intersections, then an empty polygon object is created.

◆ ~Polygon()

Sword25::Polygon::~Polygon ( )
override

Deletes the BS_Polygon object

Member Function Documentation

◆ init()

bool Sword25::Polygon::init ( int  vertexCount_,
const Vertex vertices_ 
)

Initializes the BS_Polygon with a list of Vertecies.

The Vertices need to define a polygon must not have self-intersections. If a polygon already has verticies, this will re-initialize it with the new list.

Parameters
VertexCountThe number of vertices being passed
VerteciesAn array of BS_Vertex objects representing the vertices in the polygon.
Returns
Returns false if the Vertecies have self-intersections. In this case, the object is not initialized.

◆ isCW()

bool Sword25::Polygon::isCW ( ) const

Checks whether the Vertecies of the polygon are arranged in a clockwise direction.

Returns
Returns true if the Vertecies of the polygon are arranged clockwise or co-planar. Returns false if the Vertecies of the polygon are arrange counter-clockwise.
Remarks
This method only returns a meaningful result if the polygon has at least three Vertecies.

◆ isCCW()

bool Sword25::Polygon::isCCW ( ) const

Checks whether the Vertices of the polygon are arranged in a counter-clockwise direction.

Returns
Returns true if the Vertecies of the polygon are arranged counter-clockwise. Returns false if the Vertecies of the polygon are arranged clockwise or co-planar.
Remarks
This method only returns a meaningful result if the polygon has at least three Vertecies.

◆ isPointInPolygon() [1/2]

bool Sword25::Polygon::isPointInPolygon ( const Vertex vertex,
bool  borderBelongsToPolygon = true 
) const

Checks whether a point is inside the polygon

Parameters
VertexA Vertex with the co-ordinates of the point to be tested.
BorderBelongsToPolygonSpecifies whether the edge of the polygon should be considered
Returns
Returns true if the point is inside the polygon, false if it is outside.

◆ isPointInPolygon() [2/2]

bool Sword25::Polygon::isPointInPolygon ( int  x,
int  y,
bool  borderBelongsToPolygon = true 
) const

Checks whether a point is inside the polygon

Parameters
XThe X position of the point
YThe Y position of the point
BorderBelongsToPolygonSpecifies whether the edge of the polygon should be considered
Returns
Returns true if the point is inside the polygon, false if it is outside.

◆ getCentroid()

Vertex Sword25::Polygon::getCentroid ( ) const

Returns the focus/centroid of the polygon

◆ ensureCWOrder()

void Sword25::Polygon::ensureCWOrder ( )

Ensures that the Vertecies of the polygon are arranged in a clockwise direction

◆ ensureCCWOrder()

void Sword25::Polygon::ensureCCWOrder ( )

Ensures that the Vertecies of the polygon are arranged in a counter-clockwise direction

◆ reverseVertexOrder()

void Sword25::Polygon::reverseVertexOrder ( )

Reverses the Vertecies order.

◆ operator+=()

void Sword25::Polygon::operator+= ( const Vertex delta)

Moves the polygon.

Parameters
DeltaThe vertex around the polygon to be moved.

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