Salome HOME
updated copyright message
[modules/shaper.git] / src / FeaturesPlugin / Test / TestSewing_NonManifold.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", '90')
30
31 # =============================================================================
32 # Test 1. Sew two shells with a single common edge
33 # =============================================================================
34 Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
35 Box_2 = model.addBox(Part_1_doc, 10, 10, 10)
36 Vertex_1 = model.selection("VERTEX", "[Box_1_1/Back][Box_1_1/Left][Box_1_1/Bottom]")
37 Vertex_2 = model.selection("VERTEX", "[Box_1_1/Front][Box_1_1/Left][Box_1_1/Top]")
38 Translation_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_2_1")], startPoint = Vertex_1, endPoint = Vertex_2, keepSubResults = True)
39
40 Shell_1_objects = [model.selection("FACE", "Box_1_1/Top"), model.selection("FACE", "Box_1_1/Front")]
41 Shell_1 = model.addShell(Part_1_doc, Shell_1_objects)
42
43 Shell_2_objects = [model.selection("FACE", "Translation_1_1/MF:Translated&Box_2_1/Back"), model.selection("FACE", "Translation_1_1/MF:Translated&Box_2_1/Bottom")]
44 Shell_2 = model.addShell(Part_1_doc, Shell_2_objects)
45 model.do()
46
47 Sewing_1 = model.addSewing(Part_1_doc, [model.selection("SHELL", "Shell_2_1"), model.selection("SHELL", "Shell_1_1")], 1e-07, allowNonManifold = False, alwaysCreateResult = True)
48 model.end()
49
50 # sewing failed (result is a compound with the two input shells)
51 model.testResults(Sewing_1, 1, [2], [2], [4], [14], [12])
52
53 # =============================================================================
54 # Test 2. Sew the same two shells allowing non-manifold results
55 # =============================================================================
56 model.undo()
57 model.begin()
58
59 Sewing_2 = model.addSewing(Part_1_doc, [model.selection("SHELL", "Shell_2_1"), model.selection("SHELL", "Shell_1_1")], 1e-07, allowNonManifold = True, alwaysCreateResult = True)
60 model.end()
61
62 # sewing successful
63 model.testResults(Sewing_2, 1, [0], [1], [4], [13], [10])