1 # Copyright (C) 2014-2019 CEA/DEN, EDF R&D
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.
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.
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
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 from salome.shaper import model
23 partSet = model.moduleDocument()
25 # =============================================================================
26 # Test 1. Remove face from shell
27 # =============================================================================
28 Part_1 = model.addPart(partSet)
29 Part_1_doc = Part_1.document()
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")])
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")])
41 model.checkResult(Remove_SubShapes_1, model, 1, [0], [0], [1], [4], [8])
42 model.testHaveNamingSubshapes(Remove_SubShapes_1, model, Part_1_doc)
44 # =============================================================================
45 # Test 2. Remove faces from compound
46 # =============================================================================
47 Part_2 = model.addPart(partSet)
48 Part_2_doc = Part_2.document()
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)
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")])
59 model.checkResult(Remove_SubShapes_2, model, 1, [2], [0], [2], [8], [16])
60 model.testHaveNamingSubshapes(Remove_SubShapes_2, model, Part_2_doc)
62 # =============================================================================
63 # Test 3. Remove solid from compsolid
64 # =============================================================================
65 Part_3 = model.addPart(partSet)
66 Part_3_doc = Part_3.document()
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)
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)
78 model.checkResult(Remove_SubShapes_3, model, 1, [4], [4], [24], [96], [192])
79 model.testHaveNamingSubshapes(Remove_SubShapes_3, model, Part_3_doc)
81 # =============================================================================
82 # Test 4. Check Python dump
83 # =============================================================================
85 assert(model.checkPythonDump())