Skip to content

feat(volume_mesh): add prism and pyramid cell support (upstream PR #353)#5

Merged
xarthurx merged 15 commits into
mainfrom
feat/volume-mesh-prism-pyramid
May 19, 2026
Merged

feat(volume_mesh): add prism and pyramid cell support (upstream PR #353)#5
xarthurx merged 15 commits into
mainfrom
feat/volume-mesh-prism-pyramid

Conversation

@xarthurx

Copy link
Copy Markdown
Owner

Summary

Ports upstream C++ Polyscope PR #353 (commit dcbaedb) — adds prism (6-vertex wedge) and pyramid (5-vertex) cells to `VolumeMesh`, reaching parity with all four upstream cell types.

  • New public API: `register_prism_mesh`, `register_pyramid_mesh`, `VolumeMesh::new_prism_mesh`, `VolumeMesh::new_pyramid_mesh`, `slice_prism`, `slice_pyramid`.
  • `VolumeMesh::cell_type` switches to sentinel-count classification (0/2/3/4 → Hex/Prism/Pyramid/Tet) matching upstream.
  • Cell shape data (face polygons, triangulation stencils, tet-decomposition patterns) extracted to a new `cell_data` submodule so each per-cell loop dispatches through a single `face_data_for(cell_type)` table — collapses ~90 lines of tet-vs-hex branching while making all 4 cell types first-class.
  • New example: `volume_mesh_mixed_cells_demo` registers one of each cell type side-by-side.

Changes

Commit What
`9cbb85f` Scaffold `cell_data` submodule + enum variants
`a6697d1` Sentinel-count cell_type detection
`57fb27d` Tet-decomposition + centroid for prism/pyramid
`9010c0b` Refactor 7 face-iteration sites to dispatch via `cell_data`
`fd2256f` `slice_prism` / `slice_pyramid` via tet decomposition
`8937f2b` Public `register_prism_mesh` / `register_pyramid_mesh`
`7cee690` Mixed-cell-type demo example
`be474a0` Update feature-status.md + CHANGELOG
`57a3321` rustfmt pass
`c454089` Simplify pass: faster `cell_type`, no per-cell `Vec` in decomposition, slice helper extraction, fix UI label that was miscounting prisms as hex

Test Plan

  • `cargo test --workspace` — 214 passed, 2 ignored
  • `cargo clippy --workspace -- -D warnings` — zero warnings
  • `cargo fmt --check` — clean
  • New tests cover: cell-type detection for all 4 types, prism/pyramid tet decomposition, prism/pyramid centroid, single-cell exterior face counts, mixed-cell mesh face counts, prism/pyramid slice geometry, public constructors
  • Manual visual check (please run before merging): `cargo run --release --example volume_mesh_mixed_cells_demo` — verify the four shapes render correctly side-by-side, each with its "z" scalar quantity selectable, and picking highlights individual cells

Notes

  • File-size budget: `volume_mesh/mod.rs` net change is −90 lines (the dispatch refactor offset all four new cell-type code paths). Stays well under the 2000-line limit.
  • Cross-cell decomposition consistency for prism/pyramid uses the same diagonal-split rule as upstream so shared faces in mixed meshes tessellate identically.

🤖 Generated with Claude Code

xarthurx added 10 commits May 19, 2026 09:50
- cell_type_of(): 1-3 slot checks instead of iter-filter-count, removes
  per-cell sentinel scan from 9 hot loops.
- decompose_to_tets / num_tets: drop per-cell Vec allocation via
  for_each_tet callback; num_tets is now O(n) instead of O(decompose+alloc).
- cell_centroid: iterate only real vert count from cell type.
- slice_hex/prism/pyramid: extract shared slice_via_tet_decomposition.
- Fix UI label that miscounted prisms/pyramids as hexes.
- Update stale "tetrahedral or hexahedral" doc on VolumeMesh.
Copilot AI review requested due to automatic review settings May 19, 2026 08:17
@xarthurx

Copy link
Copy Markdown
Owner Author

@copilot resolve the merge conflicts in this pull request

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

Ports upstream Polyscope PR #353 to add prism (wedge) and pyramid cell support to VolumeMesh, expanding mixed-cell functionality (cell-type detection, face iteration/rendering, slicing) to cover all four upstream cell types.

Changes:

  • Added new prism/pyramid registration + constructors and a mixed-cell demo example.
  • Refactored per-cell face/tet decomposition logic into a new cell_data table and switched cell_type detection to sentinel-count classification.
  • Extended slice helpers to support prism/pyramid via tet decomposition, with accompanying tests and documentation updates.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
examples/volume_mesh_mixed_cells_demo.rs New example showing tet/hex/prism/pyramid side-by-side.
docs/feature-status.md Updates feature parity notes to include prism/pyramid support.
crates/polyscope/src/volume_mesh.rs Adds register_prism_mesh / register_pyramid_mesh public API.
crates/polyscope/Cargo.toml Registers the new example target.
crates/polyscope-structures/src/volume_mesh/slice_geometry.rs Adds slice_prism / slice_pyramid and shared slicing helper.
crates/polyscope-structures/src/volume_mesh/mod.rs Adds new cell types, constructors, sentinel-based cell_type, and dispatches loops via cell_data.
crates/polyscope-structures/src/volume_mesh/cell_data.rs New centralized face/triangulation + tet-decomposition tables per cell type.
CHANGELOG.md Documents the new cell types, APIs, and sentinel-based classification change.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread crates/polyscope-structures/src/volume_mesh/cell_data.rs Outdated

Copilot AI commented May 19, 2026

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request

Resolved by merging origin/main into this branch and fixing the conflicts in CHANGELOG.md and docs/feature-status.md so both sets of updates are preserved. Addressed in commit 2f21074.

xarthurx added 4 commits May 19, 2026 11:29
The triangulation [[2,4,5], [2,1,4]] for prism side quad 2 was wound
opposite to its polygon order [2,5,4,1], producing inward face normals
in init_render_data (which uses (p1-p0).cross(p2-p0)). Other prism faces
and tet/hex/pyramid stencils are consistent.

Switch to [[2,5,4], [4,1,2]] (same diagonal split, CCW). Upstream C++
Polyscope ships the same inward stencil — likely latent there too.
…m-pyramid

# Conflicts:
#	CHANGELOG.md
#	docs/feature-status.md
Rustdoc parsed p[0], p[2], p[1], p[3] as broken intra-doc links,
failing the workspace doc build with -D warnings. Wrap the
expressions in backticks so rustdoc treats them as code spans.
@xarthurx xarthurx merged commit 856fad4 into main May 19, 2026
5 checks passed
@xarthurx xarthurx deleted the feat/volume-mesh-prism-pyramid branch May 19, 2026 09:42
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