2018-05-10 18:56:45 +00:00
|
|
|
//============================================================================
|
|
|
|
// Copyright (c) Kitware, Inc.
|
|
|
|
// All rights reserved.
|
|
|
|
// See LICENSE.txt for details.
|
2019-04-15 23:24:21 +00:00
|
|
|
//
|
2018-05-10 18:56:45 +00:00
|
|
|
// 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.
|
|
|
|
//============================================================================
|
|
|
|
|
2019-10-07 19:39:02 +00:00
|
|
|
#ifndef vtk_m_filter_CellMeasures_hxx
|
|
|
|
#define vtk_m_filter_CellMeasures_hxx
|
|
|
|
|
2019-03-28 17:29:24 +00:00
|
|
|
#include <vtkm/cont/DynamicCellSet.h>
|
|
|
|
#include <vtkm/cont/ErrorFilterExecution.h>
|
2018-05-10 18:56:45 +00:00
|
|
|
|
|
|
|
namespace vtkm
|
|
|
|
{
|
|
|
|
namespace filter
|
|
|
|
{
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
template <typename IntegrationType>
|
|
|
|
inline VTKM_CONT CellMeasures<IntegrationType>::CellMeasures()
|
|
|
|
: vtkm::filter::FilterCell<CellMeasures<IntegrationType>>()
|
|
|
|
{
|
|
|
|
this->SetUseCoordinateSystemAsField(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
template <typename IntegrationType>
|
2018-08-30 15:53:18 +00:00
|
|
|
template <typename T, typename StorageType, typename DerivedPolicy>
|
2018-05-10 18:56:45 +00:00
|
|
|
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,
|
2018-08-30 15:53:18 +00:00
|
|
|
const vtkm::filter::PolicyBase<DerivedPolicy>& policy)
|
2018-05-10 18:56:45 +00:00
|
|
|
{
|
2019-08-12 19:46:55 +00:00
|
|
|
if (fieldMeta.IsPointField() == false)
|
|
|
|
{
|
|
|
|
throw vtkm::cont::ErrorFilterExecution("CellMeasures expects point field input.");
|
|
|
|
}
|
|
|
|
|
2019-08-13 17:08:54 +00:00
|
|
|
const auto& cellset = input.GetCellSet();
|
2018-05-10 18:56:45 +00:00
|
|
|
vtkm::cont::ArrayHandle<T> outArray;
|
|
|
|
|
2019-08-07 16:54:47 +00:00
|
|
|
this->Invoke(vtkm::worklet::CellMeasure<IntegrationType>{},
|
2019-09-09 22:08:11 +00:00
|
|
|
vtkm::filter::ApplyPolicyCellSet(cellset, policy),
|
2019-08-07 16:54:47 +00:00
|
|
|
points,
|
|
|
|
outArray);
|
2018-05-10 18:56:45 +00:00
|
|
|
|
|
|
|
std::string outputName = this->GetCellMeasureName();
|
|
|
|
if (outputName.empty())
|
|
|
|
{
|
|
|
|
// Default name is name of input.
|
|
|
|
outputName = "measure";
|
|
|
|
}
|
2019-08-13 17:08:54 +00:00
|
|
|
return CreateResultFieldCell(input, outArray, outputName);
|
2018-05-10 18:56:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} // namespace vtkm::filter
|
2019-10-07 19:39:02 +00:00
|
|
|
|
|
|
|
#endif
|