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 2014 UT-Battelle, LLC. 11 // Copyright 2018 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 #ifndef vtk_m_cont_PointLocator_h 21 #define vtk_m_cont_PointLocator_h 22 23 #include <vtkm/cont/CoordinateSystem.h> 24 #include <vtkm/cont/ExecutionObjectBase.h> 25 #include <vtkm/exec/PointLocator.h> 26 27 namespace vtkm 28 { 29 namespace cont 30 { 31 32 class PointLocator : public vtkm::cont::ExecutionObjectBase 33 { 34 public: PointLocator()35 PointLocator() 36 : dirty(true) 37 { 38 } 39 GetCoords()40 vtkm::cont::CoordinateSystem GetCoords() const { return coordinates; } 41 SetCoords(const vtkm::cont::CoordinateSystem & coords)42 void SetCoords(const vtkm::cont::CoordinateSystem& coords) 43 { 44 coordinates = coords; 45 dirty = true; 46 } 47 48 virtual void Build() = 0; 49 Update()50 void Update() 51 { 52 if (dirty) 53 Build(); 54 dirty = false; 55 } 56 57 template <typename DeviceAdapter> PrepareForExecution(DeviceAdapter device)58 VTKM_CONT const vtkm::exec::PointLocator* PrepareForExecution(DeviceAdapter device) const 59 { 60 return PrepareForExecutionImp(device).PrepareForExecution(device); 61 } 62 63 using HandleType = vtkm::cont::VirtualObjectHandle<vtkm::exec::PointLocator>; 64 VTKM_CONT virtual const HandleType PrepareForExecutionImp( 65 vtkm::cont::DeviceAdapterId deviceId) const = 0; 66 67 private: 68 vtkm::cont::CoordinateSystem coordinates; 69 70 bool dirty; 71 }; 72 } 73 } 74 #endif // vtk_m_cont_PointLocator_h 75