VTK-m  2.0
CellInside.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_CellInside_h
11 #define vtk_m_exec_CellInside_h
12 
13 #include <vtkm/CellShape.h>
14 #include <vtkm/Types.h>
15 
16 #include <lcl/lcl.h>
17 
18 namespace vtkm
19 {
20 namespace exec
21 {
22 
23 template <typename T, typename CellShapeTag>
24 static inline VTKM_EXEC bool CellInside(const vtkm::Vec<T, 3>& pcoords, CellShapeTag)
25 {
26  using VtkcTagType = typename vtkm::internal::CellShapeTagVtkmToVtkc<CellShapeTag>::Type;
27  return lcl::cellInside(VtkcTagType{}, pcoords);
28 }
29 
30 template <typename T>
31 static inline VTKM_EXEC bool CellInside(const vtkm::Vec<T, 3>&, vtkm::CellShapeTagEmpty)
32 {
33  return false;
34 }
35 
36 template <typename T>
37 static inline VTKM_EXEC bool CellInside(const vtkm::Vec<T, 3>& pcoords, vtkm::CellShapeTagPolyLine)
38 {
39  return pcoords[0] >= T(0) && pcoords[0] <= T(1);
40 }
41 
45 template <typename T>
46 static inline VTKM_EXEC bool CellInside(const vtkm::Vec<T, 3>& pcoords,
48 {
49  bool result = false;
50  switch (shape.Id)
51  {
52  vtkmGenericCellShapeMacro(result = CellInside(pcoords, CellShapeTag()));
53  default:
54  break;
55  }
56 
57  return result;
58 }
59 }
60 } // vtkm::exec
61 
62 #endif // vtk_m_exec_CellInside_h
VTKM_EXEC
#define VTKM_EXEC
Definition: ExportMacros.h:51
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
Types.h
CellShape.h
vtkmGenericCellShapeMacro
#define vtkmGenericCellShapeMacro(call)
A macro used in a switch statement to determine cell shape.
Definition: CellShape.h:230
vtkm::Vec< T, 3 >
Definition: Types.h:975
vtkm::CellShapeTagGeneric::Id
vtkm::UInt8 Id
Definition: CellShape.h:160
vtkm::CellShapeTagGeneric
A special cell shape tag that holds a cell shape that is not known at compile time.
Definition: CellShape.h:152