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