Back to index

salome-smesh  6.5.0
ex30_tepal.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 # ====================================================================
00022 #
00023 import os
00024 
00025 import geompy
00026 import smesh
00027 
00028 # Parameters
00029 # ----------
00030 
00031 results = "/tmp/ZZ"
00032 
00033 radius =  50
00034 height = 200
00035 
00036 # Build a cylinder
00037 # ----------------
00038 
00039 base = geompy.MakeVertex(0, 0, 0)
00040 direction = geompy.MakeVectorDXDYDZ(0, 0, 1)
00041 
00042 cylinder = geompy.MakeCylinder(base, direction, radius, height)
00043 
00044 geompy.addToStudy(cylinder, "Cylinder")
00045 
00046 # Define a mesh on a geometry
00047 # ---------------------------
00048 
00049 smesh.SetCurrentStudy(salome.myStudy)
00050 
00051 m = smesh.Mesh(cylinder)
00052 
00053 # 2D mesh with BLSURF
00054 # -------------------
00055 
00056 algo2d = m.Triangle(smesh.BLSURF)
00057 
00058 algo2d.SetPhysicalMesh(1)
00059 algo2d.SetPhySize(5)
00060 
00061 algo2d.SetGeometricMesh(0)
00062 
00063 # 3D mesh with tepal
00064 # ------------------
00065 
00066 algo3d = m.Tetrahedron(smesh.GHS3DPRL)
00067 
00068 algo3d.SetMEDName(results)
00069 algo3d.SetNbPart(4)
00070 algo3d.SetBackground(False)
00071 algo3d.SetKeepFiles(False)
00072 algo3d.SetToMeshHoles(True)
00073 
00074 # Launch meshers
00075 # --------------
00076 
00077 status = m.Compute()
00078 
00079 # Test if ok
00080 # ----------
00081 
00082 if os.access(results+".xml", os.F_OK):
00083     print "Ok: tepal"
00084 else:
00085     print "KO: tepal"