NodeInCode ... "Contour" Doesn't Work On Meshes

So, I tried to invoke the Contour component via NodeInCode (since the GH Contour component seems zillion times faster than the RhinoCommon function Mesh.CreateContourCurves(mesh, plane, tol);)

But the NodeInCode version fails with a Mesh as the Shape input, while it works fine with the “Canvas” version of the component:
image

The code I’m running:

    var contour = Rhino.NodeInCode.Components.FindComponent("Contour");
    if (contour == null) return;      
    string[] warn_msgs;
    
    object[] result = contour.Evaluate(
      new object[] {
        mesh,         // S - shape
        plane.Origin, // P - point
        plane.Normal, // N - Direction
        10.0          // D - Distance between lines
      }, false, out warn_msgs);
      
    if (warn_msgs != null) foreach (var s in warn_msgs) Print(s);
          
    CT = result[0]; // contour curve

The above terminates with result[0] == null and the following warning messages:

Is there anything else I could try? (I tried instantiating the "Contourex" component as well, but no go).

// Rolf

It’s probably faster because it’s one of the few components that are currently multithreaded, as is the same Rhino command. You can do the same to speed it up considerably, given that you have more than a handful of processor cores at your disposition. The more, the merrier!

I have 6 cores (12 threads), and I compared the Component and the RhinoCommon command so that it would only generate one (1) contour, not multiple. The component also doesn’t have the two markings on it indicating it can run in parallel which I think most other parallel processing components has. Therefore I’m not sure so that parallel processing is even involved in the (single contour) comparison.

The RhinoCommon function is extremely slow for single contours, so it can never come even close to the Contour component. It is magnitudes slower for a single contour.

//Rolf

I have 20 cores and 20 threads. My bad, than it’s only the Rhino command that is multithreaded for now.

Using a mesh-plane-intersection instead of the contour method, might be a good idea!

Check this out:

All tests yielded a single contour curve and were done with a world-XY plane intersecting a relatively dense mesh (15162 vertices).

import Rhino.Geometry as rg

plane = rg.Plane.WorldXY

C = rg.Intersect.Intersection.MeshPlane(M, plane)

Also, only the Contour (ex) component (second from above) seems to be faster.

Yes, that Intersection function was super fast! Less than one ms, wow.

Why didn’t I look for an intersection myself… ? Thank you for the hint!


EDIT: Although the NodeInCode problem wasn’t solved, at least the speedy Contour problem was solved, for now, so I checked the Solution button.

// Rolf

You’re welcome.