2013-02-12 20:37:44 +06:00
|
|
|
# Projection 1D2D
|
|
|
|
# Project triangles from one meshed face to another mesh on the same box
|
|
|
|
|
2013-04-04 13:08:19 +06:00
|
|
|
import salome
|
2021-08-12 14:38:10 +05:00
|
|
|
salome.salome_init_without_session()
|
2013-04-04 13:08:19 +06:00
|
|
|
|
2022-04-11 18:28:01 +05:00
|
|
|
from salome.geom import geomBuilder
|
2013-04-04 13:08:19 +06:00
|
|
|
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' )
|
2016-03-21 17:03:25 +05:00
|
|
|
|
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()
|
2023-02-21 18:59:44 +05:00
|
|
|
if not src_mesh.Compute(): raise Exception("Error when computing Mesh")
|
2013-02-12 20:37:44 +06:00
|
|
|
|
2017-03-02 21:51:35 +05: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)
|
2023-02-21 18:59:44 +05:00
|
|
|
if not tgt_mesh.Compute(): raise Exception("Error when computing Mesh")
|