VTK  9.2.6
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 
40 template <class Scalar>
41 class vtkMappedDataArray : public vtkTypedDataArray<Scalar>
42 {
43 public:
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;
61  vtkVariant GetVariantValue(vtkIdType idx) 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;
65  void InterpolateTuple(
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 
124 protected:
126  ~vtkMappedDataArray() override;
127 
128  int GetArrayType() const override { return vtkAbstractArray::MappedDataArray; }
129 
130 private:
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) \
153 protected: \
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  \
163 public:
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
~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:332
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 atomic type representing the union of many types.
Definition: vtkVariant.h:69
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:39
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:33
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:55
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.