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 # Tetrahedrization of the geometry union of 3 boxes aligned where the middle
22 # one has a race in common with the two others.
23 # Hypothesis and algorithms for the mesh generation are global
32 smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
34 smeshgui = salome.ImportComponentGUI("SMESH")
35 smeshgui.Init(salome.myStudyId);
37 # ---- define 3 boxes box1, box2 and box3
39 box1 = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
41 idbox1 = geompy.addToStudy(box1, "box1")
43 print "Analysis of the geometry box1 :"
44 subShellList = geompy.SubShapeAll(box1, geompy.ShapeType["SHELL"])
45 subFaceList = geompy.SubShapeAll(box1, geompy.ShapeType["FACE"])
46 subEdgeList = geompy.SubShapeAll(box1, geompy.ShapeType["EDGE"])
48 print "number of Shells in box1 : ", len(subShellList)
49 print "number of Faces in box1 : ", len(subFaceList)
50 print "number of Edges in box1 : ", len(subEdgeList)
52 box2 = geompy.MakeBox(100., 0., 0., 200., 200., 300.)
54 idbox2 = geompy.addToStudy(box2, "box2")
56 print "Analysis of the geometry box2 :"
57 subShellList = geompy.SubShapeAll(box2, geompy.ShapeType["SHELL"])
58 subFaceList = geompy.SubShapeAll(box2, geompy.ShapeType["FACE"])
59 subEdgeList = geompy.SubShapeAll(box2, geompy.ShapeType["EDGE"])
61 print "number of Shells in box2 : ", len(subShellList)
62 print "number of Faces in box2 : ", len(subFaceList)
63 print "number of Edges in box2 : ", len(subEdgeList)
65 box3 = geompy.MakeBox(0., 0., 300., 200., 200., 500.)
67 idbox3 = geompy.addToStudy(box3, "box3")
69 print "Analysis of the geometry box3 :"
70 subShellList = geompy.SubShapeAll(box3, geompy.ShapeType["SHELL"])
71 subFaceList = geompy.SubShapeAll(box3, geompy.ShapeType["FACE"])
72 subEdgeList = geompy.SubShapeAll(box3, geompy.ShapeType["EDGE"])
74 print "number of Shells in box3 : ", len(subShellList)
75 print "number of Faces in box3 : ", len(subFaceList)
76 print "number of Edges in box3 : ", len(subEdgeList)
78 shell = geompy.MakePartition([box1, box2, box3])
79 idshell = geompy.addToStudy(shell,"shell")
81 print "Analysis of the geometry shell (union of box1, box2 and box3) :"
82 subShellList = geompy.SubShapeAll(shell, geompy.ShapeType["SHELL"])
83 subFaceList = geompy.SubShapeAll(shell, geompy.ShapeType["FACE"])
84 subEdgeList = geompy.SubShapeAll(shell, geompy.ShapeType["EDGE"])
86 print "number of Shells in shell : ", len(subShellList)
87 print "number of Faces in shell : ", len(subFaceList)
88 print "number of Edges in shell : ", len(subEdgeList)
91 ### ---------------------------- SMESH --------------------------------------
93 # ---- create Hypothesis
95 print "-------------------------- create Hypothesis"
97 print "-------------------------- NumberOfSegments"
101 hypNbSeg = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
102 hypNbSeg.SetNumberOfSegments(numberOfSegments)
104 print hypNbSeg.GetName()
105 print hypNbSeg.GetId()
106 print hypNbSeg.GetNumberOfSegments()
108 smeshgui.SetName(salome.ObjectToID(hypNbSeg), "NumberOfSegments_10")
110 print "-------------------------- MaxElementArea"
114 hypArea = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
115 hypArea.SetMaxElementArea(maxElementArea)
117 print hypArea.GetName()
118 print hypArea.GetId()
119 print hypArea.GetMaxElementArea()
121 smeshgui.SetName(salome.ObjectToID(hypArea), "MaxElementArea_500")
123 print "-------------------------- MaxElementVolume"
125 maxElementVolume = 500
127 hypVolume = smesh.CreateHypothesis("MaxElementVolume", "libStdMeshersEngine.so")
128 hypVolume.SetMaxElementVolume(maxElementVolume)
130 print hypVolume.GetName()
131 print hypVolume.GetId()
132 print hypVolume.GetMaxElementVolume()
134 smeshgui.SetName(salome.ObjectToID(hypVolume), "MaxElementVolume_500")
136 # ---- create Algorithms
138 print "-------------------------- create Algorithms"
140 print "-------------------------- Regular_1D"
142 regular1D = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
143 smeshgui.SetName(salome.ObjectToID(regular1D), "Wire Discretisation")
145 print "-------------------------- MEFISTO_2D"
147 mefisto2D = smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")
148 smeshgui.SetName(salome.ObjectToID(mefisto2D), "MEFISTO_2D")
150 print "-------------------------- NETGEN_3D"
152 netgen3D = smesh.CreateHypothesis("NETGEN_3D", "libNETGENEngine.so")
153 smeshgui.SetName(salome.ObjectToID(netgen3D), "NETGEN_3D")
155 # ---- init a Mesh with the shell
157 mesh = smesh.CreateMesh(shell)
158 smeshgui.SetName(salome.ObjectToID(mesh), "MeshBox3")
160 # ---- add hypothesis to shell
162 print "-------------------------- add hypothesis to shell"
164 mesh.AddHypothesis(shell,regular1D)
165 mesh.AddHypothesis(shell,hypNbSeg)
167 mesh.AddHypothesis(shell,mefisto2D)
168 mesh.AddHypothesis(shell,hypArea)
170 mesh.AddHypothesis(shell,netgen3D)
171 mesh.AddHypothesis(shell,hypVolume)
173 salome.sg.updateObjBrowser(1)
175 print "-------------------------- compute shell"
176 ret = smesh.Compute(mesh,shell)
179 log = mesh.GetLog(0) # no erase trace
182 print "Information about the MeshBox3:"
183 print "Number of nodes : ", mesh.NbNodes()
184 print "Number of edges : ", mesh.NbEdges()
185 print "Number of faces : ", mesh.NbFaces()
186 print "Number of triangles : ", mesh.NbTriangles()
187 print "Number of volumes : ", mesh.NbVolumes()
188 print "Number of tetrahedrons: ", mesh.NbTetras()
190 print "probleme when computing the mesh"