VTK  9.4.20241108
vtkDataArrayAccessor.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-License-Identifier: BSD-3-Clause
3
88#include "vtkDataArray.h"
89#include "vtkGenericDataArray.h"
90
91#ifndef vtkDataArrayAccessor_h
92#define vtkDataArrayAccessor_h
93
94// Generic form for all (non-bit) vtkDataArray subclasses.
95VTK_ABI_NAMESPACE_BEGIN
96template <typename ArrayT>
98{
99 typedef ArrayT ArrayType;
100 typedef typename ArrayType::ValueType APIType;
101
103
105 : Array(array)
106 {
107 }
108
109 VTK_ALWAYS_INLINE
110 APIType Get(vtkIdType tupleIdx, int compIdx) const
111 {
112 return this->Array->GetTypedComponent(tupleIdx, compIdx);
113 }
114
115 VTK_ALWAYS_INLINE
116 void Set(vtkIdType tupleIdx, int compIdx, APIType val) const
117 {
118 this->Array->SetTypedComponent(tupleIdx, compIdx, val);
119 }
120
121 VTK_ALWAYS_INLINE
122 void Insert(vtkIdType tupleIdx, int compIdx, APIType val) const
123 {
124 this->Array->InsertTypedComponent(tupleIdx, compIdx, val);
125 }
126
127 VTK_ALWAYS_INLINE
128 void Get(vtkIdType tupleIdx, APIType* tuple) const
129 {
130 this->Array->GetTypedTuple(tupleIdx, tuple);
131 }
132
133 VTK_ALWAYS_INLINE
134 void Set(vtkIdType tupleIdx, const APIType* tuple) const
135 {
136 this->Array->SetTypedTuple(tupleIdx, tuple);
137 }
138
139 VTK_ALWAYS_INLINE
140 void Insert(vtkIdType tupleIdx, const APIType* tuple) const
141 {
142 this->Array->InsertTypedTuple(tupleIdx, tuple);
143 }
144};
145
146// Specialization for vtkDataArray.
147template <>
149{
151 typedef double APIType;
152
154
156 : Array(array)
157 {
158 }
159
160 VTK_ALWAYS_INLINE
161 APIType Get(vtkIdType tupleIdx, int compIdx) const
162 {
163 return this->Array->GetComponent(tupleIdx, compIdx);
164 }
165
166 VTK_ALWAYS_INLINE
167 void Set(vtkIdType tupleIdx, int compIdx, APIType val) const
168 {
169 this->Array->SetComponent(tupleIdx, compIdx, val);
170 }
171
172 VTK_ALWAYS_INLINE
173 void Insert(vtkIdType tupleIdx, int compIdx, APIType val) const
174 {
175 this->Array->InsertComponent(tupleIdx, compIdx, val);
176 }
177
178 VTK_ALWAYS_INLINE
179 void Get(vtkIdType tupleIdx, APIType* tuple) const { this->Array->GetTuple(tupleIdx, tuple); }
180
181 VTK_ALWAYS_INLINE
182 void Set(vtkIdType tupleIdx, const APIType* tuple) const
183 {
184 this->Array->SetTuple(tupleIdx, tuple);
185 }
186
187 VTK_ALWAYS_INLINE
188 void Insert(vtkIdType tupleIdx, const APIType* tuple) const
189 {
190 this->Array->InsertTuple(tupleIdx, tuple);
191 }
192};
193
194VTK_ABI_NAMESPACE_END
195#endif // vtkDataArrayAccessor_h
196// VTK-HeaderTest-Exclude: vtkDataArrayAccessor.h
abstract superclass for arrays of numeric data
virtual double * GetTuple(vtkIdType tupleIdx)=0
Get the data tuple at tupleIdx.
void SetTuple(vtkIdType dstTupleIdx, vtkIdType srcTupleIdx, vtkAbstractArray *source) override
See documentation from parent class.
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
See documentation from parent class.
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:315