VTK  9.0.1
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 "vtkAbstractArray.h"
35 #include "vtkCommonCoreModule.h" // For export macro
36 #include "vtkVariant.h" // For variant type
37 
38 class vtkVariantArrayLookup;
39 
41 namespace boost
42 {
43 namespace serialization
44 {
45 class access;
46 }
47 }
48 
49 class VTKCOMMONCORE_EXPORT vtkVariantArray : public vtkAbstractArray
50 {
51 
53  friend class boost::serialization::access;
54 
55 public:
57  {
59  VTK_DATA_ARRAY_DELETE = vtkAbstractArray::VTK_DATA_ARRAY_DELETE,
60  VTK_DATA_ARRAY_ALIGNED_FREE = vtkAbstractArray::VTK_DATA_ARRAY_ALIGNED_FREE,
61  VTK_DATA_ARRAY_USER_DEFINED = vtkAbstractArray::VTK_DATA_ARRAY_USER_DEFINED
62  };
63 
64  static vtkVariantArray* New();
66  void PrintSelf(ostream& os, vtkIndent indent) override;
67 
68  //
69  // Functions required by vtkAbstractArray
70  //
71 
76  vtkTypeBool Allocate(vtkIdType sz, vtkIdType ext = 1000) override;
77 
81  void Initialize() override;
82 
87  int GetDataType() const override;
88 
94  int GetDataTypeSize() const override;
95 
103  int GetElementComponentSize() const override;
104 
109  void SetNumberOfTuples(vtkIdType number) override;
110 
117  void SetTuple(vtkIdType i, vtkIdType j, vtkAbstractArray* source) override;
118 
123  void InsertTuple(vtkIdType i, vtkIdType j, vtkAbstractArray* source) override;
124 
130  void InsertTuples(vtkIdList* dstIds, vtkIdList* srcIds, vtkAbstractArray* source) override;
131 
137  void InsertTuples(
138  vtkIdType dstStart, vtkIdType n, vtkIdType srcStart, 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(
168  vtkIdType i, vtkIdList* ptIndices, vtkAbstractArray* source, double* weights) override;
169 
178  void InterpolateTuple(vtkIdType i, vtkIdType id1, vtkAbstractArray* source1, vtkIdType id2,
179  vtkAbstractArray* source2, double t) override;
180 
186  void Squeeze() override;
187 
192  vtkTypeBool Resize(vtkIdType numTuples) override;
193 
195 
203  void SetVoidArray(void* arr, vtkIdType size, int save) override;
204  void SetVoidArray(void* arr, vtkIdType size, int save, int deleteM) override;
206 
215  unsigned long GetActualMemorySize() const override;
216 
220  int IsNumeric() const override;
221 
226  VTK_NEWINSTANCE vtkArrayIterator* NewIterator() override;
227 
228  //
229  // Additional functions
230  //
231 
235  vtkVariant& GetValue(vtkIdType id) const;
236 
241  void SetValue(vtkIdType id, vtkVariant value)
242  VTK_EXPECTS(0 <= id && id < this->GetNumberOfValues());
243 
249  void InsertValue(vtkIdType id, vtkVariant value) VTK_EXPECTS(0 <= id);
250 
254  void SetVariantValue(vtkIdType idx, vtkVariant value) override;
255 
259  void InsertVariantValue(vtkIdType idx, vtkVariant value) override;
260 
265  vtkIdType InsertNextValue(vtkVariant value);
266 
270  vtkVariant* GetPointer(vtkIdType id);
271 
275  void SetArray(
276  vtkVariant* arr, vtkIdType size, int save, int deleteMethod = VTK_DATA_ARRAY_DELETE);
277 
284  void SetArrayFreeFunction(void (*callback)(void*)) override;
285 
289  vtkIdType GetNumberOfValues() { return this->MaxId + 1; }
290 
292 
295  vtkIdType LookupValue(vtkVariant value) override;
296  void LookupValue(vtkVariant value, vtkIdList* ids) override;
298 
307  void DataChanged() override;
308 
314  virtual void DataElementChanged(vtkIdType id);
315 
321  void ClearLookup() override;
322 
327  ~vtkVariantArray() override;
328 
329 protected:
330  // Construct object with default tuple dimension (number of components) of 1.
331  vtkVariantArray();
332 
333  // Pointer to data
334 
336 
337  // Function to resize data
338  vtkVariant* ResizeAndExtend(vtkIdType sz);
339 
340  void (*DeleteFunction)(void*);
341 
342 private:
343  vtkVariantArray(const vtkVariantArray&) = delete;
344  void operator=(const vtkVariantArray&) = delete;
345 
346  vtkVariantArrayLookup* Lookup;
347  void UpdateLookup();
348 };
349 
350 #endif
Forward declaration required for Boost serialization.
An array holding vtkVariants.
Abstract superclass for all arrays.
int vtkIdType
Definition: vtkType.h:338
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph *>::edge_descriptor e, vtkGraph *)
A atomic type representing the union of many types.
Definition: vtkVariant.h:65
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:33
vtkVariant * Array
list of point or cell ids
Definition: vtkIdList.h:30
Abstract superclass to iterate over elements in an vtkAbstractArray.
#define VTK_NEWINSTANCE
void save(Archiver &ar, const vtkUnicodeString &str, const unsigned int vtkNotUsed(version))
#define VTK_EXPECTS(x)