mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-08 13:23:51 +00:00
With the major revision 2.0 of VTK-m, many items previously marked as deprecated were removed. If updating to a new version of VTK-m, it is recommended to first update to VTK-m 1.9, which will include the deprecated features but provide warnings (with the right compiler) that will point to the replacement code. Once the deprecations have been fixed, updating to 2.0 should be smoother.
92 lines
2.8 KiB
C++
92 lines
2.8 KiB
C++
//============================================================================
|
|
// 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 <vtkm/ErrorCode.h>
|
|
#include <vtkm/TypeList.h>
|
|
|
|
#include <vtkm/exec/Variant.h>
|
|
|
|
namespace vtkm
|
|
{
|
|
namespace exec
|
|
{
|
|
|
|
namespace detail
|
|
{
|
|
|
|
struct FindCellFunctor
|
|
{
|
|
template <typename Locator>
|
|
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 <typename Locator, typename LastCell>
|
|
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<Locator>::LastCell;
|
|
if (!lastCell.template IsType<ConcreteLastCell>())
|
|
{
|
|
lastCell = ConcreteLastCell{};
|
|
}
|
|
return locator.FindCell(point, cellId, parametric, lastCell.template Get<ConcreteLastCell>());
|
|
}
|
|
};
|
|
|
|
} // namespace detail
|
|
|
|
template <typename... LocatorTypes>
|
|
class VTKM_ALWAYS_EXPORT CellLocatorMultiplexer
|
|
{
|
|
vtkm::exec::Variant<LocatorTypes...> Locators;
|
|
|
|
public:
|
|
CellLocatorMultiplexer() = default;
|
|
|
|
using LastCell = vtkm::exec::Variant<typename LocatorTypes::LastCell...>;
|
|
|
|
template <typename Locator>
|
|
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
|