meshpro / optimesh

:spider_web: Mesh optimization, mesh smoothing.
575 stars 56 forks source link

Support for VTK polydata? #77

Closed cbhushan closed 3 years ago

cbhushan commented 3 years ago

I am working with VTK surfaces and am looking for ways to re-divide the surface (polydata with only triangles) to get similar-sized cells with minimal change from the original surface. optimesh seems to fit the purpose well but on trying optimesh with my VTK polydata I realized that polydata is not supported (error below).

As VTK currently does not have such optimization function, it would be nice to include support of polydata or some suggestions of how to use optimesh with VTK polydata.

nschloe commented 3 years ago

optimesh seems to fit the purpose well

Probably not. For optimesh to work on surfaces, you need to have a function to that projects points onto your surface. If you just have a VTK file, you probably don't have that.

It would work for spheres though, if that's all your after.

The polydata read bug is a missing feature from meshio, so I'll just point you to https://github.com/nschloe/meshio/issues/527.

cbhushan commented 3 years ago

Sphere was just toy example. My actual surfaces are generated as iso-surface from 3D volumetric data (in VTK: Smooth volumetric data → marching cubes → smooth using vtkWindowedSincPolyDataFilter → vtkQuadricDecimation). Although I do not have analytical expression of my volumetric data, I can numerically evaluate the function value at any arbitrary point (under interpolation limits). Would that be good enough for optimesh optimization?

I have been looking at surface mesh smoothing example in readme, which also uses sphere. Is argument x to class functions f and grad just 3D coordinate in the space? Also is grad supposed to return the gradient at point x as described below? I think even grad can be computed numerically.

image

nschloe commented 3 years ago

Would that be good enough for optimesh optimization?

Yeah, I think that should be alright. grad is the gradient just like you describe, too.