# Attention! This script has been written using the old approach basing on direct usage of SMESH idl interface.
# For the moment smesh package doesn't provide methods to check free borders.
# In the next SALOME version the scripts will be updated to use only the commands from smesh package.
import salome
import geompy
import smesh
import SMESH
# 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
tria = smesh.Mesh(box, "Mesh_free_borders")
algo = tria.Segment()
algo.NumberOfSegments(5)
algo = tria.Triangle()
algo.MaxElementArea(20.)
tria.Compute()
mesh = tria.GetMesh()
gen = smesh.smesh
# criterion : free borders
aFilterMgr = gen.CreateFilterManager()
aPredicate = aFilterMgr.CreateFreeBorders()
aFilter = aFilterMgr.CreateFilter()
aFilter.SetPredicate(aPredicate)
anIds = aFilter.GetElementsId(mesh)
# print the result
print "Criterion: Free borders Nb = ", len(anIds)
j = 1
for i in range(len(anIds)):
if j > 20: j = 1; print ""
print anIds[i],
j = j + 1
pass
print ""
# create a group
aGroup = mesh.CreateGroup(SMESH.EDGE, "Free borders")
aGroup.Add(anIds)
salome.sg.updateObjBrowser(1)
# Attention! This script has been written using the old approach basing on direct usage of SMESH idl interface.
# For the moment smesh package doesn't provide methods to check borders at multiconnection.
# In the next SALOME version the scripts will be updated to use only the commands from smesh package.
import salome
import geompy
import smesh
import SMESH
# 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
tria = smesh.Mesh(box, "Mesh_borders_at_multi-connections")
algo = tria.Segment()
algo.NumberOfSegments(5)
algo = tria.Triangle()
algo.MaxElementArea(20.)
tria.Compute()
mesh = tria.GetMesh()
gen = smesh.smesh
# Criterion : Borders at multi-connection
nb_conn = 2
aFilterMgr = gen.CreateFilterManager()
aFunctor = aFilterMgr.CreateMultiConnection()
aPredicate = aFilterMgr.CreateEqualTo()
aPredicate.SetNumFunctor(aFunctor)
aPredicate.SetMargin(nb_conn)
aFilter = aFilterMgr.CreateFilter()
aFilter.SetPredicate(aPredicate)
anIds = aFilter.GetElementsId(mesh)
# print the result
print "Criterion: Borders at multi-connections Nb = ", len(anIds)
j = 1
for i in range(len(anIds)):
if j > 20: j = 1; print ""
print anIds[i],
j = j + 1
pass
print ""
# create a group
aGroup = mesh.CreateGroup(SMESH.EDGE, "Borders at multi-connections")
aGroup.Add(anIds)
salome.sg.updateObjBrowser(1)
# Attention! This script has been written using the old approach basing on direct usage of SMESH idl interface.
# For the moment smesh package doesn't provide methods to check length 1D.
# In the next SALOME version the scripts will be updated to use only the commands from smesh package.
import salome
import geompy
import smesh
import SMESH
# 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
tria = smesh.Mesh(box, "Mesh_Length_1D")
algo = tria.Segment()
algo.NumberOfSegments(5)
algo = tria.Triangle()
algo.MaxElementArea(20.)
tria.Compute()
mesh = tria.GetMesh()
gen = smesh.smesh
# Criterion : Length > 3.
length_margin = 3.
aFilterMgr = gen.CreateFilterManager()
aFunctor = aFilterMgr.CreateLength()
aPredicate = aFilterMgr.CreateMoreThan()
aPredicate.SetNumFunctor(aFunctor)
aPredicate.SetMargin(length_margin)
aFilter = aFilterMgr.CreateFilter()
aFilter.SetPredicate(aPredicate)
anIds = aFilter.GetElementsId(mesh)
# print the result
print "Criterion: Edges length > ", length_margin, " Nb = ", len(anIds)
j = 1
for i in range(len(anIds)):
if j > 20: j = 1; print ""
print anIds[i],
j = j + 1
pass
print ""
# create a group
aGroup = mesh.CreateGroup(SMESH.EDGE, "Edges with length > " + `length_margin`)
aGroup.Add(anIds)
salome.sg.updateObjBrowser(1)
# Attention! This script has been written using the old approach basing on direct usage of SMESH idl interface.
# For the moment smesh package doesn't provide methods to check free edges.
# In the next SALOME version the scripts will be updated to use only the commands from smesh package.
import SMESH
import SMESH_mechanic
smesh = SMESH_mechanic.smesh
mesh = SMESH_mechanic.mesh
salome = SMESH_mechanic.salome
aFilterMgr = smesh.CreateFilterManager()
# Remove some elements to obtain free edges
# Criterion : AREA > 95.
area_margin = 95.
aFunctor = aFilterMgr.CreateArea()
aPredicate = aFilterMgr.CreateMoreThan()
aPredicate.SetNumFunctor(aFunctor)
aPredicate.SetMargin(area_margin)
aFilter = aFilterMgr.CreateFilter()
aFilter.SetPredicate(aPredicate)
anIds = aFilter.GetElementsId(mesh)
anEditor = mesh.GetMeshEditor()
anEditor.RemoveElements(anIds)
# Criterion : Free Edges
aPredicate = aFilterMgr.CreateFreeEdges()
aPredicate.SetMesh(mesh)
aBorders = aPredicate.GetBorders()
# create groups
aGroupF = mesh.CreateGroup(SMESH.FACE, "Faces with free edges")
aGroupN = mesh.CreateGroup(SMESH.NODE, "Nodes on free edges")
# fill groups with elements, corresponding to the criterion
print ""
print "Criterion: Free edges Nb = ", len(aBorders)
for i in range(len(aBorders)):
aBorder = aBorders[i]
print "Face # ", aBorder.myElemId, " : Edge between nodes (",
print aBorder.myPnt1, ", ", aBorder.myPnt2, ")"
aGroupF.Add([aBorder.myElemId])
aGroupN.Add([aBorder.myPnt1, aBorder.myPnt2])
salome.sg.updateObjBrowser(1)
# Attention! This script has been written using the old approach basing on direct usage of SMESH idl interface.
# For the moment smesh package doesn't provide methods to check length 2D.
# In the next SALOME version the scripts will be updated to use only the commands from smesh package.
import salome
import geompy
import smesh
import SMESH
# 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
tria = smesh.Mesh(box, "Mesh_Length_2D")
algo = tria.Segment()
algo.NumberOfSegments(5)
algo = tria.Triangle()
algo.MaxElementArea(20.)
tria.Compute()
mesh = tria.GetMesh()
gen = smesh.smesh
# Criterion : Length 2D > 5.7
length_margin = 5.7
aFilterMgr = gen.CreateFilterManager()
aFunctor = aFilterMgr.CreateLength2D()
aPredicate = aFilterMgr.CreateMoreThan()
aPredicate.SetNumFunctor(aFunctor)
aPredicate.SetMargin(length_margin)
aFilter = aFilterMgr.CreateFilter()
aFilter.SetPredicate(aPredicate)
anIds = aFilter.GetElementsId(mesh)
# print the result
print "Criterion: Edges length 2D > ", length_margin, " Nb = ", len(anIds)
j = 1
for i in range(len(anIds)):
if j > 20: j = 1; print ""
print anIds[i],
j = j + 1
pass
print ""
# create a group
aGroup = mesh.CreateGroup(SMESH.FACE, "Faces with length 2D > " + `length_margin`)
aGroup.Add(anIds)
salome.sg.updateObjBrowser(1)
# Attention! This script has been written using the old approach basing on direct usage of SMESH idl interface.
# For the moment smesh package doesn't provide methods to check borders at multiconnection 2D.
# In the next SALOME version the scripts will be updated to use only the commands from smesh package.
import salome
import geompy
import smesh
import SMESH
# create a compound of two glued boxes
box1 = geompy.MakeBox(0., 0., 0., 20., 20., 15.)
box2 = geompy.MakeTranslation(box1, 0., 20., 0)
comp = geompy.MakeCompound([box1, box2])
box = geompy.MakeGlueFaces(comp, 0.000001)
idbox = geompy.addToStudy(box, "box")
# create a mesh
tria = smesh.Mesh(box, "Box compound : 2D triangle mesh")
algo = tria.Segment()
algo.NumberOfSegments(5)
algo = tria.Triangle()
algo.MaxElementArea(20.)
tria.Compute()
mesh = tria.GetMesh()
gen = smesh.smesh
# Criterion : MULTI-CONNECTION 2D = 3
nb_conn = 3
aFilterMgr = gen.CreateFilterManager()
aFunctor = aFilterMgr.CreateMultiConnection2D()
aPredicate = aFilterMgr.CreateEqualTo()
aPredicate.SetNumFunctor(aFunctor)
aPredicate.SetMargin(nb_conn)
aFilter = aFilterMgr.CreateFilter()
aFilter.SetPredicate(aPredicate)
anIds = aFilter.GetElementsId(mesh)
# print the result
print "Criterion: Borders at multi-connection 2D = ", nb_conn, " Nb = ", len(anIds)
j = 1
for i in range(len(anIds)):
if j > 20: j = 1; print ""
print anIds[i],
j = j + 1
pass
print ""
# create a group
aGroup = mesh.CreateGroup(SMESH.FACE, "Borders at multi-connection 2D = " + `nb_conn`)
aGroup.Add(anIds)
salome.sg.updateObjBrowser(1)
# Attention! This script has been written using the old approach basing on direct usage of SMESH idl interface.
# For the moment smesh package doesn't provide methods to check area.
# In the next SALOME version the scripts will be updated to use only the commands from smesh package.
import SMESH
import SMESH_mechanic
smesh = SMESH_mechanic.smesh
mesh = SMESH_mechanic.mesh
salome = SMESH_mechanic.salome
# Criterion : AREA > 100.
area_margin = 100.
aFilterMgr = smesh.CreateFilterManager()
aFunctor = aFilterMgr.CreateArea()
aPredicate = aFilterMgr.CreateMoreThan()
aPredicate.SetNumFunctor(aFunctor)
aPredicate.SetMargin(area_margin)
aFilter = aFilterMgr.CreateFilter()
aFilter.SetPredicate(aPredicate)
anIds = aFilter.GetElementsId(mesh)
# print the result
print "Criterion: Area > ", area_margin, " Nb = ", len(anIds)
j = 1
for i in range(len(anIds)):
if j > 20: j = 1; print ""
print anIds[i],
j = j + 1
pass
print ""
# create a group
aGroup = mesh.CreateGroup(SMESH.FACE, "Area > " + `area_margin`)
aGroup.Add(anIds)
salome.sg.updateObjBrowser(1)
# Attention! This script has been written using the old approach basing on direct usage of SMESH idl interface.
# For the moment smesh package doesn't provide methods to check taper.
# In the next SALOME version the scripts will be updated to use only the commands from smesh package.
import SMESH
import SMESH_mechanic
smesh = SMESH_mechanic.smesh
mesh = SMESH_mechanic.mesh
salome = SMESH_mechanic.salome
# Criterion : Taper > 3e-20
taper_margin = 3e-20
aFilterMgr = smesh.CreateFilterManager()
aFunctor = aFilterMgr.CreateTaper()
aPredicate = aFilterMgr.CreateMoreThan()
aPredicate.SetNumFunctor(aFunctor)
aPredicate.SetMargin(taper_margin)
aFilter = aFilterMgr.CreateFilter()
aFilter.SetPredicate(aPredicate)
anIds = aFilter.GetElementsId(mesh)
# print the result
print "Criterion: Taper > ", taper_margin, " Nb = ", len(anIds)
j = 1
for i in range(len(anIds)):
if j > 20: j = 1; print ""
print anIds[i],
j = j + 1
pass
print ""
# create a group
aGroup = mesh.CreateGroup(SMESH.FACE, "Taper > " + `taper_margin`)
aGroup.Add(anIds)
salome.sg.updateObjBrowser(1)
# Attention! This script has been written using the old approach basing on direct usage of SMESH idl interface.
# For the moment smesh package doesn't provide methods to check aspect ratio.
# In the next SALOME version the scripts will be updated to use only the commands from smesh package.
import SMESH
import SMESH_mechanic
smesh = SMESH_mechanic.smesh
mesh = SMESH_mechanic.mesh
salome = SMESH_mechanic.salome
# Criterion : ASPECT RATIO > 1.8
ar_margin = 1.8
aFilterMgr = smesh.CreateFilterManager()
aFunctor = aFilterMgr.CreateAspectRatio()
aPredicate = aFilterMgr.CreateMoreThan()
aPredicate.SetNumFunctor(aFunctor)
aPredicate.SetMargin(ar_margin)
aFilter = aFilterMgr.CreateFilter()
aFilter.SetPredicate(aPredicate)
anIds = aFilter.GetElementsId(mesh)
# print the result
print "Criterion: Aspect Ratio > ", ar_margin, " Nb = ", len(anIds)
j = 1
for i in range(len(anIds)):
if j > 20: j = 1; print ""
print anIds[i],
j = j + 1
pass
print ""
# create a group
aGroup = mesh.CreateGroup(SMESH.FACE, "Aspect Ratio > " + `ar_margin`)
aGroup.Add(anIds)
salome.sg.updateObjBrowser(1)
# Attention! This script has been written using the old approach basing on direct usage of SMESH idl interface.
# For the moment smesh package doesn't provide methods to check minimum angle.
# In the next SALOME version the scripts will be updated to use only the commands from smesh package.
import SMESH
import SMESH_mechanic
smesh = SMESH_mechanic.smesh
mesh = SMESH_mechanic.mesh
salome = SMESH_mechanic.salome
# Criterion : MINIMUM ANGLE < 35.
min_angle = 35.
aFilterMgr = smesh.CreateFilterManager()
aFunctor = aFilterMgr.CreateMinimumAngle()
aPredicate = aFilterMgr.CreateLessThan()
aPredicate.SetNumFunctor(aFunctor)
aPredicate.SetMargin(min_angle)
aFilter = aFilterMgr.CreateFilter()
aFilter.SetPredicate(aPredicate)
anIds = aFilter.GetElementsId(mesh)
# print the result
print "Criterion: Minimum Angle < ", min_angle, " Nb = ", len(anIds)
j = 1
for i in range(len(anIds)):
if j > 20: j = 1; print ""
print anIds[i],
j = j + 1
pass
print ""
# create a group
aGroup = mesh.CreateGroup(SMESH.FACE, "Minimum Angle < " + `min_angle`)
aGroup.Add(anIds)
salome.sg.updateObjBrowser(1)
# Attention! This script has been written using the old approach basing on direct usage of SMESH idl interface.
# For the moment smesh package doesn't provide methods to check warping.
# In the next SALOME version the scripts will be updated to use only the commands from smesh package.
import SMESH
import SMESH_mechanic
smesh = SMESH_mechanic.smesh
mesh = SMESH_mechanic.mesh
salome = SMESH_mechanic.salome
# Criterion : WARP ANGLE > 1e-15
wa_margin = 1e-15
aFilterMgr = smesh.CreateFilterManager()
aFunctor = aFilterMgr.CreateWarping()
aPredicate = aFilterMgr.CreateMoreThan()
aPredicate.SetNumFunctor(aFunctor)
aPredicate.SetMargin(wa_margin)
aFilter = aFilterMgr.CreateFilter()
aFilter.SetPredicate(aPredicate)
anIds = aFilter.GetElementsId(mesh)
# print the result
print "Criterion: Warp > ", wa_margin, " Nb = ", len(anIds)
j = 1
for i in range(len(anIds)):
if j > 20: j = 1; print ""
print anIds[i],
j = j + 1
pass
print ""
# create a group
aGroup = mesh.CreateGroup(SMESH.FACE, "Warp > " + `wa_margin`)
aGroup.Add(anIds)
salome.sg.updateObjBrowser(1)
# Attention! This script has been written using the old approach basing on direct usage of SMESH idl interface.
# For the moment smesh package doesn't provide methods to check skew.
# In the next SALOME version the scripts will be updated to use only the commands from smesh package.
import SMESH
import SMESH_mechanic
smesh = SMESH_mechanic.smesh
mesh = SMESH_mechanic.mesh
salome = SMESH_mechanic.salome
# Criterion : Skew > 38.
skew_margin = 38.
aFilterMgr = smesh.CreateFilterManager()
aFunctor = aFilterMgr.CreateSkew()
aPredicate = aFilterMgr.CreateMoreThan()
aPredicate.SetNumFunctor(aFunctor)
aPredicate.SetMargin(skew_margin)
aFilter = aFilterMgr.CreateFilter()
aFilter.SetPredicate(aPredicate)
anIds = aFilter.GetElementsId(mesh)
# print the result
print "Criterion: Skew > ", skew_margin, " Nb = ", len(anIds)
j = 1
for i in range(len(anIds)):
if j > 20: j = 1; print ""
print anIds[i],
j = j + 1
pass
print ""
# create a group
aGroup = mesh.CreateGroup(SMESH.FACE, "Skew > " + `skew_margin`)
aGroup.Add(anIds)
salome.sg.updateObjBrowser(1)
# Attention! This script has been written using the old approach basing on direct usage of SMESH idl interface.
# For the moment smesh package doesn't provide methods to check aspect ratio 3D.
# In the next SALOME version the scripts will be updated to use only the commands from smesh package.
import SMESH
import SMESH_mechanic_tetra
smesh = SMESH_mechanic_tetra.smesh
mesh = SMESH_mechanic_tetra.mesh
salome = SMESH_mechanic_tetra.salome
# Criterion : ASPECT RATIO 3D > 4.5
ar_margin = 4.5
aFilterMgr = smesh.CreateFilterManager()
aFunctor = aFilterMgr.CreateAspectRatio3D()
aPredicate = aFilterMgr.CreateMoreThan()
aPredicate.SetNumFunctor(aFunctor)
aPredicate.SetMargin(ar_margin)
aFilter = aFilterMgr.CreateFilter()
aFilter.SetPredicate(aPredicate)
anIds = aFilter.GetElementsId(mesh)
# print the result
print "Criterion: Aspect Ratio 3D > ", ar_margin, " Nb = ", len(anIds)
j = 1
for i in range(len(anIds)):
if j > 20: j = 1; print ""
print anIds[i],
j = j + 1
pass
print ""
# create a group
aGroup = mesh.CreateGroup(SMESH.VOLUME, "Aspect Ratio 3D > " + `ar_margin`)
aGroup.Add(anIds)
salome.sg.updateObjBrowser(1)
# Attention! This script has been written using the old approach basing on direct usage of SMESH idl interface.
# For the moment smesh package doesn't provide methods to check volume.
# In the next SALOME version the scripts will be updated to use only the commands from smesh package.
import SMESH
import SMESH_mechanic_tetra
smesh = SMESH_mechanic_tetra.smesh
mesh = SMESH_mechanic_tetra.mesh
salome = SMESH_mechanic_tetra.salome
# Criterion : VOLUME < 7.
volume_margin = 7.
aFilterMgr = smesh.CreateFilterManager()
aFunctor = aFilterMgr.CreateVolume3D()
aPredicate = aFilterMgr.CreateLessThan()
aPredicate.SetNumFunctor(aFunctor)
aPredicate.SetMargin(volume_margin)
aFilter = aFilterMgr.CreateFilter()
aFilter.SetPredicate(aPredicate)
anIds = aFilter.GetElementsId(mesh)
# print the result
print ""
print "Criterion: Volume < ", volume_margin, " Nb = ", len(anIds)
j = 1
for i in range(len(anIds)):
if j > 20: j = 1; print ""
print anIds[i],
j = j + 1
pass
print ""
# create a group
aGroup = mesh.CreateGroup(SMESH.VOLUME, "Volume < " + `volume_margin`)
aGroup.Add(anIds)
salome.sg.updateObjBrowser(1)