MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/splashsurf / stitching

Function stitching

splashsurf_lib/src/dense_subdomains.rs:1603–1749  ·  view source on GitHub ↗
(
    surface_patches: Vec<SurfacePatch<I, R>>,
)

Source from the content-addressed store, hash-verified

1601}
1602
1603pub(crate) fn stitching<I: Index, R: Real>(
1604 surface_patches: Vec<SurfacePatch<I, R>>,
1605) -> TriMesh3d<R> {
1606 profile!("stitching");
1607 info!("Starting stitching of subdomain meshes to global mesh.");
1608
1609 // Calculate offsets of interior vertices and triangles
1610 let vert_and_tri_offsets = {
1611 profile!("surface patch offset scan");
1612
1613 std::iter::once((0, 0))
1614 .chain(surface_patches.iter().scan((0, 0), |offsets, patch| {
1615 let (vert_offset, tri_offset) = offsets;
1616 *vert_offset += patch.vertex_inside_count;
1617 *tri_offset += patch.triangle_inside_count;
1618 Some(*offsets)
1619 }))
1620 .collect::<Vec<_>>()
1621 };
1622
1623 let (total_interior_vert_count, total_interior_tri_count) = vert_and_tri_offsets
1624 .last()
1625 .copied()
1626 .expect("there has to be at least one entry in the offset list");
1627
1628 let mut interior_vertices = vec![Vector3::<R>::zeros(); total_interior_vert_count];
1629 let mut interior_triangles = vec![[0, 0, 0]; total_interior_tri_count];
1630
1631 let mut exterior_vertices = Vec::new();
1632 let mut exterior_triangles = Vec::new();
1633 let mut exterior_vertex_mapping = new_map();
1634
1635 {
1636 profile!("copy interior verts/tris and deduplicate exterior verts");
1637
1638 if vert_and_tri_offsets.len() > 1 {
1639 vert_and_tri_offsets
1640 .windows(2)
1641 .zip(surface_patches.iter())
1642 .for_each(|(offsets, patch)| {
1643 if let [start_offsets, end_offsets] = offsets {
1644 let (start_verts, start_tris) = *start_offsets;
1645 let (end_verts, end_tris) = *end_offsets;
1646
1647 let global_vertex_offset = start_verts;
1648
1649 let mut local_to_global_vertex_mapping = vec![0; patch.vertices.len()];
1650
1651 // Copy interior vertices
1652 {
1653 let out_verts = &mut interior_vertices[start_verts..end_verts];
1654
1655 // Copy all interior vertices into global storage
1656 patch
1657 .vertices
1658 .iter()
1659 .zip(patch.vertex_inside_flags.iter())
1660 .enumerate()

Callers 1

Calls 5

new_mapFunction · 0.85
for_eachMethod · 0.80
iterMethod · 0.45
lenMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected