MeshInspector / MeshLib

Mesh processing library
https://meshinspector.com
Other
477 stars 53 forks source link

measure thickness #2992

Closed feifeizuo closed 1 month ago

feifeizuo commented 1 month ago

Hi, Thank you very much for providing the ray method to calculate the mesh thickness in the computeThicknessAtVertices function. In general, a more accurate method of maximum inscribed sphere (MIS) can also be used to calculate the mesh thickness, refer to the Paper https://www.cad-journal.net/files/vol_13/CAD_13 (2) _2016_199 -207.pdf . At the same time, both the MIS method and the ray method are implemented in the trimesh library. It would be very helpful if the MIS method could be implemented.

thanks

Grantim commented 1 month ago

Hello!

Thanks for the suggestion and the link (unfortunately it is 404, could you please update it). We will research into this and discuss with the team.

feifeizuo commented 1 month ago

this paper : Shrinking sphere: A parallel algorithm for computing the thickness of 3D objects

Fedr commented 1 month ago

Thanks for the suggestion. We have implemented it in MeshLib, see MeshLib\source\MRMesh\MRMeshThickness.h:


/// returns the thickness at each vertex as the diameter of the inscribed sphere
[[nodiscard]] MRMESH_API std::optional<VertScalars> computeInSphereThicknessAtVertices( const Mesh& mesh,
    const InSphereSearchSettings & settings, const ProgressCallback & progress = {} );

Comparison. Ray method: image

Maximum inscribed sphere method: image

tobias-scheepers commented 1 week ago

Hi @Fedr this looks great. Any chance of exposing this to python also? Are there any downsides to this function as opposed to the original ray-casting method?

Fedr commented 1 week ago

Hi @tobias-scheepers,

Both methods are already exposed to python, please look for computeRayThicknessAtVertices and computeInSphereThicknessAtVertices functions there.

Ray-casting method always returns same or larger value compared to inscribed-sphere method, and ray-casting is typically much faster. And the difference is drastic in peak-like vertices, where inscribed-sphere method returns very small number (where the sphere touches the nearest neighbour vertex). So please select one of the methods based on your need.