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
impl ControlCage
Sourcepub fn primitive(
kind: CagePrimitive,
size: [f64; 3],
segments: usize,
rings: usize,
) -> Result<Self, String>
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.
Sourcepub fn validate(&self) -> Result<(), String>
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.
Sourcepub fn ring_count(&self) -> usize
pub fn ring_count(&self) -> usize
Rings (M).
Sourcepub fn point_count(&self) -> usize
pub fn point_count(&self) -> usize
Every free point: the rings’ plus the two poles.
Sourcepub fn index_of(&self, ring: usize, column: usize) -> usize
pub fn index_of(&self, ring: usize, column: usize) -> usize
The linear index of column column of ring ring.
Sourcepub fn pole_index(&self, which: usize) -> usize
pub fn pole_index(&self, which: usize) -> usize
The linear index of pole which (0 bottom, 1 top).
pub fn point(&self, index: usize) -> Option<Vec3>
pub fn set_point(&mut self, index: usize, point: Vec3) -> Result<(), String>
Sourcepub fn greville_u(&self, column: usize) -> f64
pub fn greville_u(&self, column: usize) -> f64
The Greville abscissa of column column — the u the point “sits” at.
Sourcepub fn greville_v(&self, row: usize) -> f64
pub fn greville_v(&self, row: usize) -> f64
The Greville abscissa of row row (0 the bottom pole, M + 1 the top).
Sourcepub fn insert_ring_between(&mut self, row: usize) -> Result<usize, String>
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.
Sourcepub fn insert_ring_at(&mut self, v: f64) -> Result<usize, String>
pub fn insert_ring_at(&mut self, v: f64) -> Result<usize, String>
Insert a ring at parameter v (strictly inside the v domain).
Sourcepub fn insert_column_between(&mut self, column: usize) -> Result<usize, String>
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.
Sourcepub fn insert_column_at(&mut self, u: f64) -> Result<usize, String>
pub fn insert_column_at(&mut self, u: f64) -> Result<usize, String>
Insert a column at periodic parameter u (reduced into [0, period)).
Sourcepub fn surface(&self) -> Result<NurbsSurface, String>
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.
Sourcepub fn solid(&self, face_name: Option<&str>) -> Result<BrepSolid, String>
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.