4#ifndef vtkImplicitArray_h
5#define vtkImplicitArray_h
7#include "vtkCommonCoreModule.h"
145#define vtkImplicitArrayTypeMacro(thisClass, superclass) \
146 vtkAbstractTypeMacroWithNewInstanceType(thisClass, superclass, \
147 vtkAOSDataArrayTemplate<typename thisClass::ValueType>, typeid(thisClass).name()); \
150 vtkObjectBase* NewInstanceInternal() const override \
152 return vtkAOSDataArrayTemplate<typename thisClass::ValueType>::New(); \
158VTK_ABI_NAMESPACE_BEGIN
159template <
class BackendT,
int ArrayType = vtkArrayTypes::VTK_IMPLICIT_ARRAY>
162 typename vtk::detail::implicit_array_traits<BackendT>::rtype, ArrayType>
166 "Supplied backend type does not have mandatory read trait. Must implement either map() const "
167 "or operator() const.");
169 using GenericDataArrayType =
177 using typename Superclass::ValueType;
201 this->GetTypedTupleImpl<BackendT>(idx, tuple);
214 return this->GetTypedComponentImpl<BackendT>(idx, comp);
238 template <
typename... Params>
241 this->
SetBackend(std::make_shared<BackendT>(std::forward<Params>(params)...));
281 return this->GetActualMemorySizeImpl<BackendT>();
296 template <
typename OtherBackend,
int OtherArrayType>
299 static_assert(std::is_same_v<BackendT, OtherBackend>,
300 "Cannot copy implicit array with one type of backend to an implicit array with a different "
302 static_assert(ArrayTypeTag::value == OtherArrayType,
303 "Cannot copy implicit array with one array type to an implicit array with a different "
309 using vtkDataArray::DeepCopy;
312 if (da ==
nullptr || da ==
this)
324 this->vtkDataArray::DeepCopy(da);
367 template <
typename U>
368 typename std::enable_if<vtk::detail::has_map_trait<U>::value,
ValueType>::type GetValueImpl(
371 return this->Backend->map(idx);
379 template <
typename U>
380 typename std::enable_if<vtk::detail::is_closure_trait<U>::value,
ValueType>::type GetValueImpl(
383 return (*this->Backend)(idx);
391 template <
typename U>
392 typename std::enable_if<vtk::detail::implicit_array_traits<U>::default_constructible,
void>::type
395 this->
Backend = std::make_shared<BackendT>();
403 template <
typename U>
404 typename std::enable_if<!vtk::detail::implicit_array_traits<U>::default_constructible,
void>::type
415 template <
typename U>
416 typename std::enable_if<vtk::detail::implicit_array_traits<U>::can_direct_read_tuple,
void>::type
420 std::is_same<typename vtk::detail::can_map_tuple_trait<U>::rtype,
ValueType>::value,
421 "Tuple type should be the same as the return type of the mapTuple");
422 this->
Backend->mapTuple(idx, tuple);
430 template <
typename U>
431 typename std::enable_if<!vtk::detail::implicit_array_traits<U>::can_direct_read_tuple &&
445 template <
typename U>
446 typename std::enable_if<!vtk::detail::implicit_array_traits<U>::can_direct_read_tuple &&
454 tuple[comp] = this->
GetValue(tupIdx + comp);
463 template <
typename U>
464 typename std::enable_if<vtk::detail::implicit_array_traits<U>::can_direct_read_component,
466 GetTypedComponentImpl(
vtkIdType idx,
int comp)
const
469 std::is_same<typename vtk::detail::can_map_component_trait<U>::rtype,
ValueType>::value,
470 "Component return type should be the same as the return type of the mapComponent");
471 return this->
Backend->mapComponent(idx, comp);
479 template <
typename U>
480 typename std::enable_if<!vtk::detail::implicit_array_traits<U>::can_direct_read_component,
482 GetTypedComponentImpl(
vtkIdType idx,
int comp)
const
492 template <
typename U>
493 typename std::enable_if<vtk::detail::implicit_array_traits<U>::can_get_memory_size,
495 GetActualMemorySizeImpl()
const
497 return this->
Backend->getMemorySize();
504 template <
typename U>
505 typename std::enable_if<!vtk::detail::implicit_array_traits<U>::can_get_memory_size,
507 GetActualMemorySizeImpl()
const
520#include "vtkImplicitArray.txx"
522#define vtkCreateReadOnlyWrappedArrayInterface(T) \
523 int GetDataType() const override; \
524 T GetDataTypeValueMin() const; \
525 T GetDataTypeValueMax() const; \
526 void GetTypedTuple(vtkIdType i, T* tuple) VTK_EXPECTS(0 <= i && i < GetNumberOfTuples()); \
527 T GetValue(vtkIdType id) const VTK_EXPECTS(0 <= id && id < GetNumberOfValues()); \
528 T* GetValueRange(int comp) VTK_SIZEHINT(2); \
529 T* GetValueRange() VTK_SIZEHINT(2);
533#define VTK_WRAP_TEMPLATE(...) __VA_ARGS__
535#ifdef VTK_USE_EXTERN_TEMPLATE
537#ifndef VTK_IMPLICIT_TEMPLATE_EXTERN
538#define VTK_IMPLICIT_TEMPLATE_EXTERN
543#pragma warning(disable : 4910)
546VTK_ABI_NAMESPACE_BEGIN
547template <typename ValueType>
549template <typename ValueType>
551template <typename ValueType>
553template <typename ValueType>
555template <typename ValueType>
562VTK_ABI_NAMESPACE_BEGIN
563template <
typename A,
typename R,
typename T>
564VTKCOMMONCORE_EXPORT
bool DoComputeScalarRange(
565 A*, R*, T,
const unsigned char* ghosts,
unsigned char ghostsToSkip);
566template <
typename A,
typename R>
567VTKCOMMONCORE_EXPORT
bool DoComputeVectorRange(
568 A*, R[2], AllValues,
const unsigned char* ghosts,
unsigned char ghostsToSkip);
569template <
typename A,
typename R>
570VTKCOMMONCORE_EXPORT
bool DoComputeVectorRange(
571 A*, R[2], FiniteValues,
const unsigned char* ghosts,
unsigned char ghostsToSkip);
575#define VTK_DECLARE_VALUERANGE_IMPLICIT_BACKENDTYPE(BackendT, ArrayTypeValue) \
576 VTK_DECLARE_VALUERANGE_ARRAYTYPE( \
577 VTK_WRAP_TEMPLATE(vtkImplicitArray<BackendT<float>, ArrayTypeValue>), double) \
578 VTK_DECLARE_VALUERANGE_ARRAYTYPE( \
579 VTK_WRAP_TEMPLATE(vtkImplicitArray<BackendT<double>, ArrayTypeValue>), double) \
580 VTK_DECLARE_VALUERANGE_ARRAYTYPE( \
581 VTK_WRAP_TEMPLATE(vtkImplicitArray<BackendT<char>, ArrayTypeValue>), double) \
582 VTK_DECLARE_VALUERANGE_ARRAYTYPE( \
583 VTK_WRAP_TEMPLATE(vtkImplicitArray<BackendT<signed char>, ArrayTypeValue>), double) \
584 VTK_DECLARE_VALUERANGE_ARRAYTYPE( \
585 VTK_WRAP_TEMPLATE(vtkImplicitArray<BackendT<unsigned char>, ArrayTypeValue>), double) \
586 VTK_DECLARE_VALUERANGE_ARRAYTYPE( \
587 VTK_WRAP_TEMPLATE(vtkImplicitArray<BackendT<short>, ArrayTypeValue>), double) \
588 VTK_DECLARE_VALUERANGE_ARRAYTYPE( \
589 VTK_WRAP_TEMPLATE(vtkImplicitArray<BackendT<unsigned short>, ArrayTypeValue>), double) \
590 VTK_DECLARE_VALUERANGE_ARRAYTYPE( \
591 VTK_WRAP_TEMPLATE(vtkImplicitArray<BackendT<int>, ArrayTypeValue>), double) \
592 VTK_DECLARE_VALUERANGE_ARRAYTYPE( \
593 VTK_WRAP_TEMPLATE(vtkImplicitArray<BackendT<unsigned int>, ArrayTypeValue>), double) \
594 VTK_DECLARE_VALUERANGE_ARRAYTYPE( \
595 VTK_WRAP_TEMPLATE(vtkImplicitArray<BackendT<long>, ArrayTypeValue>), double) \
596 VTK_DECLARE_VALUERANGE_ARRAYTYPE( \
597 VTK_WRAP_TEMPLATE(vtkImplicitArray<BackendT<unsigned long>, ArrayTypeValue>), double) \
598 VTK_DECLARE_VALUERANGE_ARRAYTYPE( \
599 VTK_WRAP_TEMPLATE(vtkImplicitArray<BackendT<long long>, ArrayTypeValue>), double) \
600 VTK_DECLARE_VALUERANGE_ARRAYTYPE( \
601 VTK_WRAP_TEMPLATE(vtkImplicitArray<BackendT<unsigned long long>, ArrayTypeValue>), double)
605VTK_ABI_NAMESPACE_BEGIN
Abstract superclass for all arrays.
int GetNumberOfComponents() const
Set/Get the dimension (n) of the components.
vtkIdType GetNumberOfTuples() const
Get the number of complete tuples (a component group) in the array.
std::integral_constant< int, VTK_OPAQUE > DataTypeTag
std::integral_constant< int, vtkArrayTypes::VTK_ABSTRACT_ARRAY > ArrayTypeTag
A utility structure serving as a backend for composite arrays: an array composed of multiple arrays c...
void Modified() override
Removes out-of-date L2_NORM_RANGE() and L2_NORM_FINITE_RANGE() values.
Base interface for all typed vtkDataArray subclasses.
vtk::detail::implicit_array_traits< BackendT >::rtype ValueType
void Initialize() override
void SetNumberOfTuples(vtkIdType number) override
void SetNumberOfComponents(int num) override
A read only array class that wraps an implicit function from integers to any value type supported by ...
vtkImplicitArrayTypeMacro(SelfType, GenericDataArrayType)
void ImplicitDeepCopy(vtkImplicitArray< OtherBackend, OtherArrayType > *other)
void SetTypedTuple(vtkIdType tupleIdx, const ValueType *tuple)
void SetTypedComponent(vtkIdType tupleIdx, int comp, ValueType value)
std::unique_ptr< vtkInternals > Internals
bool AllocateTuples(vtkIdType numTuples)
void ConstructBackend(Params &&... params)
bool ReallocateTuples(vtkIdType numTuples)
std::shared_ptr< vtkAffineImplicitBackend< T > > GetBackend()
static vtkImplicitArray< BackendT, ArrayType > * FastDownCast(vtkAbstractArray *source)
Perform a fast, safe cast from a vtkAbstractArray to a vtkDataArray.
static vtkImplicitArray * New()
unsigned long GetActualMemorySize() const override
void SetBackend(std::shared_ptr< vtkAffineImplicitBackend< T > > newBackend)
void SetValue(vtkIdType idx, ValueType value)
ValueType GetValue(vtkIdType idx) const
ValueType GetTypedComponent(vtkIdType idx, int comp) const
void Initialize() override
vtkImplicitArray< vtkAffineImplicitBackend< T >, ArrayType > SelfType
vtkAffineImplicitBackend< T > BackendType
std::integral_constant< int, vtkArrayTypes::VTK_ABSTRACT_ARRAY > ArrayTypeTag
void * GetVoidPointer(vtkIdType valueIdx) override
void DeepCopy(vtkDataArray *da) override
std::shared_ptr< vtkAffineImplicitBackend< T > > Backend
void GetTypedTuple(vtkIdType idx, ValueType *tuple) const
~vtkImplicitArray() override
A backend for the vtkImplicitArray framework allowing one to use a subset of a given data array,...
A backend for the vtkImplicitArray to query structured points efficiently.
VTK_DECLARE_VALUERANGE_IMPLICIT_BACKENDTYPE(vtkAffineImplicitBackend, vtkArrayTypes::VTK_AFFINE_ARRAY) VTK_DECLARE_VALUERANGE_IMPLICIT_BACKENDTYPE(vtkConstantImplicitBackend
A utility structure serving as a backend for affine (as a function of the index) implicit arrays.
A utility structure serving as a backend for constant implicit arrays.
A composite trait for handling all the different capabilities a "backend" to an implicit array can ha...
static constexpr bool can_read
static constexpr bool can_direct_read_component
typename trait::rtype rtype
#define vtkArrayDownCast_Template2FastCastMacro(ArrayT)
Same as vtkArrayDownCast_FastCastMacro, but treats ArrayT as a two-parameter template (the parameter ...
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
#define VTK_DECLARE_VALUERANGE_ARRAYTYPE(ArrayType, ValueType)
#define VTK_DECLARE_VALUERANGE_IMPLICIT_BACKENDTYPE(BackendT, ArrayTypeValue)
#define VTK_WRAP_TEMPLATE(...)
@ VTK_STRUCTURED_POINT_ARRAY