Normals on thin shape become corrupted

I have thin shapes, representing cortical bone consisting of an outer shell with normals facing outwards, and an inner shell with normals facing inwards. The documentation and many of the threads suggest the use of normals to best model thin structures.

Every time I import to shapeworks studio, and I suspect when I run optimize through python - the normals seem to get erased and recalculated wrong. I am not running any grooming, I have done this separately, I am simply referencing the mesh files (I have tried ply and vtk). If I export a mesh from studio and visualise the normals, the inside layer is reversed but the outer layer is not. This is not appopriate for my shape, and I believe it is what is responsible for producing distorted shape model which is not useable.

  • I assume there must be a computeNormals() somewhere which is recalculating the normals
  • in one of the issues threads on gitub it suggests one of the functions may in the background be using AutoOrientNormals in vtkPolyDataNormals.
  • I have seen the python API reference generateNormals which does not seem to distort the mesh normals
  • I can also see function to fixElement() for grooming but I cannot see where to apply this in the optimization pipeline
  • I also cannot work out how to check in python after the optimisation pipeline that the meshes being referenced retain the normal direction
  • I can only see when I open the shapeworks file and export the visualised meshes - that the normals are changed (I have tested and this happens without grooming, even at the first instance of importing meshes)

Could you please advise on how I can fix this error with erroneously recalculating normals which is impacting my ability to model these shapes?

There are several places in the pipeline where surface normals are regenerated. If VTK is not generating the normals correctly, I wonder if remeshing may help.

Have you tried using these mesh files in Studio?

This is an issue I can demonstrate primarily in Studio, if I import a mesh file into Studio - whether .ply or .vtk and I export it - the normals are changed and whats more the triangle order has been changed. Remeshing does not fix the issue, and I cannot recalculate the appropraite normals.

I suspect the same thing is happening in shapeworks python. I reference my stored meshes, is there a way I can check by exporting one of the meshs under subject that is actually being used as part of the optimise?

Any further ideas, any way I can prevent the program from recalculating triangle order and normals and use the actual supplied data?

There is not currently a way to disable the mesh fixes in the pipeline. Are you finding a problem with the correspondence particles generated by the optimizer? The same correspondence particles should be valid on your original mesh, so it may not really matter what mesh the optimization runs on. If the normal inversion is consistent across your shapes, then it should also not be affecting the optimization.

Do you have a sample mesh you could send me that I can take a look at?