springrep github

springrep

Exact CAD geometry
in pure Rust.

MITopen source license

A boundary-representation (B-rep) kernel. Booleans, fillets, sweeps and STEP on exact geometry, accurate to 1e-7 mm, with every result validated.

brep-conformance leaderboard
see the benchmark ↓

Accurate to 1e-7 mm

Surfaces are analytic or NURBS, never triangles, so volume, area and mass come straight from the exact shape. Every brep-conformance case holds to a ten-millionth of a millimetre.

Valid, and named

Each operation's output passes a validity check, or you get an error instead of a broken solid. Faces are named for the operation that made them, like plate.end, so a changed dimension never loses a fillet or a reference.

Safe and fast

100% Rust with no dependencies and no unsafe code. The fastest median case time on brep-conformance, and it compiles to WebAssembly to run in the browser.

Get started01

01add the crate
02run it
$ cargo run volume 18276.001643 mm³ area 6452.128187 mm² wrote bracket.step, 8 faces
or
src/main.rs
use springrep::{
    blend::fillet,
    boolean::difference,
    math::{Frame, Vec2, Vec3},
    measure,
    profile::Profile,
    step,
    sweep::extrude,
};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let base = Frame::new(Vec3::ZERO, Vec3::Z, Vec3::X)?;
    let below = Frame::new(Vec3::new(0.0, 0.0, -1.0), Vec3::Z, Vec3::X)?;

    let plate = extrude(&Profile::rect(Vec2::ZERO, 60.0, 40.0), &base, 8.0, "plate")?;
    let bore = extrude(&Profile::circle(Vec2::ZERO, 12.0), &below, 10.0, "bore")?;

    let part = difference(&plate, &bore)?;
    let part = fillet(&part, &[("plate.end", "bore.side")], 1.5, "round")?;

    println!("volume  {:.6} mm³", measure::volume(&part));
    println!("area    {:.6} mm²", measure::area(&part));
    std::fs::write("bracket.step", step::write(&part, "bracket")?)?;
    println!("wrote bracket.step, {} faces", part.face_count());
    Ok(())
}

Best in class02

Results from brep-conformance, an open conformance suite for B-rep kernels. Each case's expected result is derived from closed-form mathematics, not from another kernel's output, and every kernel, springrep included, is held to the same criteria.

leaderboard
    kernelcases by tightest tolerance passed, mmpass at 1e-7 mmpass at 1e-5 mmspeed lower is better