Add offscreen mesh screenshot rendering of exported exodus meshes - #146
Open
m-frey wants to merge 1 commit into
Open
Add offscreen mesh screenshot rendering of exported exodus meshes#146m-frey wants to merge 1 commit into
m-frey wants to merge 1 commit into
Conversation
m-frey
had a problem deploying
to
cubit_secrets_untrusted
July 9, 2026 13:48 — with
GitHub Actions
Failure
m-frey
requested review from
danielwolff1 and
isteinbrecher
and removed request for
Copilot
July 9, 2026 13:48
m-frey
force-pushed
the
add-mesh-screenshot
branch
from
July 9, 2026 14:00
fe33623 to
d375ae0
Compare
m-frey
requested a deployment
to
cubit_secrets_untrusted
July 9, 2026 14:00 — with
GitHub Actions
Waiting
There was a problem hiding this comment.
Pull request overview
Adds an offscreen (Agg) matplotlib-based renderer to produce PNG screenshots of the current Cubit HEX8 mesh by exporting to a temporary Exodus file, extracting exterior faces, and applying simple shading. This extends CubitPy with a convenient CubitPy.mesh_screenshot(...) helper and exposes a standalone render_mesh_screenshot(...) entry point.
Changes:
- Introduces
cubitpy.mesh_screenshot.render_mesh_screenshot(...)and_get_shaded_exterior_faces(...)to extract/shade exterior HEX8 faces and write a PNG via matplotlib. - Adds
CubitPy.mesh_screenshot(...)to export the current mesh to Exodus and render a screenshot. - Adds tests validating exterior face extraction and end-to-end screenshot generation (with matplotlib optional).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| tests/test_cubitpy.py | Adds unit/integration tests for shaded exterior face extraction and PNG rendering. |
| src/cubitpy/mesh_screenshot.py | New matplotlib-based offscreen renderer for exported HEX8 meshes. |
| src/cubitpy/cubitpy.py | Adds CubitPy.mesh_screenshot(...) convenience API. |
| src/cubitpy/init.py | Re-exports render_mesh_screenshot at package level. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+2598
to
+2600
| def test_shaded_exterior_faces(): | ||
| """Check exterior face extraction and face color generation.""" | ||
| coordinates = np.array( |
Comment on lines
+99
to
+108
| try: | ||
| import matplotlib | ||
| except ModuleNotFoundError as err: # pragma: no cover | ||
| raise ModuleNotFoundError( | ||
| "render_mesh_screenshot needs matplotlib (pip install matplotlib)." | ||
| ) from err | ||
|
|
||
| matplotlib.use("Agg") | ||
| import matplotlib.pyplot as plt | ||
| from mpl_toolkits.mplot3d.art3d import Poly3DCollection |
Comment on lines
+467
to
+473
| from cubitpy.mesh_screenshot import render_mesh_screenshot | ||
|
|
||
| exo_path = Path(cupy.temp_dir) / "cubitpy_screenshot.exo" | ||
| self.export_exo(exo_path, add_node_set_info=False) | ||
| return render_mesh_screenshot( | ||
| exo_path, png_path, skip_blocks=skip_blocks, **kwargs | ||
| ) |
Collaborator
|
@m-frey what exactly is the purpose of this new functionality? Does this really belong into CubitPy? |
m-frey
force-pushed
the
add-mesh-screenshot
branch
from
July 9, 2026 15:43
d375ae0 to
bd56a03
Compare
m-frey
had a problem deploying
to
cubit_secrets_untrusted
July 9, 2026 15:43 — with
GitHub Actions
Failure
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This exports the current Cubit mesh to a temporary Exodus file and renders hex blocks to PNG using matplotlib. The renderer extracts exterior hex faces, applies simple face shading, supports skipping selected block names, and exposes the functionality through CubitPy.mesh_screenshot(...).