@@ -49,9 +49,9 @@ def _grid(self):
4949 origin = (- (surfaces .bounds [1 ] - surfaces .bounds [0 ]) / 2 , - (surfaces .bounds [3 ] - surfaces .bounds [2 ]) / 2 , - (surfaces .bounds [5 ] - surfaces .bounds [4 ]) / 2 ),
5050 )
5151
52- def to_show_cells (self ) -> pyvista .Plotter :
52+ def to_show_cells (self , skip = tuple () ) -> pyvista .Plotter :
5353 """
54- Visualizes INP cells.
54+ Visualizes INP all cells.
5555 """
5656
5757 plot = pyvista .Plotter ()
@@ -61,9 +61,9 @@ def to_show_cells(self) -> pyvista.Plotter:
6161 cells = {}
6262
6363 for cell in self .inpt .cells :
64- if isinstance (cell , inp .Cell ):
64+ if isinstance (cell , inp .Cell ) and cell . number not in skip :
6565 shape = cell .to_show (surfaces , cells )
66- elif isinstance (cell , inp .Like ):
66+ elif isinstance (cell , inp .Like ) and cell . number not in skip :
6767 shape = cells [str (cell .cell )]
6868 else :
6969 continue
@@ -77,16 +77,16 @@ def to_show_cells(self) -> pyvista.Plotter:
7777
7878 return plot
7979
80- def to_show_surfaces (self ) -> pyvista .Plotter :
80+ def to_show_surfaces (self , skip = tuple () ) -> pyvista .Plotter :
8181 """
82- Visualizes INP surfaces.
82+ Visualizes INP all surfaces.
8383 """
8484
8585 plot = pyvista .Plotter ()
8686 plot .add_axes ()
8787
8888 for surface in self .inpt .surfaces :
89- if not isinstance (surface , inp .Surface ):
89+ if not isinstance (surface , inp .Surface ) or surface . number in skip :
9090 continue
9191
9292 shape = surface .to_show ()
@@ -95,12 +95,12 @@ def to_show_surfaces(self) -> pyvista.Plotter:
9595
9696 return plot
9797
98- def to_show_cell (self , number : str ) -> pyvista .Plotter :
98+ def to_show_cell (self , number : tuple [ str ] ) -> pyvista .Plotter :
9999 """
100- Visualizes INP cells .
100+ Visualizes INP cell(s) .
101101
102102 Parameters:
103- number : Cell number to visualize.
103+ numbers : Cell number to visualize.
104104 """
105105
106106 plot = pyvista .Plotter ()
@@ -119,23 +119,19 @@ def to_show_cell(self, number: str) -> pyvista.Plotter:
119119
120120 cells [str (cell .number )] = shape
121121
122- if str (cell .number ) != number :
122+ if str (cell .number ) not in number :
123123 continue
124124
125125 grid = self ._grid
126126 grid ['cell' ] = shape .cell (grid .points ).astype (numpy .float32 )
127127 plot .add_volume (grid , scalars = 'cell' , opacity = [0 , 0 , 0.01 , 0.01 ])
128128 plot .add_mesh (shape .surface , opacity = 0.9 )
129129
130- break
131- else :
132- raise errors .CliError (errors .CliCode .RUNTIME_DOER , number )
133-
134130 return plot
135131
136- def to_show_surface (self , number : str ) -> pyvista .Plotter :
132+ def to_show_surface (self , number : tuple [ str ] ) -> pyvista .Plotter :
137133 """
138- Visualizes INP surfaces .
134+ Visualizes INP surface(s) .
139135
140136 Parameters:
141137 number: Surface number to visualize.
@@ -145,14 +141,13 @@ def to_show_surface(self, number: str) -> pyvista.Plotter:
145141 plot .add_axes ()
146142
147143 for surface in self .inpt .surfaces :
148- if not isinstance (surface , inp .Surface ) or str ( surface . number ) != number :
144+ if not isinstance (surface , inp .Surface ):
149145 continue
150146
151- plot .add_mesh (surface .to_show ().surface )
147+ if str (surface .number ) not in number :
148+ continue
152149
153- break
154- else :
155- raise errors .CliError (errors .CliCode .RUNTIME_DOER , number )
150+ plot .add_mesh (surface .to_show ().surface )
156151
157152 return plot
158153
@@ -181,3 +176,31 @@ def to_pdf_surfaces(self, path: str | pathlib.Path):
181176
182177 if 'PYTEST_CURRENT_TEST' not in os .environ : # pragma: no cover
183178 plot .save_graphic (str (path ))
179+
180+ def to_pdf_cell (self , number : tuple [str ], path : str | pathlib .Path ):
181+ """
182+ Saves render of cells as PDF.
183+
184+ Parameters:
185+ number: Cell numbers to visualize.
186+ path: Path to new pdf file.
187+ """
188+
189+ plot = self .to_show_cell (number )
190+
191+ if 'PYTEST_CURRENT_TEST' not in os .environ : # pragma: no cover
192+ plot .save_graphic (str (path ))
193+
194+ def to_pdf_surface (self , number : tuple [str ], path : str | pathlib .Path ):
195+ """
196+ Saves render of surfaces as PDF.
197+
198+ Parameters:
199+ number: Surface numbers to visualize.
200+ path: Path to new pdf file.
201+ """
202+
203+ plot = self .to_show_surface (number )
204+
205+ if 'PYTEST_CURRENT_TEST' not in os .environ : # pragma: no cover
206+ plot .save_graphic (str (path ))
0 commit comments