VTK
vtkTypedDataArray.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkTypedDataArray.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=========================================================================*/
39#ifndef vtkTypedDataArray_h
40#define vtkTypedDataArray_h
41
42#include "vtkGenericDataArray.h"
43
44#include "vtkCommonCoreModule.h" // For export macro
45#include "vtkTypeTraits.h" // For type metadata
46
47template <class Scalar> class vtkTypedDataArrayIterator;
48
49template <class Scalar>
51 public vtkGenericDataArray<vtkTypedDataArray<Scalar>, Scalar>
52{
55public:
57 typedef typename Superclass::ValueType ValueType;
58
63
68
72 Iterator End();
73
78
88
92 int GetDataType() VTK_OVERRIDE;
93
97 int GetDataTypeSize() VTK_OVERRIDE;
98
104 void SetNumberOfValues(vtkIdType num) VTK_OVERRIDE;
105
109 virtual void SetTypedTuple(vtkIdType i, const ValueType *t) = 0;
110
115 virtual void InsertTypedTuple(vtkIdType i, const ValueType *t) = 0;
116
121
125 virtual ValueType GetValue(vtkIdType idx) const = 0;
126
131
136 virtual void SetValue(vtkIdType idx, ValueType value) = 0;
137
141 virtual void GetTypedTuple(vtkIdType idx, ValueType *t) const = 0;
142
147
151 virtual void InsertValue(vtkIdType idx, ValueType v) = 0;
152
153 virtual ValueType GetTypedComponent(vtkIdType tupleIdx, int comp) const;
154 virtual void SetTypedComponent(vtkIdType tupleIdx, int comp, ValueType v);
155
159 int GetArrayType() VTK_OVERRIDE { return vtkAbstractArray::TypedDataArray; }
160
161 // Reintroduced as pure virtual since the base vtkGenericDataArray method
162 // requires new allocation/resize APIs, though existing MappedDataArrays
163 // would just use the vtkDataArray-level virtuals.
164 virtual int Allocate(vtkIdType size, vtkIdType ext = 1000) = 0;
165 virtual int Resize(vtkIdType numTuples) = 0;
166
167protected:
170
175 virtual bool AllocateTuples(vtkIdType numTuples);
176
181 virtual bool ReallocateTuples(vtkIdType numTuples);
182
183private:
184 vtkTypedDataArray(const vtkTypedDataArray &) VTK_DELETE_FUNCTION;
185 void operator=(const vtkTypedDataArray &) VTK_DELETE_FUNCTION;
186
187 friend class vtkGenericDataArray<vtkTypedDataArray<Scalar>, Scalar>;
188};
189
190// Declare vtkArrayDownCast implementations for typed containers:
192
193// Included here to resolve chicken/egg issue with container/iterator:
194#include "vtkTypedDataArrayIterator.h" // For iterator
195
196template <class Scalar> inline
198{
199 return Iterator(this, 0);
200}
201
202template <class Scalar> inline
204{
205 return Iterator(this, this->MaxId + 1);
206}
207
208#include "vtkTypedDataArray.txx"
209
210#endif //vtkTypedDataArray_h
211
212// VTK-HeaderTest-Exclude: vtkTypedDataArray.h
Abstract superclass for all arrays.
Base interface for all typed vtkDataArray subclasses.
vtkTemplateTypeMacro(SelfType, vtkDataArray) enum
Compile time access to the VTK type identifier.
STL-style random access iterator for vtkTypedDataArrays.
Extend vtkDataArray with abstract type-specific API.
int GetArrayType() override
Method for type-checking in FastDownCast implementations.
virtual int Allocate(vtkIdType size, vtkIdType ext=1000)=0
Allocate memory for this array.
virtual int Resize(vtkIdType numTuples)=0
Resize the array to the requested number of tuples and preserve data.
virtual void SetTypedComponent(vtkIdType tupleIdx, int comp, ValueType v)
virtual bool ReallocateTuples(vtkIdType numTuples)
Needed for vtkGenericDataArray API, but just aborts.
vtkTemplateTypeMacro(vtkTypedDataArray< Scalar >, GenericDataArrayType) typedef typename Superclass typedef vtkTypedDataArrayIterator< ValueType > Iterator
Typedef to a suitable iterator class.
int GetDataTypeSize() override
Return the size of the element type in bytes.
static vtkTypedDataArray< Scalar > * FastDownCast(vtkAbstractArray *source)
Perform a fast, safe cast from a vtkAbstractArray to a vtkTypedDataArray.
virtual bool AllocateTuples(vtkIdType numTuples)
Needed for vtkGenericDataArray API, but just aborts.
Iterator Begin()
Return an iterator initialized to the first element of the data.
virtual ValueType & GetValueReference(vtkIdType idx)=0
Get a reference to the scalar value at a particular index.
virtual ValueType GetTypedComponent(vtkIdType tupleIdx, int comp) const
virtual vtkIdType InsertNextTypedTuple(const ValueType *t)=0
Insert (memory allocation performed) the tuple onto the end of the array.
Iterator End()
Return an iterator initialized to first element past the end of the data.
virtual vtkIdType InsertNextValue(ValueType v)=0
Insert data at the end of the array.
virtual void InsertTypedTuple(vtkIdType i, const ValueType *t)=0
Insert (memory allocation performed) the tuple into the ith location in the array.
virtual ValueType GetValue(vtkIdType idx) const =0
Get the data at a particular index.
virtual void SetValue(vtkIdType idx, ValueType value)=0
Set the data at a particular index.
int GetDataType() override
Return the VTK data type held by this array.
void SetNumberOfValues(vtkIdType num) override
Specify the number of values for this object to hold.
virtual void SetTypedTuple(vtkIdType i, const ValueType *t)=0
Set the tuple value at the ith location in the array.
virtual void GetTypedTuple(vtkIdType idx, ValueType *t) const =0
Copy the tuple value into a user-provided array.
virtual void InsertValue(vtkIdType idx, ValueType v)=0
Insert data at a specified position in the array.
@ value
Definition: vtkX3D.h:220
@ size
Definition: vtkX3D.h:253
Template defining traits of native types used by VTK.
Definition: vtkTypeTraits.h:32
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
int vtkIdType
Definition: vtkType.h:287
vtkArrayDownCast_TemplateFastCastMacro(vtkTypedDataArray) template< class Scalar > inline typename vtkTypedDataArray< Scalar >