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):
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)
54 # Creates mesh on the shape <piece>,
55 # sets GUI name of this mesh to <name>.
56 # Sets the following global algorithms and hypotheses:
57 # - for 1D discretization:
58 # - algorithm "Regular_1D"
59 # - hypothesis "NumberOfSegments" with number of segments <n>,
60 # - for 2D discretization:
61 # - algorithm "Quadrangle_2D"
62 # - for 3D discretization:
63 # - algorithm "Hexa_3D"
64 # --------------------
66 def __init__(self, piece, n, name):
70 self.mesh = smesh.CreateMesh(piece)
71 smeshgui.SetName(salome.ObjectToID(self.mesh), name)
75 hyp2D=smesh.CreateHypothesis("Quadrangle_2D", "libStdMeshersEngine.so")
76 smeshgui.SetName(salome.ObjectToID(hyp2D), name+"/Quadrangle")
77 self.mesh.AddHypothesis(piece, hyp2D)
79 hyp3D=smesh.CreateHypothesis("Hexa_3D", "libStdMeshersEngine.so")
80 smeshgui.SetName(salome.ObjectToID(hyp3D), name+"/ijk")
81 self.mesh.AddHypothesis(piece, hyp3D)
83 # Creates sub-mesh of the mesh, created by constructor.
84 # This sub-mesh will be created on edge <edge>.
85 # Set algorithm and hypothesis for 1D discretization of the <edge>:
86 # - algorithm "Regular_1D"
87 # - hypothesis "NumberOfSegments" with number of segments <n>
88 # Note: the <edge> will be automatically published in study under the shape, given in constructor.
89 # --------------------
91 def local(self, edge, n):
92 geompy.addToStudyInFather(self.piece, edge, geompy.SubShapeName(edge, self.piece))
93 submesh = self.mesh.GetSubMesh(edge, self.name+"/SubMeshEdge/"+str(self.cpt))
96 # Computes mesh, created by constructor.
97 # --------------------
100 smesh.Compute(self.mesh, self.piece)
101 salome.sg.updateObjBrowser(1)
103 # Creates mesh group based on a geometric group
104 # --------------------
106 def Group(self, grp, name=""):
109 tgeo = geompy.GroupOp.GetType(grp)
110 if tgeo == geompy.ShapeType["VERTEX"]:
112 elif tgeo == geompy.ShapeType["EDGE"]:
114 elif tgeo == geompy.ShapeType["FACE"]:
116 elif tgeo == geompy.ShapeType["SOLID"]:
118 return self.mesh.CreateGroupFromGEOM(type, name, grp)
120 # Export mesh in a MED file
121 # --------------------
123 def ExportMED(self, filename, groups=1):
124 self.mesh.ExportMED(filename, groups)
126 MeshHexa = MeshHexaImpl