Just to check, you're at least now getting two segments when they are close, but each segment has various visible artifacts? I believe this is to do with the logic in ExpandNarrowbandMask() which attempts to re-activate the relevant narrow band topology relative to each segment. This logic doesn't take into account neighbouring signs, so as long as the absolute value of a neighbouring distance is larger it is included in the segment. This can result in values which belong to a different segment ending up in others.
I've fixed this up and am getting cleaner results - but it's still not guaranteed to give you completely valid SDFs out the box when the boundary sizes are less than 2xthe half width - you will have to continue to rely on a renormalize/rebuild/narrow-band-resize. I think there are more improvements that can be made but at this point I'm considering re-writing it. The way I'd approach this would be:
1) Same as the current algorithm: compute the inside iso surface band masks from the input SDF and topologically split them.
2) Compute the expected narrow band size of our new segments based on the input. Alternatively a desired size could be provided.
3) For each mask:
3a) dilate (by the narrow band size)
3b) Re activate the interior of our mask where the input SDF is active
3c) Union a+b masks into a new float grid and copy over values. For the exterior narrow band, only copy POSITIVE values. If the value isn't positive, set it to positive background and deactivate it.
3d) Flood fill.
Not something I'm able to do at the moment but hope these changes and suggestions help