smesh/doc/salome/examples/quality_controls_ex05.py

55 lines
1.2 KiB
Python
Raw Normal View History

2013-02-12 20:37:44 +06:00
# Free Nodes
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 box
box = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
idbox = geompy.addToStudy(box, "box")
# create a mesh
mesh = smesh.Mesh(box, "Mesh_free_nodes")
algo = mesh.Segment()
algo.NumberOfSegments(10)
algo = mesh.Triangle(smeshBuilder.MEFISTO)
2013-02-12 20:37:44 +06:00
algo.MaxElementArea(150.)
mesh.Compute()
# Remove some elements to obtain free nodes
# Criterion : AREA < 80.
area_margin = 80.
aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_LessThan, area_margin)
2013-02-12 20:37:44 +06:00
anIds = mesh.GetIdsFromFilter(aFilter)
mesh.RemoveElements(anIds)
# criterion : free nodes
aFilter = smesh.GetFilter(SMESH.NODE, SMESH.FT_FreeNodes)
2013-02-12 20:37:44 +06:00
anNodeIds = mesh.GetIdsFromFilter(aFilter)
# create a group
aGroup = mesh.CreateEmptyGroup(SMESH.NODE, "Free_nodes")
2013-02-12 20:37:44 +06:00
aGroup.Add(anNodeIds)
# print the result
2017-03-20 17:27:30 +05:00
print("Criterion: Free nodes Nb = ", len(anNodeIds))
2013-02-12 20:37:44 +06:00
j = 1
for i in range(len(anNodeIds)):
2017-03-20 17:27:30 +05:00
if j > 20: j = 1; print("")
print(anNodeIds[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
salome.sg.updateObjBrowser(True)