Fastest Way to Compute Sections

What is the fastest way (or least faster way) to compute multiple sections in a Rhino Common plugin?

Here is my current approach:

I have a helper function:

      private IEnumerable<  RG.Curve> Intersect(RG.Plane pln, RG.Brep brep)
      {
          RG.Curve[] crvs;                       
          RG.Intersect.Intersection.BrepPlane(
                      brep,  //objref.Brep(),
                      pln,
                      0.001,
                      out crvs,
                      out RG.Point3d[] pts
                  );
          return crvs;
      }

Then I have a list of BREPS that I want sections through, and I have a list of Planes that define where I want the sections. I’ve been trying this:

            foreach (var b in breps)
            {
                this.planes.AsParallel().Select(
                    pln => Intersect(pln, b)
                ).ToList().ForEach(
                    crvs => { if (null != crvs) { this.sections.AddRange(crvs); } });

            }

this.sections is the list of all curves created through these intersections. No matter which way I do the parallel part (on planes for breps) it is too slow. I’m doing this as part of display conduit and update the sections when one of the sectioned geometries is changed (i.e. control point moved). This is too slow in practice - move a point and wait a few seconds for the sections to update.

In Rhino I’ve tinkered with a few rhino commands to see if there were fast and slow approaches through the UI. The contour command can be quite slow (1.5sec to cut 140 contours through one surface. Defining multiple flat planes at the same spacing and using the intersect command with those and the surface is really quick (a few tenths of a second maybe). So it seems there is a way to do this, I’m just not finding it yet.

Thanks,
Brad

I found that Rhino.Geometry.Intersect.Intersection.MeshPlane has an overload that accepts an list of planes. Is it possible to get a similar overload for Intersection.BrepPlane? I have found that using MeshPlane is faster than repeated calls to BrepPlane even if I have to create the mesh first (though I can often grab the render mesh).

Hi Brad,

Did you try to use a larger tolerance as a means to speedup the calculations.
It can possbly be enough for display purposes to get less accurate sections…

-Willem

You might want to also check this topic:

1 Like