VTK
dox/Common/Core/vtkVariantArray.h
Go to the documentation of this file.
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 
00104   virtual vtkIdType InsertNextTuple(vtkIdType j, vtkAbstractArray* source);
00105 
00108   virtual void *GetVoidPointer(vtkIdType id);
00109 
00112   virtual void DeepCopy(vtkAbstractArray *da);
00113 
00115 
00119   virtual void InterpolateTuple(vtkIdType i, vtkIdList *ptIndices,
00120     vtkAbstractArray* source,  double* weights);
00122 
00124 
00129   virtual void InterpolateTuple(vtkIdType i,
00130     vtkIdType id1, vtkAbstractArray* source1,
00131     vtkIdType id2, vtkAbstractArray* source2, double t);
00133 
00136   virtual void Squeeze();
00137 
00140   virtual int Resize(vtkIdType numTuples);
00141 
00143 
00149   virtual void SetVoidArray(void *arr,
00150                             vtkIdType size,
00151                             int save);
00153 
00160   virtual unsigned long GetActualMemorySize();
00161 
00164   virtual int IsNumeric();
00165 
00168   virtual vtkArrayIterator* NewIterator();
00169 
00170   //
00171   // Additional functions
00172   //
00173 
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 SetVariantValue(vtkIdType idx, vtkVariant value);
00188 
00191   vtkIdType InsertNextValue(vtkVariant value);
00192 
00193   //BTX
00196   vtkVariant* GetPointer(vtkIdType id);
00197 
00199 
00200   void SetArray(vtkVariant* arr, vtkIdType size, int save);
00201   //ETX
00203 
00207   void SetNumberOfValues(vtkIdType number);
00208 
00210   vtkIdType GetNumberOfValues() { return this->MaxId + 1; }
00211 
00213 
00214   virtual vtkIdType LookupValue(vtkVariant value);
00215   virtual void LookupValue(vtkVariant value, vtkIdList* ids);
00217 
00224   virtual void DataChanged();
00225 
00229   virtual void DataElementChanged(vtkIdType id);
00230 
00234   virtual void ClearLookup();
00235 
00238   ~vtkVariantArray();
00239 
00240 protected:
00241   // Construct object with default tuple dimension (number of components) of 1.
00242   vtkVariantArray(vtkIdType numComp=1);
00243 
00244   // Pointer to data
00245   //BTX
00246   vtkVariant* Array;
00247 
00248   // Function to resize data
00249   vtkVariant* ResizeAndExtend(vtkIdType sz);
00250   //ETX
00251 
00252   int SaveUserArray;
00253 
00254 private:
00255   vtkVariantArray(const vtkVariantArray&);  // Not implemented.
00256   void operator=(const vtkVariantArray&);  // Not implemented.
00257 
00258   vtkVariantArrayLookup* Lookup;
00259   void UpdateLookup();
00260 };
00261 
00262 #endif