|
| 1 | +from __future__ import annotations |
| 2 | + |
1 | 3 | from abc import ABCMeta, abstractmethod |
| 4 | +from typing import Union, List, Optional |
2 | 5 | from LoopStructural.modelling.features import FeatureType |
3 | 6 | from LoopStructural.utils import getLogger |
4 | 7 | from LoopStructural.utils.typing import NumericInput |
| 8 | +from LoopStructural.api import LoopIsosurfacer, surface_list |
5 | 9 |
|
6 | 10 |
|
7 | 11 | import numpy as np |
@@ -263,3 +267,54 @@ def __tojson__(self): |
263 | 267 | "regions": regions, |
264 | 268 | "faults": faults, |
265 | 269 | } |
| 270 | + |
| 271 | + def surfaces( |
| 272 | + self, |
| 273 | + value: Union[float, int, List[Union[float, int]]], |
| 274 | + bounding_box=None, |
| 275 | + name=Optional[Union[List[str], str]], |
| 276 | + ) -> surface_list: |
| 277 | + """Find the surfaces of the geological feature at a given value |
| 278 | +
|
| 279 | + Parameters |
| 280 | + ---------- |
| 281 | + value : Union[float, int, List[float, int]] |
| 282 | + value or list of values to find the surface of the feature |
| 283 | +
|
| 284 | + Returns |
| 285 | + ------- |
| 286 | + list |
| 287 | + list of surfaces |
| 288 | + """ |
| 289 | + if isinstance(value, (float, int)): |
| 290 | + value = [value] |
| 291 | + if bounding_box is None: |
| 292 | + if self.model is None: |
| 293 | + raise ValueError("Must specify bounding box") |
| 294 | + bounding_box = self.model.bounding_box |
| 295 | + |
| 296 | + isosurfacer = LoopIsosurfacer(bounding_box, self) |
| 297 | + return isosurfacer.fit(value, name) |
| 298 | + |
| 299 | + def scalar_field(self, bounding_box=None): |
| 300 | + """Create a scalar field for the feature |
| 301 | +
|
| 302 | + Parameters |
| 303 | + ---------- |
| 304 | + bounding_box : Optional[BoundingBox], optional |
| 305 | + bounding box to evaluate the scalar field in, by default None |
| 306 | +
|
| 307 | + Returns |
| 308 | + ------- |
| 309 | + np.ndarray |
| 310 | + scalar field |
| 311 | + """ |
| 312 | + if bounding_box is None: |
| 313 | + if self.model is None: |
| 314 | + raise ValueError("Must specify bounding box") |
| 315 | + bounding_box = self.model.bounding_box |
| 316 | + grid = bounding_box.vtk |
| 317 | + points = grid.points |
| 318 | + value = self.evaluate_value(points) |
| 319 | + grid[self.name] = value |
| 320 | + return grid |
0 commit comments