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