9 Boundary Representation from Scratch
Before reading a solid, what a solid is. Why the file keeps “what touches what” and “where it is” in separate records, what orientation means and why it is stored three times over, and the arithmetic that checks a shell.
The 150 records of geometry in the block file describe a rectangular box. They do it in a way that seems, at first, absurdly indirect: the box’s eight corners appear as sixteen records, its twelve edges as sixty, and no record anywhere says “box” or gives its dimensions. To see why it is done this way, and why the same scheme scales to a turbine blade, you need the idea the whole of Part 42 is built on.
There are two broad ways to describe a solid object to a computer. Constructive methods describe the operations that made it: a box, minus a cylinder, plus a fillet. Boundary methods describe its skin: the set of surfaces that separate inside from outside. STEP, like every major CAD kernel, exchanges solids as boundary representations — B-rep — because the skin is what two systems can agree on. A system that has no “fillet” operation can still accept a torus patch.
A B-rep has two layers. Geometry is the set of mathematical shapes the skin is made of: this plane, that cylinder, this line, that circle. Planes, cylinders and lines are unbounded; circles, spheres and tori are not. Topology is the description of how finite pieces of them connect: this face is the part of that plane inside this loop; this edge is the part of that line between these two vertices; these six faces together form a closed shell. Geometry says where things are; topology says what touches what.
Keeping them separate is what makes the representation robust. Two faces that share an edge share the same edge record, so there is no question of whether their boundaries coincide to within tolerance — they are the same object. The plane a face lies on can be replaced by a slightly different plane without changing what the face is connected to. And two adjacent faces on the same cylinder can share one cylinder record. Every kernel does this; STEP simply writes the two layers out as two families of entities.
9.1 The topological ladder
Part 42 defines the topology as a strict hierarchy. Each level is bounded by the level below it.
| Level | Entity | Bounded by |
|---|---|---|
| Solid | MANIFOLD_ |
one closed shell (plus optional voids) |
| Shell | CLOSED_, OPEN_ |
a set of faces |
| Face | ADVANCED_ (a FACE_) |
one or more loops (FACE_) |
| Loop | EDGE_, VERTEX_ |
a sequence of oriented edges, or (VERTEX_) one vertex |
| Edge | EDGE_, via ORIENTED_ |
two vertices |
| Vertex | VERTEX_ |
— |
Each topological entity from face down carries one piece of geometry: a face has a surface, an edge has a curve, a vertex has a point. Shells, loops and solids have no geometry of their own; they are pure connectivity.
The block: one solid, one shell, six faces, six loops (one per face), twelve edges, eight vertices. Every face is bounded by exactly one loop because a box has no holes. The bracket of Section 11.5 has top and bottom faces with two loops each — an outer rectangle and an inner circle. That is not the only structural difference a hole makes: it also brings a cylindrical face whose seam edge is traversed twice within one loop, and two circular edges that start and end at the same vertex. The plain count \(V - E + F\) still comes to 2, because the two inner loops cancel the through-hole; it is the corrected count below that reads 0.
9.2 Sharing
The first thing to understand about the connectivity is that it is achieved by reference to the same record, not by coincidence of coordinates.
The block has twelve edges and each edge belongs to two faces. There are therefore twenty-four appearances of edges in loops, but only twelve EDGE_ records. Each appearance is an ORIENTED_ — a thin record that points at an EDGE_ and adds a direction. Two faces that meet along an edge each have an ORIENTED_ pointing at the same EDGE_, one saying “forwards” and the other “backwards.”
Likewise, each vertex of the block is the meeting point of three edges, and all three EDGE_s point at the same VERTEX_. There are eight vertex records, not twenty-four.
This is what makes a B-rep watertight by construction. The question “do these two faces actually meet?” is answered by the graph, not by comparing numbers. Geometry that does not quite line up — a plane that misses its edge’s line by \(10^{-9}\) — does not break connectivity; it is what the uncertainty of Chapter 6 exists to tolerate.
9.3 Orientation
The second thing to understand is that nearly everything in the topology has a direction, and the directions have to agree.
A surface has a normal: the plane through the origin with axis (0, 0, 1) has “up” as its positive side. A face must know which side of its surface is outside the solid. The face record carries a Boolean, same_: .T. if the surface normal already points outward, .F. if the outward normal is the reverse.
A curve has a direction: a line from a point along a vector, a circle counter-clockwise about its axis. An edge is a piece of a curve between two vertices, and EDGE_ carries its own same_: whether the edge runs from its start vertex to its end vertex in the curve’s direction or against it.
A loop is a cycle of edges, and the cycle has a direction: walking it with the outward normal as “up,” the material of the face is on your left. For an outer bound that means counter-clockwise seen from outside; an inner bound, around a hole, runs the other way. Each ORIENTED_ in the loop says whether the edge is to be traversed forwards or backwards to make that true. And each FACE_ carries one more Boolean that can reverse the whole loop.
Three layers of direction on an edge alone — the curve’s, the edge’s, the oriented edge’s — plus one on the face bound and one on the face. The redundancy is deliberate: it lets records be shared. One EDGE_ serves two faces because each face wraps it in its own ORIENTED_; one PLANE can serve two coplanar faces whose normals oppose — a pocket’s floor and an undercut’s ceiling at the same height — because each face has its own same_. The cost is that a reader must compose the flags correctly, and a writer that gets one wrong produces a solid whose faces point inwards — which renders as black, meshes inside-out, and reports a negative volume. This is the most common defect in hand-written or badly converted STEP files.
9.4 Closed and manifold
A CLOSED_ claims that its faces enclose a volume with no gaps. Manifold means, informally, that the surface is everywhere locally like a sheet: every edge is traversed exactly twice by the loops of the shell, once in each direction, and every vertex is surrounded by a single fan of faces. Usually the two traversals belong to two different faces; on a seam they belong to the same face twice. A MANIFOLD_ claims both.
Neither claim is checked by the file format. But there is arithmetic that will catch a badly built one. For a solid of \(S\) shells with \(R\) inner loops and \(H\) through-holes:
\[V - E + F - R = 2(S - H)\]
This is the Euler–Poincaré characteristic, and it is the first thing a validator computes: a shell that fails it is missing an edge, has a duplicated vertex, or was never closed. Passing it proves less than failing it: a count that comes out right says nothing about orientation, self-intersection or whether the geometry actually meets along the shared edges. The familiar short form, \(V - E + F = 2\), is what it becomes for a single shell with no inner loops and no through-holes — the block: eight vertices, twelve edges, six faces, \(8 - 12 + 6 = 2\). Both of those conditions are needed, and neither alone is enough. A box with a blind pocket has no through-hole, but the pocket’s mouth is an inner loop, and its plain count is 3. The torus has one loop on its single face, but it has a through-hole, and its plain count is 0. The bracket, with two inner loops and one through-hole, comes back to 2 by cancellation — which is why the short form is worth running only on a shell you already know is a plain closed skin. Run the general form and you never have to ask.
9.5 What the file does not say
A B-rep in STEP is evaluated geometry. There is no record of how the box was made, no parameters, no features, no dimensions in the engineering sense. (AP242 does define records for construction history and for features such as holes and slots; no mainstream exporter writes them.) The 60, 20 and 10 of the block appear only as point coordinates — in vertices, in line base points, in plane origins — never as a length. If the designer had constrained the block’s length to twice its width, that fact is gone. This is a limitation and a strength: it is why STEP files from any CAD system can be read by any other, and why they cannot be edited the way the original model could. Design intent lives in the CAD system’s native format, or — for tolerances and dimensions specifically — in the PMI of Chapter 16.
A B-rep is a skin described in two layers: geometry (surfaces, curves, points) and topology (finite faces, edges, vertices connected to each other). Connectivity is by shared records, not shared coordinates. Everything has a direction, and the directions must compose to an outward normal with the face’s material on the left of every loop. The general count is \(V - E + F - R = 2(S - H)\); the familiar \(V - E + F = 2\) is its special case, for one shell with no inner loops and no through-holes.