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
16 myBuilder = geompy.myBuilder
22 # ---- define 3 boxes box1, box2 and box3
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)
50 box3 = geompy.MakeBox(0., 0., 300., 200., 200., 500.)
52 idbox3 = geompy.addToStudy(box3,"box3")
54 print "Analysis of the geometry box3 :"
55 subShellList=geompy.SubShapeAll(box3,ShapeTypeShell)
56 subFaceList=geompy.SubShapeAll(box3,ShapeTypeFace)
57 subEdgeList=geompy.SubShapeAll(box3,ShapeTypeEdge)
59 print "number of Shells in box3 : ",len(subShellList)
60 print "number of Faces in box3 : ",len(subFaceList)
61 print "number of Edges in box3 : ",len(subEdgeList)
64 blocs.append(box1._get_Name())
65 blocs.append(box2._get_Name())
66 blocs.append(box3._get_Name())
68 shell = geompy.Partition(blocs)
69 idshell = geompy.addToStudy(shell,"shell")
71 print "Analysis of the geometry shell (union of box1, box2 and box3) :"
72 subShellList=geompy.SubShapeAll(shell,ShapeTypeShell)
73 subFaceList=geompy.SubShapeAll(shell,ShapeTypeFace)
74 subEdgeList=geompy.SubShapeAll(shell,ShapeTypeEdge)
76 print "number of Shells in shell : ",len(subShellList)
77 print "number of Faces in shell : ",len(subFaceList)
78 print "number of Edges in shell : ",len(subEdgeList)
82 smeshgui = salome.ImportComponentGUI("SMESH")
83 smeshgui.Init(salome.myStudyId)
87 # ---- create Hypothesis
89 print "-------------------------- create Hypothesis"
91 print "-------------------------- NumberOfSegments"
95 hyp1=gen.CreateHypothesis("NumberOfSegments")
96 hypNbSeg=hyp1._narrow(SMESH.SMESH_NumberOfSegments)
97 hypNbSeg.SetNumberOfSegments(numberOfSegments)
98 hypNbSegID = hypNbSeg.GetId()
99 print hypNbSeg.GetName()
101 print hypNbSeg.GetNumberOfSegments()
103 idseg = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypNbSeg) )
104 smeshgui.SetName(idseg, "NumberOfSegments")
106 print "-------------------------- MaxElementArea"
110 hyp2=gen.CreateHypothesis("MaxElementArea")
111 hypArea=hyp2._narrow(SMESH.SMESH_MaxElementArea)
112 hypArea.SetMaxElementArea(maxElementArea)
113 print hypArea.GetName()
114 print hypArea.GetId()
115 print hypArea.GetMaxElementArea()
117 idarea = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypArea) )
118 smeshgui.SetName(idarea, "MaxElementArea")
120 print "-------------------------- MaxElementVolume"
122 maxElementVolume = 500
124 hyp3=gen.CreateHypothesis("MaxElementVolume")
125 hypVolume=hyp3._narrow(SMESH.SMESH_MaxElementVolume)
126 hypVolume.SetMaxElementVolume(maxElementVolume)
127 print hypVolume.GetName()
128 print hypVolume.GetId()
129 print hypVolume.GetMaxElementVolume()
131 idvolume = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypVolume) )
132 smeshgui.SetName(idvolume, "MaxElementVolume")
134 # ---- create Algorithms
136 print "-------------------------- create Algorithms"
138 print "-------------------------- Regular_1D"
140 hypothesis=gen.CreateHypothesis("Regular_1D")
141 regular1D = hypothesis._narrow(SMESH.SMESH_Regular_1D)
142 regularID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(regular1D) )
143 smeshgui.SetName(regularID, "Wire Discretisation")
145 print "-------------------------- MEFISTO_2D"
147 hypothesis=gen.CreateHypothesis("MEFISTO_2D")
148 mefisto2D = hypothesis._narrow(SMESH.SMESH_MEFISTO_2D)
149 mefistoID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(mefisto2D) )
150 smeshgui.SetName(mefistoID, "MEFISTO_2D")
152 print "-------------------------- NETGEN_3D"
154 hypothesis=gen.CreateHypothesis("NETGEN_3D")
155 netgen3D = hypothesis._narrow(SMESH.SMESH_NETGEN_3D)
156 netgenID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(netgen3D) )
157 smeshgui.SetName(netgenID, "NETGEN_3D")
159 # ---- init a Mesh with the shell
161 mesh=gen.Init(idshell)
162 idmesh = smeshgui.AddNewMesh( salome.orb.object_to_string(mesh) )
163 smeshgui.SetName(idmesh, "MeshBox2")
164 smeshgui.SetShape(idshell, idmesh)
166 # ---- add hypothesis to shell
168 print "-------------------------- add hypothesis to shell"
170 ret=mesh.AddHypothesis(shell,regular1D)
172 ret=mesh.AddHypothesis(shell,hypNbSeg)
174 ret=mesh.AddHypothesis(shell,mefisto2D)
176 ret=mesh.AddHypothesis(shell,hypArea)
178 ret=mesh.AddHypothesis(shell,netgen3D)
180 ret=mesh.AddHypothesis(shell,hypVolume)
183 smeshgui.SetAlgorithms( idmesh, regularID)
184 smeshgui.SetHypothesis( idmesh, idseg )
185 smeshgui.SetAlgorithms( idmesh, mefistoID )
186 smeshgui.SetHypothesis( idmesh, idarea )
187 smeshgui.SetAlgorithms( idmesh, netgenID )
188 smeshgui.SetHypothesis( idmesh, idvolume )
190 sg.updateObjBrowser(1)
193 print "-------------------------- compute shell"
194 ret=gen.Compute(mesh,idshell)
196 log=mesh.GetLog(0) # no erase trace
201 sg.updateObjBrowser(1)