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,
58  VTK_DATA_ARRAY_USER_DEFINED=vtkAbstractArray::VTK_DATA_ARRAY_USER_DEFINED
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 
115  vtkAbstractArray* source) override;
116 
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 
146 
151  void *GetVoidPointer(vtkIdType id) override;
152 
158  void DeepCopy(vtkAbstractArray *da) override;
159 
168  vtkAbstractArray* source, double* weights) override;
169 
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 
229 
230  //
231  // Additional functions
232  //
233 
238 
244  VTK_EXPECTS(0 <= id && id < this->GetNumberOfValues());
245 
252  VTK_EXPECTS(0 <= id);
253 
258 
263 
269 
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 
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.
341 
342  // Pointer to data
343 
345 
346  // Function to resize data
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
vtkAbstractArray::DeleteMethod
DeleteMethod
Definition: vtkAbstractArray.h:334
vtkAbstractArray::VTK_DATA_ARRAY_ALIGNED_FREE
@ VTK_DATA_ARRAY_ALIGNED_FREE
Definition: vtkAbstractArray.h:337
vtkVariant.h
vtkVariantArray::GetPointer
vtkVariant * GetPointer(vtkIdType id)
Return a pointer to the location in the internal array at the specified index.
vtkVariantArray::SetNumberOfValues
void SetNumberOfValues(vtkIdType number) override
Specify the number of values for this object to hold.
vtkVariantArray::DeepCopy
void DeepCopy(vtkAbstractArray *da) override
Deep copy of data.
VTK_EXPECTS
#define VTK_EXPECTS(x)
Definition: vtkWrappingHints.h:41
vtkX3D::value
@ value
Definition: vtkX3D.h:220
vtkAbstractArray::VTK_DATA_ARRAY_DELETE
@ VTK_DATA_ARRAY_DELETE
Definition: vtkAbstractArray.h:336
vtkIdType
int vtkIdType
Definition: vtkType.h:347
vtkVariantArray::GetVoidPointer
void * GetVoidPointer(vtkIdType id) override
Return a void pointer.
vtkVariantArray::GetValue
vtkVariant & GetValue(vtkIdType id) const
Get the data at a particular index.
vtkVariantArray::Initialize
void Initialize() override
Release storage and reset array to initial state.
vtkVariantArray::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
save
void save(Archiver &ar, const vtkUnicodeString &str, const unsigned int vtkNotUsed(version))
Definition: vtkVariantBoostSerialization.h:65
vtkAbstractArray::VTK_DATA_ARRAY_FREE
@ VTK_DATA_ARRAY_FREE
Definition: vtkAbstractArray.h:335
vtkVariantArray::DataChanged
void DataChanged() override
Tell the array explicitly that the data has changed.
vtkVariantArray::InsertNextTuple
vtkIdType InsertNextTuple(vtkIdType j, vtkAbstractArray *source) override
Insert the jth tuple in the source array, at the end in this array.
boost
Forward declaration required for Boost serialization.
Definition: vtkVariantArray.h:44
vtkVariantArray
An array holding vtkVariants.
Definition: vtkVariantArray.h:47
vtkVariantArray::ResizeAndExtend
vtkVariant * ResizeAndExtend(vtkIdType sz)
vtkVariantArray::GetNumberOfValues
vtkIdType GetNumberOfValues()
Return the number of values in the array.
Definition: vtkVariantArray.h:298
vtkVariantArray::InterpolateTuple
void InterpolateTuple(vtkIdType i, vtkIdType id1, vtkAbstractArray *source1, vtkIdType id2, vtkAbstractArray *source2, double t) override
Insert the ith tuple in this array as interpolated from the two values, p1 and p2,...
vtkAbstractArray.h
vtkVariantArray::SetVariantValue
void SetVariantValue(vtkIdType idx, vtkVariant value) override
Insert a value into the array from a variant.
vtkVariantArray::SetNumberOfTuples
void SetNumberOfTuples(vtkIdType number) override
Set the number of tuples (a component group) in the array.
vtkVariantArray::GetDataType
int GetDataType() override
Return the underlying data type.
vtkVariantArray::Allocate
vtkTypeBool Allocate(vtkIdType sz, vtkIdType ext=1000) override
Allocate memory for this array.
vtkVariantArray::LookupValue
vtkIdType LookupValue(vtkVariant value) override
Return the indices where a specific value appears.
vtkVariantArray::~vtkVariantArray
~vtkVariantArray() override
This destructor is public to work around a bug in version 1.36.0 of the Boost.Serialization library.
source
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
Definition: vtkBoostGraphAdapter.h:825
vtkVariantArray::InsertTuples
void InsertTuples(vtkIdType dstStart, vtkIdType n, vtkIdType srcStart, vtkAbstractArray *source) override
Copy n consecutive tuples starting at srcStart from the source array to this array,...
vtkAbstractArray::GetNumberOfValues
vtkIdType GetNumberOfValues() const
Get the total number of values in the array.
Definition: vtkAbstractArray.h:183
vtkVariantArray::InsertTuples
void InsertTuples(vtkIdList *dstIds, vtkIdList *srcIds, vtkAbstractArray *source) override
Copy the tuples indexed in srcIds from the source array to the tuple locations indexed by dstIds in t...
vtkVariantArray::SetVoidArray
void SetVoidArray(void *arr, vtkIdType size, int save) override
This method lets the user specify data to be held by the array.
vtkVariantArray::InsertValue
void InsertValue(vtkIdType id, vtkVariant value)
If id < GetNumberOfValues(), overwrite the array at that index.
vtkVariantArray::InterpolateTuple
void InterpolateTuple(vtkIdType i, vtkIdList *ptIndices, vtkAbstractArray *source, double *weights) override
Set the ith tuple in this array as the interpolated tuple value, given the ptIndices in the source ar...
vtkVariantArray::Squeeze
void Squeeze() override
Free any unnecessary memory.
vtkVariantArray::SetArrayFreeFunction
void SetArrayFreeFunction(void(*callback)(void *)) override
This method allows the user to specify a custom free function to be called when the array is dealloca...
vtkVariantArray::SetValue
void SetValue(vtkIdType id, vtkVariant value)
Set the data at a particular index.
vtkAbstractArray::VTK_DATA_ARRAY_USER_DEFINED
@ VTK_DATA_ARRAY_USER_DEFINED
Definition: vtkAbstractArray.h:338
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:40
vtkVariantArray::SetArray
void SetArray(vtkVariant *arr, vtkIdType size, int save, int deleteMethod=VTK_DATA_ARRAY_DELETE)
Set the internal array used by this object.
vtkVariantArray::InsertTuple
void InsertTuple(vtkIdType i, vtkIdType j, vtkAbstractArray *source) override
Insert the jth tuple in the source array, at ith location in this array.
vtkVariant
A atomic type representing the union of many types.
Definition: vtkVariant.h:72
vtkIdList
list of point or cell ids
Definition: vtkIdList.h:37
vtkVariantArray::IsNumeric
int IsNumeric() override
Since each item can be of a different type, we say that a variant array is not numeric.
vtkX3D::size
@ size
Definition: vtkX3D.h:253
vtkVariantArray::Resize
vtkTypeBool Resize(vtkIdType numTuples) override
Resize the array while conserving the data.
vtkVariantArray::LookupValue
void LookupValue(vtkVariant value, vtkIdList *ids) override
vtkVariantArray::GetDataTypeSize
int GetDataTypeSize() override
Return the size of the underlying data type.
vtkVariantArray::New
static vtkVariantArray * New()
vtkVariantArray::InsertNextValue
vtkIdType InsertNextValue(vtkVariant value)
Expand the array by one and set the value at that location.
vtkVariantArray::vtkVariantArray
vtkVariantArray()
vtkVariantArray::InsertVariantValue
void InsertVariantValue(vtkIdType idx, vtkVariant value) override
Safely insert a value into the array from a variant.
vtkVariantArray::GetElementComponentSize
int GetElementComponentSize() override
Return the size, in bytes, of the lowest-level element of an array.
vtkAbstractArray
Abstract superclass for all arrays.
Definition: vtkAbstractArray.h:79
vtkVariantArray::Array
vtkVariant * Array
Definition: vtkVariantArray.h:344
vtkVariantArray::DataElementChanged
virtual void DataElementChanged(vtkIdType id)
Tell the array explicitly that a single data element has changed.
vtkVariantArray::SetTuple
void SetTuple(vtkIdType i, vtkIdType j, vtkAbstractArray *source) override
Set the tuple at the ith location using the jth tuple in the source array.
vtkArrayIterator
Abstract superclass to iterate over elements in an vtkAbstractArray.
Definition: vtkArrayIterator.h:53
vtkVariantArray::NewIterator
vtkArrayIterator * NewIterator() override
Subclasses must override this method and provide the right kind of templated vtkArrayIteratorTemplate...
vtkVariantArray::ClearLookup
void ClearLookup() override
Delete the associated fast lookup data structure on this array, if it exists.
VTK_NEWINSTANCE
#define VTK_NEWINSTANCE
Definition: vtkWrappingHints.h:39
vtkVariantArray::GetActualMemorySize
unsigned long GetActualMemorySize() override
Return the memory in kibibytes (1024 bytes) consumed by this data array.
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkVariantArray::SetVoidArray
void SetVoidArray(void *arr, vtkIdType size, int save, int deleteM) override