@@ -19,12 +19,6 @@ class Visualize(_doer.Doer):
1919 inpt: Files to visualize.
2020 """
2121
22- GRID = pyvista .ImageData (
23- dimensions = (_show .pyvista .RESOLUTION , _show .pyvista .RESOLUTION , _show .pyvista .RESOLUTION ),
24- spacing = (_show .pyvista .BOUND / _show .pyvista .RESOLUTION , _show .pyvista .BOUND / _show .pyvista .RESOLUTION , _show .pyvista .BOUND / _show .pyvista .RESOLUTION ),
25- origin = (- _show .pyvista .BOUND / 2 , - _show .pyvista .BOUND / 2 , - _show .pyvista .BOUND / 2 ),
26- )
27-
2822 def __init__ (self , inpt : Inp ):
2923 """
3024 Initializes `Visualize`.
@@ -41,6 +35,20 @@ def __init__(self, inpt: Inp):
4135
4236 self .inpt = inpt
4337
38+ @property
39+ def _grid (self ):
40+ surfaces = self .to_show_surfaces ()
41+
42+ return pyvista .ImageData (
43+ dimensions = (_show .pyvista .RESOLUTION , _show .pyvista .RESOLUTION , _show .pyvista .RESOLUTION ),
44+ spacing = (
45+ (surfaces .bounds [1 ] - surfaces .bounds [0 ]) / _show .pyvista .RESOLUTION ,
46+ (surfaces .bounds [3 ] - surfaces .bounds [2 ]) / _show .pyvista .RESOLUTION ,
47+ (surfaces .bounds [5 ] - surfaces .bounds [4 ]) / _show .pyvista .RESOLUTION ,
48+ ),
49+ origin = (- (surfaces .bounds [1 ] - surfaces .bounds [0 ]) / 2 , - (surfaces .bounds [3 ] - surfaces .bounds [2 ]) / 2 , - (surfaces .bounds [5 ] - surfaces .bounds [4 ]) / 2 ),
50+ )
51+
4452 def to_show_cells (self ) -> pyvista .Plotter :
4553 """
4654 Visualizes INP cells.
@@ -62,8 +70,9 @@ def to_show_cells(self) -> pyvista.Plotter:
6270
6371 cells [str (cell .number )] = shape
6472
65- self .GRID ['cell' ] = shape .cell (self .GRID .points ).astype (numpy .float32 )
66- plot .add_volume (self .GRID , scalars = 'cell' , opacity = [0 , 0 , 0.01 , 0.01 ])
73+ grid = self ._grid
74+ grid ['cell' ] = shape .cell (grid .points ).astype (numpy .float32 )
75+ plot .add_volume (grid , scalars = 'cell' , opacity = [0 , 0 , 0.01 , 0.01 ])
6776 plot .add_mesh (shape .surface , opacity = 0.9 )
6877
6978 return plot
@@ -113,8 +122,9 @@ def to_show_cell(self, number: str) -> pyvista.Plotter:
113122 if str (cell .number ) != number :
114123 continue
115124
116- self .GRID ['cell' ] = shape .cell (self .GRID .points ).astype (numpy .float32 )
117- plot .add_volume (self .GRID , scalars = 'cell' , opacity = [0 , 0 , 0.01 , 0.01 ])
125+ grid = self ._grid
126+ grid ['cell' ] = shape .cell (grid .points ).astype (numpy .float32 )
127+ plot .add_volume (grid , scalars = 'cell' , opacity = [0 , 0 , 0.01 , 0.01 ])
118128 plot .add_mesh (shape .surface , opacity = 0.9 )
119129
120130 break
0 commit comments