2 # Tetrahedrization of the geometry union of 2 boxes having a face in common
3 # Hypothesis and algorithms for the mesh generation are global
12 geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM")
13 smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
15 smeshgui = salome.ImportComponentGUI("SMESH")
16 smeshgui.Init(salome.myStudyId);
22 # ---- define 2 boxes box1 and box2
24 box1 = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
26 idbox1 = geompy.addToStudy(box1,"box1")
28 print "Analysis of the geometry box1 :"
29 subShellList=geompy.SubShapeAll(box1,ShapeTypeShell)
30 subFaceList=geompy.SubShapeAll(box1,ShapeTypeFace)
31 subEdgeList=geompy.SubShapeAll(box1,ShapeTypeEdge)
33 print "number of Shells in box1 : ",len(subShellList)
34 print "number of Faces in box1 : ",len(subFaceList)
35 print "number of Edges in box1 : ",len(subEdgeList)
37 box2 = geompy.MakeBox(100., 0., 0., 200., 200., 300.)
39 idbox2 = geompy.addToStudy(box2,"box2")
41 print "Analysis of the geometry box2 :"
42 subShellList=geompy.SubShapeAll(box2,ShapeTypeShell)
43 subFaceList=geompy.SubShapeAll(box2,ShapeTypeFace)
44 subEdgeList=geompy.SubShapeAll(box2,ShapeTypeEdge)
46 print "number of Shells in box2 : ",len(subShellList)
47 print "number of Faces in box2 : ",len(subFaceList)
48 print "number of Edges in box2 : ",len(subEdgeList)
51 blocs.append(box1._get_Name())
52 blocs.append(box2._get_Name())
54 # append the tow boxes to make ine shel, referrencing only once
55 # the internal interface
57 shell = geompy.Partition(blocs)
58 idshell = geompy.addToStudy(shell,"shell")
60 print "Analysis of the geometry shell (union of box1 and box2) :"
61 subShellList=geompy.SubShapeAll(shell,ShapeTypeShell)
62 subFaceList=geompy.SubShapeAll(shell,ShapeTypeFace)
63 subEdgeList=geompy.SubShapeAll(shell,ShapeTypeEdge)
65 print "number of Shells in shell : ",len(subShellList)
66 print "number of Faces in shell : ",len(subFaceList)
67 print "number of Edges in shell : ",len(subEdgeList)
70 ### ---------------------------- SMESH --------------------------------------
72 # ---- create Hypothesis
74 print "-------------------------- create Hypothesis"
76 print "-------------------------- NumberOfSegments"
80 hypNbSeg=smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
81 hypNbSeg.SetNumberOfSegments(numberOfSegments)
83 print hypNbSeg.GetName()
84 print hypNbSeg.GetId()
85 print hypNbSeg.GetNumberOfSegments()
87 smeshgui.SetName(salome.ObjectToID(hypNbSeg), "NumberOfSegments_10")
89 print "-------------------------- MaxElementArea"
93 hypArea=smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
94 hypArea.SetMaxElementArea(maxElementArea)
96 print hypArea.GetName()
98 print hypArea.GetMaxElementArea()
100 smeshgui.SetName(salome.ObjectToID(hypArea), "MaxElementArea_500")
102 print "-------------------------- MaxElementVolume"
104 maxElementVolume = 500
106 hypVolume=smesh.CreateHypothesis("MaxElementVolume", "libStdMeshersEngine.so")
107 hypVolume.SetMaxElementVolume(maxElementVolume)
109 print hypVolume.GetName()
110 print hypVolume.GetId()
111 print hypVolume.GetMaxElementVolume()
113 smeshgui.SetName(salome.ObjectToID(hypVolume), "MaxElementVolume_500")
115 # ---- create Algorithms
117 print "-------------------------- create Algorithms"
119 print "-------------------------- Regular_1D"
121 regular1D=smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
122 smeshgui.SetName(salome.ObjectToID(regular1D), "Wire Discretisation")
124 print "-------------------------- MEFISTO_2D"
126 mefisto2D=smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")
127 smeshgui.SetName(salome.ObjectToID(mefisto2D), "MEFISTO_2D")
129 print "-------------------------- NETGEN_3D"
131 netgen3D=smesh.CreateHypothesis("NETGEN_3D", "libNETGENEngine.so")
132 smeshgui.SetName(salome.ObjectToID(netgen3D), "NETGEN_3D")
134 # ---- init a Mesh with the shell
136 mesh = smesh.CreateMesh(shell)
137 smeshgui.SetName(salome.ObjectToID(mesh), "MeshBox2")
139 # ---- add hypothesis to shell
141 print "-------------------------- add hypothesis to shell"
143 mesh.AddHypothesis(shell,regular1D)
144 mesh.AddHypothesis(shell,hypNbSeg)
146 mesh.AddHypothesis(shell,mefisto2D)
147 mesh.AddHypothesis(shell,hypArea)
149 mesh.AddHypothesis(shell,netgen3D)
150 mesh.AddHypothesis(shell,hypVolume)
152 salome.sg.updateObjBrowser(1)
154 print "-------------------------- compute shell"
155 ret= smesh.Compute(mesh,shell)
158 log=mesh.GetLog(0) # no erase trace
161 print "Information about the MeshBox2:"
162 print "Number of nodes : ", mesh.NbNodes()
163 print "Number of edges : ", mesh.NbEdges()
164 print "Number of faces : ", mesh.NbFaces()
165 print "Number of triangles : ", mesh.NbTriangles()
166 print "Number of volumes : ", mesh.NbVolumes()
167 print "Number of tetrahedrons: ", mesh.NbTetras()
169 print "probleme when computing the mesh"