Skip to main content

view_solid

Function view_solid 

Source
pub fn view_solid(
    topo: &Topology,
    solid: SolidId,
    opts: &ViewOpts,
) -> Result<(), RenderError>
Expand description

Open an interactive window showing solid, blocking until it is closed.

Left-drag orbits, scroll zooms, right-drag (or shift + left-drag) pans, and a left click highlights the picked face. Tessellation happens once up front; only the camera and selection change per frame.

§Errors

Examples found in repository?
examples/viewer.rs (line 39)
25fn main() -> Result<(), Box<dyn std::error::Error>> {
26    // A 40x40x20 box with a cylinder rising through its top, fused into one
27    // solid so the viewer can show (and pick) the combined faces.
28    let mut topo = Topology::new();
29
30    let box_solid = make_box(&mut topo, 40.0, 40.0, 20.0)?;
31
32    // Cylinder base at z=0; lift it so it spans the box and protrudes above.
33    let cyl = make_cylinder(&mut topo, 10.0, 35.0)?;
34    transform_solid(&mut topo, cyl, &Mat4::translation(20.0, 20.0, 0.0))?;
35
36    let solid = boolean(&mut topo, BooleanOp::Fuse, box_solid, cyl)?;
37
38    let opts = ViewOpts::new("brepkit viewer — box + cylinder (click a face)");
39    view_solid(&topo, solid, &opts)?;
40    Ok(())
41}