Skip to content
CADCAMFUN
Docs

Documentation

Kernels

The pure geometry and machining kernels of packages/core, explained from the inside with real outputs and 3D examples.

The kernels and how they depend on each other

The geometry and machining code in packages/core is a set of pure kernels: same input, same output, no I/O. Each page in this section explains one of them from the inside: what it is for, its data structures and algorithms, the real API, limits and constants, output captured by running it, and 3D views built from that output.

Kernel import graph Drag to orbit · scroll to zoom · right-drag to pan
Boxes are kernels; each line is a real relative import from one kernel’s source files to another’s (tests excluded), counted from packages/core/src. Lower layers sit at the front: tolerance, mesh, sketch and B-rep; history and features above them; CAM on top.
FromImports fromFiles importing
cam-generatorcam-kernel2
cam-generatorhistory1
cam-generatormesh2
cam-generatorsketch1
cam-kernelcam-generator4
cam-kernelmesh1
drawingbrep1
drawinghistory4
drawingmesh7
featuresmesh5
historybrep1
historyfeatures5
historymesh2
historysketch2
meshtolerance1

The one cycle, CAM kernel ↔ CAM generator, is deliberate: the kernel reuses the generator's strategies and element schema, and the generator calls back into the kernel's cutting data and planner.

Kernel pages

PageWhat it coversSource
Sketch solverLevenberg–Marquardt on constraint residuals, rank analysis for degrees of freedom, free points and conflicts.packages/core/src/cad/sketch.ts
Mesh and CSGClosed triangle meshes, BSP Booleans with a convex fast path, soup cleanup and topology.packages/core/src/cad/csg.ts, solid.ts, mesh-clean.ts
Exact B-repAnalytic and NURBS faces, exact Booleans, fillets, hole recognition, mass properties, STEP.packages/core/src/cad/brep/
Feature generatorsInvolute gears, ISO threads, helices and sheet metal with flat patterns.packages/core/src/cad/gear.ts, thread.ts, helix.ts, sheet-metal.ts
Tolerance and tessellationOne chord tolerance for segment counts, decimals and entity tessellation.packages/core/src/cad/tolerance.ts, tessellate.ts
CAM machining kernelPlanning, cutters, voxel stock with a remaining-volume bracket, certified collision checks.packages/core/src/cam/kernel/

Shared rules

  • Millimetres everywhere, radians in code (degrees only where a field says so, such as a gear's pressure angle or a blend angle).
  • Z up, counter-clockwise outer loops, outward-facing triangles.
  • Plain data. Meshes are typed arrays, B-reps are index tables, sketches are entity lists; everything serialises to JSON and diffs in the project history.
  • Errors are explicit. Invalid input throws a RangeError or a kernel error class (SketchError, BooleanError, BudgetExceeded) with a message the assistant can show; results that would be wrong are never returned.
  • Bounded work. Segment and vertex budgets in the mesh kernel, a time budget in the exact kernel, turn limits in threads, subdivision depth in collision checking.

Every number on these pages was produced by running the kernel with Bun against the source in this repository; re-run the snippets to reproduce them.