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
16 myBuilder = geompy.myBuilder
25 #before running this script, please be sure about
26 #the path the file fileName
28 filePath=os.environ["SMESH_ROOT_DIR"]
29 filePath=filePath+"/share/salome/resources/"
31 filename = "flight_solid.brep"
32 filename = filePath + filename
34 shape = geompy.ImportBREP(filename)
35 idShape = geompy.addToStudy(shape,"flight")
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)
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)
48 smeshgui = salome.ImportComponentGUI("SMESH")
49 smeshgui.Init(salome.myStudyId)
53 # ---- create Hypothesis
55 print "-------------------------- create Hypothesis"
57 print "-------------------------- LocalLength"
59 lengthOfSegments = 0.3
61 hypothesis=gen.CreateHypothesis("LocalLength")
62 hypLength=hypothesis._narrow(SMESH.SMESH_LocalLength)
63 hypLength.SetLength(lengthOfSegments)
64 hypLengthID = hypLength.GetId()
65 print hypLength.GetName()
67 print hypLength.GetLength()
69 idlen = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypLength) )
70 smeshgui.SetName(idlen, "LocalLength")
72 print "-------------------------- LengthFromEdges"
74 hypothesis=gen.CreateHypothesis("LengthFromEdges")
75 hypLengthFromEdge=hypothesis._narrow(SMESH.SMESH_LengthFromEdges)
76 hypLengthFromEdgeID = hypLengthFromEdge.GetId()
77 print hypLengthFromEdge.GetName()
78 print hypLengthFromEdgeID
80 idlenfromedge = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypLengthFromEdge) )
81 smeshgui.SetName(idlenfromedge, "LengthFromEdge")
83 # ---- create Algorithms
85 print "-------------------------- create Algorithms"
87 print "-------------------------- Regular_1D"
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")
94 print "-------------------------- MEFISTO_2D"
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")
101 # ---- init a Mesh with the shell
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)
108 # ---- add hypothesis to flight
110 print "-------------------------- add hypothesis to flight"
112 ret=mesh.AddHypothesis(shape,regular1D)
114 ret=mesh.AddHypothesis(shape,hypLength)
116 ret=mesh.AddHypothesis(shape,mefisto2D)
118 ret=mesh.AddHypothesis(shape,hypLengthFromEdge)
121 smeshgui.SetAlgorithms( idmesh, regularID)
122 smeshgui.SetHypothesis( idmesh, idlen )
123 smeshgui.SetAlgorithms( idmesh, mefistoID )
124 smeshgui.SetHypothesis( idmesh, idlenfromedge)
126 sg.updateObjBrowser(1)
129 print "-------------------------- compute the skin flight"
130 ret=gen.Compute(mesh,idShape)
133 log=mesh.GetLog(0) # no erase trace
137 print "probleme when computing the mesh"
139 sg.updateObjBrowser(1)