|
|
|
@ -17,66 +17,55 @@
|
|
|
|
|
#include "vtkArrayDispatch.h"
|
|
|
|
|
#include "vtkArrayDispatchImplicitArrayList.h"
|
|
|
|
|
#include "vtkDataArray.h"
|
|
|
|
|
#include "vtkDataArrayRange.h"
|
|
|
|
|
#include "vtkSmartPointer.h"
|
|
|
|
|
|
|
|
|
|
VTK_ABI_NAMESPACE_BEGIN
|
|
|
|
|
//-----------------------------------------------------------------------
|
|
|
|
|
namespace
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
template <typename ValueType>
|
|
|
|
|
struct GetValueDispatch
|
|
|
|
|
struct vtkCompositeImplicitBackend<ValueType>::Internals
|
|
|
|
|
{
|
|
|
|
|
template <typename ArrayT>
|
|
|
|
|
void operator()(ArrayT* arr, int& idx, ValueType& val) const
|
|
|
|
|
Internals(vtkDataArray* leftArr, vtkDataArray* rightArr)
|
|
|
|
|
: Left(leftArr)
|
|
|
|
|
, Right(rightArr)
|
|
|
|
|
{
|
|
|
|
|
val = static_cast<ValueType>(arr->GetValue(idx));
|
|
|
|
|
if (this->Left == nullptr || this->Right == nullptr)
|
|
|
|
|
{
|
|
|
|
|
vtkWarningWithObjectMacro(nullptr, "Creating composite array with nullptr");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
this->LeftRange = vtk::DataArrayValueRange(this->Left);
|
|
|
|
|
this->RightRange = vtk::DataArrayValueRange(this->Right);
|
|
|
|
|
this->Offset = LeftRange.size();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
vtkSmartPointer<vtkDataArray> Left;
|
|
|
|
|
vtk::detail::SelectValueRange<vtkDataArray*, vtk::detail::DynamicTupleSize>::type LeftRange;
|
|
|
|
|
vtkSmartPointer<vtkDataArray> Right;
|
|
|
|
|
vtk::detail::SelectValueRange<vtkDataArray*, vtk::detail::DynamicTupleSize>::type RightRange;
|
|
|
|
|
int Offset = -1;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
VTK_ABI_NAMESPACE_BEGIN
|
|
|
|
|
//-----------------------------------------------------------------------
|
|
|
|
|
template <typename ValueType>
|
|
|
|
|
vtkCompositeImplicitBackend<ValueType>::vtkCompositeImplicitBackend(
|
|
|
|
|
vtkDataArray* leftArr, vtkDataArray* rightArr)
|
|
|
|
|
: Left(leftArr)
|
|
|
|
|
, Right(rightArr)
|
|
|
|
|
: Internal(std::unique_ptr<Internals>(new Internals(leftArr, rightArr)))
|
|
|
|
|
{
|
|
|
|
|
if (this->Left == nullptr || this->Right == nullptr)
|
|
|
|
|
{
|
|
|
|
|
vtkWarningWithObjectMacro(nullptr, "Creating composite array with nullptr");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
this->Offset = this->Left->GetDataSize();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------
|
|
|
|
|
template <typename ValueType>
|
|
|
|
|
ValueType vtkCompositeImplicitBackend<ValueType>::operator()(int idx) const
|
|
|
|
|
vtkCompositeImplicitBackend<ValueType>::~vtkCompositeImplicitBackend()
|
|
|
|
|
{
|
|
|
|
|
int nxtIdx = idx;
|
|
|
|
|
vtkDataArray* branch;
|
|
|
|
|
if (idx < this->Offset)
|
|
|
|
|
{
|
|
|
|
|
branch = this->Left;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
nxtIdx -= this->Offset;
|
|
|
|
|
branch = this->Right;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
using DisArrays = vtkArrayDispatch::AllArrays;
|
|
|
|
|
using Dispatcher = vtkArrayDispatch::DispatchByArray<DisArrays>;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ValueType val;
|
|
|
|
|
::GetValueDispatch<ValueType> worklet;
|
|
|
|
|
if (!Dispatcher::Execute(branch, worklet, nxtIdx, val))
|
|
|
|
|
{
|
|
|
|
|
int iTup = nxtIdx / branch->GetNumberOfComponents();
|
|
|
|
|
int iComp = iTup * branch->GetNumberOfComponents() - nxtIdx;
|
|
|
|
|
val = static_cast<ValueType>(branch->GetComponent(iTup, iComp));
|
|
|
|
|
}
|
|
|
|
|
return val;
|
|
|
|
|
//-----------------------------------------------------------------------
|
|
|
|
|
template <typename ValueType>
|
|
|
|
|
ValueType vtkCompositeImplicitBackend<ValueType>::operator()(int idx) const
|
|
|
|
|
{
|
|
|
|
|
return static_cast<ValueType>((idx < this->Internal->Offset)
|
|
|
|
|
? this->Internal->LeftRange[idx]
|
|
|
|
|
: this->Internal->RightRange[idx - this->Internal->Offset]);
|
|
|
|
|
}
|
|
|
|
|
VTK_ABI_NAMESPACE_END
|
|
|
|
|