occt_wasm/lib.rs
1//! # occt-wasm
2//!
3//! `OpenCascade` CAD kernel via `WebAssembly` — no C++ toolchain required.
4//!
5//! This crate embeds a pre-built WASM binary of the [OpenCascade](https://github.com/Open-Cascade-SAS/OCCT)
6//! B-Rep CAD kernel and runs it via [wasmtime](https://wasmtime.dev/). You get
7//! full OCCT functionality (primitives, booleans, sweeps, tessellation, STEP I/O)
8//! without installing any C++ compiler, `CMake`, or OCCT libraries.
9//!
10//! # Quick Start
11//!
12//! ```no_run
13//! use occt_wasm::OcctKernel;
14//!
15//! let mut kernel = OcctKernel::new().unwrap();
16//!
17//! // Create shapes
18//! let box_shape = kernel.make_box(10.0, 20.0, 30.0).unwrap();
19//! let sphere = kernel.make_sphere(8.0).unwrap();
20//!
21//! // Boolean operations
22//! let result = kernel.fuse(box_shape, sphere).unwrap();
23//!
24//! // Query
25//! let volume = kernel.get_volume(result).unwrap();
26//!
27//! // Tessellate for rendering
28//! let mesh = kernel.tessellate(result, 0.1, 0.5).unwrap();
29//! println!("vertices: {}, triangles: {}",
30//! mesh.positions.len() / 3,
31//! mesh.indices.len() / 3);
32//!
33//! // STEP export
34//! let step_data = kernel.export_step(result).unwrap();
35//! ```
36//!
37//! # Architecture
38//!
39//! The WASM binary is brotli-compressed and embedded via `include_bytes!`.
40//! On first call to [`OcctKernel::new()`], it is decompressed and compiled
41//! by wasmtime. Shape data lives in an arena inside the WASM sandbox,
42//! referenced by opaque [`ShapeHandle`] values.
43
44#![doc(html_root_url = "https://docs.rs/occt-wasm/3.0.1")]
45// Generated code does cross-boundary integer casting (u32 <-> i32 for WASM ABI)
46// and has parameter names from the C++ facade that trigger similar_names.
47#![allow(
48 clippy::redundant_pub_crate,
49 clippy::cast_possible_wrap,
50 clippy::cast_sign_loss,
51 clippy::cast_possible_truncation,
52 clippy::similar_names,
53 clippy::too_many_arguments
54)]
55
56pub mod error;
57pub mod kernel;
58mod kernel_generated;
59pub mod types;
60
61pub use error::{OcctError, OcctResult};
62pub use kernel::OcctKernel;
63pub use types::*;