Skip to main content

Cage

Struct Cage 

Source
pub struct Cage {
    pub vertices: Vec<CageVertex>,
    pub faces: Vec<CageFace>,
    pub creases: Vec<Crease>,
    pub next_id: u32,
}
Expand description

A control cage: a mesh of faces of any number of sides — quads mostly, triangles and n-gons allowed — with the edges named in creases kept sharp. Ids are unique across vertices and faces, and next_id is the next one no element has had.

Fields§

§vertices: Vec<CageVertex>§faces: Vec<CageFace>§creases: Vec<Crease>

The edges creased, in order of their vertices.

§next_id: u32

Implementations§

Source§

impl Cage

Source

pub fn vertex(&self, id: u32) -> GeopResult<&CageVertex>

The vertex id.

Source

pub fn vertex_mut(&mut self, id: u32) -> GeopResult<&mut CageVertex>

Source

pub fn face(&self, id: u32) -> GeopResult<&CageFace>

The face id.

Source

pub fn fresh_id(&mut self) -> u32

An id no element has had yet.

Source

pub fn edges(&self) -> BTreeSet<[u32; 2]>

Every edge, each by its two vertices, the smaller id first, in order.

Source

pub fn sharpness(&self, a: u32, b: u32) -> f64

How sharp the edge between a and b is creased: zero for a smooth edge, one for a sharp one (see Crease).

Source

pub fn is_crease(&self, a: u32, b: u32) -> bool

Whether the edge between a and b is creased at all.

Source

pub fn directed_edges(&self) -> HashMap<(u32, u32), (usize, usize)>

The face that runs along each directed edge (a, b), by its index and the corner of it at a. Two faces running the same way along an edge are turned against each other: the later one is kept, and Topology::new refuses the cage by name.

Source

pub fn indexed(&self) -> GeopResult<(Mesh, Topology)>

The cage indexed and its topology checked, for an edit that walks around vertices: vertex i of the mesh is self.vertices[i], face f is self.faces[f].

Source§

impl Cage

Source

pub fn cuboid(size: [f64; 3]) -> Self

A box around the origin, size long along each axis: eight vertices, six quads.

Source

pub fn cylinder(radius: f64, height: f64, segments: usize) -> Self

A cylinder around the z axis, centred on the origin: segments quads around, two rows high, closed by an n-gon at each end.

Source

pub fn sphere(radius: f64) -> Self

A sphere-like cage around the origin: a cube of 2 x 2 quads a side, its vertices pushed out onto the sphere of radius.

Source

pub fn plane(size: f64, n: usize) -> Self

A flat square in the z = 0 plane around the origin, size wide, of n x n quads facing +z: an open cage, whose limit is a sheet.

Source

pub fn has(&self, element: Element) -> bool

Whether the cage has the element element.

Source

pub fn vertices_of(&self, keys: &[String]) -> BTreeSet<u32>

The vertices of the elements keys name, by id.

Source

pub fn centre(&self, vertices: &BTreeSet<u32>) -> Option<[f64; 3]>

The centre of the vertices vertices: their average.

Source

pub fn transform( &mut self, vertices: &BTreeSet<u32>, mirror: Mirror, f: impl Fn([f64; 3]) -> [f64; 3], )

The vertices vertices moved to where f takes them — those on the plane of mirror kept on it, where the mirror image joins them.

Source

pub fn set_sharpness(&mut self, edges: &[[u32; 2]], sharpness: f64)

Creases the edges edges at sharpness (see Crease): one is sharp, zero or less smooths them again, and more than one is sharp.

Source

pub fn delete_faces(&mut self, faces: &BTreeSet<u32>)

Deletes the faces faces, and every vertex and crease that leaves without a face.

Source

pub fn faces_along(&self, edges: &[[u32; 2]]) -> BTreeSet<u32>

The faces any of the edges edges is on, by id.

Source

pub fn faces_around(&self, vertices: &BTreeSet<u32>) -> BTreeSet<u32>

The faces any of the vertices vertices is a corner of, by id.

Source

pub fn frame(&self, faces: &BTreeSet<u32>) -> Option<[[f64; 3]; 3]>

The orientation of the faces faces, for moving them along it: z along their normals together, x along the first one’s first edge, both unit and square to each other. None for no faces, or faces whose normals cancel out.

Source

pub fn extrude( &mut self, faces: &BTreeSet<u32>, distance: f64, mirror: Mirror, ) -> GeopResult<()>

Extrudes the faces faces distance along their normals (see Cage::offset_region).

Source

pub fn inset( &mut self, faces: &BTreeSet<u32>, thickness: f64, mirror: Mirror, ) -> GeopResult<()>

Insets the faces faces: their rim moves thickness inwards, in the faces’ own planes, and a new ring of quads fills the gap to where the rim was (see Cage::offset_region). A vertex inside the region stays.

Source

pub fn insert_loop(&mut self, a: u32, b: u32, t: f64) -> GeopResult<()>

Cuts a new edge loop across the edge between a and b: through every edge of its ring (see Cage::edge_ring) at the fraction t of the way along it from a’s side, splitting each quad of the ring in two. The halves of a creased edge keep its crease.

Source

pub fn edge_slide( &mut self, edges: &[[u32; 2]], factor: f64, mirror: Mirror, ) -> GeopResult<()>

Slides the vertices of the chain of edges edges along the edges leaving the chain, by the fraction factor of their length: towards the side the faces running along the chain, oriented from its first edge, lie on for a positive factor, the other side for a negative one. Each vertex needs one edge to slide along on that side, which the quads of the chain’s faces give it: a vertex where the chain branches, or where its faces disagree, is refused by name.

Source

pub fn bevel( &mut self, edges: &[[u32; 2]], width: f64, mirror: Mirror, ) -> GeopResult<()>

Bevels the edges edges: each becomes a strip of one quad, width wide, between the two faces along it, and each vertex where three or more bevelled edges meet a face of its own. A vertex is split into one vertex per sector — the faces around it between two bevelled edges — placed width from both edges in the sector’s first and last face. At a vertex with one bevelled edge the strip ends on the faces beside it: its end vertices lie width along the two other edges of the edge’s faces there, which split there, and a triangle caps the strip between them and the vertex — which goes if that leaves it between two faces, as at a box’s corner. Edges on the boundary cannot be bevelled.

Source

pub fn merge_vertices( &mut self, vertices: &BTreeSet<u32>, mirror: Mirror, ) -> GeopResult<()>

Merges the vertices vertices into one at their centre — on the mirror plane if any of them was — keeping the lowest id. A face left with fewer than three corners goes; one that would run through the merged vertex twice is refused by name.

Source

pub fn dissolve_edges( &mut self, edges: &[[u32; 2]], mirror: Mirror, ) -> GeopResult<()>

Dissolves the edges edges: the two faces along each become one, keeping the lower id, and an end left between those two faces alone goes with it. An edge with one face, or two faces that meet along more than that edge, is refused by name.

Source

pub fn dissolve_vertices( &mut self, vertices: &BTreeSet<u32>, mirror: Mirror, ) -> GeopResult<()>

Dissolves the vertices vertices: the faces around each become one face, keeping the lowest id, and the vertex goes — as does any neighbour of it left between two faces alone. Faces around it that meet elsewhere than at it are refused by name.

Source

pub fn bridge(&mut self, a: u32, b: u32, mirror: Mirror) -> GeopResult<()>

Bridges the faces a and b: both go, and a ring of quads joins their rims, each corner of a to the nearest corner of b going the other way round — a tunnel through the body, or a handle between two of its faces. The faces need the same number of corners. With a mirror, a quad that would lie in its plane is the seam to the mirror image, and is left out.

Source

pub fn fill_hole(&mut self, a: u32, b: u32, mirror: Mirror) -> GeopResult<()>

Fills the hole the open edge between a and b is on with one face through all the vertices around it (see Cage::boundary_run). With a mirror, a hole whose rim lies in the plane is the seam to the mirror image, and is refused.

Source

pub fn halve(&mut self, axis: usize) -> GeopResult<()>

Cuts the cage at the plane where coordinate axis is zero and keeps the half where it is positive, as a mirrored cage holds it. Every edge reaching across the plane is split where it crosses, the new vertex exactly on the plane. A face crossing the plane more than twice is refused, by name.

Source

pub fn unmirrored(&self, mirror: Mirror) -> GeopResult<Cage>

The whole cage the mirrored half stands for, as a cage of its own: the half keeps its ids, the mirror image gets new ones.

Source§

impl Cage

Source

pub fn edge_ring(&self, a: u32, b: u32) -> GeopResult<Ring>

The edge ring through the edge between a and b (see Ring).

Source

pub fn edge_loop(&self, a: u32, b: u32) -> GeopResult<Vec<[u32; 2]>>

The edge loop through the edge between a and b: on through each vertex of four edges by the edge opposite — the one sharing no face with the edge arrived by — until the loop closes or reaches a vertex of any other number of edges, or the boundary. A boundary edge’s loop is the boundary it is on (see Cage::boundary_run).

Source

pub fn is_boundary(&self, a: u32, b: u32) -> bool

Whether only one face runs along the edge between a and b.

Source

pub fn boundary_run(&self, a: u32, b: u32) -> GeopResult<Vec<u32>>

The boundary the open edge between a and b is on, as the vertices around it, in the order the faces along it run: a face closing it runs the other way. Fails for an edge that is not on the boundary, and for a boundary that touches itself at a vertex, by name.

Trait Implementations§

Source§

impl Clone for Cage

Source§

fn clone(&self) -> Cage

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 Cage

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Cage

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Cage

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl Serialize for Cage

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Cage

Auto Trait Implementations§

§

impl Freeze for Cage

§

impl RefUnwindSafe for Cage

§

impl Send for Cage

§

impl Sync for Cage

§

impl Unpin for Cage

§

impl UnsafeUnpin for Cage

§

impl UnwindSafe for Cage

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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.