Curve.PlanarClosedCurveRelationship returns wrong result

Hi, i am trying to get relationship between two closed curves. As you can see in drawing, one curve contains the other, but "PlanarClosedCurveRelationship " returns mutualIntersection. Am I missing something? Thanks for help.

                    RegionContainment containment = RegionContainment.AInsideB;
                Curve newCurve = obj.Geometry as Curve;

                Plane plane = new Plane();
                bool planeOp = newCurve.TryGetPlane(out plane);
                if (obj.Id != cutoutObj.Id)
                {
                    containment = Curve.PlanarClosedCurveRelationship(curve, newCurve, plane, 0);
                    switch (containment)
                    {
                        case RegionContainment.AInsideB:
                            allGood = true;
                            break;
                        case RegionContainment.BInsideA:
                            allGood = false;
                            break;
                        case RegionContainment.Disjoint:
                            allGood = false;
                            break;
                        case RegionContainment.MutualIntersection:
                            allGood = false;
                            break;
                    }
                    if (allGood)
                        break;
                }

StructureCurvesOne.3dm (6.6 MB)

Hi @tahirhan, i guess zero is too small, when i use 0.001 tolerance i get AInsideB or BInsideA if i pick the curves in reversed order. With zero i get -1 returned.

_
c.

Maybe best to put here model tolerance so it conforms to the rest of your document.

https://developer.rhino3d.com/api/RhinoCommon/html/P_Rhino_RhinoDoc_ModelAbsoluteTolerance.htm

Actually, i tried with different tolerance values like (0.001, 0.01, 0). ā€œ0ā€ tolerance is from last trying. But i faced with same issue with non-zero values as well. Can you please share the code you tried? maybe i am missing some part?

Hi @tahirhan,

See if this RhinoCommon sample is helpful:

SampleCsTestPlanarCurveContainment.cs

ā€“ Dale

1 Like

Thanks Dale ! I guess problem is about how i get objects.

**Solved by adding tolerance value to TryGetPlane method.