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:
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:
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.