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.
100 template <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.
142 template <>
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
vtkDataArrayAccessor< vtkDataArray >::Set
void Set(vtkIdType tupleIdx, int compIdx, APIType val) const
Definition: vtkDataArrayAccessor.h:157
vtkDataArrayAccessor< vtkDataArray >::Get
void Get(vtkIdType tupleIdx, APIType *tuple) const
Definition: vtkDataArrayAccessor.h:167
vtkDataArrayAccessor
Efficient templated access to vtkDataArray.
Definition: vtkDataArrayAccessor.h:101
vtkDataArrayAccessor< vtkDataArray >::Insert
void Insert(vtkIdType tupleIdx, const APIType *tuple) const
Definition: vtkDataArrayAccessor.h:177
vtkDataArrayAccessor< vtkDataArray >::Set
void Set(vtkIdType tupleIdx, const APIType *tuple) const
Definition: vtkDataArrayAccessor.h:172
vtkDataArray::InsertTuple
void InsertTuple(vtkIdType dstTupleIdx, vtkIdType srcTupleIdx, vtkAbstractArray *source) override
Insert the tuple at srcTupleIdx in the source array into this array at dstTupleIdx.
vtkDataArrayAccessor< vtkDataArray >::APIType
double APIType
Definition: vtkDataArrayAccessor.h:146
vtkIdType
int vtkIdType
Definition: vtkType.h:347
vtkDataArrayAccessor::Insert
void Insert(vtkIdType tupleIdx, int compIdx, APIType val) const
Definition: vtkDataArrayAccessor.h:120
vtkDataArray::GetComponent
virtual double GetComponent(vtkIdType tupleIdx, int compIdx)
Return the data component at the location specified by tupleIdx and compIdx.
vtkDataArrayAccessor::APIType
ArrayType::ValueType APIType
Definition: vtkDataArrayAccessor.h:104
vtkDataArrayAccessor::Insert
void Insert(vtkIdType tupleIdx, const APIType *tuple) const
Definition: vtkDataArrayAccessor.h:135
vtkDataArrayAccessor< vtkDataArray >::Get
APIType Get(vtkIdType tupleIdx, int compIdx) const
Definition: vtkDataArrayAccessor.h:152
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:48
vtkDataArray::GetTuple
virtual double * GetTuple(vtkIdType tupleIdx)=0
Get the data tuple at tupleIdx.
vtkDataArrayAccessor::Get
APIType Get(vtkIdType tupleIdx, int compIdx) const
Definition: vtkDataArrayAccessor.h:110
vtkDataArrayAccessor::vtkDataArrayAccessor
vtkDataArrayAccessor(ArrayType *array)
Definition: vtkDataArrayAccessor.h:108
vtkDataArray::InsertComponent
virtual void InsertComponent(vtkIdType tupleIdx, int compIdx, double value)
Insert value at the location specified by tupleIdx and compIdx.
vtkDataArray::SetTuple
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::Set
void Set(vtkIdType tupleIdx, int compIdx, APIType val) const
Definition: vtkDataArrayAccessor.h:115
vtkGenericDataArray.h
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.
vtkDataArrayAccessor< vtkDataArray >::ArrayType
vtkDataArray ArrayType
Definition: vtkDataArrayAccessor.h:145
vtkDataArray.h
vtkDataArrayAccessor< vtkDataArray >::Array
ArrayType * Array
Definition: vtkDataArrayAccessor.h:148
vtkDataArrayAccessor::ArrayType
ArrayT ArrayType
Definition: vtkDataArrayAccessor.h:103
vtkDataArrayAccessor::Get
void Get(vtkIdType tupleIdx, APIType *tuple) const
Definition: vtkDataArrayAccessor.h:125
vtkDataArrayAccessor::Set
void Set(vtkIdType tupleIdx, const APIType *tuple) const
Definition: vtkDataArrayAccessor.h:130
vtkDataArrayAccessor< vtkDataArray >::Insert
void Insert(vtkIdType tupleIdx, int compIdx, APIType val) const
Definition: vtkDataArrayAccessor.h:162
vtkDataArrayAccessor::Array
ArrayType * Array
Definition: vtkDataArrayAccessor.h:106
vtkDataArrayAccessor< vtkDataArray >::vtkDataArrayAccessor
vtkDataArrayAccessor(ArrayType *array)
Definition: vtkDataArrayAccessor.h:150