I'm looking for a way to offset a TIN (triangulated irregular network) mesh (e.g. of a landscape) by a consistent distance via a Python script. In the past I've called Blender's Solidify modifier via the API, which works well, but I'd like to find an alternative that doesn't require Blender as a dependency.
Currently, I'm iterating over each triangle, making a copy of each vertex and moving these along their parent triangle's surface normal by a set distance. Where the same vertex appears in multiple triangles I calculate the offset for each normal and use the mean. Then I connect the vertices together again to make an offset mesh.
This seems to work ok for small offsets, but sharp features in the mesh can create self-intersections.
Is there a specific algorithm or library which offers a better way?
So far, apart from Blender, I've found:
- A CGAL plugin via this discussion
- Thickening, a C++ library
- OffsetMesh, a Three.js demo
But I haven't found much for Python e.g. in Open3D or Trimesh.