Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix setting of texture coordinates #317

Merged
merged 1 commit into from
Nov 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions gemgis/visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,8 +505,15 @@ def create_mesh_from_cross_section(linestring: shapely.geometry.linestring.LineS
# Creating PyVista PolyData
surface = pv.PolyData(vertices, faces)

# Generating Tcoords
surface.t_coords = uv
# Set texture coordinates on PyVista mesh. This has been renamed a few times
# Reference https://github.com/pyvista/pyvista/issues/5209
try:
if pv._version.version_info < (0, 43):
surface.active_t_coords = uv
else:
surface.active_texture_coordinates = uv
Comment on lines +511 to +514
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we want to add a third condition if the version is whenever t_coords was supported, but honestly that version of PyVista is not supported these days and this should use the modern API

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@banesullivan thanks for looking into that. I did not realize that the error was on my side during the mesh generation! I would actually keep it to the latest version of PyVista! If you don't mind just changing the old line 509 to what you have written in the new line 514 now (surface.active_texture_coordinates = uv), then I would be happy to merge it :)

Within the framework of the PyOpenSci Review, I will also have to extend and complete my tests.....

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Considering that 0.43 isn't out yet, I recommend keeping this

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, right, should have read it more carefully. So it will be renamed in 0.43 again

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely get this though and make sure this change is what you need. I did not run this code

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just checked and your changes fix the issue! The texture is shown correctly again.

except AttributeError:
raise ImportError("Please make sure you are using a compatible version of PyVista")

return surface

Expand Down