Method Brep,IsPointInside is having some strange behavior




I noticed there might be bugs in the Brep.IsPointInside method. See the first image below, the Closed brep is generated by code is im certain that the point is inside, however the method was giving me a false result back no matter whether I set the strictlyInside param to either true or false.

However, when the brep is scaled half of the size to the origin, which in this case the brep is actually FAR away from the evaluated point, this method is giving me a true feedback. I’m confused about this behavior and i’m wondering if this could be some sort of bug?

The script I was using: (10.1 KB)

(Dale Fugier) #2

Hi @Sun_Hanshen,

I didn’t look at your definition very closely. But the attached seems to work with your geometry. (11.9 KB)

– Dale


Hi @dale,

Thanks for you reply. I noticed that we basically had the same script. But the one thing I noticed that were different was the preview of our geometry in grasshopper. Check this out.

Even it was showing as a closed Brep, Grasshopper was rendering the corner with a fillet and causing the isPointInside script to give back false result. However, once I bake the geometry and re-reference it into the grasshopper script, the isPointInside method gives me correct result this time. I wonder if it could be something with the was I was creating geometry?

By the way I created this extrusion this way:

Plane tempPlane;
Plane.FitPlaneToPoints(edgePts, out tempPlane);
Vector3d vectorZ = tempPlane.ZAxis;
double multiplier = 1 / vectorZ.Length;
Vector3d extrudeVector = Vector3d.Multiply(multiplier, vectorZ);

Surface extrusionSrf = Surface.CreateExtrusion(crv, extrudeVector);
Brep extrusionBrep = extrusionSrf.ToBrep();
Brep cappedBrep = extrusionBrep.CapPlanarHoles(0.1);

(Dale Fugier) #4

Hi @Sun_Hanshen,

Is crv planar? How can I duplicate your creation here?

– Dale


Hi @dale,

Curve should be planar since it came from the Mesh,getOutline method.

You can find the whole script here:

the brep.isPointInside method is called around line 518.

I was trying to get the outline of a geometry, and test to see if the midpoint of curve is inside of the extrusion of the outline.

(Dale Fugier) #6

Hi @Sun_Hanshen,

Check the solid orientation of your Brep using Brep.SolidOrientation. You’ll see that it’s normals are pointed inward. Use Brep.Flip to flip the orientation.

– Dale