IsPointInside - bug


#1

Dear McNeel,

I found very strange behaviour of Mesh.IsPointInside method.

When the Mesh is made precisely on the grid with precise dimension this method gets really wrong result.
Example: I’ve create Mesh by snap to grid, with 5x10x15 on size.
Then, I’ve created regular grid of points:

and I want to check for the inclusion.
It gives this:

I’v try by GH component and by pure C# method Mesh.IsPointInside. Either strict true nor false with any tolerance help.

But if I will move the mesh or little scale it, its give correct result:

So strange… Could you help me to solve that problem?
I’m using Rhino SR12 (5.12.50810.13095, 08/10/2015) with the newest GH…


(Dale Fugier) #2

Can you post your geometry and some sample source that, that I can run here, that is not working for you?


#3

Hey Dale. Here are my files:

IsPointInsideBug.3dm (30.9 KB)
IsPointInsideBug.gh (17.2 KB)

Mesh is generated based on brep, but replacing it by mesh created in rhino by Mesh Primitives doesn’t change anything.

It is very simple situation. In the GH definition I’ve added rotation of the mesh and moving vector for translate the grid of point. So by just rotating mesh it even just a bit, every think is fine, but if mesh stays in correct place, nicely align to world axes, inclusion test just give mess…

The custom C# component or MeshInclusionTest component return the same result. So I think the Rhionocommon Mesh.IsPointInside() method has error. Changing tolerance doesn’t effect result.


(Dale Fugier) #4

Try using a valid tolerance - something greater than zero.

  private void RunScript(Brep B, Point3d P, ref object A)
  {
    if (null != B && P.IsValid)
    {
      var tol = Rhino.RhinoDoc.ActiveDoc.ModelAbsoluteTolerance;
      A = B.IsPointInside(P, tol, false);
    }
  }

(Sebastian Bialkowski) #5

Dear Dale.

It was while I send you my problem fr the first time. I switch to Rhino6 and problem with IsPointInside function still exist. And it is even worse.
I’ve created mesh which is closed and I think correct, but IsPointInsied still contain the same bug. Playing with the tolerance doesn’t change anything. Just look:

If i rotate point grid and mesh just by 0.00001 of radians I’m getting this:


Which is correct, but I don’t want to rotate my geometry!

I’m also attaching GH file with mesh internalised.IsPointInside_problem.gh (16.8 KB)

Thank you for help