Skip to content

Add offscreen mesh screenshot rendering of exported exodus meshes - #146

Open
m-frey wants to merge 1 commit into
imcs-compsim:mainfrom
m-frey:add-mesh-screenshot
Open

Add offscreen mesh screenshot rendering of exported exodus meshes#146
m-frey wants to merge 1 commit into
imcs-compsim:mainfrom
m-frey:add-mesh-screenshot

Conversation

@m-frey

@m-frey m-frey commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

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(...).

Copilot AI review requested due to automatic review settings July 9, 2026 13:48
@m-frey
m-frey had a problem deploying to cubit_secrets_untrusted July 9, 2026 13:48 — with GitHub Actions Failure
@m-frey
m-frey requested review from danielwolff1 and isteinbrecher and removed request for Copilot July 9, 2026 13:48
Copilot AI review requested due to automatic review settings July 9, 2026 14:00
@m-frey
m-frey force-pushed the add-mesh-screenshot branch from fe33623 to d375ae0 Compare July 9, 2026 14:00
@m-frey
m-frey requested a deployment to cubit_secrets_untrusted July 9, 2026 14:00 — with GitHub Actions Waiting

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 thread tests/test_cubitpy.py
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 thread src/cubitpy/cubitpy.py
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
)
@isteinbrecher

Copy link
Copy Markdown
Collaborator

@m-frey what exactly is the purpose of this new functionality? Does this really belong into CubitPy?

@m-frey
m-frey force-pushed the add-mesh-screenshot branch from d375ae0 to bd56a03 Compare July 9, 2026 15:43
@m-frey
m-frey had a problem deploying to cubit_secrets_untrusted July 9, 2026 15:43 — with GitHub Actions Failure
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants