vtk-m/vtkm/filter/CellMeasures.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

59 lines
1.9 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.
//============================================================================
#include <vtkm/cont/DynamicCellSet.h>
#include <vtkm/cont/ErrorFilterExecution.h>
namespace vtkm
{
namespace filter
{
//-----------------------------------------------------------------------------
template <typename IntegrationType>
inline VTKM_CONT CellMeasures<IntegrationType>::CellMeasures()
: vtkm::filter::FilterCell<CellMeasures<IntegrationType>>()
{
this->SetUseCoordinateSystemAsField(true);
}
//-----------------------------------------------------------------------------
template <typename IntegrationType>
template <typename T, typename StorageType, typename DerivedPolicy>
inline VTKM_CONT vtkm::cont::DataSet CellMeasures<IntegrationType>::DoExecute(
const vtkm::cont::DataSet& input,
const vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>, StorageType>& points,
const vtkm::filter::FieldMetadata& fieldMeta,
const vtkm::filter::PolicyBase<DerivedPolicy>& policy)
{
if (fieldMeta.IsPointField() == false)
{
throw vtkm::cont::ErrorFilterExecution("CellMeasures expects point field input.");
}
const auto& cellset = input.GetCellSet();
vtkm::cont::ArrayHandle<T> outArray;
this->Invoke(vtkm::worklet::CellMeasure<IntegrationType>{},
vtkm::filter::ApplyPolicyCellSet(cellset, policy),
points,
outArray);
std::string outputName = this->GetCellMeasureName();
if (outputName.empty())
{
// Default name is name of input.
outputName = "measure";
}
return CreateResultFieldCell(input, outArray, outputName);
}
}
} // namespace vtkm::filter