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