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