VTK  9.1.0
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.
106template <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.
157template <>
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
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:159
virtual double * GetTuple(vtkIdType tupleIdx)=0
Get the data tuple at tupleIdx.
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.
virtual void SetComponent(vtkIdType tupleIdx, int compIdx, double value)
Set the data component at the location specified by tupleIdx and compIdx to value.
virtual void InsertComponent(vtkIdType tupleIdx, int compIdx, double value)
Insert value at the location specified by tupleIdx and compIdx.
virtual double GetComponent(vtkIdType tupleIdx, int compIdx)
Return the data component at the location specified by tupleIdx and compIdx.
void InsertTuple(vtkIdType dstTupleIdx, vtkIdType srcTupleIdx, vtkAbstractArray *source) override
Insert the tuple at srcTupleIdx in the source array into this array at dstTupleIdx.
VTK_ALWAYS_INLINE void Insert(vtkIdType tupleIdx, int compIdx, APIType val) const
VTK_ALWAYS_INLINE void Insert(vtkIdType tupleIdx, const APIType *tuple) const
VTK_ALWAYS_INLINE APIType Get(vtkIdType tupleIdx, int compIdx) const
VTK_ALWAYS_INLINE void Set(vtkIdType tupleIdx, int compIdx, APIType val) const
VTK_ALWAYS_INLINE void Set(vtkIdType tupleIdx, const APIType *tuple) const
VTK_ALWAYS_INLINE void Get(vtkIdType tupleIdx, APIType *tuple) const
Efficient templated access to vtkDataArray.
VTK_ALWAYS_INLINE APIType Get(vtkIdType tupleIdx, int compIdx) const
VTK_ALWAYS_INLINE void Set(vtkIdType tupleIdx, const APIType *tuple) const
VTK_ALWAYS_INLINE void Insert(vtkIdType tupleIdx, int compIdx, APIType val) const
VTK_ALWAYS_INLINE void Set(vtkIdType tupleIdx, int compIdx, APIType val) const
VTK_ALWAYS_INLINE void Insert(vtkIdType tupleIdx, const APIType *tuple) const
VTK_ALWAYS_INLINE void Get(vtkIdType tupleIdx, APIType *tuple) const
ArrayType::ValueType APIType
vtkDataArrayAccessor(ArrayType *array)
int vtkIdType
Definition: vtkType.h:332