Fornjot CAD Kernel

repository·main·Indexed 25 days ago

https://github.com/hannobraun/fornjot

An experimental, Rust-based CAD kernel utilizing boundary representation (b-rep) designed for mechanical CAD applications and Code-CAD workflows. The project consists of several modular libraries, including fj-math, fj-core, fj-interop, fj-export, and fj-viewer. While it explores concepts like layered topological structures and functional event-sourcing for state management, the project has been shut down and the current code is considered experimental and unsuited for real-world use.

Tokens
20.4K
Snippets
41
Records
154
Agent score
82%

What's inside Fornjot

  1. Overview of Fornjot CAD Kernel

    main

    Fornjot is an early-stage, experimental CAD kernel written in Rust that uses boundary representation (b-rep). It is designed as a foundation for mechanical CAD applications (such as 3D printing, machining, and woodworking) and supports 'Code-CAD'—the practice of defining models directly in Rust or via third-party APIs in other languages.

    Note: This project has been shut down and its goals were not reached. The current code is considered experimental and unsuited for real-world use cases.

  2. Understand the Layered Topological Structure concept

    main

    The core architecture of this experiment moves away from maintaining a complex topological object graph separately from geometry. Instead, it builds the topological structure and its geometric approximation simultaneously, step-by-step.

    This approach uses a layered model:

    1. Vertices: An append-only list of points (the base layer).
    2. Triangles: An append-only list of triangles referencing vertices (the raw geometry layer).
    3. Topological Layers: Additional layers that store relationships such as Edges (pairs of vertices) and Faces (collections of triangles and their bounding edges).
    4. Solids: A high-level layer representing a solid object that refers to its constituent faces.

    By using auxiliary concepts like Sketches (2D definitions) and Faces (mapping sketches to 3D surfaces), the system can generate the necessary vertices, triangles, and topological relationships (edges/faces) at the moment of construction, rather than trying to reconstruct them from a raw mesh later.

  3. How geometry is constructed via Sketches and Faces

    main

    In this architecture, geometry is not defined by raw meshes but by construction operations that populate the core data layers.

    1. Sketching

    A sketch is an auxiliary 2D concept used to define boundaries (e.g., using lines, arcs, or splines).

    2. Defining a Face

    A face connects a 2D sketch to a 3D surface by specifying a plane (origin, u-axis, and v-axis). This operation automatically:

    • Adds the sketch points to the global vertex list.
    • Generates triangles via Delaunay triangulation (with filtering for holes) to populate the triangle list.
    • Populates topological layers with edges and face definitions (linking triangles to their boundary edges).

    3. Solid Operations

    Once a face is defined, operations like a sweep (or extrusion) can be performed along a vector to create a solid. This adds more vertices, triangles, edges, and faces to the existing lists and creates a solid object entry.

  4. Understand the Fornjot Experiment 2025-11-07 architecture

    main

    The 2025-11-07 experiment is a library-based architectural sketch designed to explore a simpler, ground-up redesign of Fornjot. It focuses on core data structures and backend processing rather than frontend operations or building/modifying tools.

    Key architectural objectives include:

    • Distinguishing topological objects: Clearly separating owned objects from shared topological objects to simplify the object graph (moving away from a universal Handle approach).
    • Local coordinate geometry: Representing all geometry in terms of local coordinates.
    • Simplified approximation: Exploring how local geometry representation can simplify the use of approximations as uniform intermediate representations.
  5. Understand the Fornjot modular architecture

    main

    Fornjot is composed of several modular Rust libraries. You can use the all-in-one fj crate or pick specific components based on your needs:

    • fj: An all-in-one API that re-exports all other crates.
    • fj-math: Math primitives used throughout the ecosystem.
    • fj-interop: Basic types for inter-crate interoperability without direct dependencies.
    • fj-core: Core primitives and logic operating on those primitives.
    • fj-export: Tools to export Fornjot models to external data formats.
    • fj-viewer: A component for displaying Fornjot models.
    • fj-window: A simple windowing abstraction used by fj-viewer.
  6. Run the Fornjot Experiment 2024-12-09 prototype

    main

    This experiment is packaged as a single application. Running it will open a window displaying hardcoded geometry and generate a 3MF file in the current directory.

    Navigation in the UI:

    • Expand tree nodes: Use the right cursor key.
    • Navigate list nodes: Use up and down cursor keys.
    • Close expanded nodes: Use the left cursor key.
    cargo run
  7. Run the Fornjot 2024-10-30 experiment

    main

    This experiment is packaged as a single application. You can run it using cargo run. When executed, the application should open a window displaying hardcoded geometry in the background and a list of operations in the foreground. It also creates a 3MF file in the current directory.

    Interacting with the prototype:

    • Use the up and down cursor keys to select different operations from the list.
    • Selecting an operation will update the background geometry to reflect the state of the model at that specific step.
    cargo run