Skip to content
AI-Ready Docs
/llms.txt/llms-mcp.txt

Booleans of curved solids ​

This page opens up the Boolean of two curved B-reps — the path B-rep, robustness and refusals names intersect the surfaces and trim their face domains. Each stage has a figure that plays its steps as you reach it. Use Play/Pause, the arrows or a step's number to go through it at your own pace; with reduced motion turned on in your system, each step is shown still.

The figures use small cases worked out in the page: two cylinders, a rectangle and a circle, a plate and a boss. The methods, the formulas and the constants are the kernel's, in packages/barocss-cad/src/.

The stages at a glance ​

StageWhat it doesSource
1. CutFor each pair of faces that can meet, the curves where their surfaces crossintersect/surface-intersection.ts, brep/analytic-boolean.ts
2. SplitEach face's 2D domain divided by its cuts into piecesbrep/curved-arrangement.ts
3. ClassifyEach piece: inside or outside the other solidbrep/analytic-boolean.ts (classify)
4. SelectPieces kept by the operation; the tool's turned over for a differencebrep/analytic-boolean.ts
5. MergeKept pieces on one plane or cylinder that touch, joined into one facebrep/analytic-boolean.ts (mergePieces)
6. StitchVertices, edges, loops, shells and bodies of the result, then a strict checkbrep/analytic-boolean.ts (stitch)

Every length test uses one tolerance and multiples of it: in the analytic Boolean, ε = 10 × max(10⁻⁷ mm, 10⁻¹¹ × S), S the largest coordinate of the two inputs' vertices (at least 1), so 10⁻⁶ mm for parts up to 10 m.

1. Where two surfaces meet ​

Most face pairs are dismissed before any intersection is computed. First their 3D boxes must overlap. Then, for a NURBS face against a plane or a cylinder, the face's control net must reach the other surface: a patch can never leave the convex hull of its control points.

Skipping pairs that cannot meet: the control-net hull
w = 1w = 1.6w = 0.8w = 1
1. A patch lies in its net's hull

A NURBS point is a weighted average of its control points. With every weight positive, the weights of the average are positive and sum to one: the point lies in the convex hull of the control points, for every (u, v).

S(u, v) = Σ wij Ni(u) Nj(v) Pij / Σ wij Ni(u) Nj(v),   N ≥ 0, w > 0
A section through a patch: the curve is a rational cubic (weights shown), the line a plane seen edge on, g = 0.15 here for the picture (the kernel uses its tolerance). The kernel applies the test to a NURBS face against a plane or a cylinder before marching.

A pair that may meet is intersected. Plane/plane pairs and the supported plane/cylinder and cylinder/cylinder pairs have closed-form curves: lines, circles, ellipses, parametrised branches. Any other pair is traced by marching: start on the curve, step along its tangent, pull back onto both surfaces, repeat.

Tracing where two surfaces meet: predictor and corrector
A · x² + y² = 16B · y² + z² = 6.25
1. Seed from coarse grids

Both surfaces are cut into coarse triangle grids. A pair of triangles that cross gives a starting point near the curve, on each surface's own parameters: (θ, z) on A, (φ, x) on B.

A: SA(θ, z) = (4 cos θ, 4 sin θ, z)   B: SB(φ, x) = (x, 2.5 cos φ, 2.5 sin φ)
Computed in the page with the kernel's predictor and corrector on these two cylinders (the kernel also has a closed form for some cylinder pairs; marching is what it uses for general patches). The full curve is two closed loops, one each side of B's axis; one is traced here.

2. Splitting a face ​

Each cut curve is mapped into the 2D domain of both faces it lies on: a plane in a frame of its own, a cylinder by angle × radius and height, a NURBS face by its scaled (u, v). The face's domain is then divided by its cuts in a 2D arrangement: every curve split where it crosses another, every crossing a vertex, every closed walk a region.

The figure runs the arrangement as a 2D Boolean, which the kernel uses for prismatic bodies and to merge coplanar pieces. Splitting a face is the same arrangement with the cuts given no material: the regions inside the face's own boundary are its pieces.

Splitting a face: the 2D curve arrangement
AB
1. Two closed rings

Each operand is a closed ring of lines and arcs with material on its left: A, a 10 × 6 rectangle; B, a circle of radius 3 about (9, 4). An arc over half a turn is split in two, so no piece starts and ends at one point: B is two half circles.

The geometry is fixed and worked out in closed form for the picture; the kernel runs the same steps on any lines, arcs and traced curves. ε is the caller's: max(10⁻⁷ mm, 10⁻¹¹ × the coordinates' size) on its own, ten times that inside the analytic Boolean.

3. Inside or outside a region ​

Many steps ask whether a 2D point lies in a face's region: whether a ray's hit lands on the face, whether a sample is inside a piece, which face a piece of a merge falls in. The answer is the parity of a ray's crossings.

Inside or outside: a ray's crossings
12345crossings to the right: 5
1. A ray to the right

From the point, a horizontal ray runs to +x. Each place it crosses the region's boundary is found exactly: a line by interpolation, an arc or curve by bisection on a piece that is monotone in y (an arc is cut at its top and bottom). Where the ray passes a vertex, both segments read the one shared point, so they agree on its side.

a piece crosses when exactly one of its ends lies above y = yₚ (half-open rule)
One outer ring and three holes, drawn as circles; the kernel's rings are any lines, arcs and traced curves. The skipped rings' crossings (hollow) come in pairs, so the count read is the count's parity either way.

4. Which pieces to keep ​

A piece no cut passes through lies wholly inside or wholly outside the other solid, so one point of it decides. Far faces are decided by their boxes alone; the rest by rays from a point inside them, in 3D against the other solid's planes, cylinders and patches. The operation then chooses:

OperationKept from AKept from B
A ∪ Boutside Boutside A
A ∩ Binside Binside A
A − Boutside Binside A, turned over

A piece lying on a face of the other solid (a coincident patch) is classified by whether the two face the same way or opposite ways, so a shared patch is kept once or not at all.

Which pieces to keep: far faces, then rays
AB
1. Pieces after the cuts

The surface intersections have split the faces: A's top is in three pieces, B's wall in two. Each piece is now wholly inside or wholly outside the other solid, and one point decides which.

A section through a plate and a boss, for the picture; in the kernel the pieces are trimmed faces and the rays run in 3D against the other solid's planes, cylinders and NURBS patches.

5. Joining coplanar pieces ​

Kept pieces on one plane facing one way — or one cylinder, facing one way — are joined only where they meet. They are grouped by their 2D boxes (padded by 10 ε, meeting directly or through others); a group of one whose rings close is kept as it is, with its own name; a larger group goes through the 2D union above and each face it makes takes the name of the first piece lying in it. A row of bosses on a plate keeps c0.top, c1.top, … rather than all taking the latest boss's name (D281).

6. Stitching the result ​

The kept pieces' boundaries become one B-rep: shared vertices, shared edges, loops, shells and bodies. The result is then checked strictly (every edge used once each way, loops closed, surfaces and curves agreeing within tolerance) before it is returned.

Stitching pieces into a solid
within r of a stored end → the same vertex
1. Ends become vertices

Every kept piece's boundary curves go into one point set by their ends. Two ends closer than the merge radius r = 20 ε are one vertex: a traced curve meets the exact one it crosses within its tracing tolerance, a little looser than curves are fitted.

find(p) = the first stored q with ‖q − p‖ ≤ r,   r = 20 ε
Proportions are the kernel's (cell 16 r, neighbour band 2 r); the points and faces are made up for the picture. On a rounded plate with 48 bosses the frozen faces save 10–13 % of the chain's time.

Numbers that must not flip ​

Some quantities are re-derived at every Boolean from the last result. A test that compares one with an exact constant, or orders by it exactly, can change its answer on the last bit after a few steps. Two such tests were found by comparing the incremental stitch with the full rebuild (D282):

QuantityExact testWhat happenedNow
An arc's sweepsplit if |sweep| > πa half circle read back as −3.141592653589794 (one ulp past π) after six Booleans was split at its top: an extra vertex and edgesplit if |sweep| > π + 10⁻¹²
Repeated face names f#1, f#2ordered by inside point x, then y, then za cylinder's two halves share one x to within 4 × 10⁻¹⁵, so #1 and #2 swapped from one Boolean to the nexta coordinate within 100 ε counts as equal; the next one decides

The general rule: compare a re-derived value with the margin the code already uses for that quantity, never exactly.

Keeping it fast ​

Each shortcut below skips work only where the answer is already known; the full test still runs everywhere else.

ShortcutWhat is skippedWhy the answer is the same
Box overlap of segments, faces and raysintersecting two pieces whose boxes are apartcurves inside disjoint boxes cannot meet
Control-net hullmarching a NURBS face against a plane or cylinder it cannot reacha patch lies in its control points' hull
Ring boxes in point-in-regionreading rings whose box does not hold the pointoutside its box a ring adds an even number of crossings
Ray hit outside the region's boxlocating that hit in the regionit is outside the region
Far uncut facesrays for faces 1000 ε clear of the other solidnothing of the other solid is near them
Lazy inside pointsfinding a point inside a piece nobody asks aboutit is found, the same, when first asked for
Vertex gridsreading cells no match can be ina point farther than 2 r from a side has no match beyond it
One shared cache of curve mapsrecomputing a pure function of a parametera slot taken by another value only costs a recomputation
Frozen faces (D283)rebuilding faces that came through a step unchangedtheir loops are taken only where the rebuild would make the same edges

The measurements behind these, and the methods used to check that results stayed the same, are in the handover note apps/cad-studio/handover/notes/report-kernel-performance-2026-10-28.md.