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
93#include "vtkDataArray.h"
94#include "vtkGenericDataArray.h"
95
96#ifndef vtkDataArrayAccessor_h
97#define vtkDataArrayAccessor_h
98
99// Generic form for all (non-bit) vtkDataArray subclasses.
100template <typename ArrayT>
102{
103 typedef ArrayT ArrayType;
104 typedef typename ArrayType::ValueType APIType;
105
107
109
110 inline APIType Get(vtkIdType tupleIdx, int compIdx) const
111 {
112 return this->Array->GetTypedComponent(tupleIdx, compIdx);
113 }
114
115 inline void Set(vtkIdType tupleIdx, int compIdx, APIType val) const
116 {
117 this->Array->SetTypedComponent(tupleIdx, compIdx, val);
118 }
119
120 inline void Insert(vtkIdType tupleIdx, int compIdx, APIType val) const
121 {
122 this->Array->InsertTypedComponent(tupleIdx, compIdx, val);
123 }
124
125 inline void Get(vtkIdType tupleIdx, APIType *tuple) const
126 {
127 this->Array->GetTypedTuple(tupleIdx, tuple);
128 }
129
130 inline void Set(vtkIdType tupleIdx, const APIType *tuple) const
131 {
132 this->Array->SetTypedTuple(tupleIdx, tuple);
133 }
134
135 inline void Insert(vtkIdType tupleIdx, const APIType *tuple) const
136 {
137 this->Array->InsertTypedTuple(tupleIdx, tuple);
138 }
139};
140
141// Specialization for vtkDataArray.
142template <>
144{
146 typedef double APIType;
147
149
151
152 inline APIType Get(vtkIdType tupleIdx, int compIdx) const
153 {
154 return this->Array->GetComponent(tupleIdx, compIdx);
155 }
156
157 inline void Set(vtkIdType tupleIdx, int compIdx, APIType val) const
158 {
159 this->Array->SetComponent(tupleIdx, compIdx, val);
160 }
161
162 inline void Insert(vtkIdType tupleIdx, int compIdx, APIType val) const
163 {
164 this->Array->InsertComponent(tupleIdx, compIdx, val);
165 }
166
167 inline void Get(vtkIdType tupleIdx, APIType *tuple) const
168 {
169 this->Array->GetTuple(tupleIdx, tuple);
170 }
171
172 inline void Set(vtkIdType tupleIdx, const APIType *tuple) const
173 {
174 this->Array->SetTuple(tupleIdx, tuple);
175 }
176
177 inline void Insert(vtkIdType tupleIdx, const APIType *tuple) const
178 {
179 this->Array->InsertTuple(tupleIdx, tuple);
180 }
181};
182
183#endif // vtkDataArrayAccessor_h
184// VTK-HeaderTest-Exclude: vtkDataArrayAccessor.h
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:55
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.
void Insert(vtkIdType tupleIdx, int compIdx, APIType val) const
void Get(vtkIdType tupleIdx, APIType *tuple) const
void Set(vtkIdType tupleIdx, int compIdx, APIType val) const
APIType Get(vtkIdType tupleIdx, int compIdx) const
void Insert(vtkIdType tupleIdx, const APIType *tuple) const
void Set(vtkIdType tupleIdx, const APIType *tuple) const
Efficient templated access to vtkDataArray.
void Set(vtkIdType tupleIdx, int compIdx, APIType val) const
void Insert(vtkIdType tupleIdx, int compIdx, APIType val) const
void Set(vtkIdType tupleIdx, const APIType *tuple) const
void Get(vtkIdType tupleIdx, APIType *tuple) const
void Insert(vtkIdType tupleIdx, const APIType *tuple) const
ArrayType::ValueType APIType
vtkDataArrayAccessor(ArrayType *array)
APIType Get(vtkIdType tupleIdx, int compIdx) const
int vtkIdType
Definition: vtkType.h:287