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§

Bitmap
Bitmap representing occupancy in a slice of a Tree.
Evaluator
Helper for controlling evaluation of Variables on a Tree.
FlatTriangleMesh
Flat triangle mesh.
Region2
2D bounding region.
Region3
3D bounding region.
Tree
Tree of operations.
TreeVec2
2D point/vector/normal.
TreeVec3
3D point/vector/normal.
TriangleMesh
Triangle mesh.
Variables
Set of variables to parameterize a Tree.

Enums§

Error
A list specifying general categories of errors.

Traits§

Point2
Trait to aid with using arbitrary 2D point types on a Contour.
Point3
Trait to aid with using arbitrary 3D point types on a TriangleMesh.

Type Aliases§

Contour
Series of 2D or 3D points forming a polygonal chain.
Result
A specialized Result type for libfive operations.
TreeFloat
An alias for Tree.
Trees
A collection of Trees.