Salome HOME
d9c30a23b4bbdf7bc79237a996866c6cf340823a
[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_curve
137 <br><h2>Creation of a Curve</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(50. , 100., 200.)
147 p2 = geompy.MakeVertex(150.,  50., 100.)
148 p3 = geompy.MakeVertex(100., 150., 170.)
149 p4 = geompy.MakeVertex(200., 200., 150.)
150
151 # create a polyline from a list of points
152 polyline = geompy.MakePolyline([p0, p1, p2, p3, p4])
153
154 # create a bezier curve from a list of points
155 bezier = geompy.MakeBezier([p0, p1, p2, p3, p4])
156
157 #create a b-spline curve from a list of points
158 interpol = geompy.MakeInterpol([p0, p1, p2, p3, p4])
159
160 # add objects in the study
161 id_p0       = geompy.addToStudy(p0,       "Point1")
162 id_p1       = geompy.addToStudy(p1,       "Point2")
163 id_p2       = geompy.addToStudy(p2,       "Point3")
164 id_p3       = geompy.addToStudy(p3,       "Point4")
165 id_p4       = geompy.addToStudy(p4,       "Point5")
166 id_polyline = geompy.addToStudy(polyline, "Polyline")
167 id_bezier   = geompy.addToStudy(bezier,   "Bezier")
168 id_interpol = geompy.addToStudy(interpol, "Interpol")
169
170 # display the points and the curves
171 gg.createAndDisplayGO(id_p0)
172 gg.createAndDisplayGO(id_p1)
173 gg.createAndDisplayGO(id_p2)
174 gg.createAndDisplayGO(id_p3)
175 gg.createAndDisplayGO(id_p4)
176 gg.createAndDisplayGO(id_polyline)
177 gg.createAndDisplayGO(id_bezier)
178 gg.createAndDisplayGO(id_interpol) 
179 \endcode
180
181 \anchor tui_creation_vector
182 <br><h2>Creation of a Vector</h2>
183
184 \code
185 mport geompy
186 import salome
187 gg = salome.ImportComponentGUI("GEOM")
188
189 # create vertices
190 p1 = geompy.MakeVertex(10., 50., 20.)
191 p2 = geompy.MakeVertex(70., 70., 70.)
192
193 # create a vector from two points
194 vector1 = geompy.MakeVector(p1, p2)
195
196 # create a vector from the given components
197 vector2 = geompy.MakeVectorDXDYDZ(30, 30, 100)
198
199 # add objects in the study
200 id_p1      = geompy.addToStudy(p1,     "Point1")
201 id_p2      = geompy.addToStudy(p2,     "Point2")
202 id_vector1 = geompy.addToStudy(vector1,"Vector1")
203 id_vector2 = geompy.addToStudy(vector2,"Vector2")
204
205 # display the points and the vectors
206 gg.createAndDisplayGO(id_p1)
207 gg.createAndDisplayGO(id_p2)
208 gg.createAndDisplayGO(id_vector1)
209 gg.createAndDisplayGO(id_vector2) 
210 \endcode
211
212 \anchor tui_creation_plane
213 <br><h2>Creation of a Plane</h2>
214
215 \code
216 import geompy
217 import salome
218 gg = salome.ImportComponentGUI("GEOM")
219
220 # create vertices
221 p1 = geompy.MakeVertex(  0.,   0., 100.)
222 p2 = geompy.MakeVertex(100.,   0.,   0.)
223 p3 = geompy.MakeVertex(200., 200., 200.)
224 p4 = geompy.MakeVertex(100., 100.,   0.)
225 p5 = geompy.MakeVertex(0.  , 100.,   0.)
226
227 # create a vector from the given components
228 vector = geompy.MakeVectorDXDYDZ(100., 100., 100.)
229
230 # create a vector from two points
231 vector_arc = geompy.MakeVector(p2, p5)
232
233 # create an arc from three points
234 arc = geompy.MakeArc(p2, p4, p5)
235
236 # create a wire
237 wire = geompy.MakeWire([vector_arc, arc])
238
239 # create a face
240 isPlanarWanted = 1
241 face = geompy.MakeFace(wire, isPlanarWanted)
242 trimsize = 1000.
243
244 # create a plane from a point, a vector and a trimsize
245 plane1 = geompy.MakePlane(p1, vector, trimsize)
246
247 # create a plane from three points and a trimsize
248 plane2 = geompy.MakePlaneThreePnt(p1, p2, p3, trimsize)
249
250 # create a plane from the given face
251 plane3 = geompy.MakePlaneFace(face, trimsize)
252
253 # add objects in the study
254 id_face   = geompy.addToStudy(face,  "Face")
255 id_plane1 = geompy.addToStudy(plane1,"Plane1")
256 id_plane2 = geompy.addToStudy(plane2,"Plane2")
257 id_plane3 = geompy.addToStudy(plane3,"Plane3")
258
259 # display the points and the vectors
260 gg.createAndDisplayGO(id_face)
261 gg.createAndDisplayGO(id_plane1)
262 gg.createAndDisplayGO(id_plane2)
263 gg.createAndDisplayGO(id_plane3)
264 gg.setDisplayMode(id_plane1,1)
265 gg.setTransparency(id_plane1,0.5)
266 gg.setDisplayMode(id_plane2,1)
267 gg.setTransparency(id_plane2,0.5)
268 gg.setDisplayMode(id_plane3,1)
269 gg.setTransparency(id_plane3,0.5) 
270 \endcode
271
272 */