3 \page tui_basic_operations_page Basic Operations
11 gg = salome.ImportComponentGUI("GEOM")
13 # create a vertex and a vector
14 p0 = geompy.MakeVertex( 0., 0., 0.)
15 p200 = geompy.MakeVertex(200., 200., 200.)
16 pz = geompy.MakeVertex( 0., 0., 100.)
19 vxyz = geompy.MakeVectorDXDYDZ(100., 100., 100.)
21 # create a box from two points
22 box = geompy.MakeBoxTwoPnt(p0, p200)
26 plane = geompy.MakePlane(pz, vxyz, trimsize)
28 # create partition objects
29 partition1 = geompy.MakePartition([box], [plane])
30 partition2 = geompy.Partition([box], [plane])
31 partition3 = geompy.MakeHalfPartition(box, plane)
33 # add objects in the study
34 id_box = geompy.addToStudy(box,"Box")
35 id_plane = geompy.addToStudy(plane,"Plane")
36 id_partition1 = geompy.addToStudy(partition1,"MakePartition")
37 id_partition2 = geompy.addToStudy(partition2,"Partition")
38 id_partition3 = geompy.addToStudy(partition3,"MakeHalfPartition")
40 # display the partition objects and the plane
41 gg.createAndDisplayGO(id_box)
42 gg.setDisplayMode(id_box,1)
43 gg.createAndDisplayGO(id_plane)
44 gg.setDisplayMode(id_plane,1)
45 gg.createAndDisplayGO(id_partition1)
46 gg.createAndDisplayGO(id_partition2)
47 gg.createAndDisplayGO(id_partition3)
51 <br><h2>Archimede</h2>
56 gg = salome.ImportComponentGUI("GEOM")
58 # create a vertex and a vector
59 p0 = geompy.MakeVertex( 0., 0., 0.)
60 p200 = geompy.MakeVertex(200., 200., 200.)
62 # create a box from two points
63 box = geompy.MakeBoxTwoPnt(p0, p200)
65 # perform an Archimede operation on the selected shape with selected parameters
68 meshingdeflection = 0.01
69 archimede = geompy.Archimede(box, weight, waterdensity, meshingdeflection)
71 # add objects in the study
72 id_box = geompy.addToStudy(box,"Box")
73 id_archimede = geompy.addToStudy(archimede,"Archimede")
75 # display the box and the result of Archimede operation
76 gg.createAndDisplayGO(id_box)
77 gg.setDisplayMode(id_box,1)
78 gg.createAndDisplayGO(id_archimede)
79 gg.setDisplayMode(id_archimede,1)
82 \anchor tui_restore_prs_params
83 <br><h2>Restore presentation parameters and subshapes</h2>
89 # create a box and a cylinder
90 box = geompy.MakeBoxDXDYDZ(200, 200, 200)
91 cyl = geompy.MakeCylinderRH(100, 300)
93 # create translated box
94 vec = geompy.MakeVectorDXDYDZ(100, 50, 0)
95 tra = geompy.MakeTranslationVector(box, vec)
97 # create partition objects
98 partition1 = geompy.MakePartition([box, cyl])
99 partition2 = geompy.MakePartition([box], [cyl])
100 partition3 = geompy.MakePartition([box], [tra])
103 box.SetColor(SALOMEDS.Color(1,0,0))
104 cyl.SetColor(SALOMEDS.Color(0,1,0))
106 # add objects in the study
107 geompy.addToStudy(box, "Box")
108 geompy.addToStudy(cyl, "Cylinder")
109 geompy.addToStudy(vec, "Vector")
110 geompy.addToStudy(tra, "Translation")
111 geompy.addToStudy(partition1, "Partition_1")
112 geompy.addToStudy(partition2, "Partition_2")
113 geompy.addToStudy(partition3, "Partition_3")
115 # Restore presentation parameters and subshapes
116 # different methods can be used to find the subshapes in the result:
117 # GetInPlace, GetSame, GetInPlaceByHistory, GetShapesOnShape.
118 # By default, GetInPlace method is used (GEOM.FSM_GetInPlace)
119 geompy.RestoreSubShapes(partition1)
121 geompy.RestoreSubShapes(partition2, [], GEOM.FSM_GetInPlace)
123 # The list of arguments can be used to avoid restoring all arguments,
124 # but restore only the passed.
125 geompy.RestoreSubShapes(partition3, [tra], GEOM.FSM_GetInPlaceByHistory)
127 # To find subshapes in a transformed shape only one method could be
128 # used: pass GEOM.FSM_Transformed for that.
129 # True passed for the last argument, means that the transformed shape
130 # will inherit colour and subshapes from its first argument (see above
132 geompy.RestoreSubShapes(tra, [], GEOM.FSM_Transformed, True)
134 # Also we could do this directly with method addToStudy:
135 partition4 = geompy.MakePartition([box, tra])
136 geompy.addToStudy(partition4, "Partition_4", True, [],
137 GEOM.FSM_GetInPlaceByHistory, False)