Skip to main content

Crate occt_wasm

Crate occt_wasm 

Source
Expand description

§occt-wasm

OpenCascade CAD kernel via WebAssembly — no C++ toolchain required.

This crate embeds a pre-built WASM binary of the OpenCascade B-Rep CAD kernel and runs it via wasmtime. You get full OCCT functionality (primitives, booleans, sweeps, tessellation, STEP I/O) without installing any C++ compiler, CMake, or OCCT libraries.

§Quick Start

use occt_wasm::OcctKernel;

let mut kernel = OcctKernel::new().unwrap();

// Create shapes
let box_shape = kernel.make_box(10.0, 20.0, 30.0).unwrap();
let sphere = kernel.make_sphere(8.0).unwrap();

// Boolean operations
let result = kernel.fuse(box_shape, sphere).unwrap();

// Query
let volume = kernel.get_volume(result).unwrap();

// Tessellate for rendering
let mesh = kernel.tessellate(result, 0.1, 0.5).unwrap();
println!("vertices: {}, triangles: {}",
    mesh.positions.len() / 3,
    mesh.indices.len() / 3);

// STEP export
let step_data = kernel.export_step(result).unwrap();

§Architecture

The WASM binary is brotli-compressed and embedded via include_bytes!. On first call to OcctKernel::new(), it is decompressed and compiled by wasmtime. Shape data lives in an arena inside the WASM sandbox, referenced by opaque ShapeHandle values.

Re-exports§

pub use error::OcctError;
pub use error::OcctResult;
pub use kernel::OcctKernel;
pub use types::*;

Modules§

error
Error types for the occt-wasm Rust crate.
kernel
WASM host implementation for the OCCT kernel.
types
Data types for the occt-wasm Rust API.