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
118 propagate the hypothesis on all correspondant edges.
119 Set algorithm and hypothesis for 1D discretization of the \a edge and all other propagate edges:
120 - algorithm "Regular_1D"
121 - hypothesis "NumberOfSegments" with number of segments \a n
122 - hypothesis "Propagation"
123 \param edge Sub-edge of the main shape
124 \param n Number of segments to split the \a edge and all other propagate edges on
125 \note: \a edge will be automatically published in study under the shape, given in constructor.
127 geompy.addToStudyInFather(self.piece, edge, geompy.SubShapeName(edge, self.piece))
128 submesh = self.mesh.GetSubMesh(edge, self.name+"/SubMeshEdge/"+str(self.cpt))
129 self.Mesh1D(edge, n, 1)
133 Computes mesh, created by constructor.
135 smesh.Compute(self.mesh, self.piece)
136 salome.sg.updateObjBrowser(1)
138 def Group(self, grp, name=""):
140 Creates mesh group based on a geometric group
141 \param grp Geometric group
142 \param name Name for mesh group to be created
146 tgeo = geompy.GroupOp.GetType(grp)
147 if tgeo == geompy.ShapeType["VERTEX"]:
149 elif tgeo == geompy.ShapeType["EDGE"]:
151 elif tgeo == geompy.ShapeType["FACE"]:
153 elif tgeo == geompy.ShapeType["SOLID"]:
155 return self.mesh.CreateGroupFromGEOM(type, name, grp)
157 def ExportMED(self, filename, groups=0):
159 Export mesh in a MED file
160 \param filename Name for MED file to be created
161 \param groups Boolean flag. If groups = 1, mesh groups will be also stored in file
163 self.mesh.ExportMED(filename, groups)
165 MeshHexa = MeshHexaImpl