1
1
#!/usr/bin/env python
2
2
3
3
from collections import defaultdict
4
+ from shutil import rmtree
5
+ from rich .prompt import Confirm
4
6
5
7
from dds import *
6
8
@@ -124,20 +126,22 @@ def parse_Evocube_output(dataset_id: int, tet_folder: DataFolder):
124
126
125
127
# if there is a hex-mesh in the labeling folder, instantiate it and retrieve mesh stats
126
128
hexmesh_minSJ = None
127
- if (labeling_folder .path / 'polycube_withHexEx_1.3/global_padding/inner_smoothing_50' ).exists ():
128
- hex_mesh_folder : DataFolder = DataFolder (labeling_folder .path / 'polycube_withHexEx_1.3/global_padding/inner_smoothing_50' )
129
+ post_processed_hex_mesh_path = labeling_folder .path / 'polycube_withHexEx_1.3' / 'global_padding' / 'inner_smoothing_50'
130
+ if post_processed_hex_mesh_path .exists ():
131
+ hex_mesh_folder : DataFolder = DataFolder (post_processed_hex_mesh_path )
129
132
hex_mesh_stats : dict = hex_mesh_folder .get_mesh_stats_dict () # type: ignore | see ../data_folder_types/hex-mesh.accessors.py
130
133
if 'quality' in hex_mesh_stats ['cells' ]:
131
134
avg_sj_sum [dataset_id ,EVOCUBE ] += hex_mesh_stats ['cells' ]['quality' ]['hex_SJ' ]['avg' ]
132
135
hexmesh_minSJ = hex_mesh_stats ['cells' ]['quality' ]['hex_SJ' ]['min' ]
133
136
min_sj_sum [dataset_id ,EVOCUBE ] += hexmesh_minSJ
134
- else :
135
- # HexEx failed, no cells in output file
136
- avg_sj_sum [dataset_id ,EVOCUBE ] += - 1.0 # assume worse value
137
- min_sj_sum [dataset_id ,EVOCUBE ] += - 1.0 # assume worse value
138
137
139
138
# update the counters
140
139
if not labeling_folder .has_valid_labeling (): # type: ignore | see ../data_folder_types/labeling.accessors.py
140
+ if (labeling_folder .path / 'polycube_withHexEx_1.3' ).exists ():
141
+ if Confirm (f"There is a 'polycube_withHexEx' output inside { labeling_folder .path } , but the labeling is invalid. Remove this hex-mesh folder?" ):
142
+ rmtree (labeling_folder .path / 'polycube_withHexEx_1.3' )
143
+ assert (not post_processed_hex_mesh_path .exists ())
144
+ assert (hexmesh_minSJ is None )
141
145
fluxes [dataset_id ,EVOCUBE ,TET_MESHING_SUCCESS ,LABELING_INVALID ] += 1
142
146
elif labeling_folder .nb_turning_points () != 0 : # type: ignore | see ../data_folder_types/labeling.accessors.py
143
147
fluxes [dataset_id ,EVOCUBE ,TET_MESHING_SUCCESS ,LABELING_NON_MONOTONE ] += 1
@@ -150,6 +154,9 @@ def parse_Evocube_output(dataset_id: int, tet_folder: DataFolder):
150
154
else :
151
155
# no hex-mesh
152
156
fluxes [dataset_id ,EVOCUBE ,LABELING_NON_MONOTONE ,HEX_MESHING_FAILURE ] += 1
157
+ # also penalize minSJ & avgSJ sums
158
+ avg_sj_sum [dataset_id ,EVOCUBE ] += - 1.0 # assume worse value
159
+ min_sj_sum [dataset_id ,EVOCUBE ] += - 1.0 # assume worse value
153
160
else :
154
161
fluxes [dataset_id ,EVOCUBE ,TET_MESHING_SUCCESS ,LABELING_SUCCESS ] += 1
155
162
if hexmesh_minSJ is not None :
@@ -161,6 +168,9 @@ def parse_Evocube_output(dataset_id: int, tet_folder: DataFolder):
161
168
else :
162
169
# no hex-mesh
163
170
fluxes [dataset_id ,EVOCUBE ,LABELING_SUCCESS ,HEX_MESHING_FAILURE ] += 1
171
+ # also penalize minSJ & avgSJ sums
172
+ avg_sj_sum [dataset_id ,EVOCUBE ] += - 1.0 # assume worse value
173
+ min_sj_sum [dataset_id ,EVOCUBE ] += - 1.0 # assume worse value
164
174
165
175
def parse_Ours_2024_03_output (dataset_id : int , tet_folder : DataFolder ):
166
176
labeling_subfolders_generated_by_ours : list [Path ] = tet_folder .get_subfolders_generated_by ('automatic_polycube' )
@@ -195,6 +205,9 @@ def parse_Ours_2024_03_output(dataset_id: int, tet_folder: DataFolder):
195
205
196
206
# update the counters
197
207
if not labeling_folder .has_valid_labeling (): # type: ignore | see ../data_folder_types/labeling.accessors.py
208
+ if (labeling_folder .path / 'polycube_withHexEx_1.3' ).exists ():
209
+ if Confirm (f"There is a 'polycube_withHexEx' output inside { labeling_folder .path } , but the labeling is invalid. Remove this hex-mesh folder?" ):
210
+ rmtree (labeling_folder .path / 'polycube_withHexEx_1.3' )
198
211
fluxes [dataset_id ,OURS_2024_03 ,TET_MESHING_SUCCESS ,LABELING_INVALID ] += 1
199
212
elif labeling_folder .nb_turning_points () != 0 : # type: ignore | see ../data_folder_types/labeling.accessors.py
200
213
fluxes [dataset_id ,OURS_2024_03 ,TET_MESHING_SUCCESS ,LABELING_NON_MONOTONE ] += 1
@@ -274,20 +287,22 @@ def parse_Ours_2024_09(dataset_id: int, tet_mesh: DataFolder): # with parsing of
274
287
275
288
# if there is a hex-mesh in the labeling folder, instantiate it and retrieve mesh stats
276
289
hexmesh_minSJ = None
277
- if (labeling_ours_folder .path / 'polycube_withHexEx_1.3/global_padding/inner_smoothing_50' ).exists ():
278
- hex_mesh_folder : DataFolder = DataFolder (labeling_ours_folder .path / 'polycube_withHexEx_1.3/global_padding/inner_smoothing_50' )
290
+ post_processed_hex_mesh_path = labeling_ours_folder .path / 'polycube_withHexEx_1.3' / 'global_padding' / 'inner_smoothing_50'
291
+ if post_processed_hex_mesh_path .exists ():
292
+ hex_mesh_folder : DataFolder = DataFolder (post_processed_hex_mesh_path )
279
293
hex_mesh_stats : dict = hex_mesh_folder .get_mesh_stats_dict () # type: ignore | see ../data_folder_types/hex-mesh.accessors.py
280
294
if 'quality' in hex_mesh_stats ['cells' ]:
281
295
avg_sj_sum [dataset_id ,OURS_2024_09 ] += hex_mesh_stats ['cells' ]['quality' ]['hex_SJ' ]['avg' ]
282
296
hexmesh_minSJ = hex_mesh_stats ['cells' ]['quality' ]['hex_SJ' ]['min' ]
283
297
min_sj_sum [dataset_id ,OURS_2024_09 ] += hexmesh_minSJ
284
- else :
285
- # HexEx failed, no cells in output file
286
- avg_sj_sum [dataset_id ,OURS_2024_09 ] += - 1.0 # assume worse value
287
- min_sj_sum [dataset_id ,OURS_2024_09 ] += - 1.0 # assume worse value
288
298
289
299
# update the counters
290
300
if not labeling_ours_folder .has_valid_labeling (): # type: ignore | see ../data_folder_types/labeling.accessors.py
301
+ if (labeling_ours_folder .path / 'polycube_withHexEx_1.3' ).exists ():
302
+ if Confirm (f"There is a 'polycube_withHexEx' output inside { labeling_ours_folder .path } , but the labeling is invalid. Remove this hex-mesh folder?" ):
303
+ rmtree (labeling_ours_folder .path / 'polycube_withHexEx_1.3' )
304
+ assert (not post_processed_hex_mesh_path .exists ())
305
+ assert (hexmesh_minSJ is None )
291
306
fluxes [dataset_id ,OURS_2024_09 ,INIT_LABELING_SUCCESS ,LABELING_INVALID ] += 1
292
307
elif labeling_ours_folder .nb_turning_points () != 0 : # type: ignore | see ../data_folder_types/labeling.accessors.py
293
308
fluxes [dataset_id ,OURS_2024_09 ,INIT_LABELING_SUCCESS ,LABELING_NON_MONOTONE ] += 1
@@ -300,6 +315,9 @@ def parse_Ours_2024_09(dataset_id: int, tet_mesh: DataFolder): # with parsing of
300
315
else :
301
316
# no hex-mesh
302
317
fluxes [dataset_id ,OURS_2024_09 ,LABELING_NON_MONOTONE ,HEX_MESHING_FAILURE ] += 1
318
+ # also penalize minSJ & avgSJ sums
319
+ avg_sj_sum [dataset_id ,OURS_2024_09 ] += - 1.0 # assume worse value
320
+ min_sj_sum [dataset_id ,OURS_2024_09 ] += - 1.0 # assume worse value
303
321
else :
304
322
# so we have a valid labeling with no turning-points
305
323
fluxes [dataset_id ,OURS_2024_09 ,INIT_LABELING_SUCCESS ,LABELING_SUCCESS ] += 1
@@ -312,6 +330,9 @@ def parse_Ours_2024_09(dataset_id: int, tet_mesh: DataFolder): # with parsing of
312
330
else :
313
331
# no hex-mesh
314
332
fluxes [dataset_id ,OURS_2024_09 ,LABELING_SUCCESS ,HEX_MESHING_FAILURE ] += 1
333
+ # also penalize minSJ & avgSJ sums
334
+ avg_sj_sum [dataset_id ,OURS_2024_09 ] += - 1.0 # assume worse value
335
+ min_sj_sum [dataset_id ,OURS_2024_09 ] += - 1.0 # assume worse value
315
336
316
337
def parse_PolyCut_output (dataset_id : int , tet_folder : DataFolder ):
317
338
if not (tet_folder .path / 'PolyCut_3' ).exists () or not (tet_folder .path / 'PolyCut_3' / surface_labeling_filename ).exists ():
@@ -337,9 +358,12 @@ def parse_PolyCut_output(dataset_id: int, tet_folder: DataFolder):
337
358
# update duration sum
338
359
labeling_duration [dataset_id ,POLYCUT ] += polycut_durations ['polycut' ] # should we take into account the duration of cusy2.exe, which is the executable writing the labeling?
339
360
340
- # if there is a hex-mesh in the labeling folder, instantiate it and retrieve mesh stats
341
361
hexmesh_minSJ = None
342
- if (labeling_folder .path / 'optimizer_100' / 'untangler' / hex_mesh_filename ).exists ():
362
+ if not labeling_folder .has_valid_labeling (): # type: ignore | see ../data_folder_types/labeling.accessors.py
363
+ # ignore the potential hex-mesh. Same policy as Evocube & Ours : invalid labeling -> no hex-mesh generation
364
+ pass
365
+ # if there is a hex-mesh in the labeling folder, instantiate it and retrieve mesh stats
366
+ elif (labeling_folder .path / 'optimizer_100' / 'untangler' / hex_mesh_filename ).exists ():
343
367
hex_mesh_folder : DataFolder = DataFolder (labeling_folder .path / 'optimizer_100' / 'untangler' )
344
368
hex_mesh_stats : dict = dict ()
345
369
try :
@@ -379,6 +403,7 @@ def parse_PolyCut_output(dataset_id: int, tet_folder: DataFolder):
379
403
380
404
# update the counters
381
405
if not labeling_folder .has_valid_labeling (): # type: ignore | see ../data_folder_types/labeling.accessors.py
406
+ assert (hexmesh_minSJ is None )
382
407
fluxes [dataset_id ,POLYCUT ,COARSER_TET_MESHING_SUCCESS ,LABELING_INVALID ] += 1
383
408
elif labeling_folder .nb_turning_points () != 0 : # type: ignore | see ../data_folder_types/labeling.accessors.py
384
409
fluxes [dataset_id ,POLYCUT ,COARSER_TET_MESHING_SUCCESS ,LABELING_NON_MONOTONE ] += 1
0 commit comments