Skip to content

Commit

Permalink
[BUG] Meshes were displaced
Browse files Browse the repository at this point in the history
  • Loading branch information
Leguark committed Mar 10, 2023
1 parent 7039cad commit 0fa2956
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 10 deletions.
4 changes: 3 additions & 1 deletion gempy/core/solution.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,9 @@ def compute_marching_cubes_regular_grid(self, level: float, scalar_field,
spacing = self.grid.regular_grid.get_dx_dy_dz(rescale=rescale)
vertices, simplices, normals, values = measure.marching_cubes(
scalar_field.reshape(rg.resolution),
level, spacing=spacing, mask=mask_array, **kwargs)
level,
spacing=spacing,
mask=mask_array, **kwargs)
idx = [0, 2, 4]
loc_0 = rg.extent_r[idx] if rescale else rg.extent[idx]
loc_0 = loc_0 + np.array(spacing) / 2
Expand Down
1 change: 0 additions & 1 deletion gempy_3/api/gp2_to_gp3_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ def gempy_project_to_interpolation_input(geo_model: Project) -> InterpolationInp
regular_grid: RegularGrid = RegularGrid(
extent=geo_model.grid.regular_grid.extent_r,
regular_grid_shape=geo_model.grid.regular_grid.resolution,
#regular_grid_shape=[2, 2, 2],
)

grid: Grid = Grid(
Expand Down
4 changes: 1 addition & 3 deletions gempy_3/api/gp3_to_gp2_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ def set_gp3_solutions_to_gp2_solution(gp3_solution: Solutions, geo_model: Projec
_set_lith_block(geo_model, octree_output, regular_grid_scalar)
_set_scalar_field(geo_model, octree_output)

# geo_model.solutions.scalar_field_at_surface_points = [octree_output.outputs_centers[0].scalar_fields.exported_fields.scalar_field_at_surface_points,
# octree_output.outputs_centers[1].scalar_fields.exported_fields.scalar_field_at_surface_points]
_set_scalar_field_at_surface_points(geo_model, octree_output)

meshes: list[DualContouringMesh] = gp3_solution.dc_meshes
Expand Down Expand Up @@ -47,7 +45,7 @@ def _set_surfaces_meshes(geo_model: Project, meshes: list[DualContouringMesh]) -
in_ = meshes

for i in range(0, len(meshes)):
surfaces_df.iloc[i, idx_of_vertices] = [in_[i].vertices * rescaling_factor - shift]
surfaces_df.iloc[i, idx_of_vertices] = [(in_[i].vertices - 0.5001) * rescaling_factor + shift] # ! remember the 0.5001
surfaces_df.iloc[i, idx_of_edges] = [in_[i].edges]

return geo_model
Expand Down
8 changes: 3 additions & 5 deletions gempy_3/api/test_api/test_model_gempy2_to_gempy3.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def map_sequential_pile(geo_model: Project) -> Project:


def test_set_gempy3_gempy2_bridge():
BackendTensor.change_backend(AvailableBackends.numpy, use_gpu=False, pykeops_enabled=True)
BackendTensor.change_backend(AvailableBackends.numpy, use_gpu=False, pykeops_enabled=False)

geo_model: Project = load_model()
geo_model = map_sequential_pile(geo_model)
Expand All @@ -56,9 +56,7 @@ def test_set_gempy3_gempy2_bridge():
input_data_descriptor: InputDataDescriptor = gempy_project_to_input_data_descriptor(geo_model)
options : InterpolationOptions = gempy_project_to_interpolation_options(geo_model)
# @on

#geo_model.set_regular_grid(extent=[0, 2000., 0, 2000., 0, 2000.], resolution=[16, 16, 16])


print(interpolation_input)
print(input_data_descriptor)
print(options)
Expand All @@ -79,7 +77,7 @@ def test_set_gempy3_gempy2_bridge():
gp.plot.plot_2d(geo_model, cell_number=25, direction='y', show_data=True, show_block=False, show_lith=True, series_n=1)

plot_object: GemPyToVista = gp.plot.plot_3d(
geo_model, show_surfaces=True, show_lith=True, off_screen=False
geo_model, show_surfaces=True, show_lith=True, off_screen=False, kwargs_plot_structured_grid={"show_edges": False}
)


Expand Down

0 comments on commit 0fa2956

Please sign in to comment.