VTK  9.3.0
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;
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;
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:
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
Abstract superclass for all arrays.
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
list of point or cell ids
Definition: vtkIdList.h:32
a simple class to control print indentation
Definition: vtkIndent.h:38
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 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.
static vtkMappedDataArray< Scalar > * FastDownCast(vtkAbstractArray *source)
Perform a fast, safe cast from a vtkAbstractArray to a vtkMappedDataArray.
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.
void * WriteVoidPointer(vtkIdType, vtkIdType) override
Not implemented.
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 * GetVoidPointer(vtkIdType id) override
Print an error and create an internal, long-lived temporary array.
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
Extend vtkDataArray with abstract type-specific API.
A type representing the union of many types.
Definition: vtkVariant.h:62
@ value
Definition: vtkX3D.h:220
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
vtkArrayDownCast_TemplateFastCastMacro(vtkMappedDataArray)
int vtkIdType
Definition: vtkType.h:315