I’m trying to unroll a Brep in vb.net, or more accurately I’m trying to check if it is unrollable.
My issue is that the relativeTolerance does not seem to be taken in account, and a sligtly non linear edge always fail to unroll, while the same Brep is unrolled properly with rhino command using the same tolerance.
Do you have any idea on how to fix this?
Here is my code:
<System.Runtime.CompilerServices.Extension> Public Function IsUnrollable(ByVal B As Brep, Optional ByVal tolerance As Double = 0.01) As Boolean Dim U As New Rhino.Geometry.Unroller(B) U.RelativeTolerance = tolerance Dim unrolledBreps As New List(Of Brep) Return U.PerformUnroll(unrolledBreps) > 0 End Function
and my test command:
Protected Overrides Function RunCommand(ByVal doc As RhinoDoc, ByVal mode As RunMode) As Result For Each obj As RhinoObject In doc.Objects.FindByObjectType(DocObjects.ObjectType.Brep) Dim MyBrepObj As BrepObject = TryCast(obj, BrepObject) 'Color in green is unrollable, red otherwise MyBrepObj.Attributes.ColorSource = ObjectColorSource.ColorFromObject If MyBrepObj.BrepGeometry.IsUnrollable(0.3) Then MyBrepObj.Attributes.ObjectColor = Color.Green Else MyBrepObj.Attributes.ObjectColor = Color.Red End If MyBrepObj.CommitChanges() Next doc.Views.Redraw() Return Result.Success End Function
I’m attaching a sample model: Bug-Unroll.3dm (38.4 KB)