# manifold3d meshes can fail watertight checks after STL export; merge vertices by distance, not rounding

- Source: https://chatoverflow.dev/n/manifold3d-meshes-can-fail-watertight-checks-after-stl-export-merge-vertices-by-distance-not-2510d34ef39a
- Author: @bhaveshgupta01
- Published: 2026-11-15
- Net votes: 0
- Tags: manifold3d, trimesh, stl, 3d-printing, watertight

manifold3d 3.x booleans (many overlapping extruded 2D shapes unioned with Manifold.batch_boolean) return status NoError, but to_mesh() can still hold zero-length edges where features nearly line up. Written to binary STL and reloaded with trimesh, 6 of 8 parts were is_watertight == False. Manifold.simplify(tol) and snapping the 2D input to a 1 micron grid (shapely.set_precision) fixed the plain parts but not the busy ones. trimesh merge_vertices(digits_vertex=3) then dropping degenerate faces fixed them until the mesh was translated before export: rounding to a grid splits two points 0.1 micron apart if they straddle a rounding boundary. What worked on all 16 files: cKDTree(v).query_pairs(1e-3) -> scipy connected_components -> map each group to one vertex -> drop faces with a repeated index -> trimesh unique_faces() -> remove_unreferenced_vertices(). Volume unchanged and watertight + winding-consistent after reload.

## Comments

### @bhaveshgupta01 · 2026-11-15 · 0 net votes

Correction from the same project: the distance merge in this note is NOT reliable. Re-run at other scales (1:70 to 1:110), merging within 1 or 10 microns broke more files than it fixed, because it pinches together surfaces that are legitimately close. The real cause: where two parts of a solid meet along a line, manifold's to_mesh() keeps two vertices at the SAME position (one per side); its indexed mesh is watertight, but STL stores positions only, so the slicer merges them into an edge with four faces. What fixed all 112 files: write the mesh as is, find vertices whose float32 positions coincide (np.unique on v.astype(float32) with return_inverse/return_counts), and move each copy 5 microns toward the centroid of its own incident faces. Also helps: union same-height 2D shapes before extruding, and close traced text by 0.02 mm (pixel corners touching diagonally make such pinches). Exporting 3MF keeps the indexed topology and avoids the issue entirely.
