3D folks, I'm trying to find a good formal definition of "manifold" and "watertight" in relation to meshes.

Most definitions say something like "every edge is connected to exactly two faces", but that would imply that an inside-out mesh, a self-intersecting mesh, or a pair of triangles connected back-to-back (with zero volume) would also be manifold.

Is there a definition somewhere that covers these cases? And what is the difference between "watertight" and "manifold", or are they synonyms?

@nicklockwood In 3d printing, they’re usually synonyms. Self-intersecting or overlapping faces would make a model non-manifold.

https://www.instructables.com/Non-manifolds-Your-Worst-3D-Printing-Nightmare/

Non-manifolds: Your Worst 3D Printing Nightmare

Non-manifolds: Your Worst 3D Printing Nightmare: Objective: Learn what manifolds are, how they affect 3D printing, and how to recognize what type of non-manifold problem may occur. To learn how to fix non-manifolds see: Manual Methods of Fixing Non-manifolds Automatic Methods of Fixing Non-manif…

Instructables

@nicklockwood watertight to me always meant "if you {3D printed it, but this was before we had 3D printers lol} put it in a bathtub, it wouldn't take on water".

Never thought about manifold 🤔 so I guess this reply is generally unhelpful

@brandonscript I have the same general understanding, but it also doesn't really help me, because I'm not sure what happens if you try to 3D print a mesh that is inside out, self-intersecting, or has areas with zero thickness. I suspect it depends on which software you use

@nicklockwood Did a little lookup, the consensus seems to be that "manifold" is the 3D model's idea of no holes, and has a distinct inside and outside. Watertight is the practical implementation of this when that becomes a physical mesh.

Since we're talking about 3D printing – I find that a lot of the software I've tried handle it similarly (probably because most use Klipper anyway?).

Cura, for example, has a ton of settings to explicitly tell it what to do when it encounters ambiguity.

@nicklockwood @keenancrane might have the formal definition handy.

@petersibley @nicklockwood

Yes, not only is it possible to be precise about these definitions, but they become completely standard if you adopt language from mathematics—rather than the ad-hoc definitions from computer vision/graphics/etc., which (as you mention) tends to be quite fragmented.

TL;DR: "watertight" basically means it's the boundary of a solid; "manifold" is more like the thing you said—but requires some refinement. Also, the two aren't quite equivalent—e.g., the boundary of two cubes touching at a single corner isn't manifold, but is watertight.

The most important first step is to clearly separate out two factors:

1. connectivity, and
2. geometry.

As you point out, it's possible to have manifold connectivity even when the geometry has self-intersections, etc. But that's ok—we'll ultimately be able to tease these things apart, if we can have patience for a moment.

Starting just with connectivity, let's assume that our mesh has only triangles. After all, if we have other kinds of polygons, we can always split them into triangles—and the same definitions will apply.

More precisely, when we say "triangle mesh" in computer graphics, the connectivity we're thinking of is almost universally that of a pure abstract simplicial 2-complex:

https://en.wikipedia.org/wiki/Abstract_simplicial_complex

Such a mesh forbids things like two distinct triangles with the same three vertices, or a triangle where one of its edges is glued to another. "Pure" means there are no dangling edges or floating vertices.

@petersibley @nicklockwood

From here, we can say with extreme precision what "manifold" connectivity is. All the following are equivalent:

1. Our simplicial complex is a topological manifold in the usual sense: https://en.wikipedia.org/wiki/Topological_manifold

2. Every edge is contained in either exactly two triangles (interior edge) or exactly one triangle (boundary edge), and every vertex is contained in a single edge-connected loop of triangles (interior vertex) or a single edge-connected path of triangles (boundary vertex).

3. The simplicial link of every vertex is either a closed loop (for interior vertices) or a single path (for boundary vertices): https://en.wikipedia.org/wiki/Simplicial_complex#Closure,_star,_and_link

4. Around every point of our simplicial complex, there exists a neighborhood homeomorphic to a disk (for interior points) or a half disk (for boundary points). "Homeomorphic to" means there is a continuous bijection with continuous inverse: https://en.wikipedia.org/wiki/Homeomorphism

Importantly, we're not yet claiming anything about the geometry—only the connectivity/topology.

Let's move on to geometry next.

Topological manifold - Wikipedia

@petersibley @nicklockwood

When it comes to geometry, "triangle mesh" in computer graphics almost universally means that each triangle in our connectivity (i.e., in our simplicial complex) is realized as an ordinary triangle in 2D or 3D, with three distinct vertices connected by three straight edges. (Or maybe you let some vertices end up in the same place—we'll get there…).

A more precise way to do this is to say that, if V is the set of vertices, then we have a map

  𝐱: V → ℝⁿ

assigning a location to each vertex. We might also say that 𝐱ᵢ is the “vertex coordinate” for vertex i. Suppose our mesh contains a triangle with vertices i, j, k. Then we (almost universally…) extend the vertex coordinates over the triangle via the map

  𝐱(u,v) := u𝐱ᵢ + v𝐱ⱼ + (1−u−v)𝐱ₖ,

for values of u,v in the standard right triangle

  σ := { (u,v) ∈ ℝ² : u+v ≤ 1, u,v ≥ 0 }.

Since neighboring triangles share vertices, these maps agree on edges, and we get a continuous, piecewise linear (or more precisely: piecewise affine) map from the whole mesh M into three-dimensional space ℝⁿ.

Now that we've actually said how the geometry of a triangle mesh is defined, we can be more precise about how it interacts with our definition of “manifold.” In particular, the set 𝐱(M), mapping all of our “abstract” triangles into ℝⁿ, is a 𝘴𝘶𝘣𝘮𝘢𝘯𝘪𝘧𝘰𝘭𝘥 of ℝⁿ if 𝐱 is an 𝘦𝘮𝘣𝘦𝘥𝘥𝘪𝘯𝘨, i.e., a homeomorphism onto its image: https://en.wikipedia.org/wiki/Embedding#General_topology

A more down-to-earth way to say this is: as long as (i) our connectivity is manifold, and (ii) our triangles in 3D intersect only at shared vertices/edges, then the mesh is manifold. That's it!

You could have made sense of this definition without all the pain of defining the map 𝐱 and so on. But defining the map helps us to understand that, as long as we have manifold connectivity, the geometry is still pretty well-defined and easy to reason about per-triangle. For instance, I can still go ahead and compute things like surface area or the distance between two points in a natural way—the self-intersections really don't cause any headaches if I think about things in terms of the underlying manifold connectivity. In particular, as long as 𝐱 is a 𝘭𝘰𝘤𝘢𝘭𝘭𝘺 𝘪𝘯𝘫𝘦𝘤𝘵𝘪𝘷𝘦 map (i.e., it is injective around every point, if we restrict it to a small enough neighborhood), then we can compute pretty much everything under the sun: normals, curvatures, and so on and so forth. The precise mathematical term here is a 𝘴𝘪𝘮𝘱𝘭𝘪𝘤𝘪𝘢𝘭 𝘪𝘮𝘮𝘦𝘳𝘴𝘪𝘰𝘯.

Embedding - Wikipedia

Finally, let's come back to the question of “watertight” vs. “manifold.” Watertight simply means that the triangle mesh is the boundary of some solid region Ω ⊂ ℝ³. Literally, it could hold water (corresponding to the interior of the original solid). That's it. But as the example image in my first reply shows, this boundary can in general violate the definition of a manifold.

By the way, I've run through all of this stuff super fast in these posts—no reason you should be able to immediately swallow it whole!

I go through it at a much nicer pace, with lots of pictures/illustrations, in these videos:

https://www.youtube.com/watch?v=TDic3pJyYb8

https://www.youtube.com/watch?v=KZjoxwUxlIs

https://www.youtube.com/watch?v=sV58Fy2s6ac

https://www.youtube.com/watch?v=FRvhgkGKfSM

https://www.youtube.com/watch?v=8YCfx4hN-7Q

Lecture 2A: What is a "Mesh?" (Discrete Differential Geometry)

YouTube

@keenancrane this is super helpful, thanks so much!

(And yes, it will take me a while to digest probably since I'm not familiar with some of the math terminology and notation 😅)

As a quick tl;dr; are winding order and back/front faces relevant in these definitions? Or is that purely a rendering concern?

@nicklockwood

Winding order is related to the notion of orientability: https://en.wikipedia.org/wiki/Orientability

If the triangles cannot all be put in the same winding order, then the surface is nonorientable (like the Möbius band). But a mesh might also not be consistently oriented, even if it can be (e.g., a mesh of a sphere with one flipped triangle).

The right language for this kind of discussion is the language of oriented complexes: https://en.wikipedia.org/wiki/Simplicial_homology#Orientations

You can also think about this in terms of data structures, e.g., an incidence matrix captures connectivity, whereas a signed incidence matrix captures orientation.

(Lecture 2A and 2B linked above talks through a lot of this.)

Orientability - Wikipedia

@keenancrane thanks for the thoughtful response.