From 53549f8ad75509b1bd9b6796f1e0c7ad47a7db36 Mon Sep 17 00:00:00 2001 From: wwmayer Date: Wed, 10 Jan 2024 14:26:18 +0100 Subject: [PATCH] PD: Add test for helix (#11601) Co-authored-by: Chris Hennes --- src/Mod/PartDesign/CMakeLists.txt | 1 + .../PartDesign/PartDesignTests/TestHelix.py | 60 +++++++++++++++---- src/Mod/PartDesign/TestPartDesignApp.py | 1 + 3 files changed, 49 insertions(+), 13 deletions(-) diff --git a/src/Mod/PartDesign/CMakeLists.txt b/src/Mod/PartDesign/CMakeLists.txt index 6717a59177..a16b52d5ca 100644 --- a/src/Mod/PartDesign/CMakeLists.txt +++ b/src/Mod/PartDesign/CMakeLists.txt @@ -38,6 +38,7 @@ set(PartDesign_TestScripts PartDesignTests/TestShapeBinder.py PartDesignTests/TestPad.py PartDesignTests/TestPocket.py + PartDesignTests/TestHelix.py PartDesignTests/TestHole.py PartDesignTests/TestRevolve.py PartDesignTests/TestLoft.py diff --git a/src/Mod/PartDesign/PartDesignTests/TestHelix.py b/src/Mod/PartDesign/PartDesignTests/TestHelix.py index e93637ec83..a1c13da1d9 100644 --- a/src/Mod/PartDesign/PartDesignTests/TestHelix.py +++ b/src/Mod/PartDesign/PartDesignTests/TestHelix.py @@ -1,21 +1,22 @@ #*************************************************************************** +#* Copyright (c) 2023 Werner Mayer * #* Copyright (c) 2023 * #* * -#* This program is free software; you can redistribute it and/or modify * -#* it under the terms of the GNU Lesser General Public License (LGPL) * -#* as published by the Free Software Foundation; either version 2 of * -#* the License, or (at your option) any later version. * -#* for detail see the LICENCE text file. * +#* This file is part of FreeCAD. * #* * -#* This program is distributed in the hope that it will be useful, * -#* but WITHOUT ANY WARRANTY; without even the implied warranty of * -#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -#* GNU Library General Public License for more details. * +#* FreeCAD is free software: you can redistribute it and/or modify it * +#* under the terms of the GNU Lesser General Public License as * +#* published by the Free Software Foundation, either version 2.1 of the * +#* License, or (at your option) any later version. * #* * -#* You should have received a copy of the GNU Library General Public * -#* License along with this program; if not, write to the Free Software * -#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * -#* USA * +#* FreeCAD is distributed in the hope that it will be useful, but * +#* WITHOUT ANY WARRANTY; without even the implied warranty of * +#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * +#* Lesser General Public License for more details. * +#* * +#* You should have received a copy of the GNU Lesser General Public * +#* License along with FreeCAD. If not, see * +#* . * #* * #*************************************************************************** @@ -23,6 +24,7 @@ from math import pi import unittest import FreeCAD +from FreeCAD import Base import Part import Sketcher import TestSketcherApp @@ -33,6 +35,38 @@ class TestHelix(unittest.TestCase): def setUp(self): self.Doc = FreeCAD.newDocument("PartDesignTestHelix") + def testHelicalTubeCase(self): + body = self.Doc.addObject('PartDesign::Body','Body') + sketch = body.newObject('Sketcher::SketchObject','Sketch') + sketch.Support = (self.Doc.getObject('XY_Plane'),['']) + sketch.MapMode = 'FlatFace' + + geoList = [] + geoList.append(Part.Circle(Base.Vector(-40.0, 0.0, 0.0), Base.Vector(0.0, 0.0, 1.0), 7.5)) + geoList.append(Part.Circle(Base.Vector(-40.0, 0.0, 0.0), Base.Vector(0.0, 0.0, 1.0), 10.0)) + sketch.addGeometry(geoList, False) + del geoList + + sketch.addConstraint(Sketcher.Constraint('PointOnObject', 0, 3, -1)) + sketch.addConstraint(Sketcher.Constraint('Coincident', 1, 3, 0, 3)) + self.Doc.recompute() + + helix = body.newObject('PartDesign::AdditiveHelix','AdditiveHelix') + helix.Profile = sketch + helix.ReferenceAxis = (sketch, ['V_Axis']) + helix.Mode = 0 + helix.Pitch = 35 + helix.Height = 100 + helix.Turns = 3 + helix.Angle = 0 + helix.Growth = 0 + helix.LeftHanded = 0 + helix.Reversed = 0 + + self.Doc.recompute() + self.assertEqual(len(helix.Shape.Solids), 1) + + def testCircleQ1(self): """ Test helix based on circle in Quadrant 1 """ body = self.Doc.addObject('PartDesign::Body','Body') diff --git a/src/Mod/PartDesign/TestPartDesignApp.py b/src/Mod/PartDesign/TestPartDesignApp.py index 3f21e924e6..3668f64614 100644 --- a/src/Mod/PartDesign/TestPartDesignApp.py +++ b/src/Mod/PartDesign/TestPartDesignApp.py @@ -32,6 +32,7 @@ from PartDesignTests.TestShapeBinder import TestSubShapeBinder # additive/subtractive features & primitives from PartDesignTests.TestPad import TestPad from PartDesignTests.TestPocket import TestPocket +from PartDesignTests.TestHelix import TestHelix from PartDesignTests.TestHole import TestHole from PartDesignTests.TestRevolve import TestRevolve from PartDesignTests.TestPipe import TestPipe