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