VTK
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 
30 class VTKCOMMONCORE_EXPORT vtkVoidArray : public vtkObject
31 {
32 public:
36  static vtkVoidArray *New();
37 
38  vtkTypeMacro(vtkVoidArray,vtkObject);
39  void PrintSelf(ostream& os, vtkIndent indent) override;
40 
45  vtkTypeBool Allocate(vtkIdType sz, vtkIdType ext=1000);
46 
50  void Initialize();
51 
55  int GetDataType() {return VTK_VOID;}
56 
60  int GetDataTypeSize() { return sizeof(void*); }
61 
66  {this->Allocate(number); this->NumberOfPointers = number;}
67 
72  {return this->NumberOfPointers;}
73 
78  {return this->Array[id];}
79 
83  void SetVoidPointer(vtkIdType id, void* ptr)
84  {this->Array[id] = ptr;}
85 
90  void InsertVoidPointer(vtkIdType i, void* ptr);
91 
96  vtkIdType InsertNextVoidPointer(void* tuple);
97 
102  void Reset()
103  {this->NumberOfPointers = 0;}
104 
108  void Squeeze()
109  {this->ResizeAndExtend (this->NumberOfPointers);}
110 
115  void** GetPointer(vtkIdType id) {return this->Array + id;}
116 
122  void** WritePointer(vtkIdType id, vtkIdType number);
123 
127  void DeepCopy(vtkVoidArray *va);
128 
129 protected:
130  vtkVoidArray();
131  ~vtkVoidArray() override;
132 
135  void** Array; // pointer to data
136 
137  void** ResizeAndExtend(vtkIdType sz); // function to resize data
138 
139 private:
140  vtkVoidArray(const vtkVoidArray&) = delete;
141  void operator=(const vtkVoidArray&) = delete;
142 };
143 
144 
145 #endif
vtkIdType GetNumberOfPointers()
Get the number of void* pointers held in the array.
Definition: vtkVoidArray.h:71
void * GetVoidPointer(vtkIdType id)
Get the void* pointer at the ith location.
Definition: vtkVoidArray.h:77
dynamic, self-adjusting array of void* pointers
Definition: vtkVoidArray.h:30
abstract base class for most VTK objects
Definition: vtkObject.h:59
#define VTK_VOID
Definition: vtkType.h:47
void SetVoidPointer(vtkIdType id, void *ptr)
Set the void* pointer value at the ith location in the array.
Definition: vtkVoidArray.h:83
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
int GetDataType()
Return the type of data.
Definition: vtkVoidArray.h:55
void ** GetPointer(vtkIdType id)
Get the address of a particular data index.
Definition: vtkVoidArray.h:115
void Reset()
Reuse already allocated data; make the container look like it is empty.
Definition: vtkVoidArray.h:102
int vtkIdType
Definition: vtkType.h:347
int GetDataTypeSize()
Return the size of the data contained in the array.
Definition: vtkVoidArray.h:60
vtkIdType NumberOfPointers
Definition: vtkVoidArray.h:133
int vtkTypeBool
Definition: vtkABI.h:69
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkIdType Size
Definition: vtkVoidArray.h:134
void ** Array
Definition: vtkVoidArray.h:135
void SetNumberOfPointers(vtkIdType number)
Set the number of void* pointers held in the array.
Definition: vtkVoidArray.h:65
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...