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