# 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::CPolygon Class Reference

A polygon, with an unlimited size of vertices. More...

#include <polygon.h>

List of all members.

Public Methods

 CPolygon ()
 Constructor. More...

 CPolygon (const CVector &a, const CVector &b, const CVector &c)
 Constructor. Init with a triangle. More...

sint getNumVertices () const
void clip (const CPlane *planes, uint nPlanes)
 Clip a polygon with a set of planes. Cohen-sutherland... clipPolygonBack() is used on planes. More...

void clip (const std::vector< CPlane > &planes)
 Clip a polygon with a set of planes. Cohen-sutherland clipping... clipPolygonBack() is used on planes. More...

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

bool toConvexPolygons (std::list< CPolygon > &outputPolygons, const CMatrix &basis) const
 Convert a concave polygon into a list of convex polygons using a 2d projection. More...

bool chain (const std::vector< CPolygon > &other, const CMatrix &basis)
 Chain the arg polygons with this polygon testing 2d intersections. More...

void getBestTriplet (uint &index0, uint &index1, uint &index2)
 get the best triplet from this poly (the one that has the highest area). More...

void buildBasis (CMatrix &dest)
 Takes the best triplet from this poly to build a normal. More...

void toConvexPolygonsLocalAndBSP (std::vector< CVector > &localVertices, CBSPNode2v &root, const CMatrix &basis) const

Static Public Methods

bool toConvexPolygonsEdgeIntersect (const CVector2f &a0, const CVector2f &a1, const CVector2f &b0, const CVector2f &b1)
bool toConvexPolygonsLeft (const std::vector< CVector > &vertex, uint a, uint b, uint c)
bool toConvexPolygonsLeftOn (const std::vector< CVector > &vertex, uint a, uint b, uint c)
bool toConvexPolygonsInCone (const std::vector< CVector > &vertex, uint a, uint b)
bool toConvexPolygonsDiagonal (const std::vector< CVector > &vertex, const CBSPNode2v &bsp, uint a, uint b)

Public Attributes

std::vector< CVectorVertices


Detailed Description

A polygon, with an unlimited size of vertices.

Author:
Lionel Berenguier , Nevrax France
Date:
2000

Definition at line 56 of file polygon.h.


Constructor & Destructor Documentation

NLMISC::CPolygon::CPolygon   [inline]
 

Constructor.

Definition at line 64 of file polygon.h.

Referenced by chain, and toConvexPolygons.

NLMISC::CPolygon::CPolygon const CVector   a,
const CVector   b,
const CVector   c
 

Constructor. Init with a triangle.

Definition at line 46 of file polygon.cpp.

References Vertices.


Member Function Documentation

void NLMISC::CPolygon::buildBasis CMatrix   dest
 

Takes the best triplet from this poly to build a normal.

From this normal and a points, build a basis (the normal is the K vector of the basis) This can be used to transform the poly in 2D after it has been inverted

Definition at line 141 of file polygon.cpp.

References getBestTriplet, nlassert, and Vertices.

bool NLMISC::CPolygon::chain const std::vector< CPolygon > &    other,
const CMatrix   basis
 

Chain the arg polygons with this polygon testing 2d intersections.

The 2d intersection test has been done in the XY plane of the basis passed at the function.

The polygon a-b-c-d-e chained with f-g-h-i-j will give the polygon a-b-f-g-h-i-j-f-b-c-d-e if the edge b-f is not 2d clipped by any edge plane in the XY plane of basis.

Parameters:
basis  is the basis of the polygon projection.
Returns:
false if chain failed. else true.

Definition at line 624 of file polygon.cpp.

References CPolygon, index, toConvexPolygonsLocalAndBSP, and Vertices.

void NLMISC::CPolygon::clip const std::vector< CPlane > &    planes
 

Clip a polygon with a set of planes. Cohen-sutherland clipping... clipPolygonBack() is used on planes.

Definition at line 89 of file polygon.cpp.

References clip.

void NLMISC::CPolygon::clip const CPlane   planes,
uint    nPlanes
 

Clip a polygon with a set of planes. Cohen-sutherland... clipPolygonBack() is used on planes.

Definition at line 56 of file polygon.cpp.

References getNumVertices, in, and Vertices.

Referenced by clip, and NL3D::CWaterRenderObs::traverse.

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

get the best triplet from this poly (the one that has the highest area).

Definition at line 106 of file polygon.cpp.

References nlassert, and Vertices.

Referenced by buildBasis.

sint NLMISC::CPolygon::getNumVertices   const [inline]
 

Definition at line 68 of file polygon.h.

References Vertices.

Referenced by clip, and NL3D::CZoneLighter::lightWater.

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

Serial this polygon.

Definition at line 99 of file polygon.cpp.

bool NLMISC::CPolygon::toConvexPolygons std::list< CPolygon > &    outputPolygons,
const CMatrix   basis
const
 

Convert a concave polygon into a list of convex polygons using a 2d projection.

The polygon mustn't overlap itself in the XY plane of the basis passed in parameter. The polygon must be direct in the XY plane of the basis passed in parameter. (Counter clock wise)

The subdivison is in non-constant n*log(n) with n is the number of vertices.

Parameters:
outputPolygons  is the list filled with clipped convex polygons. The list is not cleared at the begining. New polygons are just appended at the end.
basis  is the basis of the polygon projection.
Returns:
true if the polygon has been subdivided. false if the polygon overlap itself in the XY plane of the basis or if the polygon is not direct (clock wise).

Definition at line 440 of file polygon.cpp.

References CPolygon, nlassert, toConvexPolygonsDiagonal, toConvexPolygonsLocalAndBSP, and Vertices.

bool NLMISC::CPolygon::toConvexPolygonsDiagonal const std::vector< CVector > &    vertex,
const CBSPNode2v   bsp,
uint    a,
uint    b
[static]
 

Definition at line 375 of file polygon.cpp.

References toConvexPolygonsInCone.

Referenced by toConvexPolygons.

bool NLMISC::CPolygon::toConvexPolygonsEdgeIntersect const CVector2f   a0,
const CVector2f   a1,
const CVector2f   b0,
const CVector2f   b1
[static]
 

Definition at line 177 of file polygon.cpp.

bool NLMISC::CPolygon::toConvexPolygonsInCone const std::vector< CVector > &    vertex,
uint    a,
uint    b
[static]
 

Definition at line 351 of file polygon.cpp.

References toConvexPolygonsLeft, and toConvexPolygonsLeftOn.

Referenced by toConvexPolygonsDiagonal.

bool NLMISC::CPolygon::toConvexPolygonsLeft const std::vector< CVector > &    vertex,
uint    a,
uint    b,
uint    c
[static]
 

Definition at line 337 of file polygon.cpp.

Referenced by toConvexPolygonsInCone.

bool NLMISC::CPolygon::toConvexPolygonsLeftOn const std::vector< CVector > &    vertex,
uint    a,
uint    b,
uint    c
[static]
 

Definition at line 344 of file polygon.cpp.

Referenced by toConvexPolygonsInCone.

void NLMISC::CPolygon::toConvexPolygonsLocalAndBSP std::vector< CVector > &    localVertices,
CBSPNode2v   root,
const CMatrix   basis
const
 

Definition at line 392 of file polygon.cpp.

References NLMISC::TCConcavePolygonsVertexMap, and Vertices.

Referenced by chain, and toConvexPolygons.


Member Data Documentation

std::vector<CVector> NLMISC::CPolygon::Vertices
 

Definition at line 59 of file polygon.h.

Referenced by buildBasis, chain, clip, CPolygon, getBestTriplet, getNumVertices, NL3D::CWaterShape::getShapeInWorldSpace, NL3D::CZoneLighter::lightWater, toConvexPolygons, toConvexPolygonsLocalAndBSP, and NL3D::CWaterRenderObs::traverse.


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