]> SALOME platform Git repositories - modules/smesh.git/blob - doc/salome/examples/quality_controls_ex06.py
Salome HOME
Merge multi-study removal branch.
[modules/smesh.git] / doc / salome / examples / quality_controls_ex06.py
1 # Free Faces
2
3
4 import salome
5 salome.salome_init()
6 import GEOM
7 from salome.geom import geomBuilder
8 geompy = geomBuilder.New()
9
10 import SMESH, SALOMEDS
11 from salome.smesh import smeshBuilder
12 smesh =  smeshBuilder.New()
13
14 ####### GEOM part ########
15
16 Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200)
17 Box_1_vertex_6 = geompy.GetSubShape(Box_1, [6])
18 Box_1 = geompy.GetMainShape(Box_1_vertex_6)
19 Box_1_vertex_16 = geompy.GetSubShape(Box_1, [16])
20 Box_1 = geompy.GetMainShape(Box_1_vertex_16)
21 Box_1_vertex_11 = geompy.GetSubShape(Box_1, [11])
22 Box_1 = geompy.GetMainShape(Box_1_vertex_11)
23 Plane_1 = geompy.MakePlaneThreePnt(Box_1_vertex_6, Box_1_vertex_16, Box_1_vertex_11, 2000)
24 Partition_1 = geompy.MakePartition([Box_1], [Plane_1], [], [], geompy.ShapeType["SOLID"], 0, [], 0)
25
26 Box_1_vertex_19 = geompy.GetSubShape(Box_1, [19])
27 Box_1_vertex_21 = geompy.GetSubShape(Box_1, [21])
28 Plane_2 = geompy.MakePlaneThreePnt(Box_1_vertex_16, Box_1_vertex_19, Box_1_vertex_21, 2000)
29
30 geompy.addToStudy( Box_1, "Box_1" )
31 geompy.addToStudyInFather( Box_1, Box_1_vertex_6, "Box_1:vertex_6" )
32 geompy.addToStudyInFather( Box_1, Box_1_vertex_16, "Box_1:vertex_16" )
33 geompy.addToStudyInFather( Box_1, Box_1_vertex_11, "Box_1:vertex_11" )
34 geompy.addToStudy( Plane_1, "Plane_1" )
35 geompy.addToStudy( Partition_1, "Partition_1" )
36 geompy.addToStudyInFather( Box_1, Box_1_vertex_19, "Box_1:vertex_19" )
37 geompy.addToStudyInFather( Box_1, Box_1_vertex_21, "Box_1:vertex_21" )
38 geompy.addToStudy( Plane_2, "Plane_2" )
39
40 ###### SMESH part ######
41
42 Mesh_1 = smesh.Mesh(Partition_1)
43 Regular_1D = Mesh_1.Segment()
44 Max_Size_1 = Regular_1D.MaxSize(34.641)
45 MEFISTO_2D = Mesh_1.Triangle()
46 Tetrahedronn = Mesh_1.Tetrahedron()
47 isDone = Mesh_1.Compute()
48
49 # create a group of free faces
50 aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_FreeFaces )
51 aFaceIds = Mesh_1.GetIdsFromFilter(aFilter)
52
53 aGroup = Mesh_1.CreateEmptyGroup(SMESH.FACE, "Free_faces")
54 aGroup.Add(aFaceIds)
55
56 # print the result
57 print "Criterion: Free faces Nb = ", len(aFaceIds)
58 j = 1
59 for i in range(len(aFaceIds)):
60   if j > 20: j = 1; print ""
61   print aFaceIds[i],
62   j = j + 1
63   pass
64 print ""
65
66 #filter faces from plane 2
67 aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_BelongToPlane, Plane_2)
68 aFaceIds = Mesh_1.GetIdsFromFilter(aFilter)
69 aGroup.Remove(aFaceIds)
70
71 # create a group of shared faces (located on partition boundary inside box)
72 aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_BelongToPlane, Plane_1)
73 aFaceIds = Mesh_1.GetIdsFromFilter(aFilter)
74
75 aGroup = Mesh_1.CreateEmptyGroup(SMESH.FACE, "Shared_faces")
76 aGroup.Add(aFaceIds)
77
78 salome.sg.updateObjBrowser()