Salome HOME
540f5217168502ca2535feb135ae30d03e22b3d7
[modules/shaper.git] / src / BuildPlugin / Test / Test2398.py
1 # Copyright (C) 2018-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 SketchAPI import *
21
22 from salome.shaper import model
23
24 model.begin()
25 partSet = model.moduleDocument()
26 Part_1 = model.addPart(partSet)
27 Part_1_doc = Part_1.document()
28
29 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("YOZ"))
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, 30.79356776198042)
33 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchPoint_1.result(), SketchCircle_1.center())
34 model.do()
35
36 Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchCircle_1_2f_wire")], model.selection(), 100, 100)
37
38 Sketch_2 = model.addSketch(Part_1_doc, model.standardPlane("XOY"))
39 SketchProjection_2 = Sketch_2.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
40 SketchPoint_2 = SketchProjection_2.createdFeature()
41 SketchCircle_2 = Sketch_2.addCircle(0, 0, 25.19116787687743)
42 SketchConstraintCoincidence_2 = Sketch_2.setCoincident(SketchPoint_2.result(), SketchCircle_2.center())
43 model.do()
44
45 Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchCircle_2_2f")], model.selection(), 100, 0)
46 Rotation_1 = model.addRotation(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1")], model.selection("EDGE", "PartSet/OX"), 90)
47
48 Intersection_1 = model.addIntersection(Part_1_doc, [model.selection("SOLID", "Rotation_1_1"), model.selection("SOLID", "Extrusion_2_1")])
49
50 Sketch_3 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
51 SketchLine_1 = Sketch_3.addLine(7.903534676574237, 7.903534676574236, -7.903534676574236, 7.903534676574236)
52 SketchLine_2 = Sketch_3.addLine(-7.903534676574236, 7.903534676574236, -7.903534676574236, -7.903534676574237)
53 SketchLine_3 = Sketch_3.addLine(-7.903534676574236, -7.903534676574237, 7.903534676574237, -7.903534676574237)
54 SketchLine_4 = Sketch_3.addLine(7.903534676574237, -7.903534676574237, 7.903534676574237, 7.903534676574236)
55 SketchConstraintCoincidence_3 = Sketch_3.setCoincident(SketchLine_4.endPoint(), SketchLine_1.startPoint())
56 SketchConstraintCoincidence_4 = Sketch_3.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
57 SketchConstraintCoincidence_5 = Sketch_3.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
58 SketchConstraintCoincidence_6 = Sketch_3.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
59 SketchConstraintHorizontal_1 = Sketch_3.setHorizontal(SketchLine_1.result())
60 SketchConstraintVertical_1 = Sketch_3.setVertical(SketchLine_2.result())
61 SketchConstraintHorizontal_2 = Sketch_3.setHorizontal(SketchLine_3.result())
62 SketchConstraintVertical_2 = Sketch_3.setVertical(SketchLine_4.result())
63 SketchConstraintEqual_1 = Sketch_3.setEqual(SketchLine_4.result(), SketchLine_1.result())
64 SketchLine_5 = Sketch_3.addLine(-7.903534676574236, 7.903534676574236, 7.903534676574237, -7.903534676574237)
65 SketchLine_5.setAuxiliary(True)
66 SketchConstraintCoincidence_7 = Sketch_3.setCoincident(SketchLine_1.endPoint(), SketchLine_5.startPoint())
67 SketchConstraintCoincidence_8 = Sketch_3.setCoincident(SketchLine_3.endPoint(), SketchLine_5.endPoint())
68 SketchProjection_3 = Sketch_3.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
69 SketchPoint_3 = SketchProjection_3.createdFeature()
70 SketchConstraintCoincidence_9 = Sketch_3.setCoincident(SketchLine_5.result(), SketchAPI_Point(SketchPoint_3).coordinates())
71 SketchConstraintMiddle_1 = Sketch_3.setMiddlePoint(SketchAPI_Point(SketchPoint_3).coordinates(), SketchLine_5.result())
72 model.do()
73
74 Edge_1_objects = [model.selection("EDGE", "Sketch_3/SketchLine_2"), model.selection("EDGE", "Sketch_3/SketchLine_1"), model.selection("EDGE", "Sketch_3/SketchLine_4"), model.selection("EDGE", "Sketch_3/SketchLine_3")]
75 Edge_1 = model.addEdge(Part_1_doc, Edge_1_objects)
76
77 Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "PartSet/XOZ"), model.selection("EDGE", "PartSet/OZ"), 135)
78 Plane_5 = model.addPlane(Part_1_doc, model.selection("FACE", "Plane_1"), model.selection("EDGE", "PartSet/OZ"), 90)
79
80 Partition_1_objects = [model.selection("EDGE", "Intersection_1_1"), model.selection("FACE", "Plane_2"), model.selection("FACE", "Plane_1")]
81 Partition_1 = model.addPartition(Part_1_doc, Partition_1_objects)
82
83 Filling_1 = model.addFilling(Part_1_doc, [model.selection("EDGE", "Partition_1_1_2"), model.selection("EDGE", "Edge_1_2")])
84 Filling_2 = model.addFilling(Part_1_doc, [model.selection("EDGE", "Partition_1_1_3"), model.selection("EDGE", "Edge_1_1")])
85 Filling_3 = model.addFilling(Part_1_doc, [model.selection("EDGE", "Partition_1_1_4"), model.selection("EDGE", "Edge_1_4")])
86
87 Wire_1 = model.addWire(Part_1_doc, [model.selection("EDGE", "Partition_1_1_1"), model.selection("EDGE", "Partition_1_1_5")])
88 Filling_4 = model.addFilling(Part_1_doc, [model.selection("EDGE", "Edge_1_3"), model.selection("WIRE", "Wire_1_1")])
89 model.do()
90
91 from GeomAPI import *
92
93 # check fillings
94 REF_DATA = [(Filling_1, 719.149788883378505488508380949),
95             (Filling_2, 910.894525282186464210099074990),
96             (Filling_3, 719.149788883378505488508380949),
97             (Filling_4, 911.056740330659408755309414119)]
98 for ref in REF_DATA:
99     model.testNbResults(ref[0], 1)
100     model.testNbSubResults(ref[0], [0])
101     model.testNbSubShapes(ref[0], GeomAPI_Shape.SOLID, [0])
102     model.testNbSubShapes(ref[0], GeomAPI_Shape.FACE, [1])
103     model.testNbSubShapes(ref[0], GeomAPI_Shape.EDGE, [4])
104     model.testNbSubShapes(ref[0], GeomAPI_Shape.VERTEX, [8])
105     model.testResultsAreas(ref[0], [ref[1]])
106
107 model.end()
108
109 assert(model.checkPythonDump())