Skip to content

Commit

Permalink
add structuredgrid constructor from numpy
Browse files Browse the repository at this point in the history
  • Loading branch information
marcomusy committed Feb 12, 2024
1 parent 8e8ab50 commit b6f7212
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions examples/volumetric/struc_grid1.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@

from vedo import *

# a noisy geometry
cx = np.sqrt(np.linspace(100, 400, 10))
cy = np.linspace(30, 40, 20)
cz = np.linspace(40, 50, 30)
x, y, z = np.meshgrid(cx, cy, cz)
# print("x.shape is", x.shape)
x, y, z = np.meshgrid(cx, cy, cz) + np.random.normal(0, 0.01, (20, 10, 30))

# sgrid1 = StructuredGrid(dataurl + "structgrid.vts")
sgrid1 = StructuredGrid([x, y, z])
sgrid1.cmap("viridis", sgrid1.vertices[:, 0]+np.sin(sgrid1.vertices[:, 1]))
print(sgrid1)

sgrid2 = sgrid1.clone().cut_with_plane(normal=(-1,1,1), origin=[14,34,44])
msh2 = sgrid2.tomesh(shrink=0.9).lw(1).cmap("viridis")
msh2 = sgrid2.tomesh(shrink=0.9).linewidth(1).cmap("viridis")

show(
[["StructuredGrid", sgrid1], ["Shrinked Mesh", msh2]],
Expand Down

0 comments on commit b6f7212

Please sign in to comment.