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 "vtkCommonCoreModule.h" // For export macro 00037 #include "vtkAbstractArray.h" 00038 #include "vtkVariant.h" // For variant type 00039 00040 class vtkVariantArrayLookup; 00041 00042 //BTX 00044 namespace boost { namespace serialization { class access; } } 00045 //ETX 00046 00047 class VTKCOMMONCORE_EXPORT vtkVariantArray : public vtkAbstractArray 00048 { 00049 //BTX 00051 friend class boost::serialization::access; 00052 //ETX 00053 00054 public: 00055 static vtkVariantArray* New(); 00056 vtkTypeMacro(vtkVariantArray,vtkAbstractArray); 00057 void PrintSelf(ostream& os, vtkIndent indent); 00058 00059 // 00060 // Functions required by vtkAbstractArray 00061 // 00062 00065 virtual int Allocate(vtkIdType sz, vtkIdType ext=1000); 00066 00068 virtual void Initialize(); 00069 00072 virtual int GetDataType(); 00073 00077 virtual int GetDataTypeSize(); 00078 00083 virtual int GetElementComponentSize(); 00084 00087 virtual void SetNumberOfTuples(vtkIdType number); 00088 00094 virtual void SetTuple(vtkIdType i, vtkIdType j, vtkAbstractArray* source); 00095 00099 virtual void InsertTuple(vtkIdType i, vtkIdType j, vtkAbstractArray* source); 00100 00102 00105 virtual void InsertTuples(vtkIdList *dstIds, vtkIdList *srcIds, 00106 vtkAbstractArray *source); 00108 00112 virtual vtkIdType InsertNextTuple(vtkIdType j, vtkAbstractArray* source); 00113 00116 virtual void *GetVoidPointer(vtkIdType id); 00117 00120 virtual void DeepCopy(vtkAbstractArray *da); 00121 00123 00127 virtual void InterpolateTuple(vtkIdType i, vtkIdList *ptIndices, 00128 vtkAbstractArray* source, double* weights); 00130 00132 00137 virtual void InterpolateTuple(vtkIdType i, 00138 vtkIdType id1, vtkAbstractArray* source1, 00139 vtkIdType id2, vtkAbstractArray* source2, double t); 00141 00144 virtual void Squeeze(); 00145 00148 virtual int Resize(vtkIdType numTuples); 00149 00151 00157 virtual void SetVoidArray(void *arr, 00158 vtkIdType size, 00159 int save); 00161 00168 virtual unsigned long GetActualMemorySize(); 00169 00172 virtual int IsNumeric(); 00173 00176 virtual vtkArrayIterator* NewIterator(); 00177 00178 // 00179 // Additional functions 00180 // 00181 00183 vtkVariant & GetValue(vtkIdType id) const; 00184 00187 void SetValue(vtkIdType id, vtkVariant value); 00188 00192 void InsertValue(vtkIdType id, vtkVariant value); 00193 00195 void SetVariantValue(vtkIdType idx, vtkVariant value); 00196 00199 vtkIdType InsertNextValue(vtkVariant value); 00200 00201 //BTX 00204 vtkVariant* GetPointer(vtkIdType id); 00205 00207 00208 void SetArray(vtkVariant* arr, vtkIdType size, int save); 00209 //ETX 00211 00215 void SetNumberOfValues(vtkIdType number); 00216 00218 vtkIdType GetNumberOfValues() { return this->MaxId + 1; } 00219 00221 00222 virtual vtkIdType LookupValue(vtkVariant value); 00223 virtual void LookupValue(vtkVariant value, vtkIdList* ids); 00225 00232 virtual void DataChanged(); 00233 00237 virtual void DataElementChanged(vtkIdType id); 00238 00242 virtual void ClearLookup(); 00243 00246 ~vtkVariantArray(); 00247 00248 protected: 00249 // Construct object with default tuple dimension (number of components) of 1. 00250 vtkVariantArray(); 00251 00252 // Pointer to data 00253 //BTX 00254 vtkVariant* Array; 00255 00256 // Function to resize data 00257 vtkVariant* ResizeAndExtend(vtkIdType sz); 00258 //ETX 00259 00260 int SaveUserArray; 00261 00262 private: 00263 vtkVariantArray(const vtkVariantArray&); // Not implemented. 00264 void operator=(const vtkVariantArray&); // Not implemented. 00265 00266 vtkVariantArrayLookup* Lookup; 00267 void UpdateLookup(); 00268 }; 00269 00270 #endif