Crate libfive

source ·
Expand description

A high level wrapper around libfive – a set of tools for solid modeling based on functional representation.

Particularly suited for parametric- and procedural modeling. An infrastructure for generative design, mass customization, and domain-specific CAD tools.

§Example

let f_rep_shape = Tree::sphere(1.0.into(), TreeVec3::default())
    .difference_multi(vec![
        Tree::sphere(0.6.into(), TreeVec3::default()),
        Tree::cylinder_z(
            0.6.into(),
            2.0.into(),
            TreeVec3::new(0.0, 0.0, -1.0),
        ),
        Tree::cylinder_z(
            0.6.into(),
            2.0.into(),
            TreeVec3::new(0.0, 0.0, -1.0),
        )
        .reflect_xz(),
        Tree::cylinder_z(
            0.6.into(),
            2.0.into(),
            TreeVec3::new(0.0, 0.0, -1.0),
        )
        .reflect_yz(),
    ]);

f_rep_shape.write_stl(
    "f-rep-shape.stl",
    &Region3::new(-2.0, 2.0, -2.0, 2.0, -2.0, 2.0),
    // Subdivisions
    10.0,
)?;

The STL file generated from this code is show below.

§Features

Generated CSG Shape
  • ahash – On by default. Use AHashMap for hashing when resolving variable names. Disabling this will fall back to the slower HashMap.

  • stdlib – On by default. Add an extensive list of higher level operations – the libfive stdlib.

    To disable either/both of the above features unset default features in Cargo.toml:

    [dependencies.libfive]
    default-features = false
    
  • packed_opcodes – Tightly pack opcodes. This breaks compatibility with older saved f-rep files.

    See Tree::save()/load().

Structs§

Enums§

  • A list specifying general categories of errors.

Traits§

Type Aliases§