Skip to main content

Editable

Struct Editable 

Source
pub struct Editable { /* private fields */ }
Expand description

An indexed triangle mesh held as half-edges, for editing.

Built by Editable::from; read back by Editable::to_triangulation. See the module documentation for how faces are joined, how a point several fans meet is split, and what numbers survive an edit. Edits take &mut self and run on one thread; queries take &self, and the mesh is Send and Sync.

Implementations§

Source§

impl Editable

Source

pub fn cut( &mut self, plane: &Plane, keep: Side, cap: Option<Cap>, ) -> OgeomResult<CutReport>

Cut the mesh by plane, keeping the faces on side keep and the kept parts of the faces it crosses, and cap the cut flat when cap asks. See the module documentation for how the cut is made and capped.

Kept vertices keep their numbers and their source_vertex; the vertices the cut makes, on the edges it crosses, have none. Faces removed keep their numbers, unused; the kept parts of faces clipped, then the cap’s faces, take numbers after every face there is. A mesh closed before the cut and with every loop capped is closed after.

§Errors

OgeomError::Numeric if the plane’s origin is not finite or bridge is negative or not finite, and OgeomError::Range if the faces and vertices the cut may make would pass u32 numbering.

Source§

impl Editable

Source

pub fn fill(&mut self, rim: RimId, fill: &Fill) -> OgeomResult<FillReport>

Fill the rim rim with a patch of new faces, triangulated, refined and faired as fill asks. See the module documentation for how.

The patch shares every rim edge with the face beyond it, so the mesh is closed about it. A mesh whose every rim is filled is closed. No vertex of the mesh moves. A rim passing through a point more than once is closed about that point, whose vertices become one: the lowest-numbered keeps its number. New faces and vertices take numbers after every one there is, and the new vertices have no source_vertex. Nothing changes when the fill is refused.

§Errors
  • OgeomError::Dangling if rim names no rim: a half-edge that is not on a rim, or not the lowest-numbered of its rim.
  • OgeomError::Construction if the rim cannot be filled into a manifold: a loop of two edges, or a rim edge more faces use. Also if a loop has no triangulation without a face of collinear corners or an edge the mesh already has, if the loops’ triangulations would draw one edge twice, or if a long loop’s shadow on its plane crosses itself.
  • OgeomError::NotDone if ear clipping finds no ear it may cut.
  • OgeomError::Numeric if the fairing solve does not settle.
  • OgeomError::Range if the faces and vertices made would pass u32 numbering.
Source§

impl Editable

Source

pub fn offset( &mut self, distance: f64, region: Option<&[bool]>, ) -> OgeomResult<OffsetReport>

Offset the mesh by distance along its outward normals, outward where positive and inward where negative, and repair the folds that leaves, as the module documentation describes. With region, one entry per vertex number, only the faces whose corners are all in it move, as a step joined to the rest by a wall.

§Errors

OgeomError::Numeric if distance is not finite; OgeomError::Range if region does not have one entry per vertex number, or the wall’s vertices and faces would pass u32 numbering.

Source§

impl Editable

Source

pub fn simplify( &mut self, target: Target, tol: Tolerances, ) -> OgeomResult<SimplifyReport>

Decimate the mesh to target, as simplify decimates Editable::to_triangulation’s mesh, keeping every vertex’s source vertices: a vertex of the result has those of every vertex merged into it. See the module documentation for the numbering after.

§Errors

As simplify; nothing changes when it refuses.

Source§

impl Editable

Source

pub fn smooth(&mut self, smooth: &Smooth<'_>) -> OgeomResult<SmoothReport>

Smooth the mesh, moving its vertices onto local quadrics fitted to their neighbours, as the module documentation describes. Vertex and face numbers stay; only an edge of three or more faces may be joined anew, as its faces now stand.

§Errors

OgeomError::Numeric if size is not positive and finite, max_move is negative or not a number, or keep_edges is not an angle from zero to π; OgeomError::Range if region does not have one entry per vertex number.

Source§

impl Editable

Source

pub fn from(mesh: &Triangulation, weld: f64) -> OgeomResult<Self>

The mesh as half-edges, its vertices first welded within weld.

With weld zero the mesh’s own vertex numbers are the points, and a manifold mesh reads back from Editable::to_triangulation with the same vertices and the same triangles in the same order. With weld positive, vertices within weld of each other become one: each vertex in turn joins the lowest-numbered kept vertex within weld, found through a grid of cells weld wide, or is kept itself at its own position. A triangle naming one vertex twice, or two of whose corners became one, is removed, its face number unused.

Normals and surface parameters are not carried: an edit leaves neither true.

§Errors

OgeomError::Numeric if weld is negative or not finite, or a position is not finite; OgeomError::Range if a triangle names a vertex the mesh does not have, or the mesh has more half-edges and vertices than u32 numbers.

Source

pub fn to_triangulation(&self) -> Triangulation

The mesh’s vertices and faces, those an edit left, renumbered in order. A vertex no face of the source used is kept.

A vertex no edit touched keeps its position; a copy split off a point stands at the point’s position, so two vertices of the result may coincide.

Source

pub fn vertex_count(&self) -> usize

How many vertex numbers there are, including those of vertices gone.

Source

pub fn face_count(&self) -> usize

How many face numbers there are, including those of faces removed.

Source

pub fn position(&self, v: u32) -> Option<Point>

The position of vertex v, if it is there.

Source

pub fn face(&self, f: u32) -> Option<[u32; 3]>

The corners of face f, counter-clockwise about its outward normal, if it is there.

Source

pub fn edge(&self, h: u32) -> Option<[u32; 2]>

The vertices half-edge h runs from and to, if its face is there.

Source

pub fn source_vertex(&self, v: u32) -> Option<u32>

The source vertex vertex v came from, where it came from exactly one: the one it was welded onto, for every copy split off it and through every edit. None for a vertex an edit made, one a collapse left with several source vertices, or a number past the last.

Source

pub fn source_vertices(&self, v: u32) -> &[u32]

The source vertices vertex v came from, in increasing order: one for a vertex carried from the source, every one merged into it for a vertex a collapse kept, and none for a vertex an edit made or a number past the last. See the module documentation.

Source

pub fn source_count(&self) -> usize

How many vertices the source had: the length of a marking of them. Editable::simplify keeps the count of the mesh first built.

Source

pub fn region_from_sources(&self, marked: &[bool]) -> OgeomResult<Vec<bool>>

The region, one entry per vertex number, that a marking of the source’s vertices selects: the vertices that have at least one source vertex, and every one of them marked. A vertex an edit made, with none, and a vertex gone, are not selected. The result is what Editable::offset and Smooth::region take.

§Errors

OgeomError::Range if marked does not have one entry per source vertex, as Editable::source_count counts them.

Source

pub fn is_closed(&self) -> bool

Whether there is a face and every edge of every face is joined to another face.

Source

pub fn non_manifold(&self) -> Vec<u32>

The vertices where the faces as they stand are not a manifold, in increasing order: each copy of a point several fans meet, and both ends of each edge that more than two faces use, or that two faces run the same way.

Source

pub fn components(&self) -> Vec<Component>

The connected pieces, faces joined across edges, in the order of their lowest-numbered faces.

Source

pub fn rims(&self) -> Vec<Rim>

The rims: the loops of half-edges with no twin, in the order of their lowest-numbered half-edges.

Source

pub fn remove_faces(&mut self, faces: &[u32])

Remove faces, and split each vertex whose faces left fall into several fans into one vertex per fan, so what is left stays a manifold. Faces not there are passed over.

Source

pub fn flip_faces(&mut self, faces: &[u32])

Reverse the winding of faces, and join or part the faces about them again by the same rule as Editable::from: an edge two faces now run the same way opens, and one they now run opposite ways closes. Each face is flipped once however often it is listed; faces not there are passed over.

Trait Implementations§

Source§

impl Clone for Editable

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 Editable

Source§

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

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

impl PartialEq for Editable

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Editable

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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,

§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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.