VTK  9.1.0
vtkMappedDataArray.h
Go to the documentation of this file.
1/*==============================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkMappedDataArray.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==============================================================================*/
35#ifndef vtkMappedDataArray_h
36#define vtkMappedDataArray_h
37
38#include "vtkTypedDataArray.h"
39
40template <class Scalar>
42{
43public:
45 typedef typename Superclass::ValueType ValueType;
46
56
57 void PrintSelf(ostream& os, vtkIndent indent) override;
58
59 // vtkAbstractArray virtual method that must be reimplemented.
60 void DeepCopy(vtkAbstractArray* aa) override = 0;
62 void SetVariantValue(vtkIdType idx, vtkVariant value) override = 0;
63 void GetTuples(vtkIdList* ptIds, vtkAbstractArray* output) override = 0;
64 void GetTuples(vtkIdType p1, vtkIdType p2, vtkAbstractArray* output) override = 0;
66 vtkIdType i, vtkIdList* ptIndices, vtkAbstractArray* source, double* weights) override = 0;
68 vtkAbstractArray* source2, double t) override = 0;
69
70 // vtkDataArray virtual method that must be reimplemented.
71 void DeepCopy(vtkDataArray* da) override = 0;
72
78 void* GetVoidPointer(vtkIdType id) override;
79
85 void ExportToVoidPointer(void* ptr) override;
86
94 void DataChanged() override;
95
97
101 void SetVoidArray(void*, vtkIdType, int) override;
102 void SetVoidArray(void*, vtkIdType, int, int) override;
104
106
109 void* WriteVoidPointer(vtkIdType /*id*/, vtkIdType /*number*/) override
110 {
111 vtkErrorMacro(<< "WriteVoidPointer: Method not implemented.");
112 return nullptr;
113 }
115
119 void Modified() override;
120
121 // vtkAbstractArray override:
122 bool HasStandardMemoryLayout() const override { return false; }
123
124protected:
127
128 int GetArrayType() const override { return vtkAbstractArray::MappedDataArray; }
129
130private:
131 vtkMappedDataArray(const vtkMappedDataArray&) = delete;
132 void operator=(const vtkMappedDataArray&) = delete;
133
135
138 ValueType* TemporaryScalarPointer;
139 size_t TemporaryScalarPointerSize;
141};
142
143// Declare vtkArrayDownCast implementations for mapped containers:
145
146#include "vtkMappedDataArray.txx"
147
148// Adds an implementation of NewInstanceInternal() that returns an AoS
149// (unmapped) VTK array, if possible. Use this in combination with
150// vtkAbstractTemplateTypeMacro when your subclass is a template class.
151// Otherwise, use vtkMappedDataArrayTypeMacro.
152#define vtkMappedDataArrayNewInstanceMacro(thisClass) \
153protected: \
154 vtkObjectBase* NewInstanceInternal() const override \
155 { \
156 if (vtkDataArray* da = vtkDataArray::CreateDataArray(thisClass::VTK_DATA_TYPE)) \
157 { \
158 return da; \
159 } \
160 return thisClass::New(); \
161 } \
162 \
163public:
164
165// Same as vtkTypeMacro, but adds an implementation of NewInstanceInternal()
166// that returns a standard (unmapped) VTK array, if possible.
167#define vtkMappedDataArrayTypeMacro(thisClass, superClass) \
168 vtkAbstractTypeMacroWithNewInstanceType(thisClass, superClass, vtkDataArray); \
169 vtkMappedDataArrayNewInstanceMacro(thisClass)
170
171#endif // vtkMappedDataArray_h
172
173// VTK-HeaderTest-Exclude: vtkMappedDataArray.h
Abstract superclass for all arrays.
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:159
list of point or cell ids
Definition: vtkIdList.h:140
a simple class to control print indentation
Definition: vtkIndent.h:113
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 atomic type representing the union of many types.
Definition: vtkVariant.h:145
#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 *)
int vtkIdType
Definition: vtkType.h:332