PD: Harmonize ExternalInvoluteGear and InternalInvoluteGear

There has been lots of duplicated code between those two, and the recent
changed introduced even more copy/paste code. This commit consolidates
both implementations. The two "public" entry points, `CreateExternalGear`
and `CreateInternalGear` have been kept and now call a shared helper.
This commit is contained in:
Jonas Bähr
2023-03-11 22:42:13 +01:00
committed by Uwe
parent b3ab9c1c3c
commit 4eafedb20f
2 changed files with 234 additions and 237 deletions

View File

@@ -23,6 +23,7 @@ import unittest
import pathlib
import FreeCAD
from FreeCAD import Vector
from Part import makeCircle, Precision
import InvoluteGearFeature
@@ -60,6 +61,25 @@ class TestInvoluteGear(unittest.TestCase):
self.assertSuccessfulRecompute(gear)
self.assertClosedWire(gear.Shape)
def testExternalGearProfileOrientation(self):
gear = InvoluteGearFeature.makeInvoluteGear('TestGear')
self.assertSuccessfulRecompute(gear)
tip_diameter = (gear.NumberOfTeeth + 2 * gear.AddendumCoefficient) * gear.Modules
delta = 0.01 # yes, we do not reach micrometer precision
tip_probe = makeCircle(delta, Vector(tip_diameter/2, 0, 0))
self.assertIntersection(gear.Shape, tip_probe,
msg=f"First tooth tip does not lay on the positive X-axis")
def testInternalGearProfileOrientation(self):
gear = InvoluteGearFeature.makeInvoluteGear('TestGear')
gear.ExternalGear = False
self.assertSuccessfulRecompute(gear)
tip_diameter = (gear.NumberOfTeeth - 2 * gear.AddendumCoefficient) * gear.Modules
delta = 0.01 # yes, we do not reach micrometer precision
tip_probe = makeCircle(delta, Vector(tip_diameter/2, 0, 0))
self.assertIntersection(gear.Shape, tip_probe,
msg=f"First tooth tip does not lay on the positive X-axis")
def testCustomizedGearProfile(self):
gear = InvoluteGearFeature.makeInvoluteGear('InvoluteGear')
z = 12