Skip to main content

SignData

Struct SignData 

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

Per-mesh data that decides the sign of a distance, built by SignData::build for one revision of a mesh and one state of its BVH.

In SignMode::Pseudonormal it holds a unit pseudonormal per vertex slot, an edge normal per triangle corner (for the edge opposite that corner) and, for every zero-area triangle, the non-degenerate triangles that share a vertex with it. Face normals are recomputed from the mesh when needed.

In SignMode::Winding it holds instead the order-1 dipole moments of every BVH node (area-weighted normal sum, area-weighted centroid and a bounding radius), for the fast winding number of Barill et al. 2018.

Implementations§

Source§

impl SignData

Source

pub fn build(mesh: &mut Mesh, bvh: &Bvh, mode: SignMode) -> Result<SignData>

Builds the sign data of mesh in mode, building the mesh’s adjacency and incidence first if they are not cached. Auto is resolved here (to Winding for a closed mesh with inconsistent orientation, to Pseudonormal otherwise); SignData::status reports the outcome.

§Errors
Source

pub fn try_refit( &mut self, mesh: &Mesh, bvh: &Bvh, changes: &ChangeSet, ) -> Result<bool>

Refits pseudonormal data in place after a position-only edit, recomputing only the vertex and edge normals around changes’ moved vertices (plus the signed volume, in O(n)). Returns whether the refit ran: false (a full SignData::build is needed) when the mode is not pseudonormal, the topology changed, vertices or triangles were added or removed, the slot counts changed, the mesh’s adjacency or incidence is not cached, the BVH is not current, or a dirty triangle changed its degenerate status. On true the data is current for mesh and bvh and identical to a rebuild.

§Errors

FieldsError::OutOfMemory when the dirty sets cannot be listed.

Source

pub fn winding_number(&self, mesh: &Mesh, bvh: &Bvh, p: [f32; 3]) -> f64

The generalized winding number of mesh at p: the sum of the solid angles of its triangles seen from p, over 4π. It is 1 inside a closed, outward-facing mesh, 0 outside it, and in between near holes.

In SignMode::Winding this is the fast approximation of Barill et al. 2018, order 1: a BVH node whose centroid is more than beta = 8 times its radius away from p contributes its dipole term, and nearer leaves sum their triangles’ exact solid angles (Van Oosterom–Strackee). It is within 1e-3 of the exact value on the closed test meshes at points farther than 1% of the bounding-box diagonal from the surface; on a flat terrain the error is larger (about 1.2e-3, tested against 2e-3), since the errors of a flat sheet add up. In SignMode::Pseudonormal no moments are stored and every triangle is summed exactly, which is slow on large meshes.

Returns NaN when this data is not current for mesh and bvh (see SignData::is_current). Nothing is allocated.

Source

pub fn is_boundary_hit(mesh: &Mesh, hit: &ClosestHit) -> Option<bool>

Whether the closest feature of hit touches a boundary edge of mesh: a face interior never does, an edge when it is used by one triangle only, a vertex when any edge at it is. A point past an open rim is signed by the plane of its boundary face, so an antagonist vertex just beyond a scan’s margin can read as penetration; apps can use this to detect that halo. Returns None when the mesh’s adjacency (or, for a vertex, its incidence) is not cached, or hit is not on an alive triangle.

Source

pub fn status(&self) -> SignStatus

What the build found out about the mesh, and the resolved mode.

Source

pub fn mode(&self) -> SignMode

The resolved mode: never SignMode::Auto.

Source

pub fn is_current(&self, mesh: &Mesh, bvh: &Bvh) -> bool

True when this data was built for mesh at its current revision and epoch, and for bvh at its current generation.

Trait Implementations§

Source§

impl Clone for SignData

Source§

fn clone(&self) -> SignData

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 SignData

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> 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.