2017-03-08 23:04:12 +00:00
|
|
|
//============================================================================
|
|
|
|
// Copyright (c) Kitware, Inc.
|
|
|
|
// All rights reserved.
|
|
|
|
// See LICENSE.txt for details.
|
2019-04-15 23:24:21 +00:00
|
|
|
//
|
2017-03-08 23:04:12 +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_MaskPoints_hxx
|
|
|
|
#define vtk_m_filter_MaskPoints_hxx
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
namespace vtkm
|
|
|
|
{
|
|
|
|
namespace filter
|
|
|
|
{
|
2017-03-08 23:04:12 +00:00
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
2017-05-18 14:29:41 +00:00
|
|
|
inline VTKM_CONT MaskPoints::MaskPoints()
|
|
|
|
: vtkm::filter::FilterDataSet<MaskPoints>()
|
|
|
|
, Stride(1)
|
|
|
|
, CompactPoints(true)
|
2017-03-08 23:04:12 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
2018-08-30 15:53:18 +00:00
|
|
|
template <typename DerivedPolicy>
|
2018-04-02 21:58:21 +00:00
|
|
|
inline VTKM_CONT vtkm::cont::DataSet MaskPoints::DoExecute(
|
2017-05-26 17:53:28 +00:00
|
|
|
const vtkm::cont::DataSet& input,
|
2018-08-30 15:53:18 +00:00
|
|
|
vtkm::filter::PolicyBase<DerivedPolicy> policy)
|
2017-03-08 23:04:12 +00:00
|
|
|
{
|
|
|
|
// extract the input cell set
|
2019-08-13 17:08:54 +00:00
|
|
|
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet();
|
2017-03-08 23:04:12 +00:00
|
|
|
|
|
|
|
// run the worklet on the cell set and input field
|
|
|
|
vtkm::cont::CellSetSingleType<> outCellSet;
|
|
|
|
vtkm::worklet::MaskPoints worklet;
|
|
|
|
|
2020-05-15 23:47:30 +00:00
|
|
|
outCellSet = worklet.Run(vtkm::filter::ApplyPolicyCellSet(cells, policy, *this), this->Stride);
|
2017-03-08 23:04:12 +00:00
|
|
|
|
|
|
|
// create the output dataset
|
|
|
|
vtkm::cont::DataSet output;
|
2019-08-13 17:08:54 +00:00
|
|
|
output.SetCellSet(outCellSet);
|
2017-05-18 14:29:41 +00:00
|
|
|
output.AddCoordinateSystem(input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex()));
|
2017-03-08 23:04:12 +00:00
|
|
|
|
|
|
|
// compact the unused points in the output dataset
|
|
|
|
if (this->CompactPoints)
|
|
|
|
{
|
|
|
|
this->Compactor.SetCompactPointFields(true);
|
2019-01-28 14:24:48 +00:00
|
|
|
this->Compactor.SetMergePoints(false);
|
2020-05-15 23:47:30 +00:00
|
|
|
return this->Compactor.Execute(output);
|
2017-03-08 23:04:12 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-04-02 21:58:21 +00:00
|
|
|
return output;
|
2017-03-08 23:04:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
2018-08-30 15:53:18 +00:00
|
|
|
template <typename T, typename StorageType, typename DerivedPolicy>
|
2018-04-02 21:58:21 +00:00
|
|
|
inline VTKM_CONT bool MaskPoints::DoMapField(vtkm::cont::DataSet& result,
|
2017-05-18 14:29:41 +00:00
|
|
|
const vtkm::cont::ArrayHandle<T, StorageType>& input,
|
|
|
|
const vtkm::filter::FieldMetadata& fieldMeta,
|
2018-08-30 15:53:18 +00:00
|
|
|
vtkm::filter::PolicyBase<DerivedPolicy> policy)
|
2017-03-08 23:04:12 +00:00
|
|
|
{
|
|
|
|
// point data is copied as is because it was not collapsed
|
2017-05-18 14:29:41 +00:00
|
|
|
if (fieldMeta.IsPointField())
|
2017-03-08 23:04:12 +00:00
|
|
|
{
|
|
|
|
if (this->CompactPoints)
|
|
|
|
{
|
2018-08-30 15:53:18 +00:00
|
|
|
return this->Compactor.DoMapField(result, input, fieldMeta, policy);
|
2017-03-08 23:04:12 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-04-02 21:58:21 +00:00
|
|
|
result.AddField(fieldMeta.AsField(input));
|
2017-03-08 23:04:12 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2017-05-18 14:29:41 +00:00
|
|
|
|
2017-03-08 23:04:12 +00:00
|
|
|
// cell data does not apply
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-10-07 19:39:02 +00:00
|
|
|
#endif
|