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
impl Editable
Sourcepub fn cut(
&mut self,
plane: &Plane,
keep: Side,
cap: Option<Cap>,
) -> OgeomResult<CutReport>
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
impl Editable
Sourcepub fn fill(&mut self, rim: RimId, fill: &Fill) -> OgeomResult<FillReport>
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::Danglingifrimnames no rim: a half-edge that is not on a rim, or not the lowest-numbered of its rim.OgeomError::Constructionif 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::NotDoneif ear clipping finds no ear it may cut.OgeomError::Numericif the fairing solve does not settle.OgeomError::Rangeif the faces and vertices made would passu32numbering.
Source§impl Editable
impl Editable
Sourcepub fn offset(
&mut self,
distance: f64,
region: Option<&[bool]>,
) -> OgeomResult<OffsetReport>
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
impl Editable
Sourcepub fn simplify(
&mut self,
target: Target,
tol: Tolerances,
) -> OgeomResult<SimplifyReport>
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
impl Editable
Sourcepub fn smooth(&mut self, smooth: &Smooth<'_>) -> OgeomResult<SmoothReport>
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
impl Editable
Sourcepub fn from(mesh: &Triangulation, weld: f64) -> OgeomResult<Self>
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.
Sourcepub fn to_triangulation(&self) -> Triangulation
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.
Sourcepub fn vertex_count(&self) -> usize
pub fn vertex_count(&self) -> usize
How many vertex numbers there are, including those of vertices gone.
Sourcepub fn face_count(&self) -> usize
pub fn face_count(&self) -> usize
How many face numbers there are, including those of faces removed.
Sourcepub fn face(&self, f: u32) -> Option<[u32; 3]>
pub fn face(&self, f: u32) -> Option<[u32; 3]>
The corners of face f, counter-clockwise about its outward
normal, if it is there.
Sourcepub fn edge(&self, h: u32) -> Option<[u32; 2]>
pub fn edge(&self, h: u32) -> Option<[u32; 2]>
The vertices half-edge h runs from and to, if its face is there.
Sourcepub fn source_vertex(&self, v: u32) -> Option<u32>
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.
Sourcepub fn source_vertices(&self, v: u32) -> &[u32]
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.
Sourcepub fn source_count(&self) -> usize
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.
Sourcepub fn region_from_sources(&self, marked: &[bool]) -> OgeomResult<Vec<bool>>
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.
Sourcepub fn is_closed(&self) -> bool
pub fn is_closed(&self) -> bool
Whether there is a face and every edge of every face is joined to another face.
Sourcepub fn non_manifold(&self) -> Vec<u32>
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.
Sourcepub fn components(&self) -> Vec<Component>
pub fn components(&self) -> Vec<Component>
The connected pieces, faces joined across edges, in the order of their lowest-numbered faces.
Sourcepub fn rims(&self) -> Vec<Rim>
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.
Sourcepub fn remove_faces(&mut self, faces: &[u32])
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.
Sourcepub fn flip_faces(&mut self, faces: &[u32])
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§
impl StructuralPartialEq for Editable
Auto Trait Implementations§
impl Freeze for Editable
impl RefUnwindSafe for Editable
impl Send for Editable
impl Sync for Editable
impl Unpin for Editable
impl UnsafeUnpin for Editable
impl UnwindSafe for Editable
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> Scalar for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.