Salome HOME
updated copyright message
[modules/shaper.git] / src / FeaturesPlugin / Test / TestGlueFaces_Solids.py
1 # Copyright (C) 2014-2023  CEA, EDF
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 boxes
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 model.do()
39
40 GlueFaces_1 = model.addGlueFaces(Part_1_doc, [model.selection("SOLID", "Box_1_1"), model.selection("SOLID", "Rotation_1_1")], 1.0e-7, True)
41 model.end()
42
43 # gluing successful
44 model.testCompSolid(GlueFaces_1, [2], [2], [11], [20], [12])
45
46 # =============================================================================
47 # Test 2. Glue faces for 2 solids with 1 common edge only
48 # =============================================================================
49 model.undo() # to reuse Box_1_1, Translation_1_1, and Rotation_1_1
50 model.begin()
51 Param_alfa.setValue(90)
52 model.do()
53
54 GlueFaces_2 = model.addGlueFaces(Part_1_doc, [model.selection("SOLID", "Box_1_1"), model.selection("SOLID", "Rotation_1_1")], 1.0e-7, True)
55 model.end()
56
57 # gluing successful
58 model.testCompound(GlueFaces_2, [2], [2], [12], [23], [14])
59
60 # =============================================================================
61 # Test 3. Glue faces for 2 solids with 2 adjacent faces above default tolerance
62 # =============================================================================
63 model.undo() # to reuse Box_1_1, Translation_1_1, and Rotation_1_1
64 model.begin()
65
66 Param_alfa.setValue(0)
67 Param_dx.setValue(10.0001)
68 model.do()
69
70 GlueFaces_3 = model.addGlueFaces(Part_1_doc, [model.selection("SOLID", "Box_1_1"), model.selection("SOLID", "Rotation_1_1")], 1.0e-7, True)
71 model.end()
72
73 # no faces glued
74 model.testCompound(GlueFaces_3, [2], [2], [12], [24], [16])
75
76 # =============================================================================
77 # Test 4. Glue faces for 2 solids with 2 adjacent faces using different tolerance
78 # =============================================================================
79 model.undo() # to reuse Box_1_1, Translation_1_1, and Rotation_1_1
80 model.begin()
81
82 tol = 1.e-4
83 GlueFaces_4 = model.addGlueFaces(Part_1_doc, [model.selection("SOLID", "Box_1_1"), model.selection("SOLID", "Rotation_1_1")], tol, True)
84 model.end()
85
86 # gluing successful
87 model.testCompSolid(GlueFaces_4, [2], [2], [11], [20], [12])
88
89 # =============================================================================
90 # Test 5. Check Python dump
91 # =============================================================================
92 assert(model.checkPythonDump())