File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -569,6 +569,32 @@ bool isLayerElementOk(Mesh* m, Entity* e)
569569 return isPyramidOk (m, e);
570570 if (type == apf::Mesh::PRISM)
571571 return isPrismOk (m, e);
572+ if (type == apf::Mesh::QUAD) {
573+ // Check if quad is non-degenerate without assuming a specific embedding.
574+ // The quad is considered valid if its two sub-triangles have non-zero area
575+ // and consistent orientation.
576+
577+ Entity* v[4 ];
578+ m->getDownward (e, 0 , v);
579+ Vector p[4 ];
580+ for (int i = 0 ; i < 4 ; ++i)
581+ m->getPoint (v[i], 0 , p[i]);
582+
583+ // Form two triangles sharing a diagonal
584+ Vector n1 = apf::cross (p[1 ] - p[0 ], p[2 ] - p[0 ]);
585+ Vector n2 = apf::cross (p[2 ] - p[0 ], p[3 ] - p[0 ]);
586+
587+ double a1 = n1.getLength ();
588+ double a2 = n2.getLength ();
589+
590+ // Reject degenerate triangles
591+ const double eps = 1e-14 ;
592+ if (a1 < eps || a2 < eps)
593+ return false ;
594+
595+ // Check consistent orientation (normals point in the same general direction)
596+ return (n1 * n2) > eps * a1 * a2;
597+ }
572598 abort ();
573599 return false ;
574600}
You can’t perform that action at this time.
0 commit comments