Skip to content

Commit

Permalink
chore: update .gitignore and add new scripts for data processing
Browse files Browse the repository at this point in the history
- Added file types to .gitignore to prevent tracking of generated files
- Introduced new Python scripts for handling mesh data and force calculations
- Created a script to concatenate mesh components for further analysis
  • Loading branch information
liblaf committed Jul 1, 2024
1 parent 5f9604e commit f08e6e5
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 1 deletion.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,11 @@ poetry.toml

.pixi

*.csv
*.msh
*.obj
*.pdf
*.ply
*.png
*.stl
*.vtu
*.pdf
57 changes: 57 additions & 0 deletions exp/2024/07/01/tan-force/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import igl
import meshio
import mkit.array.points
import mkit.io
import numpy as np
import trimesh
from numpy.typing import NDArray

tetra: meshio.Mesh = mkit.io.load_meshio(
"/home/liblaf/Documents/data/target/120056/predict.vtu"
)
mandible: trimesh.Trimesh = mkit.io.load_trimesh(
"/home/liblaf/Documents/data/target/120056/post/99-mandible.vtu"
)
faces: NDArray[np.integer] = igl.boundary_facets(tetra.get_cells_type("tetra")) # pyright: ignore [reportAttributeAccessIssue]
force: NDArray[np.float64] = np.asarray(tetra.point_data["force"]) * 1e9
mandible_force: NDArray[np.float64] = force[
mkit.array.points.position_to_index(tetra.points, mandible.vertices)
]
normal_force: NDArray[np.float64] = np.abs(
trimesh.util.diagonal_dot(mandible_force, mandible.vertex_normals)
)
tan_force: NDArray[np.float64] = np.sqrt(
trimesh.util.diagonal_dot(mandible_force, mandible_force) - normal_force**2
)
mkit.io.save(
"mandible.vtu",
mandible,
point_data={
"normal_force": normal_force,
"tan_force": tan_force,
"tan_normal": tan_force / normal_force,
},
)

skull: trimesh.Trimesh = trimesh.Trimesh(tetra.points, faces).split()[1]
vert_area: NDArray[np.float64] = np.zeros((len(skull.vertices),))
vert_area[skull.faces[:, 0]] += skull.area_faces
vert_area[skull.faces[:, 1]] += skull.area_faces
vert_area[skull.faces[:, 2]] += skull.area_faces
vert_area /= 3
skull_force: NDArray[np.float64] = force[
mkit.array.points.position_to_index(tetra.points, skull.vertices)
]
normal_force = np.abs(trimesh.util.diagonal_dot(skull_force, skull.vertex_normals))
tan_force = np.sqrt(
trimesh.util.diagonal_dot(skull_force, skull_force) - normal_force**2
)
mkit.io.save(
"skull.vtu",
skull,
point_data={
"normal_force": normal_force / vert_area,
"tan_force": tan_force / vert_area,
"tan_normal": tan_force / normal_force,
},
)
12 changes: 12 additions & 0 deletions exp/2024/07/01/tetwild/concat-head.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import mkit.io
import trimesh

face: trimesh.Trimesh = mkit.io.load_trimesh(
"/home/liblaf/Documents/data/template/00-face.ply"
)
skull: trimesh.Trimesh = mkit.io.load_trimesh(
"/home/liblaf/Documents/data/template/00-skull.ply"
)
skull.faces = skull.faces[:, ::-1]
head: trimesh.Trimesh = trimesh.util.concatenate(face, skull)
head.export("head.ply")

0 comments on commit f08e6e5

Please sign in to comment.