From 116ea7904ee3ffd4acfe1f26a77bf12e6abafa62 Mon Sep 17 00:00:00 2001 From: craig-warren Date: Thu, 4 Jan 2024 12:15:29 +0000 Subject: [PATCH] Fixed PV rendering colour bug --- toolboxes/Utilities/Paraview/gprMax.py | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/toolboxes/Utilities/Paraview/gprMax.py b/toolboxes/Utilities/Paraview/gprMax.py index 5878be90..3c75aee1 100644 --- a/toolboxes/Utilities/Paraview/gprMax.py +++ b/toolboxes/Utilities/Paraview/gprMax.py @@ -74,7 +74,7 @@ def display_pmls(pmlthick, dx_dy_dz, nx_ny_nz): pml_names = ["x0", "y0", "z0", "xmax", "ymax", "zmax"] pmls = dict.fromkeys(pml_names, None) - SetActiveSource(pv_src) + SetActiveSource(pv_data) if pmlthick[0] != 0: x0 = Box( @@ -159,15 +159,13 @@ def display_pmls(pmlthick, dx_dy_dz, nx_ny_nz): # Get whatever source is loaded - should be loaded file (.vt*) or files (.pvd) -data = GetActiveSource() +pv_data = GetActiveSource() # Hide display of root data -Hide(data) - +Hide(pv_data) # Single .vti or .vtu file -file = data.FileName -dirname = os.path.dirname(file[0]) +file = pv_data.FileName[0] # Read and display data from file, i.e. materials, sources, receivers, and PMLs with open(file, "rb") as f: @@ -187,12 +185,8 @@ with open(file, "rb") as f: ################ pv_view = GetActiveView() pv_view.AxesGrid.Visibility = 1 # Show Data Axes Grid -pv_data = OpenDataFile(file) pv_disp = Show(pv_data, pv_view) -pv_src = GetActiveSource() -Hide(pv_src) -src_name = os.path.split(file) -RenameSource(src_name[1]) +pv_disp.ColorArrayName = ["CELLS", "Material"] # Discretisation dl = c["dx_dy_dz"] @@ -202,7 +196,7 @@ nl = c["nx_ny_nz"] # Materials try: for i, mat in enumerate(c["Materials"]): - threshold = threshold_filt(pv_src, i, i, ["CELLS", "Material"]) + threshold = threshold_filt(pv_data, i, i, ["CELLS", "Material"]) RenameSource(mat, threshold) # Show data in view, except for free_space