Skip to main content

geop_core_topology/euler/
mvfs.rs

1use crate::{
2    Face, FaceId, Model, Shell, ShellId, SolidId, Vertex, VertexId, boundary::BoundaryType,
3};
4use geop_core_geometry::nurb_surface::NurbSurface3D;
5use geop_core_math::{scalars::Scalar, vector::Vector3};
6
7impl<S: Scalar> Model<S> {
8    // Create a new solid with a single face and vertex at `point`. Returns the new vertex, face, and solid id.
9    pub fn mvfs(self: &mut Model<S>, point: Vector3<S>) -> (VertexId, FaceId, SolidId) {
10        let vertex_id = self.insert_vertex(Vertex { point });
11
12        let face_id = self.insert_face(Face {
13            surface: NurbSurface3D::everything(),
14            outer: BoundaryType::Vertex(vertex_id),
15            holes: Vec::new(),
16            shell: ShellId(0), // set later
17        });
18        let shell_id = self.insert_shell(Shell {
19            faces: vec![face_id],
20            solid: SolidId(0), // set later
21        });
22        let solid_id = self.insert_solid(crate::Solid {
23            shells: vec![shell_id],
24        });
25        // backwards linking
26        self.faces.get_mut(&face_id).unwrap().shell = shell_id;
27        self.shells.get_mut(&shell_id).unwrap().solid = solid_id;
28        (vertex_id, face_id, solid_id)
29    }
30}