#include <Polygon.hpp>
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 Vertex * | getVertices () 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. | |
Polygon * | clone () 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 | |
Vertex * | m_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. |
syBR::map2syBR::Polygon::Polygon | ( | ) |
Contructor.
syBR::map2syBR::Polygon::~Polygon | ( | ) |
Destructor.
bool syBR::map2syBR::Polygon::addVertex | ( | Vertex * | pVertex | ) |
Add a vertex to the vertex list.
pVertex | Vertex to add |
const unsigned long syBR::map2syBR::Polygon::getVertexCount | ( | ) | const |
const Vertex * syBR::map2syBR::Polygon::getVertices | ( | ) | const |
Get the vertices.
void syBR::map2syBR::Polygon::sortVerticesClockwise | ( | const Vector3 & | polygonNormal | ) |
Sort vertices clockwise.
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.
const Vector3 syBR::map2syBR::Polygon::getNormal | ( | ) | const |
Get the polygon normal.
const double syBR::map2syBR::Polygon::estimateDistance | ( | const Vector3 & | vec | ) | const |
Estimate the distance to the specified vector.
vec | Vector whose distance to the polygon must be estimated |
void syBR::map2syBR::Polygon::toTriangles | ( | ) |
Create triangles from the polygons list.
Polygon * syBR::map2syBR::Polygon::clone | ( | ) | const |
Create a copy of the polygon.
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.
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:
|
const Polygon::PolygonPosition syBR::map2syBR::Polygon::calculatePosition | ( | const Polygon & | polygon | ) | const |
Calculate the position of this polygon against the plane of another polygon.
polygon | Polygon whose position compared to the position of this polygon is to be calculated |
void syBR::map2syBR::Polygon::splitPolygon | ( | const Polygon & | polygonPlane, | |
Polygon ** | ppFront, | |||
Polygon ** | ppBack | |||
) | const |
Split a polygon by the plane of another polygon.
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.
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 |
const std::vector< Polygon * > & syBR::map2syBR::Polygon::getTriangles | ( | ) | const |
void syBR::map2syBR::Polygon::fillTrianglesArray | ( | Triangle * | pTriangles, | |
unsigned long & | newIndex | |||
) | const |
Fill the triangles array.
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 |
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.
Copyright © 2008 by Sebastien Frippiat
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License.
Last modified Tue Dec 30 17:57:34 2008