Salome HOME
b2e6a3295faeb3e722cfb40bb99c9d7e7921482e
[modules/shaper.git] / src / ConstructionPlugin / Test / TestPoint_34658.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 import sys
21 import salome
22 from ModelAPI import *
23
24 def assertPoint(aPoint):
25   assert(aPoint is not None)
26   aPointFeature = aPoint.feature()
27   assert(len(aPointFeature.results()) > 0)
28   aPointResult = modelAPI_ResultConstruction(aPointFeature.firstResult())
29   assert(aPointResult is not None)
30   assert(aPointResult.isInfinite())
31
32
33 salome.salome_init()
34
35 ###
36 ### SHAPER component
37 ###
38
39 from salome.shaper import model
40
41 model.begin()
42 partSet = model.moduleDocument()
43
44 ### Create Part
45 Part_1 = model.addPart(partSet)
46 Part_1_doc = Part_1.document()
47
48 ### Create Sketch
49 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("YOZ"))
50
51 ### Create SketchLine
52 SketchLine_1 = Sketch_1.addLine(0, 0, 0.5, 1.3)
53 model.do()
54
55 ### Create Edge
56 Edge_1 = model.addEdge(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], False)
57
58 ### Create LinearCopy
59 LinearCopy_1 = model.addMultiTranslation(Part_1_doc, [model.selection("EDGE", "Edge_1_1")], model.selection("EDGE", "PartSet/OX"), 4, 5, keepSubResults = True)
60
61 ### Create Plane
62 Plane_4 = model.addPlane(Part_1_doc, model.selection("EDGE", "Sketch_1/SketchLine_1"), model.selection("VERTEX", "Sketch_1/SketchLine_1_EndVertex"), True)
63 Plane_4.setName("Plane_2")
64 Plane_4.result().setName("Plane_2")
65 Plane_4.result().setTransparency(0.6)
66
67 ### Create Plane
68 Plane_5 = model.addPlane(Part_1_doc, model.selection("FACE", "Plane_2"), 1, False)
69 Plane_5.setName("Plane_3")
70 Plane_5.result().setName("Plane_3")
71 Plane_5.result().setTransparency(0.6)
72
73 ### Create Plane
74 Plane_6 = model.addPlane(Part_1_doc, model.selection("EDGE", "LinearCopy_1_1_2"), model.selection("VERTEX", "LinearCopy_1_1_2/MV:Translated&Sketch_1/SketchLine_1_EndVertex"), True)
75 Plane_6.setName("Plane_4")
76 Plane_6.result().setName("Plane_4")
77 Plane_6.result().setTransparency(0.6)
78
79 ### Create Plane
80 Plane_7 = model.addPlane(Part_1_doc, model.selection("FACE", "Plane_4"), 1, False)
81 Plane_7.setName("Plane_5")
82 Plane_7.result().setName("Plane_5")
83 Plane_7.result().setTransparency(0.6)
84
85 ### Create Plane
86 Plane_8 = model.addPlane(Part_1_doc, model.selection("EDGE", "LinearCopy_1_1_3"), model.selection("VERTEX", "LinearCopy_1_1_3/MV:Translated&Sketch_1/SketchLine_1_EndVertex"), True)
87 Plane_8.setName("Plane_6")
88 Plane_8.result().setName("Plane_6")
89 Plane_8.result().setTransparency(0.6)
90
91 ### Create Plane
92 Plane_9 = model.addPlane(Part_1_doc, model.selection("FACE", "Plane_6"), 1, False)
93 Plane_9.setName("Plane_7")
94 Plane_9.result().setName("Plane_7")
95 Plane_9.result().setTransparency(0.6)
96
97 ### Create Point (by coordinates)
98 Point_1 = model.addPoint(Part_1_doc, 16, 0.5, 1.3)
99
100 ### Create Point (by position on edge)
101 Point_2 = model.addPoint(Part_1_doc, model.selection("EDGE", "LinearCopy_1_1_4"), 2.5, False, False)
102
103 ### Create Point (by projection of point on plane)
104 Point_3 = model.addPoint(Part_1_doc, model.selection("VERTEX", "LinearCopy_1_1_3/MV:Translated&Sketch_1/SketchLine_1_EndVertex"), model.selection("FACE", "Plane_7"))
105
106 ### Create Point (by intersection of axis and plane)
107 Point_4 = model.addPoint(Part_1_doc, model.selection("EDGE", "LinearCopy_1_1_2"), model.selection("FACE", "Plane_5"))
108
109 ### Create Sketch
110 Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_2"))
111
112 ### Create SketchProjection
113 SketchProjection_1 = Sketch_2.addProjection(model.selection("VERTEX", "Sketch_1/SketchLine_1_EndVertex"), False)
114 SketchPoint_1 = SketchProjection_1.createdFeature()
115
116 ### Create SketchCircle
117 SketchCircle_1 = Sketch_2.addCircle(0, 0, 0.6)
118 Sketch_2.setCoincident(SketchPoint_1.result(), SketchCircle_1.center())
119 Sketch_2.setRadius(SketchCircle_1.results()[1], 0.6)
120 model.do()
121
122 ### Create Extrusion
123 Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchCircle_1_2f")], model.selection(), model.selection("FACE", "Plane_3"), 0, model.selection(), 0, "Faces|Wires")
124 Extrusion_1.result().setTransparency(0.6)
125
126 ### Create Point (by center of gravity)
127 Point_5 = model.addPoint(Part_1_doc, model.selection("SOLID", "Extrusion_1_1"))
128
129 ### Create Sphere
130 Sphere_1 = model.addSphere(Part_1_doc, model.selection("VERTEX", "Point_1"), 0.8)
131
132 ### Create Cylinder
133 Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "Point_2"), model.selection("EDGE", "LinearCopy_1_1_2"), 0.8, 1)
134
135 ### Create Torus
136 Torus_1 = model.addTorus(Part_1_doc, model.selection("VERTEX", "Point_3"), model.selection("EDGE", "LinearCopy_1_1_3"), 0.8, 0.25)
137
138 ### Create Cone
139 Cone_1 = model.addCone(Part_1_doc, model.selection("VERTEX", "Point_4"), model.selection("EDGE", "LinearCopy_1_1_4"), 0.8, 0.3, 1)
140
141 ### Create Sphere
142 Sphere_2 = model.addSphere(Part_1_doc, model.selection("VERTEX", "Point_5"), 0.8)
143
144 model.end()
145
146 assertPoint(Point_1)
147 assertPoint(Point_2)
148 assertPoint(Point_3)
149 assertPoint(Point_4)
150 assertPoint(Point_5)