Back to index

salome-smesh  6.5.0
SMESH_flight_skin.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 # Triangulation of the skin of the geometry from a Brep representing a plane
00025 # Hypothesis and algorithms for the mesh generation are global
00026 #
00027 import os
00028 import salome
00029 import geompy
00030 import smesh
00031 
00032 
00033 # ---------------------------- GEOM --------------------------------------
00034 
00035 # import a BRep
00036 #before running this script, please be sure about
00037 #the path the file fileName
00038 
00039 filePath = os.environ["DATA_DIR"]
00040 filePath = filePath + "/Shapes/Brep/"
00041 
00042 filename = "flight_solid.brep"
00043 filename = filePath + filename
00044 
00045 shape = geompy.Import(filename, "BREP")
00046 idShape = geompy.addToStudy(shape, "flight")
00047 
00048 print "Analysis of the geometry flight :"
00049 subShellList = geompy.SubShapeAll(shape, geompy.ShapeType["SHELL"])
00050 subFaceList  = geompy.SubShapeAll(shape, geompy.ShapeType["FACE"])
00051 subEdgeList  = geompy.SubShapeAll(shape, geompy.ShapeType["EDGE"])
00052 
00053 print "number of Shells in flight : ", len(subShellList)
00054 print "number of Faces  in flight : ", len(subFaceList)
00055 print "number of Edges  in flight : ", len(subEdgeList)
00056 
00057 
00058 ### ---------------------------- SMESH --------------------------------------
00059 smesh.SetCurrentStudy(salome.myStudy)
00060 
00061 # ---- init a Mesh with the shell
00062 shape_mesh = salome.IDToObject( idShape )
00063 
00064 mesh = smesh.Mesh(shape_mesh, "MeshFlight")
00065 
00066 
00067 # ---- set Hypothesis and Algorithm
00068 
00069 print "-------------------------- LocalLength"
00070 
00071 lengthOfSegments = 0.3
00072 
00073 regular1D = mesh.Segment()
00074 hypLength = regular1D.LocalLength(lengthOfSegments)
00075 print hypLength.GetName()
00076 print hypLength.GetId()
00077 print hypLength.GetLength()
00078 smesh.SetName(hypLength, "LocalLength_" + str(lengthOfSegments))
00079 
00080 print "-------------------------- LengthFromEdges"
00081 
00082 mefisto2D = mesh.Triangle()
00083 hypLengthFromEdge = mefisto2D.LengthFromEdges()
00084 print hypLengthFromEdge.GetName()
00085 print hypLengthFromEdge.GetId()
00086 smesh.SetName(hypLengthFromEdge,"LengthFromEdge")
00087 
00088 
00089 salome.sg.updateObjBrowser(1)
00090 
00091 
00092 print "-------------------------- compute the skin flight"
00093 ret = mesh.Compute()
00094 print ret
00095 if ret != 0:
00096     log = mesh.GetLog(0) # no erase trace
00097     for linelog in log:
00098         print linelog
00099     print "Information about the Mesh_mechanic_tetra:"
00100     print "Number of nodes      : ", mesh.NbNodes()
00101     print "Number of edges      : ", mesh.NbEdges()
00102     print "Number of faces      : ", mesh.NbFaces()
00103     print "Number of triangles  : ", mesh.NbTriangles()
00104     print "Number of volumes    : ", mesh.NbVolumes()
00105 else:
00106     print "probleme when computing the mesh"