1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 # File : SMESH_BuildCompound.py
22 # Author : Alexander KOVALEV
25 # ! Please, if you edit this example file, update also
26 # ! SMESH_SRC/doc/salome/gui/SMESH/input/tui_creating_meshes.doc
27 # ! as some sequences of symbols from this example are used during
28 # ! documentation generation to identify certain places of this file
33 from salome.geom import geomBuilder
34 geompy = geomBuilder.New(salome.myStudy)
36 import SMESH, SALOMEDS
37 from salome.smesh import smeshBuilder
38 smesh = smeshBuilder.New(salome.myStudy)
40 ## create a bottom box
41 Box_inf = geompy.MakeBox(0., 0., 0., 200., 200., 50.)
44 Psup1=geompy.MakeVertex(100., 100., 50.)
45 Fsup1=geompy.GetFaceNearPoint(Box_inf, Psup1)
47 Pinf1=geompy.MakeVertex(100., 100., 0.)
48 Finf1=geompy.GetFaceNearPoint(Box_inf, Pinf1)
51 Box_sup = geompy.MakeBox(100., 100., 50., 200., 200., 100.)
54 Psup2=geompy.MakeVertex(150., 150., 100.)
55 Fsup2=geompy.GetFaceNearPoint(Box_sup, Psup2)
57 Pinf2=geompy.MakeVertex(150., 150., 50.)
58 Finf2=geompy.GetFaceNearPoint(Box_sup, Pinf2)
60 ## Publish in the study
61 geompy.addToStudy(Box_inf, "Box_inf")
62 geompy.addToStudyInFather(Box_inf, Fsup1, "Fsup")
63 geompy.addToStudyInFather(Box_inf, Finf1, "Finf")
65 geompy.addToStudy(Box_sup, "Box_sup")
66 geompy.addToStudyInFather(Box_sup, Fsup2, "Fsup")
67 geompy.addToStudyInFather(Box_sup, Finf2, "Finf")
70 ## create a bottom mesh
71 Mesh_inf = smesh.Mesh(Box_inf, "Mesh_inf")
72 algo1D_1=Mesh_inf.Segment()
73 algo1D_1.NumberOfSegments(10)
74 algo2D_1=Mesh_inf.Quadrangle()
75 algo3D_1=Mesh_inf.Hexahedron()
78 # create a group on the top face
79 Gsup1=Mesh_inf.Group(Fsup1, "Sup")
80 # create a group on the bottom face
81 Ginf1=Mesh_inf.Group(Finf1, "Inf")
84 Mesh_sup = smesh.Mesh(Box_sup, "Mesh_sup")
85 algo1D_2=Mesh_sup.Segment()
86 algo1D_2.NumberOfSegments(5)
87 algo2D_2=Mesh_sup.Quadrangle()
88 algo3D_2=Mesh_sup.Hexahedron()
91 # create a group on the top face
92 Gsup2=Mesh_sup.Group(Fsup2, "Sup")
93 # create a group on the bottom face
94 Ginf2=Mesh_sup.Group(Finf2, "Inf")
97 # create a compound of two meshes with renaming groups with the same names and
98 # merging of elements with the given tolerance
99 Compound1 = smesh.Concatenate([Mesh_inf.GetMesh(), Mesh_sup.GetMesh()], 0, 1, 1e-05)
100 smesh.SetName(Compound1, 'Compound_with_RenamedGrps_and_MergeElems')
101 # create a compound of two meshes with uniting groups with the same names and
102 # creating groups of all elements
103 Compound2 = smesh.Concatenate([Mesh_inf.GetMesh(), Mesh_sup.GetMesh()], 1, 0, 1e-05, True)
104 smesh.SetName(Compound2, 'Compound_with_UniteGrps_and_GrpsOfAllElems')
107 salome.sg.updateObjBrowser(1)