20 #ifndef vtk_m_worklet_cellmetrics_Min_Diagonal_h
21 #define vtk_m_worklet_cellmetrics_Min_Diagonal_h
42 #define UNUSED(expr) (void)(expr);
53 template <
typename OutType,
typename Po
intCoordVecType,
typename CellShapeType>
55 const PointCoordVecType& pts,
65 template <
typename OutType,
typename Po
intCoordVecType>
67 const PointCoordVecType& pts,
68 vtkm::CellShapeTagHexahedron,
77 using Scalar = OutType;
79 Scalar temp[3], diag[4];
83 for (i = 0; i < 3; i++)
85 temp[i] =
static_cast<Scalar
>(pts[6][i] - pts[0][i]);
86 temp[i] = temp[i] * temp[i];
88 diag[0] =
vtkm::Sqrt(temp[0] + temp[1] + temp[2]);
90 for (i = 0; i < 3; i++)
92 temp[i] =
static_cast<Scalar
>(pts[4][i] - pts[2][i]);
93 temp[i] = temp[i] * temp[i];
95 diag[1] =
vtkm::Sqrt(temp[0] + temp[1] + temp[2]);
97 for (i = 0; i < 3; i++)
99 temp[i] =
static_cast<Scalar
>(pts[7][i] - pts[1][i]);
100 temp[i] = temp[i] * temp[i];
102 diag[2] =
vtkm::Sqrt(temp[0] + temp[1] + temp[2]);
104 for (i = 0; i < 3; i++)
106 temp[i] =
static_cast<Scalar
>(pts[5][i] - pts[3][i]);
107 temp[i] = temp[i] * temp[i];
109 diag[3] =
vtkm::Sqrt(temp[0] + temp[1] + temp[2]);
111 Scalar diagonal = diag[0];
113 for (i = 1; i < 4; i++)
115 diagonal = vtkm::Min(diagonal, diag[i]);
117 return Scalar(diagonal);