//============================================================================= // // 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 2019 National Technology & Engineering Solutions of Sandia, LLC (NTESS). // Copyright 2019 UT-Battelle, LLC. // Copyright 2019 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 vtk_m_worklet_MaskSelect_h #define vtk_m_worklet_MaskSelect_h #include #include namespace vtkm { namespace worklet { /// \brief Mask using arrays to select specific elements to suppress. /// /// \c MaskSelect is a worklet mask object that is used to select elementsin the output of a /// worklet to suppress the invocation. That is, the worklet will only be invoked for elements in /// the output that are not masked out by the given array. /// /// \c MaskSelect is initialized with a mask array. This array should contain a 0 for any entry /// that should be masked and a 1 for any output that should be generated. It is an error to have /// any value that is not a 0 or 1. This method is slower than specifying an index array. /// class VTKM_WORKLET_EXPORT MaskSelect { struct MaskTypes : vtkm::ListTagBase { }; using VariantArrayHandleMask = vtkm::cont::VariantArrayHandleBase; public: using ThreadToOutputMapType = vtkm::cont::ArrayHandle; MaskSelect(const VariantArrayHandleMask& maskArray, vtkm::cont::DeviceAdapterId device = vtkm::cont::DeviceAdapterTagAny()) { this->ThreadToOutputMap = this->Build(maskArray, device); } template MaskSelect(const vtkm::cont::VariantArrayHandleBase& indexArray, vtkm::cont::DeviceAdapterId device = vtkm::cont::DeviceAdapterTagAny()) { this->ThreadToOutputMap = this->Build(VariantArrayHandleMask(indexArray), device); } template vtkm::Id GetThreadRange(RangeType vtkmNotUsed(outputRange)) const { return this->ThreadToOutputMap.GetNumberOfValues(); } template ThreadToOutputMapType GetThreadToOutputMap(RangeType vtkmNotUsed(outputRange)) const { return this->ThreadToOutputMap; } private: ThreadToOutputMapType ThreadToOutputMap; VTKM_CONT ThreadToOutputMapType Build(const VariantArrayHandleMask& maskArray, vtkm::cont::DeviceAdapterId device); }; } } // namespace vtkm::worklet #endif //vtk_m_worklet_MaskSelect_h