Salome HOME
correct previous integration (Porting to Python 2.6)
[modules/smesh.git] / src / SMESH_SWIG / SMESH_fixation_tetra.py
1 #  -*- coding: iso-8859-1 -*-
2 #  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
3 #
4 #  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
5 #  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 #
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.
11 #
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.
16 #
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
20 #
21 #  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #
23 # Tetrahedrization of the geometry generated by the Python script
24 # SMESH_fixation.py
25 # Hypothesis and algorithms for the mesh generation are global
26 #
27 import SMESH_fixation
28 import smesh
29
30 compshell = SMESH_fixation.compshell
31 idcomp = SMESH_fixation.idcomp
32 geompy = SMESH_fixation.geompy
33 salome = SMESH_fixation.salome
34
35 print "Analysis of the geometry to be meshed :"
36 subShellList = geompy.SubShapeAll(compshell, geompy.ShapeType["SHELL"])
37 subFaceList  = geompy.SubShapeAll(compshell, geompy.ShapeType["FACE"])
38 subEdgeList  = geompy.SubShapeAll(compshell, geompy.ShapeType["EDGE"])
39
40 print "number of Shells in compshell : ", len(subShellList)
41 print "number of Faces  in compshell : ", len(subFaceList)
42 print "number of Edges  in compshell : ", len(subEdgeList)
43
44 status = geompy.CheckShape(compshell)
45 print " check status ", status
46
47 ### ---------------------------- SMESH --------------------------------------
48
49 # ---- init a Mesh with the compshell
50
51 mesh = smesh.Mesh(compshell, "MeshcompShell")
52
53
54 # ---- set Hypothesis and Algorithm
55
56 print "-------------------------- NumberOfSegments"
57
58 numberOfSegments = 5
59
60 regular1D = mesh.Segment()
61 regular1D.SetName("Wire Discretisation")
62 hypNbSeg = regular1D.NumberOfSegments(numberOfSegments)
63 print hypNbSeg.GetName()
64 print hypNbSeg.GetId()
65 print hypNbSeg.GetNumberOfSegments()
66 smesh.SetName(hypNbSeg, "NumberOfSegments_" + str(numberOfSegments))
67
68 ## print "-------------------------- MaxElementArea"
69
70 ## maxElementArea = 80
71
72 ## mefisto2D = mesh.Triangle()
73 ## mefisto2D.SetName("MEFISTO_2D")
74 ## hypArea = mefisto2D.MaxElementArea(maxElementArea)
75 ## print hypArea.GetName()
76 ## print hypArea.GetId()
77 ## print hypArea.GetMaxElementArea()
78 ## smesh.SetName(hypArea, "MaxElementArea_" + str(maxElementArea))
79
80 print "-------------------------- LengthFromEdges"
81
82 mefisto2D = mesh.Triangle()
83 mefisto2D.SetName("MEFISTO_2D")
84 hypLengthFromEdges = mefisto2D.LengthFromEdges()
85 print hypLengthFromEdges.GetName()
86 print hypLengthFromEdges.GetId()
87 smesh.SetName(hypLengthFromEdges, "LengthFromEdges")
88
89
90 print "-------------------------- MaxElementVolume"
91
92 maxElementVolume = 1000
93
94 netgen3D = mesh.Tetrahedron(smesh.NETGEN)
95 netgen3D.SetName("NETGEN_3D")
96 hypVolume = netgen3D.MaxElementVolume(maxElementVolume)
97 print hypVolume.GetName()
98 print hypVolume.GetId()
99 print hypVolume.GetMaxElementVolume()
100 smesh.SetName(hypVolume, "MaxElementVolume_" + str(maxElementVolume))
101
102
103 salome.sg.updateObjBrowser(1)
104
105 print "-------------------------- compute compshell"
106 ret = mesh.Compute(mesh)
107 print ret
108 if ret != 0:
109     log = mesh.GetLog(0) # no erase trace
110     for linelog in log:
111         print linelog
112     print "Information about the MeshcompShel:"
113     print "Number of nodes        : ", mesh.NbNodes()
114     print "Number of edges        : ", mesh.NbEdges()
115     print "Number of faces        : ", mesh.NbFaces()
116     print "Number of triangles    : ", mesh.NbTriangles()
117     print "Number of volumes      : ", mesh.NbVolumes()
118     print "Number of tetrahedrons : ", mesh.NbTetras()
119     
120 else:
121     print "problem when computing the mesh"