Mesh.IsPointInside() persistent bug


#1

Hi there-

It looks like Mesh.IsPointInside() will occasionally fail, when a test vertex strikes the inclusion mesh precisely on an edge. Writing one from scratch following David’s logic from this thread over on the old GH forum: http://www.grasshopper3d.com/forum/topics/mesh-ispointinside-always-false reproduces the error. I made a quick fix that does a second test based on another arbitrary vector and then determines if the number of intersections for either test is an odd number…doubles the effort, but seems to work. In any event, it’s worth knowing that this bug is persistent.

thanks,

Dave


(Dale Fugier) #2

Hi Dave,

This is a known issue.

https://mcneel.myjetbrains.com/youtrack/issue/RH-10076

I’ll mention this to the developer again.

– Dale


#3

Thanks, Dale! It fails rarely…but does indeed.


#4

This method don’t work at all in my case - http://developer.rhino3d.com/5/api/RhinoCommonWin/html/M_Rhino_Geometry_Mesh_IsPointInside.htm

Mesh is closed also tolerance here no matter if ZeroTolerance / Rhino.RhinoDoc.ActiveDoc.ModelAbsoluteTolerance / 1000 also no change with true or false always is false i wanted to build convexhull so it’s crucial for me.

First i thought that normals here are crucial but they are not :thinking:

Ok method will work if:

mesh.Vertices.CombineIdentical(true, true);
mesh.FaceNormals.ComputeFaceNormals;
mesh.UnifyNormals();
mesh.Normals.ComputeNormals();
mesh.Compact();

First i thought it will work but now i see that it randomly gives different results.

@stevebaer Any recomendations?


(Steve Baer) #5

I’m not sure what your mesh looks like. The algorithm simply creates a line from the test point to a point know to be outside of the mesh. An intersection is run on this line with the mesh and if the number of intersections is an odd number, true is returned. I’m sure there is a more robust approach, but that is what we currently have implemented.

You could try the same test with the MeshLine intersect routine in RhinoCommon.


#6

Thanks @stevebaer for suggestion. I’ll try with MeshLine one. Btw. i’m making quickhull algorithm so there’s a lot of points on edge and that’s probably the issue here.


(Dale Fugier) #7

The Waterman Polyhedra add-on included a QuickHull implementation - and it’s available in Grasshopper…

– Dale


#8

@dale i use GH only for quick prototyping code i needed this in c# and now i have partially with IsPointInside and if something is giving false it just falls to closest point with tolerance quick and dirty workaround but it works finally.