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: isPointInside_Debug.gh (10.1 KB)
I didn’t look at your definition very closely. But the attached seems to work with your geometry.
TestSunHanshen.gh (11.9 KB)
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.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);
crv planar? How can I duplicate your creation here?
Curve should be planar since it came from the Mesh,getOutline method.
You can find the whole script here: https://github.com/hanshenSun/Hanshen-s_Toolbox/blob/master/MyProject_0624/Make2D_ViewPort.cs
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.
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.
I know it’s been a few years but I highly recommend using ‘ClosestPoint’ instead.
The ‘isPointInside’ just isn’t working as it should, and closest point has a maximum distance that will return a boolean and will serve the same purpose.