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) override;
53 
54  //
55  // Functions required by vtkAbstractArray
56  //
57 
62  int Allocate(vtkIdType sz, vtkIdType ext=1000) override;
63 
67  void Initialize() override;
68 
73  int GetDataType() override;
74 
80  int GetDataTypeSize() override;
81 
89  int GetElementComponentSize() override;
90 
95  void SetNumberOfTuples(vtkIdType number) override;
96 
103  void SetTuple(vtkIdType i, vtkIdType j,
104  vtkAbstractArray* source) override;
105 
110  void InsertTuple(vtkIdType i, vtkIdType j,
111  vtkAbstractArray* source) override;
112 
118  void InsertTuples(vtkIdList *dstIds, vtkIdList *srcIds,
119  vtkAbstractArray *source) override;
120 
126  void InsertTuples(vtkIdType dstStart, vtkIdType n, vtkIdType srcStart,
127  vtkAbstractArray* source) override;
128 
135 
140  void *GetVoidPointer(vtkIdType id) override;
141 
147  void DeepCopy(vtkAbstractArray *da) override;
148 
156  void InterpolateTuple(vtkIdType i, vtkIdList *ptIndices,
157  vtkAbstractArray* source, double* weights) override;
158 
168  vtkIdType id1, vtkAbstractArray* source1,
169  vtkIdType id2, vtkAbstractArray* source2, double t) override;
170 
176  void Squeeze() override;
177 
182  int Resize(vtkIdType numTuples) override;
183 
185 
193  void SetVoidArray(void *arr, vtkIdType size, int save) override;
194  void SetVoidArray(void *arr, vtkIdType size, int save,
195  int deleteM) override;
197 
206  unsigned long GetActualMemorySize() override;
207 
211  int IsNumeric() override;
212 
218 
219  //
220  // Additional functions
221  //
222 
226  vtkVariant & GetValue(vtkIdType id) const;
227 
232  void SetValue(vtkIdType id, vtkVariant value)
233  VTK_EXPECTS(0 <= id && id < this->GetNumberOfValues());
234 
240  void InsertValue(vtkIdType id, vtkVariant value)
241  VTK_EXPECTS(0 <= id);
242 
246  void SetVariantValue(vtkIdType idx, vtkVariant value) override;
247 
251  void InsertVariantValue(vtkIdType idx, vtkVariant value) override;
252 
257  vtkIdType InsertNextValue(vtkVariant value);
258 
262  vtkVariant* GetPointer(vtkIdType id);
263 
267  void SetArray(vtkVariant* arr, vtkIdType size, int save);
268 
274  void SetNumberOfValues(vtkIdType number) override;
275 
279  vtkIdType GetNumberOfValues() { return this->MaxId + 1; }
280 
282 
286  void LookupValue(vtkVariant value, vtkIdList* ids) override;
288 
297  void DataChanged() override;
298 
304  virtual void DataElementChanged(vtkIdType id);
305 
311  void ClearLookup() override;
312 
317  ~vtkVariantArray() override;
318 
319 protected:
320  // Construct object with default tuple dimension (number of components) of 1.
321  vtkVariantArray();
322 
323  // Pointer to data
324 
326 
327  // Function to resize data
328  vtkVariant* ResizeAndExtend(vtkIdType sz);
329 
331 
332 private:
333  vtkVariantArray(const vtkVariantArray&) = delete;
334  void operator=(const vtkVariantArray&) = delete;
335 
336  vtkVariantArrayLookup* Lookup;
337  void UpdateLookup();
338 };
339 
340 #endif
virtual int IsNumeric()=0
This method is here to make backward compatibility easier.
vtkIdType GetNumberOfValues() const
Get the total number of values in the array.
Forward declaration required for Boost serialization.
virtual void DataChanged()=0
Tell the array explicitly that the data has changed.
virtual void DeepCopy(vtkAbstractArray *da)
Deep copy of data.
virtual void * GetVoidPointer(vtkIdType valueIdx)=0
Return a void pointer.
An array holding vtkVariants.
Abstract superclass for all arrays.
virtual vtkIdType LookupValue(vtkVariant value)=0
Return the value indices where a specific value appears.
virtual int GetDataTypeSize()=0
Return the size of the underlying data type.
virtual void SetNumberOfValues(vtkIdType numValues)
Specify the number of values (tuples * components) for this object to hold.
virtual int GetDataType()=0
Return the underlying data type.
int vtkIdType
Definition: vtkType.h:345
virtual void InterpolateTuple(vtkIdType dstTupleIdx, vtkIdList *ptIndices, vtkAbstractArray *source, double *weights)=0
Set the tuple at dstTupleIdx in this array to the interpolated tuple value, given the ptIndices in th...
virtual void SetVoidArray(void *vtkNotUsed(array), vtkIdType vtkNotUsed(size), int vtkNotUsed(save))=0
This method lets the user specify data to be held by the array.
virtual void Initialize()=0
Release storage and reset array to initial state.
A atomic type representing the union of many types.
Definition: vtkVariant.h:65
vtkIdType GetNumberOfValues()
Return the number of values in the array.
virtual void ClearLookup()=0
Delete the associated fast lookup data structure on this array, if it exists.
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkVariant * Array
list of point or cell ids
Definition: vtkIdList.h:30
virtual int Resize(vtkIdType numTuples)=0
Resize the array to the requested number of tuples and preserve data.
virtual vtkArrayIterator * NewIterator()=0
Subclasses must override this method and provide the right kind of templated vtkArrayIteratorTemplate...
virtual void InsertVariantValue(vtkIdType valueIdx, vtkVariant value)=0
Insert a value into the array from a variant.
Abstract superclass to iterate over elements in an vtkAbstractArray.
#define VTK_NEWINSTANCE
virtual void InsertTuple(vtkIdType dstTupleIdx, vtkIdType srcTupleIdx, vtkAbstractArray *source)=0
Insert the tuple at srcTupleIdx in the source array into this array at dstTupleIdx.
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 *)
virtual vtkIdType InsertNextTuple(vtkIdType srcTupleIdx, vtkAbstractArray *source)=0
Insert the tuple from srcTupleIdx in the source array at the end of this array.
virtual void SetTuple(vtkIdType dstTupleIdx, vtkIdType srcTupleIdx, vtkAbstractArray *source)=0
Set the tuple at dstTupleIdx in this array to the tuple at srcTupleIdx in the source array.
virtual unsigned long GetActualMemorySize()=0
Return the memory in kibibytes (1024 bytes) consumed by this data array.
virtual void SetNumberOfTuples(vtkIdType numTuples)=0
Set the number of tuples (a component group) in the array.
virtual void Squeeze()=0
Free any unnecessary memory.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
virtual int GetElementComponentSize()=0
Return the size, in bytes, of the lowest-level element of an array.
#define VTK_EXPECTS(x)
virtual void SetVariantValue(vtkIdType valueIdx, vtkVariant value)=0
Set a value in the array from a variant.
virtual void InsertTuples(vtkIdList *dstIds, vtkIdList *srcIds, vtkAbstractArray *source)=0
Copy the tuples indexed in srcIds from the source array to the tuple locations indexed by dstIds in t...
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.