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)
31 # add objects in the study
32 id_cylinder = geompy.addToStudy(cylinder, "Cylinder")
33 id_translation1 = geompy.addToStudy(translation1, "Translation1")
34 id_translation2 = geompy.addToStudy(translation2, "Translation2")
35 id_translation3 = geompy.addToStudy(translation3, "Translation3")
38 gg.createAndDisplayGO(id_cylinder)
39 gg.setDisplayMode(id_cylinder,1)
40 gg.createAndDisplayGO(id_translation1)
41 gg.setDisplayMode(id_translation1,1)
42 gg.createAndDisplayGO(id_translation2)
43 gg.setDisplayMode(id_translation2,1)
44 gg.createAndDisplayGO(id_translation3)
45 gg.setDisplayMode(id_translation3,1)
55 gg = salome.ImportComponentGUI("GEOM")
57 # create a vertex and a vector
58 p1 = geompy.MakeVertex(10, 40, 0)
59 p2 = geompy.MakeVertex( 0, 0, 50)
60 p3 = geompy.MakeVertex(10, 50,-20)
61 p4 = geompy.MakeVertex(10, 50, 60)
62 v = geompy.MakeVector(p1, p2)
63 vr = geompy.MakeVector(p3, p4)
68 cylinder = geompy.MakeCylinder(p1, v, radius1, height)
70 # rotate the given object around the given axis by the given angle
71 rotation1 = geompy.MakeRotation(cylinder, vr, math.pi)
72 rotation2 = geompy.MakeRotationThreePoints(cylinder, p4, p1, p2)
74 # add objects in the study
75 id_vr = geompy.addToStudy(vr, "Rotation 1 axis")
76 id_p4 = geompy.addToStudy(p4, "Rotation 2 center")
77 id_p1 = geompy.addToStudy(p1, "Rotation 2 point 1")
78 id_p2 = geompy.addToStudy(p2, "Rotation 2 point 2")
79 id_cylinder = geompy.addToStudy(cylinder, "Cylinder")
80 id_rotation1 = geompy.addToStudy(rotation1, "Rotation 1")
81 id_rotation2 = geompy.addToStudy(rotation2, "Rotation 2")
84 gg.createAndDisplayGO(id_vr)
85 gg.createAndDisplayGO(id_p4)
86 gg.createAndDisplayGO(id_p1)
87 gg.createAndDisplayGO(id_p2)
88 gg.createAndDisplayGO(id_cylinder)
89 gg.setDisplayMode(id_cylinder,1)
90 gg.createAndDisplayGO(id_rotation1)
91 gg.createAndDisplayGO(id_rotation2)
92 gg.setDisplayMode(id_rotation1,1)
93 gg.setDisplayMode(id_rotation2,1)
96 \anchor tui_modify_location
97 <br><h2>Modify Location</h2>
103 gg = salome.ImportComponentGUI("GEOM")
105 # create a vertex and a vector
106 p1 = geompy.MakeVertex(10, 40, 0)
107 p2 = geompy.MakeVertex( 0, 0, 50)
108 v = geompy.MakeVector(p1, p2)
113 cylinder = geompy.MakeCylinder(p1, v, radius1, height)
115 # create local coordinate systems
116 cs1 = geompy.MakeMarker( 0, 0, 0, 1,0,0, 0,1,0)
117 cs2 = geompy.MakeMarker(30,40,40, 1,0,0, 0,1,0)
119 # modify the location of the given object
120 position = geompy.MakePosition(cylinder, cs1, cs2)
122 # add objects in the study
123 id_cs1 = geompy.addToStudy(cs1, "Coordinate system 1")
124 id_cs2 = geompy.addToStudy(cs2, "Coordinate system 2")
125 id_cylinder = geompy.addToStudy(cylinder, "Cylinder")
126 id_position = geompy.addToStudy(position, "Position")
128 # display the results
129 gg.createAndDisplayGO(id_cylinder)
130 gg.setDisplayMode(id_cylinder,1)
131 gg.createAndDisplayGO(id_position)
132 gg.setDisplayMode(id_position,1)
136 <br><h2>Mirror Image</h2>
141 gg = salome.ImportComponentGUI("GEOM")
144 box = geompy.MakeBoxDXDYDZ(200, 200, 200)
146 # create an object, symmetrical to another object through the given plane
147 p1 = geompy.MakeVertex( 0, 25, 0)
148 p2 = geompy.MakeVertex( 5, 25, 0)
149 p3 = geompy.MakeVertex( 0,-30, 40)
150 plane = geompy.MakePlaneThreePnt(p1, p2, p3, 1000.)
151 mirror1 = geompy.MakeMirrorByPlane(box, plane)
153 # create an object, symmetrical to another object through the given axis
154 p4 = geompy.MakeVertex( 210, 210, -20)
155 p5 = geompy.MakeVertex( 210, 210, 220)
156 axis = geompy.MakeVector(p4, p5)
157 mirror2 = geompy.MakeMirrorByAxis(box, axis)
159 # create an object, symmetrical to another object through the given point
160 mirror3 = geompy.MakeMirrorByPoint(box, p4)
162 # add objects in the study
163 id_box = geompy.addToStudy(box, "Box")
164 id_plane = geompy.addToStudy(plane, "Plane")
165 id_mirror1 = geompy.addToStudy(mirror1, "Mirror plane")
166 id_axis = geompy.addToStudy(axis, "Axis")
167 id_mirror2 = geompy.addToStudy(mirror2, "Mirror axis")
168 id_p4 = geompy.addToStudy(p4, "Point")
169 id_mirror3 = geompy.addToStudy(mirror3, "Mirror point")
171 # display the results
172 gg.createAndDisplayGO(id_box)
173 gg.setDisplayMode(id_box,1)
174 gg.createAndDisplayGO(id_plane)
175 gg.createAndDisplayGO(id_mirror1)
176 gg.setDisplayMode(id_mirror1,1)
177 gg.createAndDisplayGO(id_axis)
178 gg.createAndDisplayGO(id_mirror2)
179 gg.setDisplayMode(id_mirror2,1)
180 gg.createAndDisplayGO(id_p4)
181 gg.createAndDisplayGO(id_mirror3)
182 gg.setDisplayMode(id_mirror3,1)
186 <br><h2>Scale Transform</h2>
191 gg = salome.ImportComponentGUI("GEOM")
193 # create a box and a sphere
194 box = geompy.MakeBoxDXDYDZ(200, 200, 200)
196 # scale the given object by the factor
197 p0 = geompy.MakeVertex(100, 100, 100)
199 scale = geompy.MakeScaleTransform(box, p0, factor)
201 # add objects in the study
202 id_box = geompy.addToStudy(box, "Box")
203 id_scale = geompy.addToStudy(scale, "Scale")
205 # display the results
206 gg.createAndDisplayGO(id_box)
207 gg.setDisplayMode(id_box,1)
208 gg.setTransparency(id_box,0.5)
209 gg.createAndDisplayGO(id_scale)
210 gg.setDisplayMode(id_scale,1)
214 <br><h2>Offset Surface</h2>
219 gg = salome.ImportComponentGUI("GEOM")
221 # create a box and a sphere
222 box = geompy.MakeBox(20, 20, 20, 200, 200, 200)
224 # create a new object as offset of the given object
225 offset = geompy.MakeOffset(box, 70.)
227 # add objects in the study
228 id_box = geompy.addToStudy(box, "Box")
229 id_offset = geompy.addToStudy(offset, "Offset")
231 # display the results
232 gg.createAndDisplayGO(id_box)
233 gg.setDisplayMode(id_box,1)
234 gg.createAndDisplayGO(id_offset)
237 \anchor tui_multi_translation
238 <br><h2>Multi Translation</h2>
243 gg = salome.ImportComponentGUI("GEOM")
245 # create vertices and vectors
246 p0 = geompy.MakeVertex( 0., 0., 0.)
247 px = geompy.MakeVertex(20., 0., 0.)
248 py = geompy.MakeVertex( 0., 20., 0.)
249 pz = geompy.MakeVertex( 0., 0., 20.)
250 pxy = geompy.MakeVertex( 50., 0., 0.)
251 pxyz = geompy.MakeVertex( 50., 50., 50.)
252 vz = geompy.MakeVector(p0, pz)
253 vxy = geompy.MakeVector(px, py)
254 vtr1d = geompy.MakeVector(p0, pxyz)
255 vtr2d = geompy.MakeVector(p0, pxy)
258 arc = geompy.MakeArc(py, pz, px)
261 wire = geompy.MakeWire([vxy, arc])
263 # create a planar face
264 face = geompy.MakeFace(wire, 1)
267 prism = geompy.MakePrismVecH(face, vz, 20.0)
269 # translate the given object along the given vector a given number of times
270 tr1d = geompy.MakeMultiTranslation1D(prism, vtr1d, 20, 4)
272 # consequently apply two specified translations to the object a given number of times
273 tr2d = geompy.MakeMultiTranslation2D(prism, vtr1d, 20, 4, vtr2d, 80, 3)
275 # add objects in the study
276 id_prism = geompy.addToStudy(prism,"Prism")
277 id_tr1d = geompy.addToStudy(tr1d,"Translation 1D")
278 id_tr2d = geompy.addToStudy(tr2d,"Translation 2D")
280 # display the prism and the results of fillet operation
281 gg.createAndDisplayGO(id_prism)
282 gg.setDisplayMode(id_prism,1)
283 gg.createAndDisplayGO(id_tr1d)
284 gg.setDisplayMode(id_tr1d,1)
285 gg.createAndDisplayGO(id_tr2d)
286 gg.setDisplayMode(id_tr2d,1)
289 \anchor tui_multi_rotation
290 <br><h2>Multi Rotation</h2>
295 gg = salome.ImportComponentGUI("GEOM")
297 # create vertices and vectors
298 p0 = geompy.MakeVertex( 0., 0., 0.)
299 px = geompy.MakeVertex(20., 0., 0.)
300 py = geompy.MakeVertex( 0., 20., 0.)
301 pz = geompy.MakeVertex( 0., 0., 20.)
302 pxyz = geompy.MakeVertex( 50., 50., 10.)
303 vz = geompy.MakeVector(p0, pz)
304 vxy = geompy.MakeVector(px, py)
305 vrot1d = geompy.MakeVector(p0, pxyz)
308 arc = geompy.MakeArc(py, pz, px)
311 wire = geompy.MakeWire([vxy, arc])
313 # create a planar face
314 face = geompy.MakeFace(wire, 1)
317 prism = geompy.MakePrismVecH(face, vz, 20.0)
319 # rotate the given object around the given axis by the given angle a given number of times
320 rot1d = geompy.MultiRotate1D(prism, vrot1d, 4)
322 # rotate the given object around the given axis by the given angle a given number of times
323 # and multi-translate the result of each rotation
324 rot2d = geompy.MultiRotate2D(prism, vrot1d, 60, 4, 50, 5)
326 # add objects in the study
327 id_prism = geompy.addToStudy(prism,"Prism")
328 id_rot1d = geompy.addToStudy(rot1d,"Rotation 1D")
329 id_rot2d = geompy.addToStudy(rot2d,"Rotation 2D")
331 # display the prism and the results of fillet operation
332 gg.createAndDisplayGO(id_prism)
333 gg.setDisplayMode(id_prism,1)
334 gg.createAndDisplayGO(id_rot1d)
335 gg.setDisplayMode(id_rot1d,1)
336 gg.createAndDisplayGO(id_rot2d)
337 gg.setDisplayMode(id_rot2d,1)
346 gg = salome.ImportComponentGUI("GEOM")
348 ShapeTypeEdge = geompy.ShapeType["EDGE"]
350 # create vertices and vectors
351 p0 = geompy.MakeVertex( 0., 0., 0.)
352 px = geompy.MakeVertex(100., 0., 0.)
353 py = geompy.MakeVertex( 0., 100., 0.)
354 pz = geompy.MakeVertex( 0., 0., 100.)
355 vz = geompy.MakeVector(p0, pz)
356 vxy = geompy.MakeVector(px, py)
359 arc = geompy.MakeArc(py, pz, px)
362 wire = geompy.MakeWire([vxy, arc])
364 # create a planar face
365 face = geompy.MakeFace(wire, 1)
368 prism = geompy.MakePrismVecH(face, vz, 100.0)
370 # get the list of IDs (IDList) for the fillet
371 prism_edges = geompy.SubShapeAllSorted(prism, ShapeTypeEdge)
373 IDlist_e.append(geompy.GetSubShapeID(prism, prism_edges[0]))
374 IDlist_e.append(geompy.GetSubShapeID(prism, prism_edges[1]))
375 IDlist_e.append(geompy.GetSubShapeID(prism, prism_edges[2]))
377 # make a fillet on the specified edges of the given shape
378 fillet = geompy.MakeFillet(prism, radius, ShapeTypeEdge, IDlist_e)
380 # make a fillet on all edges of the given shape
381 filletall = geompy.MakeFilletAll(prism, radius)
383 # add objects in the study
384 id_prism = geompy.addToStudy(prism,"Prism")
385 id_fillet = geompy.addToStudy(fillet,"Fillet")
386 id_filletall = geompy.addToStudy(filletall,"Fillet all")
388 # display the prism and the results of fillet operation
389 gg.createAndDisplayGO(id_prism)
390 gg.setDisplayMode(id_prism,1)
391 gg.createAndDisplayGO(id_fillet)
392 gg.setDisplayMode(id_fillet,1)
393 gg.createAndDisplayGO(id_filletall)
394 gg.setDisplayMode(id_filletall,1)
403 gg = salome.ImportComponentGUI("GEOM")
406 ShapeTypeFace = geompy.ShapeType["FACE"]
408 # create vertices and vectors
409 p0 = geompy.MakeVertex( 0., 0., 0.)
410 px = geompy.MakeVertex(100., 0., 0.)
411 py = geompy.MakeVertex( 0., 100., 0.)
412 pz = geompy.MakeVertex( 0., 0., 100.)
413 vz = geompy.MakeVector(p0, pz)
414 vxy = geompy.MakeVector(px, py)
417 arc = geompy.MakeArc(py, pz, px)
420 wire = geompy.MakeWire([vxy, arc])
422 # create a planar face
423 face = geompy.MakeFace(wire, 1)
426 prism = geompy.MakePrismVecH(face, vz, 100.0)
428 # get the list of IDs (IDList) for the chamfer
429 prism_faces = geompy.SubShapeAllSorted(prism, ShapeTypeFace)
430 f_ind_1 = geompy.GetSubShapeID(prism, prism_faces[0])
431 f_ind_2 = geompy.GetSubShapeID(prism, prism_faces[1])
432 IDlist_f = [f_ind_1, f_ind_2]
434 # perform a chamfer on the edges common to the specified faces
435 chamfer_e = geompy.MakeChamferEdge(prism, d1, d2, f_ind_1, f_ind_2)
437 # perform a chamfer on all edges of the specified faces
438 chamfer_f = geompy.MakeChamferFaces(prism, d1, d2, IDlist_f)
439 chamfer_f1 = geompy.MakeChamfer(prism, d1, d2, ShapeTypeFace, IDlist_f)
441 # perform a symmetric chamfer on all edges of the given shape
442 chamfer_all = geompy.MakeChamferAll(prism, d1)
444 # add objects in the study
445 id_prism = geompy.addToStudy(prism,"Prism")
446 id_chamfer_e = geompy.addToStudy(chamfer_e,"Chamfer edge")
447 id_chamfer_f = geompy.addToStudy(chamfer_f,"Chamfer faces")
448 id_chamfer_f1 = geompy.addToStudy(chamfer_f1,"Chamfer faces 1")
449 id_chamfer_all = geompy.addToStudy(chamfer_all,"Chamfer all")
451 # display the prism and the results of chamfer operation
452 gg.createAndDisplayGO(id_prism)
453 gg.setDisplayMode(id_prism,1)
454 gg.createAndDisplayGO(id_chamfer_e)
455 gg.setDisplayMode(id_chamfer_e,1)
456 gg.createAndDisplayGO(id_chamfer_f)
457 gg.setDisplayMode(id_chamfer_f,1)
458 gg.createAndDisplayGO(id_chamfer_f1)
459 gg.setDisplayMode(id_chamfer_f1,1)
460 gg.createAndDisplayGO(id_chamfer_all)
461 gg.setDisplayMode(id_chamfer_all,1)