This project compute the deformation between an original mesh and it's deformed version.
It take at inputs n pairs of 2 stl or obj files (the original and the deformed one) stored in the mesh_deformed
and
mesh_orignal
folders.
The 2 files are aligned using two methods; first, with the principal axes of inertial, then this alignment is refined using the iterative closest point (ICP). This methods make that objects with symmetry may fail to be aligned, prefer object with lot of variation like the Stanford bunny, used here as example.
- mesh_deformation : Folder where are stored the
.def
and.vtk
results files (output folder). - mesh_deformed : Folder where are stored mesh deformed
- mesh_original : Folder where are stored the non deformed mesh
- display_results.py : Script using the .def file to display the displacement value on an original mesh
- compute_deformation.py : Script aligning the deformed files with the original and generate the
.def
- Create a new conda environment with python 3.7
conda env create --file environment.yml python=3.7
- Move your original mesh to
mesh_original
- Move your deformed mesh to 'mesh_deformation'
- Run
main.py
to compute the deformation of all files in the folder
You can generate fake original and deformed file by using just running display_results.py
. This will automatically
call create_dummy_data
, loading the sample mesh saved in mesh_original
and apply a deformation on it (there are
random value in this deformation), then save the deformed mesh in mesh_deformed
.
Put as many pairs (two file with the same name) of original and deformed files into mesh_deformed
and mesh_original
folder and run main.py
.
main.py
will automatically detect all files with the same name and compute there deformation and generate 2 files in
mesh_deformation
:
*.def
: A simple txt file containing the X,Y and Z deformation of every vertices*.vtk
: A Paraview file, allowing to see the mesh and it's deformations.
The main.py
script can be called with a few arguments:
path_original
: path to the original folder containing the original files ("mesh_original" by default).path_deformed
: path to the deformed folder containing the deformed files ("mesh_deformed" by default).only_icp
: boolean describing if only the ICP methods is used or if the principal axes of inertial are used before the ICP (default: False, the principal axes of inertial are used before the ICP).
python main.py --path_original "mesh_original" --path_deformed "mesh_deformed" --only_icp "True"
# Here only the ICP methods is used to align the files together.
Notes:
In Paraview, the t
deformation correspond to the sum of the X,Y and Z deformation and n
is the normal of those
deformation.
If only_icp
is False
, the Trimesh register function is used. If True
the Trimesh icp function is used.
Original files and there deformation are saved in the mesh_deformation
folder. The vtk
file can be opened with the software Paraview.
For each files, the deformation are saved for each axis: x,y and z. Two other view are also represented;
t
the total deformation (n
the normal of the deformation vector defined as
The def
file contain the X,Y and Z deformation of every nodes. This is computed by alligning the 2 meshes and substracting the original nodes position toof the aligned mesh vertices position (
All images in this readme are from the vtk file generated by main.py and the example data.
The X deformation is calculated as
The X deformation is calculated as
The X deformation is calculated as