Struct MeshGraph

Source
pub struct MeshGraph {
    pub qbvh: Qbvh<Face>,
    pub qbvh_workspace: QbvhUpdateWorkspace,
    pub index_to_face_id: Vec<FaceId>,
    pub vertices: SlotMap<VertexId, Vertex>,
    pub halfedges: SlotMap<HalfedgeId, Halfedge>,
    pub faces: SlotMap<FaceId, Face>,
    pub positions: SecondaryMap<VertexId, Vec3>,
    pub vertex_normals: Option<SecondaryMap<VertexId, Vec3>>,
}
Expand description

Halfedge data structure for representing triangle meshes.

Please see the crate documentation for more information.

Fields§

§qbvh: Qbvh<Face>

Acceleration structure for fast spatial queries. Uses parry3d’s Qbvh to implement some of parry3d’s spatial queries.

§qbvh_workspace: QbvhUpdateWorkspace

Used in conjunction with the QBVH to accelerate spatial queries.

§index_to_face_id: Vec<FaceId>

Used to map indices stored in the QBVH to face IDs.

§vertices: SlotMap<VertexId, Vertex>

Maps vertex IDs to their corresponding graph node

§halfedges: SlotMap<HalfedgeId, Halfedge>

Maps halfedge IDs to their corresponding graph node

§faces: SlotMap<FaceId, Face>

Maps face IDs to their corresponding graph node

§positions: SecondaryMap<VertexId, Vec3>

Maps vertex IDs to their corresponding positions

§vertex_normals: Option<SecondaryMap<VertexId, Vec3>>

Maps vertex IDs to their corresponding normals

Implementations§

Source§

impl MeshGraph

Source

pub fn faces_share_edge(&self, face_id1: FaceId, face_id2: FaceId) -> bool

Test if two faces have at least one halfedge in common.

Source

pub fn faces_share_all_vertices( &self, face_id1: FaceId, face_id2: FaceId, ) -> bool

Test if two faces share all vertices.

Source

pub fn halfedges_share_all_vertices( &self, halfedge_id1: HalfedgeId, halfedge_id2: HalfedgeId, ) -> bool

Test if two halfedges share all vertices.

Source

pub fn vertices_share_position( &self, vertex_id1: VertexId, vertex_id2: VertexId, ) -> bool

Test if two vertices have the exact same position.

Source

pub fn make_outgoing_halfedge_boundary_if_possible( &mut self, _vertex_id: VertexId, )

Source§

impl MeshGraph

Source

pub fn collapse_until_edges_above_min_length( &mut self, min_length_squared: f32, selection: &mut Selection, )

Collapses edges until all edges have a length above the minimum length.

This will schedule necessary updates to the QBVH but you have to call refit() and maybe rebalance() after the operation.

Source

pub fn collapse_edge( &mut self, halfedge_id: HalfedgeId, ) -> (Vec<VertexId>, Vec<HalfedgeId>, Vec<FaceId>)

Collapse an edge in the mesh graph.

This moves the start vertex of the edge to the center of the edge and removes the end vertex and the adjacent and opposite faces.

It also performs a cleanup afterwards to remove flaps (faces that share the same vertices).

Returns the vertices, halfedges and faces that were removed.

Source§

impl MeshGraph

Source

pub fn delete_face( &mut self, face_id: FaceId, ) -> (Vec<VertexId>, Vec<HalfedgeId>)

Deletes a face from the mesh graph.

It also deletes the vertices and halfedges that are no longer connected to any other faces.

Returns the ids of the removed vertices and halfedges.

Source§

impl MeshGraph

Source

pub fn insert_vertex(&mut self, position: Vec3) -> VertexId

Inserts a vertex and it’s position into the mesh graph. It doesn’t do any connections.

Source

pub fn insert_halfedge(&mut self, end_vertex: VertexId) -> HalfedgeId

Inserts a halfedge into the mesh graph. It only connects the halfedge to the given end vertex but not the reverse. It also doesn’t do any other connections.

Source

pub fn insert_face(&mut self, halfedge: HalfedgeId) -> FaceId

Inserts a face into the mesh graph. It only connects the face to the given halfedge but not the reverse. It also doesn’t do any other connections.

Source§

impl MeshGraph

Source

pub fn triangle(&self, face: Face) -> Triangle

Source§

impl MeshGraph

Source

pub fn subdivide_edge(&mut self, halfedge_id: HalfedgeId) -> Vec<HalfedgeId>

Subdivides an edge by computing it’s center vertex. This also subdivides any adjacent triangles and makes sure everything is properly reconnected. Works only on triangle meshes.

Returns the id of the new halfedge which goes from the center vertex to the original edge’s end vertex. And also return the halfedges that are created by subdividing the adjacent faces. Only one of the two twin halfedges per face subdivision is returned. In total the number n of halfedges returned is 1 <= n <= 3. (The one from dividing the halfedge and at most 2 from dividing the two adjacent faces).

Source

pub fn subdivide_until_edges_below_max_length( &mut self, max_length_squared: f32, selection: &mut Selection, )

Subdivide all edges in the selection until all of them are <= max_length. Please note that you have to provide the squared value of max_length. All new edges created during this process are added to the selection.

This will schedule necessary updates to the QBVH but you have to call refit() and maybe rebalance() after the operation.

Source§

impl MeshGraph

Source

pub fn triangles(vertex_positions: &[Vec3]) -> Self

Create a triangle mesh graph from vertex positions. Every three positions represent a triangle.

Vertices with the same position are merged into a single vertex.

Source

pub fn indexed_triangles( vertex_positions: &[Vec3], face_indices: &[usize], ) -> Self

Create a triangle mesh graph from vertex positions and face indices. Every chunk of three indices represents a triangle.

Source

pub fn compute_vertex_normals(&mut self)

Computes the vertex normals by averaging over the computed face normals

Source

pub fn normalize_vertex_normals(&mut self)

Ensures that the vertex normals are all normalized

Source

pub fn rebalance_qbvh(&mut self)

Source

pub fn refit_qbvh(&mut self)

Recomputes the bounding boxes of the QBVH. This is necessary when the mesh is modified.

It does not no change the topology of the QBVH. Call rebalance_qbvh to to that.

Source

pub fn rebuild_qbvh(&mut self)

Clear and rebuild the QBVH.

Trait Implementations§

Source§

impl Clone for MeshGraph

Source§

fn clone(&self) -> MeshGraph

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl From<IcoSphere> for MeshGraph

Source§

fn from(isosphere: IcoSphere) -> Self

Converts to this type from the input type.
Source§

impl From<MeshGraph> for VertexIndexBuffers

Source§

fn from(mesh_graph: MeshGraph) -> VertexIndexBuffers

Converts to this type from the input type.
Source§

impl From<Quad> for MeshGraph

Source§

fn from(quad: Quad) -> Self

Converts to this type from the input type.
Source§

impl From<Triangle> for MeshGraph

Source§

fn from(triangle: Triangle) -> Self

Converts to this type from the input type.
Source§

impl PointQuery for MeshGraph

Source§

fn project_local_point( &self, point: &Point<f32>, solid: bool, ) -> PointProjection

Projects a point on self. Read more
Source§

fn project_local_point_and_get_feature( &self, _point: &Point<f32>, ) -> (PointProjection, FeatureId)

Projects a point on the boundary of self and returns the id of the feature the point was projected on.
Source§

fn project_local_point_with_max_dist( &self, pt: &OPoint<f32, Const<3>>, solid: bool, max_dist: f32, ) -> Option<PointProjection>

Projects a point on self, unless the projection lies further than the given max distance. Read more
Source§

fn project_point_with_max_dist( &self, m: &Isometry<f32, Unit<Quaternion<f32>>, 3>, pt: &OPoint<f32, Const<3>>, solid: bool, max_dist: f32, ) -> Option<PointProjection>

Projects a point on self transformed by m, unless the projection lies further than the given max distance.
Source§

fn distance_to_local_point( &self, pt: &OPoint<f32, Const<3>>, solid: bool, ) -> f32

Computes the minimal distance between a point and self.
Source§

fn contains_local_point(&self, pt: &OPoint<f32, Const<3>>) -> bool

Tests if the given point is inside of self.
Source§

fn project_point( &self, m: &Isometry<f32, Unit<Quaternion<f32>>, 3>, pt: &OPoint<f32, Const<3>>, solid: bool, ) -> PointProjection

Projects a point on self transformed by m.
Source§

fn distance_to_point( &self, m: &Isometry<f32, Unit<Quaternion<f32>>, 3>, pt: &OPoint<f32, Const<3>>, solid: bool, ) -> f32

Computes the minimal distance between a point and self transformed by m.
Source§

fn project_point_and_get_feature( &self, m: &Isometry<f32, Unit<Quaternion<f32>>, 3>, pt: &OPoint<f32, Const<3>>, ) -> (PointProjection, FeatureId)

Projects a point on the boundary of self transformed by m and returns the id of the feature the point was projected on.
Source§

fn contains_point( &self, m: &Isometry<f32, Unit<Quaternion<f32>>, 3>, pt: &OPoint<f32, Const<3>>, ) -> bool

Tests if the given point is inside of self transformed by m.
Source§

impl PointQueryWithLocation for MeshGraph

Source§

fn project_local_point_and_get_location_with_max_dist( &self, point: &Point<f32>, solid: bool, max_dist: f32, ) -> Option<(PointProjection, Self::Location)>

Projects a point on self, with a maximum projection distance.

Source§

type Location = (Face, ())

Additional shape-specific projection information Read more
Source§

fn project_local_point_and_get_location( &self, point: &Point<f32>, solid: bool, ) -> (PointProjection, Self::Location)

Projects a point on self.
Source§

fn project_point_and_get_location( &self, m: &Isometry<f32, Unit<Quaternion<f32>>, 3>, pt: &OPoint<f32, Const<3>>, solid: bool, ) -> (PointProjection, Self::Location)

Projects a point on self transformed by m.
Source§

fn project_point_and_get_location_with_max_dist( &self, m: &Isometry<f32, Unit<Quaternion<f32>>, 3>, pt: &OPoint<f32, Const<3>>, solid: bool, max_dist: f32, ) -> Option<(PointProjection, Self::Location)>

Projects a point on self transformed by m, with a maximum projection distance.
Source§

impl RayCast for MeshGraph

Source§

fn cast_local_ray( &self, ray: &Ray, max_time_of_impact: f32, solid: bool, ) -> Option<f32>

Computes the time of impact between this transform shape and a ray.
Source§

fn cast_local_ray_and_get_normal( &self, ray: &Ray, max_time_of_impact: f32, solid: bool, ) -> Option<RayIntersection>

Computes the time of impact, and normal between this transformed shape and a ray.
Source§

fn intersects_local_ray(&self, ray: &Ray, max_time_of_impact: f32) -> bool

Tests whether a ray intersects this transformed shape.
Source§

fn cast_ray( &self, m: &Isometry<f32, Unit<Quaternion<f32>>, 3>, ray: &Ray, max_time_of_impact: f32, solid: bool, ) -> Option<f32>

Computes the time of impact between this transform shape and a ray.
Source§

fn cast_ray_and_get_normal( &self, m: &Isometry<f32, Unit<Quaternion<f32>>, 3>, ray: &Ray, max_time_of_impact: f32, solid: bool, ) -> Option<RayIntersection>

Computes the time of impact, and normal between this transformed shape and a ray.
Source§

fn intersects_ray( &self, m: &Isometry<f32, Unit<Quaternion<f32>>, 3>, ray: &Ray, max_time_of_impact: f32, ) -> bool

Tests whether a ray intersects this transformed shape.
Source§

impl TypedSimdCompositeShape for MeshGraph

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> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSend for T
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Sync + Send>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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

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

fn is_in_subset(&self) -> bool

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

fn to_subset_unchecked(&self) -> SS

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

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