#mesh #ply #graphics #surface #3ds

bpa_rs

A Rust implementation of the Binary Partitioning Algorithm (BPA) for 3D point cloud data

2 releases

Uses new Rust 2024

new 0.1.1 May 24, 2025
0.1.0 May 23, 2025

#598 in Math

31 downloads per month

MIT license

1MB
1K SLoC

Ball Pivoting Algorithm (BPA)

Rust 2024 Edition.

crates.io Documentation Download

Mesh Reconstruction from a Point Cloud.

This a port of this c++ application bpa

From this paper.

"The Ball-Pivoting Algorithm for Surface Reconstruction"

by Fausto Bernardini, Joshua Mittleman, Holly Rushmeier, Claudio Silva and Gabriel Taubin

How to use the library

  • Call reconstruct() with your point cloud data.
  • The resultant mesh can then be further processed
  • Saved the mesh as a STL file.

For example :-

    let cloud =
        load_xyz(&PathBuf::from("../data/bunny.xyz")).expect("Cannot load bunny");

    // Construct a mesh from a point cloud.
    match reconstruct(&cloud, 0.002f32) {
        Some(ref triangles) => {
            // triangles is a vector of Triangles
            // where
            //
            // struct Triangle([Vec3; 3]);

            // Process the mesh.
            todo!();

            // Save the triangle as a STL file.
            save_triangles(&PathBuf::from("output.stl"), triangles)
                .expect("Err debug failing writing glue_front.stl");

        }
        None => {
            println!("Did not generate a mesh.");

        }
    }

Testing

Verification

The original libraries test with tetrahedron, cubes, spheres and bunny point cloud. Those tests has been recreated.

Snapshots

The original only tests for the existence of the test meshes. This port snapshots those meshed making any further development stable.

Benchmarking

reconstruct() and compute_ball_center() have a criterion test harness.. This version appears to run 40% faster than the cpp version, but I think there is some work be done to enhance performance.

Further work

Add a WASM example showing a mesh being reconstructed in a web browser.

Dependencies

~4.5MB
~138K SLoC