Salome HOME
Merge from BR_V5_DEV 16Feb09
[modules/smesh.git] / src / SMESH_SWIG / SMESH_flight_skin.py
1 #  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 #
3 #  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 #  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 #
6 #  This library is free software; you can redistribute it and/or
7 #  modify it under the terms of the GNU Lesser General Public
8 #  License as published by the Free Software Foundation; either
9 #  version 2.1 of the License.
10 #
11 #  This library is distributed in the hope that it will be useful,
12 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 #  Lesser General Public License for more details.
15 #
16 #  You should have received a copy of the GNU Lesser General Public
17 #  License along with this library; if not, write to the Free Software
18 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 #
20 #  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 #
22 # Triangulation of the skin of the geometry from a Brep representing a plane
23 # Hypothesis and algorithms for the mesh generation are global
24 #
25 import os
26 import salome
27 import geompy
28 import smesh
29
30
31 # ---------------------------- GEOM --------------------------------------
32
33 # import a BRep
34 #before running this script, please be sure about
35 #the path the file fileName
36
37 filePath = os.environ["DATA_DIR"]
38 filePath = filePath + "/Shapes/Brep/"
39
40 filename = "flight_solid.brep"
41 filename = filePath + filename
42
43 shape = geompy.Import(filename, "BREP")
44 idShape = geompy.addToStudy(shape, "flight")
45
46 print "Analysis of the geometry flight :"
47 subShellList = geompy.SubShapeAll(shape, geompy.ShapeType["SHELL"])
48 subFaceList  = geompy.SubShapeAll(shape, geompy.ShapeType["FACE"])
49 subEdgeList  = geompy.SubShapeAll(shape, geompy.ShapeType["EDGE"])
50
51 print "number of Shells in flight : ", len(subShellList)
52 print "number of Faces  in flight : ", len(subFaceList)
53 print "number of Edges  in flight : ", len(subEdgeList)
54
55
56 ### ---------------------------- SMESH --------------------------------------
57
58 # ---- init a Mesh with the shell
59 shape_mesh = salome.IDToObject( idShape )
60
61 mesh = smesh.Mesh(shape_mesh, "MeshFlight")
62
63
64 # ---- set Hypothesis and Algorithm
65
66 print "-------------------------- LocalLength"
67
68 lengthOfSegments = 0.3
69
70 regular1D = mesh.Segment()
71 hypLength = regular1D.LocalLength(lengthOfSegments)
72 print hypLength.GetName()
73 print hypLength.GetId()
74 print hypLength.GetLength()
75 smesh.SetName(hypLength, "LocalLength_" + str(lengthOfSegments))
76
77 print "-------------------------- LengthFromEdges"
78
79 mefisto2D = mesh.Triangle()
80 hypLengthFromEdge = mefisto2D.LengthFromEdges()
81 print hypLengthFromEdge.GetName()
82 print hypLengthFromEdge.GetId()
83 smesh.SetName(hypLengthFromEdge,"LengthFromEdge")
84
85
86 salome.sg.updateObjBrowser(1)
87
88
89 print "-------------------------- compute the skin flight"
90 ret = mesh.Compute()
91 print ret
92 if ret != 0:
93     log = mesh.GetLog(0) # no erase trace
94     for linelog in log:
95         print linelog
96     print "Information about the Mesh_mechanic_tetra:"
97     print "Number of nodes      : ", mesh.NbNodes()
98     print "Number of edges      : ", mesh.NbEdges()
99     print "Number of faces      : ", mesh.NbFaces()
100     print "Number of triangles  : ", mesh.NbTriangles()
101     print "Number of volumes    : ", mesh.NbVolumes()
102 else:
103     print "probleme when computing the mesh"