flexcompute / tidy3d

Fast electromagnetic solver (FDTD) at scale.
https://docs.flexcompute.com/projects/tidy3d/en/latest/
GNU Lesser General Public License v2.1
179 stars 40 forks source link

Add validation and repair for TriangleMesh with inward-facing normals #1976

Closed caseyflex closed 4 days ago

caseyflex commented 6 days ago

A TriangleMesh has its interior defined by the direction of its normals, which should be outward-facing. If a mesh has inward-facing normals, this changes the definition of the interior of the mesh, which may not be desired, and may not be reflected in frontend plotting.

This PR warns the user if this mesh error is detected (such a mesh will have negative volume). It also adds a function that can be easily used to repair the mesh. There may be cases where such a mesh is desired, but this will be rare compared to the case where the mesh accidentally had inward-facing normals.