Salome HOME
Merge from V5_1_2_BR branch (14 July 2009)
[modules/smesh.git] / src / SMESH_SWIG / SMESH_BuildCompound.py
1 #  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 #
3 #  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 #  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 #
6 #  This library is free software; you can redistribute it and/or
7 #  modify it under the terms of the GNU Lesser General Public
8 #  License as published by the Free Software Foundation; either
9 #  version 2.1 of the License.
10 #
11 #  This library is distributed in the hope that it will be useful,
12 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 #  Lesser General Public License for more details.
15 #
16 #  You should have received a copy of the GNU Lesser General Public
17 #  License along with this library; if not, write to the Free Software
18 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 #
20 #  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 #
22 #  File   : SMESH_BuildCompound.py
23 #  Author : Alexander KOVALEV
24 #  Module : SMESH
25 #  $Header$
26 # ! Please, if you edit this example file, update also
27 # ! SMESH_SRC/doc/salome/gui/SMESH/input/tui_creating_meshes.doc
28 # ! as some sequences of symbols from this example are used during
29 # ! documentation generation to identify certain places of this file
30 #
31 import geompy
32 import smesh
33
34 ## create a bottom box
35 Box_inf = geompy.MakeBox(0., 0., 0., 200., 200., 50.)
36
37 # get a top face
38 Psup1=geompy.MakeVertex(100., 100., 50.)
39 Fsup1=geompy.GetFaceNearPoint(Box_inf, Psup1)
40 # get a bottom face
41 Pinf1=geompy.MakeVertex(100., 100., 0.)
42 Finf1=geompy.GetFaceNearPoint(Box_inf, Pinf1)
43
44 ## create a top box
45 Box_sup = geompy.MakeBox(100., 100., 50., 200., 200., 100.)
46
47 # get a top face
48 Psup2=geompy.MakeVertex(150., 150., 100.)
49 Fsup2=geompy.GetFaceNearPoint(Box_sup, Psup2)
50 # get a bottom face
51 Pinf2=geompy.MakeVertex(150., 150., 50.)
52 Finf2=geompy.GetFaceNearPoint(Box_sup, Pinf2)
53
54 ## Publish in the study
55 geompy.addToStudy(Box_inf, "Box_inf")
56 geompy.addToStudyInFather(Box_inf, Fsup1, "Fsup")
57 geompy.addToStudyInFather(Box_inf, Finf1, "Finf")
58
59 geompy.addToStudy(Box_sup, "Box_sup")
60 geompy.addToStudyInFather(Box_sup, Fsup2, "Fsup")
61 geompy.addToStudyInFather(Box_sup, Finf2, "Finf")
62
63 ## create a bottom mesh
64 Mesh_inf = smesh.Mesh(Box_inf, "Mesh_inf")
65 algo1D_1=Mesh_inf.Segment()
66 algo1D_1.NumberOfSegments(10)
67 algo2D_1=Mesh_inf.Quadrangle()
68 algo3D_1=Mesh_inf.Hexahedron()
69 Mesh_inf.Compute()
70
71 # create a group on the top face
72 Gsup1=Mesh_inf.Group(Fsup1, "Sup")
73 # create a group on the bottom face
74 Ginf1=Mesh_inf.Group(Finf1, "Inf")
75
76 ## create a top mesh
77 Mesh_sup = smesh.Mesh(Box_sup, "Mesh_sup")
78 algo1D_2=Mesh_sup.Segment()
79 algo1D_2.NumberOfSegments(5)
80 algo2D_2=Mesh_sup.Quadrangle()
81 algo3D_2=Mesh_sup.Hexahedron()
82 Mesh_sup.Compute()
83
84 # create a group on the top face
85 Gsup2=Mesh_sup.Group(Fsup2, "Sup")
86 # create a group on the bottom face
87 Ginf2=Mesh_sup.Group(Finf2, "Inf")
88
89 ## create compounds
90 # create a compound of two meshes with renaming groups with the same names and
91 # merging of elements with the given tolerance
92 Compound1 = smesh.smesh.Concatenate([Mesh_inf.GetMesh(), Mesh_sup.GetMesh()], 0, 1, 1e-05)
93 smesh.SetName(Compound1, 'Compound_with_RenamedGrps_and_MergeElems')
94 # create a compound of two meshes with uniting groups with the same names and
95 # creating groups of all elements
96 Compound2 = smesh.smesh.Concatenate([Mesh_inf.GetMesh(), Mesh_sup.GetMesh()], 1, 0, 1e-05, True)
97 smesh.SetName(Compound2, 'Compound_with_UniteGrps_and_GrpsOfAllElems')
98 #end