Back to index

salome-smesh  6.5.0
SMESH_test1_AndDisplay.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_test1.py
00025 #  Module : SMESH
00026 #
00027 import salome
00028 import geompy
00029 import smesh
00030 
00031 
00032 # ---- define a box
00033 
00034 box = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
00035 idbox = geompy.addToStudy(box, "box")
00036 
00037 # ---- add first face of box in study
00038 
00039 subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
00040 face = subShapeList[0]
00041 name = geompy.SubShapeName(face, box)
00042 print name
00043 idface = geompy.addToStudyInFather(box, face, name)
00044 
00045 # ---- add shell from box  in study
00046 
00047 subShellList = geompy.SubShapeAll(box, geompy.ShapeType["SHELL"])
00048 shell = subShellList[0]
00049 name = geompy.SubShapeName(shell, box)
00050 print name
00051 idshell = geompy.addToStudyInFather(box, shell, name)
00052 
00053 # ---- add first edge of face in study
00054 
00055 edgeList = geompy.SubShapeAll(face, geompy.ShapeType["EDGE"])
00056 edge = edgeList[0]
00057 name = geompy.SubShapeName(edge, face)
00058 print name
00059 idedge = geompy.addToStudyInFather(face, edge, name)
00060 
00061 
00062 # ---- SMESH
00063 
00064 smesh.SetCurrentStudy(salome.myStudy)
00065 
00066 # ---- Init a Mesh with the box
00067 
00068 mesh = smesh.Mesh(box, "Meshbox")
00069 
00070 print "-------------------------- add hypothesis to box"
00071 algoReg1 = mesh.Segment()
00072 hypNbSeg1 = algoReg1.NumberOfSegments(7)
00073 print hypNbSeg1.GetName()
00074 print hypNbSeg1.GetId()
00075 print hypNbSeg1.GetNumberOfSegments()
00076 smesh.SetName(hypNbSeg1, "NumberOfSegments_7")
00077 
00078 algoMef1 = mesh.Triangle()
00079 hypArea1 = algoMef1.MaxElementArea(2500)
00080 print hypArea1.GetName()
00081 print hypArea1.GetId()
00082 print hypArea1.GetMaxElementArea()
00083 smesh.SetName(hypArea1, "MaxElementArea_2500")
00084 
00085 # ---- add hypothesis to edge
00086 print "-------------------------- add hypothesis to edge"
00087 edge = salome.IDToObject(idedge)
00088 
00089 algoReg2 = mesh.Segment(edge)
00090 hypLen1 = algoReg2.LocalLength(100)
00091 smesh.SetName(algoReg2.GetSubMesh(), "SubMeshEdge")
00092 print hypLen1.GetName()
00093 print hypLen1.GetId()
00094 print hypLen1.GetLength()
00095 smesh.SetName(hypLen1, "Local_Length_100")
00096 
00097 # ---- add hypothesis to face
00098 print "-------------------------- add hypothesis to face"
00099 face = salome.IDToObject(idface)
00100 
00101 algoMef2 = mesh.Triangle(face)
00102 hypArea2 = algoMef2.MaxElementArea(500)
00103 smesh.SetName(algoMef2.GetSubMesh(), "SubMeshFace")
00104 print hypArea2.GetName()
00105 print hypArea2.GetId()
00106 print hypArea2.GetMaxElementArea()
00107 smesh.SetName(hypArea2, "MaxElementArea_500")
00108 
00109 mesh.Compute()
00110 
00111 salome.sg.updateObjBrowser(1);
00112 
00113 sg = salome.ImportComponentGUI('SMESH')
00114 if type(sg) != type(salome.salome_ComponentGUI):
00115     sg.CreateAndDisplayActor('0:1:2:3')