libigl icon indicating copy to clipboard operation
libigl copied to clipboard

orient_outward for non-convex shapes

Open jdumas opened this issue 5 years ago • 10 comments

I was looking at the code for igl::orient_outward() and it strikes me as odd to use the centroid to decide the orientation of the patch. I should work only for convex shapes, or at least surfaces whose centroid lies in its interior (also why isn't the centroid simply computed as V.colwise().mean()? Am I missing anything?).

My suggestion would be to first orient the patch coherently using bfs_orient(), and then use the signed volume of the mesh to decide whether to flip or not. Computing the signed volume of the mesh can be done by summing up the signed volume of the tets made by each triangle and the origin (or maybe the centroid for better stability).

Also the formula for the signed volume of a tet is pretty simple dot(p2 - p1, cross(p3 - p1, p4 - p1)) / 6.0;. Is there a reason for igl::volume() to compute a lot of square roots? Better stability maybe?

jdumas avatar Aug 28 '18 13:08 jdumas