VTK
vtkDataArrayAccessor.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkDataArrayAccessor.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 =========================================================================*/
15 
97 #include "vtkDataArray.h"
98 #include "vtkGenericDataArray.h"
99 
100 #ifndef vtkDataArrayAccessor_h
101 #define vtkDataArrayAccessor_h
102 
103 #ifndef __VTK_WRAP__
104 
105 // Generic form for all (non-bit) vtkDataArray subclasses.
106 template <typename ArrayT>
108 {
109  typedef ArrayT ArrayType;
110  typedef typename ArrayType::ValueType APIType;
111 
113 
115  : Array(array)
116  {
117  }
118 
119  VTK_ALWAYS_INLINE
120  APIType Get(vtkIdType tupleIdx, int compIdx) const
121  {
122  return this->Array->GetTypedComponent(tupleIdx, compIdx);
123  }
124 
125  VTK_ALWAYS_INLINE
126  void Set(vtkIdType tupleIdx, int compIdx, APIType val) const
127  {
128  this->Array->SetTypedComponent(tupleIdx, compIdx, val);
129  }
130 
131  VTK_ALWAYS_INLINE
132  void Insert(vtkIdType tupleIdx, int compIdx, APIType val) const
133  {
134  this->Array->InsertTypedComponent(tupleIdx, compIdx, val);
135  }
136 
137  VTK_ALWAYS_INLINE
138  void Get(vtkIdType tupleIdx, APIType* tuple) const
139  {
140  this->Array->GetTypedTuple(tupleIdx, tuple);
141  }
142 
143  VTK_ALWAYS_INLINE
144  void Set(vtkIdType tupleIdx, const APIType* tuple) const
145  {
146  this->Array->SetTypedTuple(tupleIdx, tuple);
147  }
148 
149  VTK_ALWAYS_INLINE
150  void Insert(vtkIdType tupleIdx, const APIType* tuple) const
151  {
152  this->Array->InsertTypedTuple(tupleIdx, tuple);
153  }
154 };
155 
156 // Specialization for vtkDataArray.
157 template <>
159 {
161  typedef double APIType;
162 
164 
166  : Array(array)
167  {
168  }
169 
170  VTK_ALWAYS_INLINE
171  APIType Get(vtkIdType tupleIdx, int compIdx) const
172  {
173  return this->Array->GetComponent(tupleIdx, compIdx);
174  }
175 
176  VTK_ALWAYS_INLINE
177  void Set(vtkIdType tupleIdx, int compIdx, APIType val) const
178  {
179  this->Array->SetComponent(tupleIdx, compIdx, val);
180  }
181 
182  VTK_ALWAYS_INLINE
183  void Insert(vtkIdType tupleIdx, int compIdx, APIType val) const
184  {
185  this->Array->InsertComponent(tupleIdx, compIdx, val);
186  }
187 
188  VTK_ALWAYS_INLINE
189  void Get(vtkIdType tupleIdx, APIType* tuple) const { this->Array->GetTuple(tupleIdx, tuple); }
190 
191  VTK_ALWAYS_INLINE
192  void Set(vtkIdType tupleIdx, const APIType* tuple) const
193  {
194  this->Array->SetTuple(tupleIdx, tuple);
195  }
196 
197  VTK_ALWAYS_INLINE
198  void Insert(vtkIdType tupleIdx, const APIType* tuple) const
199  {
200  this->Array->InsertTuple(tupleIdx, tuple);
201  }
202 };
203 
204 #endif
205 
206 #endif // vtkDataArrayAccessor_h
207 // VTK-HeaderTest-Exclude: vtkDataArrayAccessor.h
vtkDataArrayAccessor
Efficient templated access to vtkDataArray.
Definition: vtkDataArrayAccessor.h:107
vtkDataArrayAccessor< vtkDataArray >::Insert
VTK_ALWAYS_INLINE void Insert(vtkIdType tupleIdx, int compIdx, APIType val) const
Definition: vtkDataArrayAccessor.h:183
vtkDataArray::InsertTuple
void InsertTuple(vtkIdType dstTupleIdx, vtkIdType srcTupleIdx, vtkAbstractArray *source) override
Insert the tuple at srcTupleIdx in the source array into this array at dstTupleIdx.
vtkDataArrayAccessor< vtkDataArray >::APIType
double APIType
Definition: vtkDataArrayAccessor.h:161
vtkIdType
int vtkIdType
Definition: vtkType.h:343
vtkDataArray::GetComponent
virtual double GetComponent(vtkIdType tupleIdx, int compIdx)
Return the data component at the location specified by tupleIdx and compIdx.
vtkDataArrayAccessor::APIType
ArrayType::ValueType APIType
Definition: vtkDataArrayAccessor.h:110
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:49
vtkDataArrayAccessor< vtkDataArray >::Set
VTK_ALWAYS_INLINE void Set(vtkIdType tupleIdx, int compIdx, APIType val) const
Definition: vtkDataArrayAccessor.h:177
vtkDataArrayAccessor< vtkDataArray >::Get
VTK_ALWAYS_INLINE void Get(vtkIdType tupleIdx, APIType *tuple) const
Definition: vtkDataArrayAccessor.h:189
vtkDataArray::GetTuple
virtual double * GetTuple(vtkIdType tupleIdx)=0
Get the data tuple at tupleIdx.
vtkDataArrayAccessor::vtkDataArrayAccessor
vtkDataArrayAccessor(ArrayType *array)
Definition: vtkDataArrayAccessor.h:114
vtkDataArrayAccessor< vtkDataArray >::Get
VTK_ALWAYS_INLINE APIType Get(vtkIdType tupleIdx, int compIdx) const
Definition: vtkDataArrayAccessor.h:171
vtkDataArray::InsertComponent
virtual void InsertComponent(vtkIdType tupleIdx, int compIdx, double value)
Insert value at the location specified by tupleIdx and compIdx.
vtkDataArray::SetTuple
void SetTuple(vtkIdType dstTupleIdx, vtkIdType srcTupleIdx, vtkAbstractArray *source) override
Set the tuple at dstTupleIdx in this array to the tuple at srcTupleIdx in the source array.
vtkGenericDataArray.h
vtkDataArray::SetComponent
virtual void SetComponent(vtkIdType tupleIdx, int compIdx, double value)
Set the data component at the location specified by tupleIdx and compIdx to value.
vtkDataArrayAccessor::Get
VTK_ALWAYS_INLINE void Get(vtkIdType tupleIdx, APIType *tuple) const
Definition: vtkDataArrayAccessor.h:138
vtkDataArrayAccessor< vtkDataArray >::ArrayType
vtkDataArray ArrayType
Definition: vtkDataArrayAccessor.h:160
vtkDataArrayAccessor::Get
VTK_ALWAYS_INLINE APIType Get(vtkIdType tupleIdx, int compIdx) const
Definition: vtkDataArrayAccessor.h:120
vtkDataArray.h
vtkDataArrayAccessor< vtkDataArray >::Array
ArrayType * Array
Definition: vtkDataArrayAccessor.h:163
vtkDataArrayAccessor::ArrayType
ArrayT ArrayType
Definition: vtkDataArrayAccessor.h:109
vtkDataArrayAccessor::Insert
VTK_ALWAYS_INLINE void Insert(vtkIdType tupleIdx, int compIdx, APIType val) const
Definition: vtkDataArrayAccessor.h:132
vtkDataArrayAccessor< vtkDataArray >::Set
VTK_ALWAYS_INLINE void Set(vtkIdType tupleIdx, const APIType *tuple) const
Definition: vtkDataArrayAccessor.h:192
vtkDataArrayAccessor::Array
ArrayType * Array
Definition: vtkDataArrayAccessor.h:112
vtkDataArrayAccessor< vtkDataArray >::vtkDataArrayAccessor
vtkDataArrayAccessor(ArrayType *array)
Definition: vtkDataArrayAccessor.h:165
vtkDataArrayAccessor::Set
VTK_ALWAYS_INLINE void Set(vtkIdType tupleIdx, const APIType *tuple) const
Definition: vtkDataArrayAccessor.h:144
vtkDataArrayAccessor::Set
VTK_ALWAYS_INLINE void Set(vtkIdType tupleIdx, int compIdx, APIType val) const
Definition: vtkDataArrayAccessor.h:126
vtkDataArrayAccessor< vtkDataArray >::Insert
VTK_ALWAYS_INLINE void Insert(vtkIdType tupleIdx, const APIType *tuple) const
Definition: vtkDataArrayAccessor.h:198
vtkDataArrayAccessor::Insert
VTK_ALWAYS_INLINE void Insert(vtkIdType tupleIdx, const APIType *tuple) const
Definition: vtkDataArrayAccessor.h:150