Skip to content

Commit 696620d

Browse files
committed
Updates to documentation
1 parent 1c0fd4e commit 696620d

File tree

3 files changed

+180
-13
lines changed

3 files changed

+180
-13
lines changed

pysplashsurf/pysplashsurf/docs/source/conf.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,14 @@
1010
# add these directories to sys.path here. If the directory is relative to the
1111
# documentation root, use os.path.abspath to make it absolute, like shown here.
1212
#
13-
#import pysplashsurf
13+
1414

1515
import os
1616
import sys
17-
# #sys.path.append(os.path.abspath('..'))
1817

1918
from sphinx.ext.autodoc.importer import import_module
20-
rootpath = '/Users/floeschner/programming/splashsurf/pysplashsurf/pysplashsurf'
21-
sys_path = list(sys.path)
22-
sys.path.insert(0, str(rootpath))
19+
print(f"### Appended path: {os.path.abspath('../../')}")
20+
sys.path.insert(0, os.path.abspath('../../'))
2321
pysplashsurf = import_module('pysplashsurf')
2422

2523
#import pysplashsurf
@@ -39,10 +37,11 @@
3937
extensions = [
4038
'sphinx.ext.autodoc',
4139
'sphinx.ext.autosummary',
40+
'sphinx.ext.napoleon',
4241
'numpydoc',
4342
'myst_parser',
4443
'sphinx_rtd_theme',
45-
'sphinx_autodoc_typehints'
44+
#'sphinx_autodoc_typehints'
4645
]
4746

4847
source_suffix = ['.rst', '.md']
@@ -74,7 +73,7 @@
7473

7574
always_document_param_types = True
7675
always_use_bars_union = True
77-
typehints_document_rtype = False
78-
typehints_use_rtype = False
79-
typehints_use_signature = True
80-
typehints_use_signature_return = True
76+
#typehints_document_rtype = False
77+
#typehints_use_rtype = False
78+
#typehints_use_signature = True
79+
#typehints_use_signature_return = True

pysplashsurf/pysplashsurf/pysplashsurf.pyi

Lines changed: 84 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,9 +399,92 @@ def reconstruct_surface(particles:numpy.typing.NDArray[typing.Any], *, particle_
399399
Note that all parameters use absolute distance units and are not relative to the particle radius.
400400
"""
401401

402-
def reconstruction_pipeline(particles:numpy.typing.NDArray[typing.Any], *, attributes_to_interpolate:typing.Optional[dict]=None, particle_radius:builtins.float, rest_density:builtins.float=1000.0, smoothing_length:builtins.float, cube_size:builtins.float, iso_surface_threshold:builtins.float=0.6, aabb_min:typing.Optional[typing.Sequence[builtins.float]]=None, aabb_max:typing.Optional[typing.Sequence[builtins.float]]=None, multi_threading:builtins.bool=True, subdomain_grid:builtins.bool=True, subdomain_grid_auto_disable:builtins.bool=True, subdomain_num_cubes_per_dim:builtins.int=64, check_mesh_closed:builtins.bool=False, check_mesh_manifold:builtins.bool=False, check_mesh_orientation:builtins.bool=False, check_mesh_debug:builtins.bool=False, mesh_cleanup:builtins.bool=False, mesh_cleanup_snap_dist:typing.Optional[builtins.float]=None, decimate_barnacles:builtins.bool=False, keep_vertices:builtins.bool=False, compute_normals:builtins.bool=False, sph_normals:builtins.bool=False, normals_smoothing_iters:typing.Optional[builtins.int]=None, mesh_smoothing_iters:typing.Optional[builtins.int]=None, mesh_smoothing_weights:builtins.bool=True, mesh_smoothing_weights_normalization:builtins.float=13.0, generate_quads:builtins.bool=False, quad_max_edge_diag_ratio:builtins.float=1.75, quad_max_normal_angle:builtins.float=10.0, quad_max_interior_angle:builtins.float=135.0, output_mesh_smoothing_weights:builtins.bool=False, output_raw_normals:builtins.bool=False, output_raw_mesh:builtins.bool=False, mesh_aabb_min:typing.Optional[typing.Sequence[builtins.float]]=None, mesh_aabb_max:typing.Optional[typing.Sequence[builtins.float]]=None, mesh_aabb_clamp_vertices:builtins.bool=True, dtype:typing.Optional[numpy.dtype]=None) -> tuple[MeshWithData, SurfaceReconstruction]:
402+
def reconstruction_pipeline(particles:numpy.typing.NDArray[typing.Any], *, attributes_to_interpolate:typing.Optional[dict]=None, particle_radius:builtins.float, rest_density:builtins.float=1000.0, smoothing_length:builtins.float, cube_size:builtins.float, iso_surface_threshold:builtins.float=0.6, aabb_min:typing.Optional[typing.Sequence[builtins.float]]=None, aabb_max:typing.Optional[typing.Sequence[builtins.float]]=None, multi_threading:builtins.bool=True, subdomain_grid:builtins.bool=True, subdomain_grid_auto_disable:builtins.bool=True, subdomain_num_cubes_per_dim:builtins.int=64, check_mesh_closed:builtins.bool=False, check_mesh_manifold:builtins.bool=False, check_mesh_orientation:builtins.bool=False, check_mesh_debug:builtins.bool=False, mesh_cleanup:builtins.bool=False, mesh_cleanup_snap_dist:typing.Optional[builtins.float]=None, decimate_barnacles:builtins.bool=False, keep_vertices:builtins.bool=False, compute_normals:builtins.bool=False, sph_normals:builtins.bool=False, normals_smoothing_iters:typing.Optional[builtins.int]=None, mesh_smoothing_iters:typing.Optional[builtins.int]=None, mesh_smoothing_weights:builtins.bool=True, mesh_smoothing_weights_normalization:builtins.float=13.0, generate_quads:builtins.bool=False, quad_max_edge_diag_ratio:builtins.float=1.75, quad_max_normal_angle:builtins.float=10.0, quad_max_interior_angle:builtins.float=135.0, output_mesh_smoothing_weights:builtins.bool=False, output_raw_normals:builtins.bool=False, output_raw_mesh:builtins.bool=False, mesh_aabb_min:typing.Optional[typing.Sequence[builtins.float]]=None, mesh_aabb_max:typing.Optional[typing.Sequence[builtins.float]]=None, mesh_aabb_clamp_vertices:builtins.bool=True) -> tuple[MeshWithData, SurfaceReconstruction]:
403403
r"""
404404
Runs the surface reconstruction pipeline for the given particle positions with optional post-processing
405405
406406
Note that smoothing length and cube size are given in multiples of the particle radius.
407+
408+
Parameters
409+
----------
410+
particles : numpy.ndarray
411+
A two-dimensional numpy array of shape (N, 3) containing the positions of the particles.
412+
attributes_to_interpolate
413+
Dictionary containing all attributes to interpolate. The keys are the attribute names and the values are the corresponding 1D/2D arrays.\n
414+
The arrays must have the same length as the number of particles. \n
415+
Supported array types are 2D float32/float64 arrays for vector attributes and 1D uint64/float32/float64 arrays for scalar attributes.
416+
particle_radius
417+
Particle radius
418+
rest_density
419+
Rest density of the fluid
420+
smoothing_length
421+
Smoothing length of the fluid in multiples of the particle radius (compact support radius of SPH kernel will be twice the smoothing length)
422+
cube_size
423+
Size of the cubes used for the marching cubes grid in multiples of the particle radius
424+
iso_surface_threshold
425+
Threshold for the iso surface
426+
aabb_min
427+
Lower corner of the AABB of particles to consider in the reconstruction
428+
aabb_max
429+
Upper corner of the AABB of particles to consider in the reconstruction
430+
multi_threading
431+
Multi-threading
432+
subdomain_grid
433+
Enable spatial decomposition using by dividing the domain into subdomains with dense marching cube grids for efficient multi-threading
434+
subdomain_grid_auto_disable
435+
Whether to automatically disable the subdomain grid if the global domain is too small
436+
subdomain_num_cubes_per_dim
437+
Each subdomain will be a cube consisting of this number of MC cube cells along each coordinate axis
438+
check_mesh_closed
439+
Enable checking the final mesh for holes
440+
check_mesh_manifold
441+
Enable checking the final mesh for non-manifold edges and vertices
442+
check_mesh_orientation
443+
Enable checking the final mesh for inverted triangles (compares angle between vertex normals and adjacent face normals)
444+
check_mesh_debug
445+
Enable additional debug output for the check-mesh operations (has no effect if no other check-mesh option is enabled)
446+
mesh_cleanup
447+
Flag to perform mesh cleanup\n
448+
This implements the method from “Compact isocontours from sampled data” (Moore, Warren; 1992)
449+
mesh_cleanup_snap_dist
450+
If MC mesh cleanup is enabled, vertex snapping can be limited to this distance relative to the MC edge length (should be in range of [0.0,0.5])
451+
decimate_barnacles
452+
Flag to perform barnacle decimation\n
453+
For details see “Weighted Laplacian Smoothing for Surface Reconstruction of Particle-based Fluids” (Löschner, Böttcher, Jeske, Bender; 2023).
454+
keep_vertices
455+
Flag to keep any vertices without connectivity resulting from mesh cleanup or decimation step
456+
compute_normals
457+
Flag to compute normals\n
458+
If set to True, the normals will be computed and stored in the mesh.
459+
sph_normals
460+
Flag to compute normals using SPH interpolation instead of geometry-based normals.
461+
normals_smoothing_iters
462+
Number of Laplacian smoothing iterations for the normal field
463+
mesh_smoothing_iters
464+
Number of Laplacian smoothing iterations for the mesh
465+
mesh_smoothing_weights
466+
Flag to compute mesh smoothing weights\n
467+
This implements the method from “Weighted Laplacian Smoothing for Surface Reconstruction of Particle-based Fluids” (Löschner, Böttcher, Jeske, Bender; 2023).
468+
mesh_smoothing_weights_normalization
469+
Normalization value for the mesh smoothing weights
470+
generate_quads
471+
Enable trying to convert triangles to quads if they meet quality criteria
472+
quad_max_edge_diag_ratio
473+
Maximum allowed ratio of quad edge lengths to its diagonals to merge two triangles to a quad (inverse is used for minimum)
474+
quad_max_normal_angle
475+
Maximum allowed angle (in degrees) between triangle normals to merge them to a quad
476+
quad_max_interior_angle
477+
Maximum allowed vertex interior angle (in degrees) inside a quad to merge two triangles to a quad
478+
output_mesh_smoothing_weights
479+
Flag to store the mesh smoothing weights if smoothing weights are computed.
480+
output_raw_normals
481+
Flag to output the raw normals in addition to smoothed normals if smoothing of normals is enabled
482+
output_raw_mesh
483+
When true, also return the SurfaceReconstruction object with no post-processing applied
484+
mesh_aabb_min
485+
Smallest corner of the axis-aligned bounding box for the mesh
486+
mesh_aabb_max
487+
Largest corner of the axis-aligned bounding box for the mesh
488+
mesh_aabb_clamp_vertices
489+
Flag to clamp the vertices of the mesh to the AABB
407490
"""

pysplashsurf/src/pipeline.rs

Lines changed: 87 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,90 @@ use crate::utils::{IndexT, pyerr_unsupported_scalar};
2323
/// Runs the surface reconstruction pipeline for the given particle positions with optional post-processing
2424
///
2525
/// Note that smoothing length and cube size are given in multiples of the particle radius.
26+
///
27+
/// Parameters
28+
/// ----------
29+
/// particles : numpy.ndarray
30+
/// A two-dimensional numpy array of shape (N, 3) containing the positions of the particles.
31+
/// attributes_to_interpolate
32+
/// Dictionary containing all attributes to interpolate. The keys are the attribute names and the values are the corresponding 1D/2D arrays.\n
33+
/// The arrays must have the same length as the number of particles. \n
34+
/// Supported array types are 2D float32/float64 arrays for vector attributes and 1D uint64/float32/float64 arrays for scalar attributes.
35+
/// particle_radius
36+
/// Particle radius
37+
/// rest_density
38+
/// Rest density of the fluid
39+
/// smoothing_length
40+
/// Smoothing length of the fluid in multiples of the particle radius (compact support radius of SPH kernel will be twice the smoothing length)
41+
/// cube_size
42+
/// Size of the cubes used for the marching cubes grid in multiples of the particle radius
43+
/// iso_surface_threshold
44+
/// Threshold for the iso surface
45+
/// aabb_min
46+
/// Lower corner of the AABB of particles to consider in the reconstruction
47+
/// aabb_max
48+
/// Upper corner of the AABB of particles to consider in the reconstruction
49+
/// multi_threading
50+
/// Multi-threading
51+
/// subdomain_grid
52+
/// Enable spatial decomposition using by dividing the domain into subdomains with dense marching cube grids for efficient multi-threading
53+
/// subdomain_grid_auto_disable
54+
/// Whether to automatically disable the subdomain grid if the global domain is too small
55+
/// subdomain_num_cubes_per_dim
56+
/// Each subdomain will be a cube consisting of this number of MC cube cells along each coordinate axis
57+
/// check_mesh_closed
58+
/// Enable checking the final mesh for holes
59+
/// check_mesh_manifold
60+
/// Enable checking the final mesh for non-manifold edges and vertices
61+
/// check_mesh_orientation
62+
/// Enable checking the final mesh for inverted triangles (compares angle between vertex normals and adjacent face normals)
63+
/// check_mesh_debug
64+
/// Enable additional debug output for the check-mesh operations (has no effect if no other check-mesh option is enabled)
65+
/// mesh_cleanup
66+
/// Flag to perform mesh cleanup\n
67+
/// This implements the method from “Compact isocontours from sampled data” (Moore, Warren; 1992)
68+
/// mesh_cleanup_snap_dist
69+
/// If MC mesh cleanup is enabled, vertex snapping can be limited to this distance relative to the MC edge length (should be in range of [0.0,0.5])
70+
/// decimate_barnacles
71+
/// Flag to perform barnacle decimation\n
72+
/// For details see “Weighted Laplacian Smoothing for Surface Reconstruction of Particle-based Fluids” (Löschner, Böttcher, Jeske, Bender; 2023).
73+
/// keep_vertices
74+
/// Flag to keep any vertices without connectivity resulting from mesh cleanup or decimation step
75+
/// compute_normals
76+
/// Flag to compute normals\n
77+
/// If set to True, the normals will be computed and stored in the mesh.
78+
/// sph_normals
79+
/// Flag to compute normals using SPH interpolation instead of geometry-based normals.
80+
/// normals_smoothing_iters
81+
/// Number of Laplacian smoothing iterations for the normal field
82+
/// mesh_smoothing_iters
83+
/// Number of Laplacian smoothing iterations for the mesh
84+
/// mesh_smoothing_weights
85+
/// Flag to compute mesh smoothing weights\n
86+
/// This implements the method from “Weighted Laplacian Smoothing for Surface Reconstruction of Particle-based Fluids” (Löschner, Böttcher, Jeske, Bender; 2023).
87+
/// mesh_smoothing_weights_normalization
88+
/// Normalization value for the mesh smoothing weights
89+
/// generate_quads
90+
/// Enable trying to convert triangles to quads if they meet quality criteria
91+
/// quad_max_edge_diag_ratio
92+
/// Maximum allowed ratio of quad edge lengths to its diagonals to merge two triangles to a quad (inverse is used for minimum)
93+
/// quad_max_normal_angle
94+
/// Maximum allowed angle (in degrees) between triangle normals to merge them to a quad
95+
/// quad_max_interior_angle
96+
/// Maximum allowed vertex interior angle (in degrees) inside a quad to merge two triangles to a quad
97+
/// output_mesh_smoothing_weights
98+
/// Flag to store the mesh smoothing weights if smoothing weights are computed.
99+
/// output_raw_normals
100+
/// Flag to output the raw normals in addition to smoothed normals if smoothing of normals is enabled
101+
/// output_raw_mesh
102+
/// When true, also return the SurfaceReconstruction object with no post-processing applied
103+
/// mesh_aabb_min
104+
/// Smallest corner of the axis-aligned bounding box for the mesh
105+
/// mesh_aabb_max
106+
/// Largest corner of the axis-aligned bounding box for the mesh
107+
/// mesh_aabb_clamp_vertices
108+
/// Flag to clamp the vertices of the mesh to the AABB
109+
///
26110
#[gen_stub_pyfunction]
27111
#[pyfunction]
28112
#[pyo3(name = "reconstruction_pipeline")]
@@ -35,7 +119,7 @@ use crate::utils::{IndexT, pyerr_unsupported_scalar};
35119
normals_smoothing_iters = None, mesh_smoothing_iters = None, mesh_smoothing_weights = true, mesh_smoothing_weights_normalization = 13.0,
36120
generate_quads = false, quad_max_edge_diag_ratio = 1.75, quad_max_normal_angle = 10.0, quad_max_interior_angle = 135.0,
37121
output_mesh_smoothing_weights = false, output_raw_normals = false, output_raw_mesh = false,
38-
mesh_aabb_min = None, mesh_aabb_max = None, mesh_aabb_clamp_vertices = true, dtype = None
122+
mesh_aabb_min = None, mesh_aabb_max = None, mesh_aabb_clamp_vertices = true
39123
))]
40124
pub fn reconstruction_pipeline<'py>(
41125
particles: &Bound<'py, PyUntypedArray>,
@@ -75,11 +159,12 @@ pub fn reconstruction_pipeline<'py>(
75159
mesh_aabb_min: Option<[f64; 3]>,
76160
mesh_aabb_max: Option<[f64; 3]>,
77161
mesh_aabb_clamp_vertices: bool,
78-
dtype: Option<Bound<'py, PyArrayDescr>>,
162+
//dtype: Option<Bound<'py, PyArrayDescr>>,
79163
) -> PyResult<(PyMeshWithData, PySurfaceReconstruction)> {
80164
let py = particles.py();
81165
let element_type = particles.dtype();
82166

167+
let dtype: Option<Bound<'py, PyArrayDescr>> = None;
83168
if let Some(target_dtype) = dtype
84169
&& !target_dtype.is_equiv_to(&element_type)
85170
{

0 commit comments

Comments
 (0)