Skip to content
Snippets Groups Projects
Commit afb40e7a authored by s214735's avatar s214735
Browse files

Checked docstrings for minor errors w main focus on example code

parent 015e7d5d
No related branches found
No related tags found
No related merge requests found
...@@ -27,8 +27,8 @@ def volume(obj: np.ndarray|trimesh.Trimesh, ...@@ -27,8 +27,8 @@ def volume(obj: np.ndarray|trimesh.Trimesh,
mesh = qim3d.io.load_mesh('path/to/mesh.obj') mesh = qim3d.io.load_mesh('path/to/mesh.obj')
# Compute the volume of the mesh # Compute the volume of the mesh
volume = qim3d.features.volume(mesh) vol = qim3d.features.volume(mesh)
print('Volume:', volume) print('Volume:', vol)
``` ```
Compute volume from a np.ndarray: Compute volume from a np.ndarray:
...@@ -37,9 +37,11 @@ def volume(obj: np.ndarray|trimesh.Trimesh, ...@@ -37,9 +37,11 @@ def volume(obj: np.ndarray|trimesh.Trimesh,
# Generate a 3D blob # Generate a 3D blob
synthetic_blob = qim3d.generate.noise_object(noise_scale = 0.015) synthetic_blob = qim3d.generate.noise_object(noise_scale = 0.015)
synthetic_blob = qim3d.generate.noise_object(noise_scale = 0.015)
# Compute the volume of the blob # Compute the volume of the blob
volume = qim3d.features.volume(synthetic_blob, level=0.5) volume = qim3d.features.volume(synthetic_blob, level=0.5)
volume = qim3d.features.volume(synthetic_blob, level=0.5)
print('Volume:', volume) print('Volume:', volume)
``` ```
...@@ -74,6 +76,7 @@ def area(obj: np.ndarray|trimesh.Trimesh, ...@@ -74,6 +76,7 @@ def area(obj: np.ndarray|trimesh.Trimesh,
# Compute the surface area of the mesh # Compute the surface area of the mesh
area = qim3d.features.area(mesh) area = qim3d.features.area(mesh)
area = qim3d.features.area(mesh)
print(f"Area: {area}") print(f"Area: {area}")
``` ```
...@@ -83,15 +86,18 @@ def area(obj: np.ndarray|trimesh.Trimesh, ...@@ -83,15 +86,18 @@ def area(obj: np.ndarray|trimesh.Trimesh,
# Generate a 3D blob # Generate a 3D blob
synthetic_blob = qim3d.generate.noise_object(noise_scale = 0.015) synthetic_blob = qim3d.generate.noise_object(noise_scale = 0.015)
synthetic_blob = qim3d.generate.noise_object(noise_scale = 0.015)
# Compute the surface area of the blob # Compute the surface area of the blob
volume = qim3d.features.area(synthetic_blob, level=0.5) volume = qim3d.features.area(synthetic_blob, level=0.5)
volume = qim3d.features.area(synthetic_blob, level=0.5)
print('Area:', volume) print('Area:', volume)
``` ```
""" """
if isinstance(obj, np.ndarray): if isinstance(obj, np.ndarray):
log.info("Converting volume to mesh.") log.info("Converting volume to mesh.")
obj = qim3d.mesh.from_volume(obj, **mesh_kwargs) obj = qim3d.mesh.from_volume(obj, **mesh_kwargs)
obj = qim3d.mesh.from_volume(obj, **mesh_kwargs)
return obj.area return obj.area
...@@ -123,6 +129,7 @@ def sphericity(obj: np.ndarray|trimesh.Trimesh, ...@@ -123,6 +129,7 @@ def sphericity(obj: np.ndarray|trimesh.Trimesh,
# Compute the sphericity of the mesh # Compute the sphericity of the mesh
sphericity = qim3d.features.sphericity(mesh) sphericity = qim3d.features.sphericity(mesh)
sphericity = qim3d.features.sphericity(mesh)
``` ```
Compute sphericity from a np.ndarray: Compute sphericity from a np.ndarray:
...@@ -131,9 +138,11 @@ def sphericity(obj: np.ndarray|trimesh.Trimesh, ...@@ -131,9 +138,11 @@ def sphericity(obj: np.ndarray|trimesh.Trimesh,
# Generate a 3D blob # Generate a 3D blob
synthetic_blob = qim3d.generate.noise_object(noise_scale = 0.015) synthetic_blob = qim3d.generate.noise_object(noise_scale = 0.015)
synthetic_blob = qim3d.generate.noise_object(noise_scale = 0.015)
# Compute the sphericity of the blob # Compute the sphericity of the blob
sphericity = qim3d.features.sphericity(synthetic_blob, level=0.5) sphericity = qim3d.features.sphericity(synthetic_blob, level=0.5)
sphericity = qim3d.features.sphericity(synthetic_blob, level=0.5)
``` ```
!!! info "Limitations due to pixelation" !!! info "Limitations due to pixelation"
...@@ -144,9 +153,12 @@ def sphericity(obj: np.ndarray|trimesh.Trimesh, ...@@ -144,9 +153,12 @@ def sphericity(obj: np.ndarray|trimesh.Trimesh,
if isinstance(obj, np.ndarray): if isinstance(obj, np.ndarray):
log.info("Converting volume to mesh.") log.info("Converting volume to mesh.")
obj = qim3d.mesh.from_volume(obj, **mesh_kwargs) obj = qim3d.mesh.from_volume(obj, **mesh_kwargs)
obj = qim3d.mesh.from_volume(obj, **mesh_kwargs)
volume = qim3d.features.volume(obj) volume = qim3d.features.volume(obj)
area = qim3d.features.area(obj) area = qim3d.features.area(obj)
volume = qim3d.features.volume(obj)
area = qim3d.features.area(obj)
if area == 0: if area == 0:
log.warning("Surface area is zero, sphericity is undefined.") log.warning("Surface area is zero, sphericity is undefined.")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment