smesh/doc/examples/notebook_smesh.py

46 lines
1.1 KiB
Python
Raw Normal View History

2013-02-12 20:37:44 +06:00
# Using SALOME NoteBook
import salome
salome.salome_init_without_session()
2022-04-11 18:28:01 +05:00
from salome_notebook import notebook
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
# set variables
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
2022-04-11 18:28:01 +05:00
box = geom_builder.MakeBoxDXDYDZ("Length", "Width", 300)
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
tetra = smesh_builder.Mesh(box, "MeshBox")
2013-02-12 20:37:44 +06:00
algo1D = tetra.Segment()
algo1D.NumberOfSegments("NbSegments")
algo2D = tetra.Triangle()
algo2D.MaxElementArea("MaxElementArea")
algo3D = tetra.Tetrahedron()
algo3D.MaxElementVolume("MaxElementVolume")
# compute the mesh
if not tetra.Compute(): raise Exception("Error when computing Mesh")
2013-02-12 20:37:44 +06:00
# 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)