Pgon Class Reference

#include <lib_ngon.h>

Public Member Functions

Vector CalcNormal (const Vector *padr, const CPolygon *polys) const
 
void GetMpRad (const Vector *padr, const CPolygon *polys, Vector &mp, Vector &rad) const
 
Int32 GetCount () const
 
PgonEdgeGetEdge (Int32 i)
 
Int32 ID (Int32 i) const
 
Int32 State (Int32 i) const
 
Int32 Edge (Int32 i) const
 
Int32 EdgeIndex (Int32 i) const
 
Int32 IsFirst (Int32 i) const
 
Int32 IsSegmentEnd (Int32 i) const
 
Int32 GetIdentity () const
 
Int32 GetSegmentCount () const
 
Int32 GetSegmentLen (Int32 startedge) const
 
void GetEdge (Int32 i, const CPolygon *vadr, Int32 &p1, Int32 &p2)
 
Int32 FindPolygon (Int32 id) const
 
UChar GetEdgeState (Int32 id) const
 
Int32 GetPointCount () const
 
Int32 GetPolygonCount () const
 
void UpdateStates ()
 

Private Attributes

PgonEdgem_Edge
 
Int32 m_Count
 
UInt32 m_CRC
 

Member Function Documentation

◆ CalcNormal()

Vector CalcNormal ( const Vector padr,
const CPolygon polys 
) const

Calculates the normal for the N-gon.

Parameters
[in]padrThe point array. The caller owns the pointed array.
[in]polysThe polygons array. The caller owns the pointed array.
Returns
The calculated normal.

◆ GetMpRad()

void GetMpRad ( const Vector padr,
const CPolygon polys,
Vector mp,
Vector rad 
) const

Get the bounds of the N-gon.

Parameters
[in]padrThe point array. The caller owns the pointed array.
[in]polysThe polygons array. The caller owns the pointed array.
[out]mpAssigned the calculated mid-point.
[out]radAssigned the calculated bounding box vector.

◆ GetCount()

Int32 GetCount ( ) const

Retrieves the number of elements in the array (all PgonEdge edges in all segments).

Note
This is not the same as all N-gon edges since some elements may be from internal polygons with no outer/inner N-gon edge.
Returns
The number of elements in the array.

◆ GetEdge() [1/2]

PgonEdge* GetEdge ( Int32  i)

Gets access directly to a PgonEdge. Normally the helper functions below should be used.

Parameters
[in]iAn edge index.
Returns
The edge.

◆ ID()

Int32 ID ( Int32  i) const

Retrieves the PgonEdge::ID() of the edge at index i.

Parameters
[in]iAn edge index.
Returns
The edge polygon ID.

◆ State()

Int32 State ( Int32  i) const

Retrieves the PgonEdge::State() of the edge at index i.

Parameters
[in]iAn edge index.
Returns
The edge state.

◆ Edge()

Int32 Edge ( Int32  i) const

Retrieves the PgonEdge::Edge() of the edge at index i.

Parameters
[in]iAn edge index.
Returns
The edge.

◆ EdgeIndex()

Int32 EdgeIndex ( Int32  i) const

Retrieves the PgonEdge::EdgeIndex() of the edge at index i.

Parameters
[in]iAn edge index.
Returns
The edge index.

◆ IsFirst()

Int32 IsFirst ( Int32  i) const

Retrieves the PgonEdge::IsFirst() state of the edge at index i.

Parameters
[in]iAn edge index.
Returns
The edge first state.

◆ IsSegmentEnd()

Int32 IsSegmentEnd ( Int32  i) const

Retrieves the PgonEdge::IsSegmentEnd() state of the edge at index i.

Parameters
[in]iAn edge index.
Returns
The edge segment end state.

◆ GetIdentity()

Int32 GetIdentity ( ) const

Retrieves the first polygon ID in the array, useful as a marker (identity) for the N-gon giving a polygon ID that is within the N-gon.

Returns
The first polygon ID.

◆ GetSegmentCount()

Int32 GetSegmentCount ( ) const

Retrieves the number of segments in the N-gon.

Returns
The segment count.

◆ GetSegmentLen()

Int32 GetSegmentLen ( Int32  startedge) const

Retrieves the number of elements in the segment starting from the index startedge. This includes any PgonEdge edges that are internal (NOEDGE).

Parameters
[in]startedgeAn edge index.
Returns
The number of elements in the segment starting from startedge.

◆ GetEdge() [2/2]

void GetEdge ( Int32  i,
const CPolygon vadr,
Int32 p1,
Int32 p2 
)

Maps to the function PgonEdge::GetEdge() of the edge at index i.

Parameters
[in]iAn edge index.
[in]vadrThe polygon array. The caller owns the pointed array.
[out]p1Assigned the first point index.
[out]p2Assigned the second point index.

◆ FindPolygon()

Int32 FindPolygon ( Int32  id) const

Does a search to see if the polygon index id exists within the N-gon; the look up uses tables so it is pretty fast.

Parameters
[in]idA polygon ID to search for.
Returns
The index of the first edge found with the specified polygon id, or NOTOK if no edge was found.

◆ GetEdgeState()

UChar GetEdgeState ( Int32  id) const

Retrieves the edges (bits) for polygon id that form any edge/s around the N-gon.

Parameters
[in]idCombined edge bits for all edges with polygon ID matching id: PGONEDGE
Returns
A polygon ID.

◆ GetPointCount()

Int32 GetPointCount ( ) const

Retrieves the number of points that form the N-gon.

Returns
The point count.

◆ GetPolygonCount()

Int32 GetPolygonCount ( ) const

Retrieves the number of polygons that form the N-gon.

Returns
The polygon count.

◆ UpdateStates()

void UpdateStates ( )

If any changes are done to the PgonEdges this must be called when completed to update the REPEAT markers of the PgonEdges.
Also note that any changes must correct set/change any of the marker bits (such as the segment end, or no edges markers).

Member Data Documentation

◆ m_Edge

PgonEdge* m_Edge
private

◆ m_Count

Int32 m_Count
private

◆ m_CRC

UInt32 m_CRC
private