pub struct Processor<E, T> { /* private fields */ }
Expand description

invertible and transformable geometric element

Examples

Curve processing example

use truck_geometry::*;
let curve: BSplineCurve<Point3> = BSplineCurve::new(
    KnotVec::bezier_knot(2),
    vec![
        Point3::new(0.0, 0.0, 0.0),
        Point3::new(0.0, 0.0, 1.0),
        Point3::new(1.0, 0.0, 0.0),
    ],
);
let mut processed = Processor::<_, Matrix4>::new(curve.clone());

// both curves are the same curve
const N: usize = 100;
for i in 0..=N {
    let t = i as f64 / N as f64;
    assert_eq!(curve.subs(t), processed.subs(t));
}

// Processed curve can inverted!
processed.invert();
for i in 0..=N {
    let t = i as f64 / N as f64;
    assert_eq!(curve.subs(1.0 - t), processed.subs(t));
}

Surface processing example

use truck_geometry::*;
use std::f64::consts::PI;

let sphere = Sphere::new(Point3::new(1.0, 2.0, 3.0), 2.45);
let mut processed = Processor::<_, Matrix4>::new(sphere);

// both surfaces are the same surface
const N: usize = 100;
for i in 0..=N {
    for j in 0..=N {
        let u = PI * i as f64 / N as f64;
        let v = 2.0 * PI * j as f64 / N as f64;
        assert_eq!(sphere.subs(u, v), processed.subs(u, v));
    }
}

// Processed surface can be inverted!
// Here, "invert surface" means swap (u, v)-axes.
processed.invert();
for i in 0..=N {
    for j in 0..=N {
        let u = PI * i as f64 / N as f64;
        let v = 2.0 * PI * j as f64 / N as f64;
        assert_eq!(sphere.subs(u, v), processed.subs(v, u));
    }
}

Implementations§

Creates new processor

Returns the reference of entity

Returns the reference of transform

apply the function to the entity geometry

apply the function to the entity geometry

apply the transform and inverse

Trait Implementations§

The range of the parameter of the curve.
The front end point of the curve.
The back end point of the curve.
The range of the parameter of the surface.
Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
The resulting type after dereferencing.
Dereferences the value.
Mutably dereferences the value.
Deserialize this value from the given Serde deserializer. Read more
Converts to this type from the input type.
Returns whether the curve curve is included in the surface self.
Inverts self
Returns the inverse.
The curve is in the space of Self::Point.
Creates the curve division (parameters, corresponding points). Read more
The curve is in the space of Self::Point.
Creates the curve division (parameters, corresponding points). Read more
Creates the surface division Read more
Creates the surface division Read more
The curve is in the space of Self::Point.
The derivation vector of the curve.
Substitutes the parameter t.
Returns the derivation.
Returns the 2nd-order derivation.
The surface is in the space of Self::Point.
The derivation vector of the curve.
Substitutes the parameter (u, v).
Returns the derivation by u.
Returns the derivation by v.
Returns the 2nd-order derivation by u.
Returns the 2nd-order derivation by both u and v.
Returns the 2nd-order derivation by v.
Returns the normal vector at (u, v).
point
Search parameter t such that self.subs(t) is near point.
Returns None if could not find such parameter.
Serialize this value into the given Serde serializer. Read more
transform by trans.
transformed geometry by trans.
The type returned in the event of a conversion error.
Performs the conversion.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.