31 template <
class ScalarTypeT>
36 typedef ScalarTypeT ScalarType;
54 void (*deleteFunction)(
void*)=free);
93 void operator=(
const vtkBuffer&) =
delete;
96 template <
class ScalarT>
103 template <
typename ScalarT>
108 if (this->Pointer != array)
112 this->DeleteFunction(this->Pointer);
114 this->Pointer = array;
118 this->DeleteFunction = deleteFunction;
122 template <
typename ScalarT>
126 this->SetBuffer(
nullptr, 0);
129 ScalarType* newArray =
130 static_cast<ScalarType*
>(malloc(
size *
sizeof(ScalarType)));
133 this->SetBuffer(newArray,
size,
false, free);
142 template <
typename ScalarT>
145 if (newsize == 0) {
return this->Allocate(0); }
148 (this->Save || this->DeleteFunction != free))
150 ScalarType* newArray =
151 static_cast<ScalarType*
>(malloc(newsize *
sizeof(ScalarType)));
156 std::copy(this->Pointer, this->Pointer + std::min(this->Size, newsize),
159 this->SetBuffer(newArray, newsize,
false, free);
165 ScalarType* newArray =
static_cast<ScalarType*
>(
166 realloc(this->Pointer, newsize *
sizeof(ScalarType)));
171 this->Pointer = newArray;
172 this->Size = newsize;
static vtkBuffer< ScalarTypeT > * New()
vtkIdType GetSize() const
Return the number of elements the current buffer can hold.
const ScalarType * GetBuffer() const
abstract base class for most VTK objects
vtkTemplateTypeMacro(vtkBuffer< ScalarTypeT >, vtkObject) typedef ScalarTypeT ScalarType
void SetBuffer(ScalarType *array, vtkIdType size, bool save=false, void(*deleteFunction)(void *)=free)
Set the memory buffer that this vtkBuffer object will manage.
internal storage class used by vtkSOADataArrayTemplate, vtkAOSDataArrayTemplate, and others...
ScalarType * GetBuffer()
Access the buffer as a scalar pointer.
bool Reallocate(vtkIdType newsize)
Allocate a new buffer that holds newsize elements.
void(* DeleteFunction)(void *)
bool Allocate(vtkIdType size)
Allocate a new buffer that holds size elements.
#define VTK_STANDARD_NEW_BODY(thisClass)
void save(Archiver &ar, const vtkUnicodeString &str, const unsigned int vtkNotUsed(version))