Salome HOME
e314abc85495e505775cd9e1c094a0fa92d86521
[modules/geom.git] / doc / salome / gui / GEOM / input / tui_topological_geom_objs.doc
1 /*!
2
3 \page tui_topological_geom_objs_page Topological Objects
4
5 \anchor tui_creation_edge
6 <br><h2>Creation of an Edge</h2>
7
8 \code
9 import geompy
10 import salome
11 gg = salome.ImportComponentGUI("GEOM")
12
13 #
14 # create edge by two points
15 #
16
17 # create vertices
18 p0   = geompy.MakeVertex(0.  , 0.  , 0.  )
19 pxyz = geompy.MakeVertex(100., 100., 100.)
20
21 # create an edge
22 edge = geompy.MakeEdge(p0, pxyz)
23
24 # add object in the study
25 id_edge = geompy.addToStudy(edge,"Edge_1")
26
27 # display an edge
28 gg.createAndDisplayGO(id_edge) 
29
30 #
31 # create edge from wire
32 #
33
34 # create a circle
35 c = geompy.MakeCircle(None, None, 100)
36
37 # create a wire
38 w = geompy.MakeWire([c], 1e-07)
39
40 # create an edge from wire
41 edge = geompy.MakeEdgeWire(w)
42
43 # add object in the study
44 id_edge = geompy.addToStudy(edge,"Edge_2")
45
46 # display an edge
47 gg.createAndDisplayGO(id_edge) 
48
49 #
50 # create edge from existing curve and a length
51 #
52
53 # create a circle
54 c = geompy.MakeCircle(None, None, 100)
55
56 # create an edge of length 25.0 from the circle
57 edge = geompy.MakeEdgeOnCurveByLength(c, 25.0)
58
59 # add object in the study
60 id_edge = geompy.addToStudy(edge,"Edge_3")
61
62 # display an edge
63 gg.createAndDisplayGO(id_edge) 
64
65 \endcode
66  
67 \anchor tui_creation_wire
68 <br><h2>Creation of a Wire</h2>
69
70 \code
71 import geompy
72 import salome
73 gg = salome.ImportComponentGUI("GEOM")
74
75 # create vertices
76 px   = geompy.MakeVertex(100., 0.  , 0.  )
77 py   = geompy.MakeVertex(0.  , 100., 0.  )
78 pz   = geompy.MakeVertex(0.  , 0.  , 100.)
79
80 # create a vector from two points
81 vxy = geompy.MakeVector(px, py)
82
83 # create an arc from three points
84 arc = geompy.MakeArc(py, pz, px)
85
86 # create a wire
87 wire = geompy.MakeWire([vxy, arc])
88
89 # add an object in the study
90 id_wire = geompy.addToStudy(wire,"Wire")
91
92 # display the wire
93 gg.createAndDisplayGO(id_wire) 
94 \endcode
95  
96 \anchor tui_creation_face
97 <br><h2>Creation of a Face</h2>
98
99 \code
100 import geompy
101 import salome
102 gg = salome.ImportComponentGUI("GEOM")
103
104 # create vertices
105 p0   = geompy.MakeVertex(0.  , 0.  , 0.  )
106 px   = geompy.MakeVertex(100., 0.  , 0.  )
107 py   = geompy.MakeVertex(0.  , 100., 0.  )
108 pz   = geompy.MakeVertex(0.  , 0.  , 100.)
109 pxyz = geompy.MakeVertex(100., 100., 100.)
110
111 # create a vector from two points
112 vxy = geompy.MakeVector(px, py)
113
114 # create an arc from three points
115 arc = geompy.MakeArc(py, pz, px)
116
117 # create a wire
118 wire = geompy.MakeWire([vxy, arc])
119
120 # create sketchers
121 sketcher1 = geompy.MakeSketcher("Sketcher:F -100 -100:TT 250 -100:R 0:C 100 150:R 0:L 300:WW",
122                                 [100,0,0, 1,1,1, -1,1,0])
123 sketcher2 = geompy.MakeSketcher("Sketcher:F 0 0:TT 70 0:TT 70 70:TT 0 70:WW")
124 sketcher3 = geompy.MakeSketcher("Sketcher:F 20 20:TT 50 20:TT 50 50:TT 20 50:WW")
125 isPlanarFace = 1
126
127 # create a face from the wire
128 face1 = geompy.MakeFace(wire, isPlanarFace)
129
130 # create faces from two wires
131 face2 = geompy.MakeFaceWires([wire, sketcher1],isPlanarFace)
132 face3 = geompy.MakeFaces([sketcher2, sketcher3],isPlanarFace)
133
134 # add objects in the study
135 id_face1 = geompy.addToStudy(face1,"Face1")
136 id_face2 = geompy.addToStudy(face2,"Face2")
137 id_face3 = geompy.addToStudy(face3,"Face3")
138
139 # display the faces
140 gg.createAndDisplayGO(id_face1)
141 gg.setDisplayMode(id_face1,1)
142 gg.setTransparency(id_face1,0.2)
143 gg.createAndDisplayGO(id_face2)
144 gg.setDisplayMode(id_face2,1)
145 gg.setTransparency(id_face2,0.2)
146 gg.createAndDisplayGO(id_face3)
147 gg.setDisplayMode(id_face3,1)
148 gg.setTransparency(id_face3,0.2) 
149 \endcode
150  
151 \anchor tui_creation_shell
152 <br><h2>Creation of a Shell</h2>
153
154 \code
155 import geompy
156 import salome
157 gg = salome.ImportComponentGUI("GEOM")
158
159 #create vertices
160 p0   = geompy.MakeVertex( 0.,  0.,  0.)
161 pxyz = geompy.MakeVertex( 5.,  5., 40.)
162
163 # create sketchers
164 sketcher1 = geompy.MakeSketcher("Sketcher:F 0 0:TT 70 0:TT 70 70:TT 0 70:WW")
165 sketcher2 = geompy.MakeSketcher("Sketcher:F 20 20:TT 50 20:TT 50 50:TT 20 50:WW")
166 isPlanarFace = 1
167
168 # create a face from two wires
169 face = geompy.MakeFaces([sketcher1, sketcher2],isPlanarFace)
170
171 # create a prism
172 prism = geompy.MakePrism(face, p0, pxyz)
173
174 # explode the prism into faces
175 prism_faces = geompy.SubShapeAllSortedCentres(prism, geompy.ShapeType["FACE"])
176
177 # create a shell from a set of faces
178 shell = geompy.MakeShell([prism_faces[0], prism_faces[2], prism_faces[3],
179                           prism_faces[7], prism_faces[9]])
180
181 # add objects in the study
182 id_shell = geompy.addToStudy(shell,"Shell")
183
184 # display the shell
185 gg.createAndDisplayGO(id_shell)
186 gg.setDisplayMode(id_shell,1) 
187 \endcode
188  
189 \anchor tui_creation_solid
190 <br><h2>Creation of a Solid</h2>
191
192 \code
193 import geompy
194 import salome
195 gg = salome.ImportComponentGUI("GEOM")
196
197 #create vertices
198 p0 = geompy.MakeVertex( 0.,  0.,  0.)
199 pz = geompy.MakeVertex( 0.,  0., 40.)
200
201 # create sketchers
202 sketcher = geompy.MakeSketcher("Sketcher:F -50 -50:TT 100 -50:R 0:C 50 70:R 0:L 100:WW")
203
204 # create faces from two wires
205 face = geompy.MakeFace(sketcher,1)
206
207 # create a prism
208 prism = geompy.MakePrism(face, p0, pz)
209
210 # explode the prism into faces
211 prism_faces = geompy.SubShapeAllSortedCentres(prism, geompy.ShapeType["FACE"])
212
213 # create a shell from a set of faces
214 shell = geompy.MakeShell([prism_faces[0], prism_faces[1],
215                           prism_faces[3], prism_faces[4],
216                           prism_faces[5], prism_faces[2]])
217
218 # create a solid, bounded by the given shells
219 solid = geompy.MakeSolid([shell])
220
221 # add objects in the study
222 id_solid = geompy.addToStudy(solid,"Solid")
223
224 # display the solid
225 gg.createAndDisplayGO(id_solid)
226 gg.setDisplayMode(id_solid,1) 
227 \endcode
228  
229 \anchor tui_creation_compound
230 <br><h2>Creation of a Compound</h2>
231
232 \code
233 import geompy
234 import salome
235 gg = salome.ImportComponentGUI("GEOM")
236
237 # create a vertex and a vector
238 p1 = geompy.MakeVertex(  -30.,  -30.,  50.)
239 p2 = geompy.MakeVertex(  -60.,  -60.,  30.)
240 p3 = geompy.MakeVertex(  -30.,  -30.,  10.)
241
242 # create an arc from three points
243 arc = geompy.MakeArc(p1, p2, p3)
244 ShapeListCompound = []
245 i = 0
246 while i <= 3 :
247     S = geompy.MakeTranslation(arc, i * 50., 0., 0.)
248     ShapeListCompound.append(S)
249     i = i + 1
250
251 # create a compund of the given shapes
252 compound = geompy.MakeCompound(ShapeListCompound)
253
254 # add object in the study
255 id_compound = geompy.addToStudy(compound,"Compound")
256
257 # display the compound
258 gg.createAndDisplayGO(id_compound) 
259 \endcode
260
261 */