From 0490daf96cf644923b984ff8596c51db16f8d394 Mon Sep 17 00:00:00 2001 From: f-brinkmann Date: Wed, 23 Sep 2020 14:02:30 +0200 Subject: [PATCH] Fixed Ticket #23: If using multiple evaluations grids, they are now written to NC.inp in alphabetical order fbrinkmann 2020-05-05 --- Mesh2Input/EvaluationGrids/Custom/readme.txt | 2 +- Mesh2Input/exportMesh2HRTF.py | 35 +++++++++----------- 2 files changed, 16 insertions(+), 21 deletions(-) diff --git a/Mesh2Input/EvaluationGrids/Custom/readme.txt b/Mesh2Input/EvaluationGrids/Custom/readme.txt index 8b2a31a8..4b6365af 100644 --- a/Mesh2Input/EvaluationGrids/Custom/readme.txt +++ b/Mesh2Input/EvaluationGrids/Custom/readme.txt @@ -1,4 +1,4 @@ This is the place for user generated evaluation grids. They can for example be generated with the Matlab tools under -PreProcessing/WriteReadEvaluationGrid/demo.m \ No newline at end of file +PreProcessing/EvaluationGrid(Matlab)/demo.m \ No newline at end of file diff --git a/Mesh2Input/exportMesh2HRTF.py b/Mesh2Input/exportMesh2HRTF.py index df7c4980..599a77ce 100644 --- a/Mesh2Input/exportMesh2HRTF.py +++ b/Mesh2Input/exportMesh2HRTF.py @@ -1006,16 +1006,23 @@ def calculateReceiverProperties(obj, obj_data, unitFactor): if nearFieldCalculation: fw("../../EvaluationGrids/NF_Sphere/Nodes.txt\n") else: + # alphabetically sorted list of used evaluation grids + evaluationGrids = [] if not evaluationGrid1 == 'None': - fw("../../EvaluationGrids/%s/Nodes.txt\n" % evaluationGrid1) + evaluationGrids.append(evaluationGrid1) if not evaluationGrid2 == 'None': - fw("../../EvaluationGrids/%s/Nodes.txt\n" % evaluationGrid2) + evaluationGrids.append(evaluationGrid2) if not evaluationGrid3 == 'None': - fw("../../EvaluationGrids/%s/Nodes.txt\n" % evaluationGrid3) + evaluationGrids.append(evaluationGrid3) if not evaluationGrid4 == 'None': - fw("../../EvaluationGrids/%s/Nodes.txt\n" % evaluationGrid4) + evaluationGrids.append(evaluationGrid4) if not evaluationGrid5 == 'None': - fw("../../EvaluationGrids/%s/Nodes.txt\n" % evaluationGrid5) + evaluationGrids.append(evaluationGrid5) + evaluationGrids.sort() + + # write file path of nodes to input file + for grid in evaluationGrids: + fw("../../EvaluationGrids/%s/Nodes.txt\n" % grid) fw("##\n") fw("ELEMENTS\n") if not frequencyDependency: @@ -1025,16 +1032,9 @@ def calculateReceiverProperties(obj, obj_data, unitFactor): if nearFieldCalculation: fw("../../EvaluationGrids/NF_Sphere/Elements.txt\n") else: - if not evaluationGrid1 == 'None': - fw("../../EvaluationGrids/%s/Elements.txt\n" % evaluationGrid1) - if not evaluationGrid2 == 'None': - fw("../../EvaluationGrids/%s/Elements.txt\n" % evaluationGrid2) - if not evaluationGrid3 == 'None': - fw("../../EvaluationGrids/%s/Elements.txt\n" % evaluationGrid3) - if not evaluationGrid4 == 'None': - fw("../../EvaluationGrids/%s/Elements.txt\n" % evaluationGrid4) - if not evaluationGrid5 == 'None': - fw("../../EvaluationGrids/%s/Elements.txt\n" % evaluationGrid5) + # write file path of elements to input file + for grid in evaluationGrids: + fw("../../EvaluationGrids/%s/Elements.txt\n" % grid) fw("##\n") fw("# SYMMETRY\n") fw("# 0 0 0\n") @@ -1046,11 +1046,6 @@ def calculateReceiverProperties(obj, obj_data, unitFactor): else: tmpEar='Right ear' - #changed tmpEar to ear - #if ear=='Right ear': - # tmpEar='Right ear' - #if ear=='Left ear': - # tmpEar='Left ear' fw("BOUNDARY\n") for ii in range(len(obj_data.polygons[:])): if obj.material_slots[obj_data.polygons[ii].material_index].name == obj.material_slots[tmpEar].name: