3 \page tui_transformation_operations_page Transformation Operations
5 \anchor tui_translation
6 <br><h2>Translation</h2>
11 gg = salome.ImportComponentGUI("GEOM")
13 # create a vertex and a vector
14 p1 = geompy.MakeVertex(10, 40, 0)
15 p2 = geompy.MakeVertex( 0, 0, 50)
16 p3 = geompy.MakeVertex(50, 80, 0)
17 v = geompy.MakeVector(p1, p2)
18 vt = geompy.MakeVector(p1, p3)
23 cylinder = geompy.MakeCylinder(p1, v, radius1, height)
25 # translate the given object along the vector, specified by its end points
26 # (all three functions produce the same result)
27 translation1 = geompy.MakeTranslationTwoPoints(cylinder, p1, p3)
28 translation2 = geompy.MakeTranslation(cylinder, 40, 40, 0)
29 translation3 = geompy.MakeTranslationVector(cylinder, vt)
30 translation4 = geompy.MakeTranslationVectorDistance(cylinder, vt, 200)
32 # add objects in the study
33 id_cylinder = geompy.addToStudy(cylinder, "Cylinder")
34 id_translation1 = geompy.addToStudy(translation1, "Translation1")
35 id_translation2 = geompy.addToStudy(translation2, "Translation2")
36 id_translation3 = geompy.addToStudy(translation3, "Translation3")
37 id_translation4 = geompy.addToStudy(translation4, "Translation4")
40 gg.createAndDisplayGO(id_cylinder)
41 gg.setDisplayMode(id_cylinder,1)
42 gg.createAndDisplayGO(id_translation1)
43 gg.setDisplayMode(id_translation1,1)
44 gg.createAndDisplayGO(id_translation2)
45 gg.setDisplayMode(id_translation2,1)
46 gg.createAndDisplayGO(id_translation3)
47 gg.setDisplayMode(id_translation3,1)
48 gg.createAndDisplayGO(id_translation4)
49 gg.setDisplayMode(id_translation4,1)
59 gg = salome.ImportComponentGUI("GEOM")
61 # create a vertex and a vector
62 p1 = geompy.MakeVertex(10, 40, 0)
63 p2 = geompy.MakeVertex( 0, 0, 50)
64 p3 = geompy.MakeVertex(10, 50,-20)
65 p4 = geompy.MakeVertex(10, 50, 60)
66 v = geompy.MakeVector(p1, p2)
67 vr = geompy.MakeVector(p3, p4)
72 cylinder = geompy.MakeCylinder(p1, v, radius1, height)
74 # rotate the given object around the given axis by the given angle
75 rotation1 = geompy.MakeRotation(cylinder, vr, math.pi)
76 rotation2 = geompy.MakeRotationThreePoints(cylinder, p4, p1, p2)
78 # add objects in the study
79 id_vr = geompy.addToStudy(vr, "Rotation 1 axis")
80 id_p4 = geompy.addToStudy(p4, "Rotation 2 center")
81 id_p1 = geompy.addToStudy(p1, "Rotation 2 point 1")
82 id_p2 = geompy.addToStudy(p2, "Rotation 2 point 2")
83 id_cylinder = geompy.addToStudy(cylinder, "Cylinder")
84 id_rotation1 = geompy.addToStudy(rotation1, "Rotation 1")
85 id_rotation2 = geompy.addToStudy(rotation2, "Rotation 2")
88 gg.createAndDisplayGO(id_vr)
89 gg.createAndDisplayGO(id_p4)
90 gg.createAndDisplayGO(id_p1)
91 gg.createAndDisplayGO(id_p2)
92 gg.createAndDisplayGO(id_cylinder)
93 gg.setDisplayMode(id_cylinder,1)
94 gg.createAndDisplayGO(id_rotation1)
95 gg.createAndDisplayGO(id_rotation2)
96 gg.setDisplayMode(id_rotation1,1)
97 gg.setDisplayMode(id_rotation2,1)
100 \anchor tui_modify_location
101 <br><h2>Modify Location</h2>
107 gg = salome.ImportComponentGUI("GEOM")
109 # create a vertex and a vector
110 p1 = geompy.MakeVertex(10, 40, 0)
111 p2 = geompy.MakeVertex( 0, 0, 50)
112 v = geompy.MakeVector(p1, p2)
117 cylinder = geompy.MakeCylinder(p1, v, radius1, height)
118 circle = geompy.MakeCircle(p2, v, radius1)
120 # create local coordinate systems
121 cs1 = geompy.MakeMarker( 0, 0, 0, 1,0,0, 0,1,0)
122 cs2 = geompy.MakeMarker(30,40,40, 1,0,0, 0,1,0)
124 # modify the location of the given object
125 position = geompy.MakePosition(cylinder, cs1, cs2)
126 position2 = geompy.PositionAlongPath(position, circle, 0.75, 1)
128 # add objects in the study
129 id_cs1 = geompy.addToStudy(cs1, "Coordinate system 1")
130 id_cs2 = geompy.addToStudy(cs2, "Coordinate system 2")
131 id_cylinder = geompy.addToStudy(cylinder, "Cylinder")
132 id_circle = geompy.addToStudy(circle, "Circle")
133 id_position = geompy.addToStudy(position, "Position")
134 id_position2 = geompy.addToStudy(position2, "PositionAlongPath")
136 # display the results
137 gg.createAndDisplayGO(id_cylinder)
138 gg.setDisplayMode(id_cylinder,1)
139 gg.createAndDisplayGO(id_position)
140 gg.setDisplayMode(id_position,1)
141 gg.createAndDisplayGO(id_circle)
142 gg.setDisplayMode(id_circle,1)
143 gg.createAndDisplayGO(id_position2)
144 gg.setDisplayMode(id_position2,1)
148 <br><h2>Mirror Image</h2>
153 gg = salome.ImportComponentGUI("GEOM")
156 box = geompy.MakeBoxDXDYDZ(200, 200, 200)
158 # create an object, symmetrical to another object through the given plane
159 p1 = geompy.MakeVertex( 0, 25, 0)
160 p2 = geompy.MakeVertex( 5, 25, 0)
161 p3 = geompy.MakeVertex( 0,-30, 40)
162 plane = geompy.MakePlaneThreePnt(p1, p2, p3, 1000.)
163 mirror1 = geompy.MakeMirrorByPlane(box, plane)
165 # create an object, symmetrical to another object through the given axis
166 p4 = geompy.MakeVertex( 210, 210, -20)
167 p5 = geompy.MakeVertex( 210, 210, 220)
168 axis = geompy.MakeVector(p4, p5)
169 mirror2 = geompy.MakeMirrorByAxis(box, axis)
171 # create an object, symmetrical to another object through the given point
172 mirror3 = geompy.MakeMirrorByPoint(box, p4)
174 # add objects in the study
175 id_box = geompy.addToStudy(box, "Box")
176 id_plane = geompy.addToStudy(plane, "Plane")
177 id_mirror1 = geompy.addToStudy(mirror1, "Mirror plane")
178 id_axis = geompy.addToStudy(axis, "Axis")
179 id_mirror2 = geompy.addToStudy(mirror2, "Mirror axis")
180 id_p4 = geompy.addToStudy(p4, "Point")
181 id_mirror3 = geompy.addToStudy(mirror3, "Mirror point")
183 # display the results
184 gg.createAndDisplayGO(id_box)
185 gg.setDisplayMode(id_box,1)
186 gg.createAndDisplayGO(id_plane)
187 gg.createAndDisplayGO(id_mirror1)
188 gg.setDisplayMode(id_mirror1,1)
189 gg.createAndDisplayGO(id_axis)
190 gg.createAndDisplayGO(id_mirror2)
191 gg.setDisplayMode(id_mirror2,1)
192 gg.createAndDisplayGO(id_p4)
193 gg.createAndDisplayGO(id_mirror3)
194 gg.setDisplayMode(id_mirror3,1)
198 <br><h2>Scale Transform</h2>
203 gg = salome.ImportComponentGUI("GEOM")
205 # create a box and a sphere
206 box = geompy.MakeBoxDXDYDZ(200, 200, 200)
208 # scale the given object by the factor
209 p0 = geompy.MakeVertex(100, 100, 100)
211 scale = geompy.MakeScaleTransform(box, p0, factor)
213 # add objects in the study
214 id_box = geompy.addToStudy(box, "Box")
215 id_scale = geompy.addToStudy(scale, "Scale")
217 # display the results
218 gg.createAndDisplayGO(id_box)
219 gg.setDisplayMode(id_box,1)
220 gg.setTransparency(id_box,0.5)
221 gg.createAndDisplayGO(id_scale)
222 gg.setDisplayMode(id_scale,1)
226 <br><h2>Offset Surface</h2>
231 gg = salome.ImportComponentGUI("GEOM")
233 # create a box and a sphere
234 box = geompy.MakeBox(20, 20, 20, 200, 200, 200)
236 # create a new object as offset of the given object
237 offset = geompy.MakeOffset(box, 70.)
239 # add objects in the study
240 id_box = geompy.addToStudy(box, "Box")
241 id_offset = geompy.addToStudy(offset, "Offset")
243 # display the results
244 gg.createAndDisplayGO(id_box)
245 gg.setDisplayMode(id_box,1)
246 gg.createAndDisplayGO(id_offset)
249 \anchor tui_multi_translation
250 <br><h2>Multi Translation</h2>
255 gg = salome.ImportComponentGUI("GEOM")
257 # create vertices and vectors
258 p0 = geompy.MakeVertex( 0., 0., 0.)
259 px = geompy.MakeVertex(20., 0., 0.)
260 py = geompy.MakeVertex( 0., 20., 0.)
261 pz = geompy.MakeVertex( 0., 0., 20.)
262 pxy = geompy.MakeVertex( 50., 0., 0.)
263 pxyz = geompy.MakeVertex( 50., 50., 50.)
264 vz = geompy.MakeVector(p0, pz)
265 vxy = geompy.MakeVector(px, py)
266 vtr1d = geompy.MakeVector(p0, pxyz)
267 vtr2d = geompy.MakeVector(p0, pxy)
270 arc = geompy.MakeArc(py, pz, px)
273 wire = geompy.MakeWire([vxy, arc])
275 # create a planar face
276 face = geompy.MakeFace(wire, 1)
279 prism = geompy.MakePrismVecH(face, vz, 20.0)
281 # translate the given object along the given vector a given number of times
282 tr1d = geompy.MakeMultiTranslation1D(prism, vtr1d, 20, 4)
284 # consequently apply two specified translations to the object a given number of times
285 tr2d = geompy.MakeMultiTranslation2D(prism, vtr1d, 20, 4, vtr2d, 80, 3)
287 # add objects in the study
288 id_prism = geompy.addToStudy(prism,"Prism")
289 id_tr1d = geompy.addToStudy(tr1d,"Translation 1D")
290 id_tr2d = geompy.addToStudy(tr2d,"Translation 2D")
292 # display the prism and the results of fillet operation
293 gg.createAndDisplayGO(id_prism)
294 gg.setDisplayMode(id_prism,1)
295 gg.createAndDisplayGO(id_tr1d)
296 gg.setDisplayMode(id_tr1d,1)
297 gg.createAndDisplayGO(id_tr2d)
298 gg.setDisplayMode(id_tr2d,1)
301 \anchor tui_multi_rotation
302 <br><h2>Multi Rotation</h2>
307 gg = salome.ImportComponentGUI("GEOM")
309 # create vertices and vectors
310 p0 = geompy.MakeVertex( 0., 0., 0.)
311 px = geompy.MakeVertex(20., 0., 0.)
312 py = geompy.MakeVertex( 0., 20., 0.)
313 pz = geompy.MakeVertex( 0., 0., 20.)
314 pxyz = geompy.MakeVertex( 50., 50., 10.)
315 vz = geompy.MakeVector(p0, pz)
316 vxy = geompy.MakeVector(px, py)
317 vrot1d = geompy.MakeVector(p0, pxyz)
320 arc = geompy.MakeArc(py, pz, px)
323 wire = geompy.MakeWire([vxy, arc])
325 # create a planar face
326 face = geompy.MakeFace(wire, 1)
329 prism = geompy.MakePrismVecH(face, vz, 20.0)
331 # rotate the given object around the given axis by the given angle a given number of times
332 rot1d = geompy.MultiRotate1D(prism, vrot1d, 4)
334 # rotate the given object around the given axis by the given angle a given number of times
335 # and multi-translate the result of each rotation
336 rot2d = geompy.MultiRotate2D(prism, vrot1d, 60, 4, 50, 5)
338 # add objects in the study
339 id_prism = geompy.addToStudy(prism,"Prism")
340 id_rot1d = geompy.addToStudy(rot1d,"Rotation 1D")
341 id_rot2d = geompy.addToStudy(rot2d,"Rotation 2D")
343 # display the prism and the results of fillet operation
344 gg.createAndDisplayGO(id_prism)
345 gg.setDisplayMode(id_prism,1)
346 gg.createAndDisplayGO(id_rot1d)
347 gg.setDisplayMode(id_rot1d,1)
348 gg.createAndDisplayGO(id_rot2d)
349 gg.setDisplayMode(id_rot2d,1)
358 gg = salome.ImportComponentGUI("GEOM")
360 ShapeTypeEdge = geompy.ShapeType["EDGE"]
362 # create vertices and vectors
363 p0 = geompy.MakeVertex( 0., 0., 0.)
364 px = geompy.MakeVertex(100., 0., 0.)
365 py = geompy.MakeVertex( 0., 100., 0.)
366 pz = geompy.MakeVertex( 0., 0., 100.)
367 vz = geompy.MakeVector(p0, pz)
368 vxy = geompy.MakeVector(px, py)
371 arc = geompy.MakeArc(py, pz, px)
374 wire = geompy.MakeWire([vxy, arc])
376 # create a planar face
377 face = geompy.MakeFace(wire, 1)
380 prism = geompy.MakePrismVecH(face, vz, 100.0)
382 # get the list of IDs (IDList) for the fillet
383 prism_edges = geompy.SubShapeAllSorted(prism, ShapeTypeEdge)
385 IDlist_e.append(geompy.GetSubShapeID(prism, prism_edges[0]))
386 IDlist_e.append(geompy.GetSubShapeID(prism, prism_edges[1]))
387 IDlist_e.append(geompy.GetSubShapeID(prism, prism_edges[2]))
389 # make a fillet on the specified edges of the given shape
390 fillet = geompy.MakeFillet(prism, radius, ShapeTypeEdge, IDlist_e)
392 # make a fillet on all edges of the given shape
393 filletall = geompy.MakeFilletAll(prism, radius)
395 # add objects in the study
396 id_prism = geompy.addToStudy(prism,"Prism")
397 id_fillet = geompy.addToStudy(fillet,"Fillet")
398 id_filletall = geompy.addToStudy(filletall,"Fillet all")
400 # display the prism and the results of fillet operation
401 gg.createAndDisplayGO(id_prism)
402 gg.setDisplayMode(id_prism,1)
403 gg.createAndDisplayGO(id_fillet)
404 gg.setDisplayMode(id_fillet,1)
405 gg.createAndDisplayGO(id_filletall)
406 gg.setDisplayMode(id_filletall,1)
415 gg = salome.ImportComponentGUI("GEOM")
418 ShapeTypeFace = geompy.ShapeType["FACE"]
420 # create vertices and vectors
421 p0 = geompy.MakeVertex( 0., 0., 0.)
422 px = geompy.MakeVertex(100., 0., 0.)
423 py = geompy.MakeVertex( 0., 100., 0.)
424 pz = geompy.MakeVertex( 0., 0., 100.)
425 vz = geompy.MakeVector(p0, pz)
426 vxy = geompy.MakeVector(px, py)
429 arc = geompy.MakeArc(py, pz, px)
432 wire = geompy.MakeWire([vxy, arc])
434 # create a planar face
435 face = geompy.MakeFace(wire, 1)
438 prism = geompy.MakePrismVecH(face, vz, 100.0)
440 # get the list of IDs (IDList) for the chamfer
441 prism_faces = geompy.SubShapeAllSorted(prism, ShapeTypeFace)
442 f_ind_1 = geompy.GetSubShapeID(prism, prism_faces[0])
443 f_ind_2 = geompy.GetSubShapeID(prism, prism_faces[1])
444 IDlist_f = [f_ind_1, f_ind_2]
446 # perform a chamfer on the edges common to the specified faces
447 chamfer_e = geompy.MakeChamferEdge(prism, d1, d2, f_ind_1, f_ind_2)
449 # perform a chamfer on all edges of the specified faces
450 chamfer_f = geompy.MakeChamferFaces(prism, d1, d2, IDlist_f)
451 chamfer_f1 = geompy.MakeChamfer(prism, d1, d2, ShapeTypeFace, IDlist_f)
453 # perform a symmetric chamfer on all edges of the given shape
454 chamfer_all = geompy.MakeChamferAll(prism, d1)
456 # add objects in the study
457 id_prism = geompy.addToStudy(prism,"Prism")
458 id_chamfer_e = geompy.addToStudy(chamfer_e,"Chamfer edge")
459 id_chamfer_f = geompy.addToStudy(chamfer_f,"Chamfer faces")
460 id_chamfer_f1 = geompy.addToStudy(chamfer_f1,"Chamfer faces 1")
461 id_chamfer_all = geompy.addToStudy(chamfer_all,"Chamfer all")
463 # display the prism and the results of chamfer operation
464 gg.createAndDisplayGO(id_prism)
465 gg.setDisplayMode(id_prism,1)
466 gg.createAndDisplayGO(id_chamfer_e)
467 gg.setDisplayMode(id_chamfer_e,1)
468 gg.createAndDisplayGO(id_chamfer_f)
469 gg.setDisplayMode(id_chamfer_f,1)
470 gg.createAndDisplayGO(id_chamfer_f1)
471 gg.setDisplayMode(id_chamfer_f1,1)
472 gg.createAndDisplayGO(id_chamfer_all)
473 gg.setDisplayMode(id_chamfer_all,1)