MNNormalFace Class Reference
 
 
 
MNNormalFace Class Reference

#include <MNNormalSpec.h>

Inheritance diagram for MNNormalFace:
MaxHeapOperators

Class Description

This stores specified normal information for a given face.

An array of these faces is used as a data member of class MNNormalSpec, in much the same way as an MNMapFace array is a data member of class MNMap.

Public Member Functions

  MNNormalFace ()
DllExport  MNNormalFace (int degree)
  ~MNNormalFace ()
DllExport void  Init ()
DllExport void  Clear ()
int  GetDegree ()
DllExport void  SetDegree (int degree)
int  GetNormalID (int corner)
void  SetNormalID (int corner, int norm)
int *  GetNormalIDArray ()
  Return a pointer to the internal array of normal IDs. This array has length == GetDegree().
bool  GetSpecified (int corner)
void  SetSpecified (int corner, bool value=true)
void  SpecifyAll (bool value=true)
  Set all normals on this face to be specified.
DllExport void  SpecifyNormalID (int corner, int norm)
DllExport void  MakePoly (int degree, int *pNormalID)
DllExport void  Insert (int pos, int num=1)
DllExport void  Delete (int pos, int num=1)
DllExport void  RotateStart (int newstart)
DllExport void  Flip ()
DllExport MNNormalFace operator= (const MNNormalFace &from)
DllExport MNNormalFace operator= (const MNFace &from)
DllExport void  ShallowTransfer (MNNormalFace &from)
DllExport void  MNDebugPrint (bool printAll=false)
DllExport IOResult  Save (ISave *isave)
DllExport IOResult  Load (ILoad *iload)

Constructor & Destructor Documentation

MNNormalFace ( ) [inline]
Remarks:
Constructor - initializes mDegree to 0, mpNormalID to NULL.

: mDegree(0), mpNormalID(NULL) { }
DllExport MNNormalFace ( int  degree )
Remarks:
Constructor - initializes to the degree specified.

~MNNormalFace ( ) [inline]
Remarks:
Destructor - frees data members.

{ Clear(); }

Member Function Documentation

DllExport void Init ( )
Remarks:
Initializes data members. This is useful in situations where the default constructor may not have been properly called, such as

MNNormalFace *fc = new MNNormalFace[10];

It should not be called on an MNNormalFace with data allocated, or that memory will leak.

DllExport void Clear ( )
Remarks:
Frees all allocated data, sets degree to 0.

int GetDegree ( ) [inline]
Remarks:
Returns the face's degree.

{ return mDegree; }
DllExport void SetDegree ( int  degree )
Remarks:
Sets the face's degree.
int GetNormalID ( int  corner ) [inline]
Remarks:
Accessor for normal in a particular corner of the face.

Parameters:
int corner

The (zero-based) index of the corner of the face. (A quad face has corners 0, 1, 2, and 3.)

Returns:
Index of normal (in parent MNNormalSpec's normal array), or -1 if "corner" is out of range.

{ return (mpNormalID && (corner<mDegree)) ? mpNormalID[corner] : -1; }
void SetNormalID ( int  corner,
int  norm 
) [inline]
Remarks:
Sets the normal ID used in a particular corner.

Parameters:
int corner

The (zero-based) index of the corner of the face. (A quad face has corners 0, 1, 2, and 3.)

int norm

The index of the normal (in the parent MNNormalSpec's normal array).
{ if (mpNormalID && (corner<mDegree)) mpNormalID[corner] = norm; }
int* GetNormalIDArray ( ) [inline]

Return a pointer to the internal array of normal IDs. This array has length == GetDegree().

{ return mpNormalID; }
bool GetSpecified ( int  corner ) [inline]
Remarks:
Indicates whether the normal used in a particular corner is specified or not.

Parameters:
int corner

The (zero-based) index of the corner of the face. (A quad face has

corners 0, 1, 2, and 3.)

{ return (mpNormalID && (corner<mDegree) && mSpecified[corner]) ? true : false; }
void SetSpecified ( int  corner,
bool  value = true 
) [inline]
Remarks:
Controls whether the normal used in a particular corner of the face is specified or not.

Parameters:
int corner

The (zero-based) index of the corner of the face. (A quad face has corners 0, 1, 2, and 3.)

Parameters:
bool value

Whether the corner should have a specified (true) or unspecified (false) normal.

{ if (mpNormalID && (corner<mDegree)) mSpecified.Set (corner, value); }
void SpecifyAll ( bool  value = true ) [inline]

Set all normals on this face to be specified.

{ if (value) mSpecified.SetAll(); else mSpecified.ClearAll(); }
DllExport void SpecifyNormalID ( int  corner,
int  norm 
)
Remarks:
Specifies that a particular corner of the face should use a given normal index.

Parameters:
int corner

The (zero-based) index of the corner of the face. (A quad face has corners 0, 1, 2, and 3.)

Parameters:
int norm

The index of the normal (in the parent MNNormalSpec's normal array).

DllExport void MakePoly ( int  degree,
int *  pNormalID 
)
DllExport void Insert ( int  pos,
int  num = 1 
)
Remarks:
Inserts space for more normals into an existing face. (Designed to be used in conjunction with MNFace::Insert, to increase the size of a polygon and add new vertices & normals.)
Parameters:
int pos

The location within the face where the new normals will be added.

Parameters:
int num=1

The number of new normals to add.

DllExport void Delete ( int  pos,
int  num = 1 
)
Remarks:
Deletes normals from this map face. (Designed to be used in conjunction with MNFace::Delete, to decrease the size of a polygon and remove vertices & normals.).
Parameters:
int pos

The location within the face where the new normals will be deleted.

Parameters:
int num=1

The number of new normals to delete.

DllExport void RotateStart ( int  newstart )
Remarks:
Deletes normals from this map face. (Designed to be used in conjunction with MNFace::Delete, to decrease the size of a polygon and remove vertices & normals.).
Parameters:
int newstart

The new first normal

DllExport void Flip ( )
Remarks:
Reverses order of normals, effectively inverting the face. (Designed to be used in conjunction with MNFace::Flip.)

DllExport MNNormalFace& operator= ( const MNNormalFace from )
Remarks:
Typical = operator - calls SetDegree to make this face the same size as "from", then copies the specification data and the normalIDs.

DllExport MNNormalFace& operator= ( const MNFace from )
Remarks:
Sets the degree of this NormalFace to that of the MNFace given.

DllExport void ShallowTransfer ( MNNormalFace from )
Remarks:
"Shallow-copies" data from "from". This is dangerous to use - the pointer to the normal ID array is the same in both faces after this is called.

It's typically used by MNNormal::FAlloc, when resizing the whole face array.

DllExport void MNDebugPrint ( bool  printAll = false )
Remarks:
Uses "DebugPrint" to output information about this MNNormalFace to the Debug buffer in DevStudio. Output is formatted as follows: suppose we have a 5-sided face, with normals {4,5,6,7,8}, and only the normals in corners 1 and 2 (i.e. normals 5 and 6) are specified.

MNDebugPrint (true) would generate:

_4 5 6 _7 _8

MNDebugPrint (false) would generate:

_ 5 6 _ _

This is mainly used as part of MNNormalSpec::MNDebugPrint.

DllExport IOResult Save ( ISave isave )
Remarks:
Called by the system. Saves the face's data to the stream given.

DllExport IOResult Load ( ILoad iload )
Remarks:
Called by the system. Loads the face's data from the stream given.