PerData Class Reference

PerData Class Reference

#include <mesh.h>

Class Description

This class is used for per -'something' floating-point information.

For example, it is used with Meshes to keep track of such per-vertex information as weighted (Affect Region or Soft) selections and vertex weights. It is used in MNMesh to store per-edge data (edge weights). Currently there's only one "type" of data supported, floating point values, but this may be extended in the future. PerData arrays in Meshes and MNMeshes cannot be reserved for plug-ins at this time; 3ds Max maintains the list in MESH.H of the reserved vertex data channels, and in MNMESH.H for the MNEdge data channels. The methods of this class are deliberately made to look like Tab<> methods. All methods of this class are implemented by the system.

See also
Class Mesh.
+ Inheritance diagram for PerData:

Public Member Functions

 PerData ()
 Constructor. More...
 
 PerData (int n, int tp)
 Constructor. More...
 
 ~PerData ()
 Destructor. More...
 
DllExport voidAllocData (int num)
 Allocates and returns a pointer to an array of floats of the specified size. More...
 
DllExport void FreeData (void *addr)
 Deletes the specified array of floats. More...
 
DllExport int DataSize ()
 Returns the number of bytes used by the base data type for the vertex data. More...
 
voidAddr (void *ptr, int at)
 Returns the address of the specified element in the array passed. More...
 
voidAddr (int at)
 Returns the address of the specified element in the data array. More...
 
DllExport void CopyData (void *to, void *from, int num=1)
 Copies the specified number of elements between the two data arrays. More...
 
DllExport void CopyData (int to, int from, int num=1)
 Copies the specified number of elements between the two specified locations in the data array. More...
 
DllExport void WeightedSum (void *to, void *fr1, float prop1, void *fr2, float prop2)
 Computes the weighted sum of the arguments passed. More...
 
DllExport void WeightedSum (int to, int fr1, float prop1, int fr2, float prop2)
 Computes the weighted sum of the arguments passed. More...
 
DllExport void setAlloc (int num, BOOL keep=TRUE)
 Sets the number of elements allocated in the data array. More...
 
void SetCount (int num, BOOL keep=FALSE)
 Sets the number of elements allocated in the data array and sets the dnum member to num. More...
 
void Shrink ()
 Reduces the size of the data array to contain dnum elements. More...
 
int Count ()
 Returns the number of elements used (dnum) More...
 
DllExport void Clear ()
 Clears (deletes) any allocated data and sets the count and type to 0. More...
 
DllExport void DeleteSet (BitArray del)
 Removes any element whose corresponding element in the BitArray is not set. More...
 
DllExport void Delete (int at, int num)
 Deletes the specified number of elements from the specified location in the data array. More...
 
DllExport void Insert (int at, int num, void *el)
 Inserts the specified number of data elements into the specified location in the data array. More...
 
DllExport void Append (int num, void *el)
 Appends the specified elements to the data array. More...
 
DllExport void InsertCopies (int at, int num, void *el)
 Inserts the specified number of elements into the data array at the given location. More...
 
DllExport void AppendCopies (int num, void *el)
 Appends the specified number of elements to the data array. More...
 
DllExport void SwapContents (PerData &from)
 Swaps the contents of this PerData object and the specified one. More...
 
DllExport PerDataoperator= (const PerData &from)
 Assignment operator. More...
 
DllExport void MyDebugPrint ()
 

Public Attributes

int dnum
 The number of elements of per-vertex data. More...
 
int type
 The type of data held by this class. More...
 
int alloc
 The number of elements currently allocated in the data array. More...
 
voiddata
 Points to the actual data. 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...
 

Constructor & Destructor Documentation

PerData ( )
inline

Constructor.

The number of elements is set to 0, the type is set to 0 and the data pointer is set to NULL.

724 { data=NULL; dnum=0; alloc=0; type=0; }
#define NULL
Definition: autoptr.h:18
int dnum
The number of elements of per-vertex data.
Definition: mesh.h:714
int type
The type of data held by this class.
Definition: mesh.h:716
int alloc
The number of elements currently allocated in the data array.
Definition: mesh.h:718
void * data
Points to the actual data.
Definition: mesh.h:720
PerData ( int  n,
int  tp 
)
inline

Constructor.

Parameters
nThe number of elements to allocate.
tpThe type to set.
730 { data=NULL; dnum=0; alloc=0; type=tp; setAlloc (n, FALSE); }
DllExport void setAlloc(int num, BOOL keep=TRUE)
Sets the number of elements allocated in the data array.
#define NULL
Definition: autoptr.h:18
int dnum
The number of elements of per-vertex data.
Definition: mesh.h:714
int type
The type of data held by this class.
Definition: mesh.h:716
int alloc
The number of elements currently allocated in the data array.
Definition: mesh.h:718
void * data
Points to the actual data.
Definition: mesh.h:720
~PerData ( )
inline

Destructor.

Any allocated data is freed and the count and type are set to 0.

733 { Clear (); }
DllExport void Clear()
Clears (deletes) any allocated data and sets the count and type to 0.

Member Function Documentation

DllExport void* AllocData ( int  num)

Allocates and returns a pointer to an array of floats of the specified size.

Parameters
numThe number of floats to allocate.
DllExport void FreeData ( void addr)

Deletes the specified array of floats.

Parameters
addrPointer to the array of floats to free.
DllExport int DataSize ( )

Returns the number of bytes used by the base data type for the vertex data.

This is only implemented for a type of VDATA_TYPE_FLOAT in which case it returns sizeof(float). Other cases simply return 0.

void* Addr ( void ptr,
int  at 
)
inline

Returns the address of the specified element in the array passed.

Parameters
ptrThe array whose at-th element address is returned.
atThe zero based index of the element.
755 { BYTE *vd=(BYTE *)ptr; return (void *)(vd+at*DataSize()); }
DllExport int DataSize()
Returns the number of bytes used by the base data type for the vertex data.
void* Addr ( int  at)
inline

Returns the address of the specified element in the data array.

Parameters
atThe zero based index of the element.
760 { return Addr(data,at); }
void * Addr(void *ptr, int at)
Returns the address of the specified element in the array passed.
Definition: mesh.h:755
void * data
Points to the actual data.
Definition: mesh.h:720
DllExport void CopyData ( void to,
void from,
int  num = 1 
)

Copies the specified number of elements between the two data arrays.

Parameters
toPoints to the destination data array.
fromPoints to the source data array.
numThe number of elements to copy.
DllExport void CopyData ( int  to,
int  from,
int  num = 1 
)

Copies the specified number of elements between the two specified locations in the data array.

Parameters
toThe zero based index into the data array of the destination.
fromThe zero based index into the data array of the source.
numThe number of elements to copy.
DllExport void WeightedSum ( void to,
void fr1,
float  prop1,
void fr2,
float  prop2 
)

Computes the weighted sum of the arguments passed.

This is effectively c = a*prop1 + b*prop2. This is used, for example, in splitting an edge, where we would want to interpolate the vertex weight values from the edge's endpoints to create the weight for the new vertex.

Parameters
toA pointer to the location in which the result should be stored.
fr1A pointer to the first value to be summed.
prop1The weight given to the first value.
fr2A pointer to the second value.
prop2The weight given to the second value.
DllExport void WeightedSum ( int  to,
int  fr1,
float  prop1,
int  fr2,
float  prop2 
)

Computes the weighted sum of the arguments passed.

This is similar to the method above except to, fr1, and fr2 are indices of the values in the PerData array. That is, PerData::WeightedSum (c, a, prop1, b, prop2), where a, b, and c are ints between 0 and PerData::dnum-1, is equivalent to the call PerData::WeightedSum (PerData::Addr(c), PerData::Addr(a), prop1, PerData::Addr(b), prop2).

Parameters
toThe index in the PerData array of the location in which the result should be stored.
fr1The index of the first value to be summed in the PerData array.
prop1The weight given to the first value.
fr2The index of the second value to be summed in the PerData array.
prop2The weight given to the second value.
DllExport void setAlloc ( int  num,
BOOL  keep = TRUE 
)

Sets the number of elements allocated in the data array.

Parameters
numThe number of elements to allocate.
keepIf TRUE previous values are kept (copied to the new storage); otherwise they are discarded. Defaults to TRUE.
void SetCount ( int  num,
BOOL  keep = FALSE 
)
inline

Sets the number of elements allocated in the data array and sets the dnum member to num.

Parameters
numThe number of elements to allocate.
keepIf TRUE previous values are kept (copied to the new storage); otherwise they are discarded. Defaults to FALSE.
814 { setAlloc (num, keep); dnum=num; }
DllExport void setAlloc(int num, BOOL keep=TRUE)
Sets the number of elements allocated in the data array.
int dnum
The number of elements of per-vertex data.
Definition: mesh.h:714
void Shrink ( )
inline

Reduces the size of the data array to contain dnum elements.

818 { if (alloc>dnum) setAlloc(dnum); }
DllExport void setAlloc(int num, BOOL keep=TRUE)
Sets the number of elements allocated in the data array.
int dnum
The number of elements of per-vertex data.
Definition: mesh.h:714
int alloc
The number of elements currently allocated in the data array.
Definition: mesh.h:718
int Count ( )
inline

Returns the number of elements used (dnum)

821 { return dnum; }
int dnum
The number of elements of per-vertex data.
Definition: mesh.h:714
DllExport void Clear ( )

Clears (deletes) any allocated data and sets the count and type to 0.

DllExport void DeleteSet ( BitArray  del)

Removes any element whose corresponding element in the BitArray is not set.

Parameters
delSpecifies which elements to delete. Data elelemts corresponding to bits that are on remain; for bits that are off the elements are deleted.
DllExport void Delete ( int  at,
int  num 
)

Deletes the specified number of elements from the specified location in the data array.

Parameters
atThe location to delete elements.
numThe number of elements to delete.
DllExport void Insert ( int  at,
int  num,
void el 
)

Inserts the specified number of data elements into the specified location in the data array.

Parameters
atThe zero based index of the location for the insert.
numThe number of elements to insert.
elThe data to insert.
DllExport void Append ( int  num,
void el 
)

Appends the specified elements to the data array.

Parameters
numThe number of elements to append.
elThe data to append.
DllExport void InsertCopies ( int  at,
int  num,
void el 
)

Inserts the specified number of elements into the data array at the given location.

Parameters
atThe zero based index of the location to insert the data.
numThe number of elements to insert.
elThe data to insert.
DllExport void AppendCopies ( int  num,
void el 
)

Appends the specified number of elements to the data array.

Parameters
numThe number of elements to append.
elThe data to append.
DllExport void SwapContents ( PerData from)

Swaps the contents of this PerData object and the specified one.

Parameters
fromThe object to swap with.
DllExport PerData& operator= ( const PerData from)

Assignment operator.

Parameters
fromThe VertexData source.
DllExport void MyDebugPrint ( )

Member Data Documentation

int dnum

The number of elements of per-vertex data.

int type

The type of data held by this class.

See Data Types for Mesh Vertices .

int alloc

The number of elements currently allocated in the data array.

void* data

Points to the actual data.