mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-10-08 11:29:02 +00:00
Change VectorMagnitude to work with any type of field
Previously, `VectorMagnitude` only worked with `Vec`s of size 2, 3, or 4. It now works with `Vec`s of any size. It also avoids a memory copy of non-float types (although it does add a little arithmetic in the computation).
This commit is contained in:
parent
f916a5e1f3
commit
d5ba7f4d59
@ -24,3 +24,4 @@ fallback is used.
|
||||
* `ParticleDensityNearestGridPoint`
|
||||
* `PointAverage`
|
||||
* `Probe`
|
||||
* `VectorMagnitude`
|
||||
|
@ -28,7 +28,7 @@ VTKM_CONT vtkm::cont::DataSet VectorMagnitude::DoExecute(const vtkm::cont::DataS
|
||||
|
||||
auto resolveType = [&](const auto& concrete) {
|
||||
// use std::decay to remove const ref from the decltype of concrete.
|
||||
using T = typename std::decay_t<decltype(concrete)>::ValueType;
|
||||
using T = typename std::decay_t<decltype(concrete)>::ValueType::ComponentType;
|
||||
using ReturnType = typename ::vtkm::detail::FloatingPointReturnType<T>::Type;
|
||||
vtkm::cont::ArrayHandle<ReturnType> result;
|
||||
|
||||
@ -36,9 +36,7 @@ VTKM_CONT vtkm::cont::DataSet VectorMagnitude::DoExecute(const vtkm::cont::DataS
|
||||
outArray = result;
|
||||
};
|
||||
const auto& field = this->GetFieldFromDataSet(inDataSet);
|
||||
field.GetData()
|
||||
.CastAndCallForTypesWithFloatFallback<vtkm::TypeListVecCommon, VTKM_DEFAULT_STORAGE_LIST>(
|
||||
resolveType);
|
||||
field.GetData().CastAndCallWithExtractedArray(resolveType);
|
||||
|
||||
return this->CreateResultField(
|
||||
inDataSet, this->GetOutputFieldName(), field.GetAssociation(), outArray);
|
||||
|
Loading…
Reference in New Issue
Block a user