I’m currently facing some performance issues and would appreciate your insights. (Apologies in advance for not including a file.)
The issue arises when I offset a Brep face and then unroll it. I ran a small test comparing the performance of unrolling with and without the offset step. The results were quite different:
With offset: ~960 ms
Without offset: ~170 ms
The Brep faces themselves are relatively simple, mostly partial cylindrical surfaces (blue/green in the model).
var offset = Brep.CreateFromOffsetFace(face.Face3D, offsetDistance,
Tollerances.AbsoluteTolerance, false, false);
//When i dont offset the unroller is way faster
//Also when i set the offset distance to 0, still same problem
var unroller = new Rhino.Geometry.Unroller(offset);
unroller.AbsoluteTolerance = Tollerances.AbsoluteTolerance;
var edgeIdList = new List<Guid>();
var edgeList3d = new List<Curve>();
var normalAtEdge = new List<Vector3d>();
var results = unroller.PerformUnroll(out var curves2D, out _, out _);
Has anyone experienced similar behavior or knows why the offset step causes such a significant slowdown? Any suggestions on how to improve the performance would be greatly appreciated.
my guess:
it makes a huge difference if the surfaces are trimmed / untrimmed …
i internalized a shrunk and default / filletEdge Geometry in above .gh.
also tolerances might cause issues.
@felix.brunold
provide some geometry
what tolerance are you using ?
try to
_shrinkTrimmedSrfToEdge
before you run the test.
use Stopwatch inside your code to figure out wether it is Brep.CreateFromOffsetFace or unroller.PerformUnroll.
Based on your suggestions, I did some further testing and found that ShrinkFaces() made a significant difference in performance… that definitely helped!
Regarding tolerances: I was previously using the document’s absolute tolerance. However, I noticed that setting the tolerance to 0 shaved off a few more milliseconds. I still need to test whether this holds up well in edge cases, but it looks promising so far. Thanks guys
another approach:
my guess - rhino does not have a special method to offset cylindrical surfaces.
But offsetting a cylindrical surface can be done by scale2d.
below approach is 3-5% faster for the shrunk surfaces
and 30% faster for un-shrunk surfaces
you may also consider parallel.for to do the offset. Rhino is not very suitable for Multi-Threading check this forum.