4 #ifndef vtkImplicitArray_h
5 #define vtkImplicitArray_h
7 #include "vtkCommonCoreModule.h"
12 #include <type_traits>
140 #define vtkImplicitArrayTypeMacro(thisClass, superclass) \
141 vtkAbstractTypeMacroWithNewInstanceType(thisClass, superclass, \
142 vtkAOSDataArrayTemplate<thisClass::ValueTypeT>, typeid(thisClass).name()); \
145 vtkObjectBase* NewInstanceInternal() const override \
147 return vtkAOSDataArrayTemplate<thisClass::ValueTypeT>::New(); \
153 VTK_ABI_NAMESPACE_BEGIN
154 template <
class BackendT>
157 typename vtk::detail::implicit_array_traits<BackendT>::rtype>
161 "Supplied backend type does not have mandatory read trait. Must implement either map() const "
162 "or operator() const.");
193 this->GetTypedTupleImpl<BackendT>(idx, tuple);
206 return this->GetTypedComponentImpl<BackendT>(idx, comp);
230 template <
typename... Params>
233 this->
SetBackend(std::make_shared<BackendT>(std::forward<Params>(params)...));
257 this->Initialize<BackendT>();
272 template <
typename OtherBackend>
276 "Cannot copy implicit array with one type of backend to an implicit array with a different "
321 template <
typename U>
325 return this->Backend->map(idx);
333 template <
typename U>
337 return (*this->Backend)(idx);
345 template <
typename U>
346 typename std::enable_if<vtk::detail::implicit_array_traits<U>::default_constructible,
void>
::type
349 this->Backend = std::make_shared<BackendT>();
357 template <
typename U>
358 typename std::enable_if<!vtk::detail::implicit_array_traits<U>::default_constructible,
void>
::type
361 this->Backend =
nullptr;
369 template <
typename U>
370 typename std::enable_if<vtk::detail::implicit_array_traits<U>::can_direct_read_tuple,
void>
::type
375 "Tuple type should be the same as the return type of the mapTuple");
376 this->Backend->mapTuple(idx, tuple);
384 template <
typename U>
385 typename std::enable_if<!vtk::detail::implicit_array_traits<U>::can_direct_read_tuple &&
399 template <
typename U>
400 typename std::enable_if<!vtk::detail::implicit_array_traits<U>::can_direct_read_tuple &&
401 !vtk::detail::implicit_array_traits<U>::can_direct_read_component,
408 tuple[comp] = this->
GetValue(tupIdx + comp);
417 template <
typename U>
418 typename std::enable_if<vtk::detail::implicit_array_traits<U>::can_direct_read_component,
420 GetTypedComponentImpl(
vtkIdType idx,
int comp)
const
424 "Component return type should be the same as the return type of the mapComponent");
425 return this->Backend->mapComponent(idx, comp);
433 template <
typename U>
434 typename std::enable_if<!vtk::detail::implicit_array_traits<U>::can_direct_read_component,
436 GetTypedComponentImpl(
vtkIdType idx,
int comp)
const
438 return this->
GetValue(idx * this->NumberOfComponents + comp);
447 VTK_ABI_NAMESPACE_END
449 #include "vtkImplicitArray.txx"
451 #endif // vtkImplicitArray_h
454 #ifdef VTK_IMPLICIT_VALUERANGE_INSTANTIATING
455 VTK_ABI_NAMESPACE_BEGIN
456 template <
typename ValueType>
458 template <
typename ValueType>
460 template <
typename ValueType>
462 template <
typename ValueType>
464 VTK_ABI_NAMESPACE_END
465 #include <functional>
468 #define VTK_INSTANTIATE_VALUERANGE_ARRAYTYPE(ArrayType, ValueType) \
469 template VTKCOMMONCORE_EXPORT bool DoComputeScalarRange( \
470 ArrayType*, ValueType*, vtkDataArrayPrivate::AllValues, const unsigned char*, unsigned char); \
471 template VTKCOMMONCORE_EXPORT bool DoComputeScalarRange(ArrayType*, ValueType*, \
472 vtkDataArrayPrivate::FiniteValues, const unsigned char*, unsigned char); \
473 template VTKCOMMONCORE_EXPORT bool DoComputeVectorRange(ArrayType*, ValueType[2], \
474 vtkDataArrayPrivate::AllValues, const unsigned char*, unsigned char); \
475 template VTKCOMMONCORE_EXPORT bool DoComputeVectorRange(ArrayType*, ValueType[2], \
476 vtkDataArrayPrivate::FiniteValues, const unsigned char*, unsigned char);
478 #define VTK_INSTANTIATE_VALUERANGE_VALUETYPE(ValueType) \
479 VTK_INSTANTIATE_VALUERANGE_ARRAYTYPE( \
480 vtkImplicitArray<vtkAffineImplicitBackend<ValueType>>, ValueType) \
481 VTK_INSTANTIATE_VALUERANGE_ARRAYTYPE( \
482 vtkImplicitArray<vtkCompositeImplicitBackend<ValueType>>, ValueType) \
483 VTK_INSTANTIATE_VALUERANGE_ARRAYTYPE( \
484 vtkImplicitArray<vtkConstantImplicitBackend<ValueType>>, ValueType) \
485 VTK_INSTANTIATE_VALUERANGE_ARRAYTYPE( \
486 vtkImplicitArray<vtkIndexedImplicitBackend<ValueType>>, ValueType) \
487 VTK_INSTANTIATE_VALUERANGE_ARRAYTYPE(vtkImplicitArray<std::function<ValueType(int)>>, ValueType)
489 #elif defined(VTK_USE_EXTERN_TEMPLATE) // VTK_IMPLICIT_VALUERANGE_INSTANTIATING
491 #ifndef VTK_IMPLICIT_TEMPLATE_EXTERN
492 #define VTK_IMPLICIT_TEMPLATE_EXTERN
494 #pragma warning(push)
497 #pragma warning(disable : 4910) // extern and dllexport incompatible
500 VTK_ABI_NAMESPACE_BEGIN
501 template <
typename ValueType>
503 template <
typename ValueType>
505 template <
typename ValueType>
507 template <
typename ValueType>
509 VTK_ABI_NAMESPACE_END
510 #include <functional>
514 VTK_ABI_NAMESPACE_BEGIN
515 template <
typename A,
typename R,
typename T>
517 A*, R*, T,
const unsigned char* ghosts,
unsigned char ghostsToSkip);
518 template <
typename A,
typename R>
520 A*, R[2], AllValues,
const unsigned char* ghosts,
unsigned char ghostsToSkip);
521 template <
typename A,
typename R>
523 A*, R[2], FiniteValues,
const unsigned char* ghosts,
unsigned char ghostsToSkip);
524 VTK_ABI_NAMESPACE_END
527 #define VTK_DECLARE_VALUERANGE_ARRAYTYPE(ArrayType, ValueType) \
528 extern template VTKCOMMONCORE_EXPORT bool DoComputeScalarRange( \
529 ArrayType*, ValueType*, vtkDataArrayPrivate::AllValues, const unsigned char*, unsigned char); \
530 extern template VTKCOMMONCORE_EXPORT bool DoComputeScalarRange(ArrayType*, ValueType*, \
531 vtkDataArrayPrivate::FiniteValues, const unsigned char*, unsigned char); \
532 extern template VTKCOMMONCORE_EXPORT bool DoComputeVectorRange(ArrayType*, ValueType[2], \
533 vtkDataArrayPrivate::AllValues, const unsigned char*, unsigned char); \
534 extern template VTKCOMMONCORE_EXPORT bool DoComputeVectorRange(ArrayType*, ValueType[2], \
535 vtkDataArrayPrivate::FiniteValues, const unsigned char*, unsigned char);
537 #define VTK_DECLARE_VALUERANGE_VALUETYPE(ValueType) \
538 VTK_DECLARE_VALUERANGE_ARRAYTYPE( \
539 vtkImplicitArray<vtkAffineImplicitBackend<ValueType>>, ValueType) \
540 VTK_DECLARE_VALUERANGE_ARRAYTYPE( \
541 vtkImplicitArray<vtkCompositeImplicitBackend<ValueType>>, ValueType) \
542 VTK_DECLARE_VALUERANGE_ARRAYTYPE( \
543 vtkImplicitArray<vtkConstantImplicitBackend<ValueType>>, ValueType) \
544 VTK_DECLARE_VALUERANGE_ARRAYTYPE( \
545 vtkImplicitArray<vtkIndexedImplicitBackend<ValueType>>, ValueType) \
546 VTK_DECLARE_VALUERANGE_ARRAYTYPE(vtkImplicitArray<std::function<ValueType(int)>>, ValueType)
548 #define VTK_DECLARE_VALUERANGE_IMPLICIT_BACKENDTYPE(BackendT) \
549 VTK_DECLARE_VALUERANGE_ARRAYTYPE(vtkImplicitArray<BackendT<float>>, double) \
550 VTK_DECLARE_VALUERANGE_ARRAYTYPE(vtkImplicitArray<BackendT<double>>, double) \
551 VTK_DECLARE_VALUERANGE_ARRAYTYPE(vtkImplicitArray<BackendT<char>>, double) \
552 VTK_DECLARE_VALUERANGE_ARRAYTYPE(vtkImplicitArray<BackendT<signed char>>, double) \
553 VTK_DECLARE_VALUERANGE_ARRAYTYPE(vtkImplicitArray<BackendT<unsigned char>>, double) \
554 VTK_DECLARE_VALUERANGE_ARRAYTYPE(vtkImplicitArray<BackendT<short>>, double) \
555 VTK_DECLARE_VALUERANGE_ARRAYTYPE(vtkImplicitArray<BackendT<unsigned short>>, double) \
556 VTK_DECLARE_VALUERANGE_ARRAYTYPE(vtkImplicitArray<BackendT<int>>, double) \
557 VTK_DECLARE_VALUERANGE_ARRAYTYPE(vtkImplicitArray<BackendT<unsigned int>>, double) \
558 VTK_DECLARE_VALUERANGE_ARRAYTYPE(vtkImplicitArray<BackendT<long>>, double) \
559 VTK_DECLARE_VALUERANGE_ARRAYTYPE(vtkImplicitArray<BackendT<unsigned long>>, double) \
560 VTK_DECLARE_VALUERANGE_ARRAYTYPE(vtkImplicitArray<BackendT<long long>>, double) \
561 VTK_DECLARE_VALUERANGE_ARRAYTYPE(vtkImplicitArray<BackendT<unsigned long long>>, double)
565 VTK_ABI_NAMESPACE_BEGIN
584 VTK_ABI_NAMESPACE_END
587 #undef VTK_DECLARE_VALUERANGE_ARRAYTYPE
588 #undef VTK_DECLARE_VALUERANGE_VALUETYPE
593 #endif // VTK_IMPLICIT_TEMPLATE_EXTERN
595 #endif // VTK_IMPLICIT_VALUERANGE_INSTANTIATING
A backend for the vtkImplicitArray framework allowing one to use a subset of a given data array...
A composite trait for handling all the different capabilities a "backend" to an implicit array can ha...
std::shared_ptr< BackendT > Backend
The backend object actually mapping the indexes.
ValueType GetTypedComponent(vtkIdType idx, int comp) const
Get component comp of the tuple at idx.
int GetNumberOfComponents() const
Set/Get the dimension (n) of the components.
Abstract superclass for all arrays.
VTKCOMMONCORE_EXPORT bool DoComputeScalarRange(A *, R *, T, const unsigned char *ghosts, unsigned char ghostsToSkip)
void ImplicitDeepCopy(vtkImplicitArray< OtherBackend > *other)
Specific DeepCopy for implicit arrays.
VTKCOMMONCORE_EXPORT bool DoComputeVectorRange(A *, R[2], AllValues, const unsigned char *ghosts, unsigned char ghostsToSkip)
vtkArrayDownCast_TemplateFastCastMacro(vtkImplicitArray)
void ConstructBackend(Params &&...params)
Utility method for setting backend parameterization directly.
void GetTypedTuple(vtkIdType idx, ValueType *tuple) const
Copy the tuple at idx into tuple.
Base interface for all typed vtkDataArray subclasses.
#define VTK_DECLARE_VALUERANGE_ARRAYTYPE(ArrayType, ValueType)
void SetNumberOfTuples(vtkIdType number) override
void SetTypedComponent(vtkIdType tupleIdx, int comp, ValueType value)
Will not do anything for these read only arrays!
typename trait::rtype rtype
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 ...
bool AllocateTuples(vtkIdType vtkNotUsed(numTuples))
No allocation necessary.
vtkImplicitArrayTypeMacro(SelfType, GenericDataArrayType)
ValueType GetValue(vtkIdType idx) const
Implementation of vtkGDAConceptMethods.
A utility structure serving as a backend for constant implicit arrays.
std::unique_ptr< vtkInternals > Internals
void SetBackend(std::shared_ptr< BackendT > newBackend)
Setter/Getter for Backend.
std::shared_ptr< BackendT > GetBackend()
Setter/Getter for Backend.
static vtkImplicitArray< BackendT > * FastDownCast(vtkAbstractArray *source)
Perform a fast, safe cast from a vtkAbstractArray to a vtkDataArray.
typename GenericDataArrayType::ValueType ValueType
void SetValue(vtkIdType idx, ValueType value)
Will not do anything for these read only arrays!
vtkIdType GetNumberOfTuples() const
Get the number of complete tuples (a component group) in the array.
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
A read only array class that wraps an implicit function from integers to any value type supported by ...
static vtkImplicitArray * New()
#define VTK_DECLARE_VALUERANGE_IMPLICIT_BACKENDTYPE(BackendT)
~vtkImplicitArray() override
bool ReallocateTuples(vtkIdType vtkNotUsed(numTuples))
No allocation necessary.
void * GetVoidPointer(vtkIdType valueIdx) override
Use of this method is discouraged, it creates a memory copy of the data into a contiguous AoS-ordered...
int GetArrayType() const override
Get the type of array this is when down casting.
static constexpr bool can_read
void SetNumberOfComponents(int num) override
void Modified() override
Removes out-of-date L2_NORM_RANGE() and L2_NORM_FINITE_RANGE() values.
A utility structure serving as a backend for affine (as a function of the index) implicit arrays...
void Initialize() override
Reset the array to default construction.
A utility structure serving as a backend for composite arrays: an array composed of multiple arrays c...