Back to index

salome-smesh  6.5.0
SMESH_test4.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 # Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00005 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00006 #
00007 # This library is free software; you can redistribute it and/or
00008 # modify it under the terms of the GNU Lesser General Public
00009 # License as published by the Free Software Foundation; either
00010 # version 2.1 of the License.
00011 #
00012 # This library is distributed in the hope that it will be useful,
00013 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015 # Lesser General Public License for more details.
00016 #
00017 # You should have received a copy of the GNU Lesser General Public
00018 # License along with this library; if not, write to the Free Software
00019 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00020 #
00021 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00022 #
00023 
00024 import salome
00025 import geompy
00026 import smesh
00027 
00028 
00029 # ---- GEOM
00030 
00031 box   = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
00032 idbox = geompy.addToStudy(box, "box")
00033 
00034 subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
00035 face   = subShapeList[0]
00036 name   = geompy.SubShapeName(face, box)
00037 idface = geompy.addToStudyInFather(box, face, name)
00038 
00039 box  = salome.IDToObject(idbox)
00040 face = salome.IDToObject(idface)
00041 
00042 # ---- SMESH
00043 
00044 smesh.SetCurrentStudy(salome.myStudy)
00045 mesh = smesh.Mesh(box, "Meshbox")
00046 
00047 # Set 1D algorithm/hypotheses to mesh
00048 algo1 = mesh.Segment()
00049 algo1.NumberOfSegments(10)
00050 
00051 # Set 2D algorithm/hypotheses to mesh
00052 algo2 = mesh.Triangle(smesh.MEFISTO)
00053 algo2.MaxElementArea(10)
00054 
00055 # Create submesh on face
00056 algo3 = mesh.Segment(face)
00057 algo3.NumberOfSegments(10)
00058 algo4 = mesh.Triangle(smesh.MEFISTO, face)
00059 algo4.MaxElementArea(100)
00060 submesh = algo4.GetSubMesh()
00061 smesh.SetName(submesh, "SubMeshFace")
00062 
00063 
00064 mesh.Compute()
00065 
00066 faces = submesh.GetElementsByType(smesh.FACE)
00067 if len(faces) > 1:
00068     print len(faces), len(faces)/2
00069     group1 = mesh.CreateEmptyGroup(smesh.FACE,"Group of faces")
00070     group2 = mesh.CreateEmptyGroup(smesh.FACE,"Another group of faces")
00071     group1.Add(faces[:int(len(faces)/2)])
00072     group2.Add(faces[int(len(faces)/2):])
00073 
00074 salome.sg.updateObjBrowser(1)