Splitting brep faces along isocurves in place

The RhinoCommon API has the function BrepFaceList.SplitKinkyFace for splitting a face along its kinks in place. How should I split a brep face along an isocurve in place? I’d like to provide a u-parameter and split the brep face into two brep faces with a new edge where the u-parameter’s isocurve is.

Thanks.

Hi @Russell_Emerine,

Something like this would work:

static Brep SplitFaceAtU(Brep brep, int faceIndex, double u, double tolerance)
{
  var face = brep.Faces[faceIndex];
  // Direction 1 = u stays constant, v varies
  var iso = face.IsoCurve(1, u);
  if (iso == null)
    return null;
  return face.Split(new[] { iso }, tolerance);
}

– Dale

This works! The documentation for BrepFace.Split says “Returns: A brep consisting of all the split fragments, or null on failure.” So, I was expecting the result to have just the split fragments corresponding to the original face and not the rest of the brep that the face was part of. I’d appreciate it if you’d reword the documentation to make that clear.

I have a couple of follow-up questions:

  • I expect you should always use IsoCurve instead of TrimAwareIsoCurves for this. Is that correct?
  • Do the face indices from the original brep still work on the result brep? By which I mean the new split faces are appended to the end of the face list, and the original face is still in the face list but unused.
  • Should I call Brep.Compact afterwards?
  • Does this clone the whole brep? It usually won’t matter but I’d like to know in case it ever becomes a performance consideration since I might split faces repeatedly.

Hi @Russell_Emerine,

Glad it works. I’ll get the BrepFace.Split documentation updated.

IsoCurve or TrimAwareIsoCurve? Either works. The split only uses the part of the curve that lies on the face, so the untrimmed IsoCurve is fine. TrimAwareIsoCurve returns just the pieces inside the trim, which is what the SplitFace command uses.

Face indices. Unchanged faces keep their indices. The original index isn’t left empty: one of the split pieces stays at the original index, and any other pieces are added at the end. Edge and trim indices can change.

Compact. Not needed. Split already compacts the result before returning it, so calling Brep.Compact again changes nothing.

Cloning. Yes. It duplicates the whole brep, including the surface of the face being split. If you split repeatedly, it’s cheaper to collect all the isocurves for a face and pass them to one Split call.

– Dale