I am trying to join 3 breps. I make sure their normals point in directions such that when joined, they should form a closed brep (polysurface) with all normals pointing outwards. However, occasionally I end up with an inside out polysurface.
As a fix, I’ve tried using “IsPointInside” to see if it is inside out, and then using “flip”, but this does not seem to work. Another workaround I started trying was to explode the inside out brep, get the surfaces, convert these to breps, flip these breps, retrim them and then join it all back together but I wasn’t having any luck and there must be an easier way. Any suggestions?
Thanks,
Sam
p.s. I tried to upload an example but the progress percentage counter only seems to get up to 10% or something before giving up. Maybe 16mb is too big…
It’s not so much a problem with logic for deciding to flip, but that the rhinocommon Flip() function doesn’t seem to worked on solid breps. Perhaps there is another way to flip and inverted solid?
I tried JoinedBrep.Faces.Flip but that doesn’t do it, so then I was trying to flip the faces and then use them to create a new brep, but then I have to deal with retrimming and I’m not having any luck…
I still can’t seem to upload my 3dm file with the inside out brep example I’m trying to do this for, so below is a drop box link instead. If someone could write a function to turn this thing right side out, I’d be grateful.
Hi Sam, the problem is that Rhino thinks this is not inside-out. You can see by exploding and joining in Rhino. The result still has normals facing inward, and that shouldn’t be the case. I’ll see if I can fix that.
There is a problem with one of your surfaces. See the attached. Your file tolerance is 0.001, but this surface has an edge that is out of tolerance by 800 times that much. The inside-out checker Does pretty much what you were doing. It picks a point outside of the bounding box of the solid, shoots a ray at the solid, takes the closest hit point on the solid and compares the normal of the hit surface to the ray direction.
In this case, by bad luck, the ray gets shot right through the gap along that edge and hits the side surface from the inside, rather than the top surface from the outside.