Salome HOME
b060a8e47a888650b90425f4db5e853f56f2446c
[modules/shaper.git] / src / FeaturesPlugin / Test / TestGlueFaces_Faces.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
29 # =============================================================================
30 # Prepare all input shapes
31 # =============================================================================
32 Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
33 Box_2 = model.addBox(Part_1_doc, 10, 10, 10)
34 Translation_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_2_1")], axis = model.selection("EDGE", "PartSet/OX"), distance = 10, keepSubResults = True)
35 Copy_1_objects = [model.selection("FACE", "Box_1_1/Top"),
36                   model.selection("FACE", "Translation_1_1/MF:Translated&Box_2_1/Top"),
37                   model.selection("FACE", "Translation_1_1/MF:Translated&Box_2_1/Left")]
38 Copy_1 = model.addCopy(Part_1_doc, Copy_1_objects, 1)
39 Copy_1.result().setName("Box_1_1_1")
40 Copy_1.results()[1].setName("Translation_1_1_1")
41 Copy_1.results()[2].setName("Translation_1_1_2")
42 model.do()
43
44 # =============================================================================
45 # Test 1. Glue faces of 2 adjacent solids
46 # =============================================================================
47 GlueFaces_1 = model.addGlueFaces(Part_1_doc, [model.selection("SOLID", "Translation_1_1"), model.selection("SOLID", "Box_1_1")], 1e-07, True)
48 model.do()
49
50 # gluing successful
51 model.testCompSolid(GlueFaces_1, [2], [2], [11], [20], [12])
52
53 # =============================================================================
54 # Test 2. Glue faces for 2 faces with 1 common edge only
55 # =============================================================================
56 GlueFaces_2 = model.addGlueFaces(Part_1_doc, [model.selection("FACE", "Box_1_1_1"), model.selection("FACE", "Translation_1_1_1")], 1e-07, True)
57 GlueFaces_2.result().setName("GlueFaces_2_1")
58 GlueFaces_2.result().subResult(0).setName("GlueFaces_2_1_1")
59 GlueFaces_2.result().subResult(1).setName("GlueFaces_2_1_2")
60 model.do()
61
62 # gluing successful
63 model.testCompound(GlueFaces_2, [2], [0], [2], [7], [6])
64
65 # =============================================================================
66 # Test 3. Glue faces for 1 solid and 1 faces with 1 common edge
67 # =============================================================================
68 Recover_1 = model.addRecover(Part_1_doc, GlueFaces_1, [Box_1.result()])
69 GlueFaces_3 = model.addGlueFaces(Part_1_doc, [model.selection("FACE", "Translation_1_1_2"), model.selection("SOLID", "Recover_1_1")], 1e-07, True)
70 GlueFaces_3.result().setName("GlueFaces_3_1")
71 GlueFaces_3.result().subResult(0).setName("GlueFaces_3_1_1")
72 GlueFaces_3.result().subResult(1).setName("GlueFaces_3_1_2")
73 model.end()
74
75 # no faces glued
76 model.testCompound(GlueFaces_3, [2], [1], [7], [15], [10])