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 =========================================================================*/
36 #ifndef vtkTypedDataArray_h
37 #define vtkTypedDataArray_h
38 
39 #include "vtkGenericDataArray.h"
40 
41 #include "vtkCommonCoreModule.h" // For export macro
42 #include "vtkTypeTraits.h" // For type metadata
43 
44 template <class Scalar> class vtkTypedDataArrayIterator;
45 
46 template <class Scalar>
48  public vtkGenericDataArray<vtkTypedDataArray<Scalar>, Scalar>
49 {
52 public:
54  typedef typename Superclass::ValueType ValueType;
55 
60 
64  Iterator Begin();
65 
69  Iterator End();
70 
75 
85 
89  int GetDataType() override;
90 
94  int GetDataTypeSize() override;
95 
101  void SetNumberOfValues(vtkIdType num) override;
102 
106  virtual void SetTypedTuple(vtkIdType i, const ValueType *t) = 0;
107 
112  virtual void InsertTypedTuple(vtkIdType i, const ValueType *t) = 0;
113 
117  virtual vtkIdType InsertNextTypedTuple(const ValueType *t) = 0;
118 
122  virtual ValueType GetValue(vtkIdType idx) const = 0;
123 
127  virtual ValueType& GetValueReference(vtkIdType idx) = 0;
128 
133  virtual void SetValue(vtkIdType idx, ValueType value) = 0;
134 
138  virtual void GetTypedTuple(vtkIdType idx, ValueType *t) const = 0;
139 
143  virtual vtkIdType InsertNextValue(ValueType v) = 0;
144 
148  virtual void InsertValue(vtkIdType idx, ValueType v) = 0;
149 
150  virtual ValueType GetTypedComponent(vtkIdType tupleIdx, int comp) const;
151  virtual void SetTypedComponent(vtkIdType tupleIdx, int comp, ValueType v);
152 
157 
158  // Reintroduced as pure virtual since the base vtkGenericDataArray method
159  // requires new allocation/resize APIs, though existing MappedDataArrays
160  // would just use the vtkDataArray-level virtuals.
161  int Allocate(vtkIdType size, vtkIdType ext = 1000) override = 0;
162  int Resize(vtkIdType numTuples) override = 0;
163 
164 protected:
166  ~vtkTypedDataArray() override;
167 
172  virtual bool AllocateTuples(vtkIdType numTuples);
173 
178  virtual bool ReallocateTuples(vtkIdType numTuples);
179 
180 private:
181  vtkTypedDataArray(const vtkTypedDataArray &) = delete;
182  void operator=(const vtkTypedDataArray &) = delete;
183 
184  friend class vtkGenericDataArray<vtkTypedDataArray<Scalar>, Scalar>;
185 };
186 
187 // Declare vtkArrayDownCast implementations for typed containers:
189 
190 // Included here to resolve chicken/egg issue with container/iterator:
191 #include "vtkTypedDataArrayIterator.h" // For iterator
192 
193 template <class Scalar> inline
195 {
196  return Iterator(this, 0);
197 }
198 
199 template <class Scalar> inline
201 {
202  return Iterator(this, this->MaxId + 1);
203 }
204 
205 #include "vtkTypedDataArray.txx"
206 
207 #endif //vtkTypedDataArray_h
208 
209 // VTK-HeaderTest-Exclude: vtkTypedDataArray.h
vtkTypedDataArray::InsertNextTypedTuple
virtual vtkIdType InsertNextTypedTuple(const ValueType *t)=0
Insert (memory allocation performed) the tuple onto the end of the array.
vtkGenericDataArray< vtkTypedDataArray< Scalar >, Scalar >::ValueType
Scalar ValueType
Definition: vtkGenericDataArray.h:81
vtkTypedDataArray::ReallocateTuples
virtual bool ReallocateTuples(vtkIdType numTuples)
Needed for vtkGenericDataArray API, but just aborts.
vtkTypeTraits
Template defining traits of native types used by VTK.
Definition: vtkTypeTraits.h:29
vtkTypedDataArray::FastDownCast
static vtkTypedDataArray< Scalar > * FastDownCast(vtkAbstractArray *source)
Perform a fast, safe cast from a vtkAbstractArray to a vtkTypedDataArray.
vtkTypedDataArray::GetTypedTuple
virtual void GetTypedTuple(vtkIdType idx, ValueType *t) const =0
Copy the tuple value into a user-provided array.
vtkX3D::value
Definition: vtkX3D.h:220
vtkTypedDataArray::GetDataType
int GetDataType() override
Return the VTK data type held by this array.
vtkIdType
int vtkIdType
Definition: vtkType.h:347
vtkTypedDataArray::GetDataTypeSize
int GetDataTypeSize() override
Return the size of the element type in bytes.
vtkTypedDataArray::InsertNextValue
virtual vtkIdType InsertNextValue(ValueType v)=0
Insert data at the end of the array.
vtkTypedDataArray
Extend vtkDataArray with abstract type-specific API.
Definition: vtkTypedDataArray.h:47
vtkTypedDataArray::~vtkTypedDataArray
~vtkTypedDataArray() override
vtkGenericDataArray
Base interface for all typed vtkDataArray subclasses.
Definition: vtkGenericDataArray.h:77
vtkTypedDataArray::vtkTypedDataArray
vtkTypedDataArray()
vtkTypedDataArray::InsertValue
virtual void InsertValue(vtkIdType idx, ValueType v)=0
Insert data at a specified position in the array.
vtkTypedDataArray::Allocate
int Allocate(vtkIdType size, vtkIdType ext=1000) override=0
Allocate memory for this array.
vtkTypedDataArray::GetArrayType
int GetArrayType() override
Method for type-checking in FastDownCast implementations.
Definition: vtkTypedDataArray.h:156
source
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
Definition: vtkBoostGraphAdapter.h:825
vtkTypedDataArray::SetTypedComponent
virtual void SetTypedComponent(vtkIdType tupleIdx, int comp, ValueType v)
vtkTypedDataArray::InsertTypedTuple
virtual void InsertTypedTuple(vtkIdType i, const ValueType *t)=0
Insert (memory allocation performed) the tuple into the ith location in the array.
vtkTypeTraits.h
vtkTypedDataArray::AllocateTuples
virtual bool AllocateTuples(vtkIdType numTuples)
Needed for vtkGenericDataArray API, but just aborts.
vtkTypedDataArray::GetTypedComponent
virtual ValueType GetTypedComponent(vtkIdType tupleIdx, int comp) const
vtkTypedDataArray::GetValueReference
virtual ValueType & GetValueReference(vtkIdType idx)=0
Get a reference to the scalar value at a particular index.
vtkGenericDataArray< vtkTypedDataArray< Scalar >, Scalar >::vtkTemplateTypeMacro
vtkTemplateTypeMacro(SelfType, vtkDataArray) enum
Compile time access to the VTK type identifier.
Definition: vtkGenericDataArray.h:82
vtkGenericDataArray.h
vtkX3D::size
Definition: vtkX3D.h:253
vtkTypedDataArray::Resize
int Resize(vtkIdType numTuples) override=0
Resize the array to the requested number of tuples and preserve data.
vtkTypedDataArray::Begin
Iterator Begin()
Return an iterator initialized to the first element of the data.
vtkTypedDataArray::End
Iterator End()
Return an iterator initialized to first element past the end of the data.
Definition: vtkTypedDataArray.h:200
vtkTypedDataArray::VTK_DATA_TYPE
Definition: vtkTypedDataArray.h:74
vtkAbstractArray
Abstract superclass for all arrays.
Definition: vtkAbstractArray.h:75
vtkTypedDataArray::Iterator
vtkTemplateTypeMacro(vtkTypedDataArray< Scalar >, GenericDataArrayType) typedef typename Superclass typedef vtkTypedDataArrayIterator< ValueType > Iterator
Typedef to a suitable iterator class.
Definition: vtkTypedDataArray.h:53
vtkAbstractArray::TypedDataArray
Definition: vtkAbstractArray.h:644
vtkArrayDownCast_TemplateFastCastMacro
vtkArrayDownCast_TemplateFastCastMacro(vtkTypedDataArray) template< class Scalar > inline typename vtkTypedDataArray< Scalar >
Definition: vtkTypedDataArray.h:188
vtkTypedDataArray::GetValue
virtual ValueType GetValue(vtkIdType idx) const =0
Get the data at a particular index.
vtkTypedDataArrayIterator
STL-style random access iterator for vtkTypedDataArrays.
Definition: vtkTypedDataArray.h:44
vtkTypedDataArray::SetTypedTuple
virtual void SetTypedTuple(vtkIdType i, const ValueType *t)=0
Set the tuple value at the ith location in the array.
vtkAbstractArray::MaxId
vtkIdType MaxId
Definition: vtkAbstractArray.h:685
vtkTypedDataArray::SetValue
virtual void SetValue(vtkIdType idx, ValueType value)=0
Set the data at a particular index.
vtkTypedDataArray::SetNumberOfValues
void SetNumberOfValues(vtkIdType num) override
Specify the number of values for this object to hold.