//============================================================================ // 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. // // Copyright 2019 National Technology & Engineering Solutions of Sandia, LLC (NTESS). // Copyright 2019 UT-Battelle, LLC. // Copyright 2019 Los Alamos National Security. // // Under the terms of Contract DE-NA0003525 with NTESS, // the U.S. Government retains certain rights in this software. // // Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National // Laboratory (LANL), the U.S. Government retains certain rights in // this software. //============================================================================ #ifndef vtkm_m_worklet_OrientNormals_h #define vtkm_m_worklet_OrientNormals_h #include #include #include #include #include #include #include namespace vtkm { namespace worklet { /// /// Orients normals to point outside of the dataset. This requires a closed /// manifold surface or else the behavior is undefined. This requires an /// unstructured cellset as input. /// class OrientNormals { public: template VTKM_CONT static void RunCellNormals( const CellSetType& cells, const vtkm::cont::ArrayHandle, CoordsStorageType>& coords, vtkm::cont::ArrayHandle, CellNormalStorageType>& cellNormals) { OrientCellNormals::Run(cells, coords, cellNormals); } template VTKM_CONT static void RunPointNormals( const CellSetType& cells, const vtkm::cont::ArrayHandle, CoordsStorageType>& coords, vtkm::cont::ArrayHandle, PointNormalStorageType>& pointNormals) { OrientPointNormals::Run(cells, coords, pointNormals); } template VTKM_CONT static void RunPointAndCellNormals( const CellSetType& cells, const vtkm::cont::ArrayHandle, CoordsStorageType>& coords, vtkm::cont::ArrayHandle, PointNormalStorageType>& pointNormals, vtkm::cont::ArrayHandle, CellNormalStorageType>& cellNormals) { OrientPointAndCellNormals::Run(cells, coords, pointNormals, cellNormals); } struct NegateFunctor { template VTKM_EXEC_CONT T operator()(const T& val) const { return -val; } }; /// /// Reverse the normals to point in the opposite direction. /// template VTKM_CONT static void RunFlipNormals( vtkm::cont::ArrayHandle, NormalStorageType>& normals) { const auto flippedAlias = vtkm::cont::make_ArrayHandleTransform(normals, NegateFunctor{}); vtkm::cont::Algorithm::Copy(flippedAlias, normals); } }; } } // end namespace vtkm::worklet #endif // vtkm_m_worklet_OrientNormals_h