Salome HOME
Mantis issue 0021703: [CEA 577] Boolean operations on groups.
[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 sub-shapes</h2>
84
85 \code
86 import geompy
87 import GEOM
88 import SALOMEDS
89
90 # create a box and a cylinder
91 box = geompy.MakeBoxDXDYDZ(200, 200, 200)
92 cyl = geompy.MakeCylinderRH(100, 300)
93
94 # create translated box
95 vec = geompy.MakeVectorDXDYDZ(100, 50, 0)
96 tra = geompy.MakeTranslationVector(box, vec)
97
98 # create partition objects
99 partition1 = geompy.MakePartition([box, cyl])
100 partition2 = geompy.MakePartition([box], [cyl])
101 partition3 = geompy.MakePartition([box], [tra])
102
103 # set colours
104 box.SetColor(SALOMEDS.Color(1,0,0))
105 cyl.SetColor(SALOMEDS.Color(0,1,0))
106
107 # add objects in the study
108 geompy.addToStudy(box, "Box")
109 geompy.addToStudy(cyl, "Cylinder")
110 geompy.addToStudy(vec, "Vector")
111 geompy.addToStudy(tra, "Translation")
112 geompy.addToStudy(partition1, "Partition_1")
113 geompy.addToStudy(partition2, "Partition_2")
114 geompy.addToStudy(partition3, "Partition_3")
115
116 # Restore presentation parameters and sub-shapes
117 # different methods can be used to find the sub-shapes in the result:
118 # GetInPlace, GetSame, GetInPlaceByHistory, GetShapesOnShape.
119 # By default, GetInPlace method is used (GEOM.FSM_GetInPlace)
120 geompy.RestoreSubShapes(partition1)
121
122 geompy.RestoreSubShapes(partition2, [], GEOM.FSM_GetInPlace)
123
124 # The list of arguments can be used to avoid restoring all arguments,
125 # but restore only the passed.
126 geompy.RestoreSubShapes(partition3, [tra], GEOM.FSM_GetInPlaceByHistory)
127
128 # To find sub-shapes in a transformed shape only one method could be
129 # used: pass GEOM.FSM_Transformed for that.
130 # True passed for the last argument, means that the transformed shape
131 # will inherit colour and sub-shapes from its first argument (see above
132 # MakeTranslation).
133 geompy.RestoreSubShapes(tra, [], GEOM.FSM_Transformed, True)
134
135 # Also we could do this directly with method addToStudy:
136 partition4 = geompy.MakePartition([box, tra])
137 geompy.addToStudy(partition4, "Partition_4", True, [],
138                   GEOM.FSM_GetInPlaceByHistory, False)
139 \endcode
140
141 */