MarSTDv2004: CPoly Class Reference

MarSTDv2004

CPoly Class Reference

Collaboration diagram for CPoly:

Collaboration graph
[legend]
List of all members.

Detailed Description

The polygon class defines a polygon using a DLL of edges in CW order. Polygons should be convex and defined CW to use all of the features.

Definition at line 31 of file CPoly.h.

Public Member Functions

CEdgeadd (CEdge *edge)
CEdgeaddHead (CEdge *edge)
CEdgeaddTail (CEdge *edge)
CEdgeunlink (CEdge *edge)
void remove (CEdge *edge)
void clear ()
void copy (CPoly *poly)
CPolycopy ()
void init ()
CSphere calculateSphere ()
int onFront (CPlane *plane)
int onBack (CPlane *plane)
CPolyclip (CPlane *plane)
CPolyclipFront (CPlane *plane)
void clip (CPlane *plane, CPoly *front, CPoly *back)
void clip (CPoly *poly, CPoly *inside, class CMesh *outside)
void reverseWinding ()
void triangulate (std::vector< CPoly * > *polyArray)
CPolyunlink ()

Public Attributes

CEdgeedgeHead
 First edge in DLL.
CEdgeedgeTail
 Last edge in DLL.
int edgeCount
 Number of edges.
CPlane plane
 Plane. Uses left hand rule.
CSphere sphere
void * data
 Custom data field. Use it to store a pointer to some custom data structure. Eg to define material properties, texture, ...
CPolyprev
 Reference to previous polygon in DLL.
CPolynext
 Reference to next polygon in DLL.

Member Function Documentation

CEdge* CPoly::add CEdge edge  ) 
 

Links an edge to the tail.

See also:
add_tail()

CEdge* CPoly::addHead CEdge edge  ) 
 

Links an edge to the head.

See also:
add_tail()

CEdge* CPoly::addTail CEdge edge  ) 
 

Links an edge to the tail.

See also:
add_head()

CEdge* CPoly::unlink CEdge edge  ) 
 

Unlinks an edge from the DLL. Note that this does not free any memory.

See also:
remove()

void CPoly::remove CEdge edge  ) 
 

Removes an edge. This unlinks the edge and then frees it's memory. ()

void CPoly::clear  ) 
 

Clear the DLL of edges. This will free all memory.

void CPoly::init  ) 
 

Initializes the polygon. This will calculate the plane and edge normals. This should be done when the polygon creation has finished. If the number of edges < 3 this function will bail.

CSphere CPoly::calculateSphere  ) 
 

Calculates a bounding sphere. The polygon is entirely contained within the bounding sphere.

Returns:
The bounding sphere.

int CPoly::onFront CPlane plane  ) 
 

Returns true if the polygon is in front of the plane, considering epsilon.

int CPoly::onBack CPlane plane  ) 
 

Returns true if the polygon is behind of the plane, considering epsilon.

CPoly* CPoly::clip CPlane plane  ) 
 

Clip the polygon by plane, returning the remaining polygon (all that is in front of the plane). FIXME: changing this to clip everything BEHIND the plane will probably affect brush code. Will have to fix it. :)

CPoly* CPoly::clipFront CPlane plane  ) 
 

Same as clip(CPlane* plane), however this removes the part that is behind the plane.

void CPoly::clip CPlane plane,
CPoly front,
CPoly back
 

Clip the polygon by plane, returning both the parts that are in front and behind the plane.

void CPoly::clip CPoly poly,
CPoly inside,
class CMesh outside
 

Clip the polygon by another polygon that is coplanar, possibly overlapping. out = this - poly. in = this - out.

For instance:

++++                ++++
++---- => outside = ++    inside =   ++  poly =   ----
++----              ++               ++           ----
  ----                                            ----

CPoly* CPoly::unlink  ) 
 

Unlinks this polygon from a DLL.


The documentation for this class was generated from the following file:
Generated on Tue Feb 8 21:59:43 2005 for MarSTDv2004 by  doxygen 1.4.1