//============================================================================ // 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. //============================================================================ #ifndef vtk_m_exec_CellLocatorMultiplexer_h #define vtk_m_exec_CellLocatorMultiplexer_h #include #include #include namespace vtkm { namespace exec { namespace detail { struct FindCellFunctor { template VTKM_EXEC vtkm::ErrorCode operator()(Locator&& locator, const vtkm::Vec3f& point, vtkm::Id& cellId, vtkm::Vec3f& parametric) const { return locator.FindCell(point, cellId, parametric); } template VTKM_EXEC vtkm::ErrorCode operator()(Locator&& locator, const vtkm::Vec3f& point, vtkm::Id& cellId, vtkm::Vec3f& parametric, LastCell& lastCell) const { using ConcreteLastCell = typename std::decay_t::LastCell; if (!lastCell.template IsType()) { lastCell = ConcreteLastCell{}; } return locator.FindCell(point, cellId, parametric, lastCell.template Get()); } }; } // namespace detail template class VTKM_ALWAYS_EXPORT CellLocatorMultiplexer { vtkm::exec::Variant Locators; public: CellLocatorMultiplexer() = default; using LastCell = vtkm::exec::Variant; template VTKM_CONT CellLocatorMultiplexer(const Locator& locator) : Locators(locator) { } VTKM_EXEC vtkm::ErrorCode FindCell(const vtkm::Vec3f& point, vtkm::Id& cellId, vtkm::Vec3f& parametric) const { return this->Locators.CastAndCall(detail::FindCellFunctor{}, point, cellId, parametric); } VTKM_EXEC vtkm::ErrorCode FindCell(const vtkm::Vec3f& point, vtkm::Id& cellId, vtkm::Vec3f& parametric, LastCell& lastCell) const { return this->Locators.CastAndCall( detail::FindCellFunctor{}, point, cellId, parametric, lastCell); } }; } } // namespace vtkm::exec #endif //vtk_m_exec_CellLocatorMultiplexer_h