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