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 2 boxes having a face in common
22 # 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);
36 # ---- define 2 boxes box1 and box2
38 box1 = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
40 idbox1 = geompy.addToStudy(box1, "box1")
42 print "Analysis of the geometry box1 :"
43 subShellList = geompy.SubShapeAll(box1, geompy.ShapeType["SHELL"])
44 subFaceList = geompy.SubShapeAll(box1, geompy.ShapeType["FACE"])
45 subEdgeList = geompy.SubShapeAll(box1, geompy.ShapeType["EDGE"])
47 print "number of Shells in box1 : ", len(subShellList)
48 print "number of Faces in box1 : ", len(subFaceList)
49 print "number of Edges in box1 : ", len(subEdgeList)
51 box2 = geompy.MakeBox(100., 0., 0., 200., 200., 300.)
53 idbox2 = geompy.addToStudy(box2, "box2")
55 print "Analysis of the geometry box2 :"
56 subShellList = geompy.SubShapeAll(box2, geompy.ShapeType["SHELL"])
57 subFaceList = geompy.SubShapeAll(box2, geompy.ShapeType["FACE"])
58 subEdgeList = geompy.SubShapeAll(box2, geompy.ShapeType["EDGE"])
60 print "number of Shells in box2 : ", len(subShellList)
61 print "number of Faces in box2 : ", len(subFaceList)
62 print "number of Edges in box2 : ", len(subEdgeList)
64 # append the tow boxes to make ine shel, referrencing only once
65 # the internal interface
67 shell = geompy.MakePartition([box1, box2])
68 idshell = geompy.addToStudy(shell, "shell")
70 print "Analysis of the geometry shell (union of box1 and box2) :"
71 subShellList = geompy.SubShapeAll(shell, geompy.ShapeType["SHELL"])
72 subFaceList = geompy.SubShapeAll(shell, geompy.ShapeType["FACE"])
73 subEdgeList = geompy.SubShapeAll(shell, geompy.ShapeType["EDGE"])
75 print "number of Shells in shell : ", len(subShellList)
76 print "number of Faces in shell : ", len(subFaceList)
77 print "number of Edges in shell : ", len(subEdgeList)
80 ### ---------------------------- SMESH --------------------------------------
82 # ---- create Hypothesis
84 print "-------------------------- create Hypothesis"
86 print "-------------------------- NumberOfSegments"
90 hypNbSeg = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
91 hypNbSeg.SetNumberOfSegments(numberOfSegments)
93 print hypNbSeg.GetName()
94 print hypNbSeg.GetId()
95 print hypNbSeg.GetNumberOfSegments()
97 smeshgui.SetName(salome.ObjectToID(hypNbSeg), "NumberOfSegments_10")
99 print "-------------------------- MaxElementArea"
103 hypArea = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
104 hypArea.SetMaxElementArea(maxElementArea)
106 print hypArea.GetName()
107 print hypArea.GetId()
108 print hypArea.GetMaxElementArea()
110 smeshgui.SetName(salome.ObjectToID(hypArea), "MaxElementArea_500")
112 print "-------------------------- MaxElementVolume"
114 maxElementVolume = 500
116 hypVolume = smesh.CreateHypothesis("MaxElementVolume", "libStdMeshersEngine.so")
117 hypVolume.SetMaxElementVolume(maxElementVolume)
119 print hypVolume.GetName()
120 print hypVolume.GetId()
121 print hypVolume.GetMaxElementVolume()
123 smeshgui.SetName(salome.ObjectToID(hypVolume), "MaxElementVolume_500")
125 # ---- create Algorithms
127 print "-------------------------- create Algorithms"
129 print "-------------------------- Regular_1D"
131 regular1D = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
132 smeshgui.SetName(salome.ObjectToID(regular1D), "Wire Discretisation")
134 print "-------------------------- MEFISTO_2D"
136 mefisto2D = smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")
137 smeshgui.SetName(salome.ObjectToID(mefisto2D), "MEFISTO_2D")
139 print "-------------------------- NETGEN_3D"
141 netgen3D = smesh.CreateHypothesis("NETGEN_3D", "libNETGENEngine.so")
142 smeshgui.SetName(salome.ObjectToID(netgen3D), "NETGEN_3D")
144 # ---- init a Mesh with the shell
146 mesh = smesh.CreateMesh(shell)
147 smeshgui.SetName(salome.ObjectToID(mesh), "MeshBox2")
149 # ---- add hypothesis to shell
151 print "-------------------------- add hypothesis to shell"
153 mesh.AddHypothesis(shell,regular1D)
154 mesh.AddHypothesis(shell,hypNbSeg)
156 mesh.AddHypothesis(shell,mefisto2D)
157 mesh.AddHypothesis(shell,hypArea)
159 mesh.AddHypothesis(shell,netgen3D)
160 mesh.AddHypothesis(shell,hypVolume)
162 salome.sg.updateObjBrowser(1)
164 print "-------------------------- compute shell"
165 ret = smesh.Compute(mesh,shell)
168 log = mesh.GetLog(0) # no erase trace
171 print "Information about the MeshBox2:"
172 print "Number of nodes : ", mesh.NbNodes()
173 print "Number of edges : ", mesh.NbEdges()
174 print "Number of faces : ", mesh.NbFaces()
175 print "Number of triangles : ", mesh.NbTriangles()
176 print "Number of volumes : ", mesh.NbVolumes()
177 print "Number of tetrahedrons: ", mesh.NbTetras()
179 print "probleme when computing the mesh"