//============================================================================ // 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. // // Copyright 2015 National Technology & Engineering Solutions of Sandia, LLC (NTESS). // Copyright 2015 UT-Battelle, LLC. // Copyright 2015 Los Alamos National Security. // // Under the terms of Contract DE-NA0003525 with NTESS, // the U.S. Government retains certain rights in this software. // // Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National // Laboratory (LANL), the U.S. Government retains certain rights in // this software. //============================================================================ #ifndef vtkm_m_worklet_Mask_h #define vtkm_m_worklet_Mask_h #include #include #include #include #include #include #include #include namespace vtkm { namespace worklet { // Subselect points using stride for now, creating new cellset of vertices class Mask { public: struct BoolType : vtkm::ListTagBase { }; template vtkm::cont::CellSetPermutation Run(const CellSetType& cellSet, const vtkm::Id stride, DeviceAdapter) { typedef typename vtkm::cont::DeviceAdapterAlgorithm DeviceAlgorithm; typedef vtkm::cont::CellSetPermutation OutputType; vtkm::Id numberOfInputCells = cellSet.GetNumberOfCells(); vtkm::Id numberOfSampledCells = numberOfInputCells / stride; vtkm::cont::ArrayHandleCounting strideArray(0, stride, numberOfSampledCells); DeviceAlgorithm::Copy(strideArray, this->ValidCellIds); return OutputType(this->ValidCellIds, cellSet, cellSet.GetName()); } //---------------------------------------------------------------------------- template vtkm::cont::ArrayHandle ProcessCellField( const vtkm::cont::ArrayHandle& in, const DeviceAdapter&) const { using Algo = vtkm::cont::DeviceAdapterAlgorithm; // Use a temporary permutation array to simplify the mapping: auto tmp = vtkm::cont::make_ArrayHandlePermutation(this->ValidCellIds, in); // Copy into an array with default storage: vtkm::cont::ArrayHandle result; Algo::Copy(tmp, result); return result; } private: vtkm::cont::ArrayHandle ValidCellIds; }; } } // namespace vtkm::worklet #endif // vtkm_m_worklet_Mask_h