Salome HOME
DCQ : Merge with Ecole_Ete_a6.
[modules/smesh.git] / src / SMESH_SWIG / SMESH_flight_skin.py
1 #
2 # Triangulation of the skin of the geometry from a Brep representing a plane
3 # This geometry is from EADS
4 # Hypothesis and algorithms for the mesh generation are global
5 #
6
7 import os
8 import salome
9 import geompy
10
11 import StdMeshers
12
13 geom  = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM")
14 smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
15
16 smeshgui = salome.ImportComponentGUI("SMESH")
17 smeshgui.Init(salome.myStudyId);
18
19
20 # ---------------------------- GEOM --------------------------------------
21
22 ShapeTypeShell     = 3
23 ShapeTypeFace      = 4
24 ShapeTypeEdge      = 6
25
26 # import a BRep
27 #before running this script, please be sure about
28 #the path the file fileName
29
30 filePath=os.environ["SMESH_ROOT_DIR"]
31 filePath=filePath+"/share/salome/resources/"
32
33 filename = "flight_solid.brep"
34 filename = filePath + filename
35
36 shape = geompy.ImportBREP(filename)
37 idShape = geompy.addToStudy(shape,"flight")
38
39 print "Analysis of the geometry flight :"
40 subShellList=geompy.SubShapeAll(shape,ShapeTypeShell)
41 subFaceList=geompy.SubShapeAll(shape,ShapeTypeFace)
42 subEdgeList=geompy.SubShapeAll(shape,ShapeTypeEdge)
43
44 print "number of Shells in flight : ",len(subShellList)
45 print "number of Faces in flight : ",len(subFaceList)
46 print "number of Edges in flight : ",len(subEdgeList)
47
48
49 ### ---------------------------- SMESH --------------------------------------
50
51 # ---- create Hypothesis
52
53 print "-------------------------- create Hypothesis"
54
55 print "-------------------------- LocalLength"
56
57 lengthOfSegments = 0.3
58
59 hypLength=smesh.CreateHypothesis("LocalLength", "libStdMeshersEngine.so")
60 hypLength.SetLength(lengthOfSegments)
61
62 print hypLength.GetName()
63 print  hypLength.GetId()
64 print hypLength.GetLength()
65
66 smeshgui.SetName(salome.ObjectToID(hypLength), "LocalLength_0.3")
67
68 print "-------------------------- LengthFromEdges"
69
70 hypLengthFromEdge=smesh.CreateHypothesis("LengthFromEdges", "libStdMeshersEngine.so")
71
72 print hypLengthFromEdge.GetName()
73 print hypLengthFromEdge.GetId()
74
75 smeshgui.SetName(salome.ObjectToID(hypLengthFromEdge), "LengthFromEdge")
76
77 # ---- create Algorithms
78
79 print "-------------------------- create Algorithms"
80
81 print "-------------------------- Regular_1D"
82
83 regular1D=smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
84
85 smeshgui.SetName(salome.ObjectToID(regular1D), "Wire Discretisation")
86
87 print "-------------------------- MEFISTO_2D"
88
89 mefisto2D=smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")
90
91 smeshgui.SetName(salome.ObjectToID(mefisto2D), "MEFISTO_2D")
92
93 # ---- init a Mesh with the shell
94 shape_mesh = salome.IDToObject( idShape )
95
96 mesh=smesh.CreateMesh(shape_mesh)
97 smeshgui.SetName(salome.ObjectToID(mesh), "MeshFlight")
98
99 # ---- add hypothesis to flight
100
101 print "-------------------------- add hypothesis to flight"
102
103 mesh.AddHypothesis(shape_mesh,regular1D)
104 mesh.AddHypothesis(shape_mesh,hypLength)
105 mesh.AddHypothesis(shape_mesh,mefisto2D)
106 mesh.AddHypothesis(shape_mesh,hypLengthFromEdge)
107
108 salome.sg.updateObjBrowser(1)
109
110
111 print "-------------------------- compute the skin flight"
112 ret=smesh.Compute(mesh,shape_mesh)
113 print ret
114 if ret != 0:
115     log=mesh.GetLog(0) # no erase trace
116     for linelog in log:
117         print linelog
118     print "Information about the Mesh_mechanic_tetra:"
119     print "Number of nodes      : ", mesh.NbNodes()
120     print "Number of edges      : ", mesh.NbEdges()
121     print "Number of faces      : ", mesh.NbFaces()
122     print "Number of triangles  : ", mesh.NbTriangles()
123     print "Number of volumes    : ", mesh.NbVolumes()
124 else:
125     print "probleme when computing the mesh"