Skip to main content

OcctKernel

Struct OcctKernel 

Source
pub struct OcctKernel { /* private fields */ }
Expand description

The OCCT CAD kernel, backed by a sandboxed WASM module.

Create an instance with OcctKernel::new(), then call methods to create and manipulate shapes. All shapes live in an arena inside the WASM module and are referenced by ShapeHandle.

§Example

use occt_wasm::{OcctKernel, ShapeHandle};

let mut kernel = OcctKernel::new().unwrap();
let box_shape = kernel.make_box(10.0, 20.0, 30.0).unwrap();
let volume = kernel.get_volume(box_shape).unwrap();
assert!((volume - 6000.0).abs() < 1.0);

Implementations§

Source§

impl OcctKernel

Source

pub fn new() -> OcctResult<Self>

Create a new OCCT kernel instance.

Decompresses the embedded WASM binary, compiles it with wasmtime, and initializes the OCCT runtime. This takes ~100-500ms depending on the platform.

Examples found in repository?
examples/cli.rs (line 42)
41fn run(step_out: Option<&std::path::Path>) -> Result<(), OcctError> {
42    let mut kernel = OcctKernel::new()?;
43
44    // --- Create shapes ---
45    let box_shape = kernel.make_box(30.0, 20.0, 15.0)?;
46    let cyl = kernel.make_cylinder(6.0, 25.0)?;
47    let sphere = kernel.make_sphere(4.0)?;
48    let moved_sphere = kernel.translate(sphere, 15.0, 10.0, 15.0)?;
49
50    println!("Created: box 30x20x15, cylinder r=6 h=25, sphere r=4");
51
52    // --- Boolean operations ---
53    let with_hole = kernel.cut(box_shape, cyl)?;
54    let final_shape = kernel.fuse(with_hole, moved_sphere)?;
55
56    // --- Measurements ---
57    let vol = kernel.get_volume(final_shape)?;
58    let area = kernel.get_surface_area(final_shape)?;
59    let bbox = kernel.get_bounding_box(final_shape, true)?;
60
61    println!("\nResult:");
62    println!("  Volume:       {vol:.2} mm^3");
63    println!("  Surface area: {area:.2} mm^2");
64    println!(
65        "  Bounding box: [{:.1}, {:.1}, {:.1}] to [{:.1}, {:.1}, {:.1}]",
66        bbox.min.x, bbox.min.y, bbox.min.z, bbox.max.x, bbox.max.y, bbox.max.z
67    );
68
69    // --- Topology counts ---
70    let faces = kernel.get_sub_shapes(final_shape, "Face")?;
71    let edges = kernel.get_sub_shapes(final_shape, "Edge")?;
72    let verts = kernel.get_sub_shapes(final_shape, "Vertex")?;
73    println!(
74        "  Topology:     {} faces, {} edges, {} vertices",
75        faces.len(),
76        edges.len(),
77        verts.len()
78    );
79
80    // --- Tessellate (renderer-ready mesh) ---
81    let mesh = kernel.tessellate(final_shape, 0.1, 0.5)?;
82    println!(
83        "  Mesh:         {} vertices, {} triangles",
84        mesh.positions.len() / 3,
85        mesh.indices.len() / 3
86    );
87
88    // --- STEP export ---
89    let step_data = kernel.export_step(final_shape)?;
90    if let Some(path) = step_out {
91        fs::write(path, &step_data).map_err(|e| OcctError::Operation {
92            operation: "export_step_write".to_owned(),
93            message: format!("write {}: {e}", path.display()),
94        })?;
95        println!("\nSTEP exported to: {}", path.display());
96    } else {
97        println!("\nTip: pass --step output.step to export the result");
98    }
99
100    // --- STEP round-trip ---
101    let reimported = kernel.import_step(&step_data)?;
102    let reimported_vol = kernel.get_volume(reimported)?;
103    println!(
104        "  Round-trip:   export -> import, volume delta = {:.6}",
105        (vol - reimported_vol).abs()
106    );
107
108    Ok(())
109}
Source§

impl OcctKernel

Generated kernel methods.

All facade methods wrapped as safe Rust functions.

Source

pub fn make_box(&mut self, dx: f64, dy: f64, dz: f64) -> OcctResult<ShapeHandle>

Examples found in repository?
examples/cli.rs (line 45)
41fn run(step_out: Option<&std::path::Path>) -> Result<(), OcctError> {
42    let mut kernel = OcctKernel::new()?;
43
44    // --- Create shapes ---
45    let box_shape = kernel.make_box(30.0, 20.0, 15.0)?;
46    let cyl = kernel.make_cylinder(6.0, 25.0)?;
47    let sphere = kernel.make_sphere(4.0)?;
48    let moved_sphere = kernel.translate(sphere, 15.0, 10.0, 15.0)?;
49
50    println!("Created: box 30x20x15, cylinder r=6 h=25, sphere r=4");
51
52    // --- Boolean operations ---
53    let with_hole = kernel.cut(box_shape, cyl)?;
54    let final_shape = kernel.fuse(with_hole, moved_sphere)?;
55
56    // --- Measurements ---
57    let vol = kernel.get_volume(final_shape)?;
58    let area = kernel.get_surface_area(final_shape)?;
59    let bbox = kernel.get_bounding_box(final_shape, true)?;
60
61    println!("\nResult:");
62    println!("  Volume:       {vol:.2} mm^3");
63    println!("  Surface area: {area:.2} mm^2");
64    println!(
65        "  Bounding box: [{:.1}, {:.1}, {:.1}] to [{:.1}, {:.1}, {:.1}]",
66        bbox.min.x, bbox.min.y, bbox.min.z, bbox.max.x, bbox.max.y, bbox.max.z
67    );
68
69    // --- Topology counts ---
70    let faces = kernel.get_sub_shapes(final_shape, "Face")?;
71    let edges = kernel.get_sub_shapes(final_shape, "Edge")?;
72    let verts = kernel.get_sub_shapes(final_shape, "Vertex")?;
73    println!(
74        "  Topology:     {} faces, {} edges, {} vertices",
75        faces.len(),
76        edges.len(),
77        verts.len()
78    );
79
80    // --- Tessellate (renderer-ready mesh) ---
81    let mesh = kernel.tessellate(final_shape, 0.1, 0.5)?;
82    println!(
83        "  Mesh:         {} vertices, {} triangles",
84        mesh.positions.len() / 3,
85        mesh.indices.len() / 3
86    );
87
88    // --- STEP export ---
89    let step_data = kernel.export_step(final_shape)?;
90    if let Some(path) = step_out {
91        fs::write(path, &step_data).map_err(|e| OcctError::Operation {
92            operation: "export_step_write".to_owned(),
93            message: format!("write {}: {e}", path.display()),
94        })?;
95        println!("\nSTEP exported to: {}", path.display());
96    } else {
97        println!("\nTip: pass --step output.step to export the result");
98    }
99
100    // --- STEP round-trip ---
101    let reimported = kernel.import_step(&step_data)?;
102    let reimported_vol = kernel.get_volume(reimported)?;
103    println!(
104        "  Round-trip:   export -> import, volume delta = {:.6}",
105        (vol - reimported_vol).abs()
106    );
107
108    Ok(())
109}
Source

pub fn make_box_from_corners( &mut self, x1: f64, y1: f64, z1: f64, x2: f64, y2: f64, z2: f64, ) -> OcctResult<ShapeHandle>

Source

pub fn make_cylinder( &mut self, radius: f64, height: f64, ) -> OcctResult<ShapeHandle>

Examples found in repository?
examples/cli.rs (line 46)
41fn run(step_out: Option<&std::path::Path>) -> Result<(), OcctError> {
42    let mut kernel = OcctKernel::new()?;
43
44    // --- Create shapes ---
45    let box_shape = kernel.make_box(30.0, 20.0, 15.0)?;
46    let cyl = kernel.make_cylinder(6.0, 25.0)?;
47    let sphere = kernel.make_sphere(4.0)?;
48    let moved_sphere = kernel.translate(sphere, 15.0, 10.0, 15.0)?;
49
50    println!("Created: box 30x20x15, cylinder r=6 h=25, sphere r=4");
51
52    // --- Boolean operations ---
53    let with_hole = kernel.cut(box_shape, cyl)?;
54    let final_shape = kernel.fuse(with_hole, moved_sphere)?;
55
56    // --- Measurements ---
57    let vol = kernel.get_volume(final_shape)?;
58    let area = kernel.get_surface_area(final_shape)?;
59    let bbox = kernel.get_bounding_box(final_shape, true)?;
60
61    println!("\nResult:");
62    println!("  Volume:       {vol:.2} mm^3");
63    println!("  Surface area: {area:.2} mm^2");
64    println!(
65        "  Bounding box: [{:.1}, {:.1}, {:.1}] to [{:.1}, {:.1}, {:.1}]",
66        bbox.min.x, bbox.min.y, bbox.min.z, bbox.max.x, bbox.max.y, bbox.max.z
67    );
68
69    // --- Topology counts ---
70    let faces = kernel.get_sub_shapes(final_shape, "Face")?;
71    let edges = kernel.get_sub_shapes(final_shape, "Edge")?;
72    let verts = kernel.get_sub_shapes(final_shape, "Vertex")?;
73    println!(
74        "  Topology:     {} faces, {} edges, {} vertices",
75        faces.len(),
76        edges.len(),
77        verts.len()
78    );
79
80    // --- Tessellate (renderer-ready mesh) ---
81    let mesh = kernel.tessellate(final_shape, 0.1, 0.5)?;
82    println!(
83        "  Mesh:         {} vertices, {} triangles",
84        mesh.positions.len() / 3,
85        mesh.indices.len() / 3
86    );
87
88    // --- STEP export ---
89    let step_data = kernel.export_step(final_shape)?;
90    if let Some(path) = step_out {
91        fs::write(path, &step_data).map_err(|e| OcctError::Operation {
92            operation: "export_step_write".to_owned(),
93            message: format!("write {}: {e}", path.display()),
94        })?;
95        println!("\nSTEP exported to: {}", path.display());
96    } else {
97        println!("\nTip: pass --step output.step to export the result");
98    }
99
100    // --- STEP round-trip ---
101    let reimported = kernel.import_step(&step_data)?;
102    let reimported_vol = kernel.get_volume(reimported)?;
103    println!(
104        "  Round-trip:   export -> import, volume delta = {:.6}",
105        (vol - reimported_vol).abs()
106    );
107
108    Ok(())
109}
Source

pub fn make_sphere(&mut self, radius: f64) -> OcctResult<ShapeHandle>

Examples found in repository?
examples/cli.rs (line 47)
41fn run(step_out: Option<&std::path::Path>) -> Result<(), OcctError> {
42    let mut kernel = OcctKernel::new()?;
43
44    // --- Create shapes ---
45    let box_shape = kernel.make_box(30.0, 20.0, 15.0)?;
46    let cyl = kernel.make_cylinder(6.0, 25.0)?;
47    let sphere = kernel.make_sphere(4.0)?;
48    let moved_sphere = kernel.translate(sphere, 15.0, 10.0, 15.0)?;
49
50    println!("Created: box 30x20x15, cylinder r=6 h=25, sphere r=4");
51
52    // --- Boolean operations ---
53    let with_hole = kernel.cut(box_shape, cyl)?;
54    let final_shape = kernel.fuse(with_hole, moved_sphere)?;
55
56    // --- Measurements ---
57    let vol = kernel.get_volume(final_shape)?;
58    let area = kernel.get_surface_area(final_shape)?;
59    let bbox = kernel.get_bounding_box(final_shape, true)?;
60
61    println!("\nResult:");
62    println!("  Volume:       {vol:.2} mm^3");
63    println!("  Surface area: {area:.2} mm^2");
64    println!(
65        "  Bounding box: [{:.1}, {:.1}, {:.1}] to [{:.1}, {:.1}, {:.1}]",
66        bbox.min.x, bbox.min.y, bbox.min.z, bbox.max.x, bbox.max.y, bbox.max.z
67    );
68
69    // --- Topology counts ---
70    let faces = kernel.get_sub_shapes(final_shape, "Face")?;
71    let edges = kernel.get_sub_shapes(final_shape, "Edge")?;
72    let verts = kernel.get_sub_shapes(final_shape, "Vertex")?;
73    println!(
74        "  Topology:     {} faces, {} edges, {} vertices",
75        faces.len(),
76        edges.len(),
77        verts.len()
78    );
79
80    // --- Tessellate (renderer-ready mesh) ---
81    let mesh = kernel.tessellate(final_shape, 0.1, 0.5)?;
82    println!(
83        "  Mesh:         {} vertices, {} triangles",
84        mesh.positions.len() / 3,
85        mesh.indices.len() / 3
86    );
87
88    // --- STEP export ---
89    let step_data = kernel.export_step(final_shape)?;
90    if let Some(path) = step_out {
91        fs::write(path, &step_data).map_err(|e| OcctError::Operation {
92            operation: "export_step_write".to_owned(),
93            message: format!("write {}: {e}", path.display()),
94        })?;
95        println!("\nSTEP exported to: {}", path.display());
96    } else {
97        println!("\nTip: pass --step output.step to export the result");
98    }
99
100    // --- STEP round-trip ---
101    let reimported = kernel.import_step(&step_data)?;
102    let reimported_vol = kernel.get_volume(reimported)?;
103    println!(
104        "  Round-trip:   export -> import, volume delta = {:.6}",
105        (vol - reimported_vol).abs()
106    );
107
108    Ok(())
109}
Source

pub fn make_cone( &mut self, r1: f64, r2: f64, height: f64, ) -> OcctResult<ShapeHandle>

Source

pub fn make_torus( &mut self, major_radius: f64, minor_radius: f64, ) -> OcctResult<ShapeHandle>

Source

pub fn make_ellipsoid( &mut self, rx: f64, ry: f64, rz: f64, ) -> OcctResult<ShapeHandle>

Source

pub fn make_rectangle( &mut self, width: f64, height: f64, ) -> OcctResult<ShapeHandle>

Source

pub fn fuse( &mut self, a: ShapeHandle, b: ShapeHandle, ) -> OcctResult<ShapeHandle>

Examples found in repository?
examples/cli.rs (line 54)
41fn run(step_out: Option<&std::path::Path>) -> Result<(), OcctError> {
42    let mut kernel = OcctKernel::new()?;
43
44    // --- Create shapes ---
45    let box_shape = kernel.make_box(30.0, 20.0, 15.0)?;
46    let cyl = kernel.make_cylinder(6.0, 25.0)?;
47    let sphere = kernel.make_sphere(4.0)?;
48    let moved_sphere = kernel.translate(sphere, 15.0, 10.0, 15.0)?;
49
50    println!("Created: box 30x20x15, cylinder r=6 h=25, sphere r=4");
51
52    // --- Boolean operations ---
53    let with_hole = kernel.cut(box_shape, cyl)?;
54    let final_shape = kernel.fuse(with_hole, moved_sphere)?;
55
56    // --- Measurements ---
57    let vol = kernel.get_volume(final_shape)?;
58    let area = kernel.get_surface_area(final_shape)?;
59    let bbox = kernel.get_bounding_box(final_shape, true)?;
60
61    println!("\nResult:");
62    println!("  Volume:       {vol:.2} mm^3");
63    println!("  Surface area: {area:.2} mm^2");
64    println!(
65        "  Bounding box: [{:.1}, {:.1}, {:.1}] to [{:.1}, {:.1}, {:.1}]",
66        bbox.min.x, bbox.min.y, bbox.min.z, bbox.max.x, bbox.max.y, bbox.max.z
67    );
68
69    // --- Topology counts ---
70    let faces = kernel.get_sub_shapes(final_shape, "Face")?;
71    let edges = kernel.get_sub_shapes(final_shape, "Edge")?;
72    let verts = kernel.get_sub_shapes(final_shape, "Vertex")?;
73    println!(
74        "  Topology:     {} faces, {} edges, {} vertices",
75        faces.len(),
76        edges.len(),
77        verts.len()
78    );
79
80    // --- Tessellate (renderer-ready mesh) ---
81    let mesh = kernel.tessellate(final_shape, 0.1, 0.5)?;
82    println!(
83        "  Mesh:         {} vertices, {} triangles",
84        mesh.positions.len() / 3,
85        mesh.indices.len() / 3
86    );
87
88    // --- STEP export ---
89    let step_data = kernel.export_step(final_shape)?;
90    if let Some(path) = step_out {
91        fs::write(path, &step_data).map_err(|e| OcctError::Operation {
92            operation: "export_step_write".to_owned(),
93            message: format!("write {}: {e}", path.display()),
94        })?;
95        println!("\nSTEP exported to: {}", path.display());
96    } else {
97        println!("\nTip: pass --step output.step to export the result");
98    }
99
100    // --- STEP round-trip ---
101    let reimported = kernel.import_step(&step_data)?;
102    let reimported_vol = kernel.get_volume(reimported)?;
103    println!(
104        "  Round-trip:   export -> import, volume delta = {:.6}",
105        (vol - reimported_vol).abs()
106    );
107
108    Ok(())
109}
Source

pub fn cut(&mut self, a: ShapeHandle, b: ShapeHandle) -> OcctResult<ShapeHandle>

Examples found in repository?
examples/cli.rs (line 53)
41fn run(step_out: Option<&std::path::Path>) -> Result<(), OcctError> {
42    let mut kernel = OcctKernel::new()?;
43
44    // --- Create shapes ---
45    let box_shape = kernel.make_box(30.0, 20.0, 15.0)?;
46    let cyl = kernel.make_cylinder(6.0, 25.0)?;
47    let sphere = kernel.make_sphere(4.0)?;
48    let moved_sphere = kernel.translate(sphere, 15.0, 10.0, 15.0)?;
49
50    println!("Created: box 30x20x15, cylinder r=6 h=25, sphere r=4");
51
52    // --- Boolean operations ---
53    let with_hole = kernel.cut(box_shape, cyl)?;
54    let final_shape = kernel.fuse(with_hole, moved_sphere)?;
55
56    // --- Measurements ---
57    let vol = kernel.get_volume(final_shape)?;
58    let area = kernel.get_surface_area(final_shape)?;
59    let bbox = kernel.get_bounding_box(final_shape, true)?;
60
61    println!("\nResult:");
62    println!("  Volume:       {vol:.2} mm^3");
63    println!("  Surface area: {area:.2} mm^2");
64    println!(
65        "  Bounding box: [{:.1}, {:.1}, {:.1}] to [{:.1}, {:.1}, {:.1}]",
66        bbox.min.x, bbox.min.y, bbox.min.z, bbox.max.x, bbox.max.y, bbox.max.z
67    );
68
69    // --- Topology counts ---
70    let faces = kernel.get_sub_shapes(final_shape, "Face")?;
71    let edges = kernel.get_sub_shapes(final_shape, "Edge")?;
72    let verts = kernel.get_sub_shapes(final_shape, "Vertex")?;
73    println!(
74        "  Topology:     {} faces, {} edges, {} vertices",
75        faces.len(),
76        edges.len(),
77        verts.len()
78    );
79
80    // --- Tessellate (renderer-ready mesh) ---
81    let mesh = kernel.tessellate(final_shape, 0.1, 0.5)?;
82    println!(
83        "  Mesh:         {} vertices, {} triangles",
84        mesh.positions.len() / 3,
85        mesh.indices.len() / 3
86    );
87
88    // --- STEP export ---
89    let step_data = kernel.export_step(final_shape)?;
90    if let Some(path) = step_out {
91        fs::write(path, &step_data).map_err(|e| OcctError::Operation {
92            operation: "export_step_write".to_owned(),
93            message: format!("write {}: {e}", path.display()),
94        })?;
95        println!("\nSTEP exported to: {}", path.display());
96    } else {
97        println!("\nTip: pass --step output.step to export the result");
98    }
99
100    // --- STEP round-trip ---
101    let reimported = kernel.import_step(&step_data)?;
102    let reimported_vol = kernel.get_volume(reimported)?;
103    println!(
104        "  Round-trip:   export -> import, volume delta = {:.6}",
105        (vol - reimported_vol).abs()
106    );
107
108    Ok(())
109}
Source

pub fn common( &mut self, a: ShapeHandle, b: ShapeHandle, ) -> OcctResult<ShapeHandle>

Source

pub fn section( &mut self, a: ShapeHandle, b: ShapeHandle, ) -> OcctResult<ShapeHandle>

Source

pub fn intersect( &mut self, a: ShapeHandle, b: ShapeHandle, ) -> OcctResult<ShapeHandle>

Source

pub fn fuse_all(&mut self, shape_ids: &[ShapeHandle]) -> OcctResult<ShapeHandle>

Source

pub fn cut_all( &mut self, shape_id: ShapeHandle, tool_ids: &[ShapeHandle], ) -> OcctResult<ShapeHandle>

Source

pub fn boolean_pipeline( &mut self, base_id: ShapeHandle, op_codes: &[i32], tool_ids: &[ShapeHandle], ) -> OcctResult<ShapeHandle>

Source

pub fn split( &mut self, shape_id: ShapeHandle, tool_ids: &[ShapeHandle], ) -> OcctResult<ShapeHandle>

Source

pub fn extrude( &mut self, shape_id: ShapeHandle, dx: f64, dy: f64, dz: f64, ) -> OcctResult<ShapeHandle>

Source

pub fn revolve( &mut self, shape_id: ShapeHandle, px: f64, py: f64, pz: f64, dx: f64, dy: f64, dz: f64, angle_rad: f64, ) -> OcctResult<ShapeHandle>

Source

pub fn fillet( &mut self, solid_id: ShapeHandle, edge_ids: &[ShapeHandle], radius: f64, ) -> OcctResult<ShapeHandle>

Source

pub fn chamfer( &mut self, solid_id: ShapeHandle, edge_ids: &[ShapeHandle], distance: f64, ) -> OcctResult<ShapeHandle>

Source

pub fn chamfer_dist_angle( &mut self, solid_id: ShapeHandle, edge_ids: &[ShapeHandle], distance: f64, angle_deg: f64, ) -> OcctResult<ShapeHandle>

Source

pub fn shell( &mut self, solid_id: ShapeHandle, face_ids: &[ShapeHandle], thickness: f64, tolerance: f64, ) -> OcctResult<ShapeHandle>

Source

pub fn offset( &mut self, solid_id: ShapeHandle, distance: f64, tolerance: f64, ) -> OcctResult<ShapeHandle>

Source

pub fn draft( &mut self, shape_id: ShapeHandle, face_id: ShapeHandle, angle_rad: f64, dx: f64, dy: f64, dz: f64, ) -> OcctResult<ShapeHandle>

Source

pub fn thicken( &mut self, shape_id: ShapeHandle, thickness: f64, tolerance: f64, ) -> OcctResult<ShapeHandle>

Source

pub fn defeature( &mut self, shape_id: ShapeHandle, face_ids: &[ShapeHandle], tolerance: f64, ) -> OcctResult<ShapeHandle>

Source

pub fn reverse_shape(&mut self, id: ShapeHandle) -> OcctResult<ShapeHandle>

Source

pub fn simplify(&mut self, id: ShapeHandle) -> OcctResult<ShapeHandle>

Source

pub fn fillet_variable( &mut self, solid_id: ShapeHandle, edge_id: ShapeHandle, start_radius: f64, end_radius: f64, ) -> OcctResult<ShapeHandle>

Source

pub fn fillet_batch( &mut self, solid_ids: &[ShapeHandle], edge_counts: &[i32], flat_edge_ids: &[ShapeHandle], radii: &[f64], ) -> OcctResult<Vec<u32>>

Source

pub fn offset_wire2_d( &mut self, wire_id: ShapeHandle, offset: f64, join_type: i32, ) -> OcctResult<ShapeHandle>

Source

pub fn translate( &mut self, id: ShapeHandle, dx: f64, dy: f64, dz: f64, ) -> OcctResult<ShapeHandle>

Examples found in repository?
examples/cli.rs (line 48)
41fn run(step_out: Option<&std::path::Path>) -> Result<(), OcctError> {
42    let mut kernel = OcctKernel::new()?;
43
44    // --- Create shapes ---
45    let box_shape = kernel.make_box(30.0, 20.0, 15.0)?;
46    let cyl = kernel.make_cylinder(6.0, 25.0)?;
47    let sphere = kernel.make_sphere(4.0)?;
48    let moved_sphere = kernel.translate(sphere, 15.0, 10.0, 15.0)?;
49
50    println!("Created: box 30x20x15, cylinder r=6 h=25, sphere r=4");
51
52    // --- Boolean operations ---
53    let with_hole = kernel.cut(box_shape, cyl)?;
54    let final_shape = kernel.fuse(with_hole, moved_sphere)?;
55
56    // --- Measurements ---
57    let vol = kernel.get_volume(final_shape)?;
58    let area = kernel.get_surface_area(final_shape)?;
59    let bbox = kernel.get_bounding_box(final_shape, true)?;
60
61    println!("\nResult:");
62    println!("  Volume:       {vol:.2} mm^3");
63    println!("  Surface area: {area:.2} mm^2");
64    println!(
65        "  Bounding box: [{:.1}, {:.1}, {:.1}] to [{:.1}, {:.1}, {:.1}]",
66        bbox.min.x, bbox.min.y, bbox.min.z, bbox.max.x, bbox.max.y, bbox.max.z
67    );
68
69    // --- Topology counts ---
70    let faces = kernel.get_sub_shapes(final_shape, "Face")?;
71    let edges = kernel.get_sub_shapes(final_shape, "Edge")?;
72    let verts = kernel.get_sub_shapes(final_shape, "Vertex")?;
73    println!(
74        "  Topology:     {} faces, {} edges, {} vertices",
75        faces.len(),
76        edges.len(),
77        verts.len()
78    );
79
80    // --- Tessellate (renderer-ready mesh) ---
81    let mesh = kernel.tessellate(final_shape, 0.1, 0.5)?;
82    println!(
83        "  Mesh:         {} vertices, {} triangles",
84        mesh.positions.len() / 3,
85        mesh.indices.len() / 3
86    );
87
88    // --- STEP export ---
89    let step_data = kernel.export_step(final_shape)?;
90    if let Some(path) = step_out {
91        fs::write(path, &step_data).map_err(|e| OcctError::Operation {
92            operation: "export_step_write".to_owned(),
93            message: format!("write {}: {e}", path.display()),
94        })?;
95        println!("\nSTEP exported to: {}", path.display());
96    } else {
97        println!("\nTip: pass --step output.step to export the result");
98    }
99
100    // --- STEP round-trip ---
101    let reimported = kernel.import_step(&step_data)?;
102    let reimported_vol = kernel.get_volume(reimported)?;
103    println!(
104        "  Round-trip:   export -> import, volume delta = {:.6}",
105        (vol - reimported_vol).abs()
106    );
107
108    Ok(())
109}
Source

pub fn rotate( &mut self, id: ShapeHandle, px: f64, py: f64, pz: f64, dx: f64, dy: f64, dz: f64, angle_rad: f64, ) -> OcctResult<ShapeHandle>

Source

pub fn scale( &mut self, id: ShapeHandle, px: f64, py: f64, pz: f64, factor: f64, ) -> OcctResult<ShapeHandle>

Source

pub fn mirror( &mut self, id: ShapeHandle, px: f64, py: f64, pz: f64, nx: f64, ny: f64, nz: f64, ) -> OcctResult<ShapeHandle>

Source

pub fn copy(&mut self, id: ShapeHandle) -> OcctResult<ShapeHandle>

Source

pub fn linear_pattern( &mut self, id: ShapeHandle, dx: f64, dy: f64, dz: f64, spacing: f64, count: i32, ) -> OcctResult<ShapeHandle>

Source

pub fn circular_pattern( &mut self, id: ShapeHandle, cx: f64, cy: f64, cz: f64, ax: f64, ay: f64, az: f64, angle: f64, count: i32, ) -> OcctResult<ShapeHandle>

Source

pub fn transform( &mut self, id: ShapeHandle, matrix: &[f64], ) -> OcctResult<ShapeHandle>

Source

pub fn general_transform( &mut self, id: ShapeHandle, matrix: &[f64], ) -> OcctResult<ShapeHandle>

Source

pub fn translate_batch( &mut self, ids: &[ShapeHandle], offsets: &[f64], ) -> OcctResult<Vec<u32>>

Source

pub fn compose_transform( &mut self, m1: &[f64], m2: &[f64], ) -> OcctResult<Vec<f64>>

Source

pub fn transform_batch( &mut self, ids: &[ShapeHandle], matrices: &[f64], ) -> OcctResult<Vec<u32>>

Source

pub fn rotate_batch( &mut self, ids: &[ShapeHandle], params: &[f64], ) -> OcctResult<Vec<u32>>

Source

pub fn scale_batch( &mut self, ids: &[ShapeHandle], params: &[f64], ) -> OcctResult<Vec<u32>>

Source

pub fn mirror_batch( &mut self, ids: &[ShapeHandle], params: &[f64], ) -> OcctResult<Vec<u32>>

Source

pub fn make_vertex(&mut self, x: f64, y: f64, z: f64) -> OcctResult<ShapeHandle>

Source

pub fn make_edge( &mut self, v1: ShapeHandle, v2: ShapeHandle, ) -> OcctResult<ShapeHandle>

Source

pub fn make_wire(&mut self, edge_ids: &[ShapeHandle]) -> OcctResult<ShapeHandle>

Source

pub fn make_face(&mut self, wire_id: ShapeHandle) -> OcctResult<ShapeHandle>

Source

pub fn make_face_on_surface( &mut self, face_id: ShapeHandle, wire_id: ShapeHandle, ) -> OcctResult<ShapeHandle>

Source

pub fn make_solid(&mut self, shell_id: ShapeHandle) -> OcctResult<ShapeHandle>

Source

pub fn sew( &mut self, shape_ids: &[ShapeHandle], tolerance: f64, ) -> OcctResult<ShapeHandle>

Source

pub fn make_compound( &mut self, shape_ids: &[ShapeHandle], ) -> OcctResult<ShapeHandle>

Source

pub fn make_line_edge( &mut self, x1: f64, y1: f64, z1: f64, x2: f64, y2: f64, z2: f64, ) -> OcctResult<ShapeHandle>

Source

pub fn make_circle_edge( &mut self, cx: f64, cy: f64, cz: f64, nx: f64, ny: f64, nz: f64, radius: f64, ) -> OcctResult<ShapeHandle>

Source

pub fn make_circle_arc( &mut self, cx: f64, cy: f64, cz: f64, nx: f64, ny: f64, nz: f64, radius: f64, start_angle: f64, end_angle: f64, ) -> OcctResult<ShapeHandle>

Source

pub fn make_arc_edge( &mut self, x1: f64, y1: f64, z1: f64, x2: f64, y2: f64, z2: f64, x3: f64, y3: f64, z3: f64, ) -> OcctResult<ShapeHandle>

Source

pub fn make_ellipse_edge( &mut self, cx: f64, cy: f64, cz: f64, nx: f64, ny: f64, nz: f64, major_radius: f64, minor_radius: f64, ) -> OcctResult<ShapeHandle>

Source

pub fn make_bezier_edge( &mut self, flat_points: &[f64], ) -> OcctResult<ShapeHandle>

Source

pub fn make_ellipse_arc( &mut self, cx: f64, cy: f64, cz: f64, nx: f64, ny: f64, nz: f64, major_radius: f64, minor_radius: f64, start_angle: f64, end_angle: f64, ) -> OcctResult<ShapeHandle>

Source

pub fn make_helix_wire( &mut self, px: f64, py: f64, pz: f64, dx: f64, dy: f64, dz: f64, pitch: f64, height: f64, radius: f64, ) -> OcctResult<ShapeHandle>

Source

pub fn make_non_planar_face( &mut self, wire_id: ShapeHandle, ) -> OcctResult<ShapeHandle>

Source

pub fn add_holes_in_face( &mut self, face_id: ShapeHandle, hole_wire_ids: &[ShapeHandle], ) -> OcctResult<ShapeHandle>

Source

pub fn remove_holes_from_face( &mut self, face_id: ShapeHandle, hole_indices: &[i32], ) -> OcctResult<ShapeHandle>

Source

pub fn solid_from_shell( &mut self, shell_id: ShapeHandle, ) -> OcctResult<ShapeHandle>

Source

pub fn build_solid_from_faces( &mut self, face_ids: &[ShapeHandle], tolerance: f64, ) -> OcctResult<ShapeHandle>

Source

pub fn sew_and_solidify( &mut self, face_ids: &[ShapeHandle], tolerance: f64, ) -> OcctResult<ShapeHandle>

Source

pub fn build_tri_face( &mut self, ax: f64, ay: f64, az: f64, bx: f64, by: f64, bz: f64, cx2: f64, cy2: f64, cz2: f64, ) -> OcctResult<ShapeHandle>

Source

pub fn make_tangent_arc( &mut self, x1: f64, y1: f64, z1: f64, tx: f64, ty: f64, tz: f64, x2: f64, y2: f64, z2: f64, ) -> OcctResult<ShapeHandle>

Source

pub fn bspline_surface( &mut self, flat_points: &[f64], rows: i32, cols: i32, ) -> OcctResult<ShapeHandle>

Source

pub fn get_shape_type(&mut self, id: ShapeHandle) -> OcctResult<String>

Source

pub fn get_sub_shapes( &mut self, id: ShapeHandle, shape_type: &str, ) -> OcctResult<Vec<u32>>

Examples found in repository?
examples/cli.rs (line 70)
41fn run(step_out: Option<&std::path::Path>) -> Result<(), OcctError> {
42    let mut kernel = OcctKernel::new()?;
43
44    // --- Create shapes ---
45    let box_shape = kernel.make_box(30.0, 20.0, 15.0)?;
46    let cyl = kernel.make_cylinder(6.0, 25.0)?;
47    let sphere = kernel.make_sphere(4.0)?;
48    let moved_sphere = kernel.translate(sphere, 15.0, 10.0, 15.0)?;
49
50    println!("Created: box 30x20x15, cylinder r=6 h=25, sphere r=4");
51
52    // --- Boolean operations ---
53    let with_hole = kernel.cut(box_shape, cyl)?;
54    let final_shape = kernel.fuse(with_hole, moved_sphere)?;
55
56    // --- Measurements ---
57    let vol = kernel.get_volume(final_shape)?;
58    let area = kernel.get_surface_area(final_shape)?;
59    let bbox = kernel.get_bounding_box(final_shape, true)?;
60
61    println!("\nResult:");
62    println!("  Volume:       {vol:.2} mm^3");
63    println!("  Surface area: {area:.2} mm^2");
64    println!(
65        "  Bounding box: [{:.1}, {:.1}, {:.1}] to [{:.1}, {:.1}, {:.1}]",
66        bbox.min.x, bbox.min.y, bbox.min.z, bbox.max.x, bbox.max.y, bbox.max.z
67    );
68
69    // --- Topology counts ---
70    let faces = kernel.get_sub_shapes(final_shape, "Face")?;
71    let edges = kernel.get_sub_shapes(final_shape, "Edge")?;
72    let verts = kernel.get_sub_shapes(final_shape, "Vertex")?;
73    println!(
74        "  Topology:     {} faces, {} edges, {} vertices",
75        faces.len(),
76        edges.len(),
77        verts.len()
78    );
79
80    // --- Tessellate (renderer-ready mesh) ---
81    let mesh = kernel.tessellate(final_shape, 0.1, 0.5)?;
82    println!(
83        "  Mesh:         {} vertices, {} triangles",
84        mesh.positions.len() / 3,
85        mesh.indices.len() / 3
86    );
87
88    // --- STEP export ---
89    let step_data = kernel.export_step(final_shape)?;
90    if let Some(path) = step_out {
91        fs::write(path, &step_data).map_err(|e| OcctError::Operation {
92            operation: "export_step_write".to_owned(),
93            message: format!("write {}: {e}", path.display()),
94        })?;
95        println!("\nSTEP exported to: {}", path.display());
96    } else {
97        println!("\nTip: pass --step output.step to export the result");
98    }
99
100    // --- STEP round-trip ---
101    let reimported = kernel.import_step(&step_data)?;
102    let reimported_vol = kernel.get_volume(reimported)?;
103    println!(
104        "  Round-trip:   export -> import, volume delta = {:.6}",
105        (vol - reimported_vol).abs()
106    );
107
108    Ok(())
109}
Source

pub fn distance_between( &mut self, a: ShapeHandle, b: ShapeHandle, ) -> OcctResult<f64>

Source

pub fn is_same(&mut self, a: ShapeHandle, b: ShapeHandle) -> OcctResult<bool>

Source

pub fn is_equal(&mut self, a: ShapeHandle, b: ShapeHandle) -> OcctResult<bool>

Source

pub fn is_null(&mut self, id: ShapeHandle) -> OcctResult<bool>

Source

pub fn hash_code( &mut self, id: ShapeHandle, upper_bound: i32, ) -> OcctResult<i32>

Source

pub fn shape_orientation(&mut self, id: ShapeHandle) -> OcctResult<String>

Source

pub fn iter_shapes(&mut self, id: ShapeHandle) -> OcctResult<Vec<u32>>

Source

pub fn edge_to_face_map( &mut self, id: ShapeHandle, hash_upper_bound: i32, ) -> OcctResult<Vec<i32>>

Source

pub fn downcast( &mut self, id: ShapeHandle, target_type: &str, ) -> OcctResult<ShapeHandle>

Source

pub fn adjacent_faces( &mut self, shape_id: ShapeHandle, face_id: ShapeHandle, ) -> OcctResult<Vec<u32>>

Source

pub fn shared_edges( &mut self, face_a: ShapeHandle, face_b: ShapeHandle, ) -> OcctResult<Vec<u32>>

Source

pub fn get_bounding_box( &mut self, id: ShapeHandle, use_triangulation: bool, ) -> OcctResult<BoundingBox>

Examples found in repository?
examples/cli.rs (line 59)
41fn run(step_out: Option<&std::path::Path>) -> Result<(), OcctError> {
42    let mut kernel = OcctKernel::new()?;
43
44    // --- Create shapes ---
45    let box_shape = kernel.make_box(30.0, 20.0, 15.0)?;
46    let cyl = kernel.make_cylinder(6.0, 25.0)?;
47    let sphere = kernel.make_sphere(4.0)?;
48    let moved_sphere = kernel.translate(sphere, 15.0, 10.0, 15.0)?;
49
50    println!("Created: box 30x20x15, cylinder r=6 h=25, sphere r=4");
51
52    // --- Boolean operations ---
53    let with_hole = kernel.cut(box_shape, cyl)?;
54    let final_shape = kernel.fuse(with_hole, moved_sphere)?;
55
56    // --- Measurements ---
57    let vol = kernel.get_volume(final_shape)?;
58    let area = kernel.get_surface_area(final_shape)?;
59    let bbox = kernel.get_bounding_box(final_shape, true)?;
60
61    println!("\nResult:");
62    println!("  Volume:       {vol:.2} mm^3");
63    println!("  Surface area: {area:.2} mm^2");
64    println!(
65        "  Bounding box: [{:.1}, {:.1}, {:.1}] to [{:.1}, {:.1}, {:.1}]",
66        bbox.min.x, bbox.min.y, bbox.min.z, bbox.max.x, bbox.max.y, bbox.max.z
67    );
68
69    // --- Topology counts ---
70    let faces = kernel.get_sub_shapes(final_shape, "Face")?;
71    let edges = kernel.get_sub_shapes(final_shape, "Edge")?;
72    let verts = kernel.get_sub_shapes(final_shape, "Vertex")?;
73    println!(
74        "  Topology:     {} faces, {} edges, {} vertices",
75        faces.len(),
76        edges.len(),
77        verts.len()
78    );
79
80    // --- Tessellate (renderer-ready mesh) ---
81    let mesh = kernel.tessellate(final_shape, 0.1, 0.5)?;
82    println!(
83        "  Mesh:         {} vertices, {} triangles",
84        mesh.positions.len() / 3,
85        mesh.indices.len() / 3
86    );
87
88    // --- STEP export ---
89    let step_data = kernel.export_step(final_shape)?;
90    if let Some(path) = step_out {
91        fs::write(path, &step_data).map_err(|e| OcctError::Operation {
92            operation: "export_step_write".to_owned(),
93            message: format!("write {}: {e}", path.display()),
94        })?;
95        println!("\nSTEP exported to: {}", path.display());
96    } else {
97        println!("\nTip: pass --step output.step to export the result");
98    }
99
100    // --- STEP round-trip ---
101    let reimported = kernel.import_step(&step_data)?;
102    let reimported_vol = kernel.get_volume(reimported)?;
103    println!(
104        "  Round-trip:   export -> import, volume delta = {:.6}",
105        (vol - reimported_vol).abs()
106    );
107
108    Ok(())
109}
Source

pub fn get_volume(&mut self, id: ShapeHandle) -> OcctResult<f64>

Examples found in repository?
examples/cli.rs (line 57)
41fn run(step_out: Option<&std::path::Path>) -> Result<(), OcctError> {
42    let mut kernel = OcctKernel::new()?;
43
44    // --- Create shapes ---
45    let box_shape = kernel.make_box(30.0, 20.0, 15.0)?;
46    let cyl = kernel.make_cylinder(6.0, 25.0)?;
47    let sphere = kernel.make_sphere(4.0)?;
48    let moved_sphere = kernel.translate(sphere, 15.0, 10.0, 15.0)?;
49
50    println!("Created: box 30x20x15, cylinder r=6 h=25, sphere r=4");
51
52    // --- Boolean operations ---
53    let with_hole = kernel.cut(box_shape, cyl)?;
54    let final_shape = kernel.fuse(with_hole, moved_sphere)?;
55
56    // --- Measurements ---
57    let vol = kernel.get_volume(final_shape)?;
58    let area = kernel.get_surface_area(final_shape)?;
59    let bbox = kernel.get_bounding_box(final_shape, true)?;
60
61    println!("\nResult:");
62    println!("  Volume:       {vol:.2} mm^3");
63    println!("  Surface area: {area:.2} mm^2");
64    println!(
65        "  Bounding box: [{:.1}, {:.1}, {:.1}] to [{:.1}, {:.1}, {:.1}]",
66        bbox.min.x, bbox.min.y, bbox.min.z, bbox.max.x, bbox.max.y, bbox.max.z
67    );
68
69    // --- Topology counts ---
70    let faces = kernel.get_sub_shapes(final_shape, "Face")?;
71    let edges = kernel.get_sub_shapes(final_shape, "Edge")?;
72    let verts = kernel.get_sub_shapes(final_shape, "Vertex")?;
73    println!(
74        "  Topology:     {} faces, {} edges, {} vertices",
75        faces.len(),
76        edges.len(),
77        verts.len()
78    );
79
80    // --- Tessellate (renderer-ready mesh) ---
81    let mesh = kernel.tessellate(final_shape, 0.1, 0.5)?;
82    println!(
83        "  Mesh:         {} vertices, {} triangles",
84        mesh.positions.len() / 3,
85        mesh.indices.len() / 3
86    );
87
88    // --- STEP export ---
89    let step_data = kernel.export_step(final_shape)?;
90    if let Some(path) = step_out {
91        fs::write(path, &step_data).map_err(|e| OcctError::Operation {
92            operation: "export_step_write".to_owned(),
93            message: format!("write {}: {e}", path.display()),
94        })?;
95        println!("\nSTEP exported to: {}", path.display());
96    } else {
97        println!("\nTip: pass --step output.step to export the result");
98    }
99
100    // --- STEP round-trip ---
101    let reimported = kernel.import_step(&step_data)?;
102    let reimported_vol = kernel.get_volume(reimported)?;
103    println!(
104        "  Round-trip:   export -> import, volume delta = {:.6}",
105        (vol - reimported_vol).abs()
106    );
107
108    Ok(())
109}
Source

pub fn get_surface_area(&mut self, id: ShapeHandle) -> OcctResult<f64>

Examples found in repository?
examples/cli.rs (line 58)
41fn run(step_out: Option<&std::path::Path>) -> Result<(), OcctError> {
42    let mut kernel = OcctKernel::new()?;
43
44    // --- Create shapes ---
45    let box_shape = kernel.make_box(30.0, 20.0, 15.0)?;
46    let cyl = kernel.make_cylinder(6.0, 25.0)?;
47    let sphere = kernel.make_sphere(4.0)?;
48    let moved_sphere = kernel.translate(sphere, 15.0, 10.0, 15.0)?;
49
50    println!("Created: box 30x20x15, cylinder r=6 h=25, sphere r=4");
51
52    // --- Boolean operations ---
53    let with_hole = kernel.cut(box_shape, cyl)?;
54    let final_shape = kernel.fuse(with_hole, moved_sphere)?;
55
56    // --- Measurements ---
57    let vol = kernel.get_volume(final_shape)?;
58    let area = kernel.get_surface_area(final_shape)?;
59    let bbox = kernel.get_bounding_box(final_shape, true)?;
60
61    println!("\nResult:");
62    println!("  Volume:       {vol:.2} mm^3");
63    println!("  Surface area: {area:.2} mm^2");
64    println!(
65        "  Bounding box: [{:.1}, {:.1}, {:.1}] to [{:.1}, {:.1}, {:.1}]",
66        bbox.min.x, bbox.min.y, bbox.min.z, bbox.max.x, bbox.max.y, bbox.max.z
67    );
68
69    // --- Topology counts ---
70    let faces = kernel.get_sub_shapes(final_shape, "Face")?;
71    let edges = kernel.get_sub_shapes(final_shape, "Edge")?;
72    let verts = kernel.get_sub_shapes(final_shape, "Vertex")?;
73    println!(
74        "  Topology:     {} faces, {} edges, {} vertices",
75        faces.len(),
76        edges.len(),
77        verts.len()
78    );
79
80    // --- Tessellate (renderer-ready mesh) ---
81    let mesh = kernel.tessellate(final_shape, 0.1, 0.5)?;
82    println!(
83        "  Mesh:         {} vertices, {} triangles",
84        mesh.positions.len() / 3,
85        mesh.indices.len() / 3
86    );
87
88    // --- STEP export ---
89    let step_data = kernel.export_step(final_shape)?;
90    if let Some(path) = step_out {
91        fs::write(path, &step_data).map_err(|e| OcctError::Operation {
92            operation: "export_step_write".to_owned(),
93            message: format!("write {}: {e}", path.display()),
94        })?;
95        println!("\nSTEP exported to: {}", path.display());
96    } else {
97        println!("\nTip: pass --step output.step to export the result");
98    }
99
100    // --- STEP round-trip ---
101    let reimported = kernel.import_step(&step_data)?;
102    let reimported_vol = kernel.get_volume(reimported)?;
103    println!(
104        "  Round-trip:   export -> import, volume delta = {:.6}",
105        (vol - reimported_vol).abs()
106    );
107
108    Ok(())
109}
Source

pub fn get_length(&mut self, id: ShapeHandle) -> OcctResult<f64>

Source

pub fn get_center_of_mass(&mut self, id: ShapeHandle) -> OcctResult<Vec<f64>>

Source

pub fn get_surface_center_of_mass( &mut self, face_id: ShapeHandle, ) -> OcctResult<Vec<f64>>

Source

pub fn vertex_position( &mut self, vertex_id: ShapeHandle, ) -> OcctResult<Vec<f64>>

Source

pub fn surface_type(&mut self, face_id: ShapeHandle) -> OcctResult<String>

Source

pub fn surface_normal( &mut self, face_id: ShapeHandle, u: f64, v: f64, ) -> OcctResult<Vec<f64>>

Source

pub fn point_on_surface( &mut self, face_id: ShapeHandle, u: f64, v: f64, ) -> OcctResult<Vec<f64>>

Source

pub fn outer_wire(&mut self, face_id: ShapeHandle) -> OcctResult<ShapeHandle>

Source

pub fn get_linear_center_of_mass( &mut self, id: ShapeHandle, ) -> OcctResult<Vec<f64>>

Source

pub fn surface_curvature( &mut self, face_id: ShapeHandle, u: f64, v: f64, ) -> OcctResult<Vec<f64>>

Source

pub fn uv_bounds(&mut self, face_id: ShapeHandle) -> OcctResult<Vec<f64>>

Source

pub fn get_face_cylinder_data( &mut self, face_id: ShapeHandle, ) -> OcctResult<Vec<f64>>

Source

pub fn uv_from_point( &mut self, face_id: ShapeHandle, x: f64, y: f64, z: f64, ) -> OcctResult<Vec<f64>>

Source

pub fn project_point_on_face( &mut self, face_id: ShapeHandle, x: f64, y: f64, z: f64, ) -> OcctResult<Vec<f64>>

Source

pub fn classify_point_on_face( &mut self, face_id: ShapeHandle, u: f64, v: f64, ) -> OcctResult<String>

Source

pub fn curve_type(&mut self, id: ShapeHandle) -> OcctResult<String>

Source

pub fn curve_point_at_param( &mut self, id: ShapeHandle, param: f64, ) -> OcctResult<Vec<f64>>

Source

pub fn curve_tangent( &mut self, id: ShapeHandle, param: f64, ) -> OcctResult<Vec<f64>>

Source

pub fn curve_parameters(&mut self, id: ShapeHandle) -> OcctResult<Vec<f64>>

Source

pub fn curve_is_closed(&mut self, id: ShapeHandle) -> OcctResult<bool>

Source

pub fn curve_length(&mut self, id: ShapeHandle) -> OcctResult<f64>

Source

pub fn interpolate_points( &mut self, flat_points: &[f64], periodic: bool, ) -> OcctResult<ShapeHandle>

Source

pub fn curve_is_periodic(&mut self, id: ShapeHandle) -> OcctResult<bool>

Source

pub fn approximate_points( &mut self, flat_points: &[f64], tolerance: f64, ) -> OcctResult<ShapeHandle>

Source

pub fn lift_curve2d_to_plane( &mut self, flat_points2d: &[f64], plane_ox: f64, plane_oy: f64, plane_oz: f64, plane_zx: f64, plane_zy: f64, plane_zz: f64, plane_xx: f64, plane_xy: f64, plane_xz: f64, ) -> OcctResult<ShapeHandle>

Source

pub fn get_nurbs_curve_data( &mut self, edge_id: ShapeHandle, ) -> OcctResult<NurbsCurveData>

Source

pub fn has_triangulation(&mut self, id: ShapeHandle) -> OcctResult<bool>

Source

pub fn query_batch(&mut self, ids: &[ShapeHandle]) -> OcctResult<Vec<f64>>

Source

pub fn pipe( &mut self, profile_id: ShapeHandle, spine_id: ShapeHandle, ) -> OcctResult<ShapeHandle>

Source

pub fn simple_pipe( &mut self, profile_id: ShapeHandle, spine_id: ShapeHandle, ) -> OcctResult<ShapeHandle>

Source

pub fn revolve_vec( &mut self, shape_id: ShapeHandle, cx: f64, cy: f64, cz: f64, dx: f64, dy: f64, dz: f64, angle: f64, ) -> OcctResult<ShapeHandle>

Source

pub fn loft( &mut self, wire_ids: &[ShapeHandle], is_solid: bool, ruled: bool, ) -> OcctResult<ShapeHandle>

Source

pub fn loft_with_vertices( &mut self, wire_ids: &[ShapeHandle], is_solid: bool, ruled: bool, start_vertex_id: ShapeHandle, end_vertex_id: ShapeHandle, ) -> OcctResult<ShapeHandle>

Source

pub fn sweep( &mut self, wire_id: ShapeHandle, spine_id: ShapeHandle, transition_mode: i32, ) -> OcctResult<ShapeHandle>

Source

pub fn sweep_pipe_shell( &mut self, profile_id: ShapeHandle, spine_id: ShapeHandle, freenet: bool, smooth: bool, ) -> OcctResult<ShapeHandle>

Source

pub fn draft_prism( &mut self, shape_id: ShapeHandle, dx: f64, dy: f64, dz: f64, angle_deg: f64, ) -> OcctResult<ShapeHandle>

Source

pub fn fix_shape(&mut self, id: ShapeHandle) -> OcctResult<ShapeHandle>

Source

pub fn unify_same_domain(&mut self, id: ShapeHandle) -> OcctResult<ShapeHandle>

Source

pub fn is_valid(&mut self, id: ShapeHandle) -> OcctResult<bool>

Source

pub fn heal_solid( &mut self, id: ShapeHandle, tolerance: f64, ) -> OcctResult<ShapeHandle>

Source

pub fn heal_face( &mut self, id: ShapeHandle, tolerance: f64, ) -> OcctResult<ShapeHandle>

Source

pub fn heal_wire( &mut self, id: ShapeHandle, tolerance: f64, ) -> OcctResult<ShapeHandle>

Source

pub fn fix_face_orientations( &mut self, id: ShapeHandle, ) -> OcctResult<ShapeHandle>

Source

pub fn build_curves3d(&mut self, wire_id: ShapeHandle) -> OcctResult<()>

Source

pub fn fix_wire_on_face( &mut self, wire_id: ShapeHandle, face_id: ShapeHandle, tolerance: f64, ) -> OcctResult<ShapeHandle>

Source

pub fn remove_degenerate_edges( &mut self, id: ShapeHandle, ) -> OcctResult<ShapeHandle>

Source

pub fn import_step(&mut self, data: &str) -> OcctResult<ShapeHandle>

Examples found in repository?
examples/cli.rs (line 101)
41fn run(step_out: Option<&std::path::Path>) -> Result<(), OcctError> {
42    let mut kernel = OcctKernel::new()?;
43
44    // --- Create shapes ---
45    let box_shape = kernel.make_box(30.0, 20.0, 15.0)?;
46    let cyl = kernel.make_cylinder(6.0, 25.0)?;
47    let sphere = kernel.make_sphere(4.0)?;
48    let moved_sphere = kernel.translate(sphere, 15.0, 10.0, 15.0)?;
49
50    println!("Created: box 30x20x15, cylinder r=6 h=25, sphere r=4");
51
52    // --- Boolean operations ---
53    let with_hole = kernel.cut(box_shape, cyl)?;
54    let final_shape = kernel.fuse(with_hole, moved_sphere)?;
55
56    // --- Measurements ---
57    let vol = kernel.get_volume(final_shape)?;
58    let area = kernel.get_surface_area(final_shape)?;
59    let bbox = kernel.get_bounding_box(final_shape, true)?;
60
61    println!("\nResult:");
62    println!("  Volume:       {vol:.2} mm^3");
63    println!("  Surface area: {area:.2} mm^2");
64    println!(
65        "  Bounding box: [{:.1}, {:.1}, {:.1}] to [{:.1}, {:.1}, {:.1}]",
66        bbox.min.x, bbox.min.y, bbox.min.z, bbox.max.x, bbox.max.y, bbox.max.z
67    );
68
69    // --- Topology counts ---
70    let faces = kernel.get_sub_shapes(final_shape, "Face")?;
71    let edges = kernel.get_sub_shapes(final_shape, "Edge")?;
72    let verts = kernel.get_sub_shapes(final_shape, "Vertex")?;
73    println!(
74        "  Topology:     {} faces, {} edges, {} vertices",
75        faces.len(),
76        edges.len(),
77        verts.len()
78    );
79
80    // --- Tessellate (renderer-ready mesh) ---
81    let mesh = kernel.tessellate(final_shape, 0.1, 0.5)?;
82    println!(
83        "  Mesh:         {} vertices, {} triangles",
84        mesh.positions.len() / 3,
85        mesh.indices.len() / 3
86    );
87
88    // --- STEP export ---
89    let step_data = kernel.export_step(final_shape)?;
90    if let Some(path) = step_out {
91        fs::write(path, &step_data).map_err(|e| OcctError::Operation {
92            operation: "export_step_write".to_owned(),
93            message: format!("write {}: {e}", path.display()),
94        })?;
95        println!("\nSTEP exported to: {}", path.display());
96    } else {
97        println!("\nTip: pass --step output.step to export the result");
98    }
99
100    // --- STEP round-trip ---
101    let reimported = kernel.import_step(&step_data)?;
102    let reimported_vol = kernel.get_volume(reimported)?;
103    println!(
104        "  Round-trip:   export -> import, volume delta = {:.6}",
105        (vol - reimported_vol).abs()
106    );
107
108    Ok(())
109}
Source

pub fn export_step(&mut self, id: ShapeHandle) -> OcctResult<String>

Examples found in repository?
examples/cli.rs (line 89)
41fn run(step_out: Option<&std::path::Path>) -> Result<(), OcctError> {
42    let mut kernel = OcctKernel::new()?;
43
44    // --- Create shapes ---
45    let box_shape = kernel.make_box(30.0, 20.0, 15.0)?;
46    let cyl = kernel.make_cylinder(6.0, 25.0)?;
47    let sphere = kernel.make_sphere(4.0)?;
48    let moved_sphere = kernel.translate(sphere, 15.0, 10.0, 15.0)?;
49
50    println!("Created: box 30x20x15, cylinder r=6 h=25, sphere r=4");
51
52    // --- Boolean operations ---
53    let with_hole = kernel.cut(box_shape, cyl)?;
54    let final_shape = kernel.fuse(with_hole, moved_sphere)?;
55
56    // --- Measurements ---
57    let vol = kernel.get_volume(final_shape)?;
58    let area = kernel.get_surface_area(final_shape)?;
59    let bbox = kernel.get_bounding_box(final_shape, true)?;
60
61    println!("\nResult:");
62    println!("  Volume:       {vol:.2} mm^3");
63    println!("  Surface area: {area:.2} mm^2");
64    println!(
65        "  Bounding box: [{:.1}, {:.1}, {:.1}] to [{:.1}, {:.1}, {:.1}]",
66        bbox.min.x, bbox.min.y, bbox.min.z, bbox.max.x, bbox.max.y, bbox.max.z
67    );
68
69    // --- Topology counts ---
70    let faces = kernel.get_sub_shapes(final_shape, "Face")?;
71    let edges = kernel.get_sub_shapes(final_shape, "Edge")?;
72    let verts = kernel.get_sub_shapes(final_shape, "Vertex")?;
73    println!(
74        "  Topology:     {} faces, {} edges, {} vertices",
75        faces.len(),
76        edges.len(),
77        verts.len()
78    );
79
80    // --- Tessellate (renderer-ready mesh) ---
81    let mesh = kernel.tessellate(final_shape, 0.1, 0.5)?;
82    println!(
83        "  Mesh:         {} vertices, {} triangles",
84        mesh.positions.len() / 3,
85        mesh.indices.len() / 3
86    );
87
88    // --- STEP export ---
89    let step_data = kernel.export_step(final_shape)?;
90    if let Some(path) = step_out {
91        fs::write(path, &step_data).map_err(|e| OcctError::Operation {
92            operation: "export_step_write".to_owned(),
93            message: format!("write {}: {e}", path.display()),
94        })?;
95        println!("\nSTEP exported to: {}", path.display());
96    } else {
97        println!("\nTip: pass --step output.step to export the result");
98    }
99
100    // --- STEP round-trip ---
101    let reimported = kernel.import_step(&step_data)?;
102    let reimported_vol = kernel.get_volume(reimported)?;
103    println!(
104        "  Round-trip:   export -> import, volume delta = {:.6}",
105        (vol - reimported_vol).abs()
106    );
107
108    Ok(())
109}
Source

pub fn export_stl( &mut self, id: ShapeHandle, linear_deflection: f64, ascii: bool, ) -> OcctResult<String>

Source

pub fn import_stl(&mut self, data: &str) -> OcctResult<ShapeHandle>

Source

pub fn to_brep(&mut self, id: ShapeHandle) -> OcctResult<String>

Source

pub fn from_brep(&mut self, data: &str) -> OcctResult<ShapeHandle>

Source

pub fn translate_with_history( &mut self, id: ShapeHandle, dx: f64, dy: f64, dz: f64, input_face_hashes: &[i32], hash_upper_bound: i32, ) -> OcctResult<EvolutionData>

Source

pub fn fuse_with_history( &mut self, a: ShapeHandle, b: ShapeHandle, input_face_hashes: &[i32], hash_upper_bound: i32, ) -> OcctResult<EvolutionData>

Source

pub fn cut_with_history( &mut self, a: ShapeHandle, b: ShapeHandle, input_face_hashes: &[i32], hash_upper_bound: i32, ) -> OcctResult<EvolutionData>

Source

pub fn fillet_with_history( &mut self, solid_id: ShapeHandle, edge_ids: &[ShapeHandle], radius: f64, input_face_hashes: &[i32], hash_upper_bound: i32, ) -> OcctResult<EvolutionData>

Source

pub fn rotate_with_history( &mut self, id: ShapeHandle, px: f64, py: f64, pz: f64, dx: f64, dy: f64, dz: f64, angle: f64, input_face_hashes: &[i32], hash_upper_bound: i32, ) -> OcctResult<EvolutionData>

Source

pub fn mirror_with_history( &mut self, id: ShapeHandle, px: f64, py: f64, pz: f64, nx: f64, ny: f64, nz: f64, input_face_hashes: &[i32], hash_upper_bound: i32, ) -> OcctResult<EvolutionData>

Source

pub fn scale_with_history( &mut self, id: ShapeHandle, cx: f64, cy: f64, cz: f64, factor: f64, input_face_hashes: &[i32], hash_upper_bound: i32, ) -> OcctResult<EvolutionData>

Source

pub fn intersect_with_history( &mut self, a: ShapeHandle, b: ShapeHandle, input_face_hashes: &[i32], hash_upper_bound: i32, ) -> OcctResult<EvolutionData>

Source

pub fn chamfer_with_history( &mut self, solid_id: ShapeHandle, edge_ids: &[ShapeHandle], distance: f64, input_face_hashes: &[i32], hash_upper_bound: i32, ) -> OcctResult<EvolutionData>

Source

pub fn shell_with_history( &mut self, solid_id: ShapeHandle, face_ids: &[ShapeHandle], thickness: f64, tolerance: f64, input_face_hashes: &[i32], hash_upper_bound: i32, ) -> OcctResult<EvolutionData>

Source

pub fn offset_with_history( &mut self, solid_id: ShapeHandle, distance: f64, tolerance: f64, input_face_hashes: &[i32], hash_upper_bound: i32, ) -> OcctResult<EvolutionData>

Source

pub fn thicken_with_history( &mut self, shape_id: ShapeHandle, thickness: f64, tolerance: f64, input_face_hashes: &[i32], hash_upper_bound: i32, ) -> OcctResult<EvolutionData>

Source

pub fn tessellate( &mut self, id: ShapeHandle, linear_deflection: f64, angular_deflection: f64, ) -> OcctResult<Mesh>

Examples found in repository?
examples/cli.rs (line 81)
41fn run(step_out: Option<&std::path::Path>) -> Result<(), OcctError> {
42    let mut kernel = OcctKernel::new()?;
43
44    // --- Create shapes ---
45    let box_shape = kernel.make_box(30.0, 20.0, 15.0)?;
46    let cyl = kernel.make_cylinder(6.0, 25.0)?;
47    let sphere = kernel.make_sphere(4.0)?;
48    let moved_sphere = kernel.translate(sphere, 15.0, 10.0, 15.0)?;
49
50    println!("Created: box 30x20x15, cylinder r=6 h=25, sphere r=4");
51
52    // --- Boolean operations ---
53    let with_hole = kernel.cut(box_shape, cyl)?;
54    let final_shape = kernel.fuse(with_hole, moved_sphere)?;
55
56    // --- Measurements ---
57    let vol = kernel.get_volume(final_shape)?;
58    let area = kernel.get_surface_area(final_shape)?;
59    let bbox = kernel.get_bounding_box(final_shape, true)?;
60
61    println!("\nResult:");
62    println!("  Volume:       {vol:.2} mm^3");
63    println!("  Surface area: {area:.2} mm^2");
64    println!(
65        "  Bounding box: [{:.1}, {:.1}, {:.1}] to [{:.1}, {:.1}, {:.1}]",
66        bbox.min.x, bbox.min.y, bbox.min.z, bbox.max.x, bbox.max.y, bbox.max.z
67    );
68
69    // --- Topology counts ---
70    let faces = kernel.get_sub_shapes(final_shape, "Face")?;
71    let edges = kernel.get_sub_shapes(final_shape, "Edge")?;
72    let verts = kernel.get_sub_shapes(final_shape, "Vertex")?;
73    println!(
74        "  Topology:     {} faces, {} edges, {} vertices",
75        faces.len(),
76        edges.len(),
77        verts.len()
78    );
79
80    // --- Tessellate (renderer-ready mesh) ---
81    let mesh = kernel.tessellate(final_shape, 0.1, 0.5)?;
82    println!(
83        "  Mesh:         {} vertices, {} triangles",
84        mesh.positions.len() / 3,
85        mesh.indices.len() / 3
86    );
87
88    // --- STEP export ---
89    let step_data = kernel.export_step(final_shape)?;
90    if let Some(path) = step_out {
91        fs::write(path, &step_data).map_err(|e| OcctError::Operation {
92            operation: "export_step_write".to_owned(),
93            message: format!("write {}: {e}", path.display()),
94        })?;
95        println!("\nSTEP exported to: {}", path.display());
96    } else {
97        println!("\nTip: pass --step output.step to export the result");
98    }
99
100    // --- STEP round-trip ---
101    let reimported = kernel.import_step(&step_data)?;
102    let reimported_vol = kernel.get_volume(reimported)?;
103    println!(
104        "  Round-trip:   export -> import, volume delta = {:.6}",
105        (vol - reimported_vol).abs()
106    );
107
108    Ok(())
109}
Source

pub fn mesh_shape( &mut self, id: ShapeHandle, linear_deflection: f64, angular_deflection: f64, ) -> OcctResult<Mesh>

Source

pub fn mesh_batch( &mut self, ids: &[ShapeHandle], linear_deflection: f64, angular_deflection: f64, ) -> OcctResult<MeshBatch>

Source

pub fn wireframe( &mut self, id: ShapeHandle, deflection: f64, ) -> OcctResult<EdgeData>

Source

pub fn project_edges( &mut self, shape_id: ShapeHandle, ox: f64, oy: f64, oz: f64, dx: f64, dy: f64, dz: f64, xx: f64, xy: f64, xz: f64, has_x_axis: bool, ) -> OcctResult<ProjectionData>

Source

pub fn release(&mut self, id: ShapeHandle) -> OcctResult<()>

Source

pub fn release_all(&mut self) -> OcctResult<()>

Source

pub fn get_shape_count(&mut self) -> OcctResult<u32>

Source

pub fn make_null_shape(&mut self) -> OcctResult<ShapeHandle>

Source

pub fn xcaf_new_document(&mut self) -> OcctResult<u32>

Source

pub fn xcaf_close(&mut self, doc_id: ShapeHandle) -> OcctResult<()>

Source

pub fn xcaf_add_shape( &mut self, doc_id: ShapeHandle, shape_id: ShapeHandle, ) -> OcctResult<i32>

Source

pub fn xcaf_add_component( &mut self, doc_id: ShapeHandle, parent_label_id: i32, shape_id: ShapeHandle, tx: f64, ty: f64, tz: f64, rx: f64, ry: f64, rz: f64, ) -> OcctResult<i32>

Source

pub fn xcaf_set_color( &mut self, doc_id: ShapeHandle, label_id: i32, r: f64, g: f64, b: f64, ) -> OcctResult<()>

Source

pub fn xcaf_set_name( &mut self, doc_id: ShapeHandle, label_id: i32, name: &str, ) -> OcctResult<()>

Source

pub fn xcaf_get_label_info( &mut self, doc_id: ShapeHandle, label_id: i32, ) -> OcctResult<LabelInfo>

Source

pub fn xcaf_get_child_labels( &mut self, doc_id: ShapeHandle, parent_label_id: i32, ) -> OcctResult<Vec<i32>>

Source

pub fn xcaf_get_root_labels( &mut self, doc_id: ShapeHandle, ) -> OcctResult<Vec<i32>>

Source

pub fn xcaf_export_step(&mut self, doc_id: ShapeHandle) -> OcctResult<String>

Source

pub fn xcaf_import_step(&mut self, step_data: &str) -> OcctResult<u32>

Source

pub fn xcaf_export_gltf( &mut self, doc_id: ShapeHandle, lin_deflection: f64, ang_deflection: f64, ) -> OcctResult<String>

Trait Implementations§

Source§

impl Drop for OcctKernel

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.