# Home    # nevrax.com   
Nevrax
Nevrax.org
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
Docs
 
Documentation  
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  

NLMISC::CPolygon2D Class Reference

A 2d convex polygon. More...

#include <polygon.h>

List of all members.

Public Types

typedef std::vector< CVector2fTVec2fVect
typedef std::pair< sint, sintTRaster
typedef std::vector< TRasterTRasterVect

Public Methods

 CPolygon2D ()
 default ctor. More...

 CPolygon2D (const CPolygon &src, const CMatrix &projMat=CMatrix::Identity)
 Build a 2D polygon from this 3D polygon, by using the given projection matrix The x and y components of projected vertices are used to create the 2D polygon. More...

 CPolygon2D (const CTriangle &tri, const CMatrix &projMat=CMatrix::Identity)
 Build a 2D polygon from the given triangle, by using the given projection matrix The x and y components of projected vertices are used to create the 2D polygon. More...

bool isConvex ()
 Check wether this polygon is convex;. More...

void buildConvexHull (CPolygon2D &dest) const
 Build a convex hull from this polygon. More...

void getBestTriplet (uint &index0, uint &index1, uint &index2)
 get the best triplet of vector. e.g the triplet that has the best surface. More...

void serial (NLMISC::IStream &f) throw (NLMISC::EStream)
 Serial this polygon. More...

void computeBorders (TRasterVect &borders, sint &minimumY)
 Compute the borders of this poly with sub-pixel accuracy. More...

bool intersect (const CPolygon2D &other) const
 Test wether this polygon intersect another convex polygon. Currently not optimized. More...

bool contains (const CVector2f &p) const
 Check wether a point is contained by this poly. More...

bool getNonNullSeg (uint &seg) const
 Get the index of a segment of this poly that is a non null segment. More...

void getLineEquation (uint index, float &a, float &b, float &c) const
 Get a line equation of the seg starting at the given index. More...


Public Attributes

TVec2fVect Vertices

Private Methods

float sumDPAgainstLine (float a, float b, float c) const
 Sum the dot product of this poly vertices against a plane. More...

const CVector2fgetSegRef0 (uint index) const
 Get ref to the first vertex that start at index. More...

const CVector2fgetSegRef1 (uint index) const


Detailed Description

A 2d convex polygon.

Definition at line 126 of file polygon.h.


Member Typedef Documentation

typedef std::pair<sint, sint> NLMISC::CPolygon2D::TRaster
 

Definition at line 160 of file polygon.h.

typedef std::vector<TRaster> NLMISC::CPolygon2D::TRasterVect
 

Definition at line 161 of file polygon.h.

Referenced by NL3D::CWaterRenderObs::traverse.

typedef std::vector<CVector2f> NLMISC::CPolygon2D::TVec2fVect
 

Definition at line 129 of file polygon.h.

Referenced by computeBorders.


Constructor & Destructor Documentation

NLMISC::CPolygon2D::CPolygon2D   [inline]
 

default ctor.

Definition at line 133 of file polygon.h.

NLMISC::CPolygon2D::CPolygon2D const CPolygon   src,
const CMatrix   projMat = CMatrix::Identity
 

Build a 2D polygon from this 3D polygon, by using the given projection matrix The x and y components of projected vertices are used to create the 2D polygon.

Definition at line 785 of file polygon.cpp.

References src, and Vertices.

NLMISC::CPolygon2D::CPolygon2D const CTriangle   tri,
const CMatrix   projMat = CMatrix::Identity
 

Build a 2D polygon from the given triangle, by using the given projection matrix The x and y components of projected vertices are used to create the 2D polygon.

Definition at line 1363 of file polygon.cpp.

References Vertices, x, and y.


Member Function Documentation

void NLMISC::CPolygon2D::buildConvexHull CPolygon2D &    dest const
 

Build a convex hull from this polygon.

The result poly is ordered, so it can also be used to order a convex poly given its set of vertices. NB: require this != &dest

Definition at line 836 of file polygon.cpp.

References NLAISCRIPT::l, nlassert, and Vertices.

void NLMISC::CPolygon2D::computeBorders TRasterVect   borders,
sint   minimumY
 

Compute the borders of this poly with sub-pixel accuracy.

No clipping is performed. Only points exactly inside or exactly on the left border of the polygon are kept. The output is in a vector of sint pairs. minimumY is filled with the minimum y value of the poly. Each pairs gives [xmin, xmax] for the current segment. if xmin > xmax, then no point is valid for this segment. Otherwise, all points from x = xmin (included) to x = xmax (included) are valids.

Definition at line 1075 of file polygon.cpp.

References NLMISC::Next, NLMISC::Prev, NLMISC::ScanEdge, TVec2fVect, and Vertices.

Referenced by NL3D::CWaterRenderObs::traverse.

bool NLMISC::CPolygon2D::contains const CVector2f   p const
 

Check wether a point is contained by this poly.

Definition at line 1331 of file polygon.cpp.

References getLineEquation, getNonNullSeg, getSegRef0, getSegRef1, nlassert, and Vertices.

void NLMISC::CPolygon2D::getBestTriplet uint   index0,
uint   index1,
uint   index2
 

get the best triplet of vector. e.g the triplet that has the best surface.

Definition at line 967 of file polygon.cpp.

References nlassert.

void NLMISC::CPolygon2D::getLineEquation uint    index,
float &    a,
float &    b,
float &    c
const
 

Get a line equation of the seg starting at the given index.

Definition at line 1279 of file polygon.cpp.

References getSegRef0, getSegRef1, index, nlassert, Vertices, NLMISC::CVector2f::x, and NLMISC::CVector2f::y.

Referenced by contains, and intersect.

bool NLMISC::CPolygon2D::getNonNullSeg uint   seg const
 

Get the index of a segment of this poly that is a non null segment.

Returns:
true if such a segment was found

Definition at line 1245 of file polygon.cpp.

References index, nlassert, and Vertices.

Referenced by contains, and intersect.

const CVector2f& NLMISC::CPolygon2D::getSegRef0 uint    index const [inline, private]
 

Get ref to the first vertex that start at index.

Definition at line 190 of file polygon.h.

References index, nlassert, and Vertices.

Referenced by contains, getLineEquation, and intersect.

const CVector2f& NLMISC::CPolygon2D::getSegRef1 uint    index const [inline, private]
 

Definition at line 194 of file polygon.h.

References index, nlassert, and Vertices.

Referenced by contains, getLineEquation, and intersect.

bool NLMISC::CPolygon2D::intersect const CPolygon2D &    other const
 

Test wether this polygon intersect another convex polygon. Currently not optimized.

Definition at line 1292 of file polygon.cpp.

References getLineEquation, getNonNullSeg, getSegRef0, getSegRef1, NLAISCRIPT::l, nlassert, sumDPAgainstLine, and Vertices.

Referenced by NL3D::CZoneLighter::computeTileFlagsForPositionTowardWater.

bool NLMISC::CPolygon2D::isConvex  
 

Check wether this polygon is convex;.

Definition at line 798 of file polygon.cpp.

References Vertices, x, and y.

void NLMISC::CPolygon2D::serial NLMISC::IStream   f throw (NLMISC::EStream)
 

Serial this polygon.

Definition at line 959 of file polygon.cpp.

float NLMISC::CPolygon2D::sumDPAgainstLine float    a,
float    b,
float    c
const [private]
 

Sum the dot product of this poly vertices against a plane.

Definition at line 1232 of file polygon.cpp.

Referenced by intersect.


Member Data Documentation

TVec2fVect NLMISC::CPolygon2D::Vertices
 

Definition at line 130 of file polygon.h.

Referenced by buildConvexHull, NL3D::CWaterShape::computeBBox, computeBorders, NL3D::CZoneLighter::computeTileFlagsForPositionTowardWater, contains, CPolygon2D, getLineEquation, getNonNullSeg, getSegRef0, getSegRef1, NL3D::CWaterShape::getShapeInWorldSpace, intersect, isConvex, NL3D::CWaterShape::setShape, and NL3D::CWaterRenderObs::traverse.


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