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