From a1a6f1800837325b86deced6e1323433f23037fb Mon Sep 17 00:00:00 2001 From: Roy-043 <70520633+Roy-043@users.noreply.github.com> Date: Mon, 29 Jul 2024 18:05:01 +0200 Subject: [PATCH] Draft: Fix snap intersection hang (#15612) Fixes #13797. The code as suggested by @alafr works fine and has basically been implemented. --- src/Mod/Draft/draftgeoutils/intersections.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/Mod/Draft/draftgeoutils/intersections.py b/src/Mod/Draft/draftgeoutils/intersections.py index db9d7f718b..676424393e 100644 --- a/src/Mod/Draft/draftgeoutils/intersections.py +++ b/src/Mod/Draft/draftgeoutils/intersections.py @@ -48,7 +48,7 @@ def findIntersection(edge1, edge2, """Return a list containing the intersection points of 2 edges. You can also feed 4 points instead of `edge1` and `edge2`. - If `dts` is used, `Shape.distToShape()` is used, which can be buggy. + If `dts` is used, `Shape.section()` is used. """ def getLineIntersections(pt1, pt2, pt3, pt4, infinite1, infinite2): @@ -104,24 +104,20 @@ def findIntersection(edge1, edge2, else: return [] # Lines aren't on same plane + tol = pow(10, -precision()) + # First, check bound boxes if (isinstance(edge1, Part.Edge) and isinstance(edge2, Part.Edge) and (not infinite1) and (not infinite2)): bb1 = edge1.BoundBox - bb1.enlarge(pow(10, -precision())) # enlarge one box to account for rounding errors + bb1.enlarge(tol) # enlarge one box to account for rounding errors if not bb1.intersect(edge2.BoundBox): return [] # bound boxes don't intersect - # First, try to use distToShape if possible + # First, try to use Shape.section if possible if (dts and isinstance(edge1, Part.Edge) and isinstance(edge2, Part.Edge) and (not infinite1) and (not infinite2)): - dist, pts, geom = edge1.distToShape(edge2) - sol = [] - if round(dist, precision()) == 0: - for p in pts: - if p[0] not in sol: - sol.append(p[0]) - return sol + return [v.Point for v in edge1.section((edge2), tol).Vertexes] pt1 = None