Salome HOME
935c15a6304afffd8c8fb976a8e7bb4de2cc6c0f
[modules/shaper.git] / src / FiltersPlugin / Test / Test3241.py
1 # Copyright (C) 2020-2024  CEA, EDF
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 GeomAPI import *
21 from SketchAPI import *
22
23 from salome.shaper import model
24
25 model.begin()
26 partSet = model.moduleDocument()
27 Part_1 = model.addPart(partSet)
28 Part_1_doc = Part_1.document()
29 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
30 SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
31 SketchPoint_1 = SketchProjection_1.createdFeature()
32 SketchCircle_1 = Sketch_1.addCircle(0, 0, 40)
33 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchPoint_1.result(), SketchCircle_1.center())
34 SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_1.results()[1], 40)
35 model.do()
36 Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2f"), 10, False)
37 Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_1"))
38 SketchProjection_2 = Sketch_2.addProjection(model.selection("VERTEX", "Sketch_1/SketchCircle_1"), True)
39 SketchPoint_2 = SketchProjection_2.createdFeature()
40 SketchCircle_2 = Sketch_2.addCircle(0, 0, 50)
41 SketchConstraintCoincidence_2 = Sketch_2.setCoincident(SketchAPI_Point(SketchPoint_2).coordinates(), SketchCircle_2.center())
42 SketchConstraintRadius_2 = Sketch_2.setRadius(SketchCircle_2.results()[1], 50)
43 model.do()
44 Plane_5 = model.addPlane(Part_1_doc, model.selection("FACE", "Plane_1"), 10, False)
45 Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_2"))
46 SketchProjection_3 = Sketch_3.addProjection(model.selection("VERTEX", "Sketch_1/SketchCircle_1"), True)
47 SketchPoint_3 = SketchProjection_3.createdFeature()
48 SketchCircle_3 = Sketch_3.addCircle(0, 0, 53)
49 SketchConstraintCoincidence_3 = Sketch_3.setCoincident(SketchAPI_Point(SketchPoint_3).coordinates(), SketchCircle_3.center())
50 SketchConstraintRadius_3 = Sketch_3.setRadius(SketchCircle_3.results()[1], 53)
51 model.do()
52 Filling_1_objects = [model.selection("EDGE", "Sketch_1/SketchCircle_1_2"), model.selection("EDGE", "Sketch_2/SketchCircle_2_2"), model.selection("EDGE", "Sketch_3/SketchCircle_3_2")]
53 Filling_1 = model.addFilling(Part_1_doc, Filling_1_objects)
54 Sketch_4 = model.addSketch(Part_1_doc, model.standardPlane("XOY"))
55 SketchProjection_4 = Sketch_4.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
56 SketchPoint_4 = SketchProjection_4.createdFeature()
57 SketchProjection_5 = Sketch_4.addProjection(model.selection("EDGE", "PartSet/OX"), True)
58 SketchLine_1 = SketchProjection_5.createdFeature()
59 SketchMultiRotation_1 = Sketch_4.addRotation([SketchLine_1.result()], SketchAPI_Point(SketchPoint_4).coordinates(), 360, 12, True)
60 [SketchLine_1, SketchLine_2, SketchLine_3, SketchLine_4, SketchLine_5, SketchLine_6, SketchLine_7, SketchLine_8, SketchLine_9, SketchLine_10, SketchLine_11, SketchLine_12] = SketchMultiRotation_1.rotated()
61 model.do()
62 Edge_1 = model.addEdge(Part_1_doc, [model.selection("COMPOUND", "Sketch_4")], False)
63 Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "all-in-Edge_1")], model.selection(), model.selection("FACE", "Plane_2"), 0, model.selection(), 0)
64 Split_1 = model.addSplit(Part_1_doc, [model.selection("FACE", "Filling_1_1")], [model.selection("COMPOUND", "Extrusion_1_1")], keepSubResults = True)
65 FilterFace = model.filters(Part_1_doc, [model.addFilter(name = "OnGeometry", args = [model.selection("FACE", "Split_1_1_1")])])
66 model.end()
67
68 Reference = {}
69 ResultSplit = Split_1.result().resultSubShapePair()[0]
70 exp = GeomAPI_ShapeExplorer(ResultSplit.shape(), GeomAPI_Shape.FACE)
71 while exp.more():
72     Reference[model.selection(ResultSplit, exp.current())] = True
73     exp.next()
74 model.checkFilter(Part_1_doc, model, FilterFace, Reference)