1- from typing import Optional , Union , Callable
1+ from __future__ import annotations
2+
3+ from typing import Optional , Union , Callable , List
24import numpy as np
35import numpy .typing as npt
46from LoopStructural .utils import getLogger
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
1416from 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
1921class 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