VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkVoidArray.h 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00023 #ifndef __vtkVoidArray_h 00024 #define __vtkVoidArray_h 00025 00026 #include "vtkObject.h" 00027 00028 class VTK_COMMON_EXPORT vtkVoidArray : public vtkObject 00029 { 00030 public: 00032 static vtkVoidArray *New(); 00033 00034 vtkTypeMacro(vtkVoidArray,vtkObject); 00035 void PrintSelf(ostream& os, vtkIndent indent); 00036 00039 int Allocate(vtkIdType sz, vtkIdType ext=1000); 00040 00042 void Initialize(); 00043 00045 int GetDataType() {return VTK_VOID;} 00046 00048 int GetDataTypeSize() { return sizeof(void*); } 00049 00051 00052 void SetNumberOfPointers(vtkIdType number) 00053 {this->Allocate(number); this->NumberOfPointers = number;} 00055 00057 00058 vtkIdType GetNumberOfPointers() 00059 {return this->NumberOfPointers;} 00061 00063 00064 void* GetVoidPointer(vtkIdType id) 00065 {return this->Array[id];} 00067 00069 00070 void SetVoidPointer(vtkIdType id, void* ptr) 00071 {this->Array[id] = ptr;} 00073 00076 void InsertVoidPointer(vtkIdType i, void* ptr); 00077 00080 vtkIdType InsertNextVoidPointer(void* tuple); 00081 00083 00085 void Reset() 00086 {this->NumberOfPointers = 0;} 00088 00090 00092 void Squeeze() 00093 {this->ResizeAndExtend (this->NumberOfPointers);} 00095 00098 void** GetPointer(vtkIdType id) {return this->Array + id;} 00099 00103 void** WritePointer(vtkIdType id, vtkIdType number); 00104 00106 void DeepCopy(vtkVoidArray *va); 00107 00108 protected: 00109 vtkVoidArray(); 00110 ~vtkVoidArray(); 00111 00112 vtkIdType NumberOfPointers; 00113 vtkIdType Size; 00114 void** Array; // pointer to data 00115 00116 void** ResizeAndExtend(vtkIdType sz); // function to resize data 00117 00118 private: 00119 vtkVoidArray(const vtkVoidArray&); // Not implemented. 00120 void operator=(const vtkVoidArray&); // Not implemented. 00121 }; 00122 00123 00124 #endif