Salome HOME
87ae2bd6b793ee81b1c13e619225172a7862bb0f
[modules/shaper.git] / src / FeaturesPlugin / Test / TestGlueFaces_Shell.py
1 # Copyright (C) 2014-2023  CEA/DEN, EDF R&D
2 #
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
7 #
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 # Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19
20 from salome.shaper import model
21
22
23 # Create document
24 model.begin()
25 partSet = model.moduleDocument()
26 Part_1 = model.addPart(partSet)
27 Part_1_doc = Part_1.document()
28 Param_dx = model.addParameter(Part_1_doc, "dx", '10')
29 Param_alfa = model.addParameter(Part_1_doc, "alfa", '0')
30
31 # =============================================================================
32 # Test 1. Glue faces of 2 adjacent shells
33 # =============================================================================
34 Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
35 Box_2 = model.addBox(Part_1_doc, 10, 10, 10)
36 Translation_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_2_1")], axis = model.selection("EDGE", "PartSet/OX"), distance = "dx", keepSubResults = True)
37 Rotation_1 = model.addRotation(Part_1_doc, [model.selection("SOLID", "Translation_1_1")], axis = model.selection("EDGE", "[Box_1_1/Front][Box_1_1/Right]"), angle = "alfa", keepSubResults = True)
38 Shell_1_Objects = [model.selection("FACE", "Box_1_1/Top"), model.selection("FACE", "Box_1_1/Front")]
39 Shell_1 = model.addShell(Part_1_doc, Shell_1_Objects)
40 Shell_2_Objects = [model.selection("FACE", "Rotation_1_1/MF:Rotated&Box_2_1/Top"), model.selection("FACE", "Rotation_1_1/MF:Rotated&Box_2_1/Back")]
41 Shell_2 = model.addShell(Part_1_doc, Shell_2_Objects)
42 model.do()
43
44 GlueFaces_1 = model.addGlueFaces(Part_1_doc, [model.selection("SHELL", "Shell_1_1"), model.selection("SHELL", "Shell_2_1")], 1.0e-7, True)
45 model.end()
46
47 # gluing successful
48 model.testCompound(GlueFaces_1, [2], [0], [3], [10], [8])
49
50 # =============================================================================
51 # Test 2. Glue faces for 2 shells with 1 common edge only
52 # =============================================================================
53 model.undo() # to reuse the 2 shells
54 model.begin()
55 Param_alfa.setValue(90)
56 model.do()
57
58 GlueFaces_2 = model.addGlueFaces(Part_1_doc, [model.selection("SHELL", "Shell_1_1"), model.selection("SHELL", "Shell_2_1")], 1.0e-7, True)
59 model.end()
60
61 # gluing successful
62 model.testCompound(GlueFaces_2, [2], [0], [4], [13], [10])
63
64 # =============================================================================
65 # Test 3. Glue faces for 2 shells with 2 adjacent faces above default tolerance
66 # =============================================================================
67 model.undo() # to reuse the 2 shells
68 model.begin()
69
70 Param_alfa.setValue(0)
71 Param_dx.setValue(10.0001)
72 model.do()
73
74 GlueFaces_3 = model.addGlueFaces(Part_1_doc, [model.selection("SHELL", "Shell_1_1"), model.selection("SHELL", "Shell_2_1")], 1.0e-7, True)
75 model.end()
76
77 # no faces glued
78 model.testCompound(GlueFaces_3, [2], [0], [4], [14], [12])
79
80 # =============================================================================
81 # Test 4. Glue faces for 2 solids with 2 adjacent faces using different tolerance
82 # =============================================================================
83 model.undo() # to reuse Box_1_1, Translation_1_1, and Rotation_1_1
84 model.begin()
85
86 tol = 1.e-4
87 GlueFaces_4 = model.addGlueFaces(Part_1_doc, [model.selection("SHELL", "Shell_1_1"), model.selection("SHELL", "Shell_2_1")], tol, True)
88 model.end()
89
90 # gluing successful
91 model.testCompound(GlueFaces_4, [2], [0], [3], [10], [8])
92
93 # =============================================================================
94 # Test 5. Check Python dump
95 # =============================================================================
96 assert(model.checkPythonDump())