Back to index

salome-smesh  6.5.0
PAL_MESH_041_mesh.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 #----------Vertexes------------
00032 p1 = geompy.MakeVertex(20.0,30.0,40.0)
00033 p2 = geompy.MakeVertex(90.0,80.0,0.0)
00034 p3 = geompy.MakeVertex(30.0,80.0,200.0)
00035 
00036 #----------Edges---------------
00037 e1 = geompy.MakeEdge(p1,p2)
00038 e2 = geompy.MakeEdge(p2,p3)
00039 e3 = geompy.MakeEdge(p3,p1)
00040 
00041 #----------Wire----------------
00042 ListOfEdges = []
00043 ListOfEdges.append(e3)
00044 ListOfEdges.append(e2)
00045 ListOfEdges.append(e1)
00046 wire1 = geompy.MakeWire(ListOfEdges)
00047 
00048 
00049 #----------Face----------------
00050 WantPlanarFace = 1
00051 face1 = geompy.MakeFace(wire1,WantPlanarFace)
00052 
00053 Id_face1 = geompy.addToStudy(face1,"Face1")
00054 
00055 
00056 
00057 #-----------------------------SMESH-------------------------------------------
00058 smesh.SetCurrentStudy(salome.myStudy)
00059 
00060 # -- Init mesh --
00061 plane_mesh = salome.IDToObject( Id_face1)
00062 
00063 mesh = smesh.Mesh(plane_mesh, "Mesh_1")
00064 
00065 print"---------------------Hypothesis and Algorithms"
00066 
00067 #---------------- NumberOfSegments
00068 
00069 numberOfSegment = 9
00070 
00071 algoWireDes = mesh.Segment()
00072 listHyp = algoWireDes.GetCompatibleHypothesis()
00073 print algoWireDes.GetName()
00074 algoWireDes.SetName("Ware descritisation")
00075 
00076 hypNbSeg = algoWireDes.NumberOfSegments(numberOfSegment)
00077 print hypNbSeg.GetName()
00078 print hypNbSeg.GetNumberOfSegments()
00079 smesh.SetName(hypNbSeg, "Nb. Segments")
00080 
00081 
00082 #--------------------------Max. Element Area
00083 maxElementArea = 200
00084 
00085 algoMef = mesh.Triangle()
00086 listHyp = algoMef.GetCompatibleHypothesis()
00087 print algoMef.GetName()
00088 algoMef.SetName("Triangle (Mefisto)")
00089 
00090 hypArea200 = algoMef.MaxElementArea(maxElementArea)
00091 print hypArea200.GetName()
00092 print hypArea200.GetMaxElementArea()
00093 smesh.SetName(hypArea200, "Max. Element Area")
00094 
00095 
00096 print "---------------------Compute the mesh"
00097 
00098 ret = mesh.Compute()
00099 print ret
00100 
00101 salome.sg.updateObjBrowser(1)
00102