Compare commits

...

2 Commits

Author SHA1 Message Date
Michael Krayer aec0cdead6 simplification for unraveled trajectories 2022-02-22 13:55:13 +01:00
Michael Krayer 649f8b4161 add open border bounding box 2022-02-22 13:54:38 +01:00
2 changed files with 30 additions and 4 deletions

View File

@ -536,12 +536,17 @@ class Trajectories:
self.unraveled = False self.unraveled = False
return return
def to_vtk(self): def to_vtk(self,slice_part=slice(None),slice_time=slice(None),force_ravel=False):
import pyvista as pv import pyvista as pv
mesh = pv.PolyData() mesh = pv.PolyData()
for part in self.get_trajectories_segmented(): if force_ravel or not self.unraveled:
for part in self.get_trajectories_segmented(slice_part=slice_part,slice_time=slice_time):
for seg in part: for seg in part:
mesh += pv.helpers.lines_from_points(seg.transpose()) mesh += pv.helpers.lines_from_points(seg.transpose())
else:
tmp = self.get_trajectories(slice_part=slice_part,slice_time=slice_time)
for ipart in range(self.numpart):
mesh += pv.helpers.lines_from_points(np.array([tmp[0][ipart],tmp[1][ipart],tmp[2][ipart]]).transpose())
return mesh return mesh
def _make_data_array(self): def _make_data_array(self):

21
visu.py
View File

@ -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) plotter.add_mesh(domain,color=color,style='wireframe',line_width=line_width,opacity=0.999,lighting=False)
return 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): def enable_shadows_hacked(pl):
# Reimplements pyvistas "enable_shadows()" method to also render translucent # Reimplements pyvistas "enable_shadows()" method to also render translucent
# objects (without shadows). Can be used to add objects which do not throw # objects (without shadows). Can be used to add objects which do not throw