Rhino.Geometry.Brep.MergeSurfaces does not work closing to a pipe geometry

I’m facing a problem with the Rhino.Geometry.Brep.MergeSurfaces method while merging surfaces obtained by SubD MultiPipe component. The goal is to obtain a single NURBS surface per branch that will be used to extract isocurves down the line. The MergeSurfaces method works well when merging the first two of the three surfaces for each branch, resulting in an untrimmed surface as expected. However, when I attempt to merge the last surface with the previously merged surface to obtained a “pipe” surface, I always get a None/Null result for the merge operation.

I am out of ideas for why this might be happening and would deeply appreciate any input on why or how to work around this issue altogether.

Thanks in advance!

mergeSurface.gh (202.9 KB)

MergeSurfaces(brep, brep, double, double) does not work with closed surfaces, it does not decide which edge to merge when the input surfaces share more than one edge. This is what happens when you are trying to do the second merge.

You can use MergeSurfaces(Brep brep0, Brep brep1, double tolerance, double angleToleranceRadians, Point2d point0, Point2d point1, double roundness, bool smooth), and pass it 2D points on the surfaces that are close to the edges you want to merge. Try running the _MergeSrf command manually (without pre-selecting the surfaces) to get an idea of how that point pick works.

Because of the sharp corner in the merged surface at the node, you will also need to use smooth = False and roundness = 0.0 if you want the merged surface to cover that area. In your example, you can see the merged surfaces are rounded close to the node, making a small gap with neighboring surfaces.

Depending on the output of _MultiPipe, you might also run into cases where some surfaces extend further from the node than others (see picture below). In that case, you will also have to figure out that these small surfaces (3) need to be merged with the ones after them (1), further from the node, before being able to merge surfaces (2) around the pipe.

That last point is difficult to solve programmatically, especially after the conversion to NURBS as you cannot use the SubD topology anymore to figure out how the patches are organized. This might be more of a manual process. It might also be easier without the packedFaces option in _ToNURBS, this way you know you only have to deal with one row of surfaces round the pipe.

1 Like

Thanks Pierre!

Using Point2d inputs worked perfectly for my application. As you suggested, setting roundness to 0 and ad smooth to False gave the results I was seeking.

Below I’m sharing the gh file with my solution for future reference.
mergeSurface_solved.gh (100.3 KB)