Closed qing-1998 closed 5 months ago
Dear @qing-1998,
GemGIS currently works with GemPy Versions < 3. I am currently testing GemPy 3 and work solutions to make GemGIS compatible with GemPy 3.
Stay tuned
Is there any other way to get vertices and faces from geo_model or i need to use GemPy versions <3?
Hi @qing-1998, I also am trying get vertices and faces from geo_model. I ran the following code, but there was an error.
vertices, faces = gp.get_surfaces(geo_model)
x0, y0, z0 = 0, 0, -700
for i in range(len(vertices)): np.save('vertices/' + 'vert%02d.npy' %i, vertices[i]-[x0, y0, z0]) np.save('faces/' + 'faces%02d.npy' %i, faces[i]) print(len(vertices[i]))
AttributeError: module 'gempy' has no attribute 'get_surfaces'
@glory21 As i know there has no attribute 'get surfaces' in GenPy3 @AlexanderJuestel But when i import gempy_legacy , there has an error 'ModuleNotFoundError: No module named 'numpy.distutils' , if i do not import gempy_legacy , the code can run normally.
Hi, @glory21: Again I think you should switch to gempy_v3 and use the method suggested in your issue (or here).
@qing-1998: So you can get the meshes either from geo_model.solutions.dc_meshes
or geo_model.solutions.raw_arrays.vertices
and geo_model.solutions.raw_arrays.edges
. You are correct though that the coordinates are not in the orginal form, as we use a coordinate transformation in gempy. You can easily back transform them appplying the inverse as follows
data.transform.apply_inverse(data.solutions.raw_arrays.vertices[2])
The index here is refering to a specific mesh for a structural element.
Please let me know if this is the solution you are looking for.
Cheers Jan
@javoha Thanks , the problem has been solved. Have a nice day
Jo
Just for completion:
Mesh extracted with GemGIS using mesh = gg.visualization.create_depth_maps_from_gempy(geo_model, `surface1')
with incorrect coordinates.
Mesh extracted using geo_model.solutions.dc_meshes
with incorrect coordinates and the following code:
meshes_gempy = geo_model.solutions.dc_meshes
faces = np.hstack(np.pad(meshes_gempy[0].edges, ((0, 0), (1, 0)), 'constant', constant_values=3))
mesh = pv.PolyData(meshes_gempy[0].vertices, faces)
Mesh extracted with correct coordinates using the proposed transform.
vertices = geo_model.transform.apply_inverse(geo_model.solutions.raw_arrays.vertices[0])
faces = np.hstack(np.pad(geo_model.solutions.raw_arrays.edges, ((0, 0), (1, 0)), 'constant', constant_values=3))
mesh = pv.PolyData(vertices, faces)
# Assigning Depth values to mesh
mesh['Depth [m]'] = mesh.points[:, 2]
hi, It seems i lost the Coordinates of surface points when i use "=gg.visualization.create_depth_maps_from_gempy(geo_model=geo_model, surfaces='sand1')", and also can not find it in "= geo_model.solutions.raw_arrays", i want to extract the model to pyvista , then make it to be a solid model , i use gempy-2024.1.4 , pls tell me how could i do , thanks. Have a nice day.