Salome HOME
Remove coding information from the python scripts due to tuleap issue #16806
[modules/shaper.git] / src / FeaturesPlugin / Test / TestRemoveSubShapes3.py
1 # Copyright (C) 2014-2019  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 model.begin()
23 partSet = model.moduleDocument()
24
25 # =============================================================================
26 # Test 1. Remove face from shell
27 # =============================================================================
28 Part_1 = model.addPart(partSet)
29 Part_1_doc = Part_1.document()
30
31 Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 5, 10)
32 Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Cylinder_1_1/Face_1")])
33 Face_2 = model.addFace(Part_1_doc, [model.selection("FACE", "Cylinder_1_1/Face_1")])
34 Translation_1 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Face_2_1")], model.selection("EDGE", "PartSet/OZ"), 10)
35 Shell_1 = model.addShell(Part_1_doc, [model.selection("FACE", "Translation_1_1"), model.selection("FACE", "Face_1_1")])
36
37 Remove_SubShapes_1 = model.addRemoveSubShapes(Part_1_doc, model.selection("SHELL", "Shell_1_1"))
38 Remove_SubShapes_1.setSubShapesToRemove([model.selection("FACE", "Shell_1_1/Modified_Face&Face_2_1/Face_2_1")])
39 model.do()
40
41 model.checkResult(Remove_SubShapes_1, model, 1, [0], [0], [1], [4], [8])
42 model.testHaveNamingSubshapes(Remove_SubShapes_1, model, Part_1_doc)
43
44 # =============================================================================
45 # Test 2. Remove faces from compound
46 # =============================================================================
47 Part_2 = model.addPart(partSet)
48 Part_2_doc = Part_2.document()
49
50 Cylinder_1 = model.addCylinder(Part_2_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 5, 10)
51 Face_1 = model.addFace(Part_2_doc, [model.selection("FACE", "Cylinder_1_1/Face_1")])
52 LinearCopy_1 = model.addMultiTranslation(Part_2_doc, [model.selection("FACE", "Face_1_1")], model.selection("EDGE", "PartSet/OZ"), 10, 2)
53 LinearCopy_2 = model.addMultiTranslation(Part_2_doc, [model.selection("COMPOUND", "LinearCopy_1_1")], model.selection("EDGE", "PartSet/OZ"), 20, 2)
54
55 Remove_SubShapes_2 = model.addRemoveSubShapes(Part_2_doc, model.selection("COMPOUND", "LinearCopy_2_1"))
56 Remove_SubShapes_2.setSubShapesToRemove([model.selection("FACE", "LinearCopy_2_1_2_2"), model.selection("FACE", "LinearCopy_2_1_2_1")])
57 model.do()
58
59 model.checkResult(Remove_SubShapes_2, model, 1, [2], [0], [2], [8], [16])
60 model.testHaveNamingSubshapes(Remove_SubShapes_2, model, Part_2_doc)
61
62 # =============================================================================
63 # Test 3. Remove solid from compsolid
64 # =============================================================================
65 Part_3 = model.addPart(partSet)
66 Part_3_doc = Part_3.document()
67
68 Box_1 = model.addBox(Part_3_doc, 10, 10, 10)
69 LinearCopy_1 = model.addMultiTranslation(Part_3_doc, [model.selection("SOLID", "Box_1_1")], model.selection("EDGE", "PartSet/OY"), 10, 6)
70 CompSolid_1_objects = [model.selection("SOLID", "LinearCopy_1_1_1"), model.selection("SOLID", "LinearCopy_1_1_2"), model.selection("SOLID", "LinearCopy_1_1_3"), model.selection("SOLID", "LinearCopy_1_1_4"), model.selection("SOLID", "LinearCopy_1_1_5"), model.selection("SOLID", "LinearCopy_1_1_6")]
71 CompSolid_1 = model.addCompSolid(Part_3_doc, CompSolid_1_objects)
72
73 Remove_SubShapes_3_objects = [model.selection("SOLID", "CompSolid_1_1_3"), model.selection("SOLID", "CompSolid_1_1_4")]
74 Remove_SubShapes_3 = model.addRemoveSubShapes(Part_3_doc, model.selection("COMPSOLID", "CompSolid_1_1"))
75 Remove_SubShapes_3.setSubShapesToRemove(Remove_SubShapes_3_objects)
76 model.do()
77
78 model.checkResult(Remove_SubShapes_3, model, 1, [4], [4], [24], [96], [192])
79 model.testHaveNamingSubshapes(Remove_SubShapes_3, model, Part_3_doc)
80
81 # =============================================================================
82 # Test 4. Check Python dump
83 # =============================================================================
84 model.end()
85 assert(model.checkPythonDump())