PPolygoni Class Reference

Detailed Description

The PPolygoni class represents a 2D closed polygon with 32-bit int coordinates.

Definition at line 30 of file PPolygoni.h.

#include <PPolygoni.h>

Constructor & Destructor Documentation

◆ PPolygoni() [1/3]

PPolygoni::PPolygoni ( const std::vector< PPoint2Di > &  points = std::vector< PPoint2Di >())

Constructs a polygon from the specified list of 2D-points.

◆ PPolygoni() [2/3]

PPolygoni::PPolygoni ( const PRectanglei r)

Constructs a polygon from the specified rectangle.

◆ PPolygoni() [3/3]

PPolygoni::PPolygoni ( const PPolygoni other)

Constructs a shared copy of other.

◆ ~PPolygoni()

virtual PPolygoni::~PPolygoni ( )
virtual

Destroys this object.

Member Function Documentation

◆ AddPoint() [1/2]

PPolygoni& PPolygoni::AddPoint ( papillon::int32  x,
papillon::int32  y,
papillon::int32  index = -1 
)

Inserts a point to this polygon at the specified index.

If index is -1 or invalid, then add the point at the end.

AddPoint() can be chained.

◆ AddPoint() [2/2]

PPolygoni& PPolygoni::AddPoint ( const PPoint2Di pt,
papillon::int32  index = -1 
)

Inserts a point to this polygon at the specified index.

If index is -1 or invalid, then add the point at the end.

AddPoint() can be chained.

◆ Clear()

void PPolygoni::Clear ( )

Removes all points of this polygon.

◆ GetBoundingRectangle()

PRectanglei PPolygoni::GetBoundingRectangle ( ) const

Returns the bounding rectangle of this polygon.

◆ GetConvexHull()

PPolygoni PPolygoni::GetConvexHull ( ) const

Returns the convex hull of this polygon.

If the polygon is convex, then the convex hull is the same polygon.

◆ GetFirstPoint()

PPoint2Di PPolygoni::GetFirstPoint ( ) const

Returns the first point of this polygon of PPoint2Di(0,0) if the polygon is empty.

◆ GetLastPoint()

PPoint2Di PPolygoni::GetLastPoint ( ) const

Returns the last point of this polygon of PPoint2Di(0,0) if the polygon is empty.

◆ GetPoint()

PPoint2Di PPolygoni::GetPoint ( papillon::int32  index) const

Returns the point with the specified index.

Returns PPoint2Di(0,0) if the index is invalid.

◆ Intersected()

PPolygoni PPolygoni::Intersected ( const PPolygoni other) const

Returns a polygon which is the intersection of this polygon and other.

◆ IsEmpty()

bool PPolygoni::IsEmpty ( ) const

Returns true if this polygon has no points, false otherwise.

◆ operator=()

PPolygoni& PPolygoni::operator= ( const PPolygoni other)

Performs a shared copy of other to this object.

◆ SetPoint()

void PPolygoni::SetPoint ( papillon::int32  index,
const PPoint2Di pt 
)

Sets the coordinates of the point with the specified index.

Do nothing if the index is invalid.

◆ Size()

papillon::int32 PPolygoni::Size ( ) const

Returns the number of points in this polygon.

◆ United()

PPolygoni PPolygoni::United ( const PPolygoni other) const

Returns a polygon which is the union of this polygon and other.