Skip to content

Commit baa083a

Browse files
committed
fix: return isosurfaces as a list rather than dictionary
1 parent 40673c0 commit baa083a

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

LoopStructural/api/_surface.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
from typing import Optional, Union, Callable
1+
from __future__ import annotations
2+
3+
from typing import Optional, Union, Callable, List
24
import numpy as np
35
import numpy.typing as npt
46
from LoopStructural.utils import getLogger
@@ -10,17 +12,17 @@
1012
logger.warning("Using deprecated version of scikit-image")
1113
from skimage.measure import marching_cubes_lewiner as marching_cubes
1214

13-
from LoopStructural.interpolators import GeologicalInterpolator
15+
# from LoopStructural.interpolators import GeologicalInterpolator
1416
from LoopStructural.datatypes import Surface, BoundingBox
1517

16-
surface_list = dict[str, tuple[npt.ArrayLike, npt.ArrayLike, npt.ArrayLike, npt.ArrayLike]]
18+
surface_list = dict[str, Surface]
1719

1820

1921
class LoopIsosurfacer:
2022
def __init__(
2123
self,
2224
bounding_box: BoundingBox,
23-
interpolator: Optional[GeologicalInterpolator] = None,
25+
interpolator: Optional['GeologicalInterpolator'] = None,
2426
callable: Optional[Callable[[npt.ArrayLike], npt.ArrayLike]] = None,
2527
):
2628
"""Extract isosurfaces from a geological interpolator or a callable function.
@@ -56,7 +58,9 @@ def __init__(
5658
if self.callable is None:
5759
raise ValueError("Must specify either interpolator or callable")
5860

59-
def fit(self, values: Union[list, int, float]) -> surface_list:
61+
def fit(
62+
self, values: Union[list, int, float], name: Optional[Union[List[str], str]] = None
63+
) -> surface_list:
6064
"""Extract isosurfaces from the interpolator
6165
6266
Parameters
@@ -74,7 +78,7 @@ def fit(self, values: Union[list, int, float]) -> surface_list:
7478
"""
7579
if not callable(self.callable):
7680
raise ValueError("No interpolator of callable function set")
77-
surfaces = {}
81+
surfaces = []
7882
all_values = self.callable(self.bounding_box.regular_grid())
7983
if isinstance(values, list):
8084
isovalues = values
@@ -93,11 +97,13 @@ def fit(self, values: Union[list, int, float]) -> surface_list:
9397
spacing=self.bounding_box.step_vector,
9498
)
9599
values = np.zeros(verts.shape[0]) + isovalue
96-
surfaces[f"surface_{isovalue}"] = Surface(
97-
vertices=verts + self.bounding_box.origin,
98-
triangles=faces,
99-
normals=normals,
100-
name=f"surface_{isovalue}",
101-
values=values,
100+
surfaces.append(
101+
Surface(
102+
vertices=verts + self.bounding_box.origin,
103+
triangles=faces,
104+
normals=normals,
105+
name=f"surface_{isovalue}",
106+
values=values,
107+
)
102108
)
103109
return surfaces

0 commit comments

Comments
 (0)