VTK  9.4.20250309
vtkMappedDataArray.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-License-Identifier: BSD-3-Clause
23#ifndef vtkMappedDataArray_h
24#define vtkMappedDataArray_h
25
26#include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_5_0
27#include "vtkTypedDataArray.h"
28
29VTK_ABI_NAMESPACE_BEGIN
30template <class Scalar>
31class VTK_DEPRECATED_IN_9_5_0("Please use the SetArray functionality of `vtkAOSDataArrayTemplate` "
32 "for 1 component or `vtkSOADataArrayTemplate` for more "
33 "instead.") vtkMappedDataArray : public vtkTypedDataArray<Scalar>
34{
35public:
37 typedef typename Superclass::ValueType ValueType;
38
48
49 void PrintSelf(ostream& os, vtkIndent indent) override;
50
51 // vtkAbstractArray virtual method that must be reimplemented.
52 void DeepCopy(vtkAbstractArray* aa) override = 0;
54 void SetVariantValue(vtkIdType idx, vtkVariant value) override = 0;
55 void GetTuples(vtkIdList* ptIds, vtkAbstractArray* output) override = 0;
56 void GetTuples(vtkIdType p1, vtkIdType p2, vtkAbstractArray* output) override = 0;
58 vtkIdType i, vtkIdList* ptIndices, vtkAbstractArray* source, double* weights) override = 0;
60 vtkAbstractArray* source2, double t) override = 0;
61
62 // vtkDataArray virtual method that must be reimplemented.
63 void DeepCopy(vtkDataArray* da) override = 0;
64
70 void* GetVoidPointer(vtkIdType id) override;
71
77 void ExportToVoidPointer(void* ptr) override;
78
86 void DataChanged() override;
87
89
93 void SetVoidArray(void*, vtkIdType, int) override;
94 void SetVoidArray(void*, vtkIdType, int, int) override;
96
98
101 void* WriteVoidPointer(vtkIdType /*id*/, vtkIdType /*number*/) override
102 {
103 vtkErrorMacro(<< "WriteVoidPointer: Method not implemented.");
104 return nullptr;
105 }
107
111 void Modified() override;
112
113 // vtkAbstractArray override:
114 bool HasStandardMemoryLayout() const override { return false; }
115
116protected:
119
120 int GetArrayType() const override { return vtkAbstractArray::MappedDataArray; }
121
122private:
123 vtkMappedDataArray(const vtkMappedDataArray&) = delete;
124 void operator=(const vtkMappedDataArray&) = delete;
125
127
130 ValueType* TemporaryScalarPointer;
131 size_t TemporaryScalarPointerSize;
133};
134
135// Declare vtkArrayDownCast implementations for mapped containers:
137
138VTK_ABI_NAMESPACE_END
139#include "vtkMappedDataArray.txx"
140
141// Adds an implementation of NewInstanceInternal() that returns an AoS
142// (unmapped) VTK array, if possible. Use this in combination with
143// vtkAbstractTemplateTypeMacro when your subclass is a template class.
144// Otherwise, use vtkMappedDataArrayTypeMacro.
145#define vtkMappedDataArrayNewInstanceMacro(thisClass) \
146protected: \
147 vtkObjectBase* NewInstanceInternal() const override \
148 { \
149 if (vtkDataArray* da = vtkDataArray::CreateDataArray(thisClass::VTK_DATA_TYPE)) \
150 { \
151 return da; \
152 } \
153 return thisClass::New(); \
154 } \
155 \
156public:
157
158// Same as vtkTypeMacro, but adds an implementation of NewInstanceInternal()
159// that returns a standard (unmapped) VTK array, if possible.
160#define vtkMappedDataArrayTypeMacro(thisClass, superClass) \
161 vtkAbstractTypeMacroWithNewInstanceType(thisClass, superClass, vtkDataArray); \
162 vtkMappedDataArrayNewInstanceMacro(thisClass)
163
164#endif // vtkMappedDataArray_h
165
166// VTK-HeaderTest-Exclude: vtkMappedDataArray.h
Abstract superclass for all arrays.
abstract superclass for arrays of numeric data
list of point or cell ids
Definition vtkIdList.h:133
a simple class to control print indentation
Definition vtkIndent.h:108
Map non-contiguous data structures into the vtkDataArray API.
void SetVoidArray(void *, vtkIdType, int, int) override
These methods don't make sense for mapped data array.
void Modified() override
Invalidate the internal temporary array and call superclass method.
void DeepCopy(vtkAbstractArray *aa) override=0
Deep copy of data.
void SetVariantValue(vtkIdType idx, vtkVariant value) override=0
Set a value in the array from a variant.
void * WriteVoidPointer(vtkIdType, vtkIdType) override
Not implemented.
void SetVoidArray(void *, vtkIdType, int) override
These methods don't make sense for mapped data array.
void GetTuples(vtkIdList *ptIds, vtkAbstractArray *output) override=0
Given a list of tuple ids, return an array of tuples.
vtkVariant GetVariantValue(vtkIdType idx) override=0
Retrieve value from the array as a variant.
void DeepCopy(vtkDataArray *da) override=0
Deep copy of data.
bool HasStandardMemoryLayout() const override
Returns true if this array uses the standard memory layout defined in the VTK user guide,...
void GetTuples(vtkIdType p1, vtkIdType p2, vtkAbstractArray *output) override=0
Get the tuples for the range of tuple ids specified (i.e., p1->p2 inclusive).
vtkTemplateTypeMacro(vtkMappedDataArray< Scalar >, vtkTypedDataArray< Scalar >)
void InterpolateTuple(vtkIdType i, vtkIdType id1, vtkAbstractArray *source1, vtkIdType id2, vtkAbstractArray *source2, double t) override=0
Insert the tuple at dstTupleIdx in this array to the tuple interpolated from the two tuple indices,...
void ExportToVoidPointer(void *ptr) override
Copy the internal data to the void pointer.
static vtkMappedDataArray< Scalar > * FastDownCast(vtkAbstractArray *source)
Perform a fast, safe cast from a vtkAbstractArray to a vtkMappedDataArray.
int GetArrayType() const override
Method for type-checking in FastDownCast implementations.
~vtkMappedDataArray() override
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void DataChanged() override
Read the data from the internal temporary array (created by GetVoidPointer) back into the mapped arra...
void InterpolateTuple(vtkIdType i, vtkIdList *ptIndices, vtkAbstractArray *source, double *weights) override=0
Set the tuple at dstTupleIdx in this array to the interpolated tuple value, given the ptIndices in th...
Superclass::ValueType ValueType
void * GetVoidPointer(vtkIdType id) override
Print an error and create an internal, long-lived temporary array.
Extend vtkDataArray with abstract type-specific API.
A type representing the union of many types.
Definition vtkVariant.h:162
#define vtkArrayDownCast_TemplateFastCastMacro(ArrayT)
Same as vtkArrayDownCast_FastCastMacro, but treats ArrayT as a single-parameter template (the paramet...
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
#define VTK_DEPRECATED_IN_9_5_0(reason)
int vtkIdType
Definition vtkType.h:332