smesh/doc/salome/examples/notebook_smesh.py

48 lines
1.0 KiB
Python
Raw Normal View History

2013-02-12 20:37:44 +06:00
# Using SALOME NoteBook
import salome
salome.salome_init()
import GEOM
from salome.geom import geomBuilder
2017-06-13 15:01:10 +05:00
geompy = geomBuilder.New()
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
2017-06-13 15:01:10 +05:00
smesh = smeshBuilder.New()
2013-02-12 20:37:44 +06:00
import salome_notebook
# set variables
notebook = salome_notebook.notebook
notebook.set("Length", 100)
notebook.set("Width", 200)
notebook.set("Offset", 50)
notebook.set("NbSegments", 7)
notebook.set("MaxElementArea", 800)
notebook.set("MaxElementVolume", 900)
# create a box
box = geompy.MakeBoxDXDYDZ("Length", "Width", 300)
idbox = geompy.addToStudy(box, "Box")
# create a mesh
tetra = smesh.Mesh(box, "MeshBox")
algo1D = tetra.Segment()
algo1D.NumberOfSegments("NbSegments")
algo2D = tetra.Triangle()
algo2D.MaxElementArea("MaxElementArea")
algo3D = tetra.Tetrahedron()
algo3D.MaxElementVolume("MaxElementVolume")
# compute the mesh
ret = tetra.Compute()
# translate the mesh
point = SMESH.PointStruct("Offset", 0., 0.)
vector = SMESH.DirStruct(point)
2013-02-12 20:37:44 +06:00
tetra.TranslateObject(tetra, vector, 0)