|
| 1 | +import numpy as np |
| 2 | +from gempy_engine.core.data.raw_arrays_solution import RawArraysSolution |
| 3 | + |
| 4 | +import gempy as gp |
| 5 | +from gempy.core.data.enumerators import ExampleModel |
| 6 | +from gempy.core.data.grid_modules import RegularGrid |
| 7 | +from gempy.optional_dependencies import require_gempy_viewer |
| 8 | + |
| 9 | +PLOT = True |
| 10 | + |
| 11 | + |
| 12 | +def test_marching_cubes_implementation(): |
| 13 | + model = gp.generate_example_model(ExampleModel.COMBINATION, compute_model=False) |
| 14 | + |
| 15 | + # Change the grid to only be the dense grid |
| 16 | + dense_grid: RegularGrid = RegularGrid( |
| 17 | + extent=model.grid.extent, |
| 18 | + resolution=np.array([20, 20, 20]) |
| 19 | + ) |
| 20 | + |
| 21 | + model.grid.dense_grid = dense_grid |
| 22 | + gp.set_active_grid( |
| 23 | + grid=model.grid, |
| 24 | + grid_type=[model.grid.GridTypes.DENSE], |
| 25 | + reset=True |
| 26 | + ) |
| 27 | + |
| 28 | + model.interpolation_options.evaluation_options.mesh_extraction = False # * Not extracting the mesh with dual contouring |
| 29 | + gp.compute_model(model) |
| 30 | + |
| 31 | + # Assert |
| 32 | + assert model.solutions.block_solution_type == RawArraysSolution.BlockSolutionType.DENSE_GRID |
| 33 | + assert model.solutions.dc_meshes is None |
| 34 | + arrays = model.solutions.raw_arrays # * arrays is equivalent to gempy v2 solutions |
| 35 | + |
| 36 | + assert arrays.scalar_field_matrix.shape == (3, 8_000) # * 3 surfaces, 8000 points |
| 37 | + |
| 38 | + # TODO: Code to extract the mesh with marching cubes |
| 39 | + |
| 40 | + if PLOT: |
| 41 | + gpv = require_gempy_viewer() |
| 42 | + gtv: gpv.GemPyToVista = gpv.plot_3d(model, show_data=True, image=True) |
| 43 | + import pyvista as pv |
| 44 | + pyvista_plotter: pv.Plotter = gtv.p |
| 45 | + |
| 46 | + foo = np.empty(0) # TODO: use the marching cubes algorithm to add mesh to the gempy plot |
| 47 | + # Add the mesh to the plot |
| 48 | + pyvista_plotter.add_mesh( |
| 49 | + foo, |
| 50 | + show_edges=True, |
| 51 | + color='white', |
| 52 | + opacity=0.5, |
| 53 | + ) |
0 commit comments