syBR::map2syBR::Polygon Class Reference

Polygon class. More...

#include <Polygon.hpp>

List of all members.

Public Types

enum  PolygonPosition { PP_FRONT = 0, PP_BACK, PP_ON, PP_SPANNING }
 Position of a polygon compared to the position of a plane. More...

Public Member Functions

 Polygon ()
 Contructor.
 ~Polygon ()
 Destructor.
bool addVertex (Vertex *pVertex)
 Add a vertex to the vertex list.
const unsigned long getVertexCount () const
 Get the vertex count.
const VertexgetVertices () const
 Get the vertices.
void sortVerticesClockwise (const Vector3 &polygonNormal)
 Sort vertices clockwise.
void normalizeTextureCoordinates ()
 Normalize texture coordinates.
const double getPerimetre () const
 Get perimetre of the polygon.
const Vector3 getNormal () const
 Get the polygon normal.
const double estimateDistance (const Vector3 &vec) const
 Estimate the distance to the specified vector.
void toTriangles ()
 Create triangles from the polygons list.
Polygonclone () const
 Create a copy of the polygon.
bool clipToList (std::vector< Polygon * >::iterator start, std::vector< Polygon * >::iterator end, std::vector< Polygon * > &vpClipResult, bool clipOnPlane)
 Clip a polygons list to this polygon.
const PolygonPosition calculatePosition (const Polygon &polygon) const
 Calculate the position of this polygon against the plane of another polygon.
void splitPolygon (const Polygon &polygonPlane, Polygon **ppFront, Polygon **ppBack) const
 Split a polygon by the plane of another polygon.
void getAdjacentPolygons (std::list< Polygon * > &lstPolygons, std::list< Polygon * > &lstAdjacentPolygons, std::list< Polygon * > &lstNonAdjacentPolygons)
 Get the adjacent polygons of a polygon.
const unsigned long getTriangleCount () const
 Get the triangle count.
const std::vector
< Polygon * > & 
getTriangles () const
 Get the triangles.
void fillTrianglesArray (Triangle *pTriangles, unsigned long &newIndex) const
 Fill the triangles array.

Private Member Functions

void swapVertex (Vertex *pVertex1, Vertex *pVertex2)
 Swap the content of two vertices (except the next pointer).

Private Attributes

Vertexm_pVertices
 Linked list of vertices.
unsigned long m_vertexCount
 Vertex count.
std::vector< Polygon * > m_vpTriangles
 List of triangles.
bool m_adjacentDone
 Used when retrieving adjacent polygons.


Detailed Description

Polygon class.

Member Enumeration Documentation

enum syBR::map2syBR::Polygon::PolygonPosition

Position of a polygon compared to the position of a plane.

Enumerator:
PP_FRONT  Polygon is in front of the plane.
PP_BACK  Polygon is at the back of the plane.
PP_ON  Polygon is on the plane.
PP_SPANNING  Polygon is spanning the plane.


Constructor & Destructor Documentation

syBR::map2syBR::Polygon::Polygon (  ) 

Contructor.

syBR::map2syBR::Polygon::~Polygon (  ) 

Destructor.


Member Function Documentation

bool syBR::map2syBR::Polygon::addVertex ( Vertex pVertex  ) 

Add a vertex to the vertex list.

Parameters:
pVertex Vertex to add
Returns:
One of these:
  • true if the vertex has been added
  • false otherwise

const unsigned long syBR::map2syBR::Polygon::getVertexCount (  )  const

Get the vertex count.

Returns:
Vertex count

const Vertex * syBR::map2syBR::Polygon::getVertices (  )  const

Get the vertices.

Returns:
Pointer to the first vertex in the linked list

void syBR::map2syBR::Polygon::sortVerticesClockwise ( const Vector3 polygonNormal  ) 

Sort vertices clockwise.

Parameters:
polygonNormal Normal of the polygon

void syBR::map2syBR::Polygon::normalizeTextureCoordinates (  ) 

Normalize texture coordinates.

const double syBR::map2syBR::Polygon::getPerimetre (  )  const

Get perimetre of the polygon.

Returns:
Perimetre of the polygon

const Vector3 syBR::map2syBR::Polygon::getNormal (  )  const

Get the polygon normal.

Returns:
Normal of the polygon

const double syBR::map2syBR::Polygon::estimateDistance ( const Vector3 vec  )  const

Estimate the distance to the specified vector.

Parameters:
vec Vector whose distance to the polygon must be estimated
Returns:
Approximated distance between the vector and the polygon

void syBR::map2syBR::Polygon::toTriangles (  ) 

Create triangles from the polygons list.

Polygon * syBR::map2syBR::Polygon::clone (  )  const

Create a copy of the polygon.

Returns:
Pointer to a polygon with exactly the same vertices as this one

bool syBR::map2syBR::Polygon::clipToList ( std::vector< Polygon * >::iterator  start,
std::vector< Polygon * >::iterator  end,
std::vector< Polygon * > &  vpClipResult,
bool  clipOnPlane 
)

Clip a polygons list to this polygon.

Parameters:
start First polygon in the list of polygons to be clipped
end Last polygon in the list of polygons to be clipped
vpClipResult Polygon list resulting of the clipping
clipOnPlane One of these:
  • true to clip polygons that are on the same plane as the polygon
  • false otherwise
Returns:
One of these:
  • false if the whole polygon has been kept
  • true otherwise

const Polygon::PolygonPosition syBR::map2syBR::Polygon::calculatePosition ( const Polygon polygon  )  const

Calculate the position of this polygon against the plane of another polygon.

Parameters:
polygon Polygon whose position compared to the position of this polygon is to be calculated
Returns:
Position of the polygon compared to the position of this polygon

void syBR::map2syBR::Polygon::splitPolygon ( const Polygon polygonPlane,
Polygon **  ppFront,
Polygon **  ppBack 
) const

Split a polygon by the plane of another polygon.

Parameters:
polygonPlane Splitting plane
ppFront Will contain a pointer to the polygon part which is in front of the splitting plane
ppBack Will contain a pointer to the polygon part which is at the back of the splitting plane

void syBR::map2syBR::Polygon::getAdjacentPolygons ( std::list< Polygon * > &  lstPolygons,
std::list< Polygon * > &  lstAdjacentPolygons,
std::list< Polygon * > &  lstNonAdjacentPolygons 
)

Get the adjacent polygons of a polygon.

Parameters:
lstPolygons Polygons to be checked
lstAdjacentPolygons Polygons from lstPolygons which are adjacent to this polygon
lstNonAdjacentPolygons Polygons from lstPolygons which are not adjacent to this polygon

const unsigned long syBR::map2syBR::Polygon::getTriangleCount (  )  const

Get the triangle count.

Returns:
Triangle count

const std::vector< Polygon * > & syBR::map2syBR::Polygon::getTriangles (  )  const

Get the triangles.

Returns:
Triangle list

void syBR::map2syBR::Polygon::fillTrianglesArray ( Triangle pTriangles,
unsigned long &  newIndex 
) const

Fill the triangles array.

Parameters:
pTriangles Array which is going to be filled with triangle data from this polygon
newIndex First index in the array that can be used to fill it, at the end of the operation, it will have the next index available

void syBR::map2syBR::Polygon::swapVertex ( Vertex pVertex1,
Vertex pVertex2 
) [private]

Swap the content of two vertices (except the next pointer).

Parameters:
pVertex1 Vertex to be swapped with the second vertex
pVertex2 Vertex to be swapped with the first vertex


Member Data Documentation

Vertex* syBR::map2syBR::Polygon::m_pVertices [private]

Linked list of vertices.

unsigned long syBR::map2syBR::Polygon::m_vertexCount [private]

Vertex count.

std::vector<Polygon *> syBR::map2syBR::Polygon::m_vpTriangles [private]

List of triangles.

bool syBR::map2syBR::Polygon::m_adjacentDone [private]

Used when retrieving adjacent polygons.


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

Copyright © 2008 by Sebastien Frippiat
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License.
Last modified Tue Dec 30 17:57:34 2008