2 # Tetrahedrization of the geometry union of 2 boxes having a face in common
3 # Hypothesis and algorithms for the mesh generation are global
15 myBuilder = geompy.myBuilder
21 # ---- define 2 boxes box1 and box2
23 box1 = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
25 idbox1 = geompy.addToStudy(box1,"box1")
27 print "Analysis of the geometry box1 :"
28 subShellList=geompy.SubShapeAll(box1,ShapeTypeShell)
29 subFaceList=geompy.SubShapeAll(box1,ShapeTypeFace)
30 subEdgeList=geompy.SubShapeAll(box1,ShapeTypeEdge)
32 print "number of Shells in box1 : ",len(subShellList)
33 print "number of Faces in box1 : ",len(subFaceList)
34 print "number of Edges in box1 : ",len(subEdgeList)
36 box2 = geompy.MakeBox(100., 0., 0., 200., 200., 300.)
38 idbox2 = geompy.addToStudy(box2,"box2")
40 print "Analysis of the geometry box2 :"
41 subShellList=geompy.SubShapeAll(box2,ShapeTypeShell)
42 subFaceList=geompy.SubShapeAll(box2,ShapeTypeFace)
43 subEdgeList=geompy.SubShapeAll(box2,ShapeTypeEdge)
45 print "number of Shells in box2 : ",len(subShellList)
46 print "number of Faces in box2 : ",len(subFaceList)
47 print "number of Edges in box2 : ",len(subEdgeList)
50 blocs.append(box1._get_Name())
51 blocs.append(box2._get_Name())
53 # append the tow boxes to make ine shel, referrencing only once
54 # the internal interface
56 shell = geompy.Partition(blocs)
57 idshell = geompy.addToStudy(shell,"shell")
59 print "Analysis of the geometry shell (union of box1 and box2) :"
60 subShellList=geompy.SubShapeAll(shell,ShapeTypeShell)
61 subFaceList=geompy.SubShapeAll(shell,ShapeTypeFace)
62 subEdgeList=geompy.SubShapeAll(shell,ShapeTypeEdge)
64 print "number of Shells in shell : ",len(subShellList)
65 print "number of Faces in shell : ",len(subFaceList)
66 print "number of Edges in shell : ",len(subEdgeList)
70 smeshgui = salome.ImportComponentGUI("SMESH")
71 smeshgui.Init(salome.myStudyId)
75 # ---- create Hypothesis
77 print "-------------------------- create Hypothesis"
79 print "-------------------------- NumberOfSegments"
83 hyp1=gen.CreateHypothesis("NumberOfSegments")
84 hypNbSeg=hyp1._narrow(SMESH.SMESH_NumberOfSegments)
85 hypNbSeg.SetNumberOfSegments(numberOfSegments)
86 hypNbSegID = hypNbSeg.GetId()
87 print hypNbSeg.GetName()
89 print hypNbSeg.GetNumberOfSegments()
91 idseg = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypNbSeg) )
92 smeshgui.SetName(idseg, "NumberOfSegments")
94 print "-------------------------- MaxElementArea"
98 hyp2=gen.CreateHypothesis("MaxElementArea")
99 hypArea=hyp2._narrow(SMESH.SMESH_MaxElementArea)
100 hypArea.SetMaxElementArea(maxElementArea)
101 print hypArea.GetName()
102 print hypArea.GetId()
103 print hypArea.GetMaxElementArea()
105 idarea = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypArea) )
106 smeshgui.SetName(idarea, "MaxElementArea")
108 print "-------------------------- MaxElementVolume"
110 maxElementVolume = 500
112 hyp3=gen.CreateHypothesis("MaxElementVolume")
113 hypVolume=hyp3._narrow(SMESH.SMESH_MaxElementVolume)
114 hypVolume.SetMaxElementVolume(maxElementVolume)
115 print hypVolume.GetName()
116 print hypVolume.GetId()
117 print hypVolume.GetMaxElementVolume()
119 idvolume = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypVolume) )
120 smeshgui.SetName(idvolume, "MaxElementVolume")
122 # ---- create Algorithms
124 print "-------------------------- create Algorithms"
126 print "-------------------------- Regular_1D"
128 hypothesis=gen.CreateHypothesis("Regular_1D")
129 regular1D = hypothesis._narrow(SMESH.SMESH_Regular_1D)
130 regularID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(regular1D) )
131 smeshgui.SetName(regularID, "Wire Discretisation")
133 print "-------------------------- MEFISTO_2D"
135 hypothesis=gen.CreateHypothesis("MEFISTO_2D")
136 mefisto2D = hypothesis._narrow(SMESH.SMESH_MEFISTO_2D)
137 mefistoID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(mefisto2D) )
138 smeshgui.SetName(mefistoID, "MEFISTO_2D")
140 print "-------------------------- NETGEN_3D"
142 hypothesis=gen.CreateHypothesis("NETGEN_3D")
143 netgen3D = hypothesis._narrow(SMESH.SMESH_NETGEN_3D)
144 netgenID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(netgen3D) )
145 smeshgui.SetName(netgenID, "NETGEN_3D")
147 # ---- init a Mesh with the shell
149 mesh=gen.Init(idshell)
150 idmesh = smeshgui.AddNewMesh( salome.orb.object_to_string(mesh) )
151 smeshgui.SetName(idmesh, "MeshBox2")
152 smeshgui.SetShape(idshell, idmesh)
154 # ---- add hypothesis to shell
156 print "-------------------------- add hypothesis to shell"
158 ret=mesh.AddHypothesis(shell,regular1D)
160 ret=mesh.AddHypothesis(shell,hypNbSeg)
162 ret=mesh.AddHypothesis(shell,mefisto2D)
164 ret=mesh.AddHypothesis(shell,hypArea)
166 ret=mesh.AddHypothesis(shell,netgen3D)
168 ret=mesh.AddHypothesis(shell,hypVolume)
171 smeshgui.SetAlgorithms( idmesh, regularID)
172 smeshgui.SetHypothesis( idmesh, idseg )
173 smeshgui.SetAlgorithms( idmesh, mefistoID )
174 smeshgui.SetHypothesis( idmesh, idarea )
175 smeshgui.SetAlgorithms( idmesh, netgenID )
176 smeshgui.SetHypothesis( idmesh, idvolume )
178 sg.updateObjBrowser(1)
181 print "-------------------------- compute shell"
182 ret=gen.Compute(mesh,idshell)
184 log=mesh.GetLog(0) # no erase trace
189 sg.updateObjBrowser(1)