VTK
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(vtkIdType i, vtkIdList *ptIndices,
66  vtkAbstractArray *source, double *weights) override = 0;
68  vtkAbstractArray* source1, vtkIdType id2,
69  vtkAbstractArray* source2, double t) override = 0;
70 
71  // vtkDataArray virtual method that must be reimplemented.
72  void DeepCopy(vtkDataArray *da) override = 0;
73 
79  void * GetVoidPointer(vtkIdType id) override;
80 
86  void ExportToVoidPointer(void *ptr) override;
87 
95  void DataChanged() override;
96 
98 
102  void SetVoidArray(void *, vtkIdType, int) override;
103  void SetVoidArray(void *, vtkIdType, int, int) override;
105 
107 
110  void * WriteVoidPointer(vtkIdType /*id*/, vtkIdType /*number*/) override
111  {
112  vtkErrorMacro(<<"WriteVoidPointer: Method not implemented.");
113  return nullptr;
114  }
116 
120  void Modified() override;
121 
122  // vtkAbstractArray override:
123  bool HasStandardMemoryLayout() override { return false; }
124 
125 protected:
127  ~vtkMappedDataArray() override;
128 
129  int GetArrayType() override
130  {
132  }
133 
134 private:
135  vtkMappedDataArray(const vtkMappedDataArray &) = delete;
136  void operator=(const vtkMappedDataArray &) = delete;
137 
139 
142  ValueType *TemporaryScalarPointer;
143  size_t TemporaryScalarPointerSize;
144 };
146 
147 // Declare vtkArrayDownCast implementations for mapped containers:
149 
150 #include "vtkMappedDataArray.txx"
151 
152 // Adds an implementation of NewInstanceInternal() that returns an AoS
153 // (unmapped) VTK array, if possible. Use this in combination with
154 // vtkAbstractTemplateTypeMacro when your subclass is a template class.
155 // Otherwise, use vtkMappedDataArrayTypeMacro.
156 #define vtkMappedDataArrayNewInstanceMacro(thisClass) \
157  protected: \
158  vtkObjectBase *NewInstanceInternal() const override \
159  { \
160  if (vtkDataArray *da = \
161  vtkDataArray::CreateDataArray(thisClass::VTK_DATA_TYPE)) \
162  { \
163  return da; \
164  } \
165  return thisClass::New(); \
166  } \
167  public:
168 
169 // Same as vtkTypeMacro, but adds an implementation of NewInstanceInternal()
170 // that returns a standard (unmapped) VTK array, if possible.
171 #define vtkMappedDataArrayTypeMacro(thisClass, superClass) \
172  vtkAbstractTypeMacroWithNewInstanceType(thisClass, superClass, vtkDataArray) \
173  vtkMappedDataArrayNewInstanceMacro(thisClass)
174 
175 #endif //vtkMappedDataArray_h
176 
177 // VTK-HeaderTest-Exclude: vtkMappedDataArray.h
bool HasStandardMemoryLayout() override
Returns true if this array uses the standard memory layout defined in the VTK user guide...
~vtkMappedDataArray() override
Map non-contiguous data structures into the vtkDataArray API.
Abstract superclass for all arrays.
vtkTemplateTypeMacro(SelfType, vtkDataArray) enum
Compile time access to the VTK type identifier.
int vtkIdType
Definition: vtkType.h:347
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:71
static vtkTemplateTypeMacro(vtkMappedDataArray< Scalar >, vtkTypedDataArray< Scalar >) typedef typename Superclass vtkMappedDataArray< Scalar > * FastDownCast(vtkAbstractArray *source)
Perform a fast, safe cast from a vtkAbstractArray to a 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
list of point or cell ids
Definition: vtkIdList.h:36
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:54
void DataChanged() override
Read the data from the internal temporary array (created by GetVoidPointer) back into the mapped arra...
int GetArrayType() override
Method for type-checking in FastDownCast implementations.
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.
vtkArrayDownCast_TemplateFastCastMacro(vtkTypedDataArray) template< class Scalar > inline typename vtkTypedDataArray< Scalar >
Extend vtkDataArray with abstract type-specific API.
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
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&#39;t make sense for mapped data array.
void DeepCopy(vtkAbstractArray *aa) override=0
Deep copy of data.