Salome HOME
Fix for problem: SIGSEGV appears if to select group after opening "Edit Group" dialog...
[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 import StdMeshers
11
12 smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
13
14 smeshgui = salome.ImportComponentGUI("SMESH")
15 smeshgui.Init(salome.myStudyId)
16
17
18 # ---------------------------- GEOM --------------------------------------
19
20 # import a BRep
21 #before running this script, please be sure about
22 #the path the file fileName
23
24 filePath = os.environ["SMESH_ROOT_DIR"]
25 filePath = filePath + "/share/salome/resources/"
26
27 filename = "flight_solid.brep"
28 filename = filePath + filename
29
30 shape = geompy.Import(filename, "BREP")
31 idShape = geompy.addToStudy(shape, "flight")
32
33 print "Analysis of the geometry flight :"
34 subShellList = geompy.SubShapeAll(shape, geompy.ShapeType["SHELL"])
35 subFaceList  = geompy.SubShapeAll(shape, geompy.ShapeType["FACE"])
36 subEdgeList  = geompy.SubShapeAll(shape, geompy.ShapeType["EDGE"])
37
38 print "number of Shells in flight : ", len(subShellList)
39 print "number of Faces  in flight : ", len(subFaceList)
40 print "number of Edges  in flight : ", len(subEdgeList)
41
42
43 ### ---------------------------- SMESH --------------------------------------
44
45 print "-------------------------- create Hypothesis"
46
47 print "-------------------------- LocalLength"
48
49 lengthOfSegments = 0.3
50
51 hypLength = smesh.CreateHypothesis("LocalLength", "libStdMeshersEngine.so")
52 hypLength.SetLength(lengthOfSegments)
53
54 print hypLength.GetName()
55 print hypLength.GetId()
56 print hypLength.GetLength()
57
58 smeshgui.SetName(salome.ObjectToID(hypLength), "LocalLength_0.3")
59
60 print "-------------------------- LengthFromEdges"
61
62 hypLengthFromEdge = smesh.CreateHypothesis("LengthFromEdges", "libStdMeshersEngine.so")
63
64 print hypLengthFromEdge.GetName()
65 print hypLengthFromEdge.GetId()
66
67 smeshgui.SetName(salome.ObjectToID(hypLengthFromEdge), "LengthFromEdge")
68
69 print "-------------------------- create Algorithms"
70
71 print "-------------------------- Regular_1D"
72
73 regular1D = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
74
75 smeshgui.SetName(salome.ObjectToID(regular1D), "Wire Discretisation")
76
77 print "-------------------------- MEFISTO_2D"
78
79 mefisto2D = smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")
80
81 smeshgui.SetName(salome.ObjectToID(mefisto2D), "MEFISTO_2D")
82
83 # ---- init a Mesh with the shell
84 shape_mesh = salome.IDToObject( idShape )
85
86 mesh = smesh.CreateMesh(shape_mesh)
87 smeshgui.SetName(salome.ObjectToID(mesh), "MeshFlight")
88
89 # ---- add hypothesis to flight
90
91 print "-------------------------- add hypothesis to flight"
92
93 mesh.AddHypothesis(shape_mesh,regular1D)
94 mesh.AddHypothesis(shape_mesh,hypLength)
95 mesh.AddHypothesis(shape_mesh,mefisto2D)
96 mesh.AddHypothesis(shape_mesh,hypLengthFromEdge)
97
98 salome.sg.updateObjBrowser(1)
99
100
101 print "-------------------------- compute the skin flight"
102 ret = smesh.Compute(mesh,shape_mesh)
103 print ret
104 if ret != 0:
105     log = mesh.GetLog(0) # no erase trace
106     for linelog in log:
107         print linelog
108     print "Information about the Mesh_mechanic_tetra:"
109     print "Number of nodes      : ", mesh.NbNodes()
110     print "Number of edges      : ", mesh.NbEdges()
111     print "Number of faces      : ", mesh.NbFaces()
112     print "Number of triangles  : ", mesh.NbTriangles()
113     print "Number of volumes    : ", mesh.NbVolumes()
114 else:
115     print "probleme when computing the mesh"