-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgenerate_stats_table.py
651 lines (577 loc) · 44.8 KB
/
generate_stats_table.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
#!/usr/bin/env python
from collections import defaultdict
from shutil import rmtree
from rich.prompt import Confirm
from dds import *
def main(input_folder: Path, arguments: list):
# check `arguments`
if len(arguments) != 0:
logging.fatal(f'generate_stats_table does not need other arguments than the input folder, but {arguments} were provided')
exit(1)
fluxes: defaultdict = defaultdict(int) # if a given key is missing, use default value of int() == 0
# Datasets & subsets
MAMBO_BASIC = 0
MAMBO_SIMPLE = 1
MAMBO_MEDIUM = 2
OCTREE_MESHING_CAD = 3
def MAMBO_letter_to_subset(first_letter: str) -> tuple[str,int]:
if first_letter == 'B':
return 'Basic',MAMBO_BASIC
if first_letter == 'S':
return 'Simple',MAMBO_SIMPLE
if first_letter == 'M':
return 'Medium',MAMBO_MEDIUM
log.fatal(f"Invalid MAMBO letter : '{first_letter}' is not B, S nor M.")
exit(1)
# Labeling methods
N_A = -1 # Non Applicable
EVOCUBE = 0
OURS_2024_03 = 1
GRAPHCUT = 2
OURS_2024_09 = 3
POLYCUT = 4
SHOW_GRAPHCUT_STATS = True
SHOW_POLYCUT_STATS = True
SHOW_EVOCUBE_STATS = True
SHOW_OURS_2024_03_STATS = False
SHOW_OURS_2024_09_STATS = True
# Nodes = flux sources and destinations
VOID = 0
CAD = 1
TET_MESHING_SUCCESS = 2
TET_MESHING_FAILURE = 3
COARSER_TET_MESHING_SUCCESS = 4 # coarser tet-mesh for PolyCut
COARSER_TET_MESHING_FAILURE = 5 # coarser tet-mesh for PolyCut
LABELING_SUCCESS = 6 # both valid & monotone
LABELING_NON_MONOTONE = 7 # implied valid, but with turning-points
LABELING_INVALID = 8 # with turning-points or not
LABELING_FAILURE = 9
INIT_LABELING_SUCCESS = 10 # intermediate step for OURS_2024_09
HEX_MESHING_POSITIVE_MIN_SJ = 11
HEX_MESHING_NEGATIVE_MIN_SJ = 12
HEX_MESHING_FAILURE = 13
# sum of average fidelities
sum_avg_fidelities: defaultdict[tuple[int,int],float] = defaultdict(float) # if a given key is missing, use default value of float() == 0.0
# To have the global average, divide by the number of generated labelings,
# that is the number of invalid + number of valid but non-monotone boundaries + number of succeeded
# feature-edges preservation
nb_feature_edges_sharp_and_preserved: dict[tuple[int,int],int] = defaultdict(int) # if a given key is missing, use default value of int() == 0
nb_feature_edges_sharp_and_lost: dict[tuple[int,int],int] = defaultdict(int) # if a given key is missing, use default value of int() == 0
nb_feature_edges_ignored: dict[tuple[int,int],int] = defaultdict(int) # if a given key is missing, use default value of int() == 0
# labeling generation durations
labeling_duration: dict[tuple[int,int],float] = defaultdict(float) # if a given key is missing, use default value of float() == 0.0
# per dataset and labeling method sum of all minimum Scaled Jacobian
min_sj_sum: dict[tuple[int,int],float] = defaultdict(float) # if a given key is missing, use default value of float() == 0.0
# To have the global average, divide by the number of tried hex-mesh computations,
# that is the number of valid but non-monotone boundaries + number of succeeded
# per dataset and labeling method sum of all average Scaled Jacobian
avg_sj_sum: dict[tuple[int,int],float] = defaultdict(float) # if a given key is missing, use default value of float() == 0.0
# To have the global average, divide by the number of tried hex-mesh computations,
# that is the number of valid but non-monotone boundaries + number of succeeded
# parse the current data folder,
# count tet meshes, failed/invalid/valid labelings, as well as hex-meshes
STEP_filename,_ = translate_filename_keyword('STEP')
surface_mesh_filename,_ = translate_filename_keyword('SURFACE_MESH_OBJ')
surface_labeling_filename,_ = translate_filename_keyword('SURFACE_LABELING_TXT')
tet_mesh_filename,_ = translate_filename_keyword('TET_MESH_MEDIT')
hex_mesh_filename,_ = translate_filename_keyword('HEX_MESH_MEDIT')
def parse_Evocube_output(dataset_id: int, tet_folder: DataFolder):
labeling_subfolders_generated_by_evocube: list[Path] = tet_folder.get_subfolders_generated_by('evocube')
assert(len(labeling_subfolders_generated_by_evocube) <= 1)
if ( (len(labeling_subfolders_generated_by_evocube) == 0) or \
not (labeling_subfolders_generated_by_evocube[0] / surface_labeling_filename).exists() ):
# there is a tet mesh but no labeling was written
fluxes[dataset_id,EVOCUBE,TET_MESHING_SUCCESS,LABELING_FAILURE] += 1
else:
# instantiate the labeling folder
labeling_folder: DataFolder = DataFolder(labeling_subfolders_generated_by_evocube[0])
assert(labeling_folder.type == 'labeling')
# retrieve datetime, labeling stats and feature edges info
ISO_datetime = labeling_folder.get_datetime_key_of_algo_in_info_file('evocube')
assert(ISO_datetime is not None)
labeling_info_dict = labeling_folder.get_info_dict()
assert(labeling_info_dict is not None)
Evocube_duration = labeling_info_dict[ISO_datetime]['duration'][0]
labeling_stats = labeling_folder.get_labeling_stats_dict() # type: ignore | see ../data_folder_types/labeling.accessors.py
# update avg fidelity sum
sum_avg_fidelities[dataset_id,EVOCUBE] += labeling_stats['fidelity']['avg']
# update feature-edges count
nb_feature_edges_sharp_and_preserved[dataset_id,EVOCUBE] += labeling_stats['feature-edges']['preserved']
nb_feature_edges_sharp_and_lost[dataset_id,EVOCUBE] += labeling_stats['feature-edges']['lost']
nb_feature_edges_ignored[dataset_id,EVOCUBE] += labeling_stats['feature-edges']['removed']
# update duration sum
labeling_duration[dataset_id,EVOCUBE] += Evocube_duration
# if there is a hex-mesh in the labeling folder, instantiate it and retrieve mesh stats
hexmesh_minSJ = None
post_processed_hex_mesh_path = labeling_folder.path / 'polycube_withHexEx_1.3' / 'global_padding' / 'inner_smoothing_50'
if post_processed_hex_mesh_path.exists():
hex_mesh_folder: DataFolder = DataFolder(post_processed_hex_mesh_path)
hex_mesh_stats: dict = hex_mesh_folder.get_mesh_stats_dict() # type: ignore | see ../data_folder_types/hex-mesh.accessors.py
if 'quality' in hex_mesh_stats['cells']:
avg_sj_sum[dataset_id,EVOCUBE] += hex_mesh_stats['cells']['quality']['hex_SJ']['avg']
hexmesh_minSJ = hex_mesh_stats['cells']['quality']['hex_SJ']['min']
min_sj_sum[dataset_id,EVOCUBE] += hexmesh_minSJ
# update the counters
if not labeling_folder.has_valid_labeling(): # type: ignore | see ../data_folder_types/labeling.accessors.py
if (labeling_folder.path / 'polycube_withHexEx_1.3').exists():
if Confirm(f"There is a 'polycube_withHexEx' output inside {labeling_folder.path}, but the labeling is invalid. Remove this hex-mesh folder?"):
rmtree(labeling_folder.path / 'polycube_withHexEx_1.3')
assert(not post_processed_hex_mesh_path.exists())
assert(hexmesh_minSJ is None)
fluxes[dataset_id,EVOCUBE,TET_MESHING_SUCCESS,LABELING_INVALID] += 1
elif labeling_folder.nb_turning_points() != 0: # type: ignore | see ../data_folder_types/labeling.accessors.py
fluxes[dataset_id,EVOCUBE,TET_MESHING_SUCCESS,LABELING_NON_MONOTONE] += 1
if hexmesh_minSJ is not None:
# a hex-mesh was successfully generated
if hexmesh_minSJ < 0.0:
fluxes[dataset_id,EVOCUBE,LABELING_NON_MONOTONE,HEX_MESHING_NEGATIVE_MIN_SJ] += 1
else:
fluxes[dataset_id,EVOCUBE,LABELING_NON_MONOTONE,HEX_MESHING_POSITIVE_MIN_SJ] += 1
else:
# no hex-mesh
fluxes[dataset_id,EVOCUBE,LABELING_NON_MONOTONE,HEX_MESHING_FAILURE] += 1
# also penalize minSJ & avgSJ sums
avg_sj_sum[dataset_id,EVOCUBE] += -1.0 # assume worse value
min_sj_sum[dataset_id,EVOCUBE] += -1.0 # assume worse value
else:
fluxes[dataset_id,EVOCUBE,TET_MESHING_SUCCESS,LABELING_SUCCESS] += 1
if hexmesh_minSJ is not None:
# a hex-mesh was successfully generated
if hexmesh_minSJ < 0.0:
fluxes[dataset_id,EVOCUBE,LABELING_SUCCESS,HEX_MESHING_NEGATIVE_MIN_SJ] += 1
else:
fluxes[dataset_id,EVOCUBE,LABELING_SUCCESS,HEX_MESHING_POSITIVE_MIN_SJ] += 1
else:
# no hex-mesh
fluxes[dataset_id,EVOCUBE,LABELING_SUCCESS,HEX_MESHING_FAILURE] += 1
# also penalize minSJ & avgSJ sums
avg_sj_sum[dataset_id,EVOCUBE] += -1.0 # assume worse value
min_sj_sum[dataset_id,EVOCUBE] += -1.0 # assume worse value
def parse_Ours_2024_03_output(dataset_id: int, tet_folder: DataFolder):
labeling_subfolders_generated_by_ours: list[Path] = tet_folder.get_subfolders_generated_by('automatic_polycube')
assert(len(labeling_subfolders_generated_by_ours) <= 1)
if ( (len(labeling_subfolders_generated_by_ours) == 0) or \
not (labeling_subfolders_generated_by_ours[0] / surface_labeling_filename).exists() ):
# there is a tet mesh but no labeling was written
fluxes[dataset_id,OURS_2024_03,TET_MESHING_SUCCESS,LABELING_FAILURE] += 1
else:
# instantiate the labeling folder
labeling_folder: DataFolder = DataFolder(labeling_subfolders_generated_by_ours[0])
assert(labeling_folder.type == 'labeling')
# retrieve datetime, labeling stats and feature edges info
ISO_datetime = labeling_folder.get_datetime_key_of_algo_in_info_file('automatic_polycube')
assert(ISO_datetime is not None)
labeling_info_dict = labeling_folder.get_info_dict()
assert(labeling_info_dict is not None)
ours_duration = labeling_info_dict[ISO_datetime]['duration'][0]
labeling_stats = labeling_folder.get_labeling_stats_dict() # type: ignore | see ../data_folder_types/labeling.accessors.py
# update avg fidelity sum
sum_avg_fidelities[dataset_id,OURS_2024_03] += labeling_stats['fidelity']['avg']
# update feature-edges count
nb_feature_edges_sharp_and_preserved[dataset_id,OURS_2024_03] += labeling_stats['feature-edges']['preserved']
nb_feature_edges_sharp_and_lost[dataset_id,OURS_2024_03] += labeling_stats['feature-edges']['lost']
nb_feature_edges_ignored[dataset_id,OURS_2024_03] += labeling_stats['feature-edges']['removed']
# update duration sum
labeling_duration[dataset_id,OURS_2024_03] += ours_duration
# update the counters
if not labeling_folder.has_valid_labeling(): # type: ignore | see ../data_folder_types/labeling.accessors.py
if (labeling_folder.path / 'polycube_withHexEx_1.3').exists():
if Confirm(f"There is a 'polycube_withHexEx' output inside {labeling_folder.path}, but the labeling is invalid. Remove this hex-mesh folder?"):
rmtree(labeling_folder.path / 'polycube_withHexEx_1.3')
fluxes[dataset_id,OURS_2024_03,TET_MESHING_SUCCESS,LABELING_INVALID] += 1
elif labeling_folder.nb_turning_points() != 0: # type: ignore | see ../data_folder_types/labeling.accessors.py
fluxes[dataset_id,OURS_2024_03,TET_MESHING_SUCCESS,LABELING_NON_MONOTONE] += 1
else:
# so we have a valid labeling with no turning-points
fluxes[dataset_id,OURS_2024_03,TET_MESHING_SUCCESS,LABELING_SUCCESS] += 1
def parse_Ours_2024_09(dataset_id: int, tet_mesh: DataFolder): # with parsing of the init labeling (graphcut)
labeling_subfolders_generated_by_graphcut: list[Path] = tet_folder.get_subfolders_generated_by('graphcut_labeling')
assert(len(labeling_subfolders_generated_by_graphcut) <= 1)
if ( (len(labeling_subfolders_generated_by_graphcut) == 0) or \
not (labeling_subfolders_generated_by_graphcut[0] / surface_labeling_filename).exists() ):
# there is a tet mesh but no labeling was written
fluxes[dataset_id,GRAPHCUT,TET_MESHING_SUCCESS,LABELING_FAILURE] += 1
else:
# instantiate the labeling folder
init_labeling_folder: DataFolder = DataFolder(labeling_subfolders_generated_by_graphcut[0])
assert(init_labeling_folder.type == 'labeling')
# retrieve datetime, labeling stats and feature edges info
ISO_datetime = init_labeling_folder.get_datetime_key_of_algo_in_info_file('graphcut_labeling')
assert(ISO_datetime is not None)
init_labeling_info_dict = init_labeling_folder.get_info_dict()
assert(init_labeling_info_dict is not None)
graphcut_duration = init_labeling_info_dict[ISO_datetime]['duration'][0]
labeling_stats = init_labeling_folder.get_labeling_stats_dict() # type: ignore | see ../data_folder_types/labeling.accessors.py
# update avg fidelity sum
sum_avg_fidelities[dataset_id,GRAPHCUT] += labeling_stats['fidelity']['avg']
# update feature-edges count
nb_feature_edges_sharp_and_preserved[dataset_id,GRAPHCUT] += labeling_stats['feature-edges']['preserved']
nb_feature_edges_sharp_and_lost[dataset_id,GRAPHCUT] += labeling_stats['feature-edges']['lost']
nb_feature_edges_ignored[dataset_id,GRAPHCUT] += labeling_stats['feature-edges']['removed']
# update duration sum
labeling_duration[dataset_id,GRAPHCUT] += graphcut_duration
# update the counters
if not init_labeling_folder.has_valid_labeling(): # type: ignore | see ../data_folder_types/labeling.accessors.py
fluxes[dataset_id,GRAPHCUT,TET_MESHING_SUCCESS,LABELING_INVALID] += 1
elif init_labeling_folder.nb_turning_points() != 0: # type: ignore | see ../data_folder_types/labeling.accessors.py
fluxes[dataset_id,GRAPHCUT,TET_MESHING_SUCCESS,LABELING_NON_MONOTONE] += 1
else:
# so we have a valid labeling with no turning-points
fluxes[dataset_id,GRAPHCUT,TET_MESHING_SUCCESS,LABELING_SUCCESS] += 1
labeling_subfolders_generated_by_ours: list[Path] = init_labeling_folder.get_subfolders_generated_by('automatic_polycube')
assert(len(labeling_subfolders_generated_by_ours) <= 1)
if ( (len(labeling_subfolders_generated_by_ours) == 0) or \
not (labeling_subfolders_generated_by_ours[0] / surface_labeling_filename).exists() ):
# there is an init labeling but automatic_polycube failed to write a labeling
fluxes[dataset_id,OURS_2024_09,INIT_LABELING_SUCCESS,LABELING_FAILURE] += 1
else:
# instantiate the labeling folder
labeling_ours_folder: DataFolder = DataFolder(labeling_subfolders_generated_by_ours[0])
assert(labeling_ours_folder.type == 'labeling')
# retrieve datetime, labeling stats and feature edges info
ISO_datetime = labeling_ours_folder.get_datetime_key_of_algo_in_info_file('automatic_polycube')
assert(ISO_datetime is not None)
ours_labeling_info_dict = labeling_ours_folder.get_info_dict()
assert(ours_labeling_info_dict is not None)
ours_duration = ours_labeling_info_dict[ISO_datetime]['duration'][0]
labeling_stats = labeling_ours_folder.get_labeling_stats_dict() # type: ignore | see ../data_folder_types/labeling.accessors.py
# update avg fidelity sum
sum_avg_fidelities[dataset_id,OURS_2024_09] += labeling_stats['fidelity']['avg']
# update feature-edges count
nb_feature_edges_sharp_and_preserved[dataset_id,OURS_2024_09] += labeling_stats['feature-edges']['preserved']
nb_feature_edges_sharp_and_lost[dataset_id,OURS_2024_09] += labeling_stats['feature-edges']['lost']
nb_feature_edges_ignored[dataset_id,OURS_2024_09] += labeling_stats['feature-edges']['removed']
# update duration sum
labeling_duration[dataset_id,OURS_2024_09] += ours_duration
# if there is a hex-mesh in the labeling folder, instantiate it and retrieve mesh stats
hexmesh_minSJ = None
post_processed_hex_mesh_path = labeling_ours_folder.path / 'polycube_withHexEx_1.3' / 'global_padding' / 'inner_smoothing_50'
if post_processed_hex_mesh_path.exists():
hex_mesh_folder: DataFolder = DataFolder(post_processed_hex_mesh_path)
hex_mesh_stats: dict = hex_mesh_folder.get_mesh_stats_dict() # type: ignore | see ../data_folder_types/hex-mesh.accessors.py
if 'quality' in hex_mesh_stats['cells']:
avg_sj_sum[dataset_id,OURS_2024_09] += hex_mesh_stats['cells']['quality']['hex_SJ']['avg']
hexmesh_minSJ = hex_mesh_stats['cells']['quality']['hex_SJ']['min']
min_sj_sum[dataset_id,OURS_2024_09] += hexmesh_minSJ
# update the counters
if not labeling_ours_folder.has_valid_labeling(): # type: ignore | see ../data_folder_types/labeling.accessors.py
if (labeling_ours_folder.path / 'polycube_withHexEx_1.3').exists():
if Confirm(f"There is a 'polycube_withHexEx' output inside {labeling_ours_folder.path}, but the labeling is invalid. Remove this hex-mesh folder?"):
rmtree(labeling_ours_folder.path / 'polycube_withHexEx_1.3')
assert(not post_processed_hex_mesh_path.exists())
assert(hexmesh_minSJ is None)
fluxes[dataset_id,OURS_2024_09,INIT_LABELING_SUCCESS,LABELING_INVALID] += 1
elif labeling_ours_folder.nb_turning_points() != 0: # type: ignore | see ../data_folder_types/labeling.accessors.py
fluxes[dataset_id,OURS_2024_09,INIT_LABELING_SUCCESS,LABELING_NON_MONOTONE] += 1
if hexmesh_minSJ is not None:
# a hex-mesh was successfully generated
if hexmesh_minSJ < 0.0:
fluxes[dataset_id,OURS_2024_09,LABELING_NON_MONOTONE,HEX_MESHING_NEGATIVE_MIN_SJ] += 1
else:
fluxes[dataset_id,OURS_2024_09,LABELING_NON_MONOTONE,HEX_MESHING_POSITIVE_MIN_SJ] += 1
else:
# no hex-mesh
fluxes[dataset_id,OURS_2024_09,LABELING_NON_MONOTONE,HEX_MESHING_FAILURE] += 1
# also penalize minSJ & avgSJ sums
avg_sj_sum[dataset_id,OURS_2024_09] += -1.0 # assume worse value
min_sj_sum[dataset_id,OURS_2024_09] += -1.0 # assume worse value
else:
# so we have a valid labeling with no turning-points
fluxes[dataset_id,OURS_2024_09,INIT_LABELING_SUCCESS,LABELING_SUCCESS] += 1
if hexmesh_minSJ is not None:
# a hex-mesh was successfully generated
if hexmesh_minSJ < 0.0:
fluxes[dataset_id,OURS_2024_09,LABELING_SUCCESS,HEX_MESHING_NEGATIVE_MIN_SJ] += 1
else:
fluxes[dataset_id,OURS_2024_09,LABELING_SUCCESS,HEX_MESHING_POSITIVE_MIN_SJ] += 1
else:
# no hex-mesh
fluxes[dataset_id,OURS_2024_09,LABELING_SUCCESS,HEX_MESHING_FAILURE] += 1
# also penalize minSJ & avgSJ sums
avg_sj_sum[dataset_id,OURS_2024_09] += -1.0 # assume worse value
min_sj_sum[dataset_id,OURS_2024_09] += -1.0 # assume worse value
def parse_PolyCut_output(dataset_id: int, tet_folder: DataFolder):
if not (tet_folder.path / 'PolyCut_3').exists() or not (tet_folder.path / 'PolyCut_3' / surface_labeling_filename).exists():
# there is a tet mesh but no labeling was written
fluxes[dataset_id,POLYCUT,COARSER_TET_MESHING_SUCCESS,LABELING_FAILURE] += 1
else:
# instantiate the labeling folder
labeling_folder: DataFolder = DataFolder(tet_folder.path / 'PolyCut_3')
assert(labeling_folder.type == 'labeling')
# retrieve PolyCut-specific duration file
polycut_durations = dict()
with open(labeling_folder.path / 'PolyCut.durations.json','r') as polycut_durations_stream:
polycut_durations = json.load(polycut_durations_stream)
labeling_stats = labeling_folder.get_labeling_stats_dict() # type: ignore | see ../data_folder_types/labeling.accessors.py
# update avg fidelity sum
sum_avg_fidelities[dataset_id,POLYCUT] += labeling_stats['fidelity']['avg']
# there is no feature edges in the PolyCut input & output meshes, don't count feature edges
# update duration sum
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?
hexmesh_minSJ = None
post_processed_hex_mesh_path = labeling_folder.path / 'polycube_withHexEx_1.3' / 'global_padding' / 'inner_smoothing_50'
if post_processed_hex_mesh_path.exists():
hex_mesh_folder: DataFolder = DataFolder(post_processed_hex_mesh_path)
hex_mesh_stats: dict = hex_mesh_folder.get_mesh_stats_dict() # type: ignore | see ../data_folder_types/hex-mesh.accessors.py
if 'quality' in hex_mesh_stats['cells']:
avg_sj_sum[dataset_id,POLYCUT] += hex_mesh_stats['cells']['quality']['hex_SJ']['avg']
hexmesh_minSJ = hex_mesh_stats['cells']['quality']['hex_SJ']['min']
min_sj_sum[dataset_id,POLYCUT] += hexmesh_minSJ
# update the counters
if not labeling_folder.has_valid_labeling(): # type: ignore | see ../data_folder_types/labeling.accessors.py
if (labeling_folder.path / 'polycube_withHexEx_1.3').exists():
if Confirm(f"There is a 'polycube_withHexEx' output inside {labeling_folder.path}, but the labeling is invalid. Remove this hex-mesh folder?"):
rmtree(labeling_folder.path / 'polycube_withHexEx_1.3')
assert(not post_processed_hex_mesh_path.exists())
assert(hexmesh_minSJ is None)
fluxes[dataset_id,POLYCUT,COARSER_TET_MESHING_SUCCESS,LABELING_INVALID] += 1
elif labeling_folder.nb_turning_points() != 0: # type: ignore | see ../data_folder_types/labeling.accessors.py
fluxes[dataset_id,POLYCUT,COARSER_TET_MESHING_SUCCESS,LABELING_NON_MONOTONE] += 1
if hexmesh_minSJ is not None:
# a hex-mesh was successfully generated
if hexmesh_minSJ < 0.0:
fluxes[dataset_id,POLYCUT,LABELING_NON_MONOTONE,HEX_MESHING_NEGATIVE_MIN_SJ] += 1
else:
fluxes[dataset_id,POLYCUT,LABELING_NON_MONOTONE,HEX_MESHING_POSITIVE_MIN_SJ] += 1
else:
# no hex-mesh
fluxes[dataset_id,POLYCUT,LABELING_NON_MONOTONE,HEX_MESHING_FAILURE] += 1
else:
fluxes[dataset_id,POLYCUT,COARSER_TET_MESHING_SUCCESS,LABELING_SUCCESS] += 1
if hexmesh_minSJ is not None:
# a hex-mesh was successfully generated
if hexmesh_minSJ < 0.0:
fluxes[dataset_id,POLYCUT,LABELING_SUCCESS,HEX_MESHING_NEGATIVE_MIN_SJ] += 1
else:
fluxes[dataset_id,POLYCUT,LABELING_SUCCESS,HEX_MESHING_POSITIVE_MIN_SJ] += 1
else:
# no hex-mesh
fluxes[dataset_id,POLYCUT,LABELING_SUCCESS,HEX_MESHING_FAILURE] += 1
for level_minus_1_folder in get_subfolders_of_type(input_folder / 'MAMBO', 'step'):
CAD_name = level_minus_1_folder.name
_, MAMBO_subset_id = MAMBO_letter_to_subset(CAD_name[0])
if not (level_minus_1_folder / STEP_filename).exists():
logging.warning(f"Folder {level_minus_1_folder} has no {STEP_filename}")
continue
fluxes[MAMBO_subset_id,N_A,VOID,CAD] += 1
if not (level_minus_1_folder / 'Gmsh_0.1/').exists() or not (level_minus_1_folder / 'Gmsh_0.1' / surface_mesh_filename).exists():
# not even a surface mesh
fluxes[MAMBO_subset_id,N_A,CAD,TET_MESHING_FAILURE] += 1
continue
tet_folder: DataFolder = DataFolder(level_minus_1_folder / 'Gmsh_0.1')
assert(tet_folder.type == 'tet-mesh')
fluxes[MAMBO_subset_id,N_A,CAD,TET_MESHING_SUCCESS] += 1
# analyse the labeling generated by evocube
parse_Evocube_output(MAMBO_subset_id,tet_folder)
# analyse the labeling generated by automatic_polycube
parse_Ours_2024_03_output(MAMBO_subset_id,tet_folder)
# analyse the labeling generated by graphcut_labeling, and the one generated on the output with automatic_polycube
parse_Ours_2024_09(MAMBO_subset_id,tet_folder)
# /!\ here we cannot expect a `surface_mesh_filename` inside 'Gmsh_0.15', because this mesh is extracted from a PolyCut output, and PolyCut can fail
if not (level_minus_1_folder / 'Gmsh_0.15/').exists() or not (level_minus_1_folder / 'Gmsh_0.15' / tet_mesh_filename).exists():
# not even a tet-mesh mesh
fluxes[MAMBO_subset_id,N_A,CAD,COARSER_TET_MESHING_FAILURE] += 1
continue
tet_folder: DataFolder = DataFolder(level_minus_1_folder / 'Gmsh_0.15')
assert(tet_folder.type == 'tet-mesh')
fluxes[MAMBO_subset_id,N_A,CAD,COARSER_TET_MESHING_SUCCESS] += 1
# analyse the labeling generated by PolyCut
parse_PolyCut_output(MAMBO_subset_id,tet_folder)
for level_minus_1_folder in get_subfolders_of_type(input_folder / 'OctreeMeshing' / 'cad', 'tet-mesh'):
tet_folder: DataFolder = DataFolder(level_minus_1_folder)
fluxes[OCTREE_MESHING_CAD,N_A,VOID,TET_MESHING_SUCCESS] += 1
parse_Evocube_output(OCTREE_MESHING_CAD,tet_folder)
parse_Ours_2024_09(OCTREE_MESHING_CAD,tet_folder)
# end of data folder parsing
# print high level stats for the table in the paper
table = Table(title='Stats table')
table.add_column('Dataset/Subset\n(size)')
table.add_column('Method')
table.add_column('Valid & monotone\nValid, non-monotone\nInvalid\nFailed')
table.add_column('idem, cumulative')
table.add_column('Overall\navg(fidelity)')
table.add_column('Feature-edges:\nSharp & preserved\nSharp & lost\nIgnored')
table.add_column('Total\nlabeling\nduration')
table.add_column('min(SJ) ≥ 0')
table.add_column('avg min(SJ)\navg avg(SJ)')
for dataset_str, dataset_id in {'MAMBO/Basic': MAMBO_BASIC, 'MAMBO/Simple': MAMBO_SIMPLE, 'MAMBO/Medium': MAMBO_MEDIUM, 'OctreeMeshing/cad': OCTREE_MESHING_CAD}.items():
nb_CAD_models = fluxes[dataset_id,N_A,VOID,TET_MESHING_SUCCESS] if dataset_id == OCTREE_MESHING_CAD else fluxes[dataset_id,N_A,VOID,CAD]
assert(nb_CAD_models != 0)
assert(fluxes[dataset_id,N_A,CAD,TET_MESHING_FAILURE] == 0) # expect all tet-mesh generations succeeded. easier for the stats
# needed for GRAPHCUT and OURS_2024_09 stats
nb_init_labeling_generated = \
fluxes[dataset_id,GRAPHCUT,TET_MESHING_SUCCESS,LABELING_SUCCESS] + \
fluxes[dataset_id,GRAPHCUT,TET_MESHING_SUCCESS,LABELING_NON_MONOTONE] + \
fluxes[dataset_id,GRAPHCUT,TET_MESHING_SUCCESS,LABELING_INVALID]
if SHOW_GRAPHCUT_STATS:
percentage_labeling_success = fluxes[dataset_id,GRAPHCUT,TET_MESHING_SUCCESS,LABELING_SUCCESS] / nb_CAD_models * 100
percentage_labeling_non_monotone = fluxes[dataset_id,GRAPHCUT,TET_MESHING_SUCCESS,LABELING_NON_MONOTONE] / nb_CAD_models * 100
percentage_labeling_invalid = fluxes[dataset_id,GRAPHCUT,TET_MESHING_SUCCESS,LABELING_INVALID] / nb_CAD_models * 100
percentage_labeling_failure = fluxes[dataset_id,GRAPHCUT,TET_MESHING_SUCCESS,LABELING_FAILURE] / nb_CAD_models * 100
overall_average_fidelity = sum_avg_fidelities[dataset_id,GRAPHCUT] / nb_init_labeling_generated
total_nb_feature_edges = 0 if dataset_id == OCTREE_MESHING_CAD else \
nb_feature_edges_sharp_and_preserved[dataset_id,GRAPHCUT] + \
nb_feature_edges_sharp_and_lost[dataset_id,GRAPHCUT] + \
nb_feature_edges_ignored[dataset_id,GRAPHCUT]
percentage_feature_edges_sharp_and_preserved = 0 if dataset_id == OCTREE_MESHING_CAD else (nb_feature_edges_sharp_and_preserved[dataset_id,GRAPHCUT] / total_nb_feature_edges * 100)
percentage_feature_edges_sharp_and_lost = 0 if dataset_id == OCTREE_MESHING_CAD else (nb_feature_edges_sharp_and_lost[dataset_id,GRAPHCUT] / total_nb_feature_edges * 100)
percentage_feature_edges_ignored = 0 if dataset_id == OCTREE_MESHING_CAD else (nb_feature_edges_ignored[dataset_id,GRAPHCUT] / total_nb_feature_edges * 100)
table.add_row(
f'{dataset_str} ({nb_CAD_models})',
'graphcut',
f"{percentage_labeling_success:.1f} %\n{percentage_labeling_non_monotone:.1f} %\n{percentage_labeling_invalid:.1f} %\n{percentage_labeling_failure:.1f} %",
f"{percentage_labeling_success:.1f} %\n{percentage_labeling_success+percentage_labeling_non_monotone:.1f} %\n{percentage_labeling_success+percentage_labeling_non_monotone+percentage_labeling_invalid:.1f} %\n{percentage_labeling_success+percentage_labeling_non_monotone+percentage_labeling_invalid+percentage_labeling_failure:.1f} %",
f"{overall_average_fidelity:.3f}",
"-" if dataset_id == OCTREE_MESHING_CAD else f"{percentage_feature_edges_sharp_and_preserved:.1f} %\n{percentage_feature_edges_sharp_and_lost:.1f} %\n{percentage_feature_edges_ignored:.1f} %",
f"{labeling_duration[dataset_id,GRAPHCUT]:.2f} s",
"-",
"-"
)
table.add_section()
if SHOW_POLYCUT_STATS and dataset_id != OCTREE_MESHING_CAD:
assert(fluxes[dataset_id,N_A,CAD,COARSER_TET_MESHING_FAILURE] == 0) # expect all tet-mesh generations succeeded. easier for the stats
percentage_labeling_success = fluxes[dataset_id,POLYCUT,COARSER_TET_MESHING_SUCCESS,LABELING_SUCCESS] / nb_CAD_models * 100
percentage_labeling_non_monotone = fluxes[dataset_id,POLYCUT,COARSER_TET_MESHING_SUCCESS,LABELING_NON_MONOTONE] / nb_CAD_models * 100
percentage_labeling_invalid = fluxes[dataset_id,POLYCUT,COARSER_TET_MESHING_SUCCESS,LABELING_INVALID] / nb_CAD_models * 100
percentage_labeling_failure = fluxes[dataset_id,POLYCUT,COARSER_TET_MESHING_SUCCESS,LABELING_FAILURE] / nb_CAD_models * 100
nb_labeling_generated = \
fluxes[dataset_id,POLYCUT,COARSER_TET_MESHING_SUCCESS,LABELING_SUCCESS] + \
fluxes[dataset_id,POLYCUT,COARSER_TET_MESHING_SUCCESS,LABELING_NON_MONOTONE] + \
fluxes[dataset_id,POLYCUT,COARSER_TET_MESHING_SUCCESS,LABELING_INVALID]
overall_average_fidelity = sum_avg_fidelities[dataset_id,POLYCUT] / nb_labeling_generated
duration_factor_relative_to_Ours_2024_09 = labeling_duration[dataset_id,POLYCUT] / (labeling_duration[dataset_id,GRAPHCUT]+labeling_duration[dataset_id,OURS_2024_09])
nb_tried_hex_meshing = \
fluxes[dataset_id,POLYCUT,COARSER_TET_MESHING_SUCCESS,LABELING_SUCCESS] + \
fluxes[dataset_id,POLYCUT,COARSER_TET_MESHING_SUCCESS,LABELING_NON_MONOTONE]
nb_hex_meshes_with_positive_min_sj = \
fluxes[dataset_id,POLYCUT,LABELING_SUCCESS,HEX_MESHING_POSITIVE_MIN_SJ] + \
fluxes[dataset_id,POLYCUT,LABELING_NON_MONOTONE,HEX_MESHING_POSITIVE_MIN_SJ]
percentage_hex_mesh_positive_min_SJ = nb_hex_meshes_with_positive_min_sj / nb_tried_hex_meshing * 100
average_min_SJ = min_sj_sum[dataset_id,POLYCUT] / nb_tried_hex_meshing
average_avj_SJ = avg_sj_sum[dataset_id,POLYCUT] / nb_tried_hex_meshing
table.add_row(
f'{dataset_str} ({nb_CAD_models})',
'PolyCut',
f"{percentage_labeling_success:.1f} %\n{percentage_labeling_non_monotone:.1f} %\n{percentage_labeling_invalid:.1f} %\n{percentage_labeling_failure:.1f} %",
f"{percentage_labeling_success:.1f} %\n{percentage_labeling_success+percentage_labeling_non_monotone:.1f} %\n{percentage_labeling_success+percentage_labeling_non_monotone+percentage_labeling_invalid:.1f} %\n{percentage_labeling_success+percentage_labeling_non_monotone+percentage_labeling_invalid+percentage_labeling_failure:.1f} %",
f"{overall_average_fidelity:.3f}",
"-",
f"{labeling_duration[dataset_id,POLYCUT]:.2f}† s\n(x{duration_factor_relative_to_Ours_2024_09:.0f} Ours_2024-09)",
f"{percentage_hex_mesh_positive_min_SJ:.1f} %",
f"{average_min_SJ:.3f}\n{average_avj_SJ:.3f}"
)
table.add_section()
if SHOW_EVOCUBE_STATS:
percentage_labeling_success = fluxes[dataset_id,EVOCUBE,TET_MESHING_SUCCESS,LABELING_SUCCESS] / nb_CAD_models * 100
percentage_labeling_non_monotone = fluxes[dataset_id,EVOCUBE,TET_MESHING_SUCCESS,LABELING_NON_MONOTONE] / nb_CAD_models * 100
percentage_labeling_invalid = fluxes[dataset_id,EVOCUBE,TET_MESHING_SUCCESS,LABELING_INVALID] / nb_CAD_models * 100
percentage_labeling_failure = fluxes[dataset_id,EVOCUBE,TET_MESHING_SUCCESS,LABELING_FAILURE] / nb_CAD_models * 100
nb_labeling_generated = \
fluxes[dataset_id,EVOCUBE,TET_MESHING_SUCCESS,LABELING_SUCCESS] + \
fluxes[dataset_id,EVOCUBE,TET_MESHING_SUCCESS,LABELING_NON_MONOTONE] + \
fluxes[dataset_id,EVOCUBE,TET_MESHING_SUCCESS,LABELING_INVALID]
overall_average_fidelity = sum_avg_fidelities[dataset_id,EVOCUBE] / nb_labeling_generated
total_nb_feature_edges = 0 if dataset_id == OCTREE_MESHING_CAD else \
nb_feature_edges_sharp_and_preserved[dataset_id,EVOCUBE] + \
nb_feature_edges_sharp_and_lost[dataset_id,EVOCUBE] + \
nb_feature_edges_ignored[dataset_id,EVOCUBE]
percentage_feature_edges_sharp_and_preserved = 0 if dataset_id == OCTREE_MESHING_CAD else (nb_feature_edges_sharp_and_preserved[dataset_id,EVOCUBE] / total_nb_feature_edges * 100)
percentage_feature_edges_sharp_and_lost = 0 if dataset_id == OCTREE_MESHING_CAD else (nb_feature_edges_sharp_and_lost[dataset_id,EVOCUBE] / total_nb_feature_edges * 100)
percentage_feature_edges_ignored = 0 if dataset_id == OCTREE_MESHING_CAD else (nb_feature_edges_ignored[dataset_id,EVOCUBE] / total_nb_feature_edges * 100)
duration_factor_relative_to_Ours_2024_09 = labeling_duration[dataset_id,EVOCUBE] / (labeling_duration[dataset_id,GRAPHCUT]+labeling_duration[dataset_id,OURS_2024_09])
nb_tried_hex_meshing = \
fluxes[dataset_id,EVOCUBE,TET_MESHING_SUCCESS,LABELING_SUCCESS] + \
fluxes[dataset_id,EVOCUBE,TET_MESHING_SUCCESS,LABELING_NON_MONOTONE]
nb_hex_meshes_with_positive_min_sj = \
fluxes[dataset_id,EVOCUBE,LABELING_SUCCESS,HEX_MESHING_POSITIVE_MIN_SJ] + \
fluxes[dataset_id,EVOCUBE,LABELING_NON_MONOTONE,HEX_MESHING_POSITIVE_MIN_SJ]
percentage_hex_mesh_positive_min_SJ = nb_hex_meshes_with_positive_min_sj / nb_tried_hex_meshing * 100
average_min_SJ = min_sj_sum[dataset_id,EVOCUBE] / nb_tried_hex_meshing
average_avj_SJ = avg_sj_sum[dataset_id,EVOCUBE] / nb_tried_hex_meshing
table.add_row(
f'{dataset_str} ({nb_CAD_models})',
'Evocube',
f"{percentage_labeling_success:.1f} %\n{percentage_labeling_non_monotone:.1f} %\n{percentage_labeling_invalid:.1f} %\n{percentage_labeling_failure:.1f} %",
f"{percentage_labeling_success:.1f} %\n{percentage_labeling_success+percentage_labeling_non_monotone:.1f} %\n{percentage_labeling_success+percentage_labeling_non_monotone+percentage_labeling_invalid:.1f} %\n{percentage_labeling_success+percentage_labeling_non_monotone+percentage_labeling_invalid+percentage_labeling_failure:.1f} %",
f"{overall_average_fidelity:.3f}",
"-" if dataset_id == OCTREE_MESHING_CAD else f"{percentage_feature_edges_sharp_and_preserved:.1f} %\n{percentage_feature_edges_sharp_and_lost:.1f} %\n{percentage_feature_edges_ignored:.1f} %",
f"{labeling_duration[dataset_id,EVOCUBE]:.2f} s\n(x{duration_factor_relative_to_Ours_2024_09:.0f} Ours_2024-09)",
f"{percentage_hex_mesh_positive_min_SJ:.1f} %",
f"{average_min_SJ:.3f}\n{average_avj_SJ:.3f}"
)
table.add_section()
if SHOW_OURS_2024_03_STATS and dataset_id != OCTREE_MESHING_CAD:
percentage_labeling_success = fluxes[dataset_id,OURS_2024_03,TET_MESHING_SUCCESS,LABELING_SUCCESS] / nb_CAD_models * 100
percentage_labeling_non_monotone = fluxes[dataset_id,OURS_2024_03,TET_MESHING_SUCCESS,LABELING_NON_MONOTONE] / nb_CAD_models * 100
percentage_labeling_invalid = fluxes[dataset_id,OURS_2024_03,TET_MESHING_SUCCESS,LABELING_INVALID] / nb_CAD_models * 100
percentage_labeling_failure = fluxes[dataset_id,OURS_2024_03,TET_MESHING_SUCCESS,LABELING_FAILURE] / nb_CAD_models * 100
nb_labeling_generated = \
fluxes[dataset_id,OURS_2024_03,TET_MESHING_SUCCESS,LABELING_SUCCESS] + \
fluxes[dataset_id,OURS_2024_03,TET_MESHING_SUCCESS,LABELING_NON_MONOTONE] + \
fluxes[dataset_id,OURS_2024_03,TET_MESHING_SUCCESS,LABELING_INVALID]
overall_average_fidelity = sum_avg_fidelities[dataset_id,OURS_2024_03] / nb_labeling_generated
total_nb_feature_edges = \
nb_feature_edges_sharp_and_preserved[dataset_id,OURS_2024_03] + \
nb_feature_edges_sharp_and_lost[dataset_id,OURS_2024_03] + \
nb_feature_edges_ignored[dataset_id,OURS_2024_03]
percentage_feature_edges_sharp_and_preserved = nb_feature_edges_sharp_and_preserved[dataset_id,OURS_2024_03] / total_nb_feature_edges * 100
percentage_feature_edges_sharp_and_lost = nb_feature_edges_sharp_and_lost[dataset_id,OURS_2024_03] / total_nb_feature_edges * 100
percentage_feature_edges_ignored = nb_feature_edges_ignored[dataset_id,OURS_2024_03] / total_nb_feature_edges * 100
table.add_row(
f'{dataset_str} ({nb_CAD_models})',
'Ours_2024-03',
f"{percentage_labeling_success:.1f} %\n{percentage_labeling_non_monotone:.1f} %\n{percentage_labeling_invalid:.1f} %\n{percentage_labeling_failure:.1f} %",
f"{percentage_labeling_success:.1f} %\n{percentage_labeling_success+percentage_labeling_non_monotone:.1f} %\n{percentage_labeling_success+percentage_labeling_non_monotone+percentage_labeling_invalid:.1f} %\n{percentage_labeling_success+percentage_labeling_non_monotone+percentage_labeling_invalid+percentage_labeling_failure:.1f} %",
f"{overall_average_fidelity:.3f}",
f"{percentage_feature_edges_sharp_and_preserved:.1f} %\n{percentage_feature_edges_sharp_and_lost:.1f} %\n{percentage_feature_edges_ignored:.1f} %",
f"{labeling_duration[dataset_id,OURS_2024_03]:.2f} s",
"-",
"-"
)
table.add_section()
if SHOW_OURS_2024_09_STATS:
assert(nb_init_labeling_generated == nb_CAD_models) # assert tetrahedrization & graphcut_labeling did not failed. easier for the stats
percentage_labeling_success = fluxes[dataset_id,OURS_2024_09,INIT_LABELING_SUCCESS,LABELING_SUCCESS] / nb_CAD_models * 100
percentage_labeling_non_monotone = fluxes[dataset_id,OURS_2024_09,INIT_LABELING_SUCCESS,LABELING_NON_MONOTONE] / nb_CAD_models * 100
percentage_labeling_invalid = fluxes[dataset_id,OURS_2024_09,INIT_LABELING_SUCCESS,LABELING_INVALID] / nb_CAD_models * 100
percentage_labeling_failure = fluxes[dataset_id,OURS_2024_09,INIT_LABELING_SUCCESS,LABELING_FAILURE] / nb_CAD_models * 100
nb_labeling_generated = \
fluxes[dataset_id,OURS_2024_09,INIT_LABELING_SUCCESS,LABELING_SUCCESS] + \
fluxes[dataset_id,OURS_2024_09,INIT_LABELING_SUCCESS,LABELING_NON_MONOTONE] + \
fluxes[dataset_id,OURS_2024_09,INIT_LABELING_SUCCESS,LABELING_INVALID]
overall_average_fidelity = sum_avg_fidelities[dataset_id,OURS_2024_09] / nb_labeling_generated
total_nb_feature_edges = 0 if dataset_id == OCTREE_MESHING_CAD else \
nb_feature_edges_sharp_and_preserved[dataset_id,OURS_2024_09] + \
nb_feature_edges_sharp_and_lost[dataset_id,OURS_2024_09] + \
nb_feature_edges_ignored[dataset_id,OURS_2024_09]
percentage_feature_edges_sharp_and_preserved = 0 if dataset_id == OCTREE_MESHING_CAD else (nb_feature_edges_sharp_and_preserved[dataset_id,OURS_2024_09] / total_nb_feature_edges * 100)
percentage_feature_edges_sharp_and_lost = 0 if dataset_id == OCTREE_MESHING_CAD else (nb_feature_edges_sharp_and_lost[dataset_id,OURS_2024_09] / total_nb_feature_edges * 100)
percentage_feature_edges_ignored = 0 if dataset_id == OCTREE_MESHING_CAD else (nb_feature_edges_ignored[dataset_id,OURS_2024_09] / total_nb_feature_edges * 100)
total_duration = labeling_duration[dataset_id,GRAPHCUT] + labeling_duration[dataset_id,OURS_2024_09] # init labeling duration + ours labeling optimization duration
nb_tried_hex_meshing = \
fluxes[dataset_id,OURS_2024_09,INIT_LABELING_SUCCESS,LABELING_SUCCESS] + \
fluxes[dataset_id,OURS_2024_09,INIT_LABELING_SUCCESS,LABELING_NON_MONOTONE]
assert(nb_tried_hex_meshing != 0)
nb_hex_meshes_with_positive_min_sj = \
fluxes[dataset_id,OURS_2024_09,LABELING_SUCCESS,HEX_MESHING_POSITIVE_MIN_SJ] + \
fluxes[dataset_id,OURS_2024_09,LABELING_NON_MONOTONE,HEX_MESHING_POSITIVE_MIN_SJ]
assert(nb_hex_meshes_with_positive_min_sj != 0)
percentage_hex_mesh_positive_min_SJ = nb_hex_meshes_with_positive_min_sj / nb_tried_hex_meshing * 100
average_min_SJ = min_sj_sum[dataset_id,OURS_2024_09] / nb_tried_hex_meshing
average_avj_SJ = avg_sj_sum[dataset_id,OURS_2024_09] / nb_tried_hex_meshing
table.add_row(
f'{dataset_str} ({nb_CAD_models})',
'Ours_2024-09',
f"{percentage_labeling_success:.1f} %\n{percentage_labeling_non_monotone:.1f} %\n{percentage_labeling_invalid:.1f} %\n{percentage_labeling_failure:.1f} %",
f"{percentage_labeling_success:.1f} %\n{percentage_labeling_success+percentage_labeling_non_monotone:.1f} %\n{percentage_labeling_success+percentage_labeling_non_monotone+percentage_labeling_invalid:.1f} %\n{percentage_labeling_success+percentage_labeling_non_monotone+percentage_labeling_invalid+percentage_labeling_failure:.1f} %",
f"{overall_average_fidelity:.3f}",
"-" if dataset_id == OCTREE_MESHING_CAD else f"{percentage_feature_edges_sharp_and_preserved:.1f} %\n{percentage_feature_edges_sharp_and_lost:.1f} %\n{percentage_feature_edges_ignored:.1f} %",
f"{total_duration:.2f}* s",
f"{percentage_hex_mesh_positive_min_SJ:.1f} %",
f"{average_min_SJ:.3f}\n{average_avj_SJ:.3f}"
)
table.add_section()
console = Console()
console.print(table)
console.print('*init labeling duration (graphcut) + ours duration (automatic_polycube)')
console.print('†executed on a virtual machine, do not reflect actual performances')