smesh/doc/examples/defining_hypotheses_ex11.py

38 lines
1.2 KiB
Python
Raw Permalink Normal View History

2013-02-12 20:37:44 +06:00
# Projection 1D2D
# Project triangles from one meshed face to another mesh on the same box
import salome
salome.salome_init_without_session()
2022-04-11 18:28:01 +05:00
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
# Prepare geometry
# Create a box
2022-04-11 18:28:01 +05:00
box = geom_builder.MakeBoxDXDYDZ(100, 100, 100)
2013-02-12 20:37:44 +06:00
# Get geom faces to mesh with triangles in the 1ts and 2nd meshes
2022-04-11 18:28:01 +05:00
faces = geom_builder.SubShapeAll(box, geom_builder.ShapeType["FACE"])
2013-02-12 20:37:44 +06:00
# 2 adjacent faces of the box
Face_1 = faces[2]
Face_2 = faces[0]
2022-04-11 18:28:01 +05:00
geom_builder.addToStudy( box, 'box' )
geom_builder.addToStudyInFather( box, Face_1, 'Face_1' )
geom_builder.addToStudyInFather( box, Face_2, 'Face_2' )
2022-04-15 20:49:22 +05:00
# Make the source mesh triangulated by default algorithm
2022-04-11 18:28:01 +05:00
src_mesh = smesh_builder.Mesh(Face_1, "Source mesh")
2013-02-12 20:37:44 +06:00
src_mesh.Segment().NumberOfSegments(15)
src_mesh.Triangle()
if not src_mesh.Compute(): raise Exception("Error when computing Mesh")
2013-02-12 20:37:44 +06:00
# Mesh the target mesh using the algorithm Projection1D2D
2022-04-11 18:28:01 +05:00
tgt_mesh = smesh_builder.Mesh(Face_2, "Target mesh")
2013-02-12 20:37:44 +06:00
tgt_mesh.Projection1D2D().SourceFace(Face_1,src_mesh)
if not tgt_mesh.Compute(): raise Exception("Error when computing Mesh")