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
30class VTKCOMMONCORE_EXPORT vtkVoidArray : public vtkObject
31{
32public:
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
129protected:
131 ~vtkVoidArray() VTK_OVERRIDE;
132
133 vtkIdType NumberOfPointers;
135 void** Array; // pointer to data
136
137 void** ResizeAndExtend(vtkIdType sz); // function to resize data
138
139private:
140 vtkVoidArray(const vtkVoidArray&) VTK_DELETE_FUNCTION;
141 void operator=(const vtkVoidArray&) VTK_DELETE_FUNCTION;
142};
143
144
145#endif
a simple class to control print indentation
Definition: vtkIndent.h:40
abstract base class for most VTK objects
Definition: vtkObject.h:60
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:115
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
static vtkVoidArray * New()
Initialize with empty array.
~vtkVoidArray() override
void SetVoidPointer(vtkIdType id, void *ptr)
Set the void* pointer value at the ith location in the array.
Definition: vtkVoidArray.h:83
void SetNumberOfPointers(vtkIdType number)
Set the number of void* pointers held in the array.
Definition: vtkVoidArray.h:65
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:71
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:102
void DeepCopy(vtkVoidArray *va)
Deep copy of another void array.
int Allocate(vtkIdType sz, vtkIdType ext=1000)
Allocate memory for this array.
void * GetVoidPointer(vtkIdType id)
Get the void* pointer at the ith location.
Definition: vtkVoidArray.h:77
int GetDataTypeSize()
Return the size of the data contained in the array.
Definition: vtkVoidArray.h:60
int vtkIdType
Definition: vtkType.h:287
#define VTK_VOID
Definition: vtkType.h:47