mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-08 13:23:51 +00:00
`PointLocator`s have changed from being virtual objects to being trivial objects. Part of this change means that when a worklet gets the execution object for a point locator, it gets the actual object (or a reference to it) instead of a pointer to an object. This means that the new code uses the `.` operator to access the locator's features instead of the `->` operator. To support code still using the deprecated functionality, added a specific `->` operator to the locator execution object to make it behave as if it were a pointer. However, this operator is marked deprecated to warn the user that they should modify their code to use the `.` instead.
71 lines
2.0 KiB
C++
71 lines
2.0 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/internal/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);
|
|
}
|
|
};
|
|
|
|
} // namespace detail
|
|
|
|
template <typename... LocatorTypes>
|
|
class VTKM_ALWAYS_EXPORT CellLocatorMultiplexer
|
|
{
|
|
vtkm::exec::internal::Variant<LocatorTypes...> Locators;
|
|
|
|
public:
|
|
CellLocatorMultiplexer() = default;
|
|
|
|
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_DEPRECATED(1.6, "Locators are no longer pointers. Use . operator.")
|
|
VTKM_EXEC CellLocatorMultiplexer* operator->() { return this; }
|
|
VTKM_DEPRECATED(1.6, "Locators are no longer pointers. Use . operator.")
|
|
VTKM_EXEC const CellLocatorMultiplexer* operator->() const { return this; }
|
|
};
|
|
|
|
}
|
|
} // namespace vtkm::exec
|
|
|
|
#endif //vtk_m_exec_CellLocatorMultiplexer_h
|