Skip to main content

ControlCage

Struct ControlCage 

Source
pub struct ControlCage {
    pub knots_u: Vec<f64>,
    pub knots_v: Vec<f64>,
    pub poles: [Vec3; 2],
    pub rings: Vec<Vec<Vec3>>,
}
Expand description

The cage: see the module docs for the layout.

Fields§

§knots_u: Vec<f64>

N + 1 cumulative periodic knots, knots_u[0] = 0, knots_u[N] the period.

§knots_v: Vec<f64>

Clamped cubic knots over the M + 2 rows: M + 6 values.

§poles: [Vec3; 2]

The bottom and top pole points.

§rings: Vec<Vec<Vec3>>

M rings of N points, bottom-up.

Implementations§

Source§

impl ControlCage

Source

pub fn primitive( kind: CagePrimitive, size: [f64; 3], segments: usize, rings: usize, ) -> Result<Self, String>

The initial cage around a primitive filling the size box (centred on the origin, poles on the Y axis), with segments points per ring and rings rings. Rings run counter-clockwise about +Y seen from above (from +X towards −Z), so Su × Sv points outward.

Source

pub fn validate(&self) -> Result<(), String>

Every structural invariant: ring sizes, knot counts, monotone knots, finite points. A persisted cage is checked through this before use.

Source

pub fn segments(&self) -> usize

Points per ring (N).

Source

pub fn ring_count(&self) -> usize

Rings (M).

Source

pub fn point_count(&self) -> usize

Every free point: the rings’ plus the two poles.

Source

pub fn period(&self) -> f64

The period of the around direction.

Source

pub fn domain_v(&self) -> [f64; 2]

The clamped v domain.

Source

pub fn locate(&self, index: usize) -> Option<CagePoint>

Where linear index index lands.

Source

pub fn index_of(&self, ring: usize, column: usize) -> usize

The linear index of column column of ring ring.

Source

pub fn pole_index(&self, which: usize) -> usize

The linear index of pole which (0 bottom, 1 top).

Source

pub fn point(&self, index: usize) -> Option<Vec3>

Source

pub fn set_point(&mut self, index: usize, point: Vec3) -> Result<(), String>

Source

pub fn points(&self) -> Vec<Vec3>

Every point in linear order.

Source

pub fn greville_u(&self, column: usize) -> f64

The Greville abscissa of column column — the u the point “sits” at.

Source

pub fn greville_v(&self, row: usize) -> f64

The Greville abscissa of row row (0 the bottom pole, M + 1 the top).

Source

pub fn insert_ring_between(&mut self, row: usize) -> Result<usize, String>

Insert a ring of points between rows row and row + 1 (row in 0 ..= M, row 0 being the bottom pole), by inserting the v knot half-way between their Greville abscissae. The surface is unchanged. Returns the index (0-based, among the rings) of the new ring.

Source

pub fn insert_ring_at(&mut self, v: f64) -> Result<usize, String>

Insert a ring at parameter v (strictly inside the v domain).

Source

pub fn insert_column_between(&mut self, column: usize) -> Result<usize, String>

Insert a column of points (pole to pole) between columns column and column + 1 (cyclic), half-way between their Greville abscissae. The surface is unchanged. Returns the new column’s index.

Source

pub fn insert_column_at(&mut self, u: f64) -> Result<usize, String>

Insert a column at periodic parameter u (reduced into [0, period)).

Source

pub fn surface(&self) -> Result<NurbsSurface, String>

The bicubic surface the cage controls, over [0, 1] × [0, 1]: u around (clamped at the seam), v from the bottom pole to the top.

Source

pub fn solid(&self, face_name: Option<&str>) -> Result<BrepSolid, String>

The closed solid: one face carrying face_name, a seam edge at u = 0 and a degenerate edge at each pole — the sphere’s topology on this surface. Validated before it is returned.

Source

pub fn to_json(&self) -> Value

The persisted shape: { knotsU, knotsV, poles: [[x,y,z],[x,y,z]], rings: [[[x,y,z], …], …] }.

Source

pub fn from_json(value: &Value) -> Result<Self, String>

Read a persisted cage, validating it.

Trait Implementations§

Source§

impl Clone for ControlCage

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ControlCage

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more