Version: 8.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
Check Free Faces
1 # Check Free Faces
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 cylinder = geompy.MakeCone(p1, v, 30, 20, 20)
17 
18 # create a cone
19 cone = geompy.MakeCone(p1, v, 70, 40, 60)
20 
21 # make cut
22 cut = geompy.MakeCut(cone, cylinder)
23 
24 # get faces as sub-shapes
25 faces = []
26 faces = geompy.SubShapeAllSortedCentres(cut, geompy.ShapeType["FACE"])
27 f_2 = geompy.GetSubShapeID(cut, faces[0])
28 
29 # remove one face from the shape
30 cut_without_f_2 = geompy.SuppressFaces(cut, [f_2])
31 
32 # suppress the specified wire
33 result = geompy.GetFreeFacesIDs(cut_without_f_2)
34 print "A number of free faces is ", len(result)
35 
36 # add objects in the study
37 all_faces = geompy.SubShapeAllSortedCentres(cut_without_f_2, geompy.ShapeType["FACE"])
38 for face in all_faces :
39  sub_shape_id = geompy.GetSubShapeID(cut_without_f_2, face)
40  if result.count(sub_shape_id) > 0 :
41  face_name = "Free face %d"%(sub_shape_id)
42  geompy.addToStudy(face, face_name)
43 
44 # in this example all faces from cut_without_f_2 are free
45 id_cut_without_f_2 = geompy.addToStudy(cut_without_f_2, "Cut without f_2")
46 
47 # display the results
48 gg.createAndDisplayGO(id_cut_without_f_2)
49 gg.setDisplayMode(id_cut_without_f_2,1)

Download this script