2 # Tetrahedrization of the geometry union of 3 boxes aligned where the middle
3 # one has a race in common with the two others.
4 # Hypothesis and algorithms for the mesh generation are global
13 geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM")
14 smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
16 smeshgui = salome.ImportComponentGUI("SMESH")
17 smeshgui.Init(salome.myStudyId);
23 # ---- define 3 boxes box1, box2 and box3
25 box1 = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
27 idbox1 = geompy.addToStudy(box1,"box1")
29 print "Analysis of the geometry box1 :"
30 subShellList=geompy.SubShapeAll(box1,ShapeTypeShell)
31 subFaceList=geompy.SubShapeAll(box1,ShapeTypeFace)
32 subEdgeList=geompy.SubShapeAll(box1,ShapeTypeEdge)
34 print "number of Shells in box1 : ",len(subShellList)
35 print "number of Faces in box1 : ",len(subFaceList)
36 print "number of Edges in box1 : ",len(subEdgeList)
38 box2 = geompy.MakeBox(100., 0., 0., 200., 200., 300.)
40 idbox2 = geompy.addToStudy(box2,"box2")
42 print "Analysis of the geometry box2 :"
43 subShellList=geompy.SubShapeAll(box2,ShapeTypeShell)
44 subFaceList=geompy.SubShapeAll(box2,ShapeTypeFace)
45 subEdgeList=geompy.SubShapeAll(box2,ShapeTypeEdge)
47 print "number of Shells in box2 : ",len(subShellList)
48 print "number of Faces in box2 : ",len(subFaceList)
49 print "number of Edges in box2 : ",len(subEdgeList)
51 box3 = geompy.MakeBox(0., 0., 300., 200., 200., 500.)
53 idbox3 = geompy.addToStudy(box3,"box3")
55 print "Analysis of the geometry box3 :"
56 subShellList=geompy.SubShapeAll(box3,ShapeTypeShell)
57 subFaceList=geompy.SubShapeAll(box3,ShapeTypeFace)
58 subEdgeList=geompy.SubShapeAll(box3,ShapeTypeEdge)
60 print "number of Shells in box3 : ",len(subShellList)
61 print "number of Faces in box3 : ",len(subFaceList)
62 print "number of Edges in box3 : ",len(subEdgeList)
65 blocs.append(box1._get_Name())
66 blocs.append(box2._get_Name())
67 blocs.append(box3._get_Name())
69 shell = geompy.Partition(blocs)
70 idshell = geompy.addToStudy(shell,"shell")
72 print "Analysis of the geometry shell (union of box1, box2 and box3) :"
73 subShellList=geompy.SubShapeAll(shell,ShapeTypeShell)
74 subFaceList=geompy.SubShapeAll(shell,ShapeTypeFace)
75 subEdgeList=geompy.SubShapeAll(shell,ShapeTypeEdge)
77 print "number of Shells in shell : ",len(subShellList)
78 print "number of Faces in shell : ",len(subFaceList)
79 print "number of Edges in shell : ",len(subEdgeList)
82 ### ---------------------------- SMESH --------------------------------------
84 # ---- create Hypothesis
86 print "-------------------------- create Hypothesis"
88 print "-------------------------- NumberOfSegments"
92 hypNbSeg=smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
93 hypNbSeg.SetNumberOfSegments(numberOfSegments)
95 print hypNbSeg.GetName()
96 print hypNbSeg.GetId()
97 print hypNbSeg.GetNumberOfSegments()
99 smeshgui.SetName(salome.ObjectToID(hypNbSeg), "NumberOfSegments_10")
101 print "-------------------------- MaxElementArea"
105 hypArea=smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
106 hypArea.SetMaxElementArea(maxElementArea)
108 print hypArea.GetName()
109 print hypArea.GetId()
110 print hypArea.GetMaxElementArea()
112 smeshgui.SetName(salome.ObjectToID(hypArea), "MaxElementArea_500")
114 print "-------------------------- MaxElementVolume"
116 maxElementVolume = 500
118 hypVolume=smesh.CreateHypothesis("MaxElementVolume", "libStdMeshersEngine.so")
119 hypVolume.SetMaxElementVolume(maxElementVolume)
121 print hypVolume.GetName()
122 print hypVolume.GetId()
123 print hypVolume.GetMaxElementVolume()
125 smeshgui.SetName(salome.ObjectToID(hypVolume), "MaxElementVolume_500")
127 # ---- create Algorithms
129 print "-------------------------- create Algorithms"
131 print "-------------------------- Regular_1D"
133 regular1D=smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
134 smeshgui.SetName(salome.ObjectToID(regular1D), "Wire Discretisation")
136 print "-------------------------- MEFISTO_2D"
138 mefisto2D=smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")
139 smeshgui.SetName(salome.ObjectToID(mefisto2D), "MEFISTO_2D")
141 print "-------------------------- NETGEN_3D"
143 netgen3D=smesh.CreateHypothesis("NETGEN_3D", "libNETGENEngine.so")
144 smeshgui.SetName(salome.ObjectToID(netgen3D), "NETGEN_3D")
146 # ---- init a Mesh with the shell
148 mesh = smesh.CreateMesh(shell)
149 smeshgui.SetName(salome.ObjectToID(mesh), "MeshBox3")
151 # ---- add hypothesis to shell
153 print "-------------------------- add hypothesis to shell"
155 mesh.AddHypothesis(shell,regular1D)
156 mesh.AddHypothesis(shell,hypNbSeg)
158 mesh.AddHypothesis(shell,mefisto2D)
159 mesh.AddHypothesis(shell,hypArea)
161 mesh.AddHypothesis(shell,netgen3D)
162 mesh.AddHypothesis(shell,hypVolume)
164 salome.sg.updateObjBrowser(1)
166 print "-------------------------- compute shell"
167 ret= smesh.Compute(mesh,shell)
170 log=mesh.GetLog(0) # no erase trace
173 print "Information about the MeshBox3:"
174 print "Number of nodes : ", mesh.NbNodes()
175 print "Number of edges : ", mesh.NbEdges()
176 print "Number of faces : ", mesh.NbFaces()
177 print "Number of triangles : ", mesh.NbTriangles()
178 print "Number of volumes : ", mesh.NbVolumes()
179 print "Number of tetrahedrons: ", mesh.NbTetras()
181 print "probleme when computing the mesh"