From 6de9183dad35ae03716c3cffd50d2c2807f39978 Mon Sep 17 00:00:00 2001 From: paullee0 Date: Mon, 18 Mar 2019 02:43:29 +0800 Subject: [PATCH] Fix findIntersection() can't find coincident points due to overspecifying Precision by user - Cap Precision in precision() --- src/Mod/Draft/DraftGeomUtils.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Mod/Draft/DraftGeomUtils.py b/src/Mod/Draft/DraftGeomUtils.py index d963e62a3f..00c0b9bde6 100644 --- a/src/Mod/Draft/DraftGeomUtils.py +++ b/src/Mod/Draft/DraftGeomUtils.py @@ -47,7 +47,14 @@ params = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Draft") def precision(): "precision(): returns the Draft precision setting" - return params.GetInt("precision",6) + # Set precision level with a cap to avoid overspecification that:- + # 1 - whilst it is precise enough (e.g. that OCC would consider 2 points are conincident) (not sure what it should be 10 or otherwise); + # 2 - but FreeCAD / OCC can handle 'internally' (e.g. otherwise user may set something like 15 that the code would never consider 2 points are coincident as internal float is not that precise); + + precisionMax = 10 + precisionInt = params.GetInt("precision",6) + precisionInt = (precisionInt if precisionInt <=10 else precisionMax) + return precisionInt #return params.GetInt("precision",6) def vec(edge): "vec(edge) or vec(line): returns a vector from an edge or a Part.LineSegment" @@ -346,7 +353,7 @@ def findIntersection(edge1,edge2,infinite1=False,infinite2=False,ex1=False,ex2=F center = arc.Curve.Center int = [] - # first check for coincident endpoints + # first check for coincident endpoints # Should also check if endpoints are within 'tolerence' to consider conincident (against precision level set) here? if (pt1 in [pt3,pt4]): if findAll: int.append(pt1)