c#_Intersection_Brep_(create Notches)

I am trying to create notches at intersection of 2 breps(surfaces). c# script that I have made works fine in case of waffle structure but I’m trying out on different combination where it fails to create proper notches at intersections, script creates notches inside the surface and not on its edges.

for better clarification attaching images and gh file with c#.
I am looking for a logic to solve this issue. Any help in this regard would be great.


cSharp_waffle problem.gh (58.2 KB)

You need to somehow unify all intersection curves’ directions.

Curve extended = c.Extend(CurveEnd.End, tolr * 10000, CurveExtensionStyle.Line);
Point3d end = extended.PointAtEnd;
double distance = end.DistanceTo(s1[i].ClosestPoint(end));
if(distance > tolr * 100)

OmKar.gh (68.9 KB)