1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
4 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
5 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
7 # This library is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU Lesser General Public
9 # License as published by the Free Software Foundation; either
10 # version 2.1 of the License, or (at your option) any later version.
12 # This library is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # Lesser General Public License for more details.
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with this library; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 # Triangulation of the skin of the geometry from a Brep representing a plane
25 # Hypothesis and algorithms for the mesh generation are global
31 from salome.geom import geomBuilder
32 geompy = geomBuilder.New(salome.myStudy)
34 import SMESH, SALOMEDS
35 from salome.smesh import smeshBuilder
36 smesh = smeshBuilder.New(salome.myStudy)
39 # ---------------------------- GEOM --------------------------------------
42 #before running this script, please be sure about
43 #the path the file fileName
45 filePath = os.environ["DATA_DIR"]
46 filePath = filePath + "/Shapes/Brep/"
48 filename = "flight_solid.brep"
49 filename = filePath + filename
51 shape = geompy.Import(filename, "BREP")
52 idShape = geompy.addToStudy(shape, "flight")
54 print "Analysis of the geometry flight :"
55 subShellList = geompy.SubShapeAll(shape, geompy.ShapeType["SHELL"])
56 subFaceList = geompy.SubShapeAll(shape, geompy.ShapeType["FACE"])
57 subEdgeList = geompy.SubShapeAll(shape, geompy.ShapeType["EDGE"])
59 print "number of Shells in flight : ", len(subShellList)
60 print "number of Faces in flight : ", len(subFaceList)
61 print "number of Edges in flight : ", len(subEdgeList)
64 ### ---------------------------- SMESH --------------------------------------
65 smesh.SetCurrentStudy(salome.myStudy)
67 # ---- init a Mesh with the shell
68 shape_mesh = salome.IDToObject( idShape )
70 mesh = smesh.Mesh(shape_mesh, "MeshFlight")
73 # ---- set Hypothesis and Algorithm
75 print "-------------------------- LocalLength"
77 lengthOfSegments = 0.3
79 regular1D = mesh.Segment()
80 hypLength = regular1D.LocalLength(lengthOfSegments)
81 print hypLength.GetName()
82 print hypLength.GetId()
83 print hypLength.GetLength()
84 smesh.SetName(hypLength, "LocalLength_" + str(lengthOfSegments))
86 print "-------------------------- LengthFromEdges"
88 mefisto2D = mesh.Triangle()
89 hypLengthFromEdge = mefisto2D.LengthFromEdges()
90 print hypLengthFromEdge.GetName()
91 print hypLengthFromEdge.GetId()
92 smesh.SetName(hypLengthFromEdge,"LengthFromEdge")
95 salome.sg.updateObjBrowser(1)
98 print "-------------------------- compute the skin flight"
102 log = mesh.GetLog(0) # no erase trace
105 print "Information about the Mesh_mechanic_tetra:"
106 print "Number of nodes : ", mesh.NbNodes()
107 print "Number of edges : ", mesh.NbEdges()
108 print "Number of faces : ", mesh.NbFaces()
109 print "Number of triangles : ", mesh.NbTriangles()
110 print "Number of volumes : ", mesh.NbVolumes()
112 print "probleme when computing the mesh"