smesh/doc/examples/quality_controls_ex01.py

45 lines
1.1 KiB
Python
Raw Permalink Normal View History

2013-02-12 20:37:44 +06:00
# Free Borders
import salome
salome.salome_init_without_session()
2013-02-12 20:37:44 +06:00
2022-04-11 18:28:01 +05:00
import SMESH
from salome.geom import geomBuilder
from salome.smesh import smeshBuilder
2022-04-11 18:28:01 +05:00
geom_builder = geomBuilder.New()
smesh_builder = smeshBuilder.New()
2013-02-12 20:37:44 +06:00
# create open shell: a box without one plane
2022-04-11 18:28:01 +05:00
box = geom_builder.MakeBox(0., 0., 0., 20., 20., 15.)
FaceList = geom_builder.SubShapeAll(box, geom_builder.ShapeType["FACE"])
2013-02-12 20:37:44 +06:00
FaceList.remove(FaceList[5])
2022-04-11 18:28:01 +05:00
box = geom_builder.MakeShell(FaceList)
idbox = geom_builder.addToStudy(box, "box")
2013-02-12 20:37:44 +06:00
# create a mesh
2022-04-11 18:28:01 +05:00
mesh = smesh_builder.Mesh(box, "Mesh_free_borders")
2013-02-12 20:37:44 +06:00
algo = mesh.Segment()
algo.NumberOfSegments(5)
algo = mesh.Triangle()
algo.MaxElementArea(20.)
if not mesh.Compute(): raise Exception("Error when computing Mesh")
2013-02-12 20:37:44 +06:00
# criterion : free borders
2022-04-11 18:28:01 +05:00
aFilter = smesh_builder.GetFilter(SMESH.EDGE, SMESH.FT_FreeBorders)
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: Free borders 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
aGroup = mesh.GetMesh().CreateGroup(SMESH.EDGE, "Free borders")
2013-02-12 20:37:44 +06:00
aGroup.Add(anIds)