Salome HOME
Bug 0020072: GHS3DPRLPLUGIN update. Integrating the attached patch.
[modules/smesh.git] / src / SMESH_SWIG / SMESH_box2_tetra.py
1 #  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 #
3 #  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 #  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 #
6 #  This library is free software; you can redistribute it and/or
7 #  modify it under the terms of the GNU Lesser General Public
8 #  License as published by the Free Software Foundation; either
9 #  version 2.1 of the License.
10 #
11 #  This library is distributed in the hope that it will be useful,
12 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 #  Lesser General Public License for more details.
15 #
16 #  You should have received a copy of the GNU Lesser General Public
17 #  License along with this library; if not, write to the Free Software
18 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 #
20 #  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 #
22 # Tetrahedrization of the geometry union of 2 boxes having a face in common
23 # Hypothesis and algorithms for the mesh generation are global
24 #
25 import salome
26 import geompy
27 import smesh
28
29
30 # ---- define 2 boxes box1 and box2
31
32 box1 = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
33
34 idbox1 = geompy.addToStudy(box1, "box1")
35
36 print "Analysis of the geometry box1 :"
37 subShellList = geompy.SubShapeAll(box1, geompy.ShapeType["SHELL"])
38 subFaceList  = geompy.SubShapeAll(box1, geompy.ShapeType["FACE"])
39 subEdgeList  = geompy.SubShapeAll(box1, geompy.ShapeType["EDGE"])
40
41 print "number of Shells in box1 : ", len(subShellList)
42 print "number of Faces  in box1 : ", len(subFaceList)
43 print "number of Edges  in box1 : ", len(subEdgeList)
44
45 box2 = geompy.MakeBox(100., 0., 0., 200., 200., 300.)
46
47 idbox2 = geompy.addToStudy(box2, "box2")
48
49 print "Analysis of the geometry box2 :"
50 subShellList = geompy.SubShapeAll(box2, geompy.ShapeType["SHELL"])
51 subFaceList  = geompy.SubShapeAll(box2, geompy.ShapeType["FACE"])
52 subEdgeList  = geompy.SubShapeAll(box2, geompy.ShapeType["EDGE"])
53
54 print "number of Shells in box2 : ", len(subShellList)
55 print "number of Faces  in box2 : ", len(subFaceList)
56 print "number of Edges  in box2 : ", len(subEdgeList)
57
58 # append the tow boxes to make ine shel, referrencing only once
59 # the internal interface
60
61 shell = geompy.MakePartition([box1, box2])
62 idshell = geompy.addToStudy(shell, "shell")
63
64 print "Analysis of the geometry shell (union of box1 and box2) :"
65 subShellList = geompy.SubShapeAll(shell, geompy.ShapeType["SHELL"])
66 subFaceList  = geompy.SubShapeAll(shell, geompy.ShapeType["FACE"])
67 subEdgeList  = geompy.SubShapeAll(shell, geompy.ShapeType["EDGE"])
68
69 print "number of Shells in shell : ", len(subShellList)
70 print "number of Faces  in shell : ", len(subFaceList)
71 print "number of Edges  in shell : ", len(subEdgeList)
72
73
74 ### ---------------------------- SMESH --------------------------------------
75
76 # ---- init a Mesh with the shell
77
78 mesh = smesh.Mesh(shell, "MeshBox2")
79
80
81 # ---- set Hypothesis and Algorithm
82
83 print "-------------------------- NumberOfSegments"
84
85 numberOfSegments = 10
86
87 regular1D = mesh.Segment()
88 hypNbSeg = regular1D.NumberOfSegments(numberOfSegments)
89 print hypNbSeg.GetName()
90 print hypNbSeg.GetId()
91 print hypNbSeg.GetNumberOfSegments()
92 smesh.SetName(hypNbSeg, "NumberOfSegments_" + str(numberOfSegments))
93
94 print "-------------------------- MaxElementArea"
95
96 maxElementArea = 500
97
98 mefisto2D = mesh.Triangle()
99 hypArea = mefisto2D.MaxElementArea(maxElementArea)
100 print hypArea.GetName()
101 print hypArea.GetId()
102 print hypArea.GetMaxElementArea()
103 smesh.SetName(hypArea, "MaxElementArea_" + str(maxElementArea))
104
105 print "-------------------------- MaxElementVolume"
106
107 maxElementVolume = 500
108
109 netgen3D = mesh.Tetrahedron(smesh.NETGEN)
110 hypVolume = netgen3D.MaxElementVolume(maxElementVolume)
111 print hypVolume.GetName()
112 print hypVolume.GetId()
113 print hypVolume.GetMaxElementVolume()
114 smesh.SetName(hypVolume, "MaxElementVolume_" + str(maxElementVolume))
115
116
117 salome.sg.updateObjBrowser(1)
118
119 print "-------------------------- compute shell"
120 ret = mesh.Compute()
121 print ret
122 if ret != 0:
123     log = mesh.GetLog(0) # no erase trace
124     for linelog in log:
125         print linelog
126     print "Information about the MeshBox2:"
127     print "Number of nodes       : ", mesh.NbNodes()
128     print "Number of edges       : ", mesh.NbEdges()
129     print "Number of faces       : ", mesh.NbFaces()
130     print "Number of triangles   : ", mesh.NbTriangles()
131     print "Number of volumes     : ", mesh.NbVolumes()
132     print "Number of tetrahedrons: ", mesh.NbTetras()
133 else:
134     print "probleme when computing the mesh"