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