<jupyter_start><jupyter_text>Import Dependencies<jupyter_code>import sys
import math
import numpy as np
import trimesh
from importlib import reload

from machina import HexMachina
from optimization import *
from singularity import *
from utils import *

import parametrization
import extraction<jupyter_output><empty_output><jupyter_text>Generate Tetrahedral MeshFirst, the triangle mesh representing the geometry is imported. Based on this input mesh, a volumetric tetrahedral mesh is generated and its boundary surface is extracted. Next, the curvatures and normals of this surface are computed, and some additional topological information is computed (i.e. dual).<jupyter_code>print('Reading triangle mesh...', end=" ")
sys.stdout.flush()
tri_mesh = trimesh.load_mesh('../io/cylinder.stl')
say_ok()

# Instantiate tetrahedral mesh
print('Generating tetrahedral mesh...', end=" ")
sys.stdout.flush()
machina = HexMachina(tri_mesh, max_vol = 1)
# Output tetrahedral mesh
vtk_tetmesh(machina.tet_mesh, 'tet_mesh')
say_ok()

# Construct boundary surface of tetrahedral mesh.
print('Computing surface curvatures/normals...', end=" ")
sys.stdout.flush()
# Compute face and vertex normals.
machina.surf_mesh.compute_normals()
# Compute principal curvatures and directions.
machina.surf_mesh.compute_curvatures()
# Output curvature crossfield to .vtk file.
vtk_curvature(machina.surf_mesh, 'curvature')
say_ok()

# Compute the tetrahedral one-rings of the mesh.
print('Extracting dual voronoi...', end=" ")
sys.stdout.flush()
machina.compute_dual()
say_ok()<jupyter_output>Reading triangle mesh... [92m OK. [0m
Generating tetrahedral mesh... [92m OK. [0m
Computing surface curvatures/normals... [92m OK. [0m
Extracting dual voronoi... [92m OK. [0m<jupyter_text>Construct Framefield<jupyter_code># Construct 3D frame field as an array of (U, V, W) frames.
# This field is parallel to the tet list (i.e. each tet has a frame).
print('Initializing framefield...', end=" ")
sys.stdout.flush()
# Construct frame field.
machina.init_framefield()
say_ok()

# Optimize 3D frame field by L-BFGS minimization.
print('Optimizing framefield...')
machina.optimize_framefield()
say_ok()

# Output frame field to .vtk file.
vtk_framefield(machina.frames, 'field')<jupyter_output>Initializing framefield... [92m OK. [0m
Optimizing framefield...
[92m OK. [0m<jupyter_text>Pre-process<jupyter_code># Determine the singular edges of the framefield.      
print("Computing singular graph...", end=" ")
sys.stdout.flush()
singular_vertices = singular_graph(machina)[2]
say_ok()<jupyter_output>Computing singular graph... [92m OK. [0m<jupyter_text>Parametrize<jupyter_code>reload(parametrization)

print("Parametrizing volume...")
uvw_map = parametrization.parametrize_volume(machina, singular_vertices, 3.0)
say_ok()<jupyter_output>Parametrizing volume...
Computing laplacian and constraints...
Conjugate Gradient... (Round 1)<jupyter_text>Extract hex<jupyter_code>reload(extraction)

print("Extracting hexahedrons...", end=" ")
iso_pts = extraction.extract_isolines(machina, uvw_map)
say_ok()<jupyter_output>Extracting hexahedrons...
{'fraction_non_alphanumeric': 0.11787315823190263, 'fraction_numerical': 0.008968609865470852, 'mean_word_length': 6.002242152466367, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '470743', 'license': 'MIT', 'n_tokens_mistral': 1107, 'n_tokens_neox': 1031, 'n_words': 270, 'path': 'hexmachina/Notebook.ipynb', 'repo_name': 'dnkrtz/hexmachina', 'size': '3122'}