Skip to content

Commit

Permalink
make isosurfacing like mpl. int = number of surfaces, float = surface…
Browse files Browse the repository at this point in the history
… value, list = values to isosurface
  • Loading branch information
lachlangrose committed Apr 22, 2024
1 parent 597dfaa commit 5164c47
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions LoopStructural/api/_surface.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,17 @@ def fit(
isovalues = values
elif isinstance(values, float):
isovalues = [values]
elif isinstance(values, int) and values < 1:
raise ValueError(
"Number of isosurfaces must be greater than 1. Either use a positive integer or provide a list or float for a specific isovalue."
)
elif isinstance(values, int):
isovalues = np.linspace(
np.min(all_values) + np.finfo(float).eps,
np.max(all_values) + np.finfo(float).eps,
np.nanmin(all_values) + np.finfo(float).eps,
np.nanmax(all_values) - np.finfo(float).eps,
values,
)
logger.info(f'Isosurfacing at values: {isovalues}')
for isovalue in isovalues:
try:

Expand All @@ -101,6 +106,9 @@ def fit(
except RuntimeError:
logger.warning(f"Failed to extract isosurface for {isovalue}")
continue
except ValueError:
logger.warning(f"Failed to extract isosurface for {isovalue}")
continue
values = np.zeros(verts.shape[0]) + isovalue
surfaces.append(
Surface(
Expand Down

0 comments on commit 5164c47

Please sign in to comment.