vtk-m/vtkm/exec/CellInside.h

63 lines
1.7 KiB
C
Raw Normal View History

//============================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt for details.
2019-04-15 23:24:21 +00:00
//
// 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_CellInside_h
#define vtk_m_exec_CellInside_h
#include <vtkm/CellShape.h>
#include <vtkm/Types.h>
2019-10-07 19:38:36 +00:00
#include <lcl/lcl.h>
2019-09-25 01:22:10 +00:00
namespace vtkm
{
namespace exec
{
2019-09-25 01:22:10 +00:00
template <typename T, typename CellShapeTag>
static inline VTKM_EXEC bool CellInside(const vtkm::Vec<T, 3>& pcoords, CellShapeTag)
{
2019-09-25 01:22:10 +00:00
using VtkcTagType = typename vtkm::internal::CellShapeTagVtkmToVtkc<CellShapeTag>::Type;
2019-10-07 19:38:36 +00:00
return lcl::cellInside(VtkcTagType{}, pcoords);
}
template <typename T>
2019-09-25 01:22:10 +00:00
static inline VTKM_EXEC bool CellInside(const vtkm::Vec<T, 3>&, vtkm::CellShapeTagEmpty)
{
2019-09-25 01:22:10 +00:00
return false;
}
2019-05-17 17:35:35 +00:00
template <typename T>
static inline VTKM_EXEC bool CellInside(const vtkm::Vec<T, 3>& pcoords, vtkm::CellShapeTagPolyLine)
{
return pcoords[0] >= T(0) && pcoords[0] <= T(1);
}
/// Checks if the parametric coordinates `pcoords` are on the inside for the
/// specified cell type.
///
template <typename T>
static inline VTKM_EXEC bool CellInside(const vtkm::Vec<T, 3>& pcoords,
vtkm::CellShapeTagGeneric shape)
{
bool result = false;
switch (shape.Id)
{
vtkmGenericCellShapeMacro(result = CellInside(pcoords, CellShapeTag()));
default:
break;
}
return result;
}
}
} // vtkm::exec
#endif // vtk_m_exec_CellInside_h