OSDL::Video::TwoDimensional::Polygon Class Reference

Polygons are defined as line segments passing through a suite of 2D points and enclosing a surface, since the last vector points towards the first. More...

#include <OSDLPolygon.h>

Collaboration diagram for OSDL::Video::TwoDimensional::Polygon:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 Polygon (listPoint2D &summits, bool listOwner=false)
 Creates a polygon from a suite of summit vertices.
virtual ~Polygon () throw ()
 Basic virtual destructor.
virtual bool draw (Surface &targetSurface, Pixels::ColorDefinition colorDef=Pixels::White, bool filled=true) const
 Draws the polygon on specified surface, with specified color.
virtual listPoint2DgetPoints () const
 Returns the points that this polygon gathered.
virtual void setPoints (listPoint2D &newList)
 Sets the vertex list for this polygon.
virtual bool isListOwner () const
 Tells whether the polygon owns its points.
virtual const std::string toString (Ceylan::VerbosityLevels level=Ceylan::high) const
 Returns an user-friendly description of the state of this object.

Static Public Member Functions

static PolygonCreateFlakeBranch (Length length=200, Length thickness=20, Ceylan::Maths::AngleInDegrees childAngle=50, Ceylan::Maths::Ratio branchingHeightRatio=0.7, Ceylan::Maths::Ratio scale=0.3)
 Creates a polygon whose shape is a snow flake, and which has no local referential registered.
static listPoint2DDuplicate (const listPoint2D &source)
 Duplicates specified list of points: returns another list containing clones of each points in source.
static void Delete (listPoint2D &listToBeDeleted)
 Deletes specified list of points, including the points themselves.
static listPoint2DAppend (listPoint2D &toBeAugmented, const listPoint2D &toAppend)
 Appends a shallow (not deep) copy of the toAppend list to the toBeAugmented list.
static listPoint2DApply (const Ceylan::Maths::Linear::HomogeneousMatrix3 &transformation, listPoint2D &sourceList)
 Applies transformation, specified as a 3x3 homogeneous matrix, to each point of sourceList.

Private Member Functions

 Polygon (const Polygon &source)
 Copy constructor made private to ensure that it will be never called.
Polygonoperator= (const Polygon &source)
 Assignment operator made private to ensure that it will be never called.

Private Attributes

listPoint2D_summits
 List of the summits of the polygon.
bool _listOwner
 Tells whether the polygon owns the lists and the points that are stored in it.

Detailed Description

Polygons are defined as line segments passing through a suite of 2D points and enclosing a surface, since the last vector points towards the first.

All these vectors are to be defined in the Polygon's own 2D referential.

Note:
Polygons use pointers to Point2D so that these points can be shared by several polygons, for example in the case of a vertex being common to three edges, hence multiple polygons. Therefore points, unless specified otherwise (see pointOwner) are not owned by a polygon referencing them, and only their particular list specified for a polygon is deallocated when the polygon is itself deallocated. The points themselves are left as they are.

Definition at line 385 of file OSDLPolygon.h.


Constructor & Destructor Documentation

Polygon::Polygon ( listPoint2D summits,
bool  listOwner = false 
) [explicit]

Creates a polygon from a suite of summit vertices.

Parameters:
summits the input list of summits for this polygon.
listOwner tells whether this polygon owns the specified point list and the points in it (and therefore will deallocate them) or not (in this case, neither the list object nor the points will be deallocated).
Note:
Never put twice the same point object in the list if the polygon is going to own its points, since the duplicated points would be deleted twice, which results usually in a segmentation fault.

Definition at line 493 of file OSDLPolygon.cc.

Polygon::~Polygon (  )  throw () [virtual]

Basic virtual destructor.

Definition at line 503 of file OSDLPolygon.cc.

References _listOwner, and _summits.

OSDL::Video::TwoDimensional::Polygon::Polygon ( const Polygon source  )  [explicit, private]

Copy constructor made private to ensure that it will be never called.

The compiler should complain whenever this undefined constructor is called, implicitly or not.


Member Function Documentation

listPoint2D & Polygon::Append ( listPoint2D toBeAugmented,
const listPoint2D toAppend 
) [static]

Appends a shallow (not deep) copy of the toAppend list to the toBeAugmented list.

Note:
the toBeAugmented takes ownership of the points of toAppend, if toBeAugmented is a point owner list.
Returns:
toBeAugmented after it has been augmented by toAppend's points. It is the same list as specified in argument, but modified: no copy is made. Hence the returned value can be ignored, it is just convenient when chaining functions.

Definition at line 810 of file OSDLPolygon.cc.

static listPoint2D& OSDL::Video::TwoDimensional::Polygon::Apply ( const Ceylan::Maths::Linear::HomogeneousMatrix3 &  transformation,
listPoint2D sourceList 
) [static]

Applies transformation, specified as a 3x3 homogeneous matrix, to each point of sourceList.

Parameters:
transformation the 2D geometrical transformation, specified as a 3x3 homogeneous matrix.
sourceList the list of points to transform. It will be updated thanks to the transformation.
Returns:
sourceList after all its points have been transformed. It is the same list as specified in argument, but modified: no copy is made. Hence the returned value can be ignored, it is just convenient when chaining functions.

Referenced by draw().

static Polygon& OSDL::Video::TwoDimensional::Polygon::CreateFlakeBranch ( Length  length = 200,
Length  thickness = 20,
Ceylan::Maths::AngleInDegrees  childAngle = 50,
Ceylan::Maths::Ratio  branchingHeightRatio = 0.7,
Ceylan::Maths::Ratio  scale = 0.3 
) [static]

Creates a polygon whose shape is a snow flake, and which has no local referential registered.

Note:
The caller should deallocate this polygon when finished with it.
Parameters:
length defines the height of the main branch of this flake.
thickness defines the width of the main branch of this flake.
childAngle defines the angle, in degrees, between the main branch and the second branch.
branchingHeightRatio tells at which height of the main branch the second shall begin.
scale defines the ratio of the second branch relatively to the main one.
Returns:
A polygon which does not own its points, so that they can be freely used thanks to getPoints(). Hence the caller will have to deallocate them explicitly (deallocating the returned polygon will not be enough).
See also:
PolygonSet::CreateFlake
void Polygon::Delete ( listPoint2D listToBeDeleted  )  [static]

Deletes specified list of points, including the points themselves.

Definition at line 793 of file OSDLPolygon.cc.

Referenced by setPoints(), and OSDL::Video::TwoDimensional::PolygonSet::~PolygonSet().

bool Polygon::draw ( Surface targetSurface,
Pixels::ColorDefinition  colorDef = Pixels::White,
bool  filled = true 
) const [virtual]

Draws the polygon on specified surface, with specified color.

The polygon can be rendered after transformation with the embedded matrix, the referential of this Locatable.

In all cases the place where to render the polygon on surface is determined by this inner matrix.

Parameters:
targetSurface the surface to draw to.
colorDef the polygon color.
filled tells whether the polygon should be filled.
Returns:
true iff rendering succeeded.

Definition at line 534 of file OSDLPolygon.cc.

References _summits, Apply(), OSDL::Video::TwoDimensional::drawPolygon(), and Duplicate().

listPoint2D & Polygon::Duplicate ( const listPoint2D source  )  [static]

Duplicates specified list of points: returns another list containing clones of each points in source.

Returns:
The duplicated list of points.

Definition at line 774 of file OSDLPolygon.cc.

Referenced by draw().

listPoint2D & Polygon::getPoints (  )  const [virtual]

Returns the points that this polygon gathered.

Note:
What can be done with these points depends on whether the polygon owns its points or not.

Definition at line 564 of file OSDLPolygon.cc.

References _summits.

Referenced by OSDL::Video::TwoDimensional::PolygonSet::addPointsOf().

bool Polygon::isListOwner (  )  const [virtual]

Tells whether the polygon owns its points.

Definition at line 590 of file OSDLPolygon.cc.

References _listOwner.

Referenced by OSDL::Video::TwoDimensional::PolygonSet::addPointsOf().

Polygon& OSDL::Video::TwoDimensional::Polygon::operator= ( const Polygon source  )  [private]

Assignment operator made private to ensure that it will be never called.

The compiler should complain whenever this undefined operator is called, implicitly or not.

void Polygon::setPoints ( listPoint2D newList  )  [virtual]

Sets the vertex list for this polygon.

Parameters:
newList the new list of vertices.

Any pre-existing owned list will be deallocated first.

Definition at line 573 of file OSDLPolygon.cc.

References _listOwner, _summits, and Delete().

const string Polygon::toString ( Ceylan::VerbosityLevels  level = Ceylan::high  )  const [virtual]

Returns an user-friendly description of the state of this object.

Parameters:
level the requested verbosity level.
Note:
Text output format is determined from overall settings.
See also:
Ceylan::TextDisplayable

Definition at line 599 of file OSDLPolygon.cc.

References _summits, generate_master_palette::count, and OSDL::Video::Pixels::toString().


Member Data Documentation

Tells whether the polygon owns the lists and the points that are stored in it.

Definition at line 635 of file OSDLPolygon.h.

Referenced by isListOwner(), setPoints(), and ~Polygon().

List of the summits of the polygon.

Definition at line 624 of file OSDLPolygon.h.

Referenced by draw(), getPoints(), setPoints(), toString(), and ~Polygon().


The documentation for this class was generated from the following files:
Generated on Mon Nov 29 14:06:19 2010 for OSDL by  doxygen 1.6.3