Why Two CAD Kernels Should Agree on the Same Sketch — and How NeuroCAD Verifies It
Closed 2D profiles look trivial, but the gap between NURBS and SDF representations is where modern CAD silently diverges. Here is how NeuroCAD pins the agreement as a measurable contract.
The most boring object in CAD — a closed 2D profile — is also the place where modern kernels quietly diverge. Here is how NeuroCAD makes that divergence impossible.
The failure mode you have probably seen
Open your favourite parametric CAD package. Draw a rectangle. Add a fillet to one corner with a 2 mm radius. Constrain it. Extrude it 10 mm.
It works. It always works.
Now try this: take the same sketch, change the rectangle dimension by 0.1 mm, hit “update”. On a small fraction of edits — somewhere between 0.5% and 5% depending on the kernel — the extrusion will look correct in the viewport but produce a body whose mass is off by a fraction of a percent, whose face count flickers between 5 and 6, or whose downstream fillet rolls into a corner that wasn’t there a second ago.
This is not a bug in the sketcher. The sketcher solved its constraints correctly. It is not a bug in the extrusion either. The extrusion did exactly what it was told. The bug lives in the gap between two internal representations of the same closed curve — and almost no published CAD system tests that gap directly.
NeuroCAD does. It is one of the things we think is genuinely new about the platform.
Two ways to describe a square
A 2D sketch is “just lines and arcs” until you ask the question that every solid modeller has to answer: given a point in space, is it inside the profile or outside?
Two answers exist, and modern CAD platforms keep them both:
Answer A — the analytic / NURBS answer. Each line and arc is an exact mathematical curve. The closed profile is a sequence of curves connected end-to-end. To test inside/outside you intersect a ray with the curves and count crossings. This is what classical B-rep kernels (Parasolid, ACIS, Open CASCADE) do, and what NeuroCAD’s NURBS kernel does. It is exact, it is good for boolean topology, and it is bad at one specific thing: it has no native, smooth, continuous notion of “how far am I from the surface”.
Answer B — the SDF answer. The profile is described by a single continuous function f(x, y) whose value is the signed distance to the nearest curve — negative inside, positive outside, zero on the boundary. This is what Inigo Quilez’s well-known catalogue of 2D distance functions describes [1], and what NeuroCAD’s SDF kernel does. It is great for blending, smooth booleans, gradient-driven extraction, and GPU sphere-tracing. It is also, by construction, approximate — except for the rare cases where a closed-form SDF exists.
Most CAD systems pick one and live with the consequences. Parasolid is Answer A and does not natively reason about distance fields. Most game-engine SDF implementations are Answer B and are visibly imprecise on hard topology cases. NeuroCAD keeps both, deliberately, and treats them as carriers of truth in different domains.
So what could go wrong?
If the SDF and the NURBS profile describe the same square, the inside/outside boundary of one should match the boundary of the other. That should be a tautology. In practice, three things break it:
-
Sketch solver convergence. The 2D constraint solver runs once and produces, say, four corner points. Those four corners are then handed to the NURBS curve constructor and to the SDF compiler — but the two builders may quantise or seed slightly differently, especially after subsequent edits.
-
Tolerance mixing. A NURBS knot insertion is supposed to be geometrically lossless [2], but in finite precision it leaks a few ULPs into the control polygon. If the SDF compiler is then re-derived from the NURBS curve rather than from the original analytic primitive, the SDF inherits the leak, and the leak is invisible at the sketch level.
-
Operation order. When a sketch is edited, the dependency graph re-evaluates downstream operations in some order. If the SDF and the NURBS branches re-evaluate at different points in the graph (because the sketcher updated them at different times), an extrusion that uses both representations can transiently see a mismatched pair.
Each of these alone is a 0.01% effect. Compose ten edits and the failures show up as the kind of “ghost geometry” bug that QA teams chase for a sprint and never quite reproduce.
NeuroCAD’s contract: agreement is a measured invariant
The way NeuroCAD avoids all three failure modes is not to pick the “better” representation and force everyone to use it. Instead, the platform admits up front that two kernels exist and pins six axioms that they must obey jointly. Two of those axioms apply at the sketch layer:
Axiom 1 — Identity preservation. A closed profile created in NURBS and projected to SDF retains a single persistent_id across regenerations. Both kernels point to the same identity, no matter how often the sketch is solved.
Axiom 5 — Bridge round-trip. Converting a NURBS profile to an SDF profile and back must hit a specified epsilon budget (epsilon_achieved < 1e-3), and the conversion must be receipt-tracked: every conversion writes a small structured record saying “I converted in Analytic mode, here is the achieved epsilon, here is the timestamp.”
For 2D sketches specifically, the practical test is the Hausdorff distance between sampled boundaries:
profile P, sampled on a regular grid G ⊂ ℝ²
let Z_NURBS = { (x,y) ∈ G : sign distance to NURBS profile = 0 ± δ }
let Z_SDF = { (x,y) ∈ G : f_SDF(x,y) = 0 ± δ }
agreement(P) := max( sup_{a ∈ Z_NURBS} d(a, Z_SDF),
sup_{b ∈ Z_SDF} d(b, Z_NURBS) )
assert agreement(P) < ε # ε = 5 × 10^-4 mm at unit scale
In plain language: every point that the NURBS kernel says is on the boundary must lie within ε of some point the SDF kernel also says is on the boundary, and vice versa. We sample, we measure, we either pass or we file a bug.
NURBS profile (Kernel B) SDF profile (Kernel A)
───────────────────────── ───────────────────────
╭──────╮
╭─────────────────╮ │ │
│ │ │ │
│ line 1 │ ← Hausdorff → │ │
│ │ distance < ε │ │
│ arc 1 │ │ │
╰─────────────────╯ ╰──────╯
(level set
f(x,y) = 0)
NeuroGraph 4-surface substrate
┌────────────────────────────────────────────────────────────┐
│ HistoryDag · EntityGenealogyGraph · ProjectionIndex · │
│ EvidenceGraph │
└────────────────────────────────────────────────────────────┘
↑ ↑
persistent_id conversion receipt
shared by A & B (mode, epsilon, timestamp)
The bridge between the two has four conversion modes: Analytic (exact, used for primitives like circles and rectangles), Hybrid (analytic where possible, numerical fallback elsewhere), Numerical (sampled), and Lossless (mesh fallback for non-differentiable subtrees). Sketches in the cleanly-constrained case run through Analytic; complex spline profiles fall to Hybrid. Every conversion writes a receipt. Every receipt is replayable.
Why this matters even if you never read the test report
A user-visible consequence of pinning the agreement is that every downstream feature can choose the kernel best suited to its job without fearing divergence. A pad operation can take the analytic NURBS profile to compute the boolean topology cleanly. A smooth-blend operation can take the SDF representation to integrate a SmoothUnion. A drilling operation can use the NURBS profile to pick the trim curve and the SDF profile to compute the swept volume for material-removal animation. Because the two kernels are guaranteed to agree on the boundary up to ε, mixing them stops being dangerous.
Less obviously, the agreement contract also closes a class of regression bugs that have been with parametric CAD since the 1980s. When a user edits a sketch and a downstream feature breaks, the question “did my edit actually change the geometry?” can finally be answered numerically, by sampling both representations and measuring the Hausdorff distance before and after. NeuroCAD writes that measurement as part of the dependency-graph receipt. We can grep for it.
What is shipped, what is in flight
NeuroCAD has the two kernels, the bridge, and the variable-topology hole regression pin that proves the SDF “never-fails” property end-to-end on drilled features. The 6-axiom Dual-Kernel Agreement Contract is authored and locked in our REV11.4 specification. The 2D sketch-level agreement test (Hausdorff bound on closed profile) is a proposed lab test — it is in the test plan, not yet in the merged test suite. That gap is exactly why this is publishable: the architecture supports it, the contract specifies it, and the tooling is half-built.
If you build CAD kernels for a living and the phrase “two representations of a closed curve must agree to ε on a sampled grid” sounds like an obvious thing nobody bothered to formalise — that’s our hypothesis too. We are writing it down.
References
[1] Quilez, I. 2D distance functions. https://iquilezles.org/articles/distfunctions2d/ [2] Piegl, L. and Tiller, W. The NURBS Book, 2nd ed., Springer (1997). Knot insertion preserves geometry exactly in real arithmetic.
Status
NeuroCAD’s SDF kernel and NURBS kernel both ship today, along with the four-mode bridge between them and the variable-topology hole regression pin that proves the SDF never-fails property. The 6-axiom Dual-Kernel Agreement Contract is authored in our REV11.4 specification. The 2D sketcher-profile Hausdorff agreement test is proposed and in the lab plan, not yet in the merged test suite. Anything not described as shipped should be treated as plan, not product.