2 # Tetrahedrization of a geometry (box minus a inner cylinder).
3 # Hypothesis and algorithms for the mesh generation are global
15 # -----------------------------------------------------------------------------
18 myBuilder = geompy.myBuilder
31 Orig = geom.MakePointStruct(zero,zero,zero)
32 P0 = geom.MakePointStruct(a,a,zero)
33 P1 = geom.MakePointStruct(zero,demi,zero)
34 P2 = geom.MakePointStruct(ma,a,zero)
35 P3 = geom.MakePointStruct(mun,un,zero)
36 P4 = geom.MakePointStruct(un,un,zero)
37 P5 = geom.MakePointStruct(zero,zero,un)
39 arc = geompy.MakeArc(P0,P1,P2)
40 e1 = geompy.MakeEdge(P2,P3)
41 e2 = geompy.MakeEdge(P3,P4)
42 e3 = geompy.MakeEdge(P4,P0)
45 list.append(arc._get_Name())
46 list.append(e1._get_Name())
47 list.append(e2._get_Name())
48 list.append(e3._get_Name())
50 wire = geompy.MakeWire(list)
51 face = geompy.MakeFace(wire,1)
53 dir = geompy.MakeVector(Orig,P5)
54 vol1 = geompy.MakePipe(dir,face)
57 dir = geom.MakeAxisStruct(zero,zero,zero,zero,zero,un)
58 vol2 = geompy.MakeRotation(vol1,dir,angle)
60 vol3 = geompy.MakeRotation(vol2,dir,angle)
62 vol4 = geompy.MakeRotation(vol3,dir,angle)
65 list.append(vol1._get_Name())
66 list.append(vol2._get_Name())
67 list.append(vol3._get_Name())
68 list.append(vol4._get_Name())
70 volComp = geompy.MakeCompound(list)
73 vol = geom.MakeGlueFaces(volComp,tol3d)
74 idVol = geompy.addToStudy(vol,"volume")
76 print "Analysis of the final volume:"
77 subShellList=geompy.SubShapeAll(vol,ShapeTypeShell)
78 subFaceList=geompy.SubShapeAll(vol,ShapeTypeFace)
79 subEdgeList=geompy.SubShapeAll(vol,ShapeTypeEdge)
81 print "number of Shells in the volume : ",len(subShellList)
82 print "number of Faces in the volume : ",len(subFaceList)
83 print "number of Edges in the volume : ",len(subEdgeList)
87 smeshgui = salome.ImportComponentGUI("SMESH")
88 smeshgui.Init(salome.myStudyId)
92 # ---- create Hypothesis
94 print "-------------------------- create Hypothesis"
96 print "-------------------------- NumberOfSegments"
100 hypothesis=gen.CreateHypothesis("NumberOfSegments")
101 hypNbSeg=hypothesis._narrow(SMESH.SMESH_NumberOfSegments)
102 hypNbSeg.SetNumberOfSegments(numberOfSegments)
103 hypNbSegID = hypNbSeg.GetId()
104 print hypNbSeg.GetName()
106 print hypNbSeg.GetNumberOfSegments()
108 idseg = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypNbSeg) )
109 smeshgui.SetName(idseg, "NumberOfSegments")
111 # ---- create Algorithms
113 print "-------------------------- create Algorithms"
115 print "-------------------------- Regular_1D"
117 hypothesis=gen.CreateHypothesis("Regular_1D")
118 regular1D = hypothesis._narrow(SMESH.SMESH_Regular_1D)
119 regularID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(regular1D) )
120 smeshgui.SetName(regularID, "Wire Discretisation")
122 print "-------------------------- Quadrangle_2D"
124 hypothesis=gen.CreateHypothesis("Quadrangle_2D")
125 quad2D = hypothesis._narrow(SMESH.SMESH_Quadrangle_2D)
126 quadID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(quad2D) )
127 smeshgui.SetName(quadID, "Quadrangle_2D")
129 print "-------------------------- Hexa_3D"
131 hypothesis=gen.CreateHypothesis("Hexa_3D")
132 hexa3D = hypothesis._narrow(SMESH.SMESH_Hexa_3D)
133 hexaID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(hexa3D) )
134 smeshgui.SetName(hexaID, "Hexa_3D")
136 # ---- init a Mesh with the volume
139 idmesh = smeshgui.AddNewMesh( salome.orb.object_to_string(mesh) )
140 smeshgui.SetName(idmesh, "meshVolume")
141 smeshgui.SetShape(idVol, idmesh)
143 # ---- add hypothesis to the volume
145 print "-------------------------- add hypothesis to the volume"
147 ret=mesh.AddHypothesis(vol,regular1D)
149 ret=mesh.AddHypothesis(vol,hypNbSeg)
151 ret=mesh.AddHypothesis(vol,quad2D)
153 ret=mesh.AddHypothesis(vol,hexa3D)
156 print "-------------------------- set algoritms"
158 smeshgui.SetAlgorithms( idmesh, regularID)
159 smeshgui.SetHypothesis( idmesh, idseg )
160 smeshgui.SetAlgorithms( idmesh, quadID )
161 smeshgui.SetAlgorithms( idmesh, hexaID )
163 sg.updateObjBrowser(1)
165 print "-------------------------- compute the mesh of the volume"
166 ret=gen.Compute(mesh,idVol)
169 log=mesh.GetLog(0) # no erase trace
173 print "problem when Computing the mesh"
175 sg.updateObjBrowser(1)