Public Member Functions
sal3d::Polygon2D Class Reference

Class that represents a polygon in 2D space. More...

#include <Common.hpp>

List of all members.

Public Member Functions

 Polygon2D ()
 Constructor of a polygon still without points.
 Polygon2D (const std::vector< sal3d::Point2D > &points)
 Constructor from a std::vector<sal3d::Point2D>.
 Polygon2D (const sal3d_polygon2d &polygon)
 Constructor from a C sal3d_polygon2d. Creates a new C++ object that holds it.
 Polygon2D (const Polygon2D &polygon)
 Copy constructor.
 ~Polygon2D ()
 Destructor.
sal3d_polygon2d c_polygon_2d () const
 Returns the internal C polygon2d structrue.
int numPoints () const
 Returns the number of sal3d::Point2D points the Polygon2D contains.
void appendPoint (const sal3d::Point2D &point)
 Appends a sal3d::Point2D at the end of the polygon.
void insertPoint (const sal3d::Point2D &point, int pos)
 Inserts a sal3d::Point2D at the specified location.
sal3d::Point2D removePoint ()
 Removes a sal3d::Point2D from the end of the polygon.
sal3d::Point2D removePoint (int pos)
 Removes the sal3d::Point2D at the specified location.
void removePoints ()
 Removes all sal3d::Point2D that define the Polygon2D.
void setPoints (const std::vector< sal3d::Point2D > &points)
 Sets all the points of the Polygon2D to the ones of the parameter.
std::vector< sal3d::Point2DgetPoints () const
 Returns the points that define the Polygon2D.
sal3d::Point2D getPoint (int pos) const
 Returns the sal3d::Point2D at the specified location.
bool isPointInside (const sal3d::Point2D &point) const
 Checks whether the point is inside this Polygon2D.
Polygon2Doperator= (const Polygon2D &polygon)
 Assignment operator.

Detailed Description

Class that represents a polygon in 2D space.


Constructor & Destructor Documentation

sal3d::Polygon2D::Polygon2D ( const std::vector< sal3d::Point2D > &  points) [inline, explicit]

Constructor from a std::vector<sal3d::Point2D>.

The list of points should have at least one element.

Parameters:
[in]pointsA vector of sal3d::Point2D that describe the Polygon2D.
sal3d::Polygon2D::Polygon2D ( const sal3d_polygon2d &  polygon) [inline, explicit]

Constructor from a C sal3d_polygon2d. Creates a new C++ object that holds it.

Parameters:
[in]polygonA C representation of a Polygon2D
sal3d::Polygon2D::Polygon2D ( const Polygon2D polygon) [inline]

Copy constructor.

Parameters:
[in]polygonThe Polygon2D to copy from.

Destructor.

The object is destroyed and its memory released.


Member Function Documentation

void sal3d::Polygon2D::appendPoint ( const sal3d::Point2D point) [inline]

Appends a sal3d::Point2D at the end of the polygon.

Parameters:
[in]pointPoint2D that will be added to the polygon.

References sal3d::Point2D::c_point_2d().

sal3d_polygon2d sal3d::Polygon2D::c_polygon_2d ( ) const [inline]

Returns the internal C polygon2d structrue.

Warning:
Never ever call sal3d_cop_release() with the pointer returned by this function or the application will fail.
Returns:
The sal3d's polygon2d C data structure

Referenced by sal3d::COP::cropGL().

sal3d::Point2D sal3d::Polygon2D::getPoint ( int  pos) const [inline]

Returns the sal3d::Point2D at the specified location.

Parameters:
[in]posThe position of the Point2D to retrieve
Returns:
A copy of the sal3d::Point2D in the specified position
std::vector<sal3d::Point2D> sal3d::Polygon2D::getPoints ( ) const [inline]

Returns the points that define the Polygon2D.

Returns:
A vector with the points that define the Polygon2D

References numPoints().

void sal3d::Polygon2D::insertPoint ( const sal3d::Point2D point,
int  pos 
) [inline]

Inserts a sal3d::Point2D at the specified location.

Parameters:
[in]pointPoint2D that will be added to the polygon.
[in]posThe position of the Point2D to add

References sal3d::Point2D::c_point_2d().

bool sal3d::Polygon2D::isPointInside ( const sal3d::Point2D point) const [inline]

Checks whether the point is inside this Polygon2D.

Parameters:
[in]pointTest Point2D for which we want to know whether it is inside this Polygon2D
Returns:
True if the point is inside, false otherwise.

References sal3d::Point2D::c_point_2d().

int sal3d::Polygon2D::numPoints ( ) const [inline]

Returns the number of sal3d::Point2D points the Polygon2D contains.

Returns:
The number of points this polygon contains.

Referenced by getPoints().

Polygon2D& sal3d::Polygon2D::operator= ( const Polygon2D polygon) [inline]

Assignment operator.

Parameters:
[in]polygonThe Polygon2D to copy to this object.
Returns:
The reference to this object.

Removes a sal3d::Point2D from the end of the polygon.

Returns:
The removed sal3d::Point2D

Removes the sal3d::Point2D at the specified location.

Parameters:
[in]posThe position of the Point2D to remove
Returns:
The removed sal3d::Point2D
void sal3d::Polygon2D::setPoints ( const std::vector< sal3d::Point2D > &  points) [inline]

Sets all the points of the Polygon2D to the ones of the parameter.

Parameters:
[in]pointsThe points that will define the Polygon2D

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