3 \page tui_transforming_meshes_page Transforming Meshes
5 <br><h2>Transforming Meshes</h2>
8 \anchor tui_translation
14 smesh = SMESH_mechanic.smesh
15 mesh = SMESH_mechanic.mesh
17 # define translation vector
18 point = smesh.PointStruct(-150., -150., 0.)
19 vector =smesh.DirStruct(point)
24 mesh.Translate([], vector, doCopy)
36 smesh = SMESH_mechanic.smesh
37 mesh = SMESH_mechanic.mesh
39 # define rotation axis and angle
40 axisXYZ = smesh.AxisStruct(0., 0., 0., 5., 5., 20.)
41 angle270 = 1.5 * math.pi
44 mesh.Rotate([], axisXYZ, angle270, 1)
56 smesh = SMESH_mechanic.smesh
57 mesh = SMESH_mechanic.mesh
59 # create a symmetrical copy of the mesh mirrored through a point
60 axis = SMESH.AxisStruct(0, 0, 0, 0, 0, 0)
62 mesh.Mirror([], axis, smesh.POINT, 1)
66 \anchor tui_merging_nodes
67 <h3>Merging Nodes</h3>
71 mesh = SMESH_mechanic.mesh
76 GroupsOfNodes = mesh.FindCoincidentNodes(Tolerance)
77 mesh.MergeNodes(GroupsOfNodes)
81 \anchor tui_merging_elements
82 <h3>Merging Elements</h3>
89 # create a face to be meshed
90 px = geompy.MakeVertex(100., 0. , 0. )
91 py = geompy.MakeVertex(0. , 100., 0. )
92 pz = geompy.MakeVertex(0. , 0. , 100.)
94 vxy = geompy.MakeVector(px, py)
95 arc = geompy.MakeArc(py, pz, px)
97 wire = geompy.MakeWire([vxy, arc])
100 face1 = geompy.MakeFace(wire, isPlanarFace)
101 id_face1 = geompy.addToStudy(face1, "Face1")
103 # create a circle to be an extrusion path
104 px1 = geompy.MakeVertex( 100., 100., 0.)
105 py1 = geompy.MakeVertex(-100., -100., 0.)
106 pz1 = geompy.MakeVertex( 0., 0., 50.)
108 circle = geompy.MakeCircleThreePnt(py1, pz1, px1)
109 id_circle = geompy.addToStudy(circle, "Path")
111 # create a 2D mesh on the face
112 trias = smesh.Mesh(face1, "Face : 2D mesh")
114 algo1D = trias.Segment()
115 algo1D.NumberOfSegments(6)
116 algo2D = trias.Triangle()
117 algo2D.LengthFromEdges()
122 circlemesh = smesh.Mesh(circle, "Path mesh")
123 algo = circlemesh.Segment()
124 algo.NumberOfSegments(10)
127 # extrusion of the mesh
128 trias.ExtrusionAlongPath([], circlemesh, circle,
129 1, 0, [], 0, smesh.PointStruct(0, 0, 0))
132 print "Number of nodes before MergeNodes:",
135 array_of_nodes_groups = trias.FindCoincidentNodes(tolerance)
137 trias.MergeNodes(array_of_nodes_groups)
139 print "Number of nodes after MergeNodes:", trias.NbNodes()
141 print "Number of elements before MergeEqualElements:"
142 print "Edges : ", trias.NbEdges()
143 print "Triangles : ", trias.NbTriangles()
144 print "Quadrangles: ", trias.NbQuadrangles()
145 print "Volumes : ", trias.NbVolumes()
148 trias.MergeEqualElements()
149 print "Number of elements after MergeEqualElements:"
150 print "Edges : ", trias.NbEdges()
151 print "Triangles : ", trias.NbTriangles()
152 print "Quadrangles: ", trias.NbQuadrangles()
153 print "Volumes : ", trias.NbVolumes()
155 salome.sg.updateObjBrowser(1)
158 <br><h2>Sewing Meshes</h2>
161 \anchor tui_sew_meshes_border_to_side
162 <h3>Sew Meshes Border to Side</h3>
168 # create two faces of a box
169 box1 = geompy.MakeBox(0., 0., -10., 30., 20., 25.)
170 facesList1 = geompy.SubShapeAll(box1, geompy.ShapeType["FACE"])
171 face1 = facesList1[2]
173 box2 = geompy.MakeBox(0., 5., 0., 20., 20., 15.)
174 facesList2 = geompy.SubShapeAll(box2, geompy.ShapeType["FACE"])
175 face2 = facesList2[1]
177 edgesList = geompy.SubShapeAll(face2, geompy.ShapeType["EDGE"])
180 aComp = geompy.MakeCompound([face1, face2])
181 geompy.addToStudy(aComp, "Two faces")
183 # create a mesh on two faces
184 mesh = smesh.Mesh(aComp, "Two faces : quadrangle mesh")
186 algo1D = mesh.Segment()
187 algo1D.NumberOfSegments(9)
188 algo2D = mesh.Quadrangle()
190 algo_local = mesh.Segment(edge1)
191 algo_local.Arithmetic1D(1, 4)
192 algo_local.Propagation()
197 # FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
198 # FirstNodeIDOnSide, LastNodeIDOnSide,
199 # CreatePolygons, CreatePolyedrs
200 mesh.SewBorderToSide(5, 45, 6, 113, 109, 0, 0)
204 \anchor tui_sew_conform_free_borders
205 <h3>Sew Conform Free Borders</h3>
211 # create two faces of the box
212 box1 = geompy.MakeBox(0., 0., -10., 20., 20., 15.)
213 facesList1 = geompy.SubShapeAll(box1, geompy.ShapeType["FACE"])
214 face1 = facesList1[2]
216 box2 = geompy.MakeBox(0., 5., 0., 20., 20., 15.)
217 facesList2 = geompy.SubShapeAll(box2, geompy.ShapeType["FACE"])
218 face2 = facesList2[1]
220 edgesList = geompy.SubShapeAll(face2, geompy.ShapeType["EDGE"])
223 aComp = geompy.MakeCompound([face1, face2])
224 geompy.addToStudy(aComp, "Two faces")
226 # create a mesh on two faces
227 mesh = smesh.Mesh(aComp, "Two faces : quadrangle mesh")
229 algo1D = mesh.Segment()
230 algo1D.NumberOfSegments(9)
231 algo2D = mesh.Quadrangle()
233 algo_local = mesh.Segment(edge1)
234 algo_local.Arithmetic1D(1, 4)
235 algo_local.Propagation()
239 # sew conform free borders
240 # FirstNodeID1, SecondNodeID1, LastNodeID1, FirstNodeID2, SecondNodeID2
241 mesh.SewConformFreeBorders(5, 45, 6, 3, 24)
245 \anchor tui_sew_free_borders
246 <h3>Sew Free Borders</h3>
252 # create two faces of the box
253 box1 = geompy.MakeBox(0., 0., 0., 20., 20., 15.)
254 facesList1 = geompy.SubShapeAll(box1, geompy.ShapeType["FACE"])
255 face1 = facesList1[2]
257 box2 = geompy.MakeBox(0., 5., 0., 20., 20., 15.)
258 facesList2 = geompy.SubShapeAll(box2, geompy.ShapeType["FACE"])
259 face2 = facesList2[1]
261 edgesList = geompy.SubShapeAll(face2, geompy.ShapeType["EDGE"])
264 aComp = geompy.MakeCompound([face1, face2])
265 geompy.addToStudy(aComp, "Two faces")
267 # create a mesh on two faces
268 mesh = smesh.Mesh(aComp, "Two faces : quadrangle mesh")
270 algo1D = mesh.Segment()
271 algo1D.NumberOfSegments(4)
272 algo2D = mesh.Quadrangle()
274 algo_local = mesh.Segment(edge1)
275 algo_local.Arithmetic1D(1, 4)
276 algo_local.Propagation()
281 # FirstNodeID1, SecondNodeID1, LastNodeID1,
282 # FirstNodeID2, SecondNodeID2, LastNodeID2, CreatePolygons, CreatePolyedrs
283 mesh.SewFreeBorders(6, 21, 5, 1, 12, 3, 0, 0)
287 \anchor tui_sew_side_elements
288 <h3>Sew Side Elements</h3>
295 box1 = geompy.MakeBox(0., 0., 0., 10., 10., 10.)
296 box2 = geompy.MakeBox(0., 15., 0., 20., 25., 10.)
298 EdgesList = geompy.SubShapeAll(box2, geompy.ShapeType["EDGE"])
300 aComp = geompy.MakeCompound([box1, box2])
301 geompy.addToStudy(aComp, "Two boxes")
303 # create a mesh on two boxes
304 mesh = smesh.Mesh(aComp, "Two faces : quadrangle mesh")
306 algo1D = mesh.Segment()
307 algo1D.NumberOfSegments(2)
308 algo2D = mesh.Quadrangle()
310 algo_local = mesh.Segment(EdgesList[8])
311 algo_local.NumberOfSegments(4)
312 algo_local.Propagation()
317 # IDsOfSide1Elements, IDsOfSide2Elements,
318 # NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge, NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge
319 mesh.SewSideElements([69, 70, 71, 72], [91, 92, 89, 90], 8, 38, 23, 58)