20 #ifndef vtk_m_worklet_cellmetrics_CellEdgeRatioMetric_h
21 #define vtk_m_worklet_cellmetrics_CellEdgeRatioMetric_h
45 #define UNUSED(expr) (void)(expr);
57 template <
typename OutType,
typename VecType>
60 const vtkm::Id numEdges = edges.GetNumberOfComponents();
66 FloatType currLen, minLen = e0Len, maxLen = e0Len;
67 for (
int i = 1; i < numEdges; i++)
76 if (minLen < vtkm::NegativeInfinity<FloatType>())
77 return vtkm::Infinity<OutType>();
80 OutType edgeRatio = (OutType)
vtkm::Sqrt(maxLen / minLen);
82 return vtkm::Min(edgeRatio, vtkm::Infinity<OutType>());
84 return vtkm::Max(edgeRatio, OutType(-1) * vtkm::Infinity<OutType>());
91 template <
typename OutType,
typename Po
intCoordVecType,
typename CellShapeType>
93 const PointCoordVecType& pts,
109 template <
typename OutType,
typename Po
intCoordVecType>
111 const PointCoordVecType& pts,
112 vtkm::CellShapeTagLine,
129 template <
typename OutType,
typename Po
intCoordVecType>
131 const PointCoordVecType& pts,
132 vtkm::CellShapeTagTriangle,
144 using Edge =
typename PointCoordVecType::ComponentType;
145 const Edge TriEdges[3] = { pts[1] - pts[0], pts[2] - pts[1], pts[0] - pts[2] };
146 return vtkm::worklet::cellmetrics::ComputeEdgeRatio<OutType>(vtkm::make_VecC(TriEdges, numEdges));
155 template <
typename OutType,
typename Po
intCoordVecType>
157 const PointCoordVecType& pts,
158 vtkm::CellShapeTagQuad,
170 using Edge =
typename PointCoordVecType::ComponentType;
171 const Edge QuadEdges[4] = { pts[1] - pts[0], pts[2] - pts[1], pts[3] - pts[2], pts[0] - pts[3] };
173 return vtkm::worklet::cellmetrics::ComputeEdgeRatio<OutType>(
174 vtkm::make_VecC(QuadEdges, numEdges));
186 template <
typename OutType,
typename Po
intCoordVecType>
188 const PointCoordVecType& pts,
189 vtkm::CellShapeTagTetra,
201 using Edge =
typename PointCoordVecType::ComponentType;
202 const Edge TetEdges[6] = { pts[1] - pts[0], pts[2] - pts[1], pts[0] - pts[2],
203 pts[3] - pts[0], pts[3] - pts[1], pts[3] - pts[2] };
205 return vtkm::worklet::cellmetrics::ComputeEdgeRatio<OutType>(vtkm::make_VecC(TetEdges, numEdges));
213 template <
typename OutType,
typename Po
intCoordVecType>
215 const PointCoordVecType& pts,
216 vtkm::CellShapeTagHexahedron,
228 using Edge =
typename PointCoordVecType::ComponentType;
229 const Edge HexEdges[12] = { pts[1] - pts[0], pts[2] - pts[1], pts[3] - pts[2], pts[0] - pts[3],
230 pts[5] - pts[4], pts[6] - pts[5], pts[7] - pts[6], pts[4] - pts[7],
231 pts[4] - pts[0], pts[5] - pts[1], pts[6] - pts[2], pts[7] - pts[3] };
233 return vtkm::worklet::cellmetrics::ComputeEdgeRatio<OutType>(vtkm::make_VecC(HexEdges, numEdges));
241 template <
typename OutType,
typename Po
intCoordVecType>
243 const PointCoordVecType& pts,
244 vtkm::CellShapeTagWedge,
256 using Edge =
typename PointCoordVecType::ComponentType;
257 const Edge WedgeEdges[9] = { pts[1] - pts[0], pts[2] - pts[1], pts[0] - pts[2],
258 pts[4] - pts[3], pts[5] - pts[4], pts[3] - pts[5],
259 pts[3] - pts[0], pts[4] - pts[1], pts[5] - pts[2] };
261 return vtkm::worklet::cellmetrics::ComputeEdgeRatio<OutType>(
262 vtkm::make_VecC(WedgeEdges, numEdges));
270 template <
typename OutType,
typename Po
intCoordVecType>
272 const PointCoordVecType& pts,
273 vtkm::CellShapeTagPyramid,
285 using Edge =
typename PointCoordVecType::ComponentType;
286 const Edge PyramidEdges[8] = {
287 pts[1] - pts[0], pts[2] - pts[1], pts[2] - pts[3], pts[3] - pts[0],
288 pts[4] - pts[0], pts[4] - pts[1], pts[4] - pts[2], pts[4] - pts[3]
291 return vtkm::worklet::cellmetrics::ComputeEdgeRatio<OutType>(
292 vtkm::make_VecC(PyramidEdges, numEdges));
301 #endif // vtk_m_worklet_cellmetrics_CellEdgeRatioMetric_h