From 649f8b416198ede4965176bbdcad9519399b1132 Mon Sep 17 00:00:00 2001 From: Michael Krayer Date: Tue, 22 Feb 2022 13:54:38 +0100 Subject: [PATCH] add open border bounding box --- visu.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/visu.py b/visu.py index 9c4b2da..c609257 100644 --- a/visu.py +++ b/visu.py @@ -4,6 +4,27 @@ def add_domain_bounds(plotter,bounds,color='black',line_width=2.): plotter.add_mesh(domain,color=color,style='wireframe',line_width=line_width,opacity=0.999,lighting=False) return +def add_domain_bounds_open(plotter,bounds,opacity_front=None,xlen=1.0,ylen=1.0,zlen=1.0, + color='black',line_width=2.): + import pyvista + x0,x1,y0,y1,z0,z1 = bounds + domain = pyvista.Line((x0,y0,z0),(x1,y0,z0)) + \ + pyvista.Line((x0,y0,z0),(x0,y1,z0)) + \ + pyvista.Line((x0,y0,z0),(x0,y0,z1)) + \ + pyvista.Line((x1,y0,z0),(x1,y1,z0)) + \ + pyvista.Line((x1,y0,z0),(x1,y0,z1)) + \ + pyvista.Line((x0,y0,z1),(x1,y0,z1)) + \ + pyvista.Line((x1,y0,z1),(x1,y1,z1)) + \ + pyvista.Line((x0,y1,z0),(x1,y1,z0)) + \ + pyvista.Line((x1,y1,z0),(x1,y1,z1)) + plotter.add_mesh(domain,color=color,line_width=line_width,opacity=0.999,lighting=False) + if not opacity_front is None: + domain_front = pyvista.Line((x0+(1.-xlen)*(x1-x0),y1,z1),(x1,y1,z1)) + \ + pyvista.Line((x0,y0,z1),(x0,ylen*y1,z1)) + \ + pyvista.Line((x0,y1,z0),(x0,y1,zlen*z1)) + plotter.add_mesh(domain_front,color=color,line_width=line_width,opacity=opacity_front,lighting=False) + return + def enable_shadows_hacked(pl): # Reimplements pyvistas "enable_shadows()" method to also render translucent # objects (without shadows). Can be used to add objects which do not throw