From 15f4d28e2d79a535d5e03c6b6248d1f4646dd730 Mon Sep 17 00:00:00 2001 From: MatejTomes Date: Fri, 16 Apr 2021 14:31:02 +0200 Subject: [PATCH 1/3] add the possibility to load only a mesh subset --- cherab/jet/machine/cad_files.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/cherab/jet/machine/cad_files.py b/cherab/jet/machine/cad_files.py index d82e92c..dde6288 100644 --- a/cherab/jet/machine/cad_files.py +++ b/cherab/jet/machine/cad_files.py @@ -672,10 +672,22 @@ VACUUM_VESSEL + DIAGNOSTICS + IL_SC + IL_SC_STRUCTURE + DIVERTOR_TILES + DIVERTOR_STRUCTURE -def import_jet_mesh(world, override_material=None, tungsten_material=None, beryllium_material=None, +def import_jet_mesh(world, mesh_description=JET_MESH, override_material=None, tungsten_material=None, beryllium_material=None, lambert_material=None, verbose=True): - - for mesh_item in JET_MESH: + """ Imports JET machine meshes. + + Args: + :param world: The parent node. + :param mesh_description: Optional, list of tupples of the shape (mesh file path, material). On default equals to the + JET_MESH list. + :param override_material: Optional, overrides materials specified in the mesh_description. + :param tungsten_material: Optional, overrides tungsten materials specified in mesh_description. + :param beryllium_material: Optional, overrides beryllium materials specified in mesh_description. + :param lambert_material: Optional, overrides Lambertian materials specified in mesh_description. + :param verbose: Sets the verbosity, defaults True. + """ + + for mesh_item in mesh_description: mesh_path, default_material = mesh_item From 34d004a621f0127b711580abbebe5f09a07c689a Mon Sep 17 00:00:00 2001 From: MatejTomes Date: Fri, 16 Apr 2021 19:29:31 +0200 Subject: [PATCH 2/3] reorder import_jet_mesh parameters shift the new mesh_description to the end of the parameter list --- cherab/jet/machine/cad_files.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cherab/jet/machine/cad_files.py b/cherab/jet/machine/cad_files.py index dde6288..ef1dd80 100644 --- a/cherab/jet/machine/cad_files.py +++ b/cherab/jet/machine/cad_files.py @@ -672,19 +672,19 @@ VACUUM_VESSEL + DIAGNOSTICS + IL_SC + IL_SC_STRUCTURE + DIVERTOR_TILES + DIVERTOR_STRUCTURE -def import_jet_mesh(world, mesh_description=JET_MESH, override_material=None, tungsten_material=None, beryllium_material=None, - lambert_material=None, verbose=True): +def import_jet_mesh(world, override_material=None, tungsten_material=None, beryllium_material=None, + lambert_material=None, verbose=True, mesh_description=JET_MESH): """ Imports JET machine meshes. Args: :param world: The parent node. - :param mesh_description: Optional, list of tupples of the shape (mesh file path, material). On default equals to the - JET_MESH list. :param override_material: Optional, overrides materials specified in the mesh_description. :param tungsten_material: Optional, overrides tungsten materials specified in mesh_description. :param beryllium_material: Optional, overrides beryllium materials specified in mesh_description. :param lambert_material: Optional, overrides Lambertian materials specified in mesh_description. :param verbose: Sets the verbosity, defaults True. + :param mesh_description: Optional, list of tupples of the shape (mesh file path, material). On default equals to the + JET_MESH list. """ for mesh_item in mesh_description: From 9ec3861e6063697b509ce89f1041d161b4315bec Mon Sep 17 00:00:00 2001 From: MatejTomes Date: Mon, 14 Jun 2021 16:21:56 +0200 Subject: [PATCH 3/3] rename parameter, return loaded component list --- cherab/jet/machine/cad_files.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/cherab/jet/machine/cad_files.py b/cherab/jet/machine/cad_files.py index ef1dd80..4ebea02 100644 --- a/cherab/jet/machine/cad_files.py +++ b/cherab/jet/machine/cad_files.py @@ -673,7 +673,7 @@ def import_jet_mesh(world, override_material=None, tungsten_material=None, beryllium_material=None, - lambert_material=None, verbose=True, mesh_description=JET_MESH): + lambert_material=None, verbose=True, mesh_components=JET_MESH): """ Imports JET machine meshes. Args: @@ -683,11 +683,14 @@ def import_jet_mesh(world, override_material=None, tungsten_material=None, beryl :param beryllium_material: Optional, overrides beryllium materials specified in mesh_description. :param lambert_material: Optional, overrides Lambertian materials specified in mesh_description. :param verbose: Sets the verbosity, defaults True. - :param mesh_description: Optional, list of tupples of the shape (mesh file path, material). On default equals to the + :param mesh_components: Optional, list of tupples of the shape (mesh file path, material). On default equals to the JET_MESH list. + :return: list of loaded mesh primitives. """ + + primitives = [] - for mesh_item in mesh_description: + for mesh_item in mesh_components: mesh_path, default_material = mesh_item @@ -706,7 +709,9 @@ def import_jet_mesh(world, override_material=None, tungsten_material=None, beryl print("importing {} ...".format(os.path.split(mesh_path)[1])) directory, filename = os.path.split(mesh_path) mesh_name, ext = filename.split('.') - Mesh.from_file(mesh_path, parent=world, material=material, name=mesh_name) + primitives.append(Mesh.from_file(mesh_path, parent=world, material=material, name=mesh_name)) + + return primitives ###########################