X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=doc%2Fsalome%2Fgui%2FSMESH%2Ftransforming_meshes.htm;h=f70f20b44b33aae9b04949a0ec8e588303e252eb;hp=6d2ada4f1d772a5f4f8ed17eceaebb9f5cbb6a9e;hb=529a4c0bfc7d5f67647141ed1ed03fe493f51802;hpb=6a3292e0719908b1e6ba7d3994fb314fa9fba71b diff --git a/doc/salome/gui/SMESH/transforming_meshes.htm b/doc/salome/gui/SMESH/transforming_meshes.htm index 6d2ada4f1..f70f20b44 100755 --- a/doc/salome/gui/SMESH/transforming_meshes.htm +++ b/doc/salome/gui/SMESH/transforming_meshes.htm @@ -10,8 +10,10 @@ h3.whs1 { margin-top:0pt; margin-bottom:0pt; } h4.whs2 { margin-top:0pt; margin-bottom:0pt; } p.whs3 { font-family:'Lucida Console' , monospace; margin-top:0pt; margin-bottom:0pt; } -p.whs4 { margin-top:0pt; margin-bottom:0pt; } +p.whs4 { margin-top:0pt; margin-bottom:0pt; font-weight:bold; color:#ff0000; } p.whs5 { margin-top:0pt; margin-bottom:0pt; font-family:'Lucida Console' , monospace; } +p.whs6 { margin-top:0pt; margin-bottom:0pt; font-family:'Times New Roman' , serif; } +p.whs7 { margin-top:0pt; margin-bottom:0pt; } --> - -
+ +-
import SMESH
+# + Attention! This script has been written using the old approach basing + on direct usage of SMESH idl interface.
-import SMESH_mechanic
+# For the moment smesh package doesn't provide + methods to translate meshes.
-+
# In the next SALOME version the scripts will + be updated to use only the commands from smesh package.
+ +-
mesh = - SMESH_mechanic.mesh
+import SMESH
-salome = SMESH_mechanic.salome
+import SMESH_mechanic
-+
-
# translate a mesh
+mesh = SMESH_mechanic.mesh
-anEditor = mesh.GetMeshEditor()
+anEditor = mesh.GetMeshEditor()
-point = SMESH.PointStruct(-150, -150, - 0)
+-
vector = SMESH.DirStruct(point)
+# define translation + vector
-anEditor.TranslateObject(mesh, vector, - 1)
+point = SMESH.PointStruct(-150., + -150., 0.)
-+
vector = SMESH.DirStruct(point)
-salome.sg.updateObjBrowser(1) -
++ +
# translate a mesh
-+
doCopy = 1
+ +anEditor.TranslateObject(mesh, + vector, doCopy)
+ +
-
import SMESH
+# + Attention! This script has been written using the old approach basing + on direct usage of SMESH idl interface.
-import SMESH_mechanic
+# For the moment smesh package doesn't provide + methods to rotate meshes.
+ +# In the next SALOME version the scripts will + be updated to use only the commands from smesh package.
-
mport math
+import math
-mesh = - SMESH_mechanic.mesh
+import SMESH
-salome = SMESH_mechanic.salome
+import SMESH_mechanic
-+
-
# rotate a mesh
+mesh = SMESH_mechanic.mesh
anEditor = mesh.GetMeshEditor()
-axisXYZ = SMESH.AxisStruct(0, 0, 0, 5, - 5, 20)
++ +
# define rotation axis + and angle
-angle180 = 1.5*math.pi
+axisXYZ = SMESH.AxisStruct(0., 0., 0., + 5., 5., 20.)
-anEditor.RotateObject(mesh, axisXYZ, angle180, - 1)
+angle270 = 1.5 * math.pi
-
salome.sg.updateObjBrowser(1)
+# rotate a mesh
-+
anEditor.RotateObject(mesh, axisXYZ, angle270, + 1)
-+
-
import SMESH
+# + Attention! This script has been written using the old approach basing + on direct usage of SMESH idl interface.
-import SMESH_mechanic
+# For the moment smesh package doesn't provide + methods to create symmetrical copies of meshes.
+ +# In the next SALOME version the scripts will + be updated to use only the commands from smesh package.
import math
-mesh = - SMESH_mechanic.mesh
+import SMESH
-salome = SMESH_mechanic.salome
+import SMESH_mechanic
-+
-
# create a symmetrical - copy of the mesh mirrored through a point
+mesh = SMESH_mechanic.mesh
anEditor = mesh.GetMeshEditor()
-anEditor.MirrorObject(mesh, SMESH.AxisStruct(0, - 0, 0, 0, 0, 0), SMESH.SMESH_MeshEditor.POINT, 1)
--
salome.sg.updateObjBrowser(1) -
+# create a symmetrical + copy of the mesh mirrored through a point
+ +axis = SMESH.AxisStruct(0, 0, 0, 0, 0, + 0)
-+
anEditor.MirrorObject(mesh, axis, SMESH.SMESH_MeshEditor.POINT, + 1)
-+
-
import SMESH
- -import SMESH_mechanic
+# + Attention! This script has been written using the old approach basing + on direct usage of SMESH idl interface.
-+
# For the moment smesh package doesn't provide + methods to merge nodes.
-smesh = - SMESH_mechanic.smesh
+# In the next SALOME version the scripts will + be updated to use only the commands from smesh package.
-mesh = - SMESH_mechanic.mesh
+-
salome = SMESH_mechanic.salome
+import SMESH_mechanic
-+
mesh = SMESH_mechanic.mesh
-# merge nodes
+-
aMeshEditor = mesh.GetMeshEditor()
+aMeshEditor = mesh.GetMeshEditor()
-Tolerance = 25.0
+-
+
# merge nodes
-GroupsOfNodes = aMeshEditor.FindCoincidentNodes(Tolerance)
+Tolerance = 25.0
-aMeshEditor.MergeNodes(GroupsOfNodes)
+-
+
GroupsOfNodes = + aMeshEditor.FindCoincidentNodes(Tolerance)
-salome.sg.updateObjBrowser(1) +
aMeshEditor.MergeNodes(GroupsOfNodes)
-+
-
# + Attention! This script has been written using the old approach basing + on direct usage of SMESH idl interface.
+ +# For the moment smesh package doesn't provide + methods to merge elements.
+ +# In the next SALOME version the scripts will + be updated to use only the commands from smesh package.
+ +
import salome
@@ -249,319 +293,512 @@ elseimport smesh
-+
import SMESH
+ +-
# create two faces of a - box
+# create a face to + be meshed
-box1 = geompy.MakeBox(0., - 0., -10., 30., 20., 25.)
+px = geompy.MakeVertex(100., + 0. , 0. + )
+ +py = geompy.MakeVertex(0. + , 100., + 0. )
-subShapeList1 = - geompy.SubShapeAll(box1, geompy.ShapeType["FACE"])
+pz = geompy.MakeVertex(0. + , 0. , + 100.)
-
box2 = geompy.MakeBox(0., - 5., 0., 20., 20., 15.)
+vxy = geompy.MakeVector(px, + py)
-subShapeList2 = - geompy.SubShapeAll(box2, geompy.ShapeType["FACE"])
+arc = geompy.MakeArc(py, + pz, px)
+ +-
EdgesList = geompy.SubShapeAll(subShapeList2[ - 1 ], geompy.ShapeType["EDGE"])
+wire = geompy.MakeWire([vxy, + arc])
+ +isPlanarFace = 1
-
aComp = geompy.MakeCompound( - [subShapeList1[ 2 ], subShapeList2[ 1 ]] )
+face1 = geompy.MakeFace(wire, + isPlanarFace)
+ +id_face1 = geompy.addToStudy(face1, + "Face1")
+ +-
idComp = geompy.addToStudy( - aComp, "Two faces" )
+# create a circle to + be an extrusion path
-aCompobj = - salome.IDToObject( idComp )
+px1 = geompy.MakeVertex( + 100., 100., + 0.)
+ +py1 = geompy.MakeVertex(-100., + -100., 0.)
+ +pz1 = geompy.MakeVertex( + 0., + 0., + 50.)
-
# create a mesh on two - faces
+circle = geompy.MakeCircleThreePnt(py1, + pz1, px1)
-+
id_circle = geompy.addToStudy(circle, + "Path")
-mesh = smesh.Mesh(aCompobj, - "Two faces : quadrangle mesh")
++ +
# create a 2D mesh + on the face
-algo = mesh.Segment()
+trias = smesh.Mesh(face1, + "Face : 2D mesh")
-
# define "NumberOfSegments" - hypothesis to cut an edge in a fixed number of segments
+algo1D = trias.Segment()
-algo.NumberOfSegments(9)
+algo1D.NumberOfSegments(6)
-+
algo2D = trias.Triangle()
-# create a quadrangle 2D - algorithm for faces
+algo2D.LengthFromEdges()
-mesh.Quadrangle()
+-
+
trias.Compute()
-# create a local hypothesis
+tri_mesh = trias.GetMesh()
-algo = mesh.Segment(EdgesList[2])
+-
+
# create a path mesh
-# define "Arithmetic1D" - hypothesis to cut an edge in several segments with increasing arithmetic - length
+circlemesh = smesh.Mesh(circle, + "Path mesh")
-algo.Arithmetic1D(1, - 4)
+algo = circlemesh.Segment()
-+
algo.NumberOfSegments(10)
-# define "Propagation" - hypothesis that propagates all other hypothesis on all edges on the opposite - side in case of quadrangular faces
+circlemesh.Compute()
-algo.Propagation()
+-
mesh.Compute()
+# extrusion of the + mesh
-+
aMeshEditor = tri_mesh.GetMeshEditor()
-# sew free borders
+aMeshEditor.ExtrusionAlongPathObject(tri_mesh, + circlemesh.GetMesh(), circle,
-anEditor = mesh.GetMesh().GetMeshEditor()
+1, + 0, [], 0, SMESH.PointStruct(0, 0, 0))
-anEditor.SewBorderToSide(5, - 45, 6, 113, 109, 0, 0)
+# merge nodes
+ +print "Number + of nodes before MergeNodes:", tri_mesh.NbNodes()
+ ++ +
tolerance = 0.001
+ +array_of_nodes_groups + = aMeshEditor.FindCoincidentNodes(tolerance)
+ +aMeshEditor.MergeNodes(array_of_nodes_groups)
+ ++ +
print "Number + of nodes after MergeNodes:", tri_mesh.NbNodes()
+ +print ""
+ +print "Number + of elements before MergeEqualElements:"
+ +print "Edges + : + ", tri_mesh.NbEdges()
+ +print "Triangles + : ", + tri_mesh.NbTriangles()
+ +print "Quadrangles: + ", tri_mesh.NbQuadrangles()
+ +print "Volumes + : + ", tri_mesh.NbVolumes()
+ ++ +
# merge elements
+ +aMeshEditor.MergeEqualElements()
+ ++ +
print "Number + of elements after MergeEqualElements:"
+ +print "Edges + : + ", tri_mesh.NbEdges()
+ +print "Triangles + : ", + tri_mesh.NbTriangles()
+ +print "Quadrangles: + ", tri_mesh.NbQuadrangles()
+ +print "Volumes + : + ", tri_mesh.NbVolumes()
-
salome.sg.updateObjBrowser(1) +
salome.sg.updateObjBrowser(1)
-+
-
import salome
+# + Attention! This script has been written using the old approach basing + on direct usage of SMESH idl interface.
+ +# For the moment smesh package doesn't provide + methods to sew meshes border to border.
+ +# In the next SALOME version the scripts will + be updated to use only the commands from smesh package.
+ +
import geompy
import smesh
-+
-
# create two faces of the - box
+# create two faces + of a box
box1 = geompy.MakeBox(0., - 0., -10., 20., 20., 15.)
+ 0., -10., 30., 20., 25.) + +facesList1 = geompy.SubShapeAll(box1, + geompy.ShapeType["FACE"])
-subShapeList1 = - geompy.SubShapeAll(box1, geompy.ShapeType["FACE"])
+face1 = facesList1[2]
box2 = geompy.MakeBox(0., 5., 0., 20., 20., 15.)
-subShapeList2 = - geompy.SubShapeAll(box2, geompy.ShapeType["FACE"])
+facesList2 = geompy.SubShapeAll(box2, + geompy.ShapeType["FACE"])
-EdgesList = geompy.SubShapeAll(subShapeList2[ - 1 ], geompy.ShapeType["EDGE"])
+face2 = facesList2[1]
-
aComp = geompy.MakeCompound( - [subShapeList1[ 2 ], subShapeList2[ 1 ]] )
+edgesList = geompy.SubShapeAll(face2, + geompy.ShapeType["EDGE"])
-idComp = geompy.addToStudy( - aComp, "Two faces" )
+edge1 = edgesList[2]
-aCompobj = - salome.IDToObject( idComp )
+-
+
aComp = geompy.MakeCompound([face1, + face2])
-# create a mesh on two - faces
+geompy.addToStudy(aComp, + "Two faces")
-mesh = smesh.Mesh(aCompobj, - "Two faces : quadrangle mesh")
+-
algo = mesh.Segment()
+# create a mesh on + two faces
-+
mesh = smesh.Mesh(aComp, + "Two faces : quadrangle mesh")
-# define "NumberOfSegments" - hypothesis to cut an edge in a fixed number of segments
+-
algo.NumberOfSegments(9)
+algo1D = mesh.Segment()
-+
algo1D.NumberOfSegments(9)
-# create a quadrangle 2D - algorithm for faces
+algo2D = mesh.Quadrangle()
-mesh.Quadrangle()
+-
+
algo_local = mesh.Segment(edge1)
-# create a local hypothesis
+algo_local.Arithmetic1D(1, + 4)
-algo = mesh.Segment(EdgesList[2])
+algo_local.Propagation()
-+
-
# define "Arithmetic1D" - hypothesis to cut an edge in several segments with increasing arithmetic - length
+mesh.Compute()
-algo.Arithmetic1D(1, - 4)
+-
+
anEditor = mesh.GetMesh().GetMeshEditor()
-# define "Propagation" - hypothesis that propagate all other hypothesis on all edges on - the opposite side in case of quadrangular faces
+-
algo.Propagation()
+# sew border to side
-mesh.Compute()
+# FirstNodeIDOnFreeBorder, + SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
-+
# FirstNodeIDOnSide, + LastNodeIDOnSide,
-# sew free borders
+# CreatePolygons, CreatePolyedrs
-anEditor = mesh.GetMesh().GetMeshEditor()
+anEditor.SewBorderToSide(5, + 45, 6, 113, 109, 0, 0)
-anEditor.SewConformFreeBorders(5, - 45, 6, 3, 24)
+salome.sg.updateObjBrowser(1) -
+# + Attention! This script has been written using the old approach basing + on direct usage of SMESH idl interface.
-+
# For the moment smesh package doesn't provide + methods to sew conform free borders.
-# In the next SALOME version the scripts will + be updated to use only the commands from smesh package.
-import salome
+
import geompy
import smesh
-+
-
# create two faces of the - box
+# create two faces + of the box
box1 = geompy.MakeBox(0., - 0., 0., 20., 20., 15.)
+ 0., -10., 20., 20., 15.) -subShapeList1 = - geompy.SubShapeAll(box1, geompy.ShapeType["FACE"])
+facesList1 = geompy.SubShapeAll(box1, + geompy.ShapeType["FACE"])
-+
face1 = facesList1[2]
+ +
box2 = geompy.MakeBox(0., 5., 0., 20., 20., 15.)
-subShapeList2 = - geompy.SubShapeAll(box2, geompy.ShapeType["FACE"])
+facesList2 = geompy.SubShapeAll(box2, + geompy.ShapeType["FACE"])
-EdgesList = geompy.SubShapeAll(subShapeList2[ - 1 ], geompy.ShapeType["EDGE"])
+face2 = facesList2[1]
-
aComp = geompy.MakeCompound( - [subShapeList1[ 2 ], subShapeList2[ 1 ]] )
+edgesList = geompy.SubShapeAll(face2, + geompy.ShapeType["EDGE"])
+ +edge1 = edgesList[2]
-idComp = geompy.addToStudy( - aComp, "Two faces" )
++ +
aComp = geompy.MakeCompound([face1, + face2])
-aCompobj = - salome.IDToObject( idComp )
+geompy.addToStudy(aComp, + "Two faces")
-
# create a mesh on two - faces
+# create a mesh on + two faces
-mesh = smesh.Mesh(aCompobj, +
mesh = smesh.Mesh(aComp, "Two faces : quadrangle mesh")
-algo = mesh.Segment()
+-
+
algo1D = mesh.Segment()
-# define "NumberOfSegments" - hypothesis to cut an edge in a fixed number of segments
+algo1D.NumberOfSegments(9)
-algo.NumberOfSegments(4)
+algo2D = mesh.Quadrangle()
-+
-
# creates a quadrangle - 2D algorithm for faces
+algo_local = mesh.Segment(edge1)
-mesh.Quadrangle()
+algo_local.Arithmetic1D(1, + 4)
-+
algo_local.Propagation()
-# create a local hypothesis
+-
algo = mesh.Segment(EdgesList[2])
+mesh.Compute()
-+
-
# define "Arithmetic1D" - hypothesis to cut an edge in several segments with increasing - arithmetic length
+anEditor = mesh.GetMesh().GetMeshEditor()
-algo.Arithmetic1D(1, - 4)
+-
+
# sew conform free + borders
-# define "Propagation" - hypothesis that propagate all other hypothesis on all edges on - the opposite side in case of quadrangular faces
+# FirstNodeID1, SecondNodeID1, + LastNodeID1, FirstNodeID2, SecondNodeID2
-algo.Propagation()
+anEditor.SewConformFreeBorders(5, + 45, 6, 3, 24)
-mesh.Compute()
++
# + Attention! This script has been written using the old approach basing + on direct usage of SMESH idl interface.
-# sew free borders
+# For the moment smesh package doesn't provide + methods to sew free borders.
-anEditor = mesh.GetMesh().GetMeshEditor()
+# In the next SALOME version the scripts will + be updated to use only the commands from smesh package.
-anEditor.SewFreeBorders(6, - 21, 5, 1, 12, 3, 0, 0)
++ +
import geompy
+ +import smesh
-
salome.sg.updateObjBrowser(1) -
+# create two faces + of the box
+ +box1 = geompy.MakeBox(0., + 0., 0., 20., 20., 15.)
+ +facesList1 = geompy.SubShapeAll(box1, + geompy.ShapeType["FACE"])
+ +face1 = facesList1[2]
+ ++ +
box2 = geompy.MakeBox(0., + 5., 0., 20., 20., 15.)
-+
facesList2 = geompy.SubShapeAll(box2, + geompy.ShapeType["FACE"])
+ +face2 = facesList2[1]
+ ++ +
edgesList = geompy.SubShapeAll(face2, + geompy.ShapeType["EDGE"])
+ +edge1 = edgesList[2]
+ ++ +
aComp = geompy.MakeCompound([face1, + face2])
+ +geompy.addToStudy(aComp, + "Two faces")
+ ++ +
# create a mesh on + two faces
+ +mesh = smesh.Mesh(aComp, + "Two faces : quadrangle mesh")
+ ++ +
algo1D = mesh.Segment()
+ +algo1D.NumberOfSegments(4)
+ +algo2D = mesh.Quadrangle()
+ ++ +
algo_local = mesh.Segment(edge1)
+ +algo_local.Arithmetic1D(1, + 4)
+ +algo_local.Propagation()
+ ++ +
mesh.Compute()
+ ++ +
# sew free borders
+ +# FirstNodeID1, SecondNodeID1, + LastNodeID1,
+ +# FirstNodeID2, SecondNodeID2, + LastNodeID2, CreatePolygons, CreatePolyedrs
+ +anEditor = mesh.GetMesh().GetMeshEditor()
+ +anEditor.SewFreeBorders(6, + 21, 5, 1, 12, 3, 0, 0)
import salome
+# + Attention! This script has been written using the old approach basing + on direct usage of SMESH idl interface.
+ +# For the moment smesh package doesn't provide + methods to sew side elements.
+ +# In the next SALOME version the scripts will + be updated to use only the commands from smesh package.
import geompy
@@ -569,8 +806,7 @@ else-
# create two faces of the - box
+# create two boxes
box1 = geompy.MakeBox(0., 0., 0., @@ -579,81 +815,64 @@ else
box2 = geompy.MakeBox(0., 15., 0., 20., 25., 10.)
++
EdgesList = geompy.SubShapeAll(box2, geompy.ShapeType["EDGE"])
-- -
aComp = geompy.MakeCompound( - [box1, box2] )
+-
idComp = geompy.addToStudy( - aComp, "Two faces" )
+aComp = geompy.MakeCompound([box1, + box2])
-aCompobj = - salome.IDToObject( idComp )
+geompy.addToStudy(aComp, + "Two boxes")
-
# create a mesh on two - faces
+# create a mesh on + two boxes
-mesh = smesh.Mesh(aCompobj, +
mesh = smesh.Mesh(aComp, "Two faces : quadrangle mesh")
-algo = mesh.Segment()
- -- -
# define "NumberOfSegments" - hypothesis to cut an edge in a fixed number of segments
- -algo.NumberOfSegments(2)
- -+
-
# create a quadrangle 2D - algorithm for faces
+algo1D = mesh.Segment()
-mesh.Quadrangle()
+algo1D.NumberOfSegments(2)
-+
algo2D = mesh.Quadrangle()
-# create a local hypothesis
+-
algo = mesh.Segment(EdgesList[8])
+algo_local = mesh.Segment(EdgesList[8])
-+
algo_local.NumberOfSegments(4)
-# define "Arithmetic1D" - hypothesis to cut an edge in several segments with increasing arithmetic - length
+algo_local.Propagation()
-algo.NumberOfSegments(4)
+-
+
mesh.Compute()
-# define "Propagation" - hypothesis that propagates all other hypothesis on all edges on the opposite side in case - of quadrangular faces
+-
algo.Propagation()
+anEditor = mesh.GetMesh().GetMeshEditor()
-mesh.Compute()
+-
+
# sew side elements
-# sew free borders
+# IDsOfSide1Elements, + IDsOfSide2Elements,
-anEditor = mesh.GetMesh().GetMeshEditor()
+# NodeID1OfSide1ToMerge, + NodeID1OfSide2ToMerge, NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge
anEditor.SewSideElements([69, 70, 71, 72], [91, 92, 89, 90], 8, 38, 23, 58)
-salome.sg.updateObjBrowser(1) -
-