Salome HOME
updating or adding when merging in the main trunk with the version in the
[modules/smesh.git] / src / SMESH_SWIG / SMESH_fixation_hexa.py
1 #
2 # Hexahedrization of the geometry generated by the Python script
3 # SMESH_fixation.py
4 # Hypothesis and algorithms for the mesh generation are global
5 #
6
7 import SMESH_fixation
8 import SMESH
9 import smeshpy
10
11 compshell = SMESH_fixation.compshell
12 idcomp = SMESH_fixation.idcomp
13 geompy = SMESH_fixation.geompy
14 salome = SMESH_fixation.salome
15 sg = SMESH_fixation.sg
16
17 ShapeTypeShell     = 3
18 ShapeTypeFace      = 4
19 ShapeTypeEdge      = 6
20
21 print "Analysis of the geometry to be meshed :"
22 subShellList=geompy.SubShapeAll(compshell,ShapeTypeShell)
23 subFaceList=geompy.SubShapeAll(compshell,ShapeTypeFace)
24 subEdgeList=geompy.SubShapeAll(compshell,ShapeTypeEdge)
25
26 print "number of Shells in compshell : ",len(subShellList)
27 print "number of Faces in compshell : ",len(subFaceList)
28 print "number of Edges in compshell : ",len(subEdgeList)
29
30 status=geompy.CheckShape(compshell)
31 print " check status ", status
32
33 ### ---- launch SMESH
34
35 smeshgui = salome.ImportComponentGUI("SMESH")
36 smeshgui.Init(salome.myStudyId)
37
38 gen=smeshpy.smeshpy()
39
40 ### ---- create Hypothesis
41
42 print "-------------------------- create Hypothesis"
43
44 print "-------------------------- NumberOfSegments"
45
46 numberOfSegments = 5
47
48 hyp1=gen.CreateHypothesis("NumberOfSegments")
49 hypNbSeg=hyp1._narrow(SMESH.SMESH_NumberOfSegments)
50 hypNbSeg.SetNumberOfSegments(numberOfSegments)
51 hypNbSegID = hypNbSeg.GetId()
52 print hypNbSeg.GetName()
53 print hypNbSegID
54 print hypNbSeg.GetNumberOfSegments()
55
56 idseg = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypNbSeg) )
57 smeshgui.SetName(idseg, "NumberOfSegments")
58
59 # ---- create Algorithms
60
61 print "-------------------------- create Algorithms"
62
63 print "-------------------------- Regular_1D"
64
65 hypothesis=gen.CreateHypothesis("Regular_1D")
66 regular1D = hypothesis._narrow(SMESH.SMESH_Regular_1D)
67 regularID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(regular1D) )
68 smeshgui.SetName(regularID, "Wire Discretisation")
69
70 print "-------------------------- Quadrangle_2D"
71
72 hypothesis=gen.CreateHypothesis("Quadrangle_2D")
73 quad2D = hypothesis._narrow(SMESH.SMESH_Quadrangle_2D)
74 quadID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(quad2D) )
75 smeshgui.SetName(quadID, "Quadrangle_2D")
76
77 print "-------------------------- Hexa_3D"
78
79 hypothesis=gen.CreateHypothesis("Hexa_3D")
80 hexa3D = hypothesis._narrow(SMESH.SMESH_Hexa_3D)
81 hexaID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(hexa3D) )
82 smeshgui.SetName(hexaID, "Hexa_3D")
83
84 # ---- init a Mesh with the compshell
85
86 mesh=gen.Init(idcomp)
87 idmesh = smeshgui.AddNewMesh( salome.orb.object_to_string(mesh) )
88 smeshgui.SetName(idmesh, "MeshcompShel")
89 smeshgui.SetShape(idcomp, idmesh)
90
91 # ---- add hypothesis to compshell
92
93 print "-------------------------- add hypothesis to compshell"
94
95 ret=mesh.AddHypothesis(compshell,regular1D)
96 print ret
97 ret=mesh.AddHypothesis(compshell,hypNbSeg)
98 print ret
99 ret=mesh.AddHypothesis(compshell,quad2D)
100 print ret
101 ret=mesh.AddHypothesis(compshell,hexa3D)
102 print ret
103
104 smeshgui.SetAlgorithms( idmesh, regularID)
105 smeshgui.SetHypothesis( idmesh, idseg )
106 smeshgui.SetAlgorithms( idmesh, quadID )
107 smeshgui.SetAlgorithms( idmesh, hexaID )
108
109 sg.updateObjBrowser(1)
110
111
112 print "-------------------------- compute compshell"
113 ret=gen.Compute(mesh,idcomp)
114 print ret
115 if ret != 0:
116     log=mesh.GetLog(0) # no erase trace
117     for linelog in log:
118         print linelog
119 else:
120     print "problem when Computing the mesh"
121
122 sg.updateObjBrowser(1)