Struct libfive::Tree

source ·
pub struct Tree(/* private fields */);
Expand description

Tree of operations.

§Core

§Standard Library

These features are dependent on the stdlib feature being enabled.

Implementations§

§

impl Tree

Shapes

pub fn circle(r: TreeFloat, center: TreeVec2) -> Self

pub fn ring(ro: TreeFloat, ri: TreeFloat, center: TreeVec2) -> Self

pub fn polygon(r: TreeFloat, n: u32, center: TreeVec2) -> Self

pub fn rectangle(a: TreeVec2, b: TreeVec2) -> Self

pub fn rounded_rectangle(a: TreeVec2, b: TreeVec2, r: TreeFloat) -> Self

pub fn rectangle_exact(a: TreeVec2, b: TreeVec2) -> Self

pub fn rectangle_centered_exact(size: TreeVec2, center: TreeVec2) -> Self

pub fn triangle(a: TreeVec2, b: TreeVec2, c: TreeVec2) -> Self

pub fn box_mitered(a: TreeVec3, b: TreeVec3) -> Self

pub fn box_mitered_centered(size: TreeVec3, center: TreeVec3) -> Self

pub fn box_exact_centered(size: TreeVec3, center: TreeVec3) -> Self

pub fn box_exact(a: TreeVec3, b: TreeVec3) -> Self

pub fn rounded_box(a: TreeVec3, b: TreeVec3, r: TreeFloat) -> Self

pub fn sphere(radius: TreeFloat, center: TreeVec3) -> Self

pub fn half_space(norm: TreeVec3, point: TreeVec3) -> Self

pub fn cylinder_z(r: TreeFloat, h: TreeFloat, base: TreeVec3) -> Self

pub fn cone_ang_z(angle: TreeFloat, height: TreeFloat, base: TreeVec3) -> Self

pub fn cone_z(radius: TreeFloat, height: TreeFloat, base: TreeVec3) -> Self

pub fn pyramid_z( a: TreeVec2, b: TreeVec2, zmin: TreeFloat, height: TreeFloat ) -> Self

pub fn torus_z(ro: TreeFloat, ri: TreeFloat, center: TreeVec3) -> Self

pub fn gyroid(period: TreeVec3, thickness: TreeFloat) -> Self

pub fn emptiness() -> Self

§

impl Tree

Generators

pub fn array_x(shape: Tree, nx: u32, dx: TreeFloat) -> Self

pub fn array_xy(shape: Tree, nx: u32, ny: u32, delta: TreeVec2) -> Self

pub fn array_xyz( shape: Tree, nx: u32, ny: u32, nz: u32, delta: TreeVec3 ) -> Self

pub fn array_polar_z(shape: Tree, n: u32, center: TreeVec2) -> Self

pub fn extrude_z(t: Tree, zmin: TreeFloat, zmax: TreeFloat) -> Self

§

impl Tree

§Csg

pub fn union(self, b: Tree) -> Self

pub fn intersection(self, b: Tree) -> Self

pub fn inverse(self) -> Self

pub fn difference(self, b: Tree) -> Self

pub fn offset(self, o: TreeFloat) -> Self

pub fn clearance(self, b: Tree, offset: TreeFloat) -> Self

pub fn shell(self, offset: TreeFloat) -> Self

pub fn blend_expt(self, b: Tree, m: TreeFloat) -> Self

pub fn blend_expt_unit(self, b: Tree, m: TreeFloat) -> Self

pub fn blend_rough(self, b: Tree, m: TreeFloat) -> Self

pub fn blend_difference(self, b: Tree, m: TreeFloat, o: TreeFloat) -> Self

pub fn morph(self, b: Tree, m: TreeFloat) -> Self

pub fn loft(self, b: Tree, zmin: TreeFloat, zmax: TreeFloat) -> Self

pub fn loft_between(self, b: Tree, lower: TreeVec3, upper: TreeVec3) -> Self

source§

impl Tree

Operations taking multiple 2nd arguments.

source

pub fn union_multi(self, trees: Trees) -> Self

source

pub fn intersection_multi(self, trees: Trees) -> Self

source

pub fn difference_multi(self, trees: Trees) -> Self

§

impl Tree

Transforms

pub fn moveit(self, offset: TreeVec3) -> Self

pub fn reflect_x(self, x0: TreeFloat) -> Self

pub fn reflect_y(self, y0: TreeFloat) -> Self

pub fn reflect_z(self, z0: TreeFloat) -> Self

pub fn reflect_xy(self) -> Self

pub fn reflect_yz(self) -> Self

pub fn reflect_xz(self) -> Self

pub fn symmetric_x(self) -> Self

pub fn symmetric_y(self) -> Self

pub fn symmetric_z(self) -> Self

pub fn scale_x(self, sx: TreeFloat, x0: TreeFloat) -> Self

pub fn scale_y(self, sy: TreeFloat, y0: TreeFloat) -> Self

pub fn scale_z(self, sz: TreeFloat, z0: TreeFloat) -> Self

pub fn scale_xyz(self, s: TreeVec3, center: TreeVec3) -> Self

pub fn rotate_x(self, angle: TreeFloat, center: TreeVec3) -> Self

pub fn rotate_y(self, angle: TreeFloat, center: TreeVec3) -> Self

pub fn rotate_z(self, angle: TreeFloat, center: TreeVec3) -> Self

pub fn taper_x_y( self, base: TreeVec2, h: TreeFloat, scale: TreeFloat, base_scale: TreeFloat ) -> Self

pub fn taper_xy_z( self, base: TreeVec3, height: TreeFloat, scale: TreeFloat, base_scale: TreeFloat ) -> Self

pub fn shear_x_y( self, base: TreeVec2, height: TreeFloat, offset: TreeFloat, base_offset: TreeFloat ) -> Self

pub fn repel( self, locus: TreeVec3, radius: TreeFloat, exaggerate: TreeFloat ) -> Self

pub fn repel_x( self, locus: TreeVec3, radius: TreeFloat, exaggerate: TreeFloat ) -> Self

pub fn repel_y( self, locus: TreeVec3, radius: TreeFloat, exaggerate: TreeFloat ) -> Self

pub fn repel_z( self, locus: TreeVec3, radius: TreeFloat, exaggerate: TreeFloat ) -> Self

pub fn repel_xy( self, locus: TreeVec3, radius: TreeFloat, exaggerate: TreeFloat ) -> Self

pub fn repel_yz( self, locus: TreeVec3, radius: TreeFloat, exaggerate: TreeFloat ) -> Self

pub fn repel_xz( self, locus: TreeVec3, radius: TreeFloat, exaggerate: TreeFloat ) -> Self

pub fn attract( self, locus: TreeVec3, radius: TreeFloat, exaggerate: TreeFloat ) -> Self

pub fn attract_x( self, locus: TreeVec3, radius: TreeFloat, exaggerate: TreeFloat ) -> Self

pub fn attract_y( self, locus: TreeVec3, radius: TreeFloat, exaggerate: TreeFloat ) -> Self

pub fn attract_z( self, locus: TreeVec3, radius: TreeFloat, exaggerate: TreeFloat ) -> Self

pub fn attract_xy( self, locus: TreeVec3, radius: TreeFloat, exaggerate: TreeFloat ) -> Self

pub fn attract_yz( self, locus: TreeVec3, radius: TreeFloat, exaggerate: TreeFloat ) -> Self

pub fn attract_xz( self, locus: TreeVec3, radius: TreeFloat, exaggerate: TreeFloat ) -> Self

pub fn revolve_y(self, x0: TreeFloat) -> Self

pub fn twirl_x( self, amount: TreeFloat, radius: TreeFloat, center: TreeVec3 ) -> Self

pub fn twirl_axis_x( self, amount: TreeFloat, radius: TreeFloat, center: TreeVec3 ) -> Self

pub fn twirl_y( self, amount: TreeFloat, radius: TreeFloat, center: TreeVec3 ) -> Self

pub fn twirl_axis_y( self, amount: TreeFloat, radius: TreeFloat, center: TreeVec3 ) -> Self

pub fn twirl_z( self, amount: TreeFloat, radius: TreeFloat, center: TreeVec3 ) -> Self

pub fn twirl_axis_z( self, amount: TreeFloat, radius: TreeFloat, center: TreeVec3 ) -> Self

§

impl Tree

§Text

pub fn text(txt: impl Into<Vec<u8>>, pos: TreeVec2) -> Self

source§

impl Tree

§Bases

source

pub fn x() -> Self

source

pub fn y() -> Self

source

pub fn z() -> Self

source§

impl Tree

§Functions

source

pub fn square(&self) -> Self

source

pub fn sqrt(&self) -> Self

source

pub fn neg(&self) -> Self

source

pub fn sin(&self) -> Self

source

pub fn cos(&self) -> Self

source

pub fn tan(&self) -> Self

source

pub fn asin(&self) -> Self

source

pub fn acos(&self) -> Self

source

pub fn atan(&self) -> Self

source

pub fn exp(&self) -> Self

source

pub fn abs(&self) -> Self

source

pub fn log(&self) -> Self

source

pub fn recip(&self) -> Self

source

pub fn add(self, rhs: Self) -> Self

source

pub fn mul(self, rhs: Self) -> Self

source

pub fn min(self, rhs: Self) -> Self

source

pub fn max(self, rhs: Self) -> Self

source

pub fn sub(self, rhs: Self) -> Self

source

pub fn div(self, rhs: Self) -> Self

source

pub fn atan2(self, other: Self) -> Self

source

pub fn pow(self, exp: Self) -> Self

source

pub fn nth_root(self, n: Self) -> Self

source

pub fn rem(self, rhs: Self) -> Self

source

pub fn nan_fill(self, rhs: Self) -> Self

source

pub fn compare(self, rhs: Self) -> Self

source

pub fn is_variable(&self) -> bool

Checks if the tree is a variable.

source

pub fn as_f32(&self) -> Result<f32>

Returns the value of the tree if it is constant.

I.e. if it was created from an f32 value.

§Errors

Returns TreeIsNotConstant if the tree is not constant.

source§

impl Tree

§Evaluation, Import & Export

§Common Arguments
  • region – A bounding box that will be subdivided into an quadtree/octree. For clean lines/triangles, it should be near-cubical. But this is not a hard requirement.

  • resolution – The meshing region is subdivided until the smallest region edge is below resolution in size. Make this smaller to get a higher-resolution model.

    To not loose any detail this should be approximately half the model’s smallest feature size.

source

pub fn to_bitmap(&self, region: &Region2, z: f32, resolution: f32) -> Bitmap

Renders a 2D slice of region at the given z height into a Bitmap.

source

pub fn to_triangle_mesh<T: Point3>( &self, region: &Region3, resolution: f32 ) -> Option<TriangleMesh<T>>

Renders region to a TriangleMesh.

source

pub fn to_contour_2d<T: Point2>( &self, region: Region2, z: f32, resolution: f32 ) -> Option<Vec<Contour<T>>>

Renders a 2D slice of region at the given z height to a set of 2D contours.

source

pub fn to_contour_3d<T: Point3>( &self, region: Region2, z: f32, resolution: f32 ) -> Option<Vec<Contour<T>>>

Renders region to a set of 3D contours.

source

pub fn write_svg( &self, path: impl AsRef<Path>, region: &Region2, z: f32, resolution: f32 )

Computes a 2D slice of region at the given z height and saves it to path in SVG format.

source

pub fn write_stl( &self, path: impl AsRef<Path>, region: &Region3, resolution: f32 ) -> Result<()>

Computes a mesh of region and saves it to path in STL format.

source

pub fn save(&self, path: impl AsRef<Path>) -> Result<()>

Serializes the tree to a file.

The file format is not archival and may change without notice.

Saved files may fail to load with older versions of libfive if the packed_opcodes feature is enabled.

source

pub fn load(&self, path: impl Into<Vec<u8>>) -> Result<Tree>

Deserializes a tree from a file.

Old files may fail to load if the packed_opcodes feature is enabled.

Trait Implementations§

source§

impl Add for Tree

§

type Output = Tree

The resulting type after applying the + operator.
source§

fn add(self, rhs: Tree) -> Self::Output

Performs the + operation. Read more
source§

impl Div for Tree

§

type Output = Tree

The resulting type after applying the / operator.
source§

fn div(self, rhs: Tree) -> Self::Output

Performs the / operation. Read more
source§

impl Drop for Tree

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl Mul for Tree

§

type Output = Tree

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Tree) -> Self::Output

Performs the * operation. Read more
source§

impl Neg for Tree

§

type Output = Tree

The resulting type after applying the - operator.
source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
source§

impl PartialEq for Tree

source§

fn eq(&self, other: &Tree) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Rem for Tree

§

type Output = Tree

The resulting type after applying the % operator.
source§

fn rem(self, rhs: Tree) -> Self::Output

Performs the % operation. Read more
source§

impl Sub for Tree

§

type Output = Tree

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Tree) -> Self::Output

Performs the - operation. Read more
source§

impl Eq for Tree

source§

impl StructuralPartialEq for Tree

Auto Trait Implementations§

§

impl RefUnwindSafe for Tree

§

impl !Send for Tree

§

impl !Sync for Tree

§

impl Unpin for Tree

§

impl UnwindSafe for Tree

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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.