VTK: Common/Core/vtkDataArrayAccessor.h Source File

| VTK 9.3.1

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