1 # CEA/LGLS 2004, Francis KLOSS (OCC)
2 # ==================================
18 smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
19 smesh.SetCurrentStudy(salome.myStudy)
20 smeshgui = salome.ImportComponentGUI("SMESH")
21 smeshgui.Init(salome.myStudyId)
23 # Hexahedrical meshing
25 # Examples: cube2pyGibi.py, lines 270-295
26 # cube2partition.py, lines 72-83
27 # --------------------
35 # Sets algorithm and hypothesis for 1D discretization of the <shape>:
36 # - algorithm "Regular_1D"
37 # - hypothesis "NumberOfSegments" with number of segments <n>
38 # --------------------
40 def Mesh1D(self, shape, n, propagate=0):
41 hyp1D=smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
42 smeshgui.SetName(salome.ObjectToID(hyp1D), self.name+"/WireDiscretisation/"+str(self.cpt))
43 self.mesh.AddHypothesis(shape, hyp1D)
45 hyp=smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
46 hyp.SetNumberOfSegments(n)
47 smeshgui.SetName(salome.ObjectToID(hyp), self.name+"/Segments_"+str(n)+"/"+str(self.cpt))
48 self.mesh.AddHypothesis(shape, hyp)
51 hypPro=smesh.CreateHypothesis("Propagation", "libStdMeshersEngine.so")
52 smeshgui.SetName(salome.ObjectToID(hypPro), self.name+"/Propagation/"+str(self.cpt))
53 self.mesh.AddHypothesis(shape, hypPro)
59 # Creates mesh on the shape <piece>,
60 # sets GUI name of this mesh to <name>.
61 # Sets the following global algorithms and hypotheses:
62 # - for 1D discretization:
63 # - algorithm "Regular_1D"
64 # - hypothesis "NumberOfSegments" with number of segments <n>,
65 # - for 2D discretization:
66 # - algorithm "Quadrangle_2D"
67 # - for 3D discretization:
68 # - algorithm "Hexa_3D"
69 # --------------------
71 def __init__(self, piece, n, name):
75 self.mesh = smesh.CreateMesh(piece)
76 smeshgui.SetName(salome.ObjectToID(self.mesh), name)
80 hyp2D=smesh.CreateHypothesis("Quadrangle_2D", "libStdMeshersEngine.so")
81 smeshgui.SetName(salome.ObjectToID(hyp2D), name+"/Quadrangle")
82 self.mesh.AddHypothesis(piece, hyp2D)
84 hyp3D=smesh.CreateHypothesis("Hexa_3D", "libStdMeshersEngine.so")
85 smeshgui.SetName(salome.ObjectToID(hyp3D), name+"/ijk")
86 self.mesh.AddHypothesis(piece, hyp3D)
88 # Creates sub-mesh of the mesh, created by constructor.
89 # This sub-mesh will be created on edge <edge>.
90 # Set algorithm and hypothesis for 1D discretization of the <edge>:
91 # - algorithm "Regular_1D"
92 # - hypothesis "NumberOfSegments" with number of segments <n>
93 # Note: the <edge> will be automatically published in study under the shape, given in constructor.
94 # --------------------
96 def local(self, edge, n):
97 geompy.addToStudyInFather(self.piece, edge, geompy.SubShapeName(edge, self.piece))
98 submesh = self.mesh.GetSubMesh(edge, self.name+"/SubMeshEdge/"+str(self.cpt))
101 # Creates sub-mesh of the mesh, created by constructor.
102 # This sub-mesh will be created on edge <edge> and propagate the hypothesis on all correspondant edges.
103 # Set algorithm and hypothesis for 1D discretization of the <edge> and all other propagate edges:
104 # - algorithm "Regular_1D"
105 # - hypothesis "NumberOfSegments" with number of segments <n>
106 # - hypothesis "Propagation" with number of segments <n>
107 # Note: the <edge> will be automatically published in study under the shape, given in constructor.
108 # --------------------
110 def Propagate(self, edge, n):
111 geompy.addToStudyInFather(self.piece, edge, geompy.SubShapeName(edge, self.piece))
112 submesh = self.mesh.GetSubMesh(edge, self.name+"/SubMeshEdge/"+str(self.cpt))
113 self.Mesh1D(edge, n, 1)
115 # Computes mesh, created by constructor.
116 # --------------------
119 smesh.Compute(self.mesh, self.piece)
120 salome.sg.updateObjBrowser(1)
122 # Creates mesh group based on a geometric group
123 # --------------------
125 def Group(self, grp, name=""):
128 tgeo = geompy.GroupOp.GetType(grp)
129 if tgeo == geompy.ShapeType["VERTEX"]:
131 elif tgeo == geompy.ShapeType["EDGE"]:
133 elif tgeo == geompy.ShapeType["FACE"]:
135 elif tgeo == geompy.ShapeType["SOLID"]:
137 return self.mesh.CreateGroupFromGEOM(type, name, grp)
139 # Export mesh in a MED file
140 # --------------------
142 def ExportMED(self, filename, groups=1):
143 self.mesh.ExportMED(filename, groups)
145 MeshHexa = MeshHexaImpl