2017-03-21 22:11:06 +00:00
|
|
|
//============================================================================
|
|
|
|
// Copyright (c) Kitware, Inc.
|
|
|
|
// All rights reserved.
|
|
|
|
// See LICENSE.txt for details.
|
2019-04-15 23:24:21 +00:00
|
|
|
//
|
2017-03-21 22:11:06 +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.
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
namespace
|
|
|
|
{
|
2017-05-18 14:29:41 +00:00
|
|
|
|
2017-06-15 17:17:52 +00:00
|
|
|
struct CallWorklet
|
|
|
|
{
|
|
|
|
vtkm::Id Stride;
|
|
|
|
vtkm::cont::DynamicCellSet& Output;
|
|
|
|
vtkm::worklet::Mask& Worklet;
|
|
|
|
|
|
|
|
CallWorklet(vtkm::Id stride, vtkm::cont::DynamicCellSet& output, vtkm::worklet::Mask& worklet)
|
|
|
|
: Stride(stride)
|
|
|
|
, Output(output)
|
|
|
|
, Worklet(worklet)
|
2017-05-18 14:29:41 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename CellSetType>
|
2017-06-15 17:17:52 +00:00
|
|
|
void operator()(const CellSetType& cells) const
|
2017-03-21 22:11:06 +00:00
|
|
|
{
|
2018-08-30 15:53:18 +00:00
|
|
|
this->Output = this->Worklet.Run(cells, this->Stride);
|
2017-03-21 22:11:06 +00:00
|
|
|
}
|
|
|
|
};
|
2017-06-15 17:17:52 +00:00
|
|
|
|
|
|
|
} // end anon namespace
|
2017-03-21 22:11:06 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
namespace vtkm
|
|
|
|
{
|
|
|
|
namespace filter
|
|
|
|
{
|
2017-03-21 22:11:06 +00:00
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
2017-05-18 14:29:41 +00:00
|
|
|
inline VTKM_CONT Mask::Mask()
|
|
|
|
: vtkm::filter::FilterDataSet<Mask>()
|
|
|
|
, Stride(1)
|
|
|
|
, CompactPoints(false)
|
2017-03-21 22:11:06 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
2018-08-30 15:53:18 +00:00
|
|
|
template <typename DerivedPolicy>
|
|
|
|
inline VTKM_CONT vtkm::cont::DataSet Mask::DoExecute(const vtkm::cont::DataSet& input,
|
|
|
|
vtkm::filter::PolicyBase<DerivedPolicy> policy)
|
2017-03-21 22:11:06 +00:00
|
|
|
{
|
2019-08-13 17:08:54 +00:00
|
|
|
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet();
|
2017-06-15 17:17:52 +00:00
|
|
|
vtkm::cont::DynamicCellSet cellOut;
|
2018-08-30 15:53:18 +00:00
|
|
|
CallWorklet workletCaller(this->Stride, cellOut, this->Worklet);
|
2017-06-15 17:17:52 +00:00
|
|
|
vtkm::filter::ApplyPolicy(cells, policy).CastAndCall(workletCaller);
|
2017-03-21 22:11:06 +00:00
|
|
|
|
|
|
|
// create the output dataset
|
|
|
|
vtkm::cont::DataSet output;
|
|
|
|
output.AddCoordinateSystem(input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex()));
|
2019-08-13 17:08:54 +00:00
|
|
|
output.SetCellSet(cellOut);
|
2018-04-02 21:58:21 +00:00
|
|
|
return output;
|
2017-03-21 22:11:06 +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 Mask::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>)
|
2017-03-21 22:11:06 +00:00
|
|
|
{
|
2017-06-15 17:17:52 +00:00
|
|
|
vtkm::cont::Field output;
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
if (fieldMeta.IsPointField())
|
2017-03-21 22:11:06 +00:00
|
|
|
{
|
2017-06-15 17:17:52 +00:00
|
|
|
output = fieldMeta.AsField(input); // pass through
|
2017-03-21 22:11:06 +00:00
|
|
|
}
|
2017-06-15 17:17:52 +00:00
|
|
|
else if (fieldMeta.IsCellField())
|
2017-03-21 22:11:06 +00:00
|
|
|
{
|
2018-08-30 15:53:18 +00:00
|
|
|
output = fieldMeta.AsField(this->Worklet.ProcessCellField(input));
|
2017-06-15 17:17:52 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
2017-03-21 22:11:06 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 21:58:21 +00:00
|
|
|
result.AddField(output);
|
2017-06-15 17:17:52 +00:00
|
|
|
return true;
|
2017-03-21 22:11:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|