From 40e0c60338a5fc17e10a44e671a84efc8413e5ae Mon Sep 17 00:00:00 2001 From: Furgo <148809153+furgo16@users.noreply.github.com> Date: Sat, 22 Mar 2025 15:05:41 +0100 Subject: [PATCH] BIM: move Arch wall tests to their own module --- src/Mod/BIM/CMakeLists.txt | 1 + src/Mod/BIM/TestArch.py | 45 ------------------ src/Mod/BIM/TestArchWall.py | 91 +++++++++++++++++++++++++++++++++++++ 3 files changed, 92 insertions(+), 45 deletions(-) create mode 100644 src/Mod/BIM/TestArchWall.py diff --git a/src/Mod/BIM/CMakeLists.txt b/src/Mod/BIM/CMakeLists.txt index 98756b73b6..5fdb1364fc 100644 --- a/src/Mod/BIM/CMakeLists.txt +++ b/src/Mod/BIM/CMakeLists.txt @@ -27,6 +27,7 @@ SET(Arch_SRCS ArchSpace.py ArchRebar.py TestArch.py + TestArchWall.py ArchFrame.py ArchPanel.py ArchEquipment.py diff --git a/src/Mod/BIM/TestArch.py b/src/Mod/BIM/TestArch.py index 31b6e55e9f..ac9f32b80d 100644 --- a/src/Mod/BIM/TestArch.py +++ b/src/Mod/BIM/TestArch.py @@ -393,51 +393,6 @@ class ArchTest(unittest.TestCase): App.newDocument("ArchTest") App.setActiveDocument("ArchTest") - def testWall(self): - App.Console.PrintLog ('Checking Arch Wall...\n') - l=Draft.makeLine(App.Vector(0,0,0),App.Vector(-2,0,0)) - w = Arch.makeWall(l) - self.assertTrue(w,"Arch Wall failed") - - def testWallMultiMatAlign(self): - App.Console.PrintLog ('Checking Arch Wall with MultiMaterial and 3 alignments...\n') - matA = Arch.makeMaterial() - matB = Arch.makeMaterial() - matMulti = Arch.makeMultiMaterial() - matMulti.Materials = [matA, matB] - matMulti.Thicknesses = [100, 200] # total width different from default 200 - pts = [App.Vector( 0, 0, 0), - App.Vector(1000, 0, 0), - App.Vector(1000, 1000, 0), - App.Vector(2000, 1000, 0)] - # wall based on wire: - wire = Draft.makeWire(pts) - wallWire = Arch.makeWall(wire) - wallWire.Material = matMulti - # wall based on sketch: - sketch = App.activeDocument().addObject('Sketcher::SketchObject','Sketch') - sketch.addGeometry([Part.LineSegment(pts[0], pts[1]), - Part.LineSegment(pts[1], pts[2]), - Part.LineSegment(pts[2], pts[3])]) - wallSketch = Arch.makeWall(sketch) - wallSketch.Material = matMulti - - alignLst = ["Left", "Center", "Right"] - checkLst = [[App.Vector(0, -300, 0), App.Vector(2000, 1000, 0)], - [App.Vector(0, -150, 0), App.Vector(2000, 1150, 0)], - [App.Vector(0, 0, 0), App.Vector(2000, 1300, 0)]] - for i in range(3): - wallWire.Align = alignLst[i] - wallSketch.Align = alignLst[i] - App.ActiveDocument.recompute() - for box in [wallWire.Shape.BoundBox, wallSketch.Shape.BoundBox]: - ptMin = App.Vector(box.XMin, box.YMin, 0) - self.assertTrue(ptMin.isEqual(checkLst[i][0], 1e-8), - "Arch Wall with MultiMaterial and 3 alignments failed") - ptMax = App.Vector(box.XMax, box.YMax, 0) - self.assertTrue(ptMax.isEqual(checkLst[i][1], 1e-8), - "Arch Wall with MultiMaterial and 3 alignments failed") - def testStructure(self): App.Console.PrintLog ('Checking BIM Structure...\n') s = Arch.makeStructure(length=2,width=3,height=5) diff --git a/src/Mod/BIM/TestArchWall.py b/src/Mod/BIM/TestArchWall.py new file mode 100644 index 0000000000..d1ad221533 --- /dev/null +++ b/src/Mod/BIM/TestArchWall.py @@ -0,0 +1,91 @@ +#*************************************************************************** +#* Copyright (c) 2013 Yorik van Havre * +#* * +#* This file is part of the FreeCAD CAx development system. * +#* * +#* 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. * +#* * +#* 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 Library General Public License for more details. * +#* * +#* You should have received a copy of the GNU Library General Public * +#* License along with FreeCAD; if not, write to the Free Software * +#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * +#* USA * +#* * +#***************************************************************************/ + +# Unit tests for the Arch wall module + +import os +import unittest +import Arch +import Draft +import Part + + +class TestArchWall(unittest.TestCase): + + def setUp(self): + # setting a new document to hold the tests + if App.ActiveDocument: + if App.ActiveDocument.Name != "ArchTest": + App.newDocument("ArchTest") + else: + App.newDocument("ArchTest") + App.setActiveDocument("ArchTest") + + def testWall(self): + App.Console.PrintLog ('Checking Arch Wall...\n') + l=Draft.makeLine(App.Vector(0,0,0),App.Vector(-2,0,0)) + w = Arch.makeWall(l) + self.assertTrue(w,"Arch Wall failed") + + def testWallMultiMatAlign(self): + App.Console.PrintLog ('Checking Arch Wall with MultiMaterial and 3 alignments...\n') + matA = Arch.makeMaterial() + matB = Arch.makeMaterial() + matMulti = Arch.makeMultiMaterial() + matMulti.Materials = [matA, matB] + matMulti.Thicknesses = [100, 200] # total width different from default 200 + pts = [App.Vector( 0, 0, 0), + App.Vector(1000, 0, 0), + App.Vector(1000, 1000, 0), + App.Vector(2000, 1000, 0)] + # wall based on wire: + wire = Draft.makeWire(pts) + wallWire = Arch.makeWall(wire) + wallWire.Material = matMulti + # wall based on sketch: + sketch = App.activeDocument().addObject('Sketcher::SketchObject','Sketch') + sketch.addGeometry([Part.LineSegment(pts[0], pts[1]), + Part.LineSegment(pts[1], pts[2]), + Part.LineSegment(pts[2], pts[3])]) + wallSketch = Arch.makeWall(sketch) + wallSketch.Material = matMulti + + alignLst = ["Left", "Center", "Right"] + checkLst = [[App.Vector(0, -300, 0), App.Vector(2000, 1000, 0)], + [App.Vector(0, -150, 0), App.Vector(2000, 1150, 0)], + [App.Vector(0, 0, 0), App.Vector(2000, 1300, 0)]] + for i in range(3): + wallWire.Align = alignLst[i] + wallSketch.Align = alignLst[i] + App.ActiveDocument.recompute() + for box in [wallWire.Shape.BoundBox, wallSketch.Shape.BoundBox]: + ptMin = App.Vector(box.XMin, box.YMin, 0) + self.assertTrue(ptMin.isEqual(checkLst[i][0], 1e-8), + "Arch Wall with MultiMaterial and 3 alignments failed") + ptMax = App.Vector(box.XMax, box.YMax, 0) + self.assertTrue(ptMax.isEqual(checkLst[i][1], 1e-8), + "Arch Wall with MultiMaterial and 3 alignments failed") + + def tearDown(self): + App.closeDocument("ArchTest") + pass