@@ -167,12 +167,17 @@ def open_result_in_viewer(
167
167
dpf_instance .OpenFile (file_path )
168
168
dpf_instance .Show (1 )
169
169
170
- def export_xmp_vtp (file_path : Union [str , Path ]) -> Path :
170
+ def export_xmp_vtp (
171
+ simulation_feature : Union [SimulationDirect , SimulationInverse ],
172
+ result_name : Union [str , Path ],
173
+ ) -> Path :
171
174
"""Export an XMP result into vtp file.
172
175
173
176
Parameters
174
177
----------
175
- file_path: Union[str, Path]
178
+ simulation_feature : ansys.speos.core.simulation.Simulation
179
+ The simulation feature.
180
+ result_name: Union[str, Path]
176
181
file path of an XMP result.
177
182
178
183
Returns
@@ -183,8 +188,19 @@ def export_xmp_vtp(file_path: Union[str, Path]) -> Path:
183
188
"""
184
189
import pyvista as pv
185
190
186
- if not str (file_path ).lower ().endswith ("xmp" ):
187
- raise ValueError ("Please specify a .xmp file." )
191
+ result_name = Path (result_name )
192
+ if not str (result_name ).lower ().endswith (".xmp" ):
193
+ result_name = result_name .with_name (result_name .name + ".xmp" )
194
+ file_path = _find_correct_result (simulation_feature , str (result_name ))
195
+
196
+ if file_path == "" :
197
+ raise ValueError (
198
+ "No result corresponding to "
199
+ + str (result_name )
200
+ + " is found in "
201
+ + simulation_feature ._name
202
+ )
203
+
188
204
file_path = Path (file_path )
189
205
dpf_instance = CreateObject ("XMPViewer.Application" )
190
206
dpf_instance .OpenFile (str (file_path ))
@@ -247,14 +263,20 @@ def export_xmp_vtp(file_path: Union[str, Path]) -> Path:
247
263
vtp_meshes .save (str (file_path .with_suffix (".vtp" )))
248
264
return file_path .with_suffix (".vtp" )
249
265
250
- def export_xm3_vtp (geo_faces : List [face_pb2 .Face ], file_path : Union [str , Path ]) -> Path :
266
+ def export_xm3_vtp (
267
+ simulation_feature : Union [SimulationDirect , SimulationInverse ],
268
+ geo_faces : List [face_pb2 .Face ],
269
+ result_name : Union [str , Path ],
270
+ ) -> Path :
251
271
"""Export an XMP result into vtp file.
252
272
253
273
Parameters
254
274
----------
275
+ simulation_feature : ansys.speos.core.simulation.Simulation
276
+ The simulation feature.
255
277
geo_faces: List[face_pb2.Face]
256
278
list of face geometries.
257
- file_path : Union[str, Path]
279
+ result_name : Union[str, Path]
258
280
file path of an XMP result.
259
281
260
282
Returns
@@ -265,8 +287,18 @@ def export_xm3_vtp(geo_faces: List[face_pb2.Face], file_path: Union[str, Path])
265
287
"""
266
288
import pyvista as pv
267
289
268
- if not str (file_path ).lower ().endswith ("xm3" ):
269
- raise ValueError ("Please specify a .xm3 file." )
290
+ result_name = Path (result_name )
291
+ if not str (result_name ).lower ().endswith (".xm3" ):
292
+ result_name = result_name .with_name (result_name .name + ".xm3" )
293
+ file_path = _find_correct_result (simulation_feature , str (result_name ))
294
+
295
+ if file_path == "" :
296
+ raise ValueError (
297
+ "No result corresponding to "
298
+ + str (result_name )
299
+ + " is found in "
300
+ + simulation_feature ._name
301
+ )
270
302
271
303
file_path = Path (file_path )
272
304
dpf_instance = CreateObject ("Xm3Viewer.Application" )
@@ -278,6 +310,22 @@ def export_xm3_vtp(geo_faces: List[face_pb2.Face], file_path: Union[str, Path])
278
310
xm3_data = []
279
311
content = file .readlines ()
280
312
header = content [0 ].strip ().split ("\t " )
313
+ illuminance_indices = [
314
+ i for i , header_item in enumerate (header ) if header_item == "Illuminance"
315
+ ]
316
+ irradiance_indices = [
317
+ i for i , header_item in enumerate (header ) if header_item == "Irradiance"
318
+ ]
319
+ reflection_indices = [
320
+ i for i , header_item in enumerate (header ) if "Reflection" in header_item
321
+ ]
322
+ transmission_indices = [
323
+ i for i , header_item in enumerate (header ) if "Transmission" in header_item
324
+ ]
325
+ absorption_indices = [
326
+ i for i , header_item in enumerate (header ) if "Absorption" in header_item
327
+ ]
328
+
281
329
skip_line = 1
282
330
try :
283
331
float (float (content [1 ].strip ().split ()[0 ]))
@@ -286,21 +334,6 @@ def export_xm3_vtp(geo_faces: List[face_pb2.Face], file_path: Union[str, Path])
286
334
skip_line = 2 # separated layer
287
335
for line in content [skip_line :]:
288
336
line_content = line .strip ().split ("\t " )
289
- illuminance_indices = [
290
- i for i , header_item in enumerate (header ) if header_item == "Illuminance"
291
- ]
292
- irradiance_indices = [
293
- i for i , header_item in enumerate (header ) if header_item == "Irradiance"
294
- ]
295
- reflection_indices = [
296
- i for i , header_item in enumerate (header ) if "Reflection" in header_item
297
- ]
298
- transmission_indices = [
299
- i for i , header_item in enumerate (header ) if "Transmission" in header_item
300
- ]
301
- absorption_indices = [
302
- i for i , header_item in enumerate (header ) if "Absorption" in header_item
303
- ]
304
337
xm3_data .append (
305
338
_Speos3dData (
306
339
x = float (line_content [0 ]),
0 commit comments