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::ImplicitArray>
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.");
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)...));
265 this->Initialize<BackendT>();
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)
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
407 this->Backend =
nullptr;
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
484 return this->
GetValue(idx * this->NumberOfComponents + comp);
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"
524#define VTK_WRAP_TEMPLATE(...) __VA_ARGS__
526#ifdef VTK_USE_EXTERN_TEMPLATE
528#ifndef VTK_IMPLICIT_TEMPLATE_EXTERN
529#define VTK_IMPLICIT_TEMPLATE_EXTERN
534#pragma warning(disable : 4910)
537VTK_ABI_NAMESPACE_BEGIN
538template <typename ValueType>
540template <typename ValueType>
542template <typename ValueType>
544template <typename ValueType>
546template <typename ValueType>
553VTK_ABI_NAMESPACE_BEGIN
554template <
typename A,
typename R,
typename T>
555VTKCOMMONCORE_EXPORT
bool DoComputeScalarRange(
556 A*, R*, T,
const unsigned char* ghosts,
unsigned char ghostsToSkip);
557template <
typename A,
typename R>
558VTKCOMMONCORE_EXPORT
bool DoComputeVectorRange(
559 A*, R[2], AllValues,
const unsigned char* ghosts,
unsigned char ghostsToSkip);
560template <
typename A,
typename R>
561VTKCOMMONCORE_EXPORT
bool DoComputeVectorRange(
562 A*, R[2], FiniteValues,
const unsigned char* ghosts,
unsigned char ghostsToSkip);
566#define VTK_DECLARE_VALUERANGE_IMPLICIT_BACKENDTYPE(BackendT, ArrayTypeValue) \
567 VTK_DECLARE_VALUERANGE_ARRAYTYPE( \
568 VTK_WRAP_TEMPLATE(vtkImplicitArray<BackendT<float>, ArrayTypeValue>), double) \
569 VTK_DECLARE_VALUERANGE_ARRAYTYPE( \
570 VTK_WRAP_TEMPLATE(vtkImplicitArray<BackendT<double>, ArrayTypeValue>), double) \
571 VTK_DECLARE_VALUERANGE_ARRAYTYPE( \
572 VTK_WRAP_TEMPLATE(vtkImplicitArray<BackendT<char>, ArrayTypeValue>), double) \
573 VTK_DECLARE_VALUERANGE_ARRAYTYPE( \
574 VTK_WRAP_TEMPLATE(vtkImplicitArray<BackendT<signed char>, ArrayTypeValue>), double) \
575 VTK_DECLARE_VALUERANGE_ARRAYTYPE( \
576 VTK_WRAP_TEMPLATE(vtkImplicitArray<BackendT<unsigned char>, ArrayTypeValue>), double) \
577 VTK_DECLARE_VALUERANGE_ARRAYTYPE( \
578 VTK_WRAP_TEMPLATE(vtkImplicitArray<BackendT<short>, ArrayTypeValue>), double) \
579 VTK_DECLARE_VALUERANGE_ARRAYTYPE( \
580 VTK_WRAP_TEMPLATE(vtkImplicitArray<BackendT<unsigned short>, ArrayTypeValue>), double) \
581 VTK_DECLARE_VALUERANGE_ARRAYTYPE( \
582 VTK_WRAP_TEMPLATE(vtkImplicitArray<BackendT<int>, ArrayTypeValue>), double) \
583 VTK_DECLARE_VALUERANGE_ARRAYTYPE( \
584 VTK_WRAP_TEMPLATE(vtkImplicitArray<BackendT<unsigned int>, ArrayTypeValue>), double) \
585 VTK_DECLARE_VALUERANGE_ARRAYTYPE( \
586 VTK_WRAP_TEMPLATE(vtkImplicitArray<BackendT<long>, ArrayTypeValue>), double) \
587 VTK_DECLARE_VALUERANGE_ARRAYTYPE( \
588 VTK_WRAP_TEMPLATE(vtkImplicitArray<BackendT<unsigned long>, ArrayTypeValue>), double) \
589 VTK_DECLARE_VALUERANGE_ARRAYTYPE( \
590 VTK_WRAP_TEMPLATE(vtkImplicitArray<BackendT<long long>, ArrayTypeValue>), double) \
591 VTK_DECLARE_VALUERANGE_ARRAYTYPE( \
592 VTK_WRAP_TEMPLATE(vtkImplicitArray<BackendT<unsigned long long>, ArrayTypeValue>), double)
596VTK_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, vtkArrayTypes::AbstractArray > ArrayTypeTag
std::integral_constant< int, VTK_OPAQUE > DataTypeTag
A utility structure serving as a backend for composite arrays: an array composed of multiple arrays c...
abstract superclass for arrays of numeric data
void DeepCopy(vtkAbstractArray *aa) override
Deep copy of data.
void Modified() override
Removes out-of-date L2_NORM_RANGE() and L2_NORM_FINITE_RANGE() values.
Base interface for all typed vtkDataArray subclasses.
void Initialize() override
Release storage and reset array to initial state.
void SetNumberOfTuples(vtkIdType number) override
Set the number of tuples (a component group) in the array.
void SetNumberOfComponents(int num) override
Set/Get the dimension (n) of the components.
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)
Specific DeepCopy for implicit arrays.
void SetTypedTuple(vtkIdType tupleIdx, const ValueType *tuple)
Will not do anything for these read only arrays!
void Squeeze() override
Release all extraneous internal memory including the void pointer used by GetVoidPointer
void SetTypedComponent(vtkIdType tupleIdx, int comp, ValueType value)
Will not do anything for these read only arrays!
std::unique_ptr< vtkInternals > Internals
bool AllocateTuples(vtkIdType numTuples)
No allocation necessary.
void ConstructBackend(Params &&... params)
Utility method for setting backend parameterization directly.
bool ReallocateTuples(vtkIdType numTuples)
No allocation necessary.
std::shared_ptr< BackendT > GetBackend()
Setter/Getter for Backend.
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
Return the memory in kibibytes (1024 bytes) consumed by this implicit data array.
void SetBackend(std::shared_ptr< BackendT > newBackend)
Setter/Getter for Backend.
void SetValue(vtkIdType idx, ValueType value)
Will not do anything for these read only arrays!
ValueType GetValue(vtkIdType idx) const
Implementation of vtkGDAConceptMethods.
ValueType GetTypedComponent(vtkIdType idx, int comp) const
Get component comp of the tuple at idx.
std::integral_constant< int, vtkArrayTypes::AbstractArray > ArrayTypeTag
void Initialize() override
Reset the array to default construction.
vtkImplicitArray< BackendT, ArrayType > SelfType
void * GetVoidPointer(vtkIdType valueIdx) override
Use of this method is discouraged, it creates a memory copy of the data into a contiguous AoS-ordered...
void DeepCopy(vtkDataArray *da) override
Specific DeepCopy for implicit arrays.
std::shared_ptr< BackendT > Backend
The backend object actually mapping the indexes.
void GetTypedTuple(vtkIdType idx, ValueType *tuple) const
Copy the tuple at idx into tuple.
~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.
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
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(...)