Salome HOME
89baf140d5ad9bbf223a9951ebc2d15501052812
[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 p50 = geompy.MakeVertex(50., 50., 50.)
120
121 # create a vector from two points
122 vector  = geompy.MakeVector(p0, p50)
123
124 # create an ellipse from a point, a vector and radiuses
125 ellipse = geompy.MakeEllipse(p50, vector, 50, 25)
126
127 # add objects in the study
128 id_vector  = geompy.addToStudy(vector, "Vector")
129 id_ellipse = geompy.addToStudy(ellipse,"Ellipse")
130
131 # display the ellipse and its normal vector
132 gg.createAndDisplayGO(id_vector)
133 gg.createAndDisplayGO(id_ellipse)
134 \endcode
135
136 \anchor tui_creation_arc
137 <br><h2>Creation of an Arc</h2>
138
139 \code
140 import geompy
141 import salome
142 gg = salome.ImportComponentGUI("GEOM")
143
144 # create vertices
145 p0 = geompy.MakeVertex(0., 0., 0.)
146 p1 = geompy.MakeVertex(100., 0., 0.)
147 p2 = geompy.MakeVertex(50., 0., 50.)
148
149 # create an arc from a three points
150 arc1 = geompy.MakeArc(p0, p1, p2)
151
152 # create an arc from a center point, a start point and end point
153 arc2 = geompy.MakeArcCenter(p0, p1, p2, 1)
154
155 # create an arc from a center point, a major point and minor point
156 arc3 = geompy.MakeArcOfEllipse(p0, p1, p2)
157
158 # add objects in the study
159 id_arc1 = geompy.addToStudy(arc1, "Arc 1")
160 id_arc2 = geompy.addToStudy(arc2, "Arc 2")
161 id_arc3 = geompy.addToStudy(arc3, "Arc 3")
162
163 # display the arcs
164 gg.createAndDisplayGO(id_arc1)
165 gg.createAndDisplayGO(id_arc2)
166 gg.createAndDisplayGO(id_arc3)
167 \endcode
168  
169 \anchor tui_creation_curve
170 <br><h2>Creation of a Curve</h2>
171
172 \code
173 import geompy
174 import salome
175 gg = salome.ImportComponentGUI("GEOM")
176
177 # create vertices
178 p0 = geompy.MakeVertex(0.  , 0.  , 0.  )
179 p1 = geompy.MakeVertex(50. , 100., 200.)
180 p2 = geompy.MakeVertex(150.,  50., 100.)
181 p3 = geompy.MakeVertex(100., 150., 170.)
182 p4 = geompy.MakeVertex(200., 200., 150.)
183
184 # create a polyline from a list of points
185 polyline = geompy.MakePolyline([p0, p1, p2, p3, p4])
186
187 # create a bezier curve from a list of points
188 bezier = geompy.MakeBezier([p0, p1, p2, p3, p4])
189
190 #create a b-spline curve from a list of points
191 interpol = geompy.MakeInterpol([p0, p1, p2, p3, p4])
192
193 # add objects in the study
194 id_p0       = geompy.addToStudy(p0,       "Point1")
195 id_p1       = geompy.addToStudy(p1,       "Point2")
196 id_p2       = geompy.addToStudy(p2,       "Point3")
197 id_p3       = geompy.addToStudy(p3,       "Point4")
198 id_p4       = geompy.addToStudy(p4,       "Point5")
199 id_polyline = geompy.addToStudy(polyline, "Polyline")
200 id_bezier   = geompy.addToStudy(bezier,   "Bezier")
201 id_interpol = geompy.addToStudy(interpol, "Interpol")
202
203 # display the points and the curves
204 gg.createAndDisplayGO(id_p0)
205 gg.createAndDisplayGO(id_p1)
206 gg.createAndDisplayGO(id_p2)
207 gg.createAndDisplayGO(id_p3)
208 gg.createAndDisplayGO(id_p4)
209 gg.createAndDisplayGO(id_polyline)
210 gg.createAndDisplayGO(id_bezier)
211 gg.createAndDisplayGO(id_interpol) 
212 \endcode
213
214 \anchor tui_creation_vector
215 <br><h2>Creation of a Vector</h2>
216
217 \code
218 mport geompy
219 import salome
220 gg = salome.ImportComponentGUI("GEOM")
221
222 # create vertices
223 p1 = geompy.MakeVertex(10., 50., 20.)
224 p2 = geompy.MakeVertex(70., 70., 70.)
225
226 # create a vector from two points
227 vector1 = geompy.MakeVector(p1, p2)
228
229 # create a vector from the given components
230 vector2 = geompy.MakeVectorDXDYDZ(30, 30, 100)
231
232 # add objects in the study
233 id_p1      = geompy.addToStudy(p1,     "Point1")
234 id_p2      = geompy.addToStudy(p2,     "Point2")
235 id_vector1 = geompy.addToStudy(vector1,"Vector1")
236 id_vector2 = geompy.addToStudy(vector2,"Vector2")
237
238 # display the points and the vectors
239 gg.createAndDisplayGO(id_p1)
240 gg.createAndDisplayGO(id_p2)
241 gg.createAndDisplayGO(id_vector1)
242 gg.createAndDisplayGO(id_vector2) 
243 \endcode
244
245 \anchor tui_creation_plane
246 <br><h2>Creation of a Plane</h2>
247
248 \code
249 import geompy
250 import salome
251 gg = salome.ImportComponentGUI("GEOM")
252
253 # create vertices
254 p1 = geompy.MakeVertex(  0.,   0., 100.)
255 p2 = geompy.MakeVertex(100.,   0.,   0.)
256 p3 = geompy.MakeVertex(200., 200., 200.)
257 p4 = geompy.MakeVertex(100., 100.,   0.)
258 p5 = geompy.MakeVertex(0.  , 100.,   0.)
259
260 # create a vector from the given components
261 vector = geompy.MakeVectorDXDYDZ(100., 100., 100.)
262
263 # create a vector from two points
264 vector_arc = geompy.MakeVector(p2, p5)
265
266 # create an arc from three points
267 arc = geompy.MakeArc(p2, p4, p5)
268
269 # create a wire
270 wire = geompy.MakeWire([vector_arc, arc])
271
272 # create a face
273 isPlanarWanted = 1
274 face = geompy.MakeFace(wire, isPlanarWanted)
275 trimsize = 1000.
276
277 # create a plane from a point, a vector and a trimsize
278 plane1 = geompy.MakePlane(p1, vector, trimsize)
279
280 # create a plane from three points and a trimsize
281 plane2 = geompy.MakePlaneThreePnt(p1, p2, p3, trimsize)
282
283 # create a plane from the given face
284 plane3 = geompy.MakePlaneFace(face, trimsize)
285
286 # add objects in the study
287 id_face   = geompy.addToStudy(face,  "Face")
288 id_plane1 = geompy.addToStudy(plane1,"Plane1")
289 id_plane2 = geompy.addToStudy(plane2,"Plane2")
290 id_plane3 = geompy.addToStudy(plane3,"Plane3")
291
292 # display the points and the vectors
293 gg.createAndDisplayGO(id_face)
294 gg.createAndDisplayGO(id_plane1)
295 gg.createAndDisplayGO(id_plane2)
296 gg.createAndDisplayGO(id_plane3)
297 gg.setDisplayMode(id_plane1,1)
298 gg.setTransparency(id_plane1,0.5)
299 gg.setDisplayMode(id_plane2,1)
300 gg.setTransparency(id_plane2,0.5)
301 gg.setDisplayMode(id_plane3,1)
302 gg.setTransparency(id_plane3,0.5) 
303 \endcode
304
305 */