VTK  9.3.1
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 "vtkTypedDataArray.h"
27 
28 VTK_ABI_NAMESPACE_BEGIN
29 template <class Scalar>
30 class vtkMappedDataArray : public vtkTypedDataArray<Scalar>
31 {
32 public:
34  typedef typename Superclass::ValueType ValueType;
35 
45 
46  void PrintSelf(ostream& os, vtkIndent indent) override;
47 
48  // vtkAbstractArray virtual method that must be reimplemented.
49  void DeepCopy(vtkAbstractArray* aa) override = 0;
50  vtkVariant GetVariantValue(vtkIdType idx) override = 0;
51  void SetVariantValue(vtkIdType idx, vtkVariant value) override = 0;
52  void GetTuples(vtkIdList* ptIds, vtkAbstractArray* output) override = 0;
53  void GetTuples(vtkIdType p1, vtkIdType p2, vtkAbstractArray* output) override = 0;
54  void InterpolateTuple(
55  vtkIdType i, vtkIdList* ptIndices, vtkAbstractArray* source, double* weights) override = 0;
57  vtkAbstractArray* source2, double t) override = 0;
58 
59  // vtkDataArray virtual method that must be reimplemented.
60  void DeepCopy(vtkDataArray* da) override = 0;
61 
67  void* GetVoidPointer(vtkIdType id) override;
68 
74  void ExportToVoidPointer(void* ptr) override;
75 
83  void DataChanged() override;
84 
86 
90  void SetVoidArray(void*, vtkIdType, int) override;
91  void SetVoidArray(void*, vtkIdType, int, int) override;
93 
95 
98  void* WriteVoidPointer(vtkIdType /*id*/, vtkIdType /*number*/) override
99  {
100  vtkErrorMacro(<< "WriteVoidPointer: Method not implemented.");
101  return nullptr;
102  }
104 
108  void Modified() override;
109 
110  // vtkAbstractArray override:
111  bool HasStandardMemoryLayout() const override { return false; }
112 
113 protected:
115  ~vtkMappedDataArray() override;
116 
117  int GetArrayType() const override { return vtkAbstractArray::MappedDataArray; }
118 
119 private:
120  vtkMappedDataArray(const vtkMappedDataArray&) = delete;
121  void operator=(const vtkMappedDataArray&) = delete;
122 
124 
127  ValueType* TemporaryScalarPointer;
128  size_t TemporaryScalarPointerSize;
130 };
131 
132 // Declare vtkArrayDownCast implementations for mapped containers:
134 
135 VTK_ABI_NAMESPACE_END
136 #include "vtkMappedDataArray.txx"
137 
138 // Adds an implementation of NewInstanceInternal() that returns an AoS
139 // (unmapped) VTK array, if possible. Use this in combination with
140 // vtkAbstractTemplateTypeMacro when your subclass is a template class.
141 // Otherwise, use vtkMappedDataArrayTypeMacro.
142 #define vtkMappedDataArrayNewInstanceMacro(thisClass) \
143 protected: \
144  vtkObjectBase* NewInstanceInternal() const override \
145  { \
146  if (vtkDataArray* da = vtkDataArray::CreateDataArray(thisClass::VTK_DATA_TYPE)) \
147  { \
148  return da; \
149  } \
150  return thisClass::New(); \
151  } \
152  \
153 public:
154 
155 // Same as vtkTypeMacro, but adds an implementation of NewInstanceInternal()
156 // that returns a standard (unmapped) VTK array, if possible.
157 #define vtkMappedDataArrayTypeMacro(thisClass, superClass) \
158  vtkAbstractTypeMacroWithNewInstanceType(thisClass, superClass, vtkDataArray); \
159  vtkMappedDataArrayNewInstanceMacro(thisClass)
160 
161 #endif // vtkMappedDataArray_h
162 
163 // VTK-HeaderTest-Exclude: vtkMappedDataArray.h
~vtkMappedDataArray() override
Map non-contiguous data structures into the vtkDataArray API.
vtkTemplateTypeMacro(vtkMappedDataArray< Scalar >, vtkTypedDataArray< Scalar >)
Abstract superclass for all arrays.
int vtkIdType
Definition: vtkType.h:315
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void * GetVoidPointer(vtkIdType id) override
Print an error and create an internal, long-lived temporary array.
A type representing the union of many types.
Definition: vtkVariant.h:52
vtkArrayDownCast_TemplateFastCastMacro(vtkMappedDataArray)
vtkVariant GetVariantValue(vtkIdType idx) override=0
Retrieve value from the array as a variant.
void ExportToVoidPointer(void *ptr) override
Copy the internal data to the void pointer.
a simple class to control print indentation
Definition: vtkIndent.h:28
bool HasStandardMemoryLayout() const override
Returns true if this array uses the standard memory layout defined in the VTK user guide...
list of point or cell ids
Definition: vtkIdList.h:22
int GetArrayType() const override
Method for type-checking in FastDownCast implementations.
void GetTuples(vtkIdList *ptIds, vtkAbstractArray *output) override=0
Given a list of tuple ids, return an array of tuples.
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:44
void DataChanged() override
Read the data from the internal temporary array (created by GetVoidPointer) back into the mapped arra...
Superclass::ValueType ValueType
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...
void SetVariantValue(vtkIdType idx, vtkVariant value) override=0
Set a value in the array from a variant.
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
Extend vtkDataArray with abstract type-specific API.
void Modified() override
Invalidate the internal temporary array and call superclass method.
void * WriteVoidPointer(vtkIdType, vtkIdType) override
Not implemented.
void SetVoidArray(void *, vtkIdType, int) override
These methods don't make sense for mapped data array.
void DeepCopy(vtkAbstractArray *aa) override=0
Deep copy of data.
static vtkMappedDataArray< Scalar > * FastDownCast(vtkAbstractArray *source)
Perform a fast, safe cast from a vtkAbstractArray to a vtkMappedDataArray.