2 # Tetrahedrization of a geometry (box minus a inner cylinder).
3 # Hypothesis and algorithms for the mesh generation are global
14 # -----------------------------------------------------------------------------
17 myBuilder = geompy.myBuilder
23 # ---- define a boxe and a cylinder
32 P0 = geom.MakePointStruct(0.,-1.,0.)
33 P1 = geom.MakePointStruct(0.,1.,0.)
34 Vect = geom.MakeDirection(P1)
38 boxe = geompy.MakeBox(x0,y0,z0,x1,y1,z1)
40 cylinder = geompy.MakeCylinder(P0,Vect,radius,height)
42 shape = geompy.MakeBoolean(boxe,cylinder,2)
43 idshape = geompy.addToStudy(shape,"shape")
47 print "Analysis of the shape :"
48 subShellList=geompy.SubShapeAll(shape,ShapeTypeShell)
49 subFaceList=geompy.SubShapeAll(shape,ShapeTypeFace)
50 subEdgeList=geompy.SubShapeAll(shape,ShapeTypeEdge)
52 print "number of Shells in the shape : ",len(subShellList)
53 print "number of Faces in the shape : ",len(subFaceList)
54 print "number of Edges in the shape : ",len(subEdgeList)
58 smeshgui = salome.ImportComponentGUI("SMESH")
59 smeshgui.Init(salome.myStudyId)
63 # ---- create Hypothesis
65 print "-------------------------- create Hypothesis"
67 print "-------------------------- NumberOfSegments"
71 hypothesis=gen.CreateHypothesis("NumberOfSegments")
72 hypNbSeg=hypothesis._narrow(SMESH.SMESH_NumberOfSegments)
73 hypNbSeg.SetNumberOfSegments(numberOfSegments)
74 hypNbSegID = hypNbSeg.GetId()
75 print hypNbSeg.GetName()
77 print hypNbSeg.GetNumberOfSegments()
79 idseg = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypNbSeg) )
80 smeshgui.SetName(idseg, "NumberOfSegments")
82 print "-------------------------- LengthFromEdges"
84 hypothesis=gen.CreateHypothesis("LengthFromEdges")
85 hypLengthFromEdge=hypothesis._narrow(SMESH.SMESH_LengthFromEdges)
86 hypLengthFromEdgeID = hypLengthFromEdge.GetId()
87 print hypLengthFromEdge.GetName()
88 print hypLengthFromEdgeID
90 idlenfromedge = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypLengthFromEdge) )
91 smeshgui.SetName(idlenfromedge, "LengthFromEdge")
93 print "-------------------------- MaxElementVolume"
95 maxElementVolume = 0.5
97 hypothesis=gen.CreateHypothesis("MaxElementVolume")
98 hypVolume=hypothesis._narrow(SMESH.SMESH_MaxElementVolume)
99 hypVolume.SetMaxElementVolume(maxElementVolume)
100 print hypVolume.GetName()
101 print hypVolume.GetId()
102 print hypVolume.GetMaxElementVolume()
104 idvolume = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypVolume) )
105 smeshgui.SetName(idvolume, "MaxElementVolume")
107 # ---- create Algorithms
109 print "-------------------------- create Algorithms"
111 print "-------------------------- Regular_1D"
113 hypothesis=gen.CreateHypothesis("Regular_1D")
114 regular1D = hypothesis._narrow(SMESH.SMESH_Regular_1D)
115 regularID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(regular1D) )
116 smeshgui.SetName(regularID, "Wire Discretisation")
118 print "-------------------------- MEFISTO_2D"
120 hypothesis=gen.CreateHypothesis("MEFISTO_2D")
121 mefisto2D = hypothesis._narrow(SMESH.SMESH_MEFISTO_2D)
122 mefistoID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(mefisto2D) )
123 smeshgui.SetName(mefistoID, "MEFISTO_2D")
125 print "-------------------------- NETGEN_3D"
127 hypothesis=gen.CreateHypothesis("NETGEN_3D")
128 netgen3D = hypothesis._narrow(SMESH.SMESH_NETGEN_3D)
129 netgenID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(netgen3D) )
130 smeshgui.SetName(netgenID, "NETGEN_3D")
132 # ---- init a Mesh with the shell
134 mesh=gen.Init(idshape)
135 idmesh = smeshgui.AddNewMesh( salome.orb.object_to_string(mesh) )
136 smeshgui.SetName(idmesh, "MeshShape")
137 smeshgui.SetShape(idshape, idmesh)
139 # ---- add hypothesis to flight
141 print "-------------------------- add hypothesis to the shape"
143 ret=mesh.AddHypothesis(shape,regular1D)
145 ret=mesh.AddHypothesis(shape,hypNbSeg)
147 ret=mesh.AddHypothesis(shape,mefisto2D)
149 ret=mesh.AddHypothesis(shape,hypLengthFromEdge)
151 ret=mesh.AddHypothesis(shape,netgen3D)
153 ret=mesh.AddHypothesis(shape,hypVolume)
156 smeshgui.SetAlgorithms( idmesh, regularID)
157 smeshgui.SetHypothesis( idmesh, idseg )
158 smeshgui.SetAlgorithms( idmesh, mefistoID )
159 smeshgui.SetHypothesis( idmesh, idlenfromedge)
160 smeshgui.SetAlgorithms( idmesh, netgenID )
161 smeshgui.SetHypothesis( idmesh, idvolume )
163 sg.updateObjBrowser(1)
166 print "-------------------------- compute the mesh of the shape"
167 ret=gen.Compute(mesh,idshape)
170 log=mesh.GetLog(0) # no erase trace
174 print "probleme when computing the mesh"
176 sg.updateObjBrowser(1)