Salome HOME
Merge from V6_main 11/02/2013
[modules/geom.git] / doc / salome / examples / free_faces.py
1 # Check Free Faces
2
3 import geompy
4 import salome
5 gg = salome.ImportComponentGUI("GEOM")
6
7 # create a vertex and a vector
8 p1 = geompy.MakeVertex(35, 35, 0)
9 p2 = geompy.MakeVertex(35, 35, 50)
10 v = geompy.MakeVector(p1, p2)
11
12 # create a cylinder
13 cylinder = geompy.MakeCone(p1, v, 30, 20, 20)
14
15 # create a cone
16 cone = geompy.MakeCone(p1, v, 70, 40, 60)
17
18 # make cut
19 cut = geompy.MakeCut(cone, cylinder)
20
21 # get faces as sub-shapes
22 faces = []
23 faces = geompy.SubShapeAllSortedCentres(cut, geompy.ShapeType["FACE"])
24 f_2 = geompy.GetSubShapeID(cut, faces[0])
25
26 # remove one face from the shape
27 cut_without_f_2 = geompy.SuppressFaces(cut, [f_2])
28
29 # suppress the specified wire
30 result = geompy.GetFreeFacesIDs(cut_without_f_2)
31 print "A number of free faces is ", len(result)
32
33 # add objects in the study
34 all_faces = geompy.SubShapeAllSortedCentres(cut_without_f_2, geompy.ShapeType["FACE"])
35 for face in all_faces :
36     sub_shape_id = geompy.GetSubShapeID(cut_without_f_2, face)
37     if result.count(sub_shape_id) > 0 :
38         face_name = "Free face %d"%(sub_shape_id)
39         geompy.addToStudy(face, face_name)
40
41 # in this example all faces from cut_without_f_2 are free
42 id_cut_without_f_2 = geompy.addToStudy(cut_without_f_2, "Cut without f_2")
43
44 # display the results
45 gg.createAndDisplayGO(id_cut_without_f_2)
46 gg.setDisplayMode(id_cut_without_f_2,1)