VTK  9.1.0
vtkVoidArray.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkVoidArray.h
5
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 All rights reserved.
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the above copyright notice for more information.
13
14=========================================================================*/
24#ifndef vtkVoidArray_h
25#define vtkVoidArray_h
26
27#include "vtkCommonCoreModule.h" // For export macro
28#include "vtkObject.h"
29
30class VTKCOMMONCORE_EXPORT vtkVoidArray : public vtkObject
31{
32public:
36 static vtkVoidArray* New();
38
39 vtkTypeMacro(vtkVoidArray, vtkObject);
40 void PrintSelf(ostream& os, vtkIndent indent) override;
41
47
51 void Initialize();
52
56 int GetDataType() const { return VTK_VOID; }
57
61 int GetDataTypeSize() { return sizeof(void*); }
62
67 {
68 this->Allocate(number);
69 this->NumberOfPointers = number;
70 }
71
75 vtkIdType GetNumberOfPointers() { return this->NumberOfPointers; }
76
80 void* GetVoidPointer(vtkIdType id) { return this->Array[id]; }
81
85 void SetVoidPointer(vtkIdType id, void* ptr) { this->Array[id] = ptr; }
86
91 void InsertVoidPointer(vtkIdType i, void* ptr);
92
98
103 void Reset() { this->NumberOfPointers = 0; }
104
108 void Squeeze() { this->ResizeAndExtend(this->NumberOfPointers); }
109
114 void** GetPointer(vtkIdType id) { return this->Array + id; }
115
121 void** WritePointer(vtkIdType id, vtkIdType number);
122
127
128protected:
130 ~vtkVoidArray() override;
131
134 void** Array; // pointer to data
135
136 void** ResizeAndExtend(vtkIdType sz); // function to resize data
137
138private:
139 vtkVoidArray(const vtkVoidArray&) = delete;
140 void operator=(const vtkVoidArray&) = delete;
141};
142
143#endif
a simple class to control print indentation
Definition: vtkIndent.h:113
abstract base class for most VTK objects
Definition: vtkObject.h:82
dynamic, self-adjusting array of void* pointers
Definition: vtkVoidArray.h:31
vtkIdType InsertNextVoidPointer(void *tuple)
Insert (memory allocation performed) the void* pointer at the end of the array.
void ** GetPointer(vtkIdType id)
Get the address of a particular data index.
Definition: vtkVoidArray.h:114
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void Squeeze()
Resize the array to just fit the inserted memory.
Definition: vtkVoidArray.h:108
static vtkVoidArray * New()
Initialize with empty array.
~vtkVoidArray() override
void ** ResizeAndExtend(vtkIdType sz)
void SetVoidPointer(vtkIdType id, void *ptr)
Set the void* pointer value at the ith location in the array.
Definition: vtkVoidArray.h:85
void SetNumberOfPointers(vtkIdType number)
Set the number of void* pointers held in the array.
Definition: vtkVoidArray.h:66
void Initialize()
Release storage and reset array to initial state.
void ** WritePointer(vtkIdType id, vtkIdType number)
Get the address of a particular data index.
vtkIdType GetNumberOfPointers()
Get the number of void* pointers held in the array.
Definition: vtkVoidArray.h:75
vtkIdType NumberOfPointers
Definition: vtkVoidArray.h:132
void InsertVoidPointer(vtkIdType i, void *ptr)
Insert (memory allocation performed) the void* into the ith location in the array.
void Reset()
Reuse already allocated data; make the container look like it is empty.
Definition: vtkVoidArray.h:103
void DeepCopy(vtkVoidArray *va)
Deep copy of another void array.
void ** Array
Definition: vtkVoidArray.h:134
void * GetVoidPointer(vtkIdType id)
Get the void* pointer at the ith location.
Definition: vtkVoidArray.h:80
int GetDataType() const
Return the type of data.
Definition: vtkVoidArray.h:56
vtkIdType Size
Definition: vtkVoidArray.h:133
vtkTypeBool Allocate(vtkIdType sz, vtkIdType ext=1000)
Allocate memory for this array.
int GetDataTypeSize()
Return the size of the data contained in the array.
Definition: vtkVoidArray.h:61
static vtkVoidArray * ExtendedNew()
int vtkTypeBool
Definition: vtkABI.h:69
int vtkIdType
Definition: vtkType.h:332
#define VTK_VOID
Definition: vtkType.h:43