Salome HOME
2b2ed4bbfba703ab4cb8d00401447a334fb0cca9
[modules/shaper.git] / src / FiltersPlugin / Test / TestFilter_OnGeometry_Face3.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 from GeomAPI import *
22 from SketchAPI import *
23
24 model.begin()
25 partSet = model.moduleDocument()
26 Part_1 = model.addPart(partSet)
27 Part_1_doc = Part_1.document()
28 Extrusion_1 = model.addExtrusion(Part_1_doc, [], model.selection(), 100, 0)
29 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
30 SketchCircle_1 = Sketch_1.addCircle(0, 0, 80)
31 SketchLine_1 = Sketch_1.addLine(-70.03988514133886, -38.65765757761403, 65.03214823048954, -46.59205615260649)
32 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchCircle_1.results()[1])
33 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchCircle_1.results()[1])
34 SketchLine_2 = Sketch_1.addLine(6.89273184263731, -79.70251092497334, 48.24895637932232, 63.81252391424628)
35 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_2.startPoint(), SketchCircle_1.results()[1])
36 SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchCircle_1.results()[1])
37 SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
38 SketchPoint_1 = SketchProjection_1.createdFeature()
39 SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchCircle_1.center(), SketchAPI_Point(SketchPoint_1).coordinates())
40 SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_1.results()[1], 80)
41 Extrusion_1.setNestedSketch(Sketch_1)
42 Revolution_1 = model.addRevolution(Part_1_doc, [], model.selection("EDGE", "PartSet/OZ"), 270, 0)
43 Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOZ"))
44 SketchLine_3 = Sketch_2.addLine(80, -20, 20, -20)
45 SketchLine_4 = Sketch_2.addLine(20, -20, 20, -100)
46 SketchLine_5 = Sketch_2.addLine(20, -100, 80, -100)
47 SketchLine_6 = Sketch_2.addLine(80, -100, 80, -20)
48 SketchConstraintCoincidence_6 = Sketch_2.setCoincident(SketchLine_6.endPoint(), SketchLine_3.startPoint())
49 SketchConstraintCoincidence_7 = Sketch_2.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
50 SketchConstraintCoincidence_8 = Sketch_2.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint())
51 SketchConstraintCoincidence_9 = Sketch_2.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint())
52 SketchConstraintHorizontal_1 = Sketch_2.setHorizontal(SketchLine_3.result())
53 SketchConstraintVertical_1 = Sketch_2.setVertical(SketchLine_4.result())
54 SketchConstraintHorizontal_2 = Sketch_2.setHorizontal(SketchLine_5.result())
55 SketchConstraintVertical_2 = Sketch_2.setVertical(SketchLine_6.result())
56 SketchProjection_2 = Sketch_2.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
57 SketchPoint_2 = SketchProjection_2.createdFeature()
58 SketchConstraintDistance_1 = Sketch_2.setDistance(SketchAPI_Point(SketchPoint_2).coordinates(), SketchLine_6.result(), 80, True)
59 SketchConstraintDistance_2 = Sketch_2.setDistance(SketchAPI_Point(SketchPoint_2).coordinates(), SketchLine_4.result(), 20, True)
60 SketchConstraintDistance_3 = Sketch_2.setDistance(SketchAPI_Point(SketchPoint_2).coordinates(), SketchLine_3.result(), 20, True)
61 SketchConstraintDistance_4 = Sketch_2.setDistance(SketchAPI_Point(SketchPoint_2).coordinates(), SketchLine_5.result(), 100, True)
62 Revolution_1.setNestedSketch(Sketch_2)
63 model.do()
64 Filters = model.filters(Part_1_doc, [model.addFilter(name = "OnGeometry", args = [model.selection("FACE", "Extrusion_1_1_3/To_Face")])])
65 model.end()
66
67 Reference = {}
68 # Extrusion
69 ResultExtrusion = Extrusion_1.result().resultSubShapePair()[0]
70 exp = GeomAPI_ShapeExplorer(ResultExtrusion.shape(), GeomAPI_Shape.FACE)
71 # faces of solid 1
72 Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next()
73 Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next()
74 Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next()
75 Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next()
76 Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next()
77 Reference[model.selection(ResultExtrusion, exp.current())] = True;  exp.next()
78 # faces of solid 2
79 Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next()
80 Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next()
81 Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next()
82 Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next()
83 Reference[model.selection(ResultExtrusion, exp.current())] = True;  exp.next()
84 # faces of solid 3
85 Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next()
86 Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next()
87 Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next()
88 Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next()
89 Reference[model.selection(ResultExtrusion, exp.current())] = True;  exp.next()
90 # faces of solid 4
91 Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next()
92 Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next()
93 Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next()
94 Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next()
95 Reference[model.selection(ResultExtrusion, exp.current())] = True;  exp.next()
96 # Revolution
97 ResultRevolution = Revolution_1.result().resultSubShapePair()[0]
98 exp = GeomAPI_ShapeExplorer(ResultRevolution.shape(), GeomAPI_Shape.FACE)
99 Reference[model.selection(ResultRevolution, exp.current())] = False; exp.next()
100 Reference[model.selection(ResultRevolution, exp.current())] = False; exp.next()
101 Reference[model.selection(ResultRevolution, exp.current())] = False; exp.next()
102 Reference[model.selection(ResultRevolution, exp.current())] = False; exp.next()
103 Reference[model.selection(ResultRevolution, exp.current())] = False; exp.next()
104 Reference[model.selection(ResultRevolution, exp.current())] = False; exp.next()
105
106 model.checkFilter(Part_1_doc, model, Filters, Reference)