-
|
Hi all, We have a cuboid with one corner cut away to a smooth face. We then generate a slice in XY so normal to Z - the example shown in the image is at z=1. Using the timer callback we then modulate the z position every frame to simulates the changing liquid level in a tank, for example. At the moment we are removing and then generating a new slice object in every frame. But the (significant) impact on the scene update time suggest there must be a better way? Is there an obvious solution to finding the liquid level of an irregular tank given the tank shape and liquid height? Further, would it be possible to also generate a new mesh for the volume of liquid in the tank every frame performantly? Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
|
Hope this example helps! I don't know if it's performant enough though... from vedo import *
def func(w, evt=""):
z = slider.value
level = Plane(res=(50,50)).triangulate().pos(0,0,z)
level.cut_with_mesh(tank, invert=False)
level.compute_normals()
level.lighting("off").c("blue3").alpha(0.5)
ctank = tank.clone().cut_with_plane(normal="z", origin=(0, 0, z), invert=True)
total = merge(ctank, level).compute_normals()#.flip_normals().reverse()
t2d.text(f"Water level: {z:.3f} m\nVolume: {total.volume():.4f} m:^3")
plt.remove("Plane").add(level)
settings.default_font = "Roboto"
tank = Paraboloid().rotate_x(180)
tank.compute_normals().flip_normals().reverse()
tank.lighting("off").c("orange3").alpha(0.2)
t2d = Text2D()
plt = Plotter()
slider = plt.add_slider(func, 0, 1, value=0, title="Level", show_value=False)
plt.show(
tank,
t2d,
axes=1,
bg="orange9",
bg2="blue9",
viewup="z",
)
plt.close() |
Beta Was this translation helpful? Give feedback.
-
|
Thanks, I will take a close look at this. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.








hi, I think it can be due to a precision issue as the vertices of the mesh exactly overlap with the cutting plane.
you can try to tilt a little bit the tank
tank.rotate_y(1)and see if the problem persists..also check out this simplified version which might be faster: