20 #ifndef vtk_m_worklet_cellmetrics_CellMaxAngleMetric_h 
   21 #define vtk_m_worklet_cellmetrics_CellMaxAngleMetric_h 
   42 #define UNUSED(expr) (void)(expr); 
   53 template <
typename OutType, 
typename Po
intCoordVecType, 
typename CellShapeType>
 
   55                                      const PointCoordVecType& pts,
 
   74 template <
typename OutType, 
typename Po
intCoordVecType>
 
   76                                      const PointCoordVecType& pts,
 
   77                                      vtkm::CellShapeTagTriangle,
 
   86   using Scalar = OutType;
 
   87   using CollectionOfPoints = PointCoordVecType;
 
   88   using Vector = 
typename PointCoordVecType::ComponentType;
 
   90   const Scalar l0 = GetTriangleL0Magnitude<Scalar, Vector, CollectionOfPoints>(pts);
 
   91   const Scalar l1 = GetTriangleL1Magnitude<Scalar, Vector, CollectionOfPoints>(pts);
 
   92   const Scalar l2 = GetTriangleL2Magnitude<Scalar, Vector, CollectionOfPoints>(pts);
 
   94   if (l0 <= Scalar(0.0) || l1 <= Scalar(0.0) || l2 <= Scalar(0.0))
 
   99   const Scalar oneEightyOverPi = (Scalar)57.2957795131;
 
  100   const Scalar two(2.0);
 
  101   const Scalar q0 = 
vtkm::ACos(((l1 * l1) + (l2 * l2) - (l0 * l0)) / (two * l1 * l2));
 
  102   const Scalar q1 = 
vtkm::ACos(((l2 * l2) + (l0 * l0) - (l1 * l1)) / (two * l2 * l0));
 
  103   const Scalar q2 = 
vtkm::ACos(((l0 * l0) + (l1 * l1) - (l2 * l2)) / (two * l0 * l1));
 
  105   const Scalar q = vtkm::Max(q0, vtkm::Max(q1, q2));
 
  107   const Scalar qInDegrees = q * oneEightyOverPi;
 
  120 template <
typename OutType, 
typename Po
intCoordVecType>
 
  122                                      const PointCoordVecType& pts,
 
  123                                      vtkm::CellShapeTagQuad,
 
  132   using Scalar = OutType;
 
  133   using CollectionOfPoints = PointCoordVecType;
 
  134   using Vector = 
typename PointCoordVecType::ComponentType;
 
  136   const Scalar l0 = GetQuadL0Magnitude<Scalar, Vector, CollectionOfPoints>(pts);
 
  137   const Scalar l1 = GetQuadL1Magnitude<Scalar, Vector, CollectionOfPoints>(pts);
 
  138   const Scalar l2 = GetQuadL2Magnitude<Scalar, Vector, CollectionOfPoints>(pts);
 
  139   const Scalar l3 = GetQuadL3Magnitude<Scalar, Vector, CollectionOfPoints>(pts);
 
  141   if (l0 <= Scalar(0.0) || l1 <= Scalar(0.0) || l2 <= Scalar(0.0) || l3 <= Scalar(0.0))
 
  146   const Scalar alpha0 = GetQuadAlpha0<Scalar, Vector, CollectionOfPoints>(pts);
 
  147   const Scalar alpha1 = GetQuadAlpha1<Scalar, Vector, CollectionOfPoints>(pts);
 
  148   const Scalar alpha2 = GetQuadAlpha2<Scalar, Vector, CollectionOfPoints>(pts);
 
  149   const Scalar alpha3 = GetQuadAlpha3<Scalar, Vector, CollectionOfPoints>(pts);
 
  151   const Scalar s0 = alpha0 < Scalar(0.0) ? Scalar(1.0) : Scalar(0.0);
 
  152   const Scalar s1 = alpha1 < Scalar(0.0) ? Scalar(1.0) : Scalar(0.0);
 
  153   const Scalar s2 = alpha2 < Scalar(0.0) ? Scalar(1.0) : Scalar(0.0);
 
  154   const Scalar s3 = alpha3 < Scalar(0.0) ? Scalar(1.0) : Scalar(0.0);
 
  156   const Vector L0 = GetQuadL0<Scalar, Vector, CollectionOfPoints>(pts);
 
  157   const Vector L1 = GetQuadL1<Scalar, Vector, CollectionOfPoints>(pts);
 
  158   const Vector L2 = GetQuadL2<Scalar, Vector, CollectionOfPoints>(pts);
 
  159   const Vector L3 = GetQuadL3<Scalar, Vector, CollectionOfPoints>(pts);
 
  163   const Scalar neg1(-1.0);
 
  164   const Scalar oneEightyOverPi = (Scalar)57.2957795131; 
 
  165   const Scalar threeSixty(360.0);
 
  167     (vtkm::Pow(neg1, s0) * 
vtkm::ACos(neg1 * (
static_cast<Scalar
>(vtkm::Dot(L0, L1)) / (l0 * l1))) *
 
  171     (vtkm::Pow(neg1, s1) * 
vtkm::ACos(neg1 * (
static_cast<Scalar
>(vtkm::Dot(L1, L2)) / (l1 * l2))) *
 
  175     (vtkm::Pow(neg1, s2) * 
vtkm::ACos(neg1 * (
static_cast<Scalar
>(vtkm::Dot(L2, L3)) / (l2 * l3))) *
 
  179     (vtkm::Pow(neg1, s3) * 
vtkm::ACos(neg1 * (
static_cast<Scalar
>(vtkm::Dot(L3, L0)) / (l3 * l0))) *
 
  183   const Scalar q = vtkm::Max(q0, vtkm::Max(q1, vtkm::Max(q2, q3)));
 
  189 #endif // vtk_m_worklet_cellmetrics_CellMaxAngleMetric_h