Back to index

salome-smesh  6.5.0
SMESH_BuildCompound.py
Go to the documentation of this file.
00001 #  -*- coding: iso-8859-1 -*-
00002 # Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00003 #
00004 # This library is free software; you can redistribute it and/or
00005 # modify it under the terms of the GNU Lesser General Public
00006 # License as published by the Free Software Foundation; either
00007 # version 2.1 of the License.
00008 #
00009 # This library is distributed in the hope that it will be useful,
00010 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012 # Lesser General Public License for more details.
00013 #
00014 # You should have received a copy of the GNU Lesser General Public
00015 # License along with this library; if not, write to the Free Software
00016 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00017 #
00018 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00019 #
00020 
00021 #  File   : SMESH_BuildCompound.py
00022 #  Author : Alexander KOVALEV
00023 #  Module : SMESH
00024 #  $Header: /home/server/cvs/SMESH/SMESH_SRC/src/SMESH_SWIG/SMESH_BuildCompound.py,v 1.2.2.5.4.2.8.1 2012-04-13 09:31:17 vsr Exp $
00025 # ! Please, if you edit this example file, update also
00026 # ! SMESH_SRC/doc/salome/gui/SMESH/input/tui_creating_meshes.doc
00027 # ! as some sequences of symbols from this example are used during
00028 # ! documentation generation to identify certain places of this file
00029 #
00030 import salome
00031 import geompy
00032 import smesh
00033 
00034 ## create a bottom box
00035 Box_inf = geompy.MakeBox(0., 0., 0., 200., 200., 50.)
00036 
00037 # get a top face
00038 Psup1=geompy.MakeVertex(100., 100., 50.)
00039 Fsup1=geompy.GetFaceNearPoint(Box_inf, Psup1)
00040 # get a bottom face
00041 Pinf1=geompy.MakeVertex(100., 100., 0.)
00042 Finf1=geompy.GetFaceNearPoint(Box_inf, Pinf1)
00043 
00044 ## create a top box
00045 Box_sup = geompy.MakeBox(100., 100., 50., 200., 200., 100.)
00046 
00047 # get a top face
00048 Psup2=geompy.MakeVertex(150., 150., 100.)
00049 Fsup2=geompy.GetFaceNearPoint(Box_sup, Psup2)
00050 # get a bottom face
00051 Pinf2=geompy.MakeVertex(150., 150., 50.)
00052 Finf2=geompy.GetFaceNearPoint(Box_sup, Pinf2)
00053 
00054 ## Publish in the study
00055 geompy.addToStudy(Box_inf, "Box_inf")
00056 geompy.addToStudyInFather(Box_inf, Fsup1, "Fsup")
00057 geompy.addToStudyInFather(Box_inf, Finf1, "Finf")
00058 
00059 geompy.addToStudy(Box_sup, "Box_sup")
00060 geompy.addToStudyInFather(Box_sup, Fsup2, "Fsup")
00061 geompy.addToStudyInFather(Box_sup, Finf2, "Finf")
00062 
00063 smesh.SetCurrentStudy(salome.myStudy)
00064 
00065 ## create a bottom mesh
00066 Mesh_inf = smesh.Mesh(Box_inf, "Mesh_inf")
00067 algo1D_1=Mesh_inf.Segment()
00068 algo1D_1.NumberOfSegments(10)
00069 algo2D_1=Mesh_inf.Quadrangle()
00070 algo3D_1=Mesh_inf.Hexahedron()
00071 Mesh_inf.Compute()
00072 
00073 # create a group on the top face
00074 Gsup1=Mesh_inf.Group(Fsup1, "Sup")
00075 # create a group on the bottom face
00076 Ginf1=Mesh_inf.Group(Finf1, "Inf")
00077 
00078 ## create a top mesh
00079 Mesh_sup = smesh.Mesh(Box_sup, "Mesh_sup")
00080 algo1D_2=Mesh_sup.Segment()
00081 algo1D_2.NumberOfSegments(5)
00082 algo2D_2=Mesh_sup.Quadrangle()
00083 algo3D_2=Mesh_sup.Hexahedron()
00084 Mesh_sup.Compute()
00085 
00086 # create a group on the top face
00087 Gsup2=Mesh_sup.Group(Fsup2, "Sup")
00088 # create a group on the bottom face
00089 Ginf2=Mesh_sup.Group(Finf2, "Inf")
00090 
00091 ## create compounds
00092 # create a compound of two meshes with renaming groups with the same names and
00093 # merging of elements with the given tolerance
00094 Compound1 = smesh.smesh.Concatenate([Mesh_inf.GetMesh(), Mesh_sup.GetMesh()], 0, 1, 1e-05)
00095 smesh.SetName(Compound1, 'Compound_with_RenamedGrps_and_MergeElems')
00096 # create a compound of two meshes with uniting groups with the same names and
00097 # creating groups of all elements
00098 Compound2 = smesh.smesh.Concatenate([Mesh_inf.GetMesh(), Mesh_sup.GetMesh()], 1, 0, 1e-05, True)
00099 smesh.SetName(Compound2, 'Compound_with_UniteGrps_and_GrpsOfAllElems')
00100 #end