VTK
dox/Common/Core/vtkVoidArray.h
Go to the documentation of this file.
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 "vtkCommonCoreModule.h" // For export macro
00027 #include "vtkObject.h"
00028 
00029 class VTKCOMMONCORE_EXPORT vtkVoidArray : public vtkObject
00030 {
00031 public:
00033   static vtkVoidArray *New();
00034 
00035   vtkTypeMacro(vtkVoidArray,vtkObject);
00036   void PrintSelf(ostream& os, vtkIndent indent);
00037 
00040   int Allocate(vtkIdType sz, vtkIdType ext=1000);
00041 
00043   void Initialize();
00044 
00046   int GetDataType() {return VTK_VOID;}
00047 
00049   int GetDataTypeSize() { return sizeof(void*); }
00050 
00052 
00053   void SetNumberOfPointers(vtkIdType number)
00054     {this->Allocate(number); this->NumberOfPointers = number;}
00056 
00058 
00059   vtkIdType GetNumberOfPointers()
00060     {return this->NumberOfPointers;}
00062 
00064 
00065   void* GetVoidPointer(vtkIdType id)
00066     {return this->Array[id];}
00068 
00070 
00071   void SetVoidPointer(vtkIdType id, void* ptr)
00072     {this->Array[id] = ptr;}
00074 
00077   void InsertVoidPointer(vtkIdType i, void* ptr);
00078 
00081   vtkIdType InsertNextVoidPointer(void* tuple);
00082 
00084 
00086   void Reset()
00087     {this->NumberOfPointers = 0;}
00089 
00091 
00093   void Squeeze()
00094     {this->ResizeAndExtend (this->NumberOfPointers);}
00096 
00099   void** GetPointer(vtkIdType id) {return this->Array + id;}
00100 
00104   void** WritePointer(vtkIdType id, vtkIdType number);
00105 
00107   void DeepCopy(vtkVoidArray *va);
00108 
00109 protected:
00110   vtkVoidArray();
00111   ~vtkVoidArray();
00112 
00113   vtkIdType NumberOfPointers;
00114   vtkIdType Size;
00115   void**    Array;  // pointer to data
00116 
00117   void** ResizeAndExtend(vtkIdType sz);  // function to resize data
00118 
00119 private:
00120   vtkVoidArray(const vtkVoidArray&);  // Not implemented.
00121   void operator=(const vtkVoidArray&);  // Not implemented.
00122 };
00123 
00124 
00125 #endif