Go to the documentation of this file.
31 #ifndef vtkSOADataArrayTemplate_h
32 #define vtkSOADataArrayTemplate_h
34 #include "vtkCommonCoreModule.h"
40 template <
class ValueTypeT>
49 typedef typename Superclass::ValueType
ValueType;
69 this->GetTupleIndexFromValueIndex(valueIdx, tupleIdx, comp);
82 this->GetTupleIndexFromValueIndex(valueIdx, tupleIdx, comp);
92 for (
size_t cc=0; cc < this->Data.size(); cc++)
94 tuple[cc] = this->Data[cc]->GetBuffer()[tupleIdx];
103 for (
size_t cc=0; cc < this->Data.size(); ++cc)
105 this->Data[cc]->GetBuffer()[tupleIdx] = tuple[cc];
114 return this->Data[comp]->GetBuffer()[tupleIdx];
122 this->Data[comp]->GetBuffer()[tupleIdx] =
value;
144 bool updateMaxId =
false,
bool save=
false,
145 int deleteMethod=VTK_DATA_ARRAY_FREE);
195 switch (
source->GetArrayType())
198 if (vtkDataTypesCompare(
source->GetDataType(),
223 { this->Superclass::InsertTuples(dstIds, srcIds,
source); }
241 std::vector<vtkBuffer<ValueType>*>
Data;
250 inline void GetTupleIndexFromValueIndex(
vtkIdType valueIdx,
253 tupleIdx =
static_cast<vtkIdType>(valueIdx *
254 this->NumberOfComponentsReciprocal);
265 #endif // header guard
271 #ifdef VTK_SOA_DATA_ARRAY_TEMPLATE_INSTANTIATING
272 #define VTK_SOA_DATA_ARRAY_TEMPLATE_INSTANTIATE(T) \
273 template class VTKCOMMONCORE_EXPORT vtkSOADataArrayTemplate< T >
274 #elif defined(VTK_USE_EXTERN_TEMPLATE)
275 #ifndef VTK_SOA_DATA_ARRAY_TEMPLATE_EXTERN
276 #define VTK_SOA_DATA_ARRAY_TEMPLATE_EXTERN
278 #pragma warning (push)
281 #pragma warning (disable: 4910) // extern and dllexport incompatible
286 #pragma warning (pop)
288 #endif // VTK_SOA_DATA_ARRAY_TEMPLATE_EXTERN
291 #elif defined(_MSC_VER) && !defined(VTK_BUILD_SHARED_LIBS)
292 #pragma warning (push)
295 #pragma warning (disable: 4091)
298 #pragma warning (disable: 4231)
311 #pragma warning (disable: 4910) // extern and dllexport incompatible
318 #pragma warning (pop)
@ VTK_DATA_ARRAY_ALIGNED_FREE
vtkBuffer< ValueType > * AoSCopy
ValueType GetTypedComponent(vtkIdType tupleIdx, int compIdx) const
Get component compIdx of the tuple at tupleIdx.
Template defining traits of native types used by VTK.
void SetArray(int comp, ValueType *array, vtkIdType size, bool updateMaxId=false, bool save=false, int deleteMethod=VTK_DATA_ARRAY_FREE)
Use this API to pass externally allocated memory to this instance.
~vtkSOADataArrayTemplate() override
void ExportToVoidPointer(void *ptr) override
Export a copy of the data in AoS ordering to the preallocated memory buffer.
Struct-Of-Arrays implementation of vtkGenericDataArray.
void SetTypedTuple(vtkIdType tupleIdx, const ValueType *tuple)
Set this array's tuple at tupleIdx to the values in tuple.
ValueType GetTypedComponent(vtkIdType tupleIdx, int comp) const
Get component comp of the tuple at tupleIdx.
void save(Archiver &ar, const vtkUnicodeString &str, const unsigned int vtkNotUsed(version))
void FillTypedComponent(int compIdx, ValueType value) override
Set component comp of all tuples to value.
void SetTypedComponent(vtkIdType tupleIdx, int compIdx, ValueType value)
Set component compIdx of the tuple at tupleIdx to value.
Base interface for all typed vtkDataArray subclasses.
abstract superclass for arrays of numeric data
bool ReallocateTuples(vtkIdType numTuples)
Allocate space for numTuples.
static vtkSOADataArrayTemplate< ValueType > * FastDownCast(vtkAbstractArray *source)
Perform a fast, safe cast from a vtkAbstractArray to a vtkDataArray.
vtkSOADataArrayTemplate< ValueTypeT > SelfType
void SetArrayFreeFunction(void(*callback)(void *)) override
This method allows the user to specify a custom free function to be called when the array is dealloca...
bool AllocateTuples(vtkIdType numTuples)
Allocate space for numTuples.
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
vtkSOADataArrayTemplate()
ValueType * GetComponentArrayPointer(int comp)
Return a pointer to a contiguous block of memory containing all values for a particular components (i...
double NumberOfComponentsReciprocal
#define vtkExternTemplateMacro(decl)
A macro to declare extern templates for all numerical types.
@ VTK_DATA_ARRAY_USER_DEFINED
void SetValue(vtkIdType valueIdx, ValueType value)
Set the value at valueIdx to value.
vtkTemplateTypeMacro(SelfType, vtkDataArray) enum
Compile time access to the VTK type identifier.
list of point or cell ids
void ShallowCopy(vtkDataArray *other) override
Create a shallow copy of other into this, if possible.
void InsertTuples(vtkIdType dstStart, vtkIdType n, vtkIdType srcStart, vtkAbstractArray *source) override
Copy n consecutive tuples starting at srcStart from the source array to this array,...
Abstract superclass for all arrays.
vtkArrayIterator * NewIterator() override
Subclasses must override this method and provide the right kind of templated vtkArrayIteratorTemplate...
#define vtkInstantiateTemplateMacro(decl)
A macro to instantiate a template over all numerical types.
void GetTypedTuple(vtkIdType tupleIdx, ValueType *tuple) const
Copy the tuple at tupleIdx into tuple.
void InsertTuples(vtkIdList *dstIds, vtkIdList *srcIds, vtkAbstractArray *source) override
Copy the tuples indexed in srcIds from the source array to the tuple locations indexed by dstIds in t...
void * GetVoidPointer(vtkIdType valueIdx) override
Use of this method is discouraged, it creates a deep copy of the data into a contiguous AoS-ordered b...
std::vector< vtkBuffer< ValueType > * > Data
Abstract superclass to iterate over elements in an vtkAbstractArray.
vtkArrayDownCast_TemplateFastCastMacro(vtkTypedDataArray) template< class Scalar > inline typename vtkTypedDataArray< Scalar >
int GetArrayType() override
Method for type-checking in FastDownCast implementations.
void SetArrayFreeFunction(int comp, void(*callback)(void *))
This method allows the user to specify a custom free function to be called when the array is dealloca...
static vtkSOADataArrayTemplate * New()
void SetNumberOfComponents(int numComps) override
Set/Get the dimension (n) of the components.
ValueType GetValue(vtkIdType valueIdx) const
Get the value at valueIdx.
void SetTypedComponent(vtkIdType tupleIdx, int comp, ValueType value)
Set component comp of the tuple at tupleIdx to value.