Skip to main content

MeshRegions

Struct MeshRegions 

Source
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

Source

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.

Source

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.

Source

pub fn points(&self) -> &[Point]

The mesh’s vertices as the regions read them, welded and numbered in the order of their positions.

Source

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.

Source

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.

Source

pub fn distance(&self) -> f64

The coplanar distance the regions were found to, and every surface put on a region is verified at.

Source

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.

Source

pub fn region_of(&self, triangle: usize) -> Option<RegionId>

The region holding a triangle.

Source

pub fn ids(&self) -> Vec<RegionId>

The names of the regions holding triangles, ascending.

Source

pub fn regions(&self) -> Vec<MeshRegion>

Every region holding triangles, in the order of their names.

Source

pub fn region(&self, id: RegionId) -> Option<MeshRegion>

One region, or None where no region of that name holds triangles.

Source

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.

Source

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.

Source

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

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 MeshRegions

Source§

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

Formats the value using the given formatter. Read more

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
§

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.