smesh/doc/examples/modifying_meshes_ex18.py

48 lines
1.2 KiB
Python
Raw Normal View History

2013-02-12 20:37:44 +06:00
# Uniting a Set of Triangles
import salome
salome.salome_init_without_session()
2022-04-11 18:28:01 +05:00
import SMESH
from salome.smesh import smeshBuilder
2022-04-11 18:28:01 +05:00
smesh_builder = smeshBuilder.New()
2013-02-12 20:37:44 +06:00
# create an empty mesh structure
2022-04-11 18:28:01 +05:00
mesh = smesh_builder.Mesh()
2013-02-12 20:37:44 +06:00
# create the following mesh:
# .----.----.----.
# | /| /| /|
# | / | / | / |
# | / | / | / |
# |/ |/ |/ |
# .----.----.----.
bb = [0, 0, 0, 0]
tt = [0, 0, 0, 0]
ff = [0, 0, 0, 0, 0, 0]
bb[0] = mesh.AddNode( 0., 0., 0.)
bb[1] = mesh.AddNode(10., 0., 0.)
bb[2] = mesh.AddNode(20., 0., 0.)
bb[3] = mesh.AddNode(30., 0., 0.)
tt[0] = mesh.AddNode( 0., 15., 0.)
tt[1] = mesh.AddNode(10., 15., 0.)
tt[2] = mesh.AddNode(20., 15., 0.)
tt[3] = mesh.AddNode(30., 15., 0.)
ff[0] = mesh.AddFace([bb[0], bb[1], tt[1]])
ff[1] = mesh.AddFace([bb[0], tt[1], tt[0]])
ff[2] = mesh.AddFace([bb[1], bb[2], tt[2]])
ff[3] = mesh.AddFace([bb[1], tt[2], tt[1]])
ff[4] = mesh.AddFace([bb[2], bb[3], tt[3]])
ff[5] = mesh.AddFace([bb[2], tt[3], tt[2]])
# unite a set of triangles
2017-03-20 17:27:30 +05:00
print("\nUnite a set of triangles ... ", end=' ')
res = mesh.TriToQuad([ff[2], ff[3], ff[4], ff[5]], SMESH.FT_MinimumAngle, 60.)
2017-03-20 17:27:30 +05:00
if not res: print("failed!")
else: print("done.")