pub struct MeshRegions { /* private fields */ }Expand description
The regions of a mesh, found and not yet built.
MeshRegions::find welds, cleans and orients the mesh and gathers its
triangles into regions, each on the surface recognition found for it;
MeshRegions::build places the seams and corners and builds the
faces and the solid. solid_from_mesh is the
one followed by the other. Between them a region can be merged with a
neighbour (MeshRegions::merge), split along a path of mesh vertices
(MeshRegions::split), or given a surface of a chosen kind
(MeshRegions::fit), and the build that follows goes through the
same seams, corners, faces and checks as an automatic one: a region
corrected to what recognition would have found builds what recognition
would have built.
Every surface a step puts on a region is verified as recognition’s are:
every vertex of the region within the coplanar distance of it, and
every curved surface’s triangles no farther off it in their middles
than their own sag. A step that cannot be taken is refused by name
(RegionRefusal), the regions unchanged.
A region a step left on a surface goes through the passes recognition
runs over its own regions: a round meeting two planes across smooth
edges is put on the cylinder tangent to both, and a round, ball or
torus among fillets on the surface its supports fix (see
MeshRegions::fit for the fits that keep what they were given). A
planar region of one or two triangles a step made is built as its own
face, never given to a curved neighbour as the build gives the facets
recognition leaves. A curved region the build cannot place falls back
to facets and is named in MeshSolidReport::fallbacks, with why.
Indices name the mesh as the regions read it: MeshRegions::points
and MeshRegions::triangles, welded, cleaned and oriented, not the
mesh handed to MeshRegions::find (MeshRegions::vertex_of maps
its vertices).
Implementations§
Source§impl MeshRegions
impl MeshRegions
Sourcepub fn find(
mesh: &Triangulation,
options: &MeshSolidOptions,
tol: Tolerances,
) -> OgeomResult<Self>
pub fn find( mesh: &Triangulation, options: &MeshSolidOptions, tol: Tolerances, ) -> OgeomResult<Self>
Weld, clean and orient the mesh, and gather its triangles into
regions as solid_from_mesh does before it builds.
§Errors
As solid_from_mesh.
Sourcepub fn build(&self, model: &mut Model) -> OgeomResult<MeshSolid>
pub fn build(&self, model: &mut Model) -> OgeomResult<MeshSolid>
Build the solid from the regions as they stand, through the same
seams, corners, faces and checks as
solid_from_mesh. A region with no
surface is built as planar facets; a curved region whose boundary
cannot be placed on its surface falls back to facets, and the
report names it and why (MeshSolidReport::fallbacks): a region
a step put on a surface and named there did not hold. A planar
region of one or two triangles a step made stays a face of its own.
§Errors
As solid_from_mesh.
Sourcepub fn points(&self) -> &[Point]
pub fn points(&self) -> &[Point]
The mesh’s vertices as the regions read them, welded and numbered in the order of their positions.
Sourcepub fn triangles(&self) -> &[[u32; 3]]
pub fn triangles(&self) -> &[[u32; 3]]
The mesh’s triangles as the regions read them: without the ones of no area or repeated, wound consistently and outward, and listed by their corners’ positions rather than as the input listed them.
Sourcepub fn vertex_of(&self, input: usize) -> Option<u32>
pub fn vertex_of(&self, input: usize) -> Option<u32>
The vertex of MeshRegions::points the input mesh’s vertex
input was welded into; None past the input’s vertices.
Sourcepub fn distance(&self) -> f64
pub fn distance(&self) -> f64
The coplanar distance the regions were found to, and every surface put on a region is verified at.
Sourcepub fn report(&self) -> &MeshSolidReport
pub fn report(&self) -> &MeshSolidReport
What finding the regions measured of the mesh: its welds, dropped triangles, windings and closure. The build’s report starts from it.
Sourcepub fn regions(&self) -> Vec<MeshRegion>
pub fn regions(&self) -> Vec<MeshRegion>
Every region holding triangles, in the order of their names.
Sourcepub fn region(&self, id: RegionId) -> Option<MeshRegion>
pub fn region(&self, id: RegionId) -> Option<MeshRegion>
One region, or None where no region of that name holds triangles.
Sourcepub fn merge(
&mut self,
a: RegionId,
b: RegionId,
) -> Result<RegionId, RegionRefusal>
pub fn merge( &mut self, a: RegionId, b: RegionId, ) -> Result<RegionId, RegionRefusal>
Merge region b into region a, which must share a mesh edge.
The merged region takes the surface recognition finds for its
triangles as a whole (a plane where they all lie within the
distance of one, otherwise a cylinder, cone, sphere, torus or sweep
where one verifies); where none does, the surface of the larger of
the two where it holds the other’s vertices (unless that is a patch,
fitted to the larger alone); then, with
MeshSolidOptions::patches, a patch fitted to the whole where it
is one disk and the patch verifies; and otherwise none, which
builds as facets. b is retired and the merged region keeps the
name a.
§Errors
RegionRefusal::NoSuchRegion, RegionRefusal::SameRegion or
RegionRefusal::NotAdjacent.
Sourcepub fn split(
&mut self,
id: RegionId,
path: &[u32],
) -> Result<(RegionId, RegionId), RegionRefusal>
pub fn split( &mut self, id: RegionId, path: &[u32], ) -> Result<(RegionId, RegionId), RegionRefusal>
Split a region in two along a path of mesh vertices, consecutive ones joined by edges of the region’s triangles: a path across the region from boundary to boundary, or a closed one (its last vertex its first) round part of it.
Each piece takes the surface recognition finds for it, as a merged region does, and otherwise keeps the region’s own (which holds it, as it held the whole); a piece of a region with no surface takes a patch as a merged region does. The piece holding the region’s first triangle keeps the name; the other is named anew.
§Errors
RegionRefusal::NoSuchRegion, RegionRefusal::PathTooShort,
RegionRefusal::NotAnEdgeOfTheRegion or
RegionRefusal::DoesNotCut where the path leaves the region in
one piece or in more than two.
Sourcepub fn fit(
&mut self,
id: RegionId,
kind: SurfaceKind,
constraints: &FitConstraints,
) -> Result<f64, RegionRefusal>
pub fn fit( &mut self, id: RegionId, kind: SurfaceKind, constraints: &FitConstraints, ) -> Result<f64, RegionRefusal>
Fit a surface of the kind to the region, holding what constraints
fix, and put the region on it where it verifies: every vertex of
the region within the coplanar distance, and every triangle’s middle
no farther off it than its sag. Returns the worst distance from a
vertex to the surface.
The fit is least squares on the vertices’ distances to the surface. With an axis fixed it is the surface about that line (a cylinder’s radius the vertices’ mean distance from it, a torus’s spine from the circle its profile traces); with a radius fixed the rest moves about it. An axis fixed is kept as given; otherwise the axis is set square to a plane of the solid it all but is square to, and onto a coaxial region’s, where the surface still verifies there, as recognition does. A fit holding nothing then goes through the tangent passes as recognition’s regions do (a round between two planes put on the cylinder tangent to both, a fillet on the surface its supports fix), where the surface they give still verifies; a fit holding an axis or a radius keeps the surface it was given.
A SurfaceKind::Patch is fitted over the region’s triangles by
the automatic conversion’s own patch fit and verification, whatever
MeshSolidOptions::patches says, and is kept as fitted.
§Errors
RegionRefusal::NoSuchRegion,
RegionRefusal::ConstraintDoesNotApply,
RegionRefusal::InvalidRadius, RegionRefusal::TooFewVertices,
RegionRefusal::NoFit, RegionRefusal::DoesNotVerify or
RegionRefusal::TriangleOffTheSurface; for a patch,
RegionRefusal::NotADisk, RegionRefusal::TooNarrowForAPatch
or RegionRefusal::PatchDoesNotVerify.
Trait Implementations§
Source§impl Clone for MeshRegions
impl Clone for MeshRegions
Auto Trait Implementations§
impl Freeze for MeshRegions
impl RefUnwindSafe for MeshRegions
impl Send for MeshRegions
impl Sync for MeshRegions
impl Unpin for MeshRegions
impl UnsafeUnpin for MeshRegions
impl UnwindSafe for MeshRegions
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<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.