Thanks to visit codestin.com
Credit goes to vtk.org

VTK  9.5.20250922
vtkVariantArray.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-FileCopyrightText: Copyright 2008 Sandia Corporation
3// SPDX-License-Identifier: LicenseRef-BSD-3-Clause-Sandia-USGov
87#ifndef vtkVariantArray_h
88#define vtkVariantArray_h
89
90#include "vtkAbstractArray.h"
91#include "vtkCommonCoreModule.h" // For export macro
92#include "vtkVariant.h" // For variant type
93#include "vtkWrappingHints.h" // For VTK_MARSHALMANUAL
94
96namespace boost
97{
98namespace serialization
99{
100class access;
101}
102}
103
104VTK_ABI_NAMESPACE_BEGIN
105class vtkVariantArrayLookup;
106
107class VTKCOMMONCORE_EXPORT VTK_MARSHALMANUAL vtkVariantArray : public vtkAbstractArray
108{
109
111 friend class boost::serialization::access;
112
113public:
115 {
119 VTK_DATA_ARRAY_USER_DEFINED = vtkAbstractArray::VTK_DATA_ARRAY_USER_DEFINED
120 };
121
125 void PrintSelf(ostream& os, vtkIndent indent) override;
126
127 //
128 // Functions required by vtkAbstractArray
129 //
130
135 vtkTypeBool Allocate(vtkIdType sz, vtkIdType ext = 1000) override;
136
140 void Initialize() override;
141
146 bool CopyComponent(int dstComponent, vtkAbstractArray* src, int srcComponent) override;
147
152 int GetDataType() const override;
153
159 int GetDataTypeSize() const override;
160
168 int GetElementComponentSize() const override;
169
174 void SetNumberOfTuples(vtkIdType number) override;
175
183
189
195 void InsertTuples(vtkIdList* dstIds, vtkIdList* srcIds, vtkAbstractArray* source) override;
196
198 vtkIdType dstStart, vtkIdList* srcIds, vtkAbstractArray* source) override;
199
206 vtkIdType dstStart, vtkIdType n, vtkIdType srcStart, vtkAbstractArray* source) override;
207
214
219 void* GetVoidPointer(vtkIdType id) override;
220
226 void DeepCopy(vtkAbstractArray* da) override;
227
236 vtkIdType i, vtkIdList* ptIndices, vtkAbstractArray* source, double* weights) override;
237
247 vtkAbstractArray* source2, double t) override;
248
254 void Squeeze() override;
255
260 vtkTypeBool Resize(vtkIdType numTuples) override;
261
263
271 void SetVoidArray(void* arr, vtkIdType size, int save) override;
272 void SetVoidArray(void* arr, vtkIdType size, int save, int deleteM) override;
274
283 unsigned long GetActualMemorySize() const override;
284
288 int IsNumeric() const override;
289
295
296 //
297 // Additional functions
298 //
299
304
310 VTK_EXPECTS(0 <= id && id < this->GetNumberOfValues());
311
317 void InsertValue(vtkIdType id, vtkVariant value) VTK_EXPECTS(0 <= id);
318
322 void SetVariantValue(vtkIdType idx, vtkVariant value) override;
323
327 void InsertVariantValue(vtkIdType idx, vtkVariant value) override;
328
334
339
344 vtkVariant* arr, vtkIdType size, int save, int deleteMethod = VTK_DATA_ARRAY_DELETE);
345
352 void SetArrayFreeFunction(void (*callback)(void*)) override;
353
357 vtkIdType GetNumberOfValues() const { return (this->MaxId + 1); }
358
360
364 void LookupValue(vtkVariant value, vtkIdList* ids) override;
366
375 void DataChanged() override;
376
383
389 void ClearLookup() override;
390
396
397protected:
398 // Construct object with default tuple dimension (number of components) of 1.
400
401 // Pointer to data
402
404
405 // Function to resize data
407
408 void (*DeleteFunction)(void*);
409
410private:
411 vtkVariantArray(const vtkVariantArray&) = delete;
412 void operator=(const vtkVariantArray&) = delete;
413
414 vtkVariantArrayLookup* Lookup;
415 void UpdateLookup();
416};
417
418VTK_ABI_NAMESPACE_END
419#endif
Abstract superclass for all arrays.
vtkIdType GetNumberOfValues() const
Get the total number of values in the array.
Abstract superclass to iterate over elements in an vtkAbstractArray.
list of point or cell ids
Definition vtkIdList.h:133
a simple class to control print indentation
Definition vtkIndent.h:108
An array holding vtkVariants.
vtkVariant * Array
void SetVoidArray(void *arr, vtkIdType size, int save, int deleteM) override
This method lets the user specify data to be held by the array.
void SetVoidArray(void *arr, vtkIdType size, int save) override
This method lets the user specify data to be held by the array.
bool CopyComponent(int dstComponent, vtkAbstractArray *src, int srcComponent) override
Copy one component from src into a (potentially different) component of this array.
static vtkVariantArray * New()
vtkTypeBool Allocate(vtkIdType sz, vtkIdType ext=1000) override
Allocate memory for this array.
int GetDataType() const override
Return the underlying data type.
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() override
This destructor is public to work around a bug in version 1.36.0 of the Boost.Serialization library.
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...
static vtkVariantArray * ExtendedNew()
vtkTypeBool Resize(vtkIdType numTuples) override
Resize the array while conserving the data.
void InsertTuplesStartingAt(vtkIdType dstStart, vtkIdList *srcIds, vtkAbstractArray *source) override
Copy the tuples indexed in srcIds from the source array to the tuple locations starting at index dstS...
vtkIdType InsertNextValue(vtkVariant value)
Expand the array by one and set the value at that location.
void InsertVariantValue(vtkIdType idx, vtkVariant value) override
Safely insert a value into the array from a variant.
vtkArrayIterator * NewIterator() override
Subclasses must override this method and provide the right kind of templated vtkArrayIteratorTemplate...
void ClearLookup() override
Delete the associated fast lookup data structure on this array, if it exists.
unsigned long GetActualMemorySize() const override
Return the memory in kibibytes (1024 bytes) consumed by this data array.
vtkIdType LookupValue(vtkVariant value) override
Return the indices where a specific value appears.
void SetTuple(vtkIdType i, vtkIdType j, vtkAbstractArray *source) override
Set the tuple at the ith location using the jth tuple in the source array.
vtkIdType InsertNextTuple(vtkIdType j, vtkAbstractArray *source) override
Insert the jth tuple in the source array, at the end in this array.
void SetVariantValue(vtkIdType idx, vtkVariant value) override
Insert a value into the array from a variant.
int GetDataTypeSize() const override
Return the size of the underlying data type.
void SetNumberOfTuples(vtkIdType number) override
Set the number of tuples (a component group) in the array.
void LookupValue(vtkVariant value, vtkIdList *ids) override
Return the indices where a specific value appears.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual void DataElementChanged(vtkIdType id)
Tell the array explicitly that a single data element has changed.
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...
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,...
void DeepCopy(vtkAbstractArray *da) override
Deep copy of data.
void DataChanged() override
Tell the array explicitly that the data has changed.
void InsertTuple(vtkIdType i, vtkIdType j, vtkAbstractArray *source) override
Insert the jth tuple in the source array, at ith location in this array.
void Squeeze() override
Free any unnecessary memory.
vtkVariant & GetValue(vtkIdType id) const
Get the data at a particular index.
int IsNumeric() const override
Since each item can be of a different type, we say that a variant array is not numeric.
vtkVariant * ResizeAndExtend(vtkIdType sz)
vtkVariant * GetPointer(vtkIdType id)
Return a pointer to the location in the internal array at the specified index.
void SetArray(vtkVariant *arr, vtkIdType size, int save, int deleteMethod=VTK_DATA_ARRAY_DELETE)
Set the internal array used by this object.
void SetValue(vtkIdType id, vtkVariant value)
Set the data at a particular index.
vtkIdType GetNumberOfValues() const
Return the number of values in the array.
void Initialize() override
Release storage and reset array to initial state.
void * GetVoidPointer(vtkIdType id) override
Return a void pointer.
void InsertValue(vtkIdType id, vtkVariant value)
If id < GetNumberOfValues(), overwrite the array at that index.
int GetElementComponentSize() const override
Return the size, in bytes, of the lowest-level element of an array.
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,...
A type representing the union of many types.
Definition vtkVariant.h:162
Forward declaration required for Boost serialization.
int vtkTypeBool
Definition vtkABI.h:64
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
int vtkIdType
Definition vtkType.h:333
void save(Archiver &ar, const std::string &str, const unsigned int version)
#define VTK_EXPECTS(x)
#define VTK_MARSHALMANUAL
#define VTK_NEWINSTANCE