Salome HOME
Implementation of the "0020839: EDF 1370 DOC : Update of the TUI features documentati...
[modules/geom.git] / doc / salome / gui / GEOM / input / tui_basic_geom_objs.doc
1 /*!
2
3 \page tui_basic_geom_objs_page Basic Geometrical Objects
4
5 \anchor tui_creation_point
6 <br><h2>Creation of a Point</h2>
7
8 \code
9 import geompy
10 import salome
11 gg = salome.ImportComponentGUI("GEOM")
12
13 # create vertices
14 p0 = geompy.MakeVertex(0., 0., 0.)
15 p100 = geompy.MakeVertexWithRef(p0, 100., 100., 100.)
16 px = geompy.MakeVertex(100., 0., 0.)
17 py = geompy.MakeVertex(0., 100., 0.)
18 pz = geompy.MakeVertex(0., 0., 100.)
19 p1 = geompy.MakeVertex(50., 50., 30.)
20
21 # create a curve and vertices on it
22 Arc = geompy.MakeArc(py, pz, px)
23 # create a vertex by parameter
24 p_on_arc = geompy.MakeVertexOnCurve(Arc, 0.25)
25 # create a vertex by length
26 p_on_arc2 = geompy.MakeVertexOnCurveByLength(Arc, 50., None)
27 #create a vertex by point projection
28 p_on_arc3 = geompy.MakeVertexOnCurveByCoord(Arc, 100, -10, 10)
29
30 # create 2 lines and make a point on its intersection
31 line_1 = geompy.MakeLineTwoPnt(p0, p100)
32 line_2 = geompy.MakeLineTwoPnt(p1, pz)
33 p_inter = geompy.MakeVertexOnLinesIntersection(line_1, line_2)
34
35 # create a face and vertices on it
36 Add_line = geompy.MakeLineTwoPnt(px, py)
37 arc_face = geompy.MakeFaceWires([Arc, Add_line], 1)
38 p_on_face1 = geompy.MakeVertexOnSurface(arc_face, 0.5, 0.5)
39 p_on_face2 = geompy.MakeVertexOnSurfaceByCoord(arc_face, 35, 35, 35)
40
41
42 # add objects in the study
43 id_p0       = geompy.addToStudy(p0,   "Vertex 0")
44 id_p100     = geompy.addToStudy(p100, "Vertex 100")
45 id_px       = geompy.addToStudy(px,   "Vertex X")
46 id_py       = geompy.addToStudy(py,   "Vertex Y")
47 id_pz       = geompy.addToStudy(pz,   "Vertex Z")
48 id_Arc      = geompy.addToStudy(Arc,  "Arc")
49 id_line_1   = geompy.addToStudy(line_1,  "Line 1")
50 id_line_2   = geompy.addToStudy(line_2,  "Line 2")
51 id_p_on_arc = geompy.addToStudy(p_on_arc, "Vertex on Arc by parameter")
52 id_p_on_arc2  = geompy.addToStudy(p_on_arc2, "Vertex on Arc by length")
53 id_p_on_arc3  = geompy.addToStudy(p_on_arc3, "Vertex on Arc by point projection")
54 id_p_inter    = geompy.addToStudy(p_inter,   "Vertex on Lines Intersection")
55 id_p_on_face1 = geompy.addToStudy(p_on_face1, "Vertex on face by parameter")
56 id_p_on_face2 = geompy.addToStudy(p_on_face2, "Vertex on face by point projection")
57
58 # display vertices
59 gg.createAndDisplayGO(id_p0)
60 gg.createAndDisplayGO(id_p100)
61 gg.createAndDisplayGO(id_Arc)
62 gg.createAndDisplayGO(id_p_inter)
63 gg.createAndDisplayGO(id_p_on_arc)
64 gg.createAndDisplayGO(id_p_on_arc2)
65 gg.createAndDisplayGO(id_p_on_arc3)
66 \endcode
67
68 \anchor tui_creation_line
69 <br><h2>Creation of a Line</h2>
70
71 \code
72 import geompy
73 import salome
74 gg = salome.ImportComponentGUI("GEOM")
75
76 # create vertices
77 p0 = geompy.MakeVertex(0., 0., 0.)
78 p100 = geompy.MakeVertexWithRef(p0, 100., 100., 100.)
79 px = geompy.MakeVertex(100., 0.  , 0.  )
80 py = geompy.MakeVertex(0.  , 100., 0.  )
81 pz = geompy.MakeVertex(0.  , 0.  , 100.)
82
83 # create a vector from two points
84 vxy  = geompy.MakeVector(px, py)
85
86 # create a line from a point and a vector
87 line1 = geompy.MakeLine(pz, vxy)
88
89 #create a line from two points
90 line2 = geompy.MakeLineTwoPnt(p0, p100)
91
92 # add objects in the study
93 id_vxy      = geompy.addToStudy(vxy,  "Vector")
94 id_line1    = geompy.addToStudy(line1,"Line1")
95 id_line2    = geompy.addToStudy(line2,"Line2")
96
97 # display lines
98 gg.createAndDisplayGO(id_vxy)
99 gg.createAndDisplayGO(id_line1)
100 gg.createAndDisplayGO(id_line2) 
101 \endcode
102
103 \anchor tui_creation_circle
104 <br><h2>Creation of a Circle</h2>
105
106 \code
107 import geompy
108 import salome
109 gg = salome.ImportComponentGUI("GEOM")
110
111 # create vertices
112 p0 = geompy.MakeVertex(0., 0., 0.)
113 px = geompy.MakeVertex(100., 0.  , 0.  )
114 py = geompy.MakeVertex(0.  , 100., 0.  )
115 pz = geompy.MakeVertex(0.  , 0.  , 100.)
116
117 # create a vector on two points
118 vxy  = geompy.MakeVector(px, py)
119
120 # create a circle from a point, a vector and a radius
121 circle1 = geompy.MakeCircle(pz, vxy, 30)
122
123 #create a circle from three points
124 circle2 = geompy.MakeCircleThreePnt(p0, px, py)
125
126 # add objects in the study
127 id_vxy      = geompy.addToStudy(vxy,    "Vector")
128 id_circle1  = geompy.addToStudy(circle1,"Circle1")
129 id_circle2  = geompy.addToStudy(circle2,"Circle2")
130
131 # display circles
132 gg.createAndDisplayGO(id_vxy)
133 gg.createAndDisplayGO(id_circle1)
134 gg.createAndDisplayGO(id_circle2)
135 \endcode
136
137 \anchor tui_creation_ellipse
138 <br><h2>Creation of an Ellipse</h2>
139
140 \code
141 import geompy
142 import salome
143 gg = salome.ImportComponentGUI("GEOM")
144
145 # create vertices
146 p0 = geompy.MakeVertex(0., 0., 0.)
147 p1 = geompy.MakeVertex(50., 50., 50.)
148 p2 = geompy.MakeVertex(0., 50., 0.)
149
150 # create a normal vector from two points
151 normal  = geompy.MakeVector(p0, p1)
152
153 # create a major axis vector from two points
154 major   = geompy.MakeVector(p0, p2)
155
156 # create an ellipse from a point, a vector and radiuses
157 ellipse1 = geompy.MakeEllipse(p1, normal, 50, 25)
158
159 # create an ellipse from a point, a normal vector, radiuses and a major axis vector
160 ellipse2 = geompy.MakeEllipse(p1, normal, 50, 25, major)
161
162 # add objects in the study
163 id_normal   = geompy.addToStudy(normal,   "Normal")
164 id_major    = geompy.addToStudy(major,    "Major Axis")
165 id_ellipse1 = geompy.addToStudy(ellipse1, "Ellipse 1")
166 id_ellipse2 = geompy.addToStudy(ellipse2, "Ellipse 2")
167
168 # display the ellipse and its normal vector
169 gg.createAndDisplayGO(id_normal)
170 gg.createAndDisplayGO(id_major)
171 gg.createAndDisplayGO(id_ellipse1)
172 gg.createAndDisplayGO(id_ellipse2)
173 \endcode
174
175 \anchor tui_creation_arc
176 <br><h2>Creation of an Arc</h2>
177
178 \code
179 import geompy
180 import salome
181 gg = salome.ImportComponentGUI("GEOM")
182
183 # create vertices
184 p0 = geompy.MakeVertex(0., 0., 0.)
185 p1 = geompy.MakeVertex(100., 0., 0.)
186 p2 = geompy.MakeVertex(50., 0., 50.)
187
188 # create an arc from a three points
189 arc1 = geompy.MakeArc(p0, p1, p2)
190
191 # create an arc from a center point, a start point and end point
192 arc2 = geompy.MakeArcCenter(p0, p1, p2, 1)
193
194 # create an arc from a center point, a major point and minor point
195 arc3 = geompy.MakeArcOfEllipse(p0, p1, p2)
196
197 # add objects in the study
198 id_arc1 = geompy.addToStudy(arc1, "Arc 1")
199 id_arc2 = geompy.addToStudy(arc2, "Arc 2")
200 id_arc3 = geompy.addToStudy(arc3, "Arc 3")
201
202 # display the arcs
203 gg.createAndDisplayGO(id_arc1)
204 gg.createAndDisplayGO(id_arc2)
205 gg.createAndDisplayGO(id_arc3)
206 \endcode
207  
208 \anchor tui_creation_curve
209 <br><h2>Creation of a Curve</h2>
210
211 \code
212 import geompy
213 import salome
214 gg = salome.ImportComponentGUI("GEOM")
215
216 # create vertices
217 p0 = geompy.MakeVertex(0.  , 0.  , 0.  )
218 p1 = geompy.MakeVertex(50. , 100., 200.)
219 p2 = geompy.MakeVertex(150.,  50., 100.)
220 p3 = geompy.MakeVertex(100., 150., 170.)
221 p4 = geompy.MakeVertex(200., 200., 150.)
222
223 # create a polyline from a list of points
224 polyline = geompy.MakePolyline([p0, p1, p2, p3, p4])
225
226 # create a bezier curve from a list of points
227 bezier = geompy.MakeBezier([p0, p1, p2, p3, p4])
228
229 #create a b-spline curve from a list of points
230 interpol = geompy.MakeInterpol([p0, p1, p2, p3, p4], False)
231
232 #create a polyline using parametric definition of the basic points
233 param_polyline = geompy.MakeCurveParametric("t", "sin(t)", "cos(t)", 0., 100., 100, geompy.GEOM.Polyline, theNewMethod=True)
234
235 # create a bezier curve using parametric definition of the basic points
236 param_bezier = geompy.MakeCurveParametric("t", "sin(t)", "cos(t)", 0., 100., 100, geompy.GEOM.Bezier, theNewMethod=True)
237
238 #create a b-spline curve using parametric definition of the basic points
239 param_interpol = geompy.MakeCurveParametric("t", "sin(t)", "cos(t)", 0., 100., 100, geompy.GEOM.Interpolation, theNewMethod=True)
240
241
242
243 # add objects in the study
244 id_p0       = geompy.addToStudy(p0,       "Point1")
245 id_p1       = geompy.addToStudy(p1,       "Point2")
246 id_p2       = geompy.addToStudy(p2,       "Point3")
247 id_p3       = geompy.addToStudy(p3,       "Point4")
248 id_p4       = geompy.addToStudy(p4,       "Point5")
249 id_polyline = geompy.addToStudy(polyline, "Polyline")
250 id_bezier   = geompy.addToStudy(bezier,   "Bezier")
251 id_interpol = geompy.addToStudy(interpol, "Interpol")
252 id_param_polyline = geompy.addToStudy(param_polyline, "Polyline Parametric")
253 id_param_bezier = geompy.addToStudy(param_bezier, "Bezier Parametric")
254 id_param_interpol = geompy.addToStudy(param_interpol, "Interpol Parametric")
255
256
257
258 # display the points and the curves
259 gg.createAndDisplayGO(id_p0)
260 gg.createAndDisplayGO(id_p1)
261 gg.createAndDisplayGO(id_p2)
262 gg.createAndDisplayGO(id_p3)
263 gg.createAndDisplayGO(id_p4)
264 gg.createAndDisplayGO(id_polyline)
265 gg.createAndDisplayGO(id_bezier)
266 gg.createAndDisplayGO(id_interpol) 
267 gg.createAndDisplayGO(id_param_polyline)
268 gg.createAndDisplayGO(id_param_bezier)
269 gg.createAndDisplayGO(id_param_interpol)
270
271 \endcode
272
273 \anchor tui_creation_vector
274 <br><h2>Creation of a Vector</h2>
275
276 \code
277 mport geompy
278 import salome
279 gg = salome.ImportComponentGUI("GEOM")
280
281 # create vertices
282 p1 = geompy.MakeVertex(10., 50., 20.)
283 p2 = geompy.MakeVertex(70., 70., 70.)
284
285 # create a vector from two points
286 vector1 = geompy.MakeVector(p1, p2)
287
288 # create a vector from the given components
289 vector2 = geompy.MakeVectorDXDYDZ(30, 30, 100)
290
291 # add objects in the study
292 id_p1      = geompy.addToStudy(p1,     "Point1")
293 id_p2      = geompy.addToStudy(p2,     "Point2")
294 id_vector1 = geompy.addToStudy(vector1,"Vector1")
295 id_vector2 = geompy.addToStudy(vector2,"Vector2")
296
297 # display the points and the vectors
298 gg.createAndDisplayGO(id_p1)
299 gg.createAndDisplayGO(id_p2)
300 gg.createAndDisplayGO(id_vector1)
301 gg.createAndDisplayGO(id_vector2) 
302 \endcode
303
304 \anchor tui_creation_plane
305 <br><h2>Creation of a Plane</h2>
306
307 \code
308 import geompy
309 import salome
310 gg = salome.ImportComponentGUI("GEOM")
311
312 # create vertices
313 p1 = geompy.MakeVertex(  0.,   0., 100.)
314 p2 = geompy.MakeVertex(100.,   0.,   0.)
315 p3 = geompy.MakeVertex(200., 200., 200.)
316 p4 = geompy.MakeVertex(100., 100.,   0.)
317 p5 = geompy.MakeVertex(0.  , 100.,   0.)
318
319 # create a vectors from the given components
320 vector1 = geompy.MakeVectorDXDYDZ(100., 100., 100.)
321 vector2 = geompy.MakeVectorDXDYDZ(-100., 0., 100.)
322
323 # create a vector from two points
324 vector_arc = geompy.MakeVector(p2, p5)
325
326 # create an arc from three points
327 arc = geompy.MakeArc(p2, p4, p5)
328
329 # create a wire
330 wire = geompy.MakeWire([vector_arc, arc])
331
332 # create a face
333 isPlanarWanted = 1
334 face = geompy.MakeFace(wire, isPlanarWanted)
335 trimsize = 1000.
336
337 # create a Local Coordinate System
338
339 LCS = geompy.MakeMarker(100., 100., 101., 1, 0, 0, 0, 1, 0)
340
341 # create a plane from a point, a vector and a trimsize
342 plane1 = geompy.MakePlane(p1, vector1, trimsize)
343
344 # create a plane from three points and a trimsize
345 plane2 = geompy.MakePlaneThreePnt(p1, p2, p3, trimsize)
346
347 # create a plane from the given face
348 plane3 = geompy.MakePlaneFace(face, trimsize)
349
350 # create a plane from two vectors and a trimsize
351 plane4 = geompy.MakePlane2Vec(vector1, vector2, trimsize)
352
353 # create a plane with the Local Coordinate System and a trimsize
354 plane5 = geompy.MakePlaneLCS(LCS, trimsize, 1)
355
356 # add objects in the study
357 id_face   = geompy.addToStudy(face,  "Face")
358 id_plane1 = geompy.addToStudy(plane1,"Plane1")
359 id_plane2 = geompy.addToStudy(plane2,"Plane2")
360 id_plane3 = geompy.addToStudy(plane3,"Plane3")
361 id_plane4 = geompy.addToStudy(plane4,"Plane4")
362 id_plane5 = geompy.addToStudy(plane5,"Plane5")
363
364 # display the points and the vectors
365 gg.createAndDisplayGO(id_face)
366 gg.createAndDisplayGO(id_plane1)
367 gg.createAndDisplayGO(id_plane2)
368 gg.createAndDisplayGO(id_plane3)
369 gg.createAndDisplayGO(id_plane4)
370 gg.createAndDisplayGO(id_plane5)
371 gg.setDisplayMode(id_plane1,1)
372 gg.setTransparency(id_plane1,0.5)
373 gg.setDisplayMode(id_plane2,1)
374 gg.setTransparency(id_plane2,0.5)
375 gg.setDisplayMode(id_plane3,1)
376 gg.setTransparency(id_plane3,0.5)
377 gg.setDisplayMode(id_plane4,1)
378 gg.setTransparency(id_plane4,0.5)
379 gg.setDisplayMode(id_plane5,1)
380 gg.setTransparency(id_plane5,0.5)
381 \endcode
382
383 \anchor tui_creation_lcs
384 <br><h2>Creation of a Local Coordinate System</h2>
385 \code
386 import GEOM
387 import geompy
388 import math
389 import SALOMEDS
390
391 #Create vertexes, vectors and shapes to construct local CS
392 Vertex_1 = geompy.MakeVertex(50, 50, 50)
393 Vertex_2 = geompy.MakeVertex(70, 70, 70)
394 Vertex_3 = geompy.MakeVertex(0, 0, 0)
395 Vector_X = geompy.MakeVectorDXDYDZ(50, 0, 0)
396 Vector_Y = geompy.MakeVectorDXDYDZ(0, 50, 0)
397 Face_1 = geompy.MakeFaceHW(100, 100, 1)
398 Box_1 = geompy.MakeBoxTwoPnt(Vertex_1, Vertex_2)
399
400 #Construct local CS by manual definition
401 LocalCS_1 = geompy.MakeMarker(0, 0, 0, 1, 0, 0, 0, 1, 0)
402
403 #Construct local CS by center point and two vectors (X and Y directions)
404 LocalCS_2 = geompy.MakeMarkerPntTwoVec(Vertex_3, Vector_X, Vector_Y)
405
406 #Construct local CS from shape orientation
407 LocalCS_FACE = geompy.MakeMarkerFromShape(Face_1)
408 LocalCS_BOX = geompy.MakeMarkerFromShape(Box_1)
409
410 #Add created object to study
411 geompy.addToStudy( Face_1, "Face_1" )
412 geompy.addToStudy( Vertex_1, "Vertex_1" )
413 geompy.addToStudy( Vertex_2, "Vertex_2" )
414 geompy.addToStudy( Box_1, "Box_1" )
415 geompy.addToStudy( Vertex_3, "Vertex_3" )
416 geompy.addToStudy( Vector_X, "Vector_X" )
417 geompy.addToStudy( Vector_Y, "Vector_Y" )
418 geompy.addToStudy( LocalCS_1, "LocalCS_1" )
419 geompy.addToStudy( LocalCS_2, "LocalCS_3" )
420 geompy.addToStudy( LocalCS_FACE, "LocalCS_FACE" )
421 geompy.addToStudy( LocalCS_BOX, "LocalCS_BOX" )
422 \endcode
423
424 */