1 # Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
18 # See http://www.salome-platform.org/
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
31 smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
33 smeshgui = salome.ImportComponentGUI("SMESH")
34 smeshgui.Init(salome.myStudyId)
37 # ---------------------------- GEOM --------------------------------------
40 #before running this script, please be sure about
41 #the path the file fileName
43 filePath = os.environ["DATA_DIR"]
44 filePath = filePath + "/Shapes/Brep/"
46 filename = "flight_solid.brep"
47 filename = filePath + filename
49 shape = geompy.Import(filename, "BREP")
50 idShape = geompy.addToStudy(shape, "flight")
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"])
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)
62 ### ---------------------------- SMESH --------------------------------------
64 print "-------------------------- create Hypothesis"
66 print "-------------------------- LocalLength"
68 lengthOfSegments = 0.3
70 hypLength = smesh.CreateHypothesis("LocalLength", "libStdMeshersEngine.so")
71 hypLength.SetLength(lengthOfSegments)
73 print hypLength.GetName()
74 print hypLength.GetId()
75 print hypLength.GetLength()
77 smeshgui.SetName(salome.ObjectToID(hypLength), "LocalLength_0.3")
79 print "-------------------------- LengthFromEdges"
81 hypLengthFromEdge = smesh.CreateHypothesis("LengthFromEdges", "libStdMeshersEngine.so")
83 print hypLengthFromEdge.GetName()
84 print hypLengthFromEdge.GetId()
86 smeshgui.SetName(salome.ObjectToID(hypLengthFromEdge), "LengthFromEdge")
88 print "-------------------------- create Algorithms"
90 print "-------------------------- Regular_1D"
92 regular1D = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
94 smeshgui.SetName(salome.ObjectToID(regular1D), "Wire Discretisation")
96 print "-------------------------- MEFISTO_2D"
98 mefisto2D = smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")
100 smeshgui.SetName(salome.ObjectToID(mefisto2D), "MEFISTO_2D")
102 # ---- init a Mesh with the shell
103 shape_mesh = salome.IDToObject( idShape )
105 mesh = smesh.CreateMesh(shape_mesh)
106 smeshgui.SetName(salome.ObjectToID(mesh), "MeshFlight")
108 # ---- add hypothesis to flight
110 print "-------------------------- add hypothesis to flight"
112 mesh.AddHypothesis(shape_mesh,regular1D)
113 mesh.AddHypothesis(shape_mesh,hypLength)
114 mesh.AddHypothesis(shape_mesh,mefisto2D)
115 mesh.AddHypothesis(shape_mesh,hypLengthFromEdge)
117 salome.sg.updateObjBrowser(1)
120 print "-------------------------- compute the skin flight"
121 ret = smesh.Compute(mesh,shape_mesh)
124 log = mesh.GetLog(0) # no erase trace
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()
134 print "probleme when computing the mesh"