Salome HOME
Update from BR_V5_DEV 13Feb2009
[modules/geom.git] / doc / salome / gui / GEOM / input / tui_basic_operations.doc
1 /*!
2
3 \page tui_basic_operations_page Basic Operations
4
5 \anchor tui_partition
6 <br><h2>Partition</h2>
7
8 \code
9 import geompy
10 import salome
11 gg = salome.ImportComponentGUI("GEOM")
12
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.)
17
18 # create a vector
19 vxyz = geompy.MakeVectorDXDYDZ(100., 100., 100.)
20
21 # create a box from two points
22 box = geompy.MakeBoxTwoPnt(p0, p200)
23
24 # create a plane
25 trimsize  = 500.
26 plane = geompy.MakePlane(pz, vxyz, trimsize)
27
28 # create partition objects
29 partition1 = geompy.MakePartition([box], [plane])
30 partition2 = geompy.Partition([box], [plane])
31 partition3 = geompy.MakeHalfPartition(box, plane)
32
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")
39
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)
48 \endcode
49
50 \anchor tui_archimede
51 <br><h2>Archimede</h2>
52
53 \code
54 import geompy
55 import salome
56 gg = salome.ImportComponentGUI("GEOM")
57
58 # create a vertex and a vector
59 p0   = geompy.MakeVertex(  0.,   0.,   0.)
60 p200 = geompy.MakeVertex(200., 200., 200.)
61
62 # create a box from two points
63 box = geompy.MakeBoxTwoPnt(p0, p200)
64
65 # perform an Archimede operation on the selected shape with selected parameters
66 weight  = 1000000.
67 waterdensity = 1.
68 meshingdeflection = 0.01
69 archimede  = geompy.Archimede(box, weight, waterdensity, meshingdeflection)
70
71 # add objects in the study
72 id_box = geompy.addToStudy(box,"Box")
73 id_archimede = geompy.addToStudy(archimede,"Archimede")
74
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) 
80 \endcode
81
82 \anchor tui_restore_prs_params
83 <br><h2>Restore presentation parameters and subshapes</h2>
84
85 \code
86 import geompy
87 import GEOM
88
89 # create a box and a cylinder
90 box = geompy.MakeBoxDXDYDZ(200, 200, 200)
91 cyl = geompy.MakeCylinderRH(100, 300)
92
93 # create translated box
94 vec = geompy.MakeVectorDXDYDZ(100, 50, 0)
95 tra = geompy.MakeTranslationVector(box, vec)
96
97 # create partition objects
98 partition1 = geompy.MakePartition([box, cyl])
99 partition2 = geompy.MakePartition([box], [cyl])
100 partition3 = geompy.MakePartition([box], [tra])
101
102 # set colours
103 box.SetColor(SALOMEDS.Color(1,0,0))
104 cyl.SetColor(SALOMEDS.Color(0,1,0))
105
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")
114
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)
120
121 geompy.RestoreSubShapes(partition2, [], GEOM.FSM_GetInPlace)
122
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)
126
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
131 # MakeTranslation).
132 geompy.RestoreSubShapes(tra, [], GEOM.FSM_Transformed, True)
133
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)
138 \endcode
139
140 */