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 
110 
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 
152 
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
vtkDataArrayAccessor< vtkDataArray >::Set
void Set(vtkIdType tupleIdx, int compIdx, APIType val) const
Definition: vtkDataArrayAccessor.h:160
vtkDataArrayAccessor< vtkDataArray >::Get
void Get(vtkIdType tupleIdx, APIType *tuple) const
Definition: vtkDataArrayAccessor.h:170
vtkDataArrayAccessor
Efficient templated access to vtkDataArray.
Definition: vtkDataArrayAccessor.h:104
vtkDataArrayAccessor< vtkDataArray >::Insert
void Insert(vtkIdType tupleIdx, const APIType *tuple) const
Definition: vtkDataArrayAccessor.h:180
vtkDataArrayAccessor< vtkDataArray >::Set
void Set(vtkIdType tupleIdx, const APIType *tuple) const
Definition: vtkDataArrayAccessor.h:175
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:149
vtkIdType
int vtkIdType
Definition: vtkType.h:347
vtkDataArrayAccessor::Insert
void Insert(vtkIdType tupleIdx, int compIdx, APIType val) const
Definition: vtkDataArrayAccessor.h:123
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:107
vtkDataArrayAccessor::Insert
void Insert(vtkIdType tupleIdx, const APIType *tuple) const
Definition: vtkDataArrayAccessor.h:138
vtkDataArrayAccessor< vtkDataArray >::Get
APIType Get(vtkIdType tupleIdx, int compIdx) const
Definition: vtkDataArrayAccessor.h:155
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
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:113
vtkDataArrayAccessor::vtkDataArrayAccessor
vtkDataArrayAccessor(ArrayType *array)
Definition: vtkDataArrayAccessor.h:111
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:118
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:148
vtkDataArray.h
vtkDataArrayAccessor< vtkDataArray >::Array
ArrayType * Array
Definition: vtkDataArrayAccessor.h:151
vtkDataArrayAccessor::ArrayType
ArrayT ArrayType
Definition: vtkDataArrayAccessor.h:106
vtkDataArrayAccessor::Get
void Get(vtkIdType tupleIdx, APIType *tuple) const
Definition: vtkDataArrayAccessor.h:128
vtkDataArrayAccessor::Set
void Set(vtkIdType tupleIdx, const APIType *tuple) const
Definition: vtkDataArrayAccessor.h:133
vtkDataArrayAccessor< vtkDataArray >::Insert
void Insert(vtkIdType tupleIdx, int compIdx, APIType val) const
Definition: vtkDataArrayAccessor.h:165
vtkDataArrayAccessor::Array
ArrayType * Array
Definition: vtkDataArrayAccessor.h:109
vtkDataArrayAccessor< vtkDataArray >::vtkDataArrayAccessor
vtkDataArrayAccessor(ArrayType *array)
Definition: vtkDataArrayAccessor.h:153