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