Sub topic 8
Boundary Edges and Closed Surfaces
Assume you know basic 3D coordinates, vectors, cross products, and simple Python. This chapter focuses on how shared edges reveal whether a polygon mesh has an open boundary, a hole, or a non-manifold connection.
What is a boundary edge?
An edge is a boundary edge when exactly one face uses it. The face has no neighboring face across that edge.
A plane patch is an open surface. Its outside border consists of boundary edges. A cube has no boundary edges because every edge belongs to two faces.
An edge used by two faces is usually an interior edge. The faces meet along that edge, so the surface continues through it.
An edge used by more than two faces is non-manifold. Several surface sheets meet at one edge. This structure may be useful in special models, but many modeling, simulation, and slicing tools treat it as invalid.
| Number of faces using an edge | Meaning |
|---|---|
| 0 | The edge is not part of the face set |
| 1 | Boundary edge |
| 2 | Ordinary shared edge |
| More than 2 | Non-manifold edge |
Detecting boundaries by counting faces
In an indexed face set, faces store vertex indices. Each consecutive pair of indices forms an edge, including the pair from the last index back to the first.
The direction of an edge is not important when counting whether it is shared. Therefore, store its two vertex indices in sorted order. This gives the same key for (2, 5) and (5, 2).
from collections import Counter
def edge_usage(faces):
"""Count how many faces use each undirected edge."""
counts = Counter()
for face in faces:
for i, a in enumerate(face):
b = face[(i + 1) % len(face)]
edge = (min(a, b), max(a, b))
counts[edge] += 1
return counts
# Two triangles form one square, so the four outside edges are boundaries.
faces = [
(0, 1, 2),
(0, 2, 3),
]
counts = edge_usage(faces)
boundary = [edge for edge, n in counts.items() if n == 1]
non_manifold = [edge for edge, n in counts.items() if n > 2]
print("boundary:", boundary)
print("non-manifold:", non_manifold)The diagonal (0, 2) is used by both triangles. The other four edges are used once, so they form the square's boundary.
A closed mesh should have no edges with a count of one. It should also have no edges with a count greater than two.
Closed does not always mean valid
A mesh is commonly called closed when every edge belongs to exactly two faces. This condition removes ordinary holes and open borders.
However, edge counting alone cannot prove that the entire surface is a well-formed manifold. A mesh can have two surfaces touching at a single vertex, or it can contain folded or duplicated geometry. Every edge may still have two incident faces while the neighborhood around a vertex is disconnected or otherwise invalid.
A manifold surface has a disk-like neighborhood around each interior vertex. If the surface has a boundary, the neighborhood around a boundary vertex is half-disk-like. Non-manifold vertices and edges break this local structure.
For production geometry, check more than edge counts:
- Look for boundary edges.
- Reject edges used by more than two faces.
- Check that faces meet consistently around each vertex.
- Check face winding so neighboring faces point in compatible directions.
- Remove duplicate faces and zero-area faces.
A closed mesh can also contain several disconnected closed components. That may be valid, but it matters if an application expects one connected object.
Practical interpretation
Boundary edges are useful diagnostics. In a model of a bowl, the rim is intentionally a boundary. In a model intended to represent a solid object, the same boundary may indicate a missing cap.
A hole can be repaired by adding faces, but the new faces must use the existing boundary vertices in the correct order. Their winding should make the new surface normal point consistently with the rest of the object.
In a mesh with consistent winding, each shared edge appears once in one direction and once in the reverse direction. If both faces use the same directed edge, their normals may point inconsistently. This can cause back-face culling, lighting, and solid operations to behave incorrectly.
Exercise
A mesh has 24 unique undirected edges. Three edges are used by one face, one edge is used by three faces, and all remaining edges are used by two faces. Is the mesh a clean closed manifold based on edge counts?
Show answer
No. The three edges used once are boundary edges, and the edge used three times is non-manifold. A clean closed mesh must have every edge used exactly twice.