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
impl MeshGraph
Test if two faces have at least one halfedge in common.
Test if two faces share all vertices.
Test if two halfedges share all vertices.
Test if two vertices have the exact same position.
pub fn make_outgoing_halfedge_boundary_if_possible( &mut self, _vertex_id: VertexId, )
Source§impl MeshGraph
impl MeshGraph
Sourcepub fn collapse_until_edges_above_min_length(
&mut self,
min_length_squared: f32,
selection: &mut Selection,
)
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.
Sourcepub fn collapse_edge(
&mut self,
halfedge_id: HalfedgeId,
) -> (Vec<VertexId>, Vec<HalfedgeId>, Vec<FaceId>)
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
impl MeshGraph
Sourcepub fn delete_face(
&mut self,
face_id: FaceId,
) -> (Vec<VertexId>, Vec<HalfedgeId>)
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
impl MeshGraph
Sourcepub fn insert_vertex(&mut self, position: Vec3) -> VertexId
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.
Sourcepub fn insert_halfedge(&mut self, end_vertex: VertexId) -> HalfedgeId
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.
Sourcepub fn insert_face(&mut self, halfedge: HalfedgeId) -> FaceId
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
impl MeshGraph
Sourcepub fn subdivide_edge(&mut self, halfedge_id: HalfedgeId) -> Vec<HalfedgeId>
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).
Sourcepub fn subdivide_until_edges_below_max_length(
&mut self,
max_length_squared: f32,
selection: &mut Selection,
)
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
impl MeshGraph
Sourcepub fn triangles(vertex_positions: &[Vec3]) -> Self
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.
Sourcepub fn indexed_triangles(
vertex_positions: &[Vec3],
face_indices: &[usize],
) -> Self
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.
Sourcepub fn compute_vertex_normals(&mut self)
pub fn compute_vertex_normals(&mut self)
Computes the vertex normals by averaging over the computed face normals
Sourcepub fn normalize_vertex_normals(&mut self)
pub fn normalize_vertex_normals(&mut self)
Ensures that the vertex normals are all normalized
pub fn rebalance_qbvh(&mut self)
Sourcepub fn refit_qbvh(&mut self)
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.
Sourcepub fn rebuild_qbvh(&mut self)
pub fn rebuild_qbvh(&mut self)
Clear and rebuild the QBVH.
Trait Implementations§
Source§impl From<MeshGraph> for VertexIndexBuffers
impl From<MeshGraph> for VertexIndexBuffers
Source§fn from(mesh_graph: MeshGraph) -> VertexIndexBuffers
fn from(mesh_graph: MeshGraph) -> VertexIndexBuffers
Source§impl PointQuery for MeshGraph
impl PointQuery for MeshGraph
Source§fn project_local_point(
&self,
point: &Point<f32>,
solid: bool,
) -> PointProjection
fn project_local_point( &self, point: &Point<f32>, solid: bool, ) -> PointProjection
self
. Read moreSource§fn project_local_point_and_get_feature(
&self,
_point: &Point<f32>,
) -> (PointProjection, FeatureId)
fn project_local_point_and_get_feature( &self, _point: &Point<f32>, ) -> (PointProjection, FeatureId)
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>
fn project_local_point_with_max_dist( &self, pt: &OPoint<f32, Const<3>>, solid: bool, max_dist: f32, ) -> Option<PointProjection>
self
, unless the projection lies further than the given max distance. Read moreSource§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>
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>
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
fn distance_to_local_point( &self, pt: &OPoint<f32, Const<3>>, solid: bool, ) -> f32
self
.Source§fn contains_local_point(&self, pt: &OPoint<f32, Const<3>>) -> bool
fn contains_local_point(&self, pt: &OPoint<f32, Const<3>>) -> bool
self
.Source§fn project_point(
&self,
m: &Isometry<f32, Unit<Quaternion<f32>>, 3>,
pt: &OPoint<f32, Const<3>>,
solid: bool,
) -> PointProjection
fn project_point( &self, m: &Isometry<f32, Unit<Quaternion<f32>>, 3>, pt: &OPoint<f32, Const<3>>, solid: bool, ) -> PointProjection
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
fn distance_to_point( &self, m: &Isometry<f32, Unit<Quaternion<f32>>, 3>, pt: &OPoint<f32, Const<3>>, solid: bool, ) -> f32
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)
fn project_point_and_get_feature( &self, m: &Isometry<f32, Unit<Quaternion<f32>>, 3>, pt: &OPoint<f32, Const<3>>, ) -> (PointProjection, FeatureId)
self
transformed by m
and returns the id of the
feature the point was projected on.Source§impl PointQueryWithLocation for MeshGraph
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)>
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§fn project_local_point_and_get_location(
&self,
point: &Point<f32>,
solid: bool,
) -> (PointProjection, Self::Location)
fn project_local_point_and_get_location( &self, point: &Point<f32>, solid: bool, ) -> (PointProjection, Self::Location)
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)
fn project_point_and_get_location( &self, m: &Isometry<f32, Unit<Quaternion<f32>>, 3>, pt: &OPoint<f32, Const<3>>, solid: bool, ) -> (PointProjection, Self::Location)
self
transformed by m
.Source§impl RayCast for MeshGraph
impl RayCast for MeshGraph
Source§fn cast_local_ray(
&self,
ray: &Ray,
max_time_of_impact: f32,
solid: bool,
) -> Option<f32>
fn cast_local_ray( &self, ray: &Ray, max_time_of_impact: f32, solid: bool, ) -> Option<f32>
Source§fn cast_local_ray_and_get_normal(
&self,
ray: &Ray,
max_time_of_impact: f32,
solid: bool,
) -> Option<RayIntersection>
fn cast_local_ray_and_get_normal( &self, ray: &Ray, max_time_of_impact: f32, solid: bool, ) -> Option<RayIntersection>
Source§fn intersects_local_ray(&self, ray: &Ray, max_time_of_impact: f32) -> bool
fn intersects_local_ray(&self, ray: &Ray, max_time_of_impact: f32) -> bool
Source§fn cast_ray(
&self,
m: &Isometry<f32, Unit<Quaternion<f32>>, 3>,
ray: &Ray,
max_time_of_impact: f32,
solid: bool,
) -> Option<f32>
fn cast_ray( &self, m: &Isometry<f32, Unit<Quaternion<f32>>, 3>, ray: &Ray, max_time_of_impact: f32, solid: bool, ) -> Option<f32>
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>
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>
Source§impl TypedSimdCompositeShape for MeshGraph
impl TypedSimdCompositeShape for MeshGraph
type PartShape = Triangle
type PartNormalConstraints = ()
type PartId = Face
fn map_typed_part_at( &self, face: Face, f: impl FnMut(Option<&Isometry<f32>>, &Self::PartShape, Option<&Self::PartNormalConstraints>), )
fn map_untyped_part_at( &self, face: Face, f: impl FnMut(Option<&Isometry<f32>>, &dyn Shape, Option<&dyn NormalConstraints>), )
fn typed_qbvh(&self) -> &Qbvh<Face>
Auto Trait Implementations§
impl Freeze for MeshGraph
impl RefUnwindSafe for MeshGraph
impl Send for MeshGraph
impl Sync for MeshGraph
impl Unpin for MeshGraph
impl UnwindSafe for MeshGraph
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,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read moreSource§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).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.