1 //============================================================================ 2 // Copyright (c) Kitware, Inc. 3 // All rights reserved. 4 // See LICENSE.txt for details. 5 // This software is distributed WITHOUT ANY WARRANTY; without even 6 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 7 // PURPOSE. See the above copyright notice for more information. 8 // 9 // Copyright 2017 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 10 // Copyright 2017 UT-Battelle, LLC. 11 // Copyright 2017 Los Alamos National Security. 12 // 13 // Under the terms of Contract DE-NA0003525 with NTESS, 14 // the U.S. Government retains certain rights in this software. 15 // 16 // Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National 17 // Laboratory (LANL), the U.S. Government retains certain rights in 18 // this software. 19 //============================================================================ 20 21 #ifndef vtk_m_filter_ClipWithImplicitFunction_h 22 #define vtk_m_filter_ClipWithImplicitFunction_h 23 24 #include <vtkm/cont/ImplicitFunctionHandle.h> 25 #include <vtkm/filter/FilterDataSet.h> 26 #include <vtkm/worklet/Clip.h> 27 28 namespace vtkm 29 { 30 namespace filter 31 { 32 33 /// \brief Clip a dataset using an implicit function 34 /// 35 /// Clip a dataset using a given implicit function value, such as vtkm::Sphere 36 /// or vtkm::Frustum. 37 /// The resulting geometry will not be water tight. 38 class ClipWithImplicitFunction : public vtkm::filter::FilterDataSet<ClipWithImplicitFunction> 39 { 40 public: 41 ClipWithImplicitFunction(); 42 SetImplicitFunction(const vtkm::cont::ImplicitFunctionHandle & func)43 void SetImplicitFunction(const vtkm::cont::ImplicitFunctionHandle& func) 44 { 45 this->Function = func; 46 } 47 SetInvertClip(bool invert)48 void SetInvertClip(bool invert) { this->Invert = invert; } 49 GetImplicitFunction()50 const vtkm::cont::ImplicitFunctionHandle& GetImplicitFunction() const { return this->Function; } 51 52 template <typename DerivedPolicy, typename DeviceAdapter> 53 vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& input, 54 const vtkm::filter::PolicyBase<DerivedPolicy>& policy, 55 const DeviceAdapter& tag); 56 57 //Map a new field onto the resulting dataset after running the filter. 58 //This call is only valid after Execute has been called. 59 template <typename T, typename StorageType, typename DerivedPolicy, typename DeviceAdapter> 60 bool DoMapField(vtkm::cont::DataSet& result, 61 const vtkm::cont::ArrayHandle<T, StorageType>& input, 62 const vtkm::filter::FieldMetadata& fieldMeta, 63 const vtkm::filter::PolicyBase<DerivedPolicy>& policy, 64 const DeviceAdapter& tag); 65 66 private: 67 vtkm::cont::ImplicitFunctionHandle Function; 68 vtkm::worklet::Clip Worklet; 69 bool Invert; 70 }; 71 } 72 } // namespace vtkm::filter 73 74 #include <vtkm/filter/ClipWithImplicitFunction.hxx> 75 76 #endif // vtk_m_filter_ClipWithImplicitFunction_h 77