Skip to main content

Chain

Struct Chain 

Source
pub struct Chain<C> {
    pub name: String,
    pub curves: Vec<C>,
    pub curve_names: Vec<String>,
    pub joint_names: Vec<String>,
}
Expand description

A chain of curves, with a stable name for every curve and every joint between them — what extrude, revolve and the sweeps build the names of what they make from (see the crate docs). For a sketch these are its element ids; for a shape built in code, positions in the chain (Chain::closed).

joint_names[i] names the joint where curves[i] starts. A closed loop has one joint per curve; an open chain one more, its end.

Fields§

§name: String

What the chain goes by: its sketch’s name, or its edge’s; empty for one built in code.

§curves: Vec<C>§curve_names: Vec<String>§joint_names: Vec<String>

Implementations§

Source§

impl<const D: usize> Chain<NurbCurve<D>>

Source

pub fn closed(curves: Vec<NurbCurve<D>>) -> Self

A closed loop whose curves are called c0, c1, ... and whose joints p0, p1, ..., p0 where c0 starts.

Source

pub fn open(curves: Vec<NurbCurve<D>>) -> Self

An open chain, named like Chain::closed plus its end joint.

Source

pub fn with_prefix(self, prefix: &str) -> Self

The same chain with prefix put in front of every name — to keep several Chain::closed loops of one extrude apart.

Source

pub fn is_closed(&self) -> bool

Source

pub fn check_names(&self) -> GeopResult<()>

Checks that there is one name per curve and one per joint.

Source

pub fn reversed(&self) -> Self

The same chain traversed the other way; every name stays with its curve or joint.

Source

pub fn starting_at(&self, k: usize) -> Self

The closed chain starting at its joint k.

Source

pub fn map_curves(&self, f: impl Fn(&NurbCurve<D>) -> NurbCurve<D>) -> Self

The same chain with f applied to every curve, keeping the names.

Source

pub fn joint(&self, i: usize) -> GeopResult<<NurbCurve<D> as ChainCurve>::Point>

Joint i, where it is.

Source

pub fn joints(&self) -> GeopResult<Vec<<NurbCurve<D> as ChainCurve>::Point>>

The joints, where they are.

Source§

impl Chain<NurbCurve2D>

Source

pub fn corners(&self) -> GeopResult<Vec<usize>>

The joints of the closed chain where its tangent turns — the corners a designer sees — as indices into joint_names, in order. A joint is smooth where the curve arriving and the curve leaving could have one tangent direction: their tangents’ cross product could be zero and their dot product is definitely positive. Everything else is a corner: a turn, a cusp, or a tangent that could vanish. The split of an arc at a quarter turn, or a sketch point where two curves meet tangentially, is no corner.

Source§

impl Chain<NurbCurve3D>

Source

pub fn starting_on(&self, plane: &CoordinateSystem) -> GeopResult<Option<Self>>

The open chain run from its end on plane: as it is if it starts there, the other way round if only its end could lie on it. None if neither end could.

Trait Implementations§

Source§

impl<C: Clone> Clone for Chain<C>

Source§

fn clone(&self) -> Chain<C>

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<C: Debug> Debug for Chain<C>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<C> Freeze for Chain<C>

§

impl<C> RefUnwindSafe for Chain<C>
where C: RefUnwindSafe,

§

impl<C> Send for Chain<C>
where C: Send,

§

impl<C> Sync for Chain<C>
where C: Sync,

§

impl<C> Unpin for Chain<C>
where C: Unpin,

§

impl<C> UnsafeUnpin for Chain<C>

§

impl<C> UnwindSafe for Chain<C>
where C: UnwindSafe,

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

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.