Skip to content

Commit d9668de

Browse files
committed
Implement reader for BGEO file format
1 parent 65f9f5a commit d9668de

File tree

8 files changed

+771
-6
lines changed

8 files changed

+771
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
## Master
22

3+
- CLI: Add support for reading BGEO files
34
- Lib: Allow passing in an existing `SurfaceReconstruction` to reuse allocated memory (currently only memory for the resulting surface mesh is reused) (https://github.com/w1th0utnam3/splashsurf/pull/7)
45
- Lib: Add `Default` trait bound to `Index` and `Real` types
56

Cargo.lock

Lines changed: 113 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Surface reconstruction library and CLI for particle data from SPH simulations, w
1616
- [Sequences of files](#sequences-of-files)
1717
- [Input file formats](#input-file-formats)
1818
- [VTK](#vtk)
19+
- [BGEO](#bgeo)
1920
- [PLY](#ply)
2021
- [XYZ](#xyz)
2122
- [Output file formats](#output-file-formats)
@@ -30,7 +31,7 @@ The following sections mainly focus on the CLI of `splashsurf`. For more informa
3031
This is a basic but high-performance implementation of a marching cubes based surface reconstruction for SPH fluid simulations (e.g performed with [SPlisHSPlasH](https://github.com/InteractiveComputerGraphics/SPlisHSPlasH)).
3132
The output of this tool is the reconstructed triangle surface mesh of the fluid.
3233
At the moment it does not compute normals or other additional data.
33-
As input, it supports particle positions from .vtk files and binary .xyz files (i.e. files containing a binary dump of a particle position array). In addition, required parameters are the kernel radius and particle radius (to compute the volume of particles) used for the original SPH simulation as well as the surface threshold.
34+
As input, it supports reading particle positions from `.vtk`, `.bgeo`, `.ply` and binary `.xyz` files (i.e. files containing a binary dump of a particle position array). In addition, required parameters are the kernel radius and particle radius (to compute the volume of particles) used for the original SPH simulation as well as the surface threshold.
3435

3536
The implementation first computes the density of each particle using the typical SPH approach with a cubic kernel.
3637
This density is then evaluated or mapped onto a sparse grid using spatial hashing in the support radius of each particle.
@@ -105,7 +106,7 @@ OPTIONS:
105106
106107
ARGS:
107108
<input-file> Path to the input file where the particle positions are stored (supported formats: VTK, binary
108-
XYZ, PLY)
109+
XYZ, PLY, BGEO)
109110
```
110111
For example:
111112
```
@@ -167,6 +168,10 @@ With these parameters, a scene with 13353401 particles is reconstructed in less
167168

168169
Files with the "`.vtk`" extension are loaded using [`vtkio`](https://crates.io/crates/vtkio). The VTK file is loaded as a big endian binary file and has to contain an "Unstructured Grid" with either `f32` or `f64` vertex coordinates. Any other data or attributes are ignored. Only the first "Unstructured Grid" is loaded, other entities are ignored.
169170

171+
### BGEO
172+
173+
Files with the "`.bgeo`" extension are loaded using a custom parser. Not that only the "old" `BGEOV` format is supported (which is the format supported by "Partio"). Only points and their implicit position vector attributes are loaded from the file. All other entities (e.g. vertices) and attributes are ignored/discarded. Notably, the parser supports BGEO files written by [SPlisHSPlasH](https://github.com/InteractiveComputerGraphics/SPlisHSPlasH) ("Partio export").
174+
170175
### PLY
171176

172177
Files with the "`.ply`" extension are loaded using [`ply-rs`](https://crates.io/crates/ply-rs). The PLY file has to contain an element called "`vertex`" with the properties `x`, `y` and `z` of type `f32`/["`Property::Float`"](https://docs.rs/ply-rs/0.1.3/ply_rs/ply/enum.Property.html#variant.Float). Any other properties or elements are ignored.

splashsurf/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,5 @@ anyhow = "1.0"
2222
num = "0.3"
2323
rayon = "1.5"
2424
ply-rs = "0.1.3"
25+
flate2 = "1.0"
26+
nom = "6.0"

splashsurf/README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Surface reconstruction library and CLI for particle data from SPH simulations, w
1616
- [Sequences of files](#sequences-of-files)
1717
- [Input file formats](#input-file-formats)
1818
- [VTK](#vtk)
19+
- [BGEO](#bgeo)
1920
- [PLY](#ply)
2021
- [XYZ](#xyz)
2122
- [Output file formats](#output-file-formats)
@@ -30,7 +31,7 @@ The following sections mainly focus on the CLI of `splashsurf`. For more informa
3031
This is a basic but high-performance implementation of a marching cubes based surface reconstruction for SPH fluid simulations (e.g performed with [SPlisHSPlasH](https://github.com/InteractiveComputerGraphics/SPlisHSPlasH)).
3132
The output of this tool is the reconstructed triangle surface mesh of the fluid.
3233
At the moment it does not compute normals or other additional data.
33-
As input, it supports particle positions from .vtk files and binary .xyz files (i.e. files containing a binary dump of a particle position array). In addition, required parameters are the kernel radius and particle radius (to compute the volume of particles) used for the original SPH simulation as well as the surface threshold.
34+
As input, it supports reading particle positions from `.vtk`, `.bgeo`, `.ply` and binary `.xyz` files (i.e. files containing a binary dump of a particle position array). In addition, required parameters are the kernel radius and particle radius (to compute the volume of particles) used for the original SPH simulation as well as the surface threshold.
3435

3536
The implementation first computes the density of each particle using the typical SPH approach with a cubic kernel.
3637
This density is then evaluated or mapped onto a sparse grid using spatial hashing in the support radius of each particle.
@@ -105,7 +106,7 @@ OPTIONS:
105106
106107
ARGS:
107108
<input-file> Path to the input file where the particle positions are stored (supported formats: VTK, binary
108-
XYZ, PLY)
109+
XYZ, PLY, BGEO)
109110
```
110111
For example:
111112
```
@@ -167,6 +168,10 @@ With these parameters, a scene with 13353401 particles is reconstructed in less
167168

168169
Files with the "`.vtk`" extension are loaded using [`vtkio`](https://crates.io/crates/vtkio). The VTK file is loaded as a big endian binary file and has to contain an "Unstructured Grid" with either `f32` or `f64` vertex coordinates. Any other data or attributes are ignored. Only the first "Unstructured Grid" is loaded, other entities are ignored.
169170

171+
### BGEO
172+
173+
Files with the "`.bgeo`" extension are loaded using a custom parser. Not that only the "old" `BGEOV` format is supported (which is the format supported by "Partio"). Only points and their implicit position vector attributes are loaded from the file. All other entities (e.g. vertices) and attributes are ignored/discarded. Notably, the parser supports BGEO files written by [SPlisHSPlasH](https://github.com/InteractiveComputerGraphics/SPlisHSPlasH) ("Partio export").
174+
170175
### PLY
171176

172177
Files with the "`.ply`" extension are loaded using [`ply-rs`](https://crates.io/crates/ply-rs). The PLY file has to contain an element called "`vertex`" with the properties `x`, `y` and `z` of type `f32`/["`Property::Float`"](https://docs.rs/ply-rs/0.1.3/ply_rs/ply/enum.Property.html#variant.Float). Any other properties or elements are ignored.

splashsurf/src/io.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use splashsurf_lib::coarse_prof::profile;
88
use splashsurf_lib::nalgebra::Vector3;
99
use splashsurf_lib::Real;
1010

11+
pub mod bgeo_format;
1112
pub mod ply_format;
1213
pub mod vtk_format;
1314
pub mod xyz_format;
@@ -58,6 +59,7 @@ pub fn load_particle_positions<R: Real, P: AsRef<Path>>(
5859
"vtk" => vtk_format::particles_from_vtk(&input_file)?,
5960
"xyz" => xyz_format::particles_from_xyz(&input_file)?,
6061
"ply" => ply_format::particles_from_ply(&input_file)?,
62+
"bgeo" => bgeo_format::particles_from_bgeo(&input_file)?,
6163
_ => {
6264
return Err(anyhow!(
6365
"Unsupported file format extension \"{}\" of particle file",

0 commit comments

Comments
 (0)