31template <
class ScalarTypeT>
36 typedef ScalarTypeT ScalarType;
98 void operator=(
const vtkBuffer&) VTK_DELETE_FUNCTION;
101template <
class ScalarT>
108template <
typename ScalarT>
113 if (this->Pointer != array)
117 if (this->DeleteMethod == VTK_DATA_ARRAY_FREE)
123 delete [] this->Pointer;
126 this->Pointer = array;
130 this->DeleteMethod = deleteMethod;
134template <
typename ScalarT>
138 this->SetBuffer(NULL, 0);
141 ScalarType* newArray =
142 static_cast<ScalarType*
>(malloc(
size *
sizeof(ScalarType)));
145 this->SetBuffer(newArray,
size,
false, VTK_DATA_ARRAY_FREE);
154template <
typename ScalarT>
157 if (newsize == 0) {
return this->Allocate(0); }
160 (this->Save || this->DeleteMethod == VTK_DATA_ARRAY_DELETE))
162 ScalarType* newArray =
163 static_cast<ScalarType*
>(malloc(newsize *
sizeof(ScalarType)));
168 std::copy(this->Pointer, this->Pointer + std::min(this->Size, newsize),
171 this->SetBuffer(newArray, newsize,
false, VTK_DATA_ARRAY_FREE);
177 ScalarType* newArray =
static_cast<ScalarType*
>(
178 realloc(this->Pointer, newsize *
sizeof(ScalarType)));
183 this->Pointer = newArray;
184 this->Size = newsize;
internal storage class used by vtkSOADataArrayTemplate, vtkAOSDataArrayTemplate, and others.
bool Reallocate(vtkIdType newsize)
Allocate a new buffer that holds newsize elements.
ScalarType * GetBuffer()
Access the buffer as a scalar pointer.
const ScalarType * GetBuffer() const
vtkTemplateTypeMacro(vtkBuffer< ScalarTypeT >, vtkObject) typedef ScalarTypeT ScalarType
vtkIdType GetSize() const
Return the number of elements the current buffer can hold.
bool Allocate(vtkIdType size)
Allocate a new buffer that holds size elements.
void SetBuffer(ScalarType *array, vtkIdType size, bool save=false, int deleteMethod=VTK_DATA_ARRAY_FREE)
Set the memory buffer that this vtkBuffer object will manage.
static vtkBuffer< ScalarTypeT > * New()
abstract base class for most VTK objects
#define VTK_STANDARD_NEW_BODY(thisClass)
void save(Archiver &ar, const vtkUnicodeString &str, const unsigned int vtkNotUsed(version))