VTK-m  2.0
OrientNormals.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 // This software is distributed WITHOUT ANY WARRANTY; without even
6 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
7 // PURPOSE. See the above copyright notice for more information.
8 //
9 // Copyright 2019 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
10 // Copyright 2019 UT-Battelle, LLC.
11 // Copyright 2019 Los Alamos National Security.
12 //
13 // Under the terms of Contract DE-NA0003525 with NTESS,
14 // the U.S. Government retains certain rights in this software.
15 //
16 // Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
17 // Laboratory (LANL), the U.S. Government retains certain rights in
18 // this software.
19 //============================================================================
20 #ifndef vtkm_m_worklet_OrientNormals_h
21 #define vtkm_m_worklet_OrientNormals_h
22 
23 #include <vtkm/Types.h>
24 
25 #include <vtkm/cont/Algorithm.h>
26 #include <vtkm/cont/ArrayHandle.h>
28 
32 
33 namespace vtkm
34 {
35 namespace worklet
36 {
37 
44 {
45 public:
46  template <typename CellSetType,
47  typename CoordsCompType,
48  typename CoordsStorageType,
49  typename CellNormalCompType,
50  typename CellNormalStorageType>
52  const CellSetType& cells,
53  const vtkm::cont::ArrayHandle<vtkm::Vec<CoordsCompType, 3>, CoordsStorageType>& coords,
54  vtkm::cont::ArrayHandle<vtkm::Vec<CellNormalCompType, 3>, CellNormalStorageType>& cellNormals)
55  {
56  OrientCellNormals::Run(cells, coords, cellNormals);
57  }
58 
59  template <typename CellSetType,
60  typename CoordsCompType,
61  typename CoordsStorageType,
62  typename PointNormalCompType,
63  typename PointNormalStorageType>
65  const CellSetType& cells,
66  const vtkm::cont::ArrayHandle<vtkm::Vec<CoordsCompType, 3>, CoordsStorageType>& coords,
68  pointNormals)
69  {
70  OrientPointNormals::Run(cells, coords, pointNormals);
71  }
72 
73  template <typename CellSetType,
74  typename CoordsCompType,
75  typename CoordsStorageType,
76  typename PointNormalCompType,
77  typename PointNormalStorageType,
78  typename CellNormalCompType,
79  typename CellNormalStorageType>
81  const CellSetType& cells,
82  const vtkm::cont::ArrayHandle<vtkm::Vec<CoordsCompType, 3>, CoordsStorageType>& coords,
84  pointNormals,
85  vtkm::cont::ArrayHandle<vtkm::Vec<CellNormalCompType, 3>, CellNormalStorageType>& cellNormals)
86  {
87  OrientPointAndCellNormals::Run(cells, coords, pointNormals, cellNormals);
88  }
89 
91  {
92  template <typename T>
93  VTKM_EXEC_CONT T operator()(const T& val) const
94  {
95  return -val;
96  }
97  };
98 
102  template <typename NormalCompType, typename NormalStorageType>
104  vtkm::cont::ArrayHandle<vtkm::Vec<NormalCompType, 3>, NormalStorageType>& normals)
105  {
106  const auto flippedAlias = vtkm::cont::make_ArrayHandleTransform(normals, NegateFunctor{});
107  vtkm::cont::Algorithm::Copy(flippedAlias, normals);
108  }
109 };
110 }
111 } // end namespace vtkm::worklet
112 
113 
114 #endif // vtkm_m_worklet_OrientNormals_h
vtkm::cont::ArrayHandle
Manages an array-worth of data.
Definition: ArrayHandle.h:283
ArrayHandle.h
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
vtkm::worklet::OrientCellNormals::Run
static VTKM_CONT void Run(const CellSetType &cells, const vtkm::cont::ArrayHandle< vtkm::Vec< CoordsCompType, 3 >, CoordsStorageType > &coords, vtkm::cont::ArrayHandle< vtkm::Vec< CellNormalCompType, 3 >, CellNormalStorageType > &cellNormals)
Definition: OrientCellNormals.h:331
Types.h
VTKM_EXEC_CONT
#define VTKM_EXEC_CONT
Definition: ExportMacros.h:52
vtkm::worklet::OrientNormals::RunCellNormals
static VTKM_CONT void RunCellNormals(const CellSetType &cells, const vtkm::cont::ArrayHandle< vtkm::Vec< CoordsCompType, 3 >, CoordsStorageType > &coords, vtkm::cont::ArrayHandle< vtkm::Vec< CellNormalCompType, 3 >, CellNormalStorageType > &cellNormals)
Definition: OrientNormals.h:51
vtkm::worklet::OrientNormals::NegateFunctor
Definition: OrientNormals.h:90
ArrayHandleTransform.h
vtkm::cont::Algorithm::Copy
static VTKM_CONT bool Copy(vtkm::cont::DeviceAdapterId devId, const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< U, COut > &output)
Definition: Algorithm.h:410
vtkm::worklet::OrientNormals::RunFlipNormals
static VTKM_CONT void RunFlipNormals(vtkm::cont::ArrayHandle< vtkm::Vec< NormalCompType, 3 >, NormalStorageType > &normals)
Reverse the normals to point in the opposite direction.
Definition: OrientNormals.h:103
vtkm::worklet::OrientNormals
Orients normals to point outside of the dataset.
Definition: OrientNormals.h:43
vtkm::cont::make_ArrayHandleTransform
VTKM_CONT vtkm::cont::ArrayHandleTransform< HandleType, FunctorType > make_ArrayHandleTransform(HandleType handle, FunctorType functor)
make_ArrayHandleTransform is convenience function to generate an ArrayHandleTransform.
Definition: ArrayHandleTransform.h:474
Algorithm.h
VTKM_CONT
#define VTKM_CONT
Definition: ExportMacros.h:57
vtkm::worklet::OrientNormals::RunPointAndCellNormals
static VTKM_CONT void RunPointAndCellNormals(const CellSetType &cells, const vtkm::cont::ArrayHandle< vtkm::Vec< CoordsCompType, 3 >, CoordsStorageType > &coords, vtkm::cont::ArrayHandle< vtkm::Vec< PointNormalCompType, 3 >, PointNormalStorageType > &pointNormals, vtkm::cont::ArrayHandle< vtkm::Vec< CellNormalCompType, 3 >, CellNormalStorageType > &cellNormals)
Definition: OrientNormals.h:80
vtkm::worklet::OrientNormals::RunPointNormals
static VTKM_CONT void RunPointNormals(const CellSetType &cells, const vtkm::cont::ArrayHandle< vtkm::Vec< CoordsCompType, 3 >, CoordsStorageType > &coords, vtkm::cont::ArrayHandle< vtkm::Vec< PointNormalCompType, 3 >, PointNormalStorageType > &pointNormals)
Definition: OrientNormals.h:64
vtkm::worklet::OrientNormals::NegateFunctor::operator()
VTKM_EXEC_CONT T operator()(const T &val) const
Definition: OrientNormals.h:93
vtkm::Vec
A short fixed-length array.
Definition: Types.h:767
OrientPointAndCellNormals.h
OrientPointNormals.h
OrientCellNormals.h
vtkm::worklet::OrientPointNormals::Run
static VTKM_CONT void Run(const CellSetType &cells, const vtkm::cont::ArrayHandle< vtkm::Vec< CoordsCompType, 3 >, CoordsStorageType > &coords, vtkm::cont::ArrayHandle< vtkm::Vec< PointNormalCompType, 3 >, PointNormalStorageType > &pointNormals)
Definition: OrientPointNormals.h:269
vtkm::worklet::OrientPointAndCellNormals::Run
static VTKM_CONT void Run(const CellSetType &cells, const vtkm::cont::ArrayHandle< vtkm::Vec< CoordsCompType, 3 >, CoordsStorageType > &coords, vtkm::cont::ArrayHandle< vtkm::Vec< PointNormalCompType, 3 >, PointNormalStorageType > &pointNormals, vtkm::cont::ArrayHandle< vtkm::Vec< CellNormalCompType, 3 >, CellNormalStorageType > &cellNormals)
Definition: OrientPointAndCellNormals.h:306