Skip to content

Commit e048cdf

Browse files
committed
batch_processing generates hex-meshes using HexEx
on PolyCut outputs as well
1 parent ba70124 commit e048cdf

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

definitions/algorithms/batch_processing.py

+23-3
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@
6161
AUTOMATIC_POLYCUBE_OUTPUT_MISSING_POLICY = 'ask'
6262
EVOCUBE_OUTPUT_MISSING_POLICY = 'ask'
6363
POLYCUT_OUTPUT_MISSING_POLICY = 'pass' # on Windows only. selector for not only PolyCut itself, but the whole pipeline their provide (with hex-meshing & untangling)
64-
POLYCUBE_WITHHEXEX_OUTPUT_MISSING_POLICY = 'ask'
65-
GLOBAL_PADDING_OUTPUT_MISSING_POLICY = 'ask'
66-
INNER_SMOOTHING_OUTPUT_MISSING_POLICY = 'ask'
64+
POLYCUBE_WITHHEXEX_OUTPUT_MISSING_POLICY = 'run'
65+
GLOBAL_PADDING_OUTPUT_MISSING_POLICY = 'run'
66+
INNER_SMOOTHING_OUTPUT_MISSING_POLICY = 'run'
6767

6868
RUNNING_ALGO_LINE_TEMPLATE = "Running [green]{algo}[/] on [cyan]{path}[/]"
6969
EXISTING_OUTPUT_LINE_TEMPLATE = "\[[bright_black]-[/]] [green]{algo}[/] on [cyan]{path}[/]" # type: ignore
@@ -77,6 +77,7 @@
7777
assert(AUTOMATIC_POLYCUBE_PATH is not None)
7878
AUTOMATIC_POLYCUBE_PATH = Path(expanduser(AUTOMATIC_POLYCUBE_PATH))
7979

80+
TET_MESH_MEDIT,_ = translate_filename_keyword('TET_MESH_MEDIT')
8081
SURFACE_MESH_OBJ,_ = translate_filename_keyword('SURFACE_MESH_OBJ')
8182
SURFACE_MAP_TXT,_ = translate_filename_keyword('SURFACE_MAP_TXT')
8283
SURFACE_MESH_STATS_JSON,_ = translate_filename_keyword('SURFACE_MESH_STATS_JSON')
@@ -590,6 +591,19 @@ def process_step(step_object: DataFolder):
590591
assert((coarser_tet_mesh_for_PolyCut.path / SURFACE_MESH_OBJ).exists())
591592
# else: PolyCut failed to generate 'segmentation_XYZ.obj', we cannot extract a .txt labeling
592593

594+
# overwrite 'Gmsh_0.15' / `SURFACE_MAP_TXT`, which do not correspond to the converted, colorless .obj
595+
# infer the surface map (association from surface triangles to tetrahedra facets) from the tetrahedral and triangle meshes
596+
assert(AUTOMATIC_POLYCUBE_PATH is not None)
597+
command_line = '{executable} {tet_mesh} {triangle_mesh} {output_surface_map}'.format(
598+
executable = AUTOMATIC_POLYCUBE_PATH / 'extract_surface',
599+
tet_mesh = coarser_tet_mesh_for_PolyCut.path / TET_MESH_MEDIT,
600+
triangle_mesh = coarser_tet_mesh_for_PolyCut.path / SURFACE_MESH_OBJ,
601+
output_surface_map = coarser_tet_mesh_for_PolyCut.path / SURFACE_MAP_TXT
602+
)
603+
with CONSOLE.status(RUNNING_ALGO_LINE_TEMPLATE.format(algo="extract_surface",path=collapseuser(coarser_tet_mesh_for_PolyCut.path))) as status:
604+
subprocess.run(command_line, shell=True, capture_output=False)
605+
CONSOLE.print(NEW_OUTPUT_LINE_TEMPLATE.format(algo='extract_surface', path=collapseuser(coarser_tet_mesh_for_PolyCut.path)))
606+
593607
# sometimes there is no `HEX_MESH_MEDIT` in untangler/
594608
# (which was 'hex_highest_quality.mesh' before run_PolyCut_pipeline() renamed it)
595609
# -> if there is a 'untangler.hex_smooth.mesh', rename it `HEX_MESH_MEDIT`
@@ -601,6 +615,12 @@ def process_step(step_object: DataFolder):
601615
coarser_tet_mesh_for_PolyCut.path / 'PolyCut_3' / 'optimizer_100' / HEX_MESH_MEDIT
602616
)
603617

618+
# alongside the hex-mesh generated by the set of executables in the polycut demo,
619+
# generate a hex-mesh with the same process as Evocube/automatic_polycube outputs: polycube_withHexEx, then global padding, then inner smoothing
620+
621+
if (coarser_tet_mesh_for_PolyCut.path / 'PolyCut_3' / SURFACE_LABELING_TXT).exists():
622+
labeling_object: DataFolder = DataFolder(coarser_tet_mesh_for_PolyCut.path / 'PolyCut_3')
623+
process_labeling(labeling_object)
604624

605625

606626
def main(input_folder: Path, arguments: list):

0 commit comments

Comments
 (0)