Face Class Reference

#include <mesh.h>

Class Description

This class represents a single triangular face.

The class maintains three indices into the vertex list for the face, a 32-bit smoothing group for the face, and 32-bits of face flags. The flags also store information about the visibility of the face, the visibility of the three edges, and whether or not the face has texture vertices present. The most significant 16-bits of the face flags store the material index. All methods of this class are implemented by the system.

See also
Class Mesh.
+ Inheritance diagram for Face:

Public Member Functions

 Face ()
 Constructor. More...
 
MtlID getMatID ()
 Retrieves the zero based material ID for this face. More...
 
void setMatID (MtlID id)
 Sets the material ID for this face. More...
 
void setSmGroup (DWORD i)
 Sets the smoothing group bits for this face. More...
 
DWORD getSmGroup (void)
 Returns the smoothing group bits for this face. More...
 
DllExport void setVerts (DWORD *vrt)
 Sets the vertices of this face. More...
 
void setVerts (int a, int b, int c)
 Sets the vertices of this face. More...
 
DllExport void setEdgeVis (int edge, int visFlag)
 Sets the visibility of the specified edge. More...
 
DllExport void setEdgeVisFlags (int va, int vb, int vc)
 Sets the visibility of the all the edges. More...
 
int getEdgeVis (int edge)
 Retrieves the edge visibility for the specified edge. More...
 
DWORD getVert (int index)
 Returns the index into the mesh vertex array of the specified vertex. More...
 
DWORD * getAllVerts (void)
 Retrieves a pointer to the vertex array. More...
 
BOOL Hidden ()
 Determines if the face is hidden or visible. More...
 
void Hide ()
 Hides this face (makes it invisible in the viewports). More...
 
void Show ()
 Shows this face (makes it visible in the viewports). More...
 
void SetHide (BOOL hide)
 Sets the hidden state of this face. More...
 
BOOL InForeground ()
 
void PushToForeground ()
 
void PushToBackground ()
 
void SetInForegound (BOOL foreground)
 
BOOL IsBackFacing ()
 
void SetBackFacing ()
 
void SetFrontFacing ()
 
void SetBackFacing (BOOL backFacing)
 
DllExport DWORD GetOtherIndex (DWORD v0, DWORD v1)
 Returns the first vertex in the face that isn't v0 or v1. More...
 
DllExport DWORD GetEdgeIndex (DWORD v0, DWORD v1)
 Returns the index of the edge in the face that goes from v0 to v1, or v1 to v0. More...
 
DllExport int Direction (DWORD v0, DWORD v1)
 Indicates order in which vertices v0 and v1 appear in the face. More...
 
DllExport DWORD GetVertIndex (DWORD v0)
 Returns the index of the specified vertex in this face's vertex list (0, 1 or 2). More...
 
DllExport void OrderVerts (DWORD &v0, DWORD &v1)
 This method switches v0,v1 if needed to put them in face-order. More...
 

Public Attributes

DWORD v [3]
 These are zero-based indices into a mesh object's array of vertices. More...
 
DWORD smGroup
 Smoothing group bits for the face. More...
 
DWORD flags
 The Face Flags: Can be from the following list: More...
 

Additional Inherited Members

- Static Public Member Functions inherited from MaxHeapOperators
static UtilExport voidoperator new (size_t size)
 Standard new operator used to allocate objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e)
 Standard new operator used to allocate objects if there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate objects that takes the type of memory, filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate arrays of objects. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport void operator delete (void *ptr)
 Standard delete operator used to deallocate an object If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an object If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an object that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, void *placement_ptr)
 Placement new operator. More...
 
static UtilExport void operator delete (void *ptr, void *placement_ptr)
 Placement delete operator. More...
 
static UtilExport voidaligned_malloc (size_t size, size_t alignment)
 Allocates memory on a specified alignment boundary. More...
 
static UtilExport voidaligned_realloc (void *ptr, size_t size, size_t alignment)
 Reallocates memory on a specified alignment boundary. More...
 
static UtilExport void aligned_free (void *ptr)
 Frees a block of memory that was allocated with aligned_malloc/aligned_realloc. More...
 

Constructor & Destructor Documentation

Face ( )
inline

Constructor.

The smoothing groups and face flags are initialized to zero.

216 { smGroup = flags = 0; }
DWORD smGroup
Smoothing group bits for the face.
Definition: mesh.h:203
DWORD flags
The Face Flags: Can be from the following list:
Definition: mesh.h:212

Member Function Documentation

MtlID getMatID ( )
inline

Retrieves the zero based material ID for this face.

Note: typedef unsigned short MtlID;

220 { return (int)( ( flags >> FACE_MATID_SHIFT ) & FACE_MATID_MASK); }
#define FACE_MATID_MASK
A mask used to access the material ID.
Definition: MeshFaceFlagConstants.h:55
DWORD flags
The Face Flags: Can be from the following list:
Definition: mesh.h:212
#define FACE_MATID_SHIFT
The number of bits to shift the flags to access the material.
Definition: MeshFaceFlagConstants.h:54
void setMatID ( MtlID  id)
inline

Sets the material ID for this face.

Parameters
idSpecifies the zero based material index.
225 {flags &= 0xFFFF; flags |= (DWORD)(id<<FACE_MATID_SHIFT);}
DWORD flags
The Face Flags: Can be from the following list:
Definition: mesh.h:212
#define FACE_MATID_SHIFT
The number of bits to shift the flags to access the material.
Definition: MeshFaceFlagConstants.h:54
void setSmGroup ( DWORD  i)
inline

Sets the smoothing group bits for this face.

Parameters
iSpecifies the smoothing group bits for this face.
228 { smGroup = i; }
DWORD smGroup
Smoothing group bits for the face.
Definition: mesh.h:203
DWORD getSmGroup ( void  )
inline

Returns the smoothing group bits for this face.

231 { return smGroup; }
DWORD smGroup
Smoothing group bits for the face.
Definition: mesh.h:203
DllExport void setVerts ( DWORD *  vrt)

Sets the vertices of this face.

Parameters
vrtAn array of the 3 vertices to store. These are zero based indices into the mesh object's array of vertices.
void setVerts ( int  a,
int  b,
int  c 
)
inline

Sets the vertices of this face.

The specified indexes are zero based indices into the mesh object's array of vertices.

Parameters
aSpecifies the first vertex.
bSpecifies the second vertex.
cSpecifies the third vertex.
243 { v[0]=a; v[1]=b; v[2]=c; }
DWORD v[3]
These are zero-based indices into a mesh object's array of vertices.
Definition: mesh.h:196
DllExport void setEdgeVis ( int  edge,
int  visFlag 
)

Sets the visibility of the specified edge.

Parameters
edgeSpecifies the edge to set the visibility of. You may use 0, 1, or 2.
visFlagOne of the following values:
  • EDGE_VIS Sets the edge as visible.
  • EDGE_INVIS Sets the edge as invisible.
DllExport void setEdgeVisFlags ( int  va,
int  vb,
int  vc 
)

Sets the visibility of the all the edges.

Parameters
vaSpecifies the visibility for edge 0. Use either EDGE_VIS or EDGE_INVIS.
vbSpecifies the visibility for edge 1. Use either EDGE_VIS or EDGE_INVIS.
vcSpecifies the visibility for edge 2. Use either EDGE_VIS or EDGE_INVIS.
int getEdgeVis ( int  edge)
inline

Retrieves the edge visibility for the specified edge.

Parameters
edgeSpecifies the edge.
Returns
Nonzero if the edge is visible, zero if the edge is invisible.
267 { return flags & (VIS_BIT << edge); }
DWORD flags
The Face Flags: Can be from the following list:
Definition: mesh.h:212
#define VIS_BIT
Definition: MeshFaceFlagConstants.h:20
DWORD getVert ( int  index)
inline

Returns the index into the mesh vertex array of the specified vertex.

Parameters
indexSpecifies the vertex to retrieve. You may use 0, 1 or 2.
272 { return v[index]; }
DWORD v[3]
These are zero-based indices into a mesh object's array of vertices.
Definition: mesh.h:196
DWORD* getAllVerts ( void  )
inline

Retrieves a pointer to the vertex array.

Returns
A pointer to the vertex array.
276 { return v; }
DWORD v[3]
These are zero-based indices into a mesh object's array of vertices.
Definition: mesh.h:196
BOOL Hidden ( )
inline

Determines if the face is hidden or visible.

Returns
TRUE if the face is hidden; otherwise FALSE.
280 {return flags&FACE_HIDDEN?TRUE:FALSE;}
DWORD flags
The Face Flags: Can be from the following list:
Definition: mesh.h:212
#define FACE_HIDDEN
Face visibility bit.
Definition: MeshFaceFlagConstants.h:33
void Hide ( )
inline

Hides this face (makes it invisible in the viewports).

283 {flags|=FACE_HIDDEN;}
DWORD flags
The Face Flags: Can be from the following list:
Definition: mesh.h:212
#define FACE_HIDDEN
Face visibility bit.
Definition: MeshFaceFlagConstants.h:33
void Show ( )
inline

Shows this face (makes it visible in the viewports).

286 {flags&=~FACE_HIDDEN;}
DWORD flags
The Face Flags: Can be from the following list:
Definition: mesh.h:212
#define FACE_HIDDEN
Face visibility bit.
Definition: MeshFaceFlagConstants.h:33
void SetHide ( BOOL  hide)
inline

Sets the hidden state of this face.

Parameters
hideSpecifies the hidden state for the face. Pass TRUE to hide the face; FALSE to show it.
291 {if (hide) Hide(); else Show();}
void Hide()
Hides this face (makes it invisible in the viewports).
Definition: mesh.h:283
void Show()
Shows this face (makes it visible in the viewports).
Definition: mesh.h:286
BOOL InForeground ( )
inline
293 {return flags&FACE_INFOREGROUND?TRUE:FALSE;}
#define FACE_INFOREGROUND
Used to track faces that are in the foreground.
Definition: MeshFaceFlagConstants.h:47
DWORD flags
The Face Flags: Can be from the following list:
Definition: mesh.h:212
void PushToForeground ( )
inline
#define FACE_INFOREGROUND
Used to track faces that are in the foreground.
Definition: MeshFaceFlagConstants.h:47
DWORD flags
The Face Flags: Can be from the following list:
Definition: mesh.h:212
void PushToBackground ( )
inline
#define FACE_INFOREGROUND
Used to track faces that are in the foreground.
Definition: MeshFaceFlagConstants.h:47
DWORD flags
The Face Flags: Can be from the following list:
Definition: mesh.h:212
void SetInForegound ( BOOL  foreground)
inline
296 {if (foreground) PushToForeground(); else PushToBackground();}
void PushToForeground()
Definition: mesh.h:294
void PushToBackground()
Definition: mesh.h:295
BOOL IsBackFacing ( )
inline
298 {return flags&FACE_BACKFACING?TRUE:FALSE;}
DWORD flags
The Face Flags: Can be from the following list:
Definition: mesh.h:212
#define FACE_BACKFACING
Used to track which faces are back facing.
Definition: MeshFaceFlagConstants.h:48
void SetBackFacing ( )
inline
DWORD flags
The Face Flags: Can be from the following list:
Definition: mesh.h:212
#define FACE_BACKFACING
Used to track which faces are back facing.
Definition: MeshFaceFlagConstants.h:48
void SetFrontFacing ( )
inline
DWORD flags
The Face Flags: Can be from the following list:
Definition: mesh.h:212
#define FACE_BACKFACING
Used to track which faces are back facing.
Definition: MeshFaceFlagConstants.h:48
void SetBackFacing ( BOOL  backFacing)
inline
301 {if (backFacing) SetBackFacing(); else SetFrontFacing();}
void SetFrontFacing()
Definition: mesh.h:300
void SetBackFacing()
Definition: mesh.h:299
DllExport DWORD GetOtherIndex ( DWORD  v0,
DWORD  v1 
)

Returns the first vertex in the face that isn't v0 or v1.

Parameters
v0The zero based index of one of the vertices to check.
v1The zero based index of the other vertex to check.
Returns
The zero based index of the vertex found in the Mesh's vertex list.
DllExport DWORD GetEdgeIndex ( DWORD  v0,
DWORD  v1 
)

Returns the index of the edge in the face that goes from v0 to v1, or v1 to v0.

Parameters
v0The zero based index of the vertex at one end of the edge.
v1The zero based index of the vertex at the other end of the edge.
Returns
The zero based index of the edge found in the Mesh's edge list.
DllExport int Direction ( DWORD  v0,
DWORD  v1 
)

Indicates order in which vertices v0 and v1 appear in the face.

Parameters
v0One vertex on this face.
v1Another vertex on this face.
Returns
1 if v1 follows v0 in sequence (This includes e.g. when Face::v[2] == v0 and Face::v[0] == v1.) -1 if v0 follows v1 in sequence 0 if v0 or v1 are not on the face.
DllExport DWORD GetVertIndex ( DWORD  v0)

Returns the index of the specified vertex in this face's vertex list (0, 1 or 2).

If not found 3 is returned.

Parameters
v0The zero based index of the vertex to check.
DllExport void OrderVerts ( DWORD &  v0,
DWORD &  v1 
)

This method switches v0,v1 if needed to put them in face-order.

If v0 and v1 are in the order in which they appear in the face, or if one or both of them are not actually on the face, nothing happens. If however v0 follows v1, the values of the parameters are switched, so that they are then in the correct order for this face. Sample Code:

Face & f = mesh.faces[edge.f[0]];
DWORD v0 = edge.v[0];
DWORD v1 = edge.v[1];
// Switch v0, v1 if needed to match orientation in selected face.
f.OrderVerts(v0,v1);
Parameters
v0One vertex on this face.
v1Another vertex on this face.

Member Data Documentation

DWORD v[3]

These are zero-based indices into a mesh object's array of vertices.

DWORD smGroup

Smoothing group bits for the face.

Each bit of this 32 bit value represents membership in a smoothing group. The least significant bit represents smoothing group #1 while the most significant bit represents group #32. If two adjacent faces are assigned the same smoothing group bit, the edge between them is rendered smoothly.

DWORD flags

The Face Flags: Can be from the following list: