Salome HOME
removing the call to the tetrahedron generator NETGEN, because I did not yet
[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 salome
8 from salome import sg
9
10 import geompy
11
12 import SMESH
13 import smeshpy
14
15 geom = geompy.geom
16 myBuilder = geompy.myBuilder
17
18 ShapeTypeShell     = 3
19 ShapeTypeFace      = 4
20 ShapeTypeEdge      = 6
21
22 import os
23
24 # import a BRep
25 #before running this script, please be sure about
26 #the path the file fileName
27
28 filePath=os.environ["SMESH_ROOT_DIR"]
29 filePath=filePath+"/share/salome/resources/"
30
31 filename = "flight_solid.brep"
32 filename = filePath + filename
33
34 shape = geompy.ImportBREP(filename)
35 idShape = geompy.addToStudy(shape,"flight")
36
37 print "Analysis of the geometry flight :"
38 subShellList=geompy.SubShapeAll(shape,ShapeTypeShell)
39 subFaceList=geompy.SubShapeAll(shape,ShapeTypeFace)
40 subEdgeList=geompy.SubShapeAll(shape,ShapeTypeEdge)
41
42 print "number of Shells in flight : ",len(subShellList)
43 print "number of Faces in flight : ",len(subFaceList)
44 print "number of Edges in flight : ",len(subEdgeList)
45
46 # ---- launch SMESH
47
48 smeshgui = salome.ImportComponentGUI("SMESH")
49 smeshgui.Init(salome.myStudyId)
50
51 gen=smeshpy.smeshpy()
52
53 # ---- create Hypothesis
54
55 print "-------------------------- create Hypothesis"
56
57 print "-------------------------- LocalLength"
58
59 lengthOfSegments = 0.3
60
61 hypothesis=gen.CreateHypothesis("LocalLength")
62 hypLength=hypothesis._narrow(SMESH.SMESH_LocalLength)
63 hypLength.SetLength(lengthOfSegments)
64 hypLengthID = hypLength.GetId()
65 print hypLength.GetName()
66 print hypLengthID
67 print hypLength.GetLength()
68
69 idlen = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypLength) )
70 smeshgui.SetName(idlen, "LocalLength")
71
72 print "-------------------------- LengthFromEdges"
73
74 hypothesis=gen.CreateHypothesis("LengthFromEdges")
75 hypLengthFromEdge=hypothesis._narrow(SMESH.SMESH_LengthFromEdges)
76 hypLengthFromEdgeID = hypLengthFromEdge.GetId()
77 print hypLengthFromEdge.GetName()
78 print hypLengthFromEdgeID
79
80 idlenfromedge = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypLengthFromEdge) )
81 smeshgui.SetName(idlenfromedge, "LengthFromEdge")
82
83 # ---- create Algorithms
84
85 print "-------------------------- create Algorithms"
86
87 print "-------------------------- Regular_1D"
88
89 hypothesis=gen.CreateHypothesis("Regular_1D")
90 regular1D = hypothesis._narrow(SMESH.SMESH_Regular_1D)
91 regularID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(regular1D) )
92 smeshgui.SetName(regularID, "Wire Discretisation")
93
94 print "-------------------------- MEFISTO_2D"
95
96 hypothesis=gen.CreateHypothesis("MEFISTO_2D")
97 mefisto2D = hypothesis._narrow(SMESH.SMESH_MEFISTO_2D)
98 mefistoID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(mefisto2D) )
99 smeshgui.SetName(mefistoID, "MEFISTO_2D")
100
101 # ---- init a Mesh with the shell
102
103 mesh=gen.Init(idShape)
104 idmesh = smeshgui.AddNewMesh( salome.orb.object_to_string(mesh) )
105 smeshgui.SetName(idmesh, "MeshFlight")
106 smeshgui.SetShape(idShape, idmesh)
107
108 # ---- add hypothesis to flight
109
110 print "-------------------------- add hypothesis to flight"
111
112 ret=mesh.AddHypothesis(shape,regular1D)
113 print ret
114 ret=mesh.AddHypothesis(shape,hypLength)
115 print ret
116 ret=mesh.AddHypothesis(shape,mefisto2D)
117 print ret
118 ret=mesh.AddHypothesis(shape,hypLengthFromEdge)
119 print ret
120
121 smeshgui.SetAlgorithms( idmesh, regularID)
122 smeshgui.SetHypothesis( idmesh, idlen )
123 smeshgui.SetAlgorithms( idmesh, mefistoID )
124 smeshgui.SetHypothesis( idmesh, idlenfromedge)
125
126 sg.updateObjBrowser(1)
127
128
129 print "-------------------------- compute the skin flight"
130 ret=gen.Compute(mesh,idShape)
131 print ret
132 if ret != 0:
133     log=mesh.GetLog(0) # no erase trace
134     for linelog in log:
135         print linelog
136 else:
137     print "probleme when computing the mesh"
138
139 sg.updateObjBrowser(1)