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) VTK_OVERRIDE;
40 
45  int 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 
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 
128 
129 protected:
131  ~vtkVoidArray() VTK_OVERRIDE;
132 
133  vtkIdType NumberOfPointers;
134  vtkIdType Size;
135  void** Array; // pointer to data
136 
137  void** ResizeAndExtend(vtkIdType sz); // function to resize data
138 
139 private:
140  vtkVoidArray(const vtkVoidArray&) VTK_DELETE_FUNCTION;
141  void operator=(const vtkVoidArray&) VTK_DELETE_FUNCTION;
142 };
143 
144 
145 #endif
vtkVoidArray::InsertNextVoidPointer
vtkIdType InsertNextVoidPointer(void *tuple)
Insert (memory allocation performed) the void* pointer at the end of the array.
vtkVoidArray::GetPointer
void ** GetPointer(vtkIdType id)
Get the address of a particular data index.
Definition: vtkVoidArray.h:115
vtkVoidArray::GetDataTypeSize
int GetDataTypeSize()
Return the size of the data contained in the array.
Definition: vtkVoidArray.h:60
vtkIdType
int vtkIdType
Definition: vtkType.h:287
vtkVoidArray::InsertVoidPointer
void InsertVoidPointer(vtkIdType i, void *ptr)
Insert (memory allocation performed) the void* into the ith location in the array.
vtkVoidArray::DeepCopy
void DeepCopy(vtkVoidArray *va)
Deep copy of another void array.
VTK_VOID
#define VTK_VOID
Definition: vtkType.h:47
vtkVoidArray
dynamic, self-adjusting array of void* pointers
Definition: vtkVoidArray.h:31
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:60
vtkVoidArray::New
static vtkVoidArray * New()
Initialize with empty array.
vtkVoidArray::GetVoidPointer
void * GetVoidPointer(vtkIdType id)
Get the void* pointer at the ith location.
Definition: vtkVoidArray.h:77
vtkVoidArray::SetVoidPointer
void SetVoidPointer(vtkIdType id, void *ptr)
Set the void* pointer value at the ith location in the array.
Definition: vtkVoidArray.h:83
vtkVoidArray::Squeeze
void Squeeze()
Resize the array to just fit the inserted memory.
Definition: vtkVoidArray.h:108
vtkVoidArray::Initialize
void Initialize()
Release storage and reset array to initial state.
vtkVoidArray::Allocate
int Allocate(vtkIdType sz, vtkIdType ext=1000)
Allocate memory for this array.
vtkVoidArray::GetDataType
int GetDataType()
Return the type of data.
Definition: vtkVoidArray.h:55
vtkVoidArray::Reset
void Reset()
Reuse already allocated data; make the container look like it is empty.
Definition: vtkVoidArray.h:102
vtkVoidArray::WritePointer
void ** WritePointer(vtkIdType id, vtkIdType number)
Get the address of a particular data index.
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:40
vtkVoidArray::vtkVoidArray
vtkVoidArray()
vtkVoidArray::SetNumberOfPointers
void SetNumberOfPointers(vtkIdType number)
Set the number of void* pointers held in the array.
Definition: vtkVoidArray.h:65
vtkObject.h
vtkVoidArray::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkVoidArray::~vtkVoidArray
~vtkVoidArray() override
vtkVoidArray::GetNumberOfPointers
vtkIdType GetNumberOfPointers()
Get the number of void* pointers held in the array.
Definition: vtkVoidArray.h:71