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