@@ -343,7 +343,7 @@ def initOperation(self, obj):
343343 )
344344
345345 obj .Colinear = 10.0
346- obj .Discretize = 0.1
346+ obj .Discretize = 0.25
347347 obj .Tolerance = Path .Preferences .defaultGeometryTolerance ()
348348 self .setupAdditionalProperties (obj )
349349
@@ -359,6 +359,12 @@ def buildMedialWires(self, obj, faces):
359359 wires_by_face = dict ()
360360 self .voronoiDebugCache = dict ()
361361
362+ def is_exterior (vertex , face ):
363+ vector = FreeCAD .Vector (vertex .toPoint (face .BoundBox .ZMin ))
364+ (u , v ) = face .Surface .parameter (vector )
365+ # isPartOfDomain is faster than face.IsInside(...)
366+ return not face .isPartOfDomain (u , v )
367+
362368 def insert_many_wires (vd , wires ):
363369 for wire in wires :
364370 Path .Log .debug ("discretize value: {}" .format (obj .Discretize ))
@@ -402,16 +408,17 @@ def insert_many_wires(vd, wires):
402408 else :
403409 e .Color = SECONDARY
404410
411+ # filter our colinear edged so there are fewer ones
412+ # to iterate over in colorExterior which is slow
405413 vd .colorColinear (COLINEAR , obj .Colinear )
406- vd .colorTwins (TWIN )
407414
408415 vd .colorExterior (EXTERIOR1 )
409- vd .colorExterior (
410- EXTERIOR2 ,
411- lambda v : not f . isInside (
412- v . toPoint ( f . BoundBox . ZMin ), obj . Tolerance , True
413- ),
414- )
416+ vd .colorExterior (EXTERIOR2 , lambda v : is_exterior ( v , f ))
417+
418+ # if colorTwin is done before colorExterior we seem to have
419+ # much more weird exterior edges needed to be filtered out,
420+ # keep it here to be safe
421+ vd . colorTwins ( TWIN )
415422
416423 wires = _collectVoronoiWires (vd )
417424 wires = _sortVoronoiWires (wires )
0 commit comments