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 -------------------------------------------------------------------------*/
34 #ifndef vtkVariantArray_h
35 #define vtkVariantArray_h
36 
37 #include "vtkCommonCoreModule.h" // For export macro
38 #include "vtkAbstractArray.h"
39 #include "vtkVariant.h" // For variant type
40 
41 class vtkVariantArrayLookup;
42 
44 namespace boost { namespace serialization { class access; } }
45 
46 class VTKCOMMONCORE_EXPORT vtkVariantArray : public vtkAbstractArray
47 {
48 
50  friend class boost::serialization::access;
51 
52 public:
53  static vtkVariantArray* New();
55  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
56 
57  //
58  // Functions required by vtkAbstractArray
59  //
60 
65  int Allocate(vtkIdType sz, vtkIdType ext=1000) VTK_OVERRIDE;
66 
70  void Initialize() VTK_OVERRIDE;
71 
76  int GetDataType() VTK_OVERRIDE;
77 
83  int GetDataTypeSize() VTK_OVERRIDE;
84 
92  int GetElementComponentSize() VTK_OVERRIDE;
93 
98  void SetNumberOfTuples(vtkIdType number) VTK_OVERRIDE;
99 
106  void SetTuple(vtkIdType i, vtkIdType j,
107  vtkAbstractArray* source) VTK_OVERRIDE;
108 
113  void InsertTuple(vtkIdType i, vtkIdType j,
114  vtkAbstractArray* source) VTK_OVERRIDE;
115 
121  void InsertTuples(vtkIdList *dstIds, vtkIdList *srcIds,
122  vtkAbstractArray *source) VTK_OVERRIDE;
123 
129  void InsertTuples(vtkIdType dstStart, vtkIdType n, vtkIdType srcStart,
130  vtkAbstractArray* source) VTK_OVERRIDE;
131 
137  vtkIdType InsertNextTuple(vtkIdType j, vtkAbstractArray* source) VTK_OVERRIDE;
138 
143  void *GetVoidPointer(vtkIdType id) VTK_OVERRIDE;
144 
150  void DeepCopy(vtkAbstractArray *da) VTK_OVERRIDE;
151 
159  void InterpolateTuple(vtkIdType i, vtkIdList *ptIndices,
160  vtkAbstractArray* source, double* weights) VTK_OVERRIDE;
161 
170  void InterpolateTuple(vtkIdType i,
171  vtkIdType id1, vtkAbstractArray* source1,
172  vtkIdType id2, vtkAbstractArray* source2, double t) VTK_OVERRIDE;
173 
179  void Squeeze() VTK_OVERRIDE;
180 
185  int Resize(vtkIdType numTuples) VTK_OVERRIDE;
186 
188 
196  void SetVoidArray(void *arr, vtkIdType size, int save) VTK_OVERRIDE;
197  void SetVoidArray(void *arr, vtkIdType size, int save,
198  int deleteM) VTK_OVERRIDE;
200 
209  unsigned long GetActualMemorySize() VTK_OVERRIDE;
210 
214  int IsNumeric() VTK_OVERRIDE;
215 
220  VTK_NEWINSTANCE vtkArrayIterator* NewIterator() VTK_OVERRIDE;
221 
222  //
223  // Additional functions
224  //
225 
229  vtkVariant & GetValue(vtkIdType id) const;
230 
235  void SetValue(vtkIdType id, vtkVariant value);
236 
242  void InsertValue(vtkIdType id, vtkVariant value);
243 
247  void SetVariantValue(vtkIdType idx, vtkVariant value) VTK_OVERRIDE;
248 
252  void InsertVariantValue(vtkIdType idx, vtkVariant value) VTK_OVERRIDE;
253 
258  vtkIdType InsertNextValue(vtkVariant value);
259 
263  vtkVariant* GetPointer(vtkIdType id);
264 
268  void SetArray(vtkVariant* arr, vtkIdType size, int save);
269 
275  void SetNumberOfValues(vtkIdType number) VTK_OVERRIDE;
276 
280  vtkIdType GetNumberOfValues() { return this->MaxId + 1; }
281 
283 
287  void LookupValue(vtkVariant value, vtkIdList* ids) VTK_OVERRIDE;
289 
298  void DataChanged() VTK_OVERRIDE;
299 
305  virtual void DataElementChanged(vtkIdType id);
306 
312  void ClearLookup() VTK_OVERRIDE;
313 
318  ~vtkVariantArray() VTK_OVERRIDE;
319 
320 protected:
321  // Construct object with default tuple dimension (number of components) of 1.
323 
324  // Pointer to data
325 
326  vtkVariant* Array;
327 
328  // Function to resize data
329  vtkVariant* ResizeAndExtend(vtkIdType sz);
330 
331  int SaveUserArray;
332 
333 private:
334  vtkVariantArray(const vtkVariantArray&) VTK_DELETE_FUNCTION;
335  void operator=(const vtkVariantArray&) VTK_DELETE_FUNCTION;
336 
337  vtkVariantArrayLookup* Lookup;
338  void UpdateLookup();
339 };
340 
341 #endif
Abstract superclass for all arrays.
Abstract superclass to iterate over elements in an vtkAbstractArray.
list of point or cell ids
Definition: vtkIdList.h:37
a simple class to control print indentation
Definition: vtkIndent.h:40
An array holding vtkVariants.
static vtkVariantArray * New()
vtkIdType LookupValue(vtkVariant value) override
Return the indices where a specific value appears.
void LookupValue(vtkVariant value, vtkIdList *ids) override
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void DataChanged() override
Tell the array explicitly that the data has changed.
int Allocate(vtkIdType sz, vtkIdType ext=1000) override
Allocate memory for this array.
A atomic type representing the union of many types.
Definition: vtkVariant.h:76
Forward declaration required for Boost serialization.
@ value
Definition: vtkX3D.h:220
@ size
Definition: vtkX3D.h:253
void DeepCopy(vtkPistonReference *self, vtkPistonReference *other)
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
int vtkIdType
Definition: vtkType.h:287
void save(Archiver &ar, const vtkUnicodeString &str, const unsigned int vtkNotUsed(version))
#define VTK_NEWINSTANCE