diff --git a/docs/doc/data_handling/io.md b/docs/doc/data_handling/io.md index 82c984bbced233b2a35836bdd072e3c73aa8bf8b..607d81ede891e5700eb593ab7ddfa876a6037ac0 100644 --- a/docs/doc/data_handling/io.md +++ b/docs/doc/data_handling/io.md @@ -8,5 +8,5 @@ - Downloader - export_ome_zarr - import_ome_zarr - - save_mesh - - load_mesh \ No newline at end of file + - load_mesh + - save_mesh \ No newline at end of file diff --git a/qim3d/mesh/_common_mesh_methods.py b/qim3d/mesh/_common_mesh_methods.py index ace4749a9c083aa9291e8adbc61ad65c9e1dfda7..7ff2dbe888ef52f766c350fb639aa25f25884c87 100644 --- a/qim3d/mesh/_common_mesh_methods.py +++ b/qim3d/mesh/_common_mesh_methods.py @@ -7,11 +7,35 @@ from qim3d.utils._logger import log def from_volume( volume: np.ndarray, - **Kwargs + **kwargs ) -> hmesh.Manifold: + """ Convert a 3D numpy array to a mesh object using the [volumetric_isocontour](https://www2.compute.dtu.dk/projects/GEL/PyGEL/pygel3d/hmesh.html#volumetric_isocontour) function from Pygel3D. + + Args: + volume (np.ndarray): A 3D numpy array representing a volume. + **kwargs: Additional arguments to pass to the Pygel3D volumetric_isocontour function. + + Raises: + ValueError: If the input volume is not a 3D numpy array. + + Returns: + hmesh.Manifold: A Pygel3D mesh object representing the input volume. + + Example: + Convert a 3D numpy array to a Pygel3D mesh object: + ```python + import qim3d + + # Generate a 3D blob + synthetic_blob = qim3d.generate.noise_object(noise_scale = 0.015) + + # Convert the 3D numpy array to a Pygel3D mesh object + mesh = qim3d.mesh.from_volume(synthetic_blob) + ``` + """ if volume.ndim != 3: raise ValueError("The input volume must be a 3D numpy array.") - mesh = hmesh.volumetric_isocontour(volume) + mesh = hmesh.volumetric_isocontour(volume, **kwargs) return mesh \ No newline at end of file diff --git a/qim3d/viz/_k3d.py b/qim3d/viz/_k3d.py index aab60d40130d269d120b708311ee654652990135..2bfe12735f9d38874d05cd4c62f9a4a025dc8c07 100644 --- a/qim3d/viz/_k3d.py +++ b/qim3d/viz/_k3d.py @@ -211,7 +211,8 @@ def mesh( See full reference: https://www2.compute.dtu.dk/projects/GEL/PyGEL/pygel3d/jupyter_display.html#display Returns: - k3d.Plot or None: + k3d.Plot or None: + - If `backend="k3d"`, returns a `k3d.Plot` object. - If `backend="pygel3d"`, the function displays the mesh but does not return a plot object. Example: