smesh/doc/salome/examples/quality_controls_ex06.py

79 lines
2.5 KiB
Python
Raw Normal View History

2013-02-12 20:37:44 +06:00
# Free Faces
2013-02-12 20:37:44 +06:00
import salome
salome.salome_init()
import GEOM
from salome.geom import geomBuilder
2017-06-13 15:01:10 +05:00
geompy = geomBuilder.New()
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
2017-06-13 15:01:10 +05:00
smesh = smeshBuilder.New()
2013-02-12 20:37:44 +06:00
####### GEOM part ########
Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200)
Box_1_vertex_6 = geompy.GetSubShape(Box_1, [6])
Box_1 = geompy.GetMainShape(Box_1_vertex_6)
Box_1_vertex_16 = geompy.GetSubShape(Box_1, [16])
Box_1 = geompy.GetMainShape(Box_1_vertex_16)
Box_1_vertex_11 = geompy.GetSubShape(Box_1, [11])
Box_1 = geompy.GetMainShape(Box_1_vertex_11)
Plane_1 = geompy.MakePlaneThreePnt(Box_1_vertex_6, Box_1_vertex_16, Box_1_vertex_11, 2000)
Partition_1 = geompy.MakePartition([Box_1], [Plane_1], [], [], geompy.ShapeType["SOLID"], 0, [], 0)
Box_1_vertex_19 = geompy.GetSubShape(Box_1, [19])
Box_1_vertex_21 = geompy.GetSubShape(Box_1, [21])
Plane_2 = geompy.MakePlaneThreePnt(Box_1_vertex_16, Box_1_vertex_19, Box_1_vertex_21, 2000)
geompy.addToStudy( Box_1, "Box_1" )
geompy.addToStudyInFather( Box_1, Box_1_vertex_6, "Box_1:vertex_6" )
geompy.addToStudyInFather( Box_1, Box_1_vertex_16, "Box_1:vertex_16" )
geompy.addToStudyInFather( Box_1, Box_1_vertex_11, "Box_1:vertex_11" )
geompy.addToStudy( Plane_1, "Plane_1" )
geompy.addToStudy( Partition_1, "Partition_1" )
geompy.addToStudyInFather( Box_1, Box_1_vertex_19, "Box_1:vertex_19" )
geompy.addToStudyInFather( Box_1, Box_1_vertex_21, "Box_1:vertex_21" )
geompy.addToStudy( Plane_2, "Plane_2" )
###### SMESH part ######
Mesh_1 = smesh.Mesh(Partition_1)
Regular_1D = Mesh_1.Segment()
Max_Size_1 = Regular_1D.MaxSize(34.641)
MEFISTO_2D = Mesh_1.Triangle()
Tetrahedronn = Mesh_1.Tetrahedron()
isDone = Mesh_1.Compute()
# create a group of free faces
aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_FreeFaces )
2013-02-12 20:37:44 +06:00
aFaceIds = Mesh_1.GetIdsFromFilter(aFilter)
aGroup = Mesh_1.CreateEmptyGroup(SMESH.FACE, "Free_faces")
2013-02-12 20:37:44 +06:00
aGroup.Add(aFaceIds)
# print the result
2017-03-20 17:27:30 +05:00
print("Criterion: Free faces Nb = ", len(aFaceIds))
2013-02-12 20:37:44 +06:00
j = 1
for i in range(len(aFaceIds)):
2017-03-20 17:27:30 +05:00
if j > 20: j = 1; print("")
print(aFaceIds[i], end=' ')
2013-02-12 20:37:44 +06:00
j = j + 1
pass
2017-03-20 17:27:30 +05:00
print("")
2013-02-12 20:37:44 +06:00
#filter faces from plane 2
aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_BelongToPlane, Plane_2)
2013-02-12 20:37:44 +06:00
aFaceIds = Mesh_1.GetIdsFromFilter(aFilter)
aGroup.Remove(aFaceIds)
# create a group of shared faces (located on partition boundary inside box)
aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_BelongToPlane, Plane_1)
2013-02-12 20:37:44 +06:00
aFaceIds = Mesh_1.GetIdsFromFilter(aFilter)
aGroup = Mesh_1.CreateEmptyGroup(SMESH.FACE, "Shared_faces")
2013-02-12 20:37:44 +06:00
aGroup.Add(aFaceIds)
2017-06-13 15:01:10 +05:00
salome.sg.updateObjBrowser()