3ds Max C++ API Reference
BufferProxy< ElementType > Class Template Reference

#include <triangulate.h>

+ Inheritance diagram for BufferProxy< ElementType >:

Public Member Functions

 BufferProxy ()
 Initializes all members to zero, an invalid empty buffer. More...
 
 BufferProxy (ElementType *data, size_t numElements, size_t stride=sizeof(ElementType))
 
size_t Count () const
 Retrieves the number of elements in the buffer. More...
 
size_t Stride () const
 Retrieves the element stride. More...
 
bool IsValid () const
 Retrieves whether the buffer points to actual memory. More...
 
bool IsEmpty () const
 Retrieves whether the buffer is empty or not. More...
 
ElementType & operator[] (size_t i)
 
const ElementType & operator[] (size_t i) const
 

Protected Attributes

ElementType * mData
 A pointer to the first element in the buffer. More...
 
size_t mNumElements
 The number of elements contained in the buffer. More...
 
size_t mStride
 Each element in the buffer is mStride bytes apart. 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

template<typename ElementType>
class MaxSDK::BufferProxy< ElementType >

See also
Class BufferProxy.

Description:
This class wraps a raw memory buffer and it allows individual access to elements each located with a given stride in bytes. e.g. to iterate over every MNMesh vertex position: MaxSDK::BufferProxy<const Point3> meshVerticesBuffer(mnmeshVertices, numv, sizeof(MNVert));

Constructor & Destructor Documentation

◆ BufferProxy() [1/2]

BufferProxy ( )
inline

Initializes all members to zero, an invalid empty buffer.

39  : mData(nullptr)
40  , mNumElements(0)
41  , mStride(0)
42  {
43  }
ElementType * mData
A pointer to the first element in the buffer.
Definition: triangulate.h:107
size_t mStride
Each element in the buffer is mStride bytes apart.
Definition: triangulate.h:113
size_t mNumElements
The number of elements contained in the buffer.
Definition: triangulate.h:110

◆ BufferProxy() [2/2]

BufferProxy ( ElementType *  data,
size_t  numElements,
size_t  stride = sizeof(ElementType) 
)
inline
Remarks
Constructor. mData, mNumElements, and mStride are initialized to the values specified.
Parameters
data- initial value for mData
numElements- initial value for mNumElements
stride- initial value for mStride
51  : mData(data)
52  , mNumElements(numElements)
53  , mStride(stride)
54  {
55  }

Member Function Documentation

◆ Count()

size_t Count ( ) const
inline

Retrieves the number of elements in the buffer.

Returns
The number of elements in the buffer.
60  {
61  return mNumElements;
62  }

◆ Stride()

size_t Stride ( ) const
inline

Retrieves the element stride.

Returns
The element stride.
67  {
68  return mStride;
69  }

◆ IsValid()

bool IsValid ( ) const
inline

Retrieves whether the buffer points to actual memory.

Returns
The buffer is valid or not.
74  {
75  return mData != nullptr;
76  }

◆ IsEmpty()

bool IsEmpty ( ) const
inline

Retrieves whether the buffer is empty or not.

Returns
Whether the buffer is empty or not.
81  {
82  return mNumElements != 0;
83  }

◆ operator[]() [1/2]

ElementType& operator[] ( size_t  i)
inline
Remarks
Allows access to an element of the buffer using the subscript operator.
Returns
The element at the provided index.
88  {
89  DbgAssert(IsValid() && i < mNumElements);
90  intptr_t rawData = reinterpret_cast<intptr_t>(mData);
91  intptr_t elementPtr = rawData + (i * mStride);
92  return *reinterpret_cast<ElementType*>(elementPtr);
93  }
bool IsValid() const
Retrieves whether the buffer points to actual memory.
Definition: triangulate.h:73
#define DbgAssert(expr)
Definition: assert1.h:82

◆ operator[]() [2/2]

const ElementType& operator[] ( size_t  i) const
inline
Remarks
Allows access to an element of the buffer using the subscript operator.
Returns
The element at the provided index.
98  {
99  DbgAssert(IsValid() && i < mNumElements);
100  intptr_t rawData = reinterpret_cast<intptr_t>(mData);
101  intptr_t elementPtr = rawData + (i * mStride);
102  return *reinterpret_cast<const ElementType*>(elementPtr);
103  }

Member Data Documentation

◆ mData

ElementType* mData
protected

A pointer to the first element in the buffer.

◆ mNumElements

size_t mNumElements
protected

The number of elements contained in the buffer.

◆ mStride

size_t mStride
protected

Each element in the buffer is mStride bytes apart.