2022-02-07 17:03:08 +00:00
|
|
|
//============================================================================
|
|
|
|
// 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.
|
|
|
|
//
|
|
|
|
//=============================================================================
|
|
|
|
#ifndef vtk_m_filter_ComputeMoments_hxx
|
|
|
|
#define vtk_m_filter_ComputeMoments_hxx
|
|
|
|
|
|
|
|
#include <vtkm/cont/ArrayHandle.h>
|
|
|
|
#include <vtkm/filter/image_processing/ComputeMoments.h>
|
|
|
|
#include <vtkm/filter/image_processing/worklet/ComputeMoments.h>
|
|
|
|
|
|
|
|
namespace vtkm
|
|
|
|
{
|
|
|
|
namespace filter
|
|
|
|
{
|
|
|
|
namespace image_processing
|
|
|
|
{
|
|
|
|
|
|
|
|
VTKM_CONT ComputeMoments::ComputeMoments()
|
|
|
|
{
|
|
|
|
this->SetOutputFieldName("moments_");
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_CONT vtkm::cont::DataSet ComputeMoments::DoExecute(const vtkm::cont::DataSet& input)
|
|
|
|
{
|
|
|
|
const auto& field = this->GetFieldFromDataSet(input);
|
2022-08-29 18:42:02 +00:00
|
|
|
if (!field.IsPointField())
|
2022-02-07 17:03:08 +00:00
|
|
|
{
|
|
|
|
throw vtkm::cont::ErrorBadValue("Active field for ComputeMoments must be a point field.");
|
|
|
|
}
|
|
|
|
|
|
|
|
vtkm::cont::DataSet output = this->CreateResult(input);
|
|
|
|
auto worklet = vtkm::worklet::moments::ComputeMoments(this->Radius, this->Spacing);
|
|
|
|
|
|
|
|
auto resolveType = [&](const auto& concrete) {
|
|
|
|
worklet.Run(input.GetCellSet(), concrete, this->Order, output);
|
|
|
|
};
|
2023-05-22 19:03:23 +00:00
|
|
|
this->CastAndCallVariableVecField(field, resolveType);
|
2022-02-07 17:03:08 +00:00
|
|
|
|
|
|
|
return output;
|
|
|
|
}
|
|
|
|
} // namespace image_processing
|
|
|
|
} // namespace filter
|
|
|
|
} // namespace vtkm
|
|
|
|
#endif //vtk_m_filter_ComputeMoments_hxx
|