Salome HOME
Merge french translations update from origin/fbt/french_translation_check_geom branch
[modules/geom.git] / doc / salome / examples / repairing_operations_ex05.py
1 # Suppress Holes
2
3 import salome
4 salome.salome_init()
5 import GEOM
6 from salome.geom import geomBuilder
7 geompy = geomBuilder.New(salome.myStudy)
8 gg = salome.ImportComponentGUI("GEOM")
9
10 # create a vertex and a vector
11 p1 = geompy.MakeVertex(35, 35, 0)
12 p2 = geompy.MakeVertex(35, 35, 50)
13 v = geompy.MakeVector(p1, p2)
14
15 # create a cylinder
16 height = 20
17 radius1 = 20
18 cylinder = geompy.MakeCylinder(p1, v, radius1, height)
19
20 # create a cone
21 cone = geompy.MakeCone(p1, v, 70, 0, 80)
22
23 # make a cut
24 cut = geompy.MakeCut(cone, cylinder)
25
26 # get faces as sub-shapes
27 faces = geompy.SubShapeAllSortedCentres(cut, geompy.ShapeType["FACE"])
28 f_2 = geompy.GetSubShapeID(cut, faces[2])
29
30 # remove one face from the shape
31 cut_without_f_2 = geompy.SuppressFaces(cut, [f_2])
32
33 # get edges as sub-shapes
34 edges = geompy.SubShapeAllSortedCentres(faces[2], geompy.ShapeType["EDGE"])
35 edge  = geompy.GetInPlace(cut_without_f_2, edges[0], True)
36 e_2 = geompy.GetSubShapeID(cut_without_f_2, edge)
37
38 # suppress a hole using the selected edge
39 result = geompy.SuppressHoles(cut_without_f_2, [e_2])
40
41 # add objects in the study
42 id_cut = geompy.addToStudy(cut, "Cut")
43 id_cut_without_f_2 = geompy.addToStudy(cut_without_f_2, "Cut without f_2")
44 id_result = geompy.addToStudy(result, "Result")
45
46 # display the results
47 gg.createAndDisplayGO(id_cut)
48 gg.setDisplayMode(id_cut,1)
49 gg.createAndDisplayGO(id_cut_without_f_2)
50 gg.setDisplayMode(id_cut_without_f_2,1)
51 gg.createAndDisplayGO(id_result)
52 gg.setDisplayMode(id_result,1)