Salome HOME
c6ba8a58c71367ca31501452661df22e77ede467
[modules/shaper.git] / src / FeaturesPlugin / Test / TestFusionFaces32443.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 SketchAPI import *
22
23 # Create document
24 model.begin()
25 partSet = model.moduleDocument()
26 Part_1 = model.addPart(partSet)
27 Part_1_doc = Part_1.document()
28
29 model.addParameter(Part_1_doc, "hauteur", '200')
30 model.addParameter(Part_1_doc, "rayon", '20')
31 model.addParameter(Part_1_doc, "largeur", '100')
32 model.addParameter(Part_1_doc, "epaisseur", '10')
33 model.addParameter(Part_1_doc, "distance", '50')
34
35 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
36 SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OY"), False)
37 SketchLine_1 = SketchProjection_1.createdFeature()
38 SketchLine_2 = Sketch_1.addLine(0, 50, 0, 60)
39 SketchLine_3 = Sketch_1.addLine(100, 60.00000000000041, 100, 50.00000000001594)
40 Sketch_1.setVertical(SketchLine_2.result())
41 Sketch_1.setVertical(SketchLine_3.result())
42 Sketch_1.setVerticalDistance(SketchLine_2.endPoint(), SketchLine_2.startPoint(), "epaisseur")
43 Sketch_1.setVerticalDistance(SketchAPI_Line(SketchLine_1).startPoint(), SketchLine_2.startPoint(), "distance")
44
45 SketchProjection_2 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OX"), False)
46 SketchLine_4 = SketchProjection_2.createdFeature()
47
48 SketchArc_1 = Sketch_1.addArc(50, 0, 0, 60, 100, 60.00000000000041, True)
49 Sketch_1.setCoincident(SketchLine_4.result(), SketchArc_1.center())
50 Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchArc_1.startPoint())
51 Sketch_1.setCoincident(SketchLine_3.result(), SketchArc_1.endPoint())
52
53 SketchArc_2 = Sketch_1.addArc(50, 0, 0, 50, 100, 50.00000000001594, True)
54 Sketch_1.setCoincident(SketchArc_1.center(), SketchArc_2.center())
55 Sketch_1.setCoincident(SketchLine_3.result(), SketchArc_2.endPoint())
56 Sketch_1.setCoincident(SketchArc_1.endPoint(), SketchLine_3.startPoint())
57 Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchArc_2.endPoint())
58 Sketch_1.setCoincident(SketchArc_2.startPoint(), SketchLine_2.startPoint())
59 Sketch_1.setCoincident(SketchLine_2.startPoint(), SketchLine_1.result())
60 Sketch_1.setHorizontalDistance(SketchArc_2.center(), SketchAPI_Line(SketchLine_1).startPoint(), "largeur/2")
61 Sketch_1.setHorizontalDistance(SketchArc_2.endPoint(), SketchAPI_Line(SketchLine_1).startPoint(), "largeur")
62 model.do()
63
64 Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "all-in-Sketch_1")], model.selection(), "hauteur", 0, "Faces|Wires")
65
66 Sketch_2 = model.addSketch(Part_1_doc, model.standardPlane("XOZ"))
67 SketchCircle_1 = Sketch_2.addCircle(50, 100, 20)
68
69 SketchProjection_3 = Sketch_2.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
70 SketchPoint_1 = SketchProjection_3.createdFeature()
71 Sketch_2.setHorizontalDistance(SketchAPI_Point(SketchPoint_1).coordinates(), SketchCircle_1.center(), "largeur/2")
72 Sketch_2.setVerticalDistance(SketchCircle_1.center(), SketchAPI_Point(SketchPoint_1).coordinates(), "hauteur/2")
73 Sketch_2.setRadius(SketchCircle_1.results()[1], "rayon")
74 model.do()
75
76 ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [model.selection("COMPOUND", "all-in-Sketch_2")], model.selection(), [model.selection("COMPOUND", "all-in-Extrusion_1")])
77
78 Sketch_3 = model.addSketch(Part_1_doc, model.standardPlane("XOZ"))
79 SketchLine_5 = Sketch_3.addLine(0, 150, 100, 50)
80 SketchLine_6 = Sketch_3.addLine(0, 50, 100, 150)
81 SketchProjection_4 = Sketch_3.addProjection(model.selection("EDGE", "PartSet/OZ"), False)
82 SketchLine_7 = SketchProjection_4.createdFeature()
83 Sketch_3.setCoincident(SketchLine_6.startPoint(), SketchLine_7.result())
84 SketchLine_8 = Sketch_3.addLine(0, 150, 100, 150)
85 Sketch_3.setCoincident(SketchLine_5.startPoint(), SketchLine_8.startPoint())
86 Sketch_3.setHorizontal(SketchLine_8.result())
87
88 SketchLine_9 = Sketch_3.addLine(0, 50, 100, 50)
89 Sketch_3.setCoincident(SketchLine_6.startPoint(), SketchLine_9.startPoint())
90 Sketch_3.setCoincident(SketchLine_5.endPoint(), SketchLine_9.endPoint())
91 Sketch_3.setHorizontal(SketchLine_9.result())
92 Sketch_3.setCoincident(SketchLine_5.startPoint(), SketchLine_8.startPoint())
93 Sketch_3.setCoincident(SketchLine_5.startPoint(), SketchLine_7.result())
94 Sketch_3.setCoincident(SketchLine_6.endPoint(), SketchLine_8.endPoint())
95 Sketch_3.setLength(SketchLine_9.result(), "largeur")
96 Sketch_3.setLength(SketchLine_8.result(), "largeur")
97
98 SketchProjection_5 = Sketch_3.addProjection(model.selection("VERTEX", "Sketch_2/SketchCircle_1_2__cc"), False)
99 SketchPoint_2 = SketchProjection_5.createdFeature()
100 Sketch_3.setVerticalDistance(SketchAPI_Point(SketchPoint_2).coordinates(), SketchLine_9.startPoint(), "largeur/2")
101 Sketch_3.setVerticalDistance(SketchLine_5.startPoint(), SketchAPI_Point(SketchPoint_2).coordinates(), "largeur/2")
102 model.do()
103
104 ### Create Extrusion
105 Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "all-in-Sketch_3")], model.selection(), 100, 0, "Edges")
106
107 ### Create Split
108 Split_1 = model.addSplit(Part_1_doc, [model.selection("SOLID", "ExtrusionCut_1_1")], [model.selection("COMPOUND", "Extrusion_2_1")], keepSubResults = True)
109
110 ### Create FusionFaces
111 FusionFaces_1 = model.addFusionFaces(Part_1_doc, model.selection("COMPSOLID", "Split_1_1"))
112
113 model.end()
114
115 model.checkResult(FusionFaces_1, model, 1, [6], [6], [36], [144], [288])
116
117 assert(model.checkPythonDump())