Curve.Contains Fail

Could anyone help me to understand why all of the X points are being returned as Outside the closed curve?


bad-containment.3dm (63.9 KB)

This has me stumped - I am using the ClosedCurve Point Containment test method
https://developer.rhino3d.com/api/rhinocommon/rhino.geometry.curve/contains

I am calling it with Plane.WorldXY and tolerance of 0.001 (I also tried 1)

I suspect the complex polycurve is the cause of the problem but its real CNC geometry. I tried to SimplyfyCrv (no effect) and i have checked there are no short curves.

If I test points along a line at other places within the outer curve it returns Inside.

Hi,
I hope this project serves as inspiration, I think It will help you a lot. You can find a clear usage containtment specifically aimed at CNC cutting (not limited to points, but also curves, 3d breps and so on.

If you need any help you can tag me here.

Farouk

Thanks @farouk.serragedine that looks interesting.
It sounds like we work in a similar space.

I am still keen to know why the RhinoCommon command appears to be failing in this case

Using your model and a recent beta of V8:

This code, using RhinoCommon, returns Inside for your curve and the two points indicated (used commenting to test both). The first point was a click inside the curve I made arbitrarily in the top view. The second point was taken from one of your text dots using the List command.

                   Point3d pt22 = new Point3d(1302.646, 1100.183, 0);
                   Point3d pt33 = new Point3d(1326.6116944876946, 1099.334098, 0);
                   if (crv.Contains(pt33) == PointContainment.Inside)
                   {
                       MessageBox.Show("Point Inside");
                   }
 

Have you tried the other inside checks to see if that might be the issue, such as not passing the plane?

Thank you @Nathan_Bossett I can confirm i am passing XY Plane & a tolerance.

I encountered this with 7SR35 - so maybe it is another bug specific to Rhino 7 which has been fixed by the tuneups to Rhino 8 ?

Anyone able to to test and confirm?

Could be. I haven’t examined it to see if your text dots are all right on the curve and it’s a reasonable difference. If it isn’t a reasonable result:

Here’s the information for your bug report all in one place:
bad-containment.3dm (63.9 KB)

I loaded your drawing in the V7 release candidate and in V8 then ran this script. As shown in the screenshot, it reports Outside for V8 and inside for V7. The only difference is that V8 is read only because I opened V8 after V7.

import Rhino.RhinoDoc as rd
import Rhino.Geometry as rg
import System as sys

id = sys.Guid('4EF0DF88-D38F-4b18-83C1-2C3C4FFBDB20')
b = rd.ActiveDoc.Objects.FindId(id)

c = rg.Point3d(1326.6116944876946, 1099.334098, 0)
if b.Geometry.Contains(c) == rg.PointContainment.Inside:
    print 'inside'
else:
    print 'outside'

1 Like

Thank you @Nathan_Bossett really apprecaite you taking a look at the weekend.

Just to confirm Is Rhino 8 is reporting inside yes?

The points were generated by sampling along the domain of the line.

This geometry is from a larger file from one of our CNC customers.
They seem to have been really unlucky as they have surfaced two Rhino geometry bugs in the same file! (the other is Mystery - Why does Join give an Open Curve? - Rhino / Rhino for Windows - McNeel Forum)

Does look like Rhino 8 resolves both though :slight_smile: good reasons to make the move to .net 7 and upgrade :slight_smile:

Presumably the tuneup for these algorithms won’t reach Rhino 7?

Correct, on my earlier test with copy-pasted code inside my own plugin project and this morning with the scripts I quoted and your data file.

7.35.23280.19001 (RC build)
8.0.23283.13003

As you see in the code, I wasn’t passing planes or tolerances.

I’m not quite sure how the tolerances work, either:
Say that in 2-space you have a line segment along y=0 which is the top of a rectangle.
If you have a point (0,-0.0001) it’s inside the box.

If you specify a tolerance of 0.001, does that expand the area Rhino effectively considers to be:

  1. inside the box
  2. on the line
    or
  3. outside the box

I can see use cases for each, but I don’t think you get to specify and I don’t know what Rhino does.

For anyone else experiencing this, it has been confirmed as a bug by @pedrocortes and logged as RH-77898 It affects Rhino 7 only - it is fixed in Rhino 8