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>
163 "Supplied backend type does not have mandatory read trait. Must implement either map() const "
164 "or operator() const.");
173 using typename Superclass::ValueType;
197 this->GetTypedTupleImpl<BackendT>(idx, tuple);
210 return this->GetTypedComponentImpl<BackendT>(idx, comp);
234 template <
typename... Params>
237 this->
SetBackend(std::make_shared<BackendT>(std::forward<Params>(params)...));
261 return this->GetActualMemorySizeImpl<BackendT>();
276 template <
typename OtherBackend,
int OtherArrayType>
279 static_assert(std::is_same_v<BackendT, OtherBackend>,
280 "Cannot copy implicit array with one type of backend to an implicit array with a different "
282 static_assert(ArrayTypeTag::value == OtherArrayType,
283 "Cannot copy implicit array with one array type to an implicit array with a different "
289 using vtkDataArray::DeepCopy;
292 if (da ==
nullptr || da ==
this)
344 template <
typename U>
345 typename std::enable_if<vtk::detail::has_map_trait<U>::value,
ValueType>::type GetValueImpl(
348 return this->Backend->map(idx);
356 template <
typename U>
357 typename std::enable_if<vtk::detail::is_closure_trait<U>::value,
ValueType>::type GetValueImpl(
360 return (*this->Backend)(idx);
368 template <
typename U>
369 typename std::enable_if<vtk::detail::implicit_array_traits<U>::default_constructible,
void>::type
372 this->
Backend = std::make_shared<BackendT>();
380 template <
typename U>
381 typename std::enable_if<!vtk::detail::implicit_array_traits<U>::default_constructible,
void>::type
392 template <
typename U>
393 typename std::enable_if<vtk::detail::implicit_array_traits<U>::can_direct_read_tuple,
void>::type
397 std::is_same<typename vtk::detail::can_map_tuple_trait<U>::rtype,
ValueType>::value,
398 "Tuple type should be the same as the return type of the mapTuple");
399 this->
Backend->mapTuple(idx, tuple);
407 template <
typename U>
408 typename std::enable_if<!vtk::detail::implicit_array_traits<U>::can_direct_read_tuple &&
422 template <
typename U>
423 typename std::enable_if<!vtk::detail::implicit_array_traits<U>::can_direct_read_tuple &&
431 tuple[comp] = this->
GetValue(tupIdx + comp);
440 template <
typename U>
441 typename std::enable_if<vtk::detail::implicit_array_traits<U>::can_direct_read_component,
443 GetTypedComponentImpl(
vtkIdType idx,
int comp)
const
446 std::is_same<typename vtk::detail::can_map_component_trait<U>::rtype,
ValueType>::value,
447 "Component return type should be the same as the return type of the mapComponent");
448 return this->
Backend->mapComponent(idx, comp);
456 template <
typename U>
457 typename std::enable_if<!vtk::detail::implicit_array_traits<U>::can_direct_read_component,
459 GetTypedComponentImpl(
vtkIdType idx,
int comp)
const
469 template <
typename U>
470 typename std::enable_if<vtk::detail::implicit_array_traits<U>::can_get_memory_size,
472 GetActualMemorySizeImpl()
const
474 return this->
Backend->getMemorySize();
481 template <
typename U>
482 typename std::enable_if<!vtk::detail::implicit_array_traits<U>::can_get_memory_size,
484 GetActualMemorySizeImpl()
const
501#define vtkCreateImplicitWrappedArrayInterface(T) \
502 vtkCreateWrappedArrayReadInterface(T); \
503 bool SetNumberOfValues(vtkIdType number) override;
505#include "vtkImplicitArray.txx"
Abstract superclass for all arrays.
virtual void SetNumberOfTuples(vtkIdType numTuples)
Set the number of tuples (a component group) in the array.
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
virtual void Initialize()
Release storage and reset array to initial state.
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 SetNumberOfComponents(int num) override
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 SetTypedComponent(vtkIdType tupleIdx, int comp, ValueType value)
Will not do anything for these read only arrays!
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.
void Initialize() override
Reset the array to default construction.
vtkImplicitArray< vtkAffineImplicitBackend< ValueTypeT >, ArrayType > SelfType
vtkAffineImplicitBackend< ValueTypeT > BackendType
std::integral_constant< int, vtkArrayTypes::VTK_ABSTRACT_ARRAY > ArrayTypeTag
void DeepCopy(vtkDataArray *da) override
Specific DeepCopy for implicit arrays.
std::shared_ptr< vtkAffineImplicitBackend< ValueTypeT > > Backend
void GetTypedTuple(vtkIdType idx, ValueType *tuple) const
Copy the tuple at idx into tuple.
~vtkImplicitArray() override
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 *)