Salome HOME
Fix bug 12796: Warning missed for the bad file 'test18.med'
[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 StdMeshers
30
31 smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
32
33 smeshgui = salome.ImportComponentGUI("SMESH")
34 smeshgui.Init(salome.myStudyId)
35
36
37 # ---------------------------- GEOM --------------------------------------
38
39 # import a BRep
40 #before running this script, please be sure about
41 #the path the file fileName
42
43 filePath = os.environ["DATA_DIR"]
44 filePath = filePath + "/Shapes/Brep/"
45
46 filename = "flight_solid.brep"
47 filename = filePath + filename
48
49 shape = geompy.Import(filename, "BREP")
50 idShape = geompy.addToStudy(shape, "flight")
51
52 print "Analysis of the geometry flight :"
53 subShellList = geompy.SubShapeAll(shape, geompy.ShapeType["SHELL"])
54 subFaceList  = geompy.SubShapeAll(shape, geompy.ShapeType["FACE"])
55 subEdgeList  = geompy.SubShapeAll(shape, geompy.ShapeType["EDGE"])
56
57 print "number of Shells in flight : ", len(subShellList)
58 print "number of Faces  in flight : ", len(subFaceList)
59 print "number of Edges  in flight : ", len(subEdgeList)
60
61
62 ### ---------------------------- SMESH --------------------------------------
63
64 print "-------------------------- create Hypothesis"
65
66 print "-------------------------- LocalLength"
67
68 lengthOfSegments = 0.3
69
70 hypLength = smesh.CreateHypothesis("LocalLength", "libStdMeshersEngine.so")
71 hypLength.SetLength(lengthOfSegments)
72
73 print hypLength.GetName()
74 print hypLength.GetId()
75 print hypLength.GetLength()
76
77 smeshgui.SetName(salome.ObjectToID(hypLength), "LocalLength_0.3")
78
79 print "-------------------------- LengthFromEdges"
80
81 hypLengthFromEdge = smesh.CreateHypothesis("LengthFromEdges", "libStdMeshersEngine.so")
82
83 print hypLengthFromEdge.GetName()
84 print hypLengthFromEdge.GetId()
85
86 smeshgui.SetName(salome.ObjectToID(hypLengthFromEdge), "LengthFromEdge")
87
88 print "-------------------------- create Algorithms"
89
90 print "-------------------------- Regular_1D"
91
92 regular1D = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
93
94 smeshgui.SetName(salome.ObjectToID(regular1D), "Wire Discretisation")
95
96 print "-------------------------- MEFISTO_2D"
97
98 mefisto2D = smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")
99
100 smeshgui.SetName(salome.ObjectToID(mefisto2D), "MEFISTO_2D")
101
102 # ---- init a Mesh with the shell
103 shape_mesh = salome.IDToObject( idShape )
104
105 mesh = smesh.CreateMesh(shape_mesh)
106 smeshgui.SetName(salome.ObjectToID(mesh), "MeshFlight")
107
108 # ---- add hypothesis to flight
109
110 print "-------------------------- add hypothesis to flight"
111
112 mesh.AddHypothesis(shape_mesh,regular1D)
113 mesh.AddHypothesis(shape_mesh,hypLength)
114 mesh.AddHypothesis(shape_mesh,mefisto2D)
115 mesh.AddHypothesis(shape_mesh,hypLengthFromEdge)
116
117 salome.sg.updateObjBrowser(1)
118
119
120 print "-------------------------- compute the skin flight"
121 ret = smesh.Compute(mesh,shape_mesh)
122 print ret
123 if ret != 0:
124     log = mesh.GetLog(0) # no erase trace
125     for linelog in log:
126         print linelog
127     print "Information about the Mesh_mechanic_tetra:"
128     print "Number of nodes      : ", mesh.NbNodes()
129     print "Number of edges      : ", mesh.NbEdges()
130     print "Number of faces      : ", mesh.NbFaces()
131     print "Number of triangles  : ", mesh.NbTriangles()
132     print "Number of volumes    : ", mesh.NbVolumes()
133 else:
134     print "probleme when computing the mesh"