smesh/doc/salome/examples/quality_controls_ex03.py

50 lines
1.2 KiB
Python
Raw Normal View History

2013-02-12 20:37:44 +06:00
# Length 1D
2013-02-12 20:37:44 +06:00
import salome
salome.salome_init()
import GEOM
from salome.geom import geomBuilder
geompy = geomBuilder.New(salome.myStudy)
2013-02-12 20:37:44 +06:00
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
smesh = smeshBuilder.New(salome.myStudy)
2013-02-12 20:37:44 +06:00
# create open shell: a box without one plane
box = geompy.MakeBox(0., 0., 0., 20., 20., 15.)
FaceList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
FaceList.remove(FaceList[5])
box = geompy.MakeShell(FaceList)
idbox = geompy.addToStudy(box, "box")
# create a mesh
mesh = smesh.Mesh(box, "Mesh_Length_1D")
algo = mesh.Segment()
algo.NumberOfSegments(5)
algo = mesh.Triangle()
algo.MaxElementArea(20.)
mesh.Compute()
# Criterion : Length > 3.
length_margin = 3.
aFilter = smesh.GetFilter(SMESH.EDGE, SMESH.FT_Length, SMESH.FT_MoreThan, length_margin)
2013-02-12 20:37:44 +06:00
anIds = mesh.GetIdsFromFilter(aFilter)
# print the result
2017-03-20 17:27:30 +05:00
print("Criterion: Edges length > ", length_margin, " Nb = ", len(anIds))
2013-02-12 20:37:44 +06:00
j = 1
for i in range(len(anIds)):
2017-03-20 17:27:30 +05:00
if j > 20: j = 1; print("")
print(anIds[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
# create a group
2017-03-20 17:27:30 +05:00
aGroup = mesh.GetMesh().CreateGroup(SMESH.EDGE, "Edges with length > " + repr(length_margin))
2013-02-12 20:37:44 +06:00
aGroup.Add(anIds)
salome.sg.updateObjBrowser(True)