Issue with Rhino.Geometry.Mesh.IsPointInside()

I would like to report this bug on mesh.IsPointInside(). I found other posts mentioning something similar, but they are all quite old and related to rhino 7 (I’m using rhino 8).

To put it simple, mesh.IsPointInside() is returning false-positives; meaning that some points outside the mesh return True.

I believe it’s a bug because if I use brep.IsPointInside() instead, it works as intended.

I created this very simple script and rhino file attached to demonstrate this. If you run the script and select the mesh and points, there’s a row of points outside the mesh that remain intact. However, if you select a polysurface instead, the script finds all outside points correctly.

PS: the script I’m providing is just a simple example. My actual script requires mesh.IsPointInside() and it cannot be replaced by brep.IsPointInside().

DeleteOutsidePoints.py (802 Bytes)

IsPointInside_test.3dm (852.0 KB)

Seems like the mesh command does not like when points are coincident with the mesh.

Hello Roberto,

you’re referring to this group of points that are exactly on the level of the edge, right?

image

If so, I see that this is fixed in RhinoBETA. Could you have a look if it behaves as you expect?

I don’t think it’s that - strictlyIn is True and so points that are at the surface get deleted (are considered outside). Either way, if it’s the first case, I’ll see if the fix for this issue can be backported to 8.

Giulio

giulio@mcneel.com

I tried in Rhino 9 Beta.

Tolerance 0.1, Strict set to False:

This is the file I used:

mesh_inclusion_c.gh (49.2 KB)


But those points don’t exist in Rhino BETA. And the logic is:

if not mesh.IsPointInside(pt, 0.001, True): #strictlyIn=True - notice the 'not'
    delete_points.append(points[pt_index])

This means that they should get deleted, along with the points on the surface.
I do not think anything else is a problem AFAICT, but will wait for OP.

@martinsiegrist I do not see that. What version of BETA? I am testing in today’s. It will come out in a little bit.

I skipped last weeks beta since it did not load my file.

Will download the new Beta asap tomorrow

:face_with_crossed_out_eyes:
Did you report it? Is it the Kangaroo bug?

However, in any case, I think you’ll be happy once you can download the newer one:


I did not report it. The file is so big I can’t share it.

(untelated from thread, but… @martinsiegrist try to break it down to some component: if you do not try to figure out where things go amiss, we are without a report. Without a report, Rhino BETA will likely stay like this)

I know and I try to upload files whenever I can.

There’s another weird one where the Query Model Object component just stops syncronizing. Again super difficult to replicate in a small definition.

Last weeks Beta worked fine until @kike modified the custom preview test component.

@martinsiegrist can you start a new thread and mention @kike there?
(just mention the same, I am sure he’ll try to help)

The custom preview issue should be solved already.

Custom Preview (WIP) - Transform input? - Serengeti (Rhino BETA) - McNeel Forum

Hi everyone, thank you for all the replies.

Just to clarify, I’m talking about this row of points that should be deleted when you ran the script:

And for comparison, those points are indeed deleted if you pick the polysurface instead of the mesh when you ran the script (Rhino.Geometry.Brep.IsPointInside() method).

I’ve seen this behavior in multiple other meshes. It frequently misses just a few rows of points for some reason. These points are usually not on the mesh surface, so I don’t think that is the issue.

I’m currently using Rhino 8 and haven’t tried RhinoBETA yet, so it is possible this has been fixed in rhino 9. Although it looks like the issue is in the method itself, so if rhino 9 uses the same API then the problem will persist, I assume.

I think this now looks as expected in the latest Rhino 9 WIP

@Roberto_Neto going back to the very first post: could you please see if Rhino BETA works the way you need? If it does, I do not promise that I can backport the fix entirely, but certainly I can do something about these cases.

Hey @piac

I downloaded Rhino BETA yesterday and it looks like it works as intended - meaning the InPointInside() function is not producing false-positives as far as I can tell.

The only thing that I noticed is that it is much slower than the rhino 8 version. When I ran it in bigger parts with more points, the difference is significant.

Thanks @Roberto_Neto for the test. I’ll see if I can help either cases. How much is speed important in your calculations? If it’s a matter of success vs failure, we can probably even give you two different functions (fast and simple vs slow and precise).

Hey @piac

I use this function for volume discretization (discretize the volume into a pointcloud), which happens multiple times since the volume of the part changes slightly during the process I created. So I’d say speed is quite important to me.

I think having 2 functions is helpful. I could use the “slow and precise” one for the first discretization, and the “fast and simple” one for the pointcloud updates.

Let’s see. I think I managed to take down the timings. If all goes well, the first two updates should be released today.

RH-98468 Accuracy issue for 8 and 9 BETA.
RH-98522 Speed issue for 9 BETA.