From aba904f1e2cae65cf2be993cc3544429cf3df23d Mon Sep 17 00:00:00 2001 From: vocx-fc Date: Tue, 2 Jun 2020 09:28:21 -0500 Subject: [PATCH] Draft: move more functions to draftgeoutils.general --- src/Mod/Draft/DraftGeomUtils.py | 41 +---------------------- src/Mod/Draft/draftgeoutils/general.py | 46 ++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 40 deletions(-) diff --git a/src/Mod/Draft/DraftGeomUtils.py b/src/Mod/Draft/DraftGeomUtils.py index 35bdef6e82..607cf8ac0a 100644 --- a/src/Mod/Draft/DraftGeomUtils.py +++ b/src/Mod/Draft/DraftGeomUtils.py @@ -257,46 +257,7 @@ from draftgeoutils.faces import removeSplitter # circle functions ********************************************************* -def getBoundaryAngles(angle, alist): - """returns the 2 closest angles from the list that - encompass the given angle""" - negs = True - while negs: - negs = False - for i in range(len(alist)): - if alist[i] < 0: - alist[i] = 2*math.pi + alist[i] - negs = True - if angle < 0: - angle = 2*math.pi + angle - negs = True - lower = None - for a in alist: - if a < angle: - if lower is None: - lower = a - else: - if a > lower: - lower = a - if lower is None: - lower = 0 - for a in alist: - if a > lower: - lower = a - higher = None - for a in alist: - if a > angle: - if higher is None: - higher = a - else: - if a < higher: - higher = a - if higher is None: - higher = 2*math.pi - for a in alist: - if a < higher: - higher = a - return (lower,higher) +from draftgeoutils.general import getBoundaryAngles # These functions are not imported because they are incomplete; diff --git a/src/Mod/Draft/draftgeoutils/general.py b/src/Mod/Draft/draftgeoutils/general.py index 3c273afa28..74a00c9a63 100644 --- a/src/Mod/Draft/draftgeoutils/general.py +++ b/src/Mod/Draft/draftgeoutils/general.py @@ -293,3 +293,49 @@ def findClosest(base_point, point_list): npoint = n return npoint + + +def getBoundaryAngles(angle, alist): + """Return the 2 closest angles that encompass the given angle.""" + negs = True + while negs: + negs = False + for i in range(len(alist)): + if alist[i] < 0: + alist[i] = 2*math.pi + alist[i] + negs = True + if angle < 0: + angle = 2*math.pi + angle + negs = True + + lower = None + for a in alist: + if a < angle: + if lower is None: + lower = a + else: + if a > lower: + lower = a + + if lower is None: + lower = 0 + for a in alist: + if a > lower: + lower = a + + higher = None + for a in alist: + if a > angle: + if higher is None: + higher = a + else: + if a < higher: + higher = a + + if higher is None: + higher = 2*math.pi + for a in alist: + if a < higher: + higher = a + + return lower, higher