1 # Copyright (C) 2014-2022 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
21 from ModelAPI import *
25 partSet = model.moduleDocument()
26 Part_1 = model.addPart(partSet)
27 Part_1_doc = Part_1.document()
28 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
29 SketchCircle_1 = Sketch_1.addCircle(15, 13, 11)
31 Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2r")], model.selection(), 10, 0)
34 Part_2 = model.addPart(partSet)
35 Part_2_doc = Part_2.document()
36 Sketch_2 = model.addSketch(Part_2_doc, model.defaultPlane("XOZ"))
37 SketchCircle_2 = Sketch_2.addCircle(-13, -9, 5)
39 Extrusion_2 = model.addExtrusion(Part_2_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2r")], model.selection(), 10, 0)
40 ImportResult_1 = model.addImportResult(Part_2_doc, [model.selection("SOLID", "Part_1/Extrusion_1_1")])
43 Part_3 = model.addPart(partSet)
44 Part_3_doc = Part_3.document()
45 Extrusion_3 = model.addExtrusion(Part_3_doc, [], model.selection(), 1, 0)
46 Sketch_3 = model.addSketch(Part_3_doc, model.defaultPlane("XOZ"))
47 SketchCircle_3 = Sketch_3.addCircle(-4, 2, 5)
48 Extrusion_3.setNestedSketch(Sketch_3)
53 # check Part_2 is ok and contains 2 solids in result
54 assert(Part_2.feature().results().size() == 1)
55 aPartShape = Part_2.feature().firstResult().shape()
56 assert(aPartShape.shapeTypeStr() == "COMPOUND")
57 aShapeExplorer = GeomAPI_ShapeExplorer(aPartShape, GeomAPI_Shape.SOLID)
58 assert(aShapeExplorer.more())
60 assert(aShapeExplorer.more())
62 # check that selection of this part and the lower part is impossible (by validator)
64 aSel = ImportResult_1.feature().selectionList("objects").value(0)
65 aSel.selectSubShape("SOLID", "Part_2/Extrusion_1_1")
67 aFactory = ModelAPI_Session.get().validators()
68 assert(not aFactory.validate(ImportResult_1.feature()))
71 aSel = ImportResult_1.feature().selectionList("objects").value(0)
72 aSel.selectSubShape("SOLID", "Part_3/Extrusion_1_1")
74 assert(not aFactory.validate(ImportResult_1.feature()))
76 # back to correct value
78 aSel = ImportResult_1.feature().selectionList("objects").value(0)
79 aSel.selectSubShape("SOLID", "Part_1/Extrusion_1_1")
81 assert(aFactory.validate(ImportResult_1.feature()))
83 # TODO: implement for GEOMOETRICAL also
84 assert(model.checkPythonDump(model.ModelHighAPI.CHECK_NAMING))