Salome HOME
Merge commit 'refs/tags/V9_2_0^{}'
[modules/shaper.git] / src / SketchPlugin / Test / TestIntersectionWithCircle.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 """
22     TestIntersectionWithCircle.py
23     Unit test of SketchPlugin_IntersectionPoint class
24 """
25
26 from GeomAPI import *
27 from SketchAPI import *
28
29 from salome.shaper import model
30
31 model.begin()
32 partSet = model.moduleDocument()
33 Part_1 = model.addPart(partSet)
34 Part_1_doc = Part_1.document()
35 ParamD = model.addParameter(Part_1_doc, "D", "12")
36 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
37 SketchLine_1 = Sketch_1.addLine(21.25834261322606, 21.25834261322606, 0, 0)
38 SketchLine_2 = Sketch_1.addLine(0, 0, 50, -4.088404617988313e-023)
39 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
40 SketchLine_3 = Sketch_1.addLine(50, -4.088404617988313e-023, 50, 50)
41 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
42 SketchLine_4 = Sketch_1.addLine(50, 50, 28.74165738677394, 28.74165738677394)
43 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
44 SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
45 SketchPoint_1 = SketchProjection_1.createdFeature()
46 SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchAPI_Point(SketchPoint_1).coordinates())
47 SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_2.result())
48 SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_3.result())
49 SketchConstraintCollinear_1 = Sketch_1.setCollinear(SketchLine_4.result(), SketchLine_1.result())
50 SketchConstraintEqual_1 = Sketch_1.setEqual(SketchLine_2.result(), SketchLine_3.result())
51 SketchConstraintEqual_2 = Sketch_1.setEqual(SketchLine_1.result(), SketchLine_4.result())
52 SketchArc_1 = Sketch_1.addArc(31, 19, 21.25834261322606, 21.25834261322606, 28.74165738677394, 28.74165738677394, False)
53 SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchArc_1.startPoint())
54 SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchArc_1.endPoint())
55 SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_2.result(), 50)
56 SketchConstraintRadius_1 = Sketch_1.setRadius(SketchArc_1.results()[1], 10)
57 SketchConstraintDistance_1 = Sketch_1.setDistance(SketchArc_1.center(), SketchLine_2.result(), 19, True)
58 model.do()
59 Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2f-SketchLine_3f-SketchLine_4f-SketchArc_1_2r")], model.selection(), 10, 0)
60 Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2"), "D", True)
61 Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_1"))
62 SketchIntersectionPoint_1 = Sketch_2.addIntersectionPoint(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchArc_1_2][Extrusion_1_1/To_Face]"), True)
63 SketchIntersectionPoint_1.result().setName("SketchIntersectionPoint_1")
64 [SketchPoint_2, SketchPoint_3] = SketchIntersectionPoint_1.intersectionPoints()
65 SketchCircle_1 = Sketch_2.addCircle(38.14142842854285, 10, 1)
66 SketchConstraintCoincidence_7 = Sketch_2.setCoincident(SketchCircle_1.center(), SketchAPI_Point(SketchPoint_2).coordinates())
67 SketchConstraintRadius_2 = Sketch_2.setRadius(SketchCircle_1.results()[1], 1)
68 SketchLine_5 = Sketch_2.addLine(23.85857157145715, 10.5, 23.85857157145715, 5)
69 SketchLine_6 = Sketch_2.addLine(22.85857157145715, 6, 22.85857157145715, 10.5)
70 SketchLine_7 = Sketch_2.addLine(22.85857157145715, 10.5, 23.85857157145715, 10.5)
71 SketchConstraintCoincidence_8 = Sketch_2.setCoincident(SketchLine_6.endPoint(), SketchLine_7.startPoint())
72 SketchConstraintCoincidence_9 = Sketch_2.setCoincident(SketchLine_5.startPoint(), SketchLine_7.endPoint())
73 SketchConstraintCoincidence_10 = Sketch_2.setCoincident(SketchAPI_Point(SketchPoint_3).coordinates(), SketchLine_5.result())
74 SketchConstraintVertical_2 = Sketch_2.setVertical(SketchLine_5.result())
75 SketchConstraintVertical_3 = Sketch_2.setVertical(SketchLine_6.result())
76 SketchConstraintHorizontal_2 = Sketch_2.setHorizontal(SketchLine_7.result())
77 SketchConstraintDistanceHorizontal_1 = Sketch_2.setHorizontalDistance(SketchLine_6.endPoint(), SketchLine_5.startPoint(), 1)
78 SketchConstraintDistanceVertical_1 = Sketch_2.setVerticalDistance(SketchLine_5.startPoint(), SketchAPI_Point(SketchPoint_3).coordinates(), 0.5)
79 SketchArc_2 = Sketch_2.addArc(23.85857157145715, 6, 23.85857157145715, 5, 22.85857157145715, 6, True)
80 SketchConstraintCoincidence_11 = Sketch_2.setCoincident(SketchLine_5.result(), SketchArc_2.center())
81 SketchConstraintCoincidence_12 = Sketch_2.setCoincident(SketchLine_5.endPoint(), SketchArc_2.startPoint())
82 SketchConstraintCoincidence_13 = Sketch_2.setCoincident(SketchArc_2.endPoint(), SketchLine_6.startPoint())
83 SketchConstraintDistanceVertical_2 = Sketch_2.setVerticalDistance(SketchAPI_Point(SketchPoint_3).coordinates(), SketchArc_2.startPoint(), 5)
84 SketchConstraintTangent_1 = Sketch_2.setTangent(SketchArc_2.results()[1], SketchLine_6.result())
85 model.do()
86 RevolutionCut_1 = model.addRevolutionCut(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_7r-SketchLine_6r-SketchArc_2_2f-SketchLine_5r")], model.selection("EDGE", "Sketch_2/SketchLine_5"), 360, 0, [model.selection("SOLID", "Extrusion_1_1")])
87 ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchCircle_1_2f")], model.selection(), 5, 5, [model.selection("SOLID", "RevolutionCut_1_1")])
88 model.do()
89
90 assert(SketchIntersectionPoint_1.feature().results().size() == 2)
91
92 model.testNbResults(ExtrusionCut_1, 1)
93 model.testNbSubResults(ExtrusionCut_1, [0])
94 model.testNbSubShapes(ExtrusionCut_1, GeomAPI_Shape.SOLID, [1])
95 model.testNbSubShapes(ExtrusionCut_1, GeomAPI_Shape.FACE, [13])
96 model.testNbSubShapes(ExtrusionCut_1, GeomAPI_Shape.EDGE, [66])
97 model.testNbSubShapes(ExtrusionCut_1, GeomAPI_Shape.VERTEX, [132])
98 model.testResultsVolumes(ExtrusionCut_1, [9451.611727849665840039961040020])
99
100 # change parameter and check intersection validity
101 ParamD.setValue(15)
102 model.do();
103
104 assert(SketchIntersectionPoint_1.feature().results().size() == 2)
105
106 model.testNbResults(ExtrusionCut_1, 1)
107 model.testNbSubResults(ExtrusionCut_1, [0])
108 model.testNbSubShapes(ExtrusionCut_1, GeomAPI_Shape.SOLID, [1])
109 model.testNbSubShapes(ExtrusionCut_1, GeomAPI_Shape.FACE, [14])
110 model.testNbSubShapes(ExtrusionCut_1, GeomAPI_Shape.EDGE, [74])
111 model.testNbSubShapes(ExtrusionCut_1, GeomAPI_Shape.VERTEX, [148])
112 model.testResultsVolumes(ExtrusionCut_1, [9451.152473626798382611013948917])
113
114 # change parameter and check intersection validity
115 ParamD.setValue(19)
116 model.do();
117
118 assert(SketchIntersectionPoint_1.feature().results().size() == 2)
119
120 model.testNbResults(ExtrusionCut_1, 1)
121 model.testNbSubResults(ExtrusionCut_1, [0])
122 model.testNbSubShapes(ExtrusionCut_1, GeomAPI_Shape.SOLID, [1])
123 model.testNbSubShapes(ExtrusionCut_1, GeomAPI_Shape.FACE, [14])
124 model.testNbSubShapes(ExtrusionCut_1, GeomAPI_Shape.EDGE, [74])
125 model.testNbSubShapes(ExtrusionCut_1, GeomAPI_Shape.VERTEX, [148])
126 model.testResultsVolumes(ExtrusionCut_1, [9448.046243665688962209969758987])
127
128 # change parameter and check intersection validity
129 ParamD.setValue(23)
130 model.do();
131
132 assert(SketchIntersectionPoint_1.feature().results().size() == 1)
133
134 model.testNbResults(ExtrusionCut_1, 1)
135 model.testNbSubResults(ExtrusionCut_1, [0])
136 model.testNbSubShapes(ExtrusionCut_1, GeomAPI_Shape.SOLID, [1])
137 model.testNbSubShapes(ExtrusionCut_1, GeomAPI_Shape.FACE, [10])
138 model.testNbSubShapes(ExtrusionCut_1, GeomAPI_Shape.EDGE, [50])
139 model.testNbSubShapes(ExtrusionCut_1, GeomAPI_Shape.VERTEX, [100])
140 model.testResultsVolumes(ExtrusionCut_1, [9458.635858820198336616158485413])
141
142 # change parameter and check intersection validity
143 ParamD.setValue(29)
144 model.do();
145
146 assert(SketchIntersectionPoint_1.feature().results().size() == 1)
147
148 model.testNbResults(ExtrusionCut_1, 1)
149 model.testNbSubResults(ExtrusionCut_1, [0])
150 model.testNbSubShapes(ExtrusionCut_1, GeomAPI_Shape.SOLID, [1])
151 model.testNbSubShapes(ExtrusionCut_1, GeomAPI_Shape.FACE, [9])
152 model.testNbSubShapes(ExtrusionCut_1, GeomAPI_Shape.EDGE, [42])
153 model.testNbSubShapes(ExtrusionCut_1, GeomAPI_Shape.VERTEX, [84])
154 model.testResultsVolumes(ExtrusionCut_1, [9463.846034357124153757467865944])
155
156 model.end()
157
158 assert(model.checkPythonDump())