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