vtk-m/vtkm/filter/Probe.hxx
Kenneth Moreland 5fa02057ae Rely less on overload resolution for ApplyPolicy
Previously, all the ApplyPolicy functions had the same name and used
template resolution to figure out which one to use. This was pretty
clear at first when there was just one for fields and one for cell sets.
But then it grew to several different types, particularly for fields. It
was hard to look at the code and figure out which form of ApplyPolicy
was being used, and compilers were starting to get confused.

Resolve the problem by giving all the methods unique names to make it
clear which one you expect to be called.
2019-09-09 16:08:11 -06:00

68 lines
2.3 KiB
C++

//============================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt for details.
//
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//============================================================================
namespace vtkm
{
namespace filter
{
VTKM_CONT
inline void Probe::SetGeometry(const vtkm::cont::DataSet& geometry)
{
this->Geometry = vtkm::cont::DataSet();
this->Geometry.SetCellSet(geometry.GetCellSet());
this->Geometry.AddCoordinateSystem(geometry.GetCoordinateSystem());
}
template <typename DerivedPolicy>
VTKM_CONT inline vtkm::cont::DataSet Probe::DoExecute(
const vtkm::cont::DataSet& input,
vtkm::filter::PolicyBase<DerivedPolicy> policy)
{
this->Worklet.Run(vtkm::filter::ApplyPolicyCellSet(input.GetCellSet(), policy),
input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex()),
this->Geometry.GetCoordinateSystem().GetData());
auto output = this->Geometry;
auto hpf = this->Worklet.GetHiddenPointsField();
auto hcf = this->Worklet.GetHiddenCellsField(
vtkm::filter::ApplyPolicyCellSet(output.GetCellSet(), policy));
output.AddField(vtkm::cont::make_FieldPoint("HIDDEN", hpf));
output.AddField(vtkm::cont::make_FieldCell("HIDDEN", hcf));
return output;
}
template <typename T, typename StorageType, typename DerivedPolicy>
VTKM_CONT inline bool Probe::DoMapField(vtkm::cont::DataSet& result,
const vtkm::cont::ArrayHandle<T, StorageType>& input,
const vtkm::filter::FieldMetadata& fieldMeta,
vtkm::filter::PolicyBase<DerivedPolicy>)
{
if (fieldMeta.IsPointField())
{
auto fieldArray =
this->Worklet.ProcessPointField(input, typename DerivedPolicy::AllCellSetList());
result.AddField(fieldMeta.AsField(fieldArray));
return true;
}
else if (fieldMeta.IsCellField())
{
auto fieldArray = this->Worklet.ProcessCellField(input);
result.AddField(fieldMeta.AsField(fieldArray));
return true;
}
return false;
}
}
} // vtkm::filter