4#ifndef vtkImplicitArray_h
5#define vtkImplicitArray_h
7#include "vtkCommonCoreModule.h"
143#define vtkImplicitArrayTypeMacro(thisClass, superclass) \
144 vtkAbstractTypeMacroWithNewInstanceType(thisClass, superclass, \
145 vtkAOSDataArrayTemplate<typename thisClass::ValueType>, typeid(thisClass).name()); \
148 vtkObjectBase* NewInstanceInternal() const override \
150 return vtkAOSDataArrayTemplate<typename thisClass::ValueType>::New(); \
156VTK_ABI_NAMESPACE_BEGIN
157template <
class BackendT,
int ArrayType = vtkArrayTypes::VTK_IMPLICIT_ARRAY>
160 typename vtk::detail::implicit_array_traits<BackendT>::rtype, ArrayType>
164 "Supplied backend type does not have mandatory read trait. Must implement either map() const "
165 "or operator() const.");
167 using GenericDataArrayType =
175 using typename Superclass::ValueType;
199 this->GetTypedTupleImpl<BackendT>(idx, tuple);
212 return this->GetTypedComponentImpl<BackendT>(idx, comp);
236 template <
typename... Params>
239 this->
SetBackend(std::make_shared<BackendT>(std::forward<Params>(params)...));
263 return this->GetActualMemorySizeImpl<BackendT>();
278 template <
typename OtherBackend,
int OtherArrayType>
281 static_assert(std::is_same_v<BackendT, OtherBackend>,
282 "Cannot copy implicit array with one type of backend to an implicit array with a different "
284 static_assert(ArrayTypeTag::value == OtherArrayType,
285 "Cannot copy implicit array with one array type to an implicit array with a different "
291 using vtkDataArray::DeepCopy;
294 if (da ==
nullptr || da ==
this)
306 this->vtkDataArray::DeepCopy(da);
346 template <
typename U>
347 typename std::enable_if<vtk::detail::has_map_trait<U>::value,
ValueType>::type GetValueImpl(
350 return this->Backend->map(idx);
358 template <
typename U>
359 typename std::enable_if<vtk::detail::is_closure_trait<U>::value,
ValueType>::type GetValueImpl(
362 return (*this->Backend)(idx);
370 template <
typename U>
371 typename std::enable_if<vtk::detail::implicit_array_traits<U>::default_constructible,
void>::type
374 this->
Backend = std::make_shared<BackendT>();
382 template <
typename U>
383 typename std::enable_if<!vtk::detail::implicit_array_traits<U>::default_constructible,
void>::type
394 template <
typename U>
395 typename std::enable_if<vtk::detail::implicit_array_traits<U>::can_direct_read_tuple,
void>::type
399 std::is_same<typename vtk::detail::can_map_tuple_trait<U>::rtype,
ValueType>::value,
400 "Tuple type should be the same as the return type of the mapTuple");
401 this->
Backend->mapTuple(idx, tuple);
409 template <
typename U>
410 typename std::enable_if<!vtk::detail::implicit_array_traits<U>::can_direct_read_tuple &&
424 template <
typename U>
425 typename std::enable_if<!vtk::detail::implicit_array_traits<U>::can_direct_read_tuple &&
433 tuple[comp] = this->
GetValue(tupIdx + comp);
442 template <
typename U>
443 typename std::enable_if<vtk::detail::implicit_array_traits<U>::can_direct_read_component,
445 GetTypedComponentImpl(
vtkIdType idx,
int comp)
const
448 std::is_same<typename vtk::detail::can_map_component_trait<U>::rtype,
ValueType>::value,
449 "Component return type should be the same as the return type of the mapComponent");
450 return this->
Backend->mapComponent(idx, comp);
458 template <
typename U>
459 typename std::enable_if<!vtk::detail::implicit_array_traits<U>::can_direct_read_component,
461 GetTypedComponentImpl(
vtkIdType idx,
int comp)
const
471 template <
typename U>
472 typename std::enable_if<vtk::detail::implicit_array_traits<U>::can_get_memory_size,
474 GetActualMemorySizeImpl()
const
476 return this->
Backend->getMemorySize();
483 template <
typename U>
484 typename std::enable_if<!vtk::detail::implicit_array_traits<U>::can_get_memory_size,
486 GetActualMemorySizeImpl()
const
499#include "vtkImplicitArray.txx"
501#define vtkCreateReadOnlyWrappedArrayInterface(T) \
502 int GetDataType() const override; \
503 T GetDataTypeValueMin() const; \
504 T GetDataTypeValueMax() const; \
505 void GetTypedTuple(vtkIdType i, T* tuple) VTK_EXPECTS(0 <= i && i < GetNumberOfTuples()); \
506 T GetValue(vtkIdType id) const VTK_EXPECTS(0 <= id && id < GetNumberOfValues()); \
507 T* GetValueRange(int comp) VTK_SIZEHINT(2); \
508 T* GetValueRange() VTK_SIZEHINT(2);
512#define VTK_WRAP_TEMPLATE(...) __VA_ARGS__
514#ifdef VTK_USE_EXTERN_TEMPLATE
516#ifndef VTK_IMPLICIT_TEMPLATE_EXTERN
517#define VTK_IMPLICIT_TEMPLATE_EXTERN
522#pragma warning(disable : 4910)
525VTK_ABI_NAMESPACE_BEGIN
526template <typename ValueType>
528template <typename ValueType>
530template <typename ValueType>
532template <typename ValueType>
534template <typename ValueType>
541VTK_ABI_NAMESPACE_BEGIN
542template <
typename A,
typename R,
typename T>
543VTKCOMMONCORE_EXPORT
bool DoComputeScalarRange(
544 A*, R*, T,
const unsigned char* ghosts,
unsigned char ghostsToSkip);
545template <
typename A,
typename R>
546VTKCOMMONCORE_EXPORT
bool DoComputeVectorRange(
547 A*, R[2], AllValues,
const unsigned char* ghosts,
unsigned char ghostsToSkip);
548template <
typename A,
typename R>
549VTKCOMMONCORE_EXPORT
bool DoComputeVectorRange(
550 A*, R[2], FiniteValues,
const unsigned char* ghosts,
unsigned char ghostsToSkip);
554#define VTK_DECLARE_VALUERANGE_IMPLICIT_BACKENDTYPE(BackendT, ArrayTypeValue) \
555 VTK_DECLARE_VALUERANGE_ARRAYTYPE( \
556 VTK_WRAP_TEMPLATE(vtkImplicitArray<BackendT<float>, ArrayTypeValue>), double) \
557 VTK_DECLARE_VALUERANGE_ARRAYTYPE( \
558 VTK_WRAP_TEMPLATE(vtkImplicitArray<BackendT<double>, ArrayTypeValue>), double) \
559 VTK_DECLARE_VALUERANGE_ARRAYTYPE( \
560 VTK_WRAP_TEMPLATE(vtkImplicitArray<BackendT<char>, ArrayTypeValue>), double) \
561 VTK_DECLARE_VALUERANGE_ARRAYTYPE( \
562 VTK_WRAP_TEMPLATE(vtkImplicitArray<BackendT<signed char>, ArrayTypeValue>), double) \
563 VTK_DECLARE_VALUERANGE_ARRAYTYPE( \
564 VTK_WRAP_TEMPLATE(vtkImplicitArray<BackendT<unsigned char>, ArrayTypeValue>), double) \
565 VTK_DECLARE_VALUERANGE_ARRAYTYPE( \
566 VTK_WRAP_TEMPLATE(vtkImplicitArray<BackendT<short>, ArrayTypeValue>), double) \
567 VTK_DECLARE_VALUERANGE_ARRAYTYPE( \
568 VTK_WRAP_TEMPLATE(vtkImplicitArray<BackendT<unsigned short>, ArrayTypeValue>), double) \
569 VTK_DECLARE_VALUERANGE_ARRAYTYPE( \
570 VTK_WRAP_TEMPLATE(vtkImplicitArray<BackendT<int>, ArrayTypeValue>), double) \
571 VTK_DECLARE_VALUERANGE_ARRAYTYPE( \
572 VTK_WRAP_TEMPLATE(vtkImplicitArray<BackendT<unsigned int>, ArrayTypeValue>), double) \
573 VTK_DECLARE_VALUERANGE_ARRAYTYPE( \
574 VTK_WRAP_TEMPLATE(vtkImplicitArray<BackendT<long>, ArrayTypeValue>), double) \
575 VTK_DECLARE_VALUERANGE_ARRAYTYPE( \
576 VTK_WRAP_TEMPLATE(vtkImplicitArray<BackendT<unsigned long>, ArrayTypeValue>), double) \
577 VTK_DECLARE_VALUERANGE_ARRAYTYPE( \
578 VTK_WRAP_TEMPLATE(vtkImplicitArray<BackendT<long long>, ArrayTypeValue>), double) \
579 VTK_DECLARE_VALUERANGE_ARRAYTYPE( \
580 VTK_WRAP_TEMPLATE(vtkImplicitArray<BackendT<unsigned long long>, ArrayTypeValue>), double)
584VTK_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)
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 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