VTK-m  2.0
CellLocatorMultiplexer.h
Go to the documentation of this file.
1 //============================================================================
2 // Copyright (c) Kitware, Inc.
3 // All rights reserved.
4 // See LICENSE.txt for details.
5 //
6 // This software is distributed WITHOUT ANY WARRANTY; without even
7 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
8 // PURPOSE. See the above copyright notice for more information.
9 //============================================================================
10 #ifndef vtk_m_exec_CellLocatorMultiplexer_h
11 #define vtk_m_exec_CellLocatorMultiplexer_h
12 
13 #include <vtkm/ErrorCode.h>
14 #include <vtkm/TypeList.h>
15 
16 #include <vtkm/exec/Variant.h>
17 
18 namespace vtkm
19 {
20 namespace exec
21 {
22 
23 namespace detail
24 {
25 
26 struct FindCellFunctor
27 {
28  template <typename Locator>
29  VTKM_EXEC vtkm::ErrorCode operator()(Locator&& locator,
30  const vtkm::Vec3f& point,
31  vtkm::Id& cellId,
32  vtkm::Vec3f& parametric) const
33  {
34  return locator.FindCell(point, cellId, parametric);
35  }
36 
37  template <typename Locator, typename LastCell>
38  VTKM_EXEC vtkm::ErrorCode operator()(Locator&& locator,
39  const vtkm::Vec3f& point,
40  vtkm::Id& cellId,
41  vtkm::Vec3f& parametric,
42  LastCell& lastCell) const
43  {
44  using ConcreteLastCell = typename std::decay_t<Locator>::LastCell;
45  if (!lastCell.template IsType<ConcreteLastCell>())
46  {
47  lastCell = ConcreteLastCell{};
48  }
49  return locator.FindCell(point, cellId, parametric, lastCell.template Get<ConcreteLastCell>());
50  }
51 };
52 
53 } // namespace detail
54 
55 template <typename... LocatorTypes>
57 {
58  vtkm::exec::Variant<LocatorTypes...> Locators;
59 
60 public:
61  CellLocatorMultiplexer() = default;
62 
63  using LastCell = vtkm::exec::Variant<typename LocatorTypes::LastCell...>;
64 
65  template <typename Locator>
66  VTKM_CONT CellLocatorMultiplexer(const Locator& locator)
67  : Locators(locator)
68  {
69  }
70 
72  vtkm::Id& cellId,
73  vtkm::Vec3f& parametric) const
74  {
75  return this->Locators.CastAndCall(detail::FindCellFunctor{}, point, cellId, parametric);
76  }
77 
79  vtkm::Id& cellId,
80  vtkm::Vec3f& parametric,
81  LastCell& lastCell) const
82  {
83  return this->Locators.CastAndCall(
84  detail::FindCellFunctor{}, point, cellId, parametric, lastCell);
85  }
86 };
87 
88 }
89 } // namespace vtkm::exec
90 
91 #endif //vtk_m_exec_CellLocatorMultiplexer_h
vtkm::ErrorCode
ErrorCode
Definition: ErrorCode.h:19
vtkm::exec::CellLocatorMultiplexer::CellLocatorMultiplexer
VTKM_CONT CellLocatorMultiplexer(const Locator &locator)
Definition: CellLocatorMultiplexer.h:66
VTKM_EXEC
#define VTKM_EXEC
Definition: ExportMacros.h:51
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
vtkm::exec::CellLocatorMultiplexer::LastCell
vtkm::exec::Variant< typename LocatorTypes::LastCell... > LastCell
Definition: CellLocatorMultiplexer.h:63
Variant.h
vtkm::exec::CellLocatorMultiplexer::Locators
vtkm::exec::Variant< LocatorTypes... > Locators
Definition: CellLocatorMultiplexer.h:58
vtkm::Id
vtkm::Int32 Id
Represents an ID (index into arrays).
Definition: Types.h:191
vtkm::exec::CellLocatorMultiplexer
Definition: CellLocatorMultiplexer.h:56
ErrorCode.h
VTKM_CONT
#define VTKM_CONT
Definition: ExportMacros.h:57
TypeList.h
vtkm::exec::CellLocatorMultiplexer::FindCell
VTKM_EXEC vtkm::ErrorCode FindCell(const vtkm::Vec3f &point, vtkm::Id &cellId, vtkm::Vec3f &parametric) const
Definition: CellLocatorMultiplexer.h:71
vtkm::Vec< vtkm::FloatDefault, 3 >
vtkm::exec::CellLocatorMultiplexer::FindCell
VTKM_EXEC vtkm::ErrorCode FindCell(const vtkm::Vec3f &point, vtkm::Id &cellId, vtkm::Vec3f &parametric, LastCell &lastCell) const
Definition: CellLocatorMultiplexer.h:78
VTKM_ALWAYS_EXPORT
#define VTKM_ALWAYS_EXPORT
Definition: ExportMacros.h:92