VTK
vtkVariantArray.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkVariantArray.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
15 /*-------------------------------------------------------------------------
16  Copyright 2008 Sandia Corporation.
17  Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
18  the U.S. Government retains certain rights in this software.
19 -------------------------------------------------------------------------*/
31 #ifndef vtkVariantArray_h
32 #define vtkVariantArray_h
33 
34 #include "vtkCommonCoreModule.h" // For export macro
35 #include "vtkAbstractArray.h"
36 #include "vtkVariant.h" // For variant type
37 
38 class vtkVariantArrayLookup;
39 
41 namespace boost { namespace serialization { class access; } }
42 
43 class VTKCOMMONCORE_EXPORT vtkVariantArray : public vtkAbstractArray
44 {
45 
47  friend class boost::serialization::access;
48 
49 public:
50  static vtkVariantArray* New();
52  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
53 
54  //
55  // Functions required by vtkAbstractArray
56  //
57 
62  int Allocate(vtkIdType sz, vtkIdType ext=1000) VTK_OVERRIDE;
63 
67  void Initialize() VTK_OVERRIDE;
68 
73  int GetDataType() VTK_OVERRIDE;
74 
80  int GetDataTypeSize() VTK_OVERRIDE;
81 
89  int GetElementComponentSize() VTK_OVERRIDE;
90 
95  void SetNumberOfTuples(vtkIdType number) VTK_OVERRIDE;
96 
103  void SetTuple(vtkIdType i, vtkIdType j,
104  vtkAbstractArray* source) VTK_OVERRIDE;
105 
110  void InsertTuple(vtkIdType i, vtkIdType j,
111  vtkAbstractArray* source) VTK_OVERRIDE;
112 
118  void InsertTuples(vtkIdList *dstIds, vtkIdList *srcIds,
119  vtkAbstractArray *source) VTK_OVERRIDE;
120 
126  void InsertTuples(vtkIdType dstStart, vtkIdType n, vtkIdType srcStart,
127  vtkAbstractArray* source) VTK_OVERRIDE;
128 
134  vtkIdType InsertNextTuple(vtkIdType j, vtkAbstractArray* source) VTK_OVERRIDE;
135 
140  void *GetVoidPointer(vtkIdType id) VTK_OVERRIDE;
141 
147  void DeepCopy(vtkAbstractArray *da) VTK_OVERRIDE;
148 
156  void InterpolateTuple(vtkIdType i, vtkIdList *ptIndices,
157  vtkAbstractArray* source, double* weights) VTK_OVERRIDE;
158 
167  void InterpolateTuple(vtkIdType i,
168  vtkIdType id1, vtkAbstractArray* source1,
169  vtkIdType id2, vtkAbstractArray* source2, double t) VTK_OVERRIDE;
170 
176  void Squeeze() VTK_OVERRIDE;
177 
182  int Resize(vtkIdType numTuples) VTK_OVERRIDE;
183 
185 
193  void SetVoidArray(void *arr, vtkIdType size, int save) VTK_OVERRIDE;
194  void SetVoidArray(void *arr, vtkIdType size, int save,
195  int deleteM) VTK_OVERRIDE;
197 
206  unsigned long GetActualMemorySize() VTK_OVERRIDE;
207 
211  int IsNumeric() VTK_OVERRIDE;
212 
217  VTK_NEWINSTANCE vtkArrayIterator* NewIterator() VTK_OVERRIDE;
218 
219  //
220  // Additional functions
221  //
222 
226  vtkVariant & GetValue(vtkIdType id) const;
227 
232  void SetValue(vtkIdType id, vtkVariant value);
233 
239  void InsertValue(vtkIdType id, vtkVariant value);
240 
244  void SetVariantValue(vtkIdType idx, vtkVariant value) VTK_OVERRIDE;
245 
249  void InsertVariantValue(vtkIdType idx, vtkVariant value) VTK_OVERRIDE;
250 
255  vtkIdType InsertNextValue(vtkVariant value);
256 
260  vtkVariant* GetPointer(vtkIdType id);
261 
265  void SetArray(vtkVariant* arr, vtkIdType size, int save);
266 
272  void SetNumberOfValues(vtkIdType number) VTK_OVERRIDE;
273 
277  vtkIdType GetNumberOfValues() { return this->MaxId + 1; }
278 
280 
283  vtkIdType LookupValue(vtkVariant value) VTK_OVERRIDE;
284  void LookupValue(vtkVariant value, vtkIdList* ids) VTK_OVERRIDE;
286 
295  void DataChanged() VTK_OVERRIDE;
296 
302  virtual void DataElementChanged(vtkIdType id);
303 
309  void ClearLookup() VTK_OVERRIDE;
310 
315  ~vtkVariantArray() VTK_OVERRIDE;
316 
317 protected:
318  // Construct object with default tuple dimension (number of components) of 1.
319  vtkVariantArray();
320 
321  // Pointer to data
322 
323  vtkVariant* Array;
324 
325  // Function to resize data
326  vtkVariant* ResizeAndExtend(vtkIdType sz);
327 
328  int SaveUserArray;
329 
330 private:
331  vtkVariantArray(const vtkVariantArray&) VTK_DELETE_FUNCTION;
332  void operator=(const vtkVariantArray&) VTK_DELETE_FUNCTION;
333 
334  vtkVariantArrayLookup* Lookup;
335  void UpdateLookup();
336 };
337 
338 #endif
Forward declaration required for Boost serialization.
virtual void DataChanged()=0
Tell the array explicitly that the data has changed.
An array holding vtkVariants.
Abstract superclass for all arrays.
virtual vtkIdType LookupValue(vtkVariant value)=0
Return the value indices where a specific value appears.
int vtkIdType
Definition: vtkType.h:345
A atomic type representing the union of many types.
Definition: vtkVariant.h:69
a simple class to control print indentation
Definition: vtkIndent.h:33
list of point or cell ids
Definition: vtkIdList.h:30
Abstract superclass to iterate over elements in an vtkAbstractArray.
#define VTK_NEWINSTANCE
virtual int Allocate(vtkIdType numValues, vtkIdType ext=1000)=0
Allocate memory for this array.
void save(Archiver &ar, const vtkUnicodeString &str, const unsigned int vtkNotUsed(version))
boost::graph_traits< vtkGraph *>::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.