Skip to content
Merged
Show file tree
Hide file tree
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
14 changes: 13 additions & 1 deletion src/polyscope/volume_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,19 @@ def register_volume_mesh(
material: str | None = None,
transparency: float | None = None,
) -> VolumeMesh:
"""Register a new volume mesh"""
"""
Register a new volume mesh.

Pass index arrays of tets (N,4), hexes (N,8) or mixed_cells (N,8) to specify the cell connectivity.

The mixed_cells argument supports a mixture of tets, hexes, prisms, and pyramid elements; for each
row of indices, right-pad with -1 indices when not needed for that element type, for example a
pyramid cell row might be [72, 33, 86, 91, 15, -1, -1, -1].

It is not supported to specify both tets/hexes and the general mixed_cells; in this case, just pass
all cells as mixed_cells. You may pass both the tets and hexes arrays simultaneously, if so the cells
are presumed to be ordered with all tetrahedral cells coming first, then hexahedral cells.
"""

if not psb.is_initialized():
raise RuntimeError("Polyscope has not been initialized")
Expand Down
14 changes: 14 additions & 0 deletions test/tests/test_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -1816,6 +1816,20 @@ def test_add_mixed(self):
# cells[-5:,4:] = -1 # clear out some rows at end
# ps.register_volume_mesh("test_mesh3", self.generate_verts(), hexes=self.generate_tets())

def test_add_prisms_pyramids_mixed(self):
np.random.seed(777)
n_pts = 10
# prisms: (N,6) padded to (N,8) with -1 in last 2 cols
prism_cells = np.random.randint(0, n_pts, size=(n_pts, 8))
prism_cells[:, 6:] = -1
# pyramids: (N,5) padded to (N,8) with -1 in last 3 cols
pyramid_cells = np.random.randint(0, n_pts, size=(n_pts, 8))
pyramid_cells[:, 5:] = -1
cells = np.concatenate([prism_cells, pyramid_cells], axis=0)
ps.register_volume_mesh("test_mesh3", self.generate_verts(), mixed_cells=cells)
ps.show(3)
ps.remove_all_structures()

def test_options(self):
p = ps.register_volume_mesh("test_mesh", self.generate_verts(), self.generate_tets())

Expand Down
Loading