VTK
dox/Common/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 -------------------------------------------------------------------------*/
00036 #ifndef __vtkVariantArray_h
00037 #define __vtkVariantArray_h
00038 
00039 #include "vtkAbstractArray.h"
00040 #include "vtkVariant.h" // For variant type
00041 
00042 class vtkVariantArrayLookup;
00043 
00044 //BTX
00046 namespace boost { namespace serialization { class access; } }
00047 //ETX
00048 
00049 class VTK_COMMON_EXPORT vtkVariantArray : public vtkAbstractArray
00050 {
00051 //BTX
00053   friend class boost::serialization::access;
00054 //ETX
00055 
00056 public:
00057   static vtkVariantArray* New();
00058   vtkTypeMacro(vtkVariantArray,vtkAbstractArray);
00059   void PrintSelf(ostream& os, vtkIndent indent);
00060 
00061   // 
00062   // Functions required by vtkAbstractArray
00063   //
00064 
00067   virtual int Allocate(vtkIdType sz, vtkIdType ext=1000);
00068 
00070   virtual void Initialize();
00071 
00074   virtual int GetDataType();
00075 
00079   virtual int GetDataTypeSize();
00080 
00085   virtual int GetElementComponentSize();
00086 
00089   virtual void SetNumberOfTuples(vtkIdType number);
00090 
00096   virtual void SetTuple(vtkIdType i, vtkIdType j, vtkAbstractArray* source);
00097 
00101   virtual void InsertTuple(vtkIdType i, vtkIdType j, vtkAbstractArray* source);
00102 
00106   virtual vtkIdType InsertNextTuple(vtkIdType j, vtkAbstractArray* source);
00107   
00110   virtual void *GetVoidPointer(vtkIdType id);
00111 
00114   virtual void DeepCopy(vtkAbstractArray *da);
00115 
00117 
00121   virtual void InterpolateTuple(vtkIdType i, vtkIdList *ptIndices,
00122     vtkAbstractArray* source,  double* weights);
00124 
00126 
00131   virtual void InterpolateTuple(vtkIdType i, 
00132     vtkIdType id1, vtkAbstractArray* source1, 
00133     vtkIdType id2, vtkAbstractArray* source2, double t);
00135     
00138   virtual void Squeeze(); 
00139 
00142   virtual int Resize(vtkIdType numTuples);
00143 
00145 
00151   virtual void SetVoidArray(void *arr,
00152                             vtkIdType size,
00153                             int save);
00155 
00162   virtual unsigned long GetActualMemorySize();
00163   
00166   virtual int IsNumeric();
00167 
00170   virtual vtkArrayIterator* NewIterator();
00171 
00172   //
00173   // Additional functions
00174   //
00175 
00177   vtkVariant & GetValue(vtkIdType id) const;
00178 
00181   void SetValue(vtkIdType id, vtkVariant value);
00182 
00186   void InsertValue(vtkIdType id, vtkVariant value);
00187 
00189   void SetVariantValue(vtkIdType idx, vtkVariant value);
00190 
00193   vtkIdType InsertNextValue(vtkVariant value);
00194 
00195   //BTX
00198   vtkVariant* GetPointer(vtkIdType id);
00199 
00201 
00202   void SetArray(vtkVariant* arr, vtkIdType size, int save);
00203   //ETX
00205 
00209   void SetNumberOfValues(vtkIdType number);
00210 
00212   vtkIdType GetNumberOfValues() { return this->MaxId + 1; }
00213 
00215 
00216   virtual vtkIdType LookupValue(vtkVariant value);
00217   virtual void LookupValue(vtkVariant value, vtkIdList* ids);
00219   
00226   virtual void DataChanged();
00227 
00231   virtual void DataElementChanged(vtkIdType id);
00232 
00236   virtual void ClearLookup();
00237 
00240   ~vtkVariantArray();
00241   
00242 protected:
00243   // Construct object with default tuple dimension (number of components) of 1.
00244   vtkVariantArray(vtkIdType numComp=1);
00245 
00246   // Pointer to data
00247   //BTX
00248   vtkVariant* Array;
00249 
00250   // Function to resize data
00251   vtkVariant* ResizeAndExtend(vtkIdType sz);
00252   //ETX
00253 
00254   int SaveUserArray;
00255 
00256 private:
00257   vtkVariantArray(const vtkVariantArray&);  // Not implemented.
00258   void operator=(const vtkVariantArray&);  // Not implemented.
00259 
00260   vtkVariantArrayLookup* Lookup;
00261   void UpdateLookup();
00262 };
00263 
00264 #endif