Skip to content

lerouxl/Mesh-deformation-display

Repository files navigation

Mesh-deformation-display

Illustation image

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.

Project architecture:

  • 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

Installation:

  1. Create a new conda environment with python 3.7 conda env create --file environment.yml python=3.7
  2. Move your original mesh to mesh_original
  3. Move your deformed mesh to 'mesh_deformation'
  4. Run main.py to compute the deformation of all files in the folder

Generation of example file:

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.

Uses:

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.

Output data:

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 ($t=x+y+z$), and n the normal of the deformation vector defined as $n=\sqrt{x^2+y^2+z^2}$.

Calculation of the norm

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 ( $mesh_{aligned}.vertices - mesh_{original}.vertices$ )

All images in this readme are from the vtk file generated by main.py and the example data.

Example of random deformation generated by create_dummy_data:

Deformation in X:

The X deformation is calculated as $x_{def} = 0.2*abs(cos(z)) * 0.1 * random$

Image of the X deformation

Deformation in Y:

The X deformation is calculated as $y_{def} = 0.2*cos(x)$

Image of the Y deformation

Deformation in Z:

The X deformation is calculated as $z_{def} = 0.2*random$

Image of the Z deformation

About

Script for aligning 2 mesh and computing there difference.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages