Skip to content

CAD kernel foundations · Part eleven

How Boolean operations work on B-rep models

The textbook Boolean algorithm has five steps. A kernel that works on imported CAD data needs a large amount of machinery around those steps, and none of it is optional. In this article we go through what each step has to do, the two schools that solved the problem in different ways, and why a correct implementation still fails.

Boolean operations on B-rep models

When we ask a modeller to cut a hole in a plate, the operation looks like a single step. Below the API call, the kernel has to find every place where the two boundaries touch, cut both boundaries along those places, work out which of the resulting pieces lie inside which shape, discard the pieces the operation does not need, and assemble the rest into a valid solid. All of this is done in floating-point arithmetic, on surfaces that were probably created in another system and imported through STEP.

The classical description of that process fits on one slide, but every kernel that implements it is tens of thousands of lines long. The extra code handles all the ways in which real geometry differs from the geometry on the slide.

In this article we look at the problem: the classical algorithm, where it came from, what it assumes, and what each of its five steps turns into when we try to compute it. None of this belongs to a particular kernel; it applies to anyone who does this in floating point.

About this series

This is one article in CAD Kernel Foundations, a series on what is inside a CAD kernel, from the bottom up: the data structures that hold topology and geometry, the rules that make a shape valid, and then the modelling algorithms built on them. Booleans are the first algorithm we cover at length, because much of the rest (splitting, sectioning, defeaturing, volume-making, imprinting) uses the same machinery with a different rule applied at the end.

It assumes you know what a B-rep is: vertex, edge, wire, face, shell, solid, and the separation between topology and the geometry it points at. Part one covers this if you want to read it first. It does not assume you have read the source of any kernel.

The classical five-step algorithm

Every textbook account of B-rep Booleans, from 2D profile clipping up to 3D solids, follows the same steps. Let’s go through them on an example: A is an L-shaped bracket profile, and B is a disc placed over its re-entrant corner. Their boundaries cross at four points.

01

Two profiles

AB

02

Find intersections, break curves

03

Classify every segment

04

Keep, delete, assemble

argument / object tool new geometry from intersection
  1. Identify intersections. Compute every point (2D) or curve (3D) where the boundaries of A and B meet.
  2. Break into segments or faces. Split the original geometry at those intersections, so that no piece crosses a boundary of the other shape.
  3. Classify regions. Sort each disjoint piece into one of four groups: A outside B, A inside B, B outside A, B inside A. The usual method is ray firing: shoot a ray from a point on the piece and look at how it meets the boundary of the other shape. The form everyone learns counts the crossings and takes the parity (odd means inside). That form does not work when the shapes touch. The form that does reads only the nearest crossing and checks whether the boundary there is entering or leaving. Part seven compares the two.
  4. Keep or delete. Select groups according to the operation.
  5. Sew. Join the remaining pieces into a new closed boundary.

A outside B

Two disjoint runs of the bracket’s boundary.

A inside B

The corner, and a broad run along the base.

B inside A

The arcs inside the bracket.

B outside A

The arc through the notch, and the arc below the base.

Step 3 in full. Four crossings cut each boundary into four pieces, and each piece goes into exactly one group. No group is a single connected curve. This is normal, and it is why the final step is an assembly problem and not a trace along one curve.

Union  A ∪ B

Keeps A out B · B out A

Intersection  A ∩ B

Keeps A in B · B in A

Difference  A − B

Keeps A out B · B in A

Each result is assembled from pieces of both original boundaries: teal where the curve came from A, ochre where it came from B. In the difference, removing the disc cuts the bracket in two, so a correct implementation has to detect that the result is two solids and not one.
OperationA out BA in BB in AB out A
Union  A ∪ BKeepDeleteDeleteKeep
Intersection  A ∩ BDeleteKeepKeepDelete
Difference  A − BKeepDeleteKeepDelete

As a specification of what a Boolean produces, this is correct, and the output of a working kernel satisfies it. As a description of how to produce it, each step carries an assumption that imported CAD data often breaks.

The five steps in 3D

If we take the example up one dimension, the method stays the same and only the things being cut change. The bracket profile becomes a plate, and the disc becomes a cylinder passing through it. In 2D we cut curves at points; in 3D we cut shells along curves.

The two solids

AB

An L-shaped plate and a cylinder through its re-entrant corner.

The section

The four crossing points become two closed loops, each made of two arcs and two vertical edges.

Step 1 in 3D. The section between two solids is a set of closed loops, and finding how many loops there are is part of the problem.

Step 2 needs new terms. Cutting a 2D boundary at a point gives two segments; cutting a 3D shell along a closed loop gives two shell regions, connected patches of surface that lie entirely inside or entirely outside the other solid. Every face that a loop passes through is split, and the fragments are then grouped by connectivity.

Let’s count the regions on each side:

A outside B

Two regions: the cylinder cuts the plate in two.

A inside B

One region around the corner.

B inside A

Two bands, one per section loop.

B outside A

One region: the parts above and below the plate keep it connected.

Six disjoint shell regions from two solids. The classical description does not give this number; it comes from the geometry, and an implementation has to compute it.

The counts differ between the two sides. A outside B has two pieces because the cylinder cuts through the plate at the corner. B outside A has one piece because the cylinder walls above and below the plate keep it connected all the way round. The same cut gives a different number of regions on each side, so neither count can be hard-coded.

In 2DIn 3D
The section isA set of pointsA set of closed loops
What gets cutBoundary curvesBoundary shells
A piece isA segment of curveA connected region of surface
Reassembly meansChaining segments into loopsChaining regions into closed shells, then deciding which shell encloses which

The last row is where 3D gets harder. In 2D we can trace the remaining segments end to end and we are done. In 3D the remaining regions have to be joined into closed shells, and then those shells have to be sorted into outer boundaries and cavities before we know which solid we have built. Sorting shells into those that bound material and those that bound a void is a separate algorithm, and every kernel needs one. We come back to it in step 5.

Union  A ∪ B

Keeps A out B · B out A. One solid.

Intersection  A ∩ B

Keeps A in B · B in A. One solid.

Difference  A − B

Keeps A out B · B in A. Two solids.

The same keep/delete table drives all three results, and they differ in the number of solids as well as in shape. The union and the intersection each give one solid. Subtracting the cylinder cuts the plate in two, so the difference is two solids, as in the 2D difference. The five-step description does not prepare us for this.

Pieces on the boundary: IN, OUT and ON

So far every classification has had two answers: a piece of boundary lies inside the other solid, or outside it. This is enough for the examples above because the operands meet transversally: they cross, and nothing lies flat against anything. If we slide the cylinder until its wall is flush with the side of the plate, or place one block on top of another, the shared boundary is neither inside nor outside. It is on the other boundary. This happens in ordinary assemblies, and the four-group table has no entry for it.

With this third relation on each side, we get six regions instead of four. This is Mäntylä’s classification, and it is the one implementations use. Let’s look at the simplest example that has all six: two rectangles that overlap and share part of their top and bottom edges.

ABA OUT B

The left edge and the two runs beyond B.

ABA IN B

One edge, strictly inside B.

ABA ON B

The two runs where ∂A and ∂B are the same curve.

ABB OUT A

The right edge and the two runs beyond A.

ABB IN A

One edge, strictly inside A.

ABB ON A

The same two runs, B’s copy of them.

Six regions from two operands. The first two columns are the usual inside/outside split; the third is the one the classical table leaves out. A ON B and B ON A occupy the same points in space: they are two representations of the same curve, one from each operand, and the algorithm has to decide which copy to keep.

The keep/delete table from the five-step description then has two more columns:

OperationA out BA in BA on BB on AB in AB out A
Union  A ∪ BKeepDeleteKeepDeleteDeleteKeep
Intersection  A ∩ BDeleteKeepKeepDeleteKeepDelete
Difference  A − BKeepDeleteDeleteDeleteKeep, reversedDelete

Let’s check it against the figure. The union of the two rectangles is one wide rectangle: the left edge comes from A OUT B, the right edge from B OUT A, and the top and bottom runs across the middle from A ON B. The intersection is the narrow overlap: the left edge comes from B IN A, the right edge from A IN B, and the top and bottom again from the ON group. The same ON pieces are needed in both results.

The two ON columns are never both kept. A ON B and B ON A are the same points in space, contributed once by each operand, so keeping both would give the result two coincident copies of every shared face. One copy is kept and the other is discarded. The groups cannot tell us which one, because the two candidates have the same position, the same extent and the same tolerance. We explain why in the section on the ON state, after the steps have been opened up.

Two schools: Rochester and Cambridge

The description above is, almost line for line, the boundary-evaluation algorithm that Aristides Requicha and Herbert Voelcker published from the University of Rochester’s Production Automation Project, and implemented in the PADL systems in the early 1970s. PADL was the first solid modeller shown to handle objects with overlapping boundaries correctly. Two of its terms are useful, because the distinction they make applies whatever name a given kernel uses:

  • Self-edges: edges that were already present in A or B, now cut into pieces.
  • Cross-edges: edges that exist only because two faces intersected. They have to be created from scratch, and most of the work goes into them.

Here is Requicha’s scheme, reduced to its control flow:

Generate_Tentative_Edges(A, B);
for each edge E do
{
  EwrtS = Classify_wrt_Solid(E, S);   // against the *result* solid
  Add_to_BRep(EonS);                  // commit it immediately
}

Classify an edge, add it to the output, move to the next one. The classification comes from a transition (how membership changes as a point travels along the curve and crosses a face), and the result is built incrementally, one edge at a time. We call this the Rochester scheme.

The second tradition is the BUILD system and its descendants: the Cambridge lineage, through Braid and Stroud, and from there into GPM and most probably ACIS. It inverts the loop:

Rochester (PADL)Cambridge (BUILD)
Shape of the loopclassify → build → classify → buildclassify everything → then build
Driven bytransition along each edgemembership of every piece
Knows the operationfrom the start (it classifies against S)only at the end

This framing comes from Slyadnev and Kurnev, in a technical memo on one kernel’s Booleans, but the distinction is general, and the inversion has a consequence in any kernel that takes the Cambridge route. If we classify everything before we know the operation, the decomposition we build cannot depend on the operation: it is the complete cell complex of all the arguments against one another. That one complex then answers union, intersection, difference and the rest by selection, with no recomputation. It is expensive to build once and nearly free to query, which is the opposite trade-off to Rochester.

Specification and method

The question “does kernel X follow the five steps?” has no clear answer, because the five steps are one school’s method and not the definition of the problem. A kernel can meet the same specification with a different method. The useful question is which steps it keeps, which it inverts, and what each difference protects against.

The two conditions of the method

Both schools, whatever the shape of their loop, rely on the same two assumptions. Stroud states them at the start of the BUILD-lineage algorithm. They are the reason the method works, and also the reason it cannot handle certain inputs.

“The condition that there are no completely new boundary portions is necessary because the algorithm builds the result object or objects from portions of the boundaries of the two original objects. There are no completely new parts, except for new edges where part of the boundary of one object cuts through the boundary of the other…”

I. Stroud, Boundary Representation Modelling Techniques, §6.1

Condition 1: a Boolean creates no new boundary

Written as a containment, for any operation ⊛ and any operands:

∂(A ⊛ B)  ⊆  ∂A ∪ ∂B

The section edges look like a counterexample, but they are not. A face/face intersection curve is new topology (there was no edge there before), but every point on it already lay on ∂A and on ∂B, so it was already in the right-hand side. Every point of the result lies on one of the two input boundaries.

This is the strongest structural fact in the subject, and we can build on it directly. It means we can compute the right-hand side in full, once, without knowing which operation was asked for, and then obtain any operation by deleting from it. At least one production kernel is built on exactly this.

Condition 2: the operands are manifold

The second condition is not a numerical requirement. It says that some answers are not determined by the representation itself. There are three standard cases:

  • An infinitely thin piece of boundary (two faces back to back) can be kept or deleted, and both readings are defensible.
  • Two solids that touch along an edge and are added: the result may be one object with a non-manifold edge, or two objects. Nothing in the inputs prefers either.
  • The same, at a single vertex.

More precision does not resolve these cases, because the question is about what the model is for, not about where the geometry is. An implementation has to choose a convention, document it, and apply it. This is also why a Boolean can be formally correct and still useless in practice, as we see with step 4 below.

Where real CAD data breaks the steps

Let’s take the steps one at a time and look at what each one assumes. Four of the five rest on something real CAD data does not provide.

Step 2 assumes the split is exact

Two NURBS surfaces do not intersect in a curve we can write down. They intersect in an approximated curve that carries a tolerance, and the split it produces is only nearly clean. A vertex that should lie exactly on an edge lies 3×10−7 away from it. Whether that counts as “on” is a decision, and every later step depends on it.

Step 3 assumes parity works

Counting ray crossings is valid only for a closed, well-oriented, manifold shell. Booleans are often asked to classify against solids with internal faces, open shells, and boundaries that touch themselves. On those inputs parity does not raise an error; it returns a wrong answer.

Step 4 can return a result of the wrong dimension

If we apply the keep/delete table literally to two blocks that only touch along a face, the intersection is that shared face: a solid operation on two solids that returns a surface. This is formally correct, since those are the common points, but it is useless for engineering, because an infinitely thin plate cannot be manufactured. Requicha’s answer was to define CAD Booleans as regularised operations, written ∪*, ∩* and \*, which take the closure of the interior of the result and so can never reduce its dimension. The five steps as usually stated do not mention this, and nothing in the four-group table enforces it.

Declaring the operations regularised is easy; implementing them is harder. Regularisation assumes we can tell a solid region from a dangling one, and tolerance removes exactly that distinction. If the envelopes of two edges overlap across the whole thickness of a thin plate, then for the tolerant arithmetic the plate is a face. The regularisation step then has nothing to remove, because there is no interior left to take the closure of. Dangling faces in the output of a Cut are the usual symptom, and they do not mean that the step was skipped.

Step 5 assumes sewing is safe

Sewing matches boundary pieces by proximity within a tolerance. Doing this at the end of a Boolean throws away the exact structural information the earlier steps worked to establish, and replaces it with a guess.

Summary

Steps 2 to 5 each rely on something imported geometry does not provide. Step 1 (“find where the boundaries meet”) looks safe, but it is the step that grows the most, and the next three sections describe what it involves.

Step 1: the six interference types, each with two outcomes

Before looking at any implementation, let’s set out what an implementation has to deal with, because most of the difficulty lies between “find where the boundaries meet” and a working intersection stage.

First we need to state an assumption. Part one ended on four questions the theory cannot settle, and the third was where the tolerance is stored: on the entity, on the model, or on the operation. This section assumes the first answer: every entity carries its own tolerance. Most kernels make this choice, and it decides which imported data they can accept at all. It has a cost, and that cost appears within this section, so each consequence below says whether it comes from the representation or from this choice.

Let’s start from the assumption the classical account cannot keep: that a point is a point. In a tolerant kernel every entity carries a distance within which it is considered to be exactly where it claims to be, so each entity becomes a volume.

A vertex is a sphere

TolV

radius = Tol(V)

An edge is a pipe

TolE

radius = Tol(E)

A face is a slab

2·TolF

thickness = 2·Tol(F)

The three envelopes. They are part of the model itself, not error bars drawn around it for analysis. The curve inside the pipe is only a convenience; the kernel has to reason about the pipe.

The tolerances are not independent. An edge cannot be more precise than the vertices that bound it, and a face cannot be more precise than its edges:

Tol(E) ≤ max Tol(Vi)     Tol(F) ≤ max Tol(Ei)

So a single imprecise vertex, whether imported or produced by an earlier operation, makes everything built on it less precise.

Now we need a definition to replace “the boundaries meet”. Two entities interfere when there is some region of space where the distance between their underlying geometry is no greater than the sum of their tolerances. We say interfere and not intersect because the same test has to detect crossing, touching and overlapping. The classical account treats crossing as the only case and does not allow for the other two.

Three kinds of entity, taken in pairs, give six interference types, and each one is a different computation with a different output:

InterferenceThe testWhat it produces
Vertex / Vertexdistance between the two pointsone merged vertex, placed at the midpoint
Vertex / Edgedistance from the point to its projection on the curvethe vertex, plus its parameter on that curve
Vertex / Facedistance from the point to its projection on the surfacethe vertex, plus its u,v on that surface
Edge / Edgedistance between two curvesa new vertex, or a shared parametric range
Edge / Facedistance between a curve and a surfacea new vertex, or a range of the curve lying in the face
Face / Facedistance between two surfacesintersection curves, or isolated vertices

Each of the last three rows lists two possible outputs, and they have different dimensions. Let’s take edge / face as the example:

Case 1: the edge pierces the face

new vertex

Output: a new vertex, with its parameter on the curve and its u,v on the surface.

Case 2: the edge lies in the face

common part

Output: a parametric range of the curve. The answer contains no point.

The same interference type and the same code path give two incompatible answers, one of dimension 0 and one of dimension 1. Everything after this (the data structure, the splitting, the classification) has to represent both. The classical five steps only describe the left-hand case. Edge / edge and face / face have the same two cases.

This leads to the property that turns intersection into a fixpoint problem instead of a single pass. Every interference that produces a new vertex has to give that vertex a tolerance. One kernel uses this rule:

Tol(Vnew) = max (Toli, Tolj) + ½ D

that is, the larger of the two input tolerances plus half the distance between them. The exact expression is a choice, but the direction is not. A vertex created to stand for two things that were not in the same place cannot be more precise than either of them, and it has to cover the gap between them. So recording an intersection makes the model less precise at that spot, a less precise spot has a larger envelope, and a larger envelope can reach entities that were out of range when the search for candidates began. This is why intersection cannot be done in a single sweep. It has to detect which tolerances grew, go back for the pairs that are now in range, and repeat until nothing changes.

The fixpoint is the cost of the tolerance choice. If we use one tolerance for the whole operation instead, nothing grows, the set of candidates never changes, and a single sweep is enough. The cost moves elsewhere: we have to fix that tolerance before we know what the operands are made of, and we have no way to record that one particular vertex is less precise than the rest of the model.

Rule: the order of computation

The six types are computed from the lowest dimension up: V/V, V/E, E/E, V/F, E/F, F/F. The reason is that once a coincidence between two sub-shapes is settled, the interference between their parents does not need to find it again: if two vertices have already been merged, the edges meeting there do not need to rediscover it. In the reverse order, every higher-level result would have to be pushed back down onto the sub-shapes afterwards, where it could contradict what is already there. Two more rules follow: the result of an interference never has a higher dimension than the lower-dimensional of its two inputs, and it splits its sources wherever it can.

Step 1: classifying the section curve against the face boundary

Intersecting two surfaces is only half of step 1. A face is a trimmed piece of a surface, so the curve that comes back has to be intersected again with the boundary of each of the two faces, to find which parts of it lie in both. Most of the case analysis happens in this second intersection, and its output is an ordered sequence of contact events along the curve.

BUILD named six of these events, and the names are still used:

ContactWhat happened
ENTERSThe curve crosses the face boundary inward.
LEAVESIt crosses outward.
INOSCULIt is inside the face and touches an edge without leaving.
OUTOSCULIt is outside the face and touches an edge without entering.
WIREIt cuts a wire edge (an edge with the same loop on both sides, which bounds nothing).
ONEDGEIt runs along an edge of the face instead of across it.
holewire edgeFENTERSWIREINOSCULLEAVESOUTOSCULONEDGE
One face, in its own parametric space, and the six ways a section curve can meet its boundary. Only the first two are crossings. A naive implementation that counts crossings either miscounts the other four or misses them. ONEDGE is the hardest, because it is an interval and not a point, and it can stand for any of the other cases depending on which side the curve is on before and after.

The order of contacts

These events cannot occur in any order. A curve that has just entered a face cannot enter it again without leaving first. Written out, the constraint is a small transition table:

AfterThe next contact must beand can never be
ENTERSLEAVES, INOSCUL, WIRE, ONEDGEENTERS, OUTOSCUL
LEAVESENTERS, OUTOSCUL, ONEDGELEAVES, INOSCUL, WIRE
INOSCUL or WIREINOSCUL, WIRE, LEAVES, ONEDGEENTERS, OUTOSCUL
ONEDGEanything—

This table is useful in two ways. First, a violation proves that something earlier produced a wrong answer, so it is one of the few cheap, exact correctness checks available in a Boolean. Second, it resolves cases that no distance computation can. When a section curve crosses two bounding edges at nearly the same place, the two crossing points cannot be told apart numerically and their order along the curve is arbitrary. The table decides it: if the curve is inside the face there, the pair must read LEAVES then ENTERS; if it is outside, ENTERS then LEAVES. No other part of the algorithm has this information.

Two more rules follow from the table. INOSCUL and WIRE contacts always come in pairs (one closes a segment, the other opens the next), so an odd count is also a fault. And OUTOSCUL contacts can be discarded: the curve is outside the face, so nothing there belongs to the result, and if the contact was part of a real interaction, another face pair has already recorded it.

Closed section curves

Sorting contacts along a curve means sorting their parameters, and this works until the curve is closed. On a closed curve the parameter reaches the end of its range and starts again, so an interval that crosses the seam comes back inverted: the point where the curve entered the face has a higher parameter than the point where it left.

The interval wraps

t = 0t = 0.25t = 0.75inside the face: 0.75 → 1.25

The curve leaves the face at 0.25 and enters at 0.75. Sorted naively, the inside part reads 0.25 → 0.75, which is the half that is outside. The correct reading is 0.75 → 1.25.

No contacts at all

no crossings — split anyway

The curve lies entirely inside both faces. There is nothing to sort, and the segment has to be created explicitly.

In both panels step 1 produces something the five-step description has no name for. On the left, the fix is to shift the parameter by one period, which requires knowing that the first event in the sequence should be an ENTERS. On the right there is no event at all: a point-in-face test shows that the curve is inside, and then the implementation has to create split points, because most kernels cannot represent an edge of 360 degrees. Whether it creates one or two depends on the modeller, not on the geometry.

Tangent and coincident surfaces

Two cases have no single right answer.

Surfaces that touch at a single point. For example, two spheres meeting at one point, or a cylinder resting on a plane. The contact is real and lies inside both faces, and what to do with it depends on the operation: subtracting an internally tangent solid leaves a non-manifold result, subtracting an externally tangent one is harmless, and adding two externally tangent solids is the problem case. Most implementations ignore these contacts and accept that a non-manifold result can get through. The alternative (emitting a degenerate ring of zero radius and removing it afterwards) is more code for a case users rarely intend.

Surfaces that coincide. When the two surfaces are the same surface, there is no intersection curve to compute; the limits of the interaction are set by the faces around the coincident pair. The general solution is to imprint each face onto the other and produce matching sub-faces that can be joined later. This can often be skipped, because the matching pieces end up inside the result anyway and the neighbouring faces supply everything the seam needs. But when we subtract one sphere from another, every surface coincides, no neighbouring face has a different surface to contribute, and the interaction has to be built from the bounding curves instead. Sphere-in-sphere is the standard example showing that coincidence has to be handled by the main algorithm.

Step 2: splitting edges

“Split the geometry at the intersections” assumes we can say where an intersection is, and a point is not enough for that. The same vertex is generally shared by several edges, and it sits at a different parameter on each of them; a bare 3D point loses the information the splitting needs. So the unit of record is a vertex together with its parameter on one specific curve. If we sort these along a curve, the intervals between consecutive ones are the segments produced by the split.

V1VaVbV2one pave blockshrunk range…
A curve with four split points and the segments between them. The marked segment is bounded by two of them; the highlighted interval is what remains of the first segment once the spheres of its endpoints are removed.

The highlighted interval is a second thing the classical account does not describe. The endpoints of a segment are spheres, and inside a sphere the position of the curve is not determined: anything there is already inside the endpoint. Only the part outside both spheres can be tested against anything else. So a segment has two ranges: the one given by its parameters, and a shorter one that can be used.

This leads to a case that has to be handled and cannot be avoided: when the two end spheres overlap, the usable range is empty. The segment is shorter than the uncertainty of its own endpoints. It is not degenerate (it has two distinct vertices and a real curve, and it passes a validity check), but no point on it can be classified, because every point on it is inside an endpoint. Every implementation needs a decision for this case, and no decision is clearly right. With one tolerance for the whole operation, the case is at least predictable: it happens on segments shorter than that tolerance. With a tolerance per vertex it can appear anywhere, on a segment that looks healthy, because one of its ends was enlarged by something that happened elsewhere in the model.

Overlaps also need their own record. When several segments on different edges turn out to be the same curve within tolerance, or a segment turns out to lie within a face instead of crossing it, the fact cannot be stored on any one of them, because it concerns a group. Merging these groups raises two more problems:

Coincidence is not transitive

V21V22V1must merge — cannot

V1 coincides with both ends of the edge, so the two ends coincide with each other. But they are the two ends of one edge and can never be the same vertex.

“Practically coincident” is not coincident

apart by 10⁻⁶, tolerance 10⁻⁷C1C2becomes3 new vertices, 8 new edges

No overlap is recorded. The answer is arithmetically correct and useless in practice; only the numbers are wrong.

Two failures that are not bugs. Left: coincidence within tolerance is not an equivalence relation. It is reflexive and symmetric but not transitive, so “merge everything that coincides” can require a merge that the topology forbids. Right: the tolerances were too tight for the modelling error, and the algorithm did exactly what it was told.
Terminology

Kernels use different names for these. We borrow the names one production kernel uses: a pave for a vertex with its parameter, a pave block for a segment between two of them, the shrunk range for the usable interval, and a common block for a recorded overlap. The names are specific to that kernel, but anyone who does this in floating point needs the four concepts.

The ON state: why it cannot be merged into IN or OUT

It would be convenient if ON were a tie-break: round it to IN for one operation and to OUT for another, and keep four groups. This does not work, and the reason is structural. Requicha addressed this directly. When we combine a piece’s membership with respect to A with its membership with respect to B to get its membership in the result, IN and OUT combine without ambiguity, as a Boolean operation on intervals. ON does not combine at all. Two pieces that are both ON may or may not belong to the result, and no information about the pieces themselves can tell us which. We have to look at the neighbourhood (the infinitesimal layer of material on either side), which in practice means comparing the orientations of the two surfaces at the shared point.

Two pairs can have the same position and the same tolerance and differ only in the direction of their normals: one pair fuses into a single face, and the other pair cancels. This is why every serious implementation has ON as a separate state in its classification enum, alongside IN, OUT and UNKNOWN, and not as a flag on the other two.

This is also where step 4 goes wrong. Two solids that meet only along a face have an intersection made entirely of ON pieces, and the set-theoretic answer, the shared face, is a surface returned by a solid operation. Regularisation exists to delete exactly this, so it is not a clean-up pass applied afterwards. It is a decision about the ON group, and it has to be made with the neighbourhood information available.

Step 5: joining the result as a graph problem

“Join the remaining pieces” is the shortest of the five steps and the most misleading. It is not a proximity match. When we reach this step we have two boundaries cut along a shared seam, whose structure the whole algorithm has established, and the job is to join matching pairs along that seam. This is a connectivity problem, and it comes with three stages.

Removing hanging edges

A hanging edge

free endclosed ringone loose edge — delete it

The rule is local and cheap: every intersection edge must have another intersection edge at both of its ends.

Rings that share a run

shared runring 1ring 2which ring owns it?

A set of disjoint closed rings is not guaranteed. Rings can overlap along whole sequences of edges.

Two problems that appear before any joining. Left: a cylindrical surface meeting a planar face can produce a closed ring plus a stray edge attached at one end only; both objects get one, and both have to be deleted before the seam can be used. Right: the harder case, and historically a common source of failures in joining code. When intersection rings share edges, “join ring to ring” is not well defined, and the joiner has to match individual edge pairs and verify each one.

Reducing every operation to an intersection

Braid observed, early in the history of the field, that we never need three joining procedures:

A + B  =  ¬(¬A & ¬B)       A − B  =  A & ¬B

If we negate an operand (reverse its orientation, so that inside becomes outside), every Boolean becomes an intersection. There is then one joining method, used by every operation, which matters because the joining method is the fragile part. The negations have a cost, and an implementation that cares about speed will special-case them away again, but they are the right way to think about the step, and they make one more fact clear.

The joining process classifies edges in pairs: one member of each pair belongs to the result, and the other does not. So the discarded half is a complete, valid shape of its own, the dual of the requested operation, and it comes out of the same run at no extra cost. The classical five steps do not mention this, although many useful things a kernel can do with a decomposition use the discarded half.

Separating shells and cavities

After joining, all the topology and geometry from both operands is in a single object. It is separated by connectivity, not by geometry: start from an edge marked non-result, move everything connected to it into its own shell, and repeat until no marked edges remain. Then do the same for the result edges to split them into distinct shells.

Only then comes a question a 2D Boolean never has to ask: which of these shells are outer boundaries, and which are cavities inside other shells? The operation has already established that the shells do not intersect, so a point-in-body test answers it. The exception is shells that touch another shell without crossing it: these shells are not independent, and no seam was created to record the contact.

If there were no intersections at all, the answer depends only on containment, decided by a single point-in-body test and a table:

A + BA − BA & B
A inside BBnothingA
B inside AAA, with B as a cavityB
disjointboth, unchangedAnothing
Why proximity sewing is the wrong tool

A generic sewing pass matches boundary pieces that lie within some tolerance of each other. If we run one at the end of a Boolean, it has to guess the correspondences that the intersection stage computed exactly, and it will get some of them wrong, because by then the tolerances have grown. The approach above keeps the correspondences already established, and reduces the final step to walking a graph that already exists.

Why a correct implementation still fails

Everything above can be implemented exactly as specified, and the operation will still fail on inputs a user considers fine. The causes are properties of the representation, not defects in the code, so they apply to every kernel.

Valid does not mean usable. A shape passes a validity check by meeting local criteria: curves agree with their surface parametrisations within the stated tolerance, faces close, and orientations are consistent. None of this prevents a shape from interfering with itself. Examples are an edge whose two end spheres overlap, or a vertex with a tolerance of 50 units in a model measured in millimetres, touching a dozen sub-shapes it has no topological connection to. Both shapes are valid, and neither can be used, because the first thing the algorithm does is resolve interferences, and these shapes interfere with themselves before the other argument is considered.

A validity check can contradict itself across a split. Checkers sample: they compare the 3D curve with the surface parametrisation at a fixed number of points along the edge. If we split that edge in two, each half is sampled at a new set of points that were not tested before, and a half can fail a check its parent passed. Since the parent was declared valid, the checker is wrong about one of them, and splitting edges is the second step of a Boolean.

The true answer is often a shape the format cannot hold. The exact result of intersecting two tolerant curves is a region of space: every place where they are closer than their combined tolerance. That region is neither a point nor a curve, and a boundary representation cannot store it. So implementations use the exact intersection of the underlying geometry, which is a point, and accept the mismatch. This is the right engineering decision, but it is still an approximation, and it causes problems whenever the region is large.

Tolerances can encode facts the topology cannot express. Two edges that should meet but do not can be joined by increasing the tolerance of a shared vertex until its sphere contains both loose ends. The model is then valid and the gap is closed. But a sphere only records that the ends are close, not how to get from one to the other: the connecting path is missing. Any later stage that needs to walk a boundary through that vertex has nothing to walk along, and with two such pairs at one vertex the question is not even well defined.

The parametrisation runs out of resolution before the geometry does. A cylinder is parametrised with u around and v along its axis, and v is unbounded. If we scale the cylinder up enough, curves that cross the parameter space at a clear angle become, in double precision, indistinguishable from parallel. The 3D geometry is not ill-conditioned, but the angles that face reconstruction relies on can no longer be computed.

The curve can enter without leaving. The oldest recorded failure of this algorithm is also the simplest: a section curve is found to enter a face, and the crossing where it leaves is not found. The two crossings are separate computations on separate pieces of boundary, each inexact, and nothing forces them to agree. The contact table from step 1 then has an ENTERS it can never close, and the segment it opened runs to the end of the curve. One mitigation is structural rather than numerical: when intersecting the section curve with a face, compare it with the other face’s surface instead of its bounding curves, because curve/surface is much better conditioned than curve/curve. This lowers the failure rate but does not remove the failure, and thirty years of implementations have not removed it either.

Summary

No implementer chose anything in this part of the article. Six interference types with two outcomes each, an order of contacts that a point test cannot supply, coincidence that is not transitive, a sixth region that combines by neighbourhood rather than by position, and true answers that cannot be stored: all of these come from the representation, and no answer to part one’s four questions removes them. Tolerances that grow as they are used, and segments with no usable interior, come instead from the choice this section assumed: a tolerance on every entity. An implementation has to handle both lists. Together they make up the difference between the five-step description and a working kernel.

What the theory leaves to the implementation

This article has not named a data structure, and that is deliberate. The problem statement is complete: six interference types with two possible outcomes each, an order of contacts finer than a point test can express, tolerances that grow while they are being used, segments with no usable interior, coincidence that is not an equivalence relation, a sixth region that combines by neighbourhood rather than by position, and true answers that a boundary representation cannot store.

Five of these come from the representation itself. The two about tolerance come from where the tolerance is stored, which part one left open and this article decided for the reader; a kernel that decides differently gets a shorter list and different problems. In both cases, none of the seven is an implementer’s preference. What the implementer does choose is the answer to each of them, and these answers depend on one another. If we classify before we know the operation, we need a data structure that outlives the operation. If we treat coincidence as structural rather than geometric, we need somewhere to record a group instead of a pair. Each choice leads to the next.

The two conditions from earlier apply whatever kernel you use. Both arguments must be valid solids, and neither may be degenerate. Most Boolean failures in practice break one of these two conditions, and are found late.

Reading list

Sources

  • A. G. Requicha, H. B. Voelcker, Boolean Operations in Solid Modeling: Boundary Evaluation and Merging Algorithms, technical memorandum, January 1984: the five steps, self- and cross-edges, transitions, and the regularized operations.
  • I. Stroud, Boundary Representation Modelling Techniques, Springer, 2006. Chapter 6, §6.1, is the source for the two conditions, the six contact types and their ordering grammar, the closed-curve parametrisation problem, hanging-edge removal, and the shell-separation and containment tables. Appendix G.1 supplies the entry-without-exit failure, the curve/surface conditioning argument, and the overlapping intersection rings. The passage on anonymous error messages is his as well.
  • M. Mäntylä, An Introduction to Solid Modeling, Computer Science Press, 1988: the six-region A IN B / A OUT B / A ON B classification and its recomposition rules. Read here through Stroud §6.1, which states the classification, attributes it and illustrates it in his figure 6.8; the six-panel figure above follows that illustration. The book itself was not consulted.
  • I. C. Braid, Designing with Volumes, PhD dissertation, Cambridge University Computer Laboratory / CANTAB Press, 1974: the BUILD system, and the reduction of all three operations to a single intersection with negated operands. Also read through Stroud §6.1.
  • C. M. Hoffmann, Geometric and Solid Modeling: the propagation ambiguity that the fixed interference order avoids, and “avoid asking the same geometric question twice.” Read here through the Quaoar memo, which cites it for both points.
  • S. Slyadnev, OpenCascade Booleans, Quaoar Studio technical memo, v1.0 2015 / v1.1 2025-03-10. The architecture chapter was written with Peter Kurnev, lead developer of OCCT Booleans, and is the source for the Rochester / Cambridge framing used above. Its kernel-specific half (the interference vocabulary, the robustness survey, the roadmap) is used in the companion article instead. quaoar.su/files/papers/cascade/2025-03-Booleans.pdf
Revision history

. Part numbers renumbered for the new part two, The Mathematics a Kernel Stands On.