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>
162 typename vtk::detail::implicit_array_traits<BackendT>::rtype>
166 "Supplied backend type does not have mandatory read trait. Must implement either map() const "
167 "or operator() const.");
198 this->GetTypedTupleImpl<BackendT>(idx, tuple);
211 return this->GetTypedComponentImpl<BackendT>(idx, comp);
235 template <
typename... Params>
238 this->
SetBackend(std::make_shared<BackendT>(std::forward<Params>(params)...));
267 this->Initialize<BackendT>();
282 return this->GetActualMemorySizeImpl<BackendT>();
296 template <
typename OtherBackend>
299 static_assert(std::is_same<BackendT, OtherBackend>::value,
300 "Cannot copy implicit array with one type of backend to an implicit array with a different "
345 template <
typename U>
346 typename std::enable_if<vtk::detail::has_map_trait<U>::value,
ValueType>::type GetValueImpl(
349 return this->Backend->map(idx);
357 template <
typename U>
358 typename std::enable_if<vtk::detail::is_closure_trait<U>::value,
ValueType>::type GetValueImpl(
361 return (*this->Backend)(idx);
369 template <
typename U>
370 typename std::enable_if<vtk::detail::implicit_array_traits<U>::default_constructible,
void>::type
373 this->Backend = std::make_shared<BackendT>();
381 template <
typename U>
382 typename std::enable_if<!vtk::detail::implicit_array_traits<U>::default_constructible,
void>::type
385 this->Backend =
nullptr;
393 template <
typename U>
394 typename std::enable_if<vtk::detail::implicit_array_traits<U>::can_direct_read_tuple,
void>::type
398 std::is_same<typename vtk::detail::can_map_tuple_trait<U>::rtype,
ValueType>::value,
399 "Tuple type should be the same as the return type of the mapTuple");
400 this->Backend->mapTuple(idx, tuple);
408 template <
typename U>
409 typename std::enable_if<!vtk::detail::implicit_array_traits<U>::can_direct_read_tuple &&
423 template <
typename U>
424 typename std::enable_if<!vtk::detail::implicit_array_traits<U>::can_direct_read_tuple &&
432 tuple[comp] = this->
GetValue(tupIdx + comp);
441 template <
typename U>
442 typename std::enable_if<vtk::detail::implicit_array_traits<U>::can_direct_read_component,
444 GetTypedComponentImpl(
vtkIdType idx,
int comp)
const
447 std::is_same<typename vtk::detail::can_map_component_trait<U>::rtype,
ValueType>::value,
448 "Component return type should be the same as the return type of the mapComponent");
449 return this->Backend->mapComponent(idx, comp);
457 template <
typename U>
458 typename std::enable_if<!vtk::detail::implicit_array_traits<U>::can_direct_read_component,
460 GetTypedComponentImpl(
vtkIdType idx,
int comp)
const
462 return this->
GetValue(idx * this->NumberOfComponents + comp);
470 template <
typename U>
471 typename std::enable_if<vtk::detail::implicit_array_traits<U>::can_get_memory_size,
473 GetActualMemorySizeImpl()
const
475 return this->Backend->getMemorySize();
482 template <
typename U>
483 typename std::enable_if<!vtk::detail::implicit_array_traits<U>::can_get_memory_size,
485 GetActualMemorySizeImpl()
const
498#include "vtkImplicitArray.txx"
503#ifdef VTK_IMPLICIT_VALUERANGE_INSTANTIATING
504VTK_ABI_NAMESPACE_BEGIN
505template <
typename ValueType>
507template <
typename ValueType>
509template <
typename ValueType>
511template <
typename ValueType>
513template <
typename ValueType>
519#define VTK_INSTANTIATE_VALUERANGE_ARRAYTYPE(ArrayType, ValueType) \
520 template VTKCOMMONCORE_EXPORT bool DoComputeScalarRange( \
521 ArrayType*, ValueType*, vtkDataArrayPrivate::AllValues, const unsigned char*, unsigned char); \
522 template VTKCOMMONCORE_EXPORT bool DoComputeScalarRange(ArrayType*, ValueType*, \
523 vtkDataArrayPrivate::FiniteValues, const unsigned char*, unsigned char); \
524 template VTKCOMMONCORE_EXPORT bool DoComputeVectorRange(ArrayType*, ValueType[2], \
525 vtkDataArrayPrivate::AllValues, const unsigned char*, unsigned char); \
526 template VTKCOMMONCORE_EXPORT bool DoComputeVectorRange(ArrayType*, ValueType[2], \
527 vtkDataArrayPrivate::FiniteValues, const unsigned char*, unsigned char);
529#define VTK_INSTANTIATE_VALUERANGE_VALUETYPE(ValueType) \
530 VTK_INSTANTIATE_VALUERANGE_ARRAYTYPE( \
531 vtkImplicitArray<vtkAffineImplicitBackend<ValueType>>, ValueType) \
532 VTK_INSTANTIATE_VALUERANGE_ARRAYTYPE( \
533 vtkImplicitArray<vtkCompositeImplicitBackend<ValueType>>, ValueType) \
534 VTK_INSTANTIATE_VALUERANGE_ARRAYTYPE( \
535 vtkImplicitArray<vtkConstantImplicitBackend<ValueType>>, ValueType) \
536 VTK_INSTANTIATE_VALUERANGE_ARRAYTYPE( \
537 vtkImplicitArray<vtkStructuredPointBackend<ValueType>>, ValueType) \
538 VTK_INSTANTIATE_VALUERANGE_ARRAYTYPE( \
539 vtkImplicitArray<vtkIndexedImplicitBackend<ValueType>>, ValueType) \
540 VTK_INSTANTIATE_VALUERANGE_ARRAYTYPE(vtkImplicitArray<std::function<ValueType(int)>>, ValueType)
542#elif defined(VTK_USE_EXTERN_TEMPLATE)
544#ifndef VTK_IMPLICIT_TEMPLATE_EXTERN
545#define VTK_IMPLICIT_TEMPLATE_EXTERN
550#pragma warning(disable : 4910)
553VTK_ABI_NAMESPACE_BEGIN
554template <
typename ValueType>
556template <
typename ValueType>
558template <
typename ValueType>
560template <
typename ValueType>
562template <
typename ValueType>
569VTK_ABI_NAMESPACE_BEGIN
570template <
typename A,
typename R,
typename T>
572 A*, R*, T,
const unsigned char* ghosts,
unsigned char ghostsToSkip);
573template <
typename A,
typename R>
575 A*, R[2], AllValues,
const unsigned char* ghosts,
unsigned char ghostsToSkip);
576template <
typename A,
typename R>
578 A*, R[2], FiniteValues,
const unsigned char* ghosts,
unsigned char ghostsToSkip);
582#define VTK_DECLARE_VALUERANGE_ARRAYTYPE(ArrayType, ValueType) \
583 extern template VTKCOMMONCORE_EXPORT bool DoComputeScalarRange( \
584 ArrayType*, ValueType*, vtkDataArrayPrivate::AllValues, const unsigned char*, unsigned char); \
585 extern template VTKCOMMONCORE_EXPORT bool DoComputeScalarRange(ArrayType*, ValueType*, \
586 vtkDataArrayPrivate::FiniteValues, const unsigned char*, unsigned char); \
587 extern template VTKCOMMONCORE_EXPORT bool DoComputeVectorRange(ArrayType*, ValueType[2], \
588 vtkDataArrayPrivate::AllValues, const unsigned char*, unsigned char); \
589 extern template VTKCOMMONCORE_EXPORT bool DoComputeVectorRange(ArrayType*, ValueType[2], \
590 vtkDataArrayPrivate::FiniteValues, const unsigned char*, unsigned char);
592#define VTK_DECLARE_VALUERANGE_VALUETYPE(ValueType) \
593 VTK_DECLARE_VALUERANGE_ARRAYTYPE( \
594 vtkImplicitArray<vtkAffineImplicitBackend<ValueType>>, ValueType) \
595 VTK_DECLARE_VALUERANGE_ARRAYTYPE( \
596 vtkImplicitArray<vtkCompositeImplicitBackend<ValueType>>, ValueType) \
597 VTK_DECLARE_VALUERANGE_ARRAYTYPE( \
598 vtkImplicitArray<vtkConstantImplicitBackend<ValueType>>, ValueType) \
599 VTK_DECLARE_VALUERANGE_ARRAYTYPE( \
600 vtkImplicitArray<vtkStructuredPointBackend<ValueType>>, ValueType) \
601 VTK_DECLARE_VALUERANGE_ARRAYTYPE( \
602 vtkImplicitArray<vtkIndexedImplicitBackend<ValueType>>, ValueType) \
603 VTK_DECLARE_VALUERANGE_ARRAYTYPE(vtkImplicitArray<std::function<ValueType(int)>>, ValueType)
605#define VTK_DECLARE_VALUERANGE_IMPLICIT_BACKENDTYPE(BackendT) \
606 VTK_DECLARE_VALUERANGE_ARRAYTYPE(vtkImplicitArray<BackendT<float>>, double) \
607 VTK_DECLARE_VALUERANGE_ARRAYTYPE(vtkImplicitArray<BackendT<double>>, double) \
608 VTK_DECLARE_VALUERANGE_ARRAYTYPE(vtkImplicitArray<BackendT<char>>, double) \
609 VTK_DECLARE_VALUERANGE_ARRAYTYPE(vtkImplicitArray<BackendT<signed char>>, double) \
610 VTK_DECLARE_VALUERANGE_ARRAYTYPE(vtkImplicitArray<BackendT<unsigned char>>, double) \
611 VTK_DECLARE_VALUERANGE_ARRAYTYPE(vtkImplicitArray<BackendT<short>>, double) \
612 VTK_DECLARE_VALUERANGE_ARRAYTYPE(vtkImplicitArray<BackendT<unsigned short>>, double) \
613 VTK_DECLARE_VALUERANGE_ARRAYTYPE(vtkImplicitArray<BackendT<int>>, double) \
614 VTK_DECLARE_VALUERANGE_ARRAYTYPE(vtkImplicitArray<BackendT<unsigned int>>, double) \
615 VTK_DECLARE_VALUERANGE_ARRAYTYPE(vtkImplicitArray<BackendT<long>>, double) \
616 VTK_DECLARE_VALUERANGE_ARRAYTYPE(vtkImplicitArray<BackendT<unsigned long>>, double) \
617 VTK_DECLARE_VALUERANGE_ARRAYTYPE(vtkImplicitArray<BackendT<long long>>, double) \
618 VTK_DECLARE_VALUERANGE_ARRAYTYPE(vtkImplicitArray<BackendT<unsigned long long>>, double)
622VTK_ABI_NAMESPACE_BEGIN
645#undef VTK_DECLARE_VALUERANGE_ARRAYTYPE
646#undef VTK_DECLARE_VALUERANGE_VALUETYPE
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.
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.
void SetNumberOfComponents(int num) override
void SetNumberOfTuples(vtkIdType number) override
A read only array class that wraps an implicit function from integers to any value type supported by ...
ValueType GetTypedComponent(vtkIdType idx, int comp) const
Get component comp of the tuple at idx.
typename GenericDataArrayType::ValueType ValueType
void SetBackend(std::shared_ptr< BackendT > newBackend)
Setter/Getter for Backend.
void SetTypedTuple(vtkIdType tupleIdx, const ValueType *tuple)
Will not do anything for these read only arrays!
std::shared_ptr< BackendT > GetBackend()
Setter/Getter for Backend.
vtkImplicitArrayTypeMacro(SelfType, GenericDataArrayType)
std::shared_ptr< BackendT > Backend
The backend object actually mapping the indexes.
unsigned long GetActualMemorySize() const override
Return the memory in kibibytes (1024 bytes) consumed by this implicit data array.
void * GetVoidPointer(vtkIdType valueIdx) override
Use of this method is discouraged, it creates a memory copy of the data into a contiguous AoS-ordered...
std::unique_ptr< vtkInternals > Internals
bool ReallocateTuples(vtkIdType vtkNotUsed(numTuples))
No allocation necessary.
void Initialize() override
Reset the array to default construction.
void ConstructBackend(Params &&... params)
Utility method for setting backend parameterization directly.
~vtkImplicitArray() override
bool AllocateTuples(vtkIdType vtkNotUsed(numTuples))
No allocation necessary.
int GetArrayType() const override
Get the type of array this is when down casting.
void GetTypedTuple(vtkIdType idx, ValueType *tuple) const
Copy the tuple at idx into tuple.
void ImplicitDeepCopy(vtkImplicitArray< OtherBackend > *other)
Specific DeepCopy for implicit arrays.
static vtkImplicitArray * New()
ValueType GetValue(vtkIdType idx) const
Implementation of vtkGDAConceptMethods.
void SetValue(vtkIdType idx, ValueType value)
Will not do anything for these read only arrays!
static vtkImplicitArray< BackendT > * FastDownCast(vtkAbstractArray *source)
Perform a fast, safe cast from a vtkAbstractArray to a vtkDataArray.
void SetTypedComponent(vtkIdType tupleIdx, int comp, ValueType value)
Will not do anything for these read only arrays!
void Squeeze() override
Release all extraneous internal memory including the void pointer used by GetVoidPointer
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.
VTKCOMMONCORE_EXPORT bool DoComputeScalarRange(A *, R *, T, const unsigned char *ghosts, unsigned char ghostsToSkip)
VTKCOMMONCORE_EXPORT bool DoComputeVectorRange(A *, R[2], AllValues, const unsigned char *ghosts, unsigned char ghostsToSkip)
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_TemplateFastCastMacro(ArrayT)
Same as vtkArrayDownCast_FastCastMacro, but treats ArrayT as a single-parameter template (the paramet...
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)