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