Functions

All functions infer float precision based on the input (np.float32 or np.float64).

pysplashsurf.barnacle_decimation(mesh, *, keep_vertices)

Performs specialized decimation on the given mesh to prevent “barnacles” when applying weighted Laplacian smoothing

The decimation is performed inplace and modifies the given mesh. Returns the vertex-vertex connectivity of the decimated mesh which can be used for other post-processing steps.

pysplashsurf.check_mesh_consistency(mesh, grid, *, check_closed=True, check_manifold=True, debug=False)

Checks the consistency of a reconstructed surface mesh (watertightness, manifoldness), optionally returns a string with details if problems are found

pysplashsurf.convert_tris_to_quads(mesh, *, non_squareness_limit=1.75, normal_angle_limit=10.0, max_interior_angle=135.0)

Converts triangles to quads by merging triangles sharing an edge if they fulfill the given criteria

This operation creates a new mesh and does not modify the input mesh. Angles are specified in degrees.

pysplashsurf.laplacian_smoothing_normals_parallel(normals, vertex_connectivity, *, iterations)

Laplacian smoothing of a normal field

The smoothing is performed inplace and modifies the given normal array.

pysplashsurf.laplacian_smoothing_parallel(mesh, vertex_connectivity, *, iterations, beta=1.0, weights)

Laplacian smoothing of mesh vertices with feature weights

The smoothing is performed inplace and modifies the vertices of the given mesh.

pysplashsurf.marching_cubes(values, *, iso_surface_threshold, cube_size, translation=None, return_grid=False)

Performs a standard marching cubes triangulation of a 3D array of values

The array of values has to be a contiguous array with shape (nx, ny, nz). The iso-surface threshold defines which value is considered to be “on” the surface. The cube size and translation parameters define the scaling and translation of the resulting mesh. Without translation, the value values[0, 0, 0] is located at coordinates (0, 0, 0).

The values are interpreted as a “density field”, meaning that values higher than the iso-surface threshold are considered to be “inside” the surface and values lower than the threshold are considered to be “outside” the surface. This is the opposite convention to an SDF (signed distance field). However, even if values of an SDF are provided as an input, the marching cubes algorithm will still work and produce a watertight surface mesh (if the surface is fully contained in the array).

If return_grid is set to True, the function will return a tuple of the mesh and the uniform grid that was used for the triangulation. This can be used for other functions such as check_mesh_consistency(). Otherwise, only the mesh is returned.

The function is currently single-threaded. The SPH surface reconstruction functions reconstruction_pipeline() and reconstruct_surface() improve performance by processing multiple patches in parallel.

pysplashsurf.marching_cubes_cleanup(mesh, grid, *, max_rel_snap_dist=None, max_iter=5, keep_vertices=False)

Performs simplification on the given mesh inspired by the “Compact Contouring”/”Mesh displacement” approach by Doug Moore and Joe Warren

The simplification is performed inplace and modifies the given mesh. The method is designed specifically for meshes generated by Marching Cubes. See Moore and Warren: Mesh Displacement: An Improved Contouring Method for Trivariate Data (1991) or Moore and Warren: “Compact Isocontours from Sampled Data” in “Graphics Gems III” (1992).

pysplashsurf.neighborhood_search_spatial_hashing_parallel(particle_positions, domain, search_radius)

Performs a neighborhood search using spatial hashing (multithreaded implementation)

pysplashsurf.reconstruct_surface(particles, *, particle_radius, rest_density=1000.0, smoothing_length, cube_size, iso_surface_threshold=0.6, multi_threading=True, global_neighborhood_list=False, subdomain_grid=True, subdomain_grid_auto_disable=True, subdomain_num_cubes_per_dim=64, aabb_min=None, aabb_max=None)

Performs a surface reconstruction from the given particles without additional post-processing

Note that all parameters use absolute distance units and are not relative to the particle radius.

pysplashsurf.reconstruction_pipeline(particles, *, attributes_to_interpolate=None, particle_radius, rest_density=1000.0, smoothing_length, cube_size, iso_surface_threshold=0.6, aabb_min=None, aabb_max=None, multi_threading=True, subdomain_grid=True, subdomain_grid_auto_disable=True, subdomain_num_cubes_per_dim=64, check_mesh_closed=False, check_mesh_manifold=False, check_mesh_orientation=False, check_mesh_debug=False, mesh_cleanup=False, mesh_cleanup_snap_dist=None, decimate_barnacles=False, keep_vertices=False, compute_normals=False, sph_normals=False, normals_smoothing_iters=None, mesh_smoothing_iters=None, mesh_smoothing_weights=True, mesh_smoothing_weights_normalization=13.0, generate_quads=False, quad_max_edge_diag_ratio=1.75, quad_max_normal_angle=10.0, quad_max_interior_angle=135.0, output_mesh_smoothing_weights=False, output_raw_normals=False, output_raw_mesh=False, mesh_aabb_min=None, mesh_aabb_max=None, mesh_aabb_clamp_vertices=True, dtype=None)

Runs the surface reconstruction pipeline for the given particle positions with optional post-processing

Note that smoothing length and cube size are given in multiples of the particle radius.