New Brep.Split overrides added to SR13

There are three new Brep.Split overrides included with RhinoCommon for Rhino 6 SR13:

// Splits a Brep into pieces using Breps as cutters.
Brep[] Brep.Split(
  IEnumerable<Brep> cutters, 
  double intersectionTolerance
);

// Splits a Brep into pieces using curves, 
// at least partially on the Brep, as cutters.
Brep[] Brep.Split(
  IEnumerable<Curve> cutters, 
  double intersectionTolerance
);

// Splits a Brep into pieces using a combination of curves, 
// to be extruded, and Breps as cutters.
Brep[] Brep.Split(
  IEnumerable<GeometryBase> cutters, 
  Vector3d normal, 
  bool planView, 
  double intersectionTolerance
);

Rhino 6 SR13 Release Candidate Available

Give 'em a try and just us know how it goes.

Thanks,

– Dale

4 Likes

I’m calling the second one and I’m getting occasional inconsistencies.
The curves are from Brep.Faces[i].IsoCurve() so I trust they are pretty close to complete overlap on the Brep. Yet some of them miss.

image

Hi @Will_Wang,

Did you try the “third one?” Feel free to post a model.

– Dale

Is the Vector3d parameter the face normal? It worked better on flat faces but when it comes to warped faces not so much.


Can I send a file to you in DM?

EDIT:
I’ve found that I can use the Brep.Faces[i].Split() instead and it seems to produce the best results so far.

Hello,
I too seem to get inconsistencies if I am trying to split a surface with intersecting curves or breps. it seems like the surface will split multiple times as long as the cutters don’t intersect. If the cutters do intersect then only one direction of cuts will be effective and the other direction will be ignored.

The third option does seem to work but as @Will_Wang notes non-planar is trickier given the added normal variable.

It would be nice if the options for multiple intersecting curves or Breps would work as well as option 3.

Thanks

Hi @NavArch,

There isn’t anything we can do without sample models + source code, that we can run here to reproduce what you are seeing , that does not work the way you want.

Thanks,

– Dale

@dale,
I’ve attached a sample file that I want to split at all intersections.
I’ve attached my script which completely splits the surfaces. When I try to split using the other options I don’t get a complete split of all surfaces.
brep_split-test.3dm (68.3 KB)
SplitAtIntersections_01_cmd.py (3.6 KB)

Hi @NavArch,

Just curious, does this work too?

import System
import System.Collections.Generic.IEnumerable as IEnumerable
import Rhino
import scriptcontext as sc

def test_brep_split():
    
    prompt = 'Select all surfaces and polysurfaces to split'
    filter = Rhino.DocObjects.ObjectType.Surface | Rhino.DocObjects.ObjectType.PolysrfFilter
    rc, objrefs = Rhino.Input.RhinoGet.GetMultipleObjects(prompt, False, filter)
    if rc != Rhino.Commands.Result.Success:
        return
        
    breps = [objref.Brep() for objref in objrefs]
    tol = sc.doc.ModelAbsoluteTolerance
    
    for i in range(0, len(breps)):
        temp = breps[:]
        brep = temp.pop(i)
        pieces = brep.Split.Overloads[IEnumerable[Rhino.Geometry.Brep], System.Double](temp, tol)
        [sc.doc.Objects.AddBrep(piece) for piece in pieces]
    
    [sc.doc.Objects.Delete(objref, True) for objref in objrefs]
    sc.doc.Views.Redraw()

test_brep_split()

– Dale

1 Like

If I understand how your script is different than what I sent I think I see where my code may have been causing the issue. I’ll work the problem some more and get back if I’m still thinking there is an issue.

For anyone who might come behind and use Dales script, note one caveat that it will delete any breps that aren’t split.

@Dale,

So I was able to improve my script SplitAtIntersections_02_cmd.py (3.1 KB) to run better after looking at yours, but I am still finding that splitting a brep with intersecting curves is still failing. I can split a brep in one direction but need to re-run my script to get the opposing direction splits to split.

I can get your script to split all intersecting breps in the first run, but it is much slower than my script when I start trying to process hundreds of surfaces at a time. For some reason I can run my script twice and still be done faster than your script.

Am I doing something wrong that my script won’t work like your brep splitting script?

Hi @NavArch,

Have you tried using this Brep.Split override?

https://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Geometry_Brep_Split_4.htm

Sorry, no ideas on this other than the low-level split code is doing something else/different. Is the time differential enough not to use it? How often do you need to do this?

– Dale

@Dale,
I had gotten the override to work previously but must of not had all the settings right. I just tried it again with the updated algorithm based on your code and it seems to work more robustly. However, I do get some weird splits on no-planar surfaces, because I’m having to select the vector as the surface normal at the middle of the surface U,V (0.5,0.5), which is fine for planar surfaces but not so much on non-planar ones. Right now the Brep.Split(curves) method still seems to produce the most reliable results, even if I have to run it twice.

Concerning speed, there is a drastic difference between the codes. Minutes versus over an hour for larger selections. I don’t use the script every day, but at that time difference its still worth figuring out the fastest solution.
Thanks
Ian