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);
235 template <
typename... Params>
238 this->
SetBackend(std::make_shared<BackendT>(std::forward<Params>(params)...));
262 return this->GetActualMemorySizeImpl<BackendT>();
277 template <
typename OtherBackend,
int OtherArrayType>
280 static_assert(std::is_same_v<BackendT, OtherBackend>,
281 "Cannot copy implicit array with one type of backend to an implicit array with a different "
283 static_assert(ArrayTypeTag::value == OtherArrayType,
284 "Cannot copy implicit array with one array type to an implicit array with a different "
290 using vtkDataArray::DeepCopy;
293 if (da ==
nullptr || da ==
this)
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
503#define vtkCreateImplicitWrappedArrayInterface(T) \
504 vtkCreateWrappedArrayReadInterface(T); \
505 bool SetNumberOfValues(vtkIdType number) override;
507#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
bool IsBackendConstructed() const
Setter/Getter for Backend.
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)
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 *)
#define VTK_DEPRECATED_IN_9_7_0(reason)