Skip to content

Commit afcacc0

Browse files
committed
Run cargo fmt
1 parent 3e6a4d4 commit afcacc0

File tree

10 files changed

+650
-217
lines changed

10 files changed

+650
-217
lines changed

pysplashsurf/src/aabb.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
use numpy::{PyArray, PyArray1, PyArray2, PyReadonlyArray2};
22
use pyo3::{prelude::*, PyResult};
3-
use splashsurf_lib::{nalgebra::Vector3, Aabb3d};
43
use pyo3_stub_gen::derive::*;
4+
use splashsurf_lib::{nalgebra::Vector3, Aabb3d};
55

66
macro_rules! create_aabb3d_interface {
77
($name: ident, $type: ident) => {
88
/// Aabb3d wrapper
99
#[gen_stub_pyclass]
1010
#[pyclass]
1111
pub struct $name {
12-
pub inner: Aabb3d<$type>
12+
pub inner: Aabb3d<$type>,
1313
}
1414

1515
impl $name {
@@ -23,7 +23,10 @@ macro_rules! create_aabb3d_interface {
2323
impl $name {
2424
#[new]
2525
fn py_new<'py>(min: [$type; 3], max: [$type; 3]) -> PyResult<Self> {
26-
Ok($name::new(Aabb3d::<$type>::new(Vector3::from_column_slice(&min), Vector3::from_column_slice(&max))))
26+
Ok($name::new(Aabb3d::<$type>::new(
27+
Vector3::from_column_slice(&min),
28+
Vector3::from_column_slice(&max),
29+
)))
2730
}
2831

2932
/// Constructs the smallest AABB fitting around all the given points
@@ -109,7 +112,8 @@ macro_rules! create_aabb3d_interface {
109112

110113
/// Checks if the given point is inside of the AABB, the AABB is considered to be half-open to its max coordinate
111114
fn contains_point(&self, point: [$type; 3]) -> bool {
112-
self.inner.contains_point(&Vector3::from_column_slice(&point))
115+
self.inner
116+
.contains_point(&Vector3::from_column_slice(&point))
113117
}
114118

115119
/// Translates the AABB by the given vector
@@ -134,7 +138,8 @@ macro_rules! create_aabb3d_interface {
134138

135139
/// Enlarges this AABB to the smallest AABB enclosing both itself and another point
136140
fn join_with_point(&mut self, point: [$type; 3]) {
137-
self.inner.join_with_point(&Vector3::from_column_slice(&point));
141+
self.inner
142+
.join_with_point(&Vector3::from_column_slice(&point));
138143
}
139144

140145
/// Grows this AABB uniformly in all directions by the given scalar margin (i.e. adding the margin to min/max extents)
@@ -151,4 +156,4 @@ macro_rules! create_aabb3d_interface {
151156
}
152157

153158
create_aabb3d_interface!(Aabb3dF64, f64);
154-
create_aabb3d_interface!(Aabb3dF32, f32);
159+
create_aabb3d_interface!(Aabb3dF32, f32);

pysplashsurf/src/lib.rs

Lines changed: 75 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
use pyo3::prelude::*;
22
use pyo3_stub_gen::define_stub_info_gatherer;
33

4-
mod uniform_grid;
5-
mod mesh;
64
mod aabb;
5+
mod mesh;
76
mod sph_interpolation;
7+
mod uniform_grid;
88

99
mod marching_cubes;
10-
mod post_processing;
11-
mod reconstruction;
1210
mod neighborhood_search;
1311
mod pipeline;
12+
mod post_processing;
13+
mod reconstruction;
1414

1515
/// High-Level Bindings of the splashsurf surface reconstruction implementation.
1616
/// Support reconstructing Level-Set surfaces from particle clouds or from regular grids.
@@ -38,34 +38,82 @@ fn pysplashsurf(m: &Bound<'_, PyModule>) -> PyResult<()> {
3838
let _ = m.add_class::<aabb::Aabb3dF32>()?;
3939
let _ = m.add_class::<aabb::Aabb3dF64>()?;
4040

41-
let _ = m.add_function(wrap_pyfunction!(reconstruction::reconstruct_surface_py_f32, m)?);
42-
let _ = m.add_function(wrap_pyfunction!(reconstruction::reconstruct_surface_py_f64, m)?);
43-
44-
let _ = m.add_function(wrap_pyfunction!(post_processing::convert_tris_to_quads_py_f32, m)?);
45-
let _ = m.add_function(wrap_pyfunction!(post_processing::convert_tris_to_quads_py_f64, m)?);
46-
47-
let _ = m.add_function(wrap_pyfunction!(post_processing::marching_cubes_cleanup_py_f32, m)?);
48-
let _ = m.add_function(wrap_pyfunction!(post_processing::marching_cubes_cleanup_py_f64, m)?);
49-
50-
let _ = m.add_function(wrap_pyfunction!(marching_cubes::check_mesh_consistency_py_f32, m)?);
51-
let _ = m.add_function(wrap_pyfunction!(marching_cubes::check_mesh_consistency_py_f64, m)?);
41+
let _ = m.add_function(wrap_pyfunction!(
42+
reconstruction::reconstruct_surface_py_f32,
43+
m
44+
)?);
45+
let _ = m.add_function(wrap_pyfunction!(
46+
reconstruction::reconstruct_surface_py_f64,
47+
m
48+
)?);
49+
50+
let _ = m.add_function(wrap_pyfunction!(
51+
post_processing::convert_tris_to_quads_py_f32,
52+
m
53+
)?);
54+
let _ = m.add_function(wrap_pyfunction!(
55+
post_processing::convert_tris_to_quads_py_f64,
56+
m
57+
)?);
58+
59+
let _ = m.add_function(wrap_pyfunction!(
60+
post_processing::marching_cubes_cleanup_py_f32,
61+
m
62+
)?);
63+
let _ = m.add_function(wrap_pyfunction!(
64+
post_processing::marching_cubes_cleanup_py_f64,
65+
m
66+
)?);
67+
68+
let _ = m.add_function(wrap_pyfunction!(
69+
marching_cubes::check_mesh_consistency_py_f32,
70+
m
71+
)?);
72+
let _ = m.add_function(wrap_pyfunction!(
73+
marching_cubes::check_mesh_consistency_py_f64,
74+
m
75+
)?);
5276

5377
let _ = m.add_function(wrap_pyfunction!(post_processing::decimation_py_f32, m)?);
5478
let _ = m.add_function(wrap_pyfunction!(post_processing::decimation_py_f64, m)?);
5579

56-
let _ = m.add_function(wrap_pyfunction!(post_processing::par_laplacian_smoothing_inplace_py_f32, m)?);
57-
let _ = m.add_function(wrap_pyfunction!(post_processing::par_laplacian_smoothing_inplace_py_f64, m)?);
58-
59-
let _ = m.add_function(wrap_pyfunction!(post_processing::par_laplacian_smoothing_normals_inplace_py_f32, m)?);
60-
let _ = m.add_function(wrap_pyfunction!(post_processing::par_laplacian_smoothing_normals_inplace_py_f64, m)?);
61-
62-
let _ = m.add_function(wrap_pyfunction!(neighborhood_search::neighborhood_search_spatial_hashing_parallel_py_f32, m)?);
63-
let _ = m.add_function(wrap_pyfunction!(neighborhood_search::neighborhood_search_spatial_hashing_parallel_py_f64, m)?);
64-
65-
let _ = m.add_function(wrap_pyfunction!(pipeline::reconstruction_pipeline_py_f32, m)?);
66-
let _ = m.add_function(wrap_pyfunction!(pipeline::reconstruction_pipeline_py_f64, m)?);
80+
let _ = m.add_function(wrap_pyfunction!(
81+
post_processing::par_laplacian_smoothing_inplace_py_f32,
82+
m
83+
)?);
84+
let _ = m.add_function(wrap_pyfunction!(
85+
post_processing::par_laplacian_smoothing_inplace_py_f64,
86+
m
87+
)?);
88+
89+
let _ = m.add_function(wrap_pyfunction!(
90+
post_processing::par_laplacian_smoothing_normals_inplace_py_f32,
91+
m
92+
)?);
93+
let _ = m.add_function(wrap_pyfunction!(
94+
post_processing::par_laplacian_smoothing_normals_inplace_py_f64,
95+
m
96+
)?);
97+
98+
let _ = m.add_function(wrap_pyfunction!(
99+
neighborhood_search::neighborhood_search_spatial_hashing_parallel_py_f32,
100+
m
101+
)?);
102+
let _ = m.add_function(wrap_pyfunction!(
103+
neighborhood_search::neighborhood_search_spatial_hashing_parallel_py_f64,
104+
m
105+
)?);
106+
107+
let _ = m.add_function(wrap_pyfunction!(
108+
pipeline::reconstruction_pipeline_py_f32,
109+
m
110+
)?);
111+
let _ = m.add_function(wrap_pyfunction!(
112+
pipeline::reconstruction_pipeline_py_f64,
113+
m
114+
)?);
67115

68116
Ok(())
69117
}
70118

71-
define_stub_info_gatherer!(stub_info);
119+
define_stub_info_gatherer!(stub_info);

pysplashsurf/src/marching_cubes.rs

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1-
use pyo3::{exceptions::{PyRuntimeError, PyValueError}, prelude::*};
1+
use pyo3::{
2+
exceptions::{PyRuntimeError, PyValueError},
3+
prelude::*,
4+
};
25

3-
use crate::{mesh::{TriMesh3dF32, TriMesh3dF64, TriMeshWithDataF32, TriMeshWithDataF64}, uniform_grid::{UniformGridF32, UniformGridF64}};
6+
use crate::{
7+
mesh::{TriMesh3dF32, TriMesh3dF64, TriMeshWithDataF32, TriMeshWithDataF64},
8+
uniform_grid::{UniformGridF32, UniformGridF64},
9+
};
410

511
#[pyfunction]
612
#[pyo3(name = "check_mesh_consistency_f32")]
@@ -15,10 +21,24 @@ pub fn check_mesh_consistency_py_f32<'py>(
1521
) -> PyResult<()> {
1622
if mesh.downcast_bound::<TriMesh3dF32>(py).is_ok() {
1723
let mesh = mesh.downcast_bound::<TriMesh3dF32>(py).unwrap();
18-
splashsurf_lib::marching_cubes::check_mesh_consistency(&grid.inner, &mesh.borrow().inner, check_closed, check_manifold, debug).map_err(|x| PyErr::new::<PyRuntimeError, _>(x))
24+
splashsurf_lib::marching_cubes::check_mesh_consistency(
25+
&grid.inner,
26+
&mesh.borrow().inner,
27+
check_closed,
28+
check_manifold,
29+
debug,
30+
)
31+
.map_err(|x| PyErr::new::<PyRuntimeError, _>(x))
1932
} else if mesh.downcast_bound::<TriMeshWithDataF32>(py).is_ok() {
2033
let mesh = mesh.downcast_bound::<TriMeshWithDataF32>(py).unwrap();
21-
splashsurf_lib::marching_cubes::check_mesh_consistency(&grid.inner, &mesh.borrow().inner.mesh, check_closed, check_manifold, debug).map_err(|x| PyErr::new::<PyRuntimeError, _>(x))
34+
splashsurf_lib::marching_cubes::check_mesh_consistency(
35+
&grid.inner,
36+
&mesh.borrow().inner.mesh,
37+
check_closed,
38+
check_manifold,
39+
debug,
40+
)
41+
.map_err(|x| PyErr::new::<PyRuntimeError, _>(x))
2242
} else {
2343
Err(PyErr::new::<PyValueError, _>("Invalid mesh type"))
2444
}
@@ -37,11 +57,25 @@ pub fn check_mesh_consistency_py_f64<'py>(
3757
) -> PyResult<()> {
3858
if mesh.downcast_bound::<TriMesh3dF64>(py).is_ok() {
3959
let mesh = mesh.downcast_bound::<TriMesh3dF64>(py).unwrap();
40-
splashsurf_lib::marching_cubes::check_mesh_consistency(&grid.inner, &mesh.borrow().inner, check_closed, check_manifold, debug).map_err(|x| PyErr::new::<PyRuntimeError, _>(x))
60+
splashsurf_lib::marching_cubes::check_mesh_consistency(
61+
&grid.inner,
62+
&mesh.borrow().inner,
63+
check_closed,
64+
check_manifold,
65+
debug,
66+
)
67+
.map_err(|x| PyErr::new::<PyRuntimeError, _>(x))
4168
} else if mesh.downcast_bound::<TriMeshWithDataF64>(py).is_ok() {
4269
let mesh = mesh.downcast_bound::<TriMeshWithDataF64>(py).unwrap();
43-
splashsurf_lib::marching_cubes::check_mesh_consistency(&grid.inner, &mesh.borrow().inner.mesh, check_closed, check_manifold, debug).map_err(|x| PyErr::new::<PyRuntimeError, _>(x))
70+
splashsurf_lib::marching_cubes::check_mesh_consistency(
71+
&grid.inner,
72+
&mesh.borrow().inner.mesh,
73+
check_closed,
74+
check_manifold,
75+
debug,
76+
)
77+
.map_err(|x| PyErr::new::<PyRuntimeError, _>(x))
4478
} else {
4579
Err(PyErr::new::<PyValueError, _>("Invalid mesh type"))
4680
}
47-
}
81+
}

0 commit comments

Comments
 (0)