VTK  9.2.5
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 // Generic form for all (non-bit) vtkDataArray subclasses.
104 template <typename ArrayT>
106 {
107  typedef ArrayT ArrayType;
108  typedef typename ArrayType::ValueType APIType;
109 
111 
113  : Array(array)
114  {
115  }
116 
117  VTK_ALWAYS_INLINE
118  APIType Get(vtkIdType tupleIdx, int compIdx) const
119  {
120  return this->Array->GetTypedComponent(tupleIdx, compIdx);
121  }
122 
123  VTK_ALWAYS_INLINE
124  void Set(vtkIdType tupleIdx, int compIdx, APIType val) const
125  {
126  this->Array->SetTypedComponent(tupleIdx, compIdx, val);
127  }
128 
129  VTK_ALWAYS_INLINE
130  void Insert(vtkIdType tupleIdx, int compIdx, APIType val) const
131  {
132  this->Array->InsertTypedComponent(tupleIdx, compIdx, val);
133  }
134 
135  VTK_ALWAYS_INLINE
136  void Get(vtkIdType tupleIdx, APIType* tuple) const
137  {
138  this->Array->GetTypedTuple(tupleIdx, tuple);
139  }
140 
141  VTK_ALWAYS_INLINE
142  void Set(vtkIdType tupleIdx, const APIType* tuple) const
143  {
144  this->Array->SetTypedTuple(tupleIdx, tuple);
145  }
146 
147  VTK_ALWAYS_INLINE
148  void Insert(vtkIdType tupleIdx, const APIType* tuple) const
149  {
150  this->Array->InsertTypedTuple(tupleIdx, tuple);
151  }
152 };
153 
154 // Specialization for vtkDataArray.
155 template <>
157 {
159  typedef double APIType;
160 
162 
164  : Array(array)
165  {
166  }
167 
168  VTK_ALWAYS_INLINE
169  APIType Get(vtkIdType tupleIdx, int compIdx) const
170  {
171  return this->Array->GetComponent(tupleIdx, compIdx);
172  }
173 
174  VTK_ALWAYS_INLINE
175  void Set(vtkIdType tupleIdx, int compIdx, APIType val) const
176  {
177  this->Array->SetComponent(tupleIdx, compIdx, val);
178  }
179 
180  VTK_ALWAYS_INLINE
181  void Insert(vtkIdType tupleIdx, int compIdx, APIType val) const
182  {
183  this->Array->InsertComponent(tupleIdx, compIdx, val);
184  }
185 
186  VTK_ALWAYS_INLINE
187  void Get(vtkIdType tupleIdx, APIType* tuple) const { this->Array->GetTuple(tupleIdx, tuple); }
188 
189  VTK_ALWAYS_INLINE
190  void Set(vtkIdType tupleIdx, const APIType* tuple) const
191  {
192  this->Array->SetTuple(tupleIdx, tuple);
193  }
194 
195  VTK_ALWAYS_INLINE
196  void Insert(vtkIdType tupleIdx, const APIType* tuple) const
197  {
198  this->Array->InsertTuple(tupleIdx, tuple);
199  }
200 };
201 
202 #endif // vtkDataArrayAccessor_h
203 // VTK-HeaderTest-Exclude: vtkDataArrayAccessor.h
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:165
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 * GetTuple(vtkIdType tupleIdx)=0
Get the data tuple at tupleIdx.
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:332