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