Back to index

salome-smesh  6.5.0
SMESH_reg.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 #  File   : SMESH_reg.py
00025 #  Module : SMESH
00026 #
00027 import salome
00028 import geompy
00029 import smesh
00030 
00031 import StdMeshers
00032 
00033 
00034 # ---- define a box
00035 print "Define box"
00036 box = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
00037 idbox = geompy.addToStudy(box, "box")
00038 
00039 # ---- add faces of box to study
00040 print "Add faces to study"
00041 idface = []
00042 subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
00043 for f in subShapeList:
00044   name = geompy.SubShapeName(f, box)
00045   print name
00046   idface.append( geompy.addToStudyInFather(box, f, name) )
00047 
00048 # ---- add edges of box to study
00049 print "Add edges to study"
00050 idedge = []
00051 subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["EDGE"])
00052 for f in subShapeList:
00053   name = geompy.SubShapeName(f, box)
00054   print name
00055   idedge.append( geompy.addToStudyInFather(box, f, name) )
00056 
00057 salome.sg.updateObjBrowser(1);
00058 
00059 # ---- launch SMESH
00060 smeshgui = salome.ImportComponentGUI("SMESH")
00061 smeshgui.Init(salome.myStudyId)
00062 smesh.SetCurrentStudy(salome.myStudy)
00063 
00064 # ---- Creating meshes
00065 
00066 box = salome.IDToObject(idbox)
00067 names = [ "MeshBoxReg", "MeshBoxScale", "MeshBoxTable", "MeshBoxExpr" ]
00068 
00069 
00070 print "-------------------------- Create ", names[0], " mesh"
00071 mesh = smesh.Mesh(box, names[0])
00072 algo = mesh.Segment()
00073 hyp = algo.NumberOfSegments(7)
00074 hyp.SetDistrType(0)
00075 smesh.SetName(hyp, "NumberOfSegmentsReg")
00076 algo = mesh.Triangle()
00077 algo.MaxElementArea(2500)
00078 
00079 print "-------------------------- Create ", names[1], " mesh"
00080 mesh = smesh.Mesh(box, names[1])
00081 algo = mesh.Segment()
00082 hyp = algo.NumberOfSegments(7)
00083 hyp.SetDistrType(1)
00084 hyp.SetScaleFactor(2)
00085 smesh.SetName(hyp, "NumberOfSegmentsScale")
00086 algo = mesh.Triangle()
00087 algo.MaxElementArea(2500)
00088 
00089 print "-------------------------- Create ", names[2], " mesh"
00090 mesh = smesh.Mesh(box,names[2])
00091 algo = mesh.Segment()
00092 hyp = algo.NumberOfSegments(7)
00093 hyp.SetDistrType(2)
00094 hyp.SetTableFunction( [0, 0.1, 0.5, 1.0, 1.0, 0.1] )
00095 hyp.SetConversionMode(0)
00096 smesh.SetName(hyp, "NumberOfSegmentsTable")
00097 algo = mesh.Triangle()
00098 algo.MaxElementArea(2500)
00099 
00100 print "-------------------------- Create ", names[3], " mesh"
00101 mesh = smesh.Mesh(box, names[3])
00102 algo = mesh.Segment()
00103 hyp = algo.NumberOfSegments(10)
00104 hyp.SetDistrType(3)
00105 hyp.SetExpressionFunction("sin(3*t)")
00106 hyp.SetConversionMode(1)
00107 smesh.SetName(hyp, "NumberOfSegmentsExpr")
00108 algo = mesh.Triangle()
00109 algo.MaxElementArea(2500)
00110 
00111 
00112 salome.sg.updateObjBrowser(1);
00113