VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkVariantArray.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 =========================================================================*/ 00015 /*------------------------------------------------------------------------- 00016 Copyright 2008 Sandia Corporation. 00017 Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, 00018 the U.S. Government retains certain rights in this software. 00019 -------------------------------------------------------------------------*/ 00033 #ifndef __vtkVariantArray_h 00034 #define __vtkVariantArray_h 00035 00036 #include "vtkAbstractArray.h" 00037 #include "vtkVariant.h" // For variant type 00038 00039 class vtkVariantArrayLookup; 00040 00041 //BTX 00043 namespace boost { namespace serialization { class access; } } 00044 //ETX 00045 00046 class VTK_COMMON_EXPORT vtkVariantArray : public vtkAbstractArray 00047 { 00048 //BTX 00050 friend class boost::serialization::access; 00051 //ETX 00052 00053 public: 00054 static vtkVariantArray* New(); 00055 vtkTypeMacro(vtkVariantArray,vtkAbstractArray); 00056 void PrintSelf(ostream& os, vtkIndent indent); 00057 00058 // 00059 // Functions required by vtkAbstractArray 00060 // 00061 00064 virtual int Allocate(vtkIdType sz, vtkIdType ext=1000); 00065 00067 virtual void Initialize(); 00068 00071 virtual int GetDataType(); 00072 00076 virtual int GetDataTypeSize(); 00077 00082 virtual int GetElementComponentSize(); 00083 00086 virtual void SetNumberOfTuples(vtkIdType number); 00087 00093 virtual void SetTuple(vtkIdType i, vtkIdType j, vtkAbstractArray* source); 00094 00098 virtual void InsertTuple(vtkIdType i, vtkIdType j, vtkAbstractArray* source); 00099 00103 virtual vtkIdType InsertNextTuple(vtkIdType j, vtkAbstractArray* source); 00104 00107 virtual void *GetVoidPointer(vtkIdType id); 00108 00111 virtual void DeepCopy(vtkAbstractArray *da); 00112 00114 00118 virtual void InterpolateTuple(vtkIdType i, vtkIdList *ptIndices, 00119 vtkAbstractArray* source, double* weights); 00121 00123 00128 virtual void InterpolateTuple(vtkIdType i, 00129 vtkIdType id1, vtkAbstractArray* source1, 00130 vtkIdType id2, vtkAbstractArray* source2, double t); 00132 00135 virtual void Squeeze(); 00136 00139 virtual int Resize(vtkIdType numTuples); 00140 00142 00148 virtual void SetVoidArray(void *arr, 00149 vtkIdType size, 00150 int save); 00152 00159 virtual unsigned long GetActualMemorySize(); 00160 00163 virtual int IsNumeric(); 00164 00167 virtual vtkArrayIterator* NewIterator(); 00168 00169 // 00170 // Additional functions 00171 // 00172 00173 //BTX 00175 vtkVariant & GetValue(vtkIdType id) const; 00176 00179 void SetValue(vtkIdType id, vtkVariant value); 00180 00184 void InsertValue(vtkIdType id, vtkVariant value); 00185 00187 void InsertVariantValue(vtkIdType idx, vtkVariant value); 00188 00191 vtkIdType InsertNextValue(vtkVariant value); 00192 00195 vtkVariant* GetPointer(vtkIdType id); 00196 00198 00199 void SetArray(vtkVariant* arr, vtkIdType size, int save); 00200 //ETX 00202 00206 void SetNumberOfValues(vtkIdType number); 00207 00209 vtkIdType GetNumberOfValues() { return this->MaxId + 1; } 00210 00211 //BTX 00213 00214 virtual vtkIdType LookupValue(vtkVariant value); 00215 virtual void LookupValue(vtkVariant value, vtkIdList* ids); 00216 //ETX 00218 00225 virtual void DataChanged(); 00226 00230 virtual void DataElementChanged(vtkIdType id); 00231 00235 virtual void ClearLookup(); 00236 00239 ~vtkVariantArray(); 00240 00241 protected: 00242 // Construct object with default tuple dimension (number of components) of 1. 00243 vtkVariantArray(vtkIdType numComp=1); 00244 00245 // Pointer to data 00246 //BTX 00247 vtkVariant* Array; 00248 00249 // Function to resize data 00250 vtkVariant* ResizeAndExtend(vtkIdType sz); 00251 //ETX 00252 00253 int SaveUserArray; 00254 00255 private: 00256 vtkVariantArray(const vtkVariantArray&); // Not implemented. 00257 void operator=(const vtkVariantArray&); // Not implemented. 00258 00259 //BTX 00260 vtkVariantArrayLookup* Lookup; 00261 void UpdateLookup(); 00262 //ETX 00263 }; 00264 00265 #endif