Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
qim3d
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
QIM
Tools
qim3d
Commits
afb40e7a
Commit
afb40e7a
authored
4 months ago
by
s214735
Browse files
Options
Downloads
Patches
Plain Diff
Checked docstrings for minor errors w main focus on example code
parent
015e7d5d
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
qim3d/features/_common_features_methods.py
+14
-2
14 additions, 2 deletions
qim3d/features/_common_features_methods.py
with
14 additions
and
2 deletions
qim3d/features/_common_features_methods.py
+
14
−
2
View file @
afb40e7a
...
@@ -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
vol
ume
= qim3d.features.volume(mesh)
vol = qim3d.features.volume(mesh)
print(
'
Volume:
'
, vol
ume
)
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.
"
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment