2017-03-28 20:42:22 +00:00
|
|
|
//============================================================================
|
|
|
|
// Copyright (c) Kitware, Inc.
|
|
|
|
// All rights reserved.
|
|
|
|
// See LICENSE.txt for details.
|
2019-04-15 23:24:21 +00:00
|
|
|
//
|
2017-03-28 20:42:22 +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.
|
|
|
|
//============================================================================
|
|
|
|
#ifndef vtkm_m_worklet_Mask_h
|
|
|
|
#define vtkm_m_worklet_Mask_h
|
|
|
|
|
|
|
|
#include <vtkm/worklet/DispatcherMapTopology.h>
|
|
|
|
#include <vtkm/worklet/WorkletMapTopology.h>
|
|
|
|
|
2018-08-30 15:53:18 +00:00
|
|
|
#include <vtkm/cont/ArrayCopy.h>
|
2017-03-28 20:42:22 +00:00
|
|
|
#include <vtkm/cont/ArrayHandle.h>
|
|
|
|
#include <vtkm/cont/ArrayHandleCounting.h>
|
|
|
|
#include <vtkm/cont/ArrayHandlePermutation.h>
|
2017-05-18 14:51:24 +00:00
|
|
|
#include <vtkm/cont/CellSetPermutation.h>
|
|
|
|
#include <vtkm/cont/DataSet.h>
|
2017-03-28 20:42:22 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
namespace vtkm
|
|
|
|
{
|
|
|
|
namespace worklet
|
|
|
|
{
|
2017-03-28 20:42:22 +00:00
|
|
|
|
|
|
|
// Subselect points using stride for now, creating new cellset of vertices
|
|
|
|
class Mask
|
|
|
|
{
|
|
|
|
public:
|
2018-08-30 15:53:18 +00:00
|
|
|
template <typename CellSetType>
|
|
|
|
vtkm::cont::CellSetPermutation<CellSetType> Run(const CellSetType& cellSet, const vtkm::Id stride)
|
2017-03-28 20:42:22 +00:00
|
|
|
{
|
2018-02-22 13:29:13 +00:00
|
|
|
using OutputType = vtkm::cont::CellSetPermutation<CellSetType>;
|
2017-03-28 20:42:22 +00:00
|
|
|
|
|
|
|
vtkm::Id numberOfInputCells = cellSet.GetNumberOfCells();
|
|
|
|
vtkm::Id numberOfSampledCells = numberOfInputCells / stride;
|
|
|
|
vtkm::cont::ArrayHandleCounting<vtkm::Id> strideArray(0, stride, numberOfSampledCells);
|
|
|
|
|
2018-08-30 15:53:18 +00:00
|
|
|
vtkm::cont::ArrayCopy(strideArray, this->ValidCellIds);
|
2017-03-28 20:42:22 +00:00
|
|
|
|
2019-08-13 21:28:37 +00:00
|
|
|
return OutputType(this->ValidCellIds, cellSet);
|
2017-03-28 20:42:22 +00:00
|
|
|
}
|
|
|
|
|
2017-06-15 17:17:52 +00:00
|
|
|
//----------------------------------------------------------------------------
|
2018-08-30 15:53:18 +00:00
|
|
|
template <typename ValueType, typename StorageType>
|
2017-06-15 17:17:52 +00:00
|
|
|
vtkm::cont::ArrayHandle<ValueType> ProcessCellField(
|
2018-08-30 15:53:18 +00:00
|
|
|
const vtkm::cont::ArrayHandle<ValueType, StorageType>& in) const
|
2017-03-28 20:42:22 +00:00
|
|
|
{
|
2017-06-15 17:17:52 +00:00
|
|
|
// Use a temporary permutation array to simplify the mapping:
|
|
|
|
auto tmp = vtkm::cont::make_ArrayHandlePermutation(this->ValidCellIds, in);
|
2017-03-28 20:42:22 +00:00
|
|
|
|
2017-06-15 17:17:52 +00:00
|
|
|
// Copy into an array with default storage:
|
|
|
|
vtkm::cont::ArrayHandle<ValueType> result;
|
2018-08-30 15:53:18 +00:00
|
|
|
vtkm::cont::ArrayCopy(tmp, result);
|
2017-03-28 20:42:22 +00:00
|
|
|
|
2017-06-15 17:17:52 +00:00
|
|
|
return result;
|
2017-03-28 20:42:22 +00:00
|
|
|
}
|
|
|
|
|
2020-02-06 21:58:59 +00:00
|
|
|
vtkm::cont::ArrayHandle<vtkm::Id> GetValidCellIds() const { return this->ValidCellIds; }
|
|
|
|
|
2017-03-28 20:42:22 +00:00
|
|
|
private:
|
|
|
|
vtkm::cont::ArrayHandle<vtkm::Id> ValidCellIds;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
} // namespace vtkm::worklet
|
|
|
|
|
|
|
|
#endif // vtkm_m_worklet_Mask_h
|