1 # CEA/LGLS 2004, Francis KLOSS (OCC)
2 # ==================================
21 smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
22 smesh.SetCurrentStudy(salome.myStudy)
23 smeshgui = salome.ImportComponentGUI("SMESH")
24 smeshgui.Init(salome.myStudyId)
28 Class MeshHexaImpl for Hexahedrical meshing
30 Examples: cube2pyGibi.py, lines 270-295
31 cube2partition.py, lines 72-83
38 def Mesh1D(self, shape, n, propagate=0):
40 Define Wires discretization.
41 Sets algorithm and hypothesis for 1D discretization of \a shape:
42 - algorithm "Regular_1D"
43 - hypothesis "NumberOfSegments" with number of segments \a n
44 \param shape Main shape or sub-shape to define wire discretization of
45 \param n Number of segments to split eash wire of the \a shape on
46 \param propagate Boolean flag. If propagate = 1,
47 "Propagation" hypothesis will be applied also to the \a shape
49 hyp1D=smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
50 smeshgui.SetName(salome.ObjectToID(hyp1D), self.name+"/WireDiscretisation/"+str(self.cpt))
51 self.mesh.AddHypothesis(shape, hyp1D)
53 hyp=smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
54 hyp.SetNumberOfSegments(n)
55 smeshgui.SetName(salome.ObjectToID(hyp), self.name+"/Segments_"+str(n)+"/"+str(self.cpt))
56 self.mesh.AddHypothesis(shape, hyp)
59 hypPro=smesh.CreateHypothesis("Propagation", "libStdMeshersEngine.so")
60 smeshgui.SetName(salome.ObjectToID(hypPro), self.name+"/Propagation/"+str(self.cpt))
61 self.mesh.AddHypothesis(shape, hypPro)
65 def __init__(self, piece, n, name):
69 Creates mesh on the shape \a piece,
70 sets GUI name of this mesh to \a name. \n
71 Sets the following global algorithms and hypotheses:
72 - for 1D discretization:
73 - algorithm "Regular_1D"
74 - hypothesis "NumberOfSegments" with number of segments \a n
75 - for 2D discretization:
76 - algorithm "Quadrangle_2D"
77 - for 3D discretization:
79 \param piece Shape to be meshed
80 \param n Global number of segments for wires discretization
81 \param name Name for mesh to be created
86 self.mesh = smesh.CreateMesh(piece)
87 smeshgui.SetName(salome.ObjectToID(self.mesh), name)
91 hyp2D=smesh.CreateHypothesis("Quadrangle_2D", "libStdMeshersEngine.so")
92 smeshgui.SetName(salome.ObjectToID(hyp2D), name+"/Quadrangle")
93 self.mesh.AddHypothesis(piece, hyp2D)
95 hyp3D=smesh.CreateHypothesis("Hexa_3D", "libStdMeshersEngine.so")
96 smeshgui.SetName(salome.ObjectToID(hyp3D), name+"/ijk")
97 self.mesh.AddHypothesis(piece, hyp3D)
99 def local(self, edge, n):
101 Creates sub-mesh of the mesh, created by constructor.
102 This sub-mesh will be created on edge \a edge.
103 Set algorithm and hypothesis for 1D discretization of the \a edge:
104 - algorithm "Regular_1D"
105 - hypothesis "NumberOfSegments" with number of segments \a n
106 \param edge Sub-edge of the main shape
107 \param n Number of segments to split the \a edge on
108 \note: \a edge will be automatically published in study under the shape, given in constructor.
110 geompy.addToStudyInFather(self.piece, edge, geompy.SubShapeName(edge, self.piece))
111 submesh = self.mesh.GetSubMesh(edge, self.name+"/SubMeshEdge/"+str(self.cpt))
114 def Propagate(self, edge, n):
116 Creates sub-mesh of the mesh, created by constructor.
117 This sub-mesh will be created on edge \a edge and propagate the hypothesis on all correspondant edges.
118 Set algorithm and hypothesis for 1D discretization of the \a edge and all other propagate edges:
119 - algorithm "Regular_1D"
120 - hypothesis "NumberOfSegments" with number of segments \a n
121 - hypothesis "Propagation"
122 \param edge Sub-edge of the main shape
123 \param n Number of segments to split the \a edge and all other propagate edges on
124 \note: \a edge will be automatically published in study under the shape, given in constructor.
126 geompy.addToStudyInFather(self.piece, edge, geompy.SubShapeName(edge, self.piece))
127 submesh = self.mesh.GetSubMesh(edge, self.name+"/SubMeshEdge/"+str(self.cpt))
128 self.Mesh1D(edge, n, 1)
132 Computes mesh, created by constructor.
134 smesh.Compute(self.mesh, self.piece)
135 salome.sg.updateObjBrowser(1)
137 def Group(self, grp, name=""):
139 Creates mesh group based on a geometric group
140 \param grp Geometric group
141 \param name Name for mesh group to be created
145 tgeo = geompy.GroupOp.GetType(grp)
146 if tgeo == geompy.ShapeType["VERTEX"]:
148 elif tgeo == geompy.ShapeType["EDGE"]:
150 elif tgeo == geompy.ShapeType["FACE"]:
152 elif tgeo == geompy.ShapeType["SOLID"]:
154 return self.mesh.CreateGroupFromGEOM(type, name, grp)
156 def ExportMED(self, filename, groups=1):
158 Export mesh in a MED file
159 \param filename Name for MED file to be created
160 \param groups Boolean flag. If groups = 1, mesh groups will be also stored in file
162 self.mesh.ExportMED(filename, groups)
164 MeshHexa = MeshHexaImpl