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);
58 
59  // vtkAbstractArray virtual method that must be reimplemented.
60  void DeepCopy(vtkAbstractArray *aa) = 0;
63  void GetTuples(vtkIdList *ptIds, vtkAbstractArray *output) = 0;
64  void GetTuples(vtkIdType p1, vtkIdType p2, vtkAbstractArray *output) = 0;
65  void InterpolateTuple(vtkIdType i, vtkIdList *ptIndices,
66  vtkAbstractArray *source, double *weights) = 0;
68  vtkAbstractArray* source1, vtkIdType id2,
69  vtkAbstractArray* source2, double t) = 0;
70 
71  // vtkDataArray virtual method that must be reimplemented.
72  void DeepCopy(vtkDataArray *da) = 0;
73 
79  void * GetVoidPointer(vtkIdType id);
80 
86  void ExportToVoidPointer(void *ptr);
87 
95  void DataChanged();
96 
98 
102  void SetVoidArray(void *, vtkIdType, int);
103  void SetVoidArray(void *, vtkIdType, int, int);
105 
107 
110  void * WriteVoidPointer(vtkIdType /*id*/, vtkIdType /*number*/)
111  {
112  vtkErrorMacro(<<"WriteVoidPointer: Method not implemented.");
113  return NULL;
114  }
116 
120  void Modified();
121 
122  // vtkAbstractArray override:
123  bool HasStandardMemoryLayout() { return false; }
124 
125 protected:
128 
129  virtual int GetArrayType()
130  {
132  }
133 
134 private:
135  vtkMappedDataArray(const vtkMappedDataArray &) VTK_DELETE_FUNCTION;
136  void operator=(const vtkMappedDataArray &) VTK_DELETE_FUNCTION;
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 \
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
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
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.
void DataChanged()
Read the data from the internal temporary array (created by GetVoidPointer) back into the mapped arra...
int vtkIdType
Definition: vtkType.h:287
void ExportToVoidPointer(void *ptr)
Copy the internal data to the void pointer.
vtkVariant GetVariantValue(vtkIdType idx)=0
Retrieve value from the array as a variant.
A atomic type representing the union of many types.
Definition: vtkVariant.h:75
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.
a simple class to control print indentation
Definition: vtkIndent.h:39
void * GetVoidPointer(vtkIdType id)
Print an error and create an internal, long-lived temporary array.
void DeepCopy(vtkAbstractArray *aa)=0
Deep copy of data.
virtual int GetArrayType()
Method for type-checking in FastDownCast implementations.
list of point or cell ids
Definition: vtkIdList.h:36
void * WriteVoidPointer(vtkIdType, vtkIdType)
Not implemented.
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
vtkArrayDownCast_TemplateFastCastMacro(vtkTypedDataArray) template< class Scalar > inline typename vtkTypedDataArray< Scalar >
bool HasStandardMemoryLayout()
Returns true if this array uses the standard memory layout defined in the VTK user guide...
Extend vtkDataArray with abstract type-specific API.
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
void Modified()
Invalidate the internal temporary array and call superclass method.
void GetTuples(vtkIdList *ptIds, vtkAbstractArray *output)=0
Given a list of tuple ids, return an array of tuples.
void InterpolateTuple(vtkIdType i, vtkIdList *ptIndices, vtkAbstractArray *source, double *weights)=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)=0
Set a value in the array from a variant.
void SetVoidArray(void *, vtkIdType, int)
These methods don't make sense for mapped data array.