3ds Max C++ API Reference
PerData Class Reference

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

#include <mesh.h>

+ 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...
 
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...
 

Detailed 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.

Constructor & Destructor Documentation

◆ PerData() [1/2]

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.

725 { data=NULL; dnum=0; alloc=0; type=0; }
#define NULL
Definition: autoptr.h:18
void * data
Points to the actual data.
Definition: mesh.h:721
int alloc
The number of elements currently allocated in the data array.
Definition: mesh.h:719
int type
The type of data held by this class.
Definition: mesh.h:717
int dnum
The number of elements of per-vertex data.
Definition: mesh.h:715

◆ PerData() [2/2]

PerData ( int  n,
int  tp 
)
inline

Constructor.

Parameters
nThe number of elements to allocate.
tpThe type to set.
731 { 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.

◆ ~PerData()

~PerData ( )
inline

Destructor.

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

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

Member Function Documentation

◆ AllocData()

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.

◆ FreeData()

DllExport void FreeData ( void addr)

Deletes the specified array of floats.

Parameters
addrPointer to the array of floats to free.

◆ DataSize()

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.

◆ Addr() [1/2]

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.
756 { 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.

◆ Addr() [2/2]

void* Addr ( int  at)
inline

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

Parameters
atThe zero based index of the element.
761 { return Addr(data,at); }
void * Addr(void *ptr, int at)
Returns the address of the specified element in the array passed.
Definition: mesh.h:756

◆ CopyData() [1/2]

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.

◆ CopyData() [2/2]

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.

◆ WeightedSum() [1/2]

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.

◆ WeightedSum() [2/2]

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.

◆ setAlloc()

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.

◆ SetCount()

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.
815 { setAlloc (num, keep); dnum=num; }

◆ Shrink()

void Shrink ( )
inline

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

819 { if (alloc>dnum) setAlloc(dnum); }

◆ Count()

int Count ( )
inline

Returns the number of elements used (dnum)

822 { return dnum; }

◆ Clear()

DllExport void Clear ( )

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

◆ DeleteSet()

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.

◆ Delete()

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.

◆ Insert()

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.

◆ Append()

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.

◆ InsertCopies()

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.

◆ AppendCopies()

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.

◆ SwapContents()

DllExport void SwapContents ( PerData from)

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

Parameters
fromThe object to swap with.

◆ operator=()

DllExport PerData& operator= ( const PerData from)

Assignment operator.

Parameters
fromThe VertexData source.

◆ MyDebugPrint()

DllExport void MyDebugPrint ( )

Member Data Documentation

◆ dnum

int dnum

The number of elements of per-vertex data.

◆ type

int type

The type of data held by this class.

See Data Types for Mesh Vertices .

◆ alloc

int alloc

The number of elements currently allocated in the data array.

◆ data

void* data

Points to the actual data.