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:
54  {
57  VTK_DATA_ARRAY_ALIGNED_FREE=vtkAbstractArray::VTK_DATA_ARRAY_ALIGNED_FREE,
59  };
60 
61  static vtkVariantArray* New();
63  void PrintSelf(ostream& os, vtkIndent indent) override;
64 
65  //
66  // Functions required by vtkAbstractArray
67  //
68 
73  vtkTypeBool Allocate(vtkIdType sz, vtkIdType ext=1000) override;
74 
78  void Initialize() override;
79 
84  int GetDataType() override;
85 
91  int GetDataTypeSize() override;
92 
100  int GetElementComponentSize() override;
101 
106  void SetNumberOfTuples(vtkIdType number) override;
107 
114  void SetTuple(vtkIdType i, vtkIdType j,
115  vtkAbstractArray* source) override;
116 
121  void InsertTuple(vtkIdType i, vtkIdType j,
122  vtkAbstractArray* source) override;
123 
129  void InsertTuples(vtkIdList *dstIds, vtkIdList *srcIds,
130  vtkAbstractArray *source) override;
131 
137  void InsertTuples(vtkIdType dstStart, vtkIdType n, vtkIdType srcStart,
138  vtkAbstractArray* source) override;
139 
145  vtkIdType InsertNextTuple(vtkIdType j, vtkAbstractArray* source) override;
146 
151  void *GetVoidPointer(vtkIdType id) override;
152 
158  void DeepCopy(vtkAbstractArray *da) override;
159 
167  void InterpolateTuple(vtkIdType i, vtkIdList *ptIndices,
168  vtkAbstractArray* source, double* weights) override;
169 
178  void InterpolateTuple(vtkIdType i,
179  vtkIdType id1, vtkAbstractArray* source1,
180  vtkIdType id2, vtkAbstractArray* source2, double t) override;
181 
187  void Squeeze() override;
188 
193  vtkTypeBool Resize(vtkIdType numTuples) override;
194 
196 
204  void SetVoidArray(void *arr, vtkIdType size, int save) override;
205  void SetVoidArray(void *arr, vtkIdType size, int save,
206  int deleteM) override;
208 
217  unsigned long GetActualMemorySize() override;
218 
222  int IsNumeric() override;
223 
228  VTK_NEWINSTANCE vtkArrayIterator* NewIterator() override;
229 
230  //
231  // Additional functions
232  //
233 
237  vtkVariant & GetValue(vtkIdType id) const;
238 
243  void SetValue(vtkIdType id, vtkVariant value)
244  VTK_EXPECTS(0 <= id && id < this->GetNumberOfValues());
245 
251  void InsertValue(vtkIdType id, vtkVariant value)
252  VTK_EXPECTS(0 <= id);
253 
257  void SetVariantValue(vtkIdType idx, vtkVariant value) override;
258 
262  void InsertVariantValue(vtkIdType idx, vtkVariant value) override;
263 
268  vtkIdType InsertNextValue(vtkVariant value);
269 
273  vtkVariant* GetPointer(vtkIdType id);
274 
278  void SetArray(vtkVariant* arr, vtkIdType size, int save, int deleteMethod=VTK_DATA_ARRAY_DELETE);
279 
286  void SetArrayFreeFunction(void (*callback)(void *)) override;
287 
293  void SetNumberOfValues(vtkIdType number) override;
294 
298  vtkIdType GetNumberOfValues() { return this->MaxId + 1; }
299 
301 
304  vtkIdType LookupValue(vtkVariant value) override;
305  void LookupValue(vtkVariant value, vtkIdList* ids) override;
307 
316  void DataChanged() override;
317 
323  virtual void DataElementChanged(vtkIdType id);
324 
330  void ClearLookup() override;
331 
336  ~vtkVariantArray() override;
337 
338 protected:
339  // Construct object with default tuple dimension (number of components) of 1.
340  vtkVariantArray();
341 
342  // Pointer to data
343 
345 
346  // Function to resize data
347  vtkVariant* ResizeAndExtend(vtkIdType sz);
348 
349  void (*DeleteFunction)(void*);
350 
351 private:
352  vtkVariantArray(const vtkVariantArray&) = delete;
353  void operator=(const vtkVariantArray&) = delete;
354 
355  vtkVariantArrayLookup* Lookup;
356  void UpdateLookup();
357 };
358 
359 #endif
Forward declaration required for Boost serialization.
An array holding vtkVariants.
Abstract superclass for all arrays.
int vtkIdType
Definition: vtkType.h:347
A atomic type representing the union of many types.
Definition: vtkVariant.h:71
int vtkTypeBool
Definition: vtkABI.h:69
vtkIdType GetNumberOfValues()
Return the number of values in the array.
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkVariant * Array
list of point or cell ids
Definition: vtkIdList.h:36
Abstract superclass to iterate over elements in an vtkAbstractArray.
#define VTK_NEWINSTANCE
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 *)
#define VTK_EXPECTS(x)