X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=doc%2Fexamples%2Fmodifying_meshes_ex15.py;fp=doc%2Fexamples%2Fmodifying_meshes_ex15.py;h=cd058178a4ea6dc2787a35d06837a42a773ee79c;hp=0000000000000000000000000000000000000000;hb=4cf07a14111e98e8889620ee7e6371574c31a50c;hpb=d9f4b53e489dd5857db264ede6acded7b076c9f1 diff --git a/doc/examples/modifying_meshes_ex15.py b/doc/examples/modifying_meshes_ex15.py new file mode 100644 index 000000000..cd058178a --- /dev/null +++ b/doc/examples/modifying_meshes_ex15.py @@ -0,0 +1,49 @@ +# Moving Nodes + +import salome +salome.salome_init_without_session() + +from salome.geom import geomBuilder +from salome.smesh import smeshBuilder + +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() + +box = geom_builder.MakeBoxDXDYDZ(200, 200, 200) + +mesh = smesh_builder.Mesh( box ) +mesh.Segment().AutomaticLength(0.1) +mesh.Quadrangle() +mesh.Compute() + +# find node at (0,0,0) which is located on a geom vertex +node000 = None +for vId in geom_builder.SubShapeAllIDs( box, geom_builder.ShapeType["VERTEX"]): + if node000: break + nodeIds = mesh.GetSubMeshNodesId( vId, True ) + for node in nodeIds: + xyz = mesh.GetNodeXYZ( node ) + if xyz[0] == 0 and xyz[1] == 0 and xyz[2] == 0 : + node000 = node + pass + pass + pass + +if not node000: + raise Exception("node000 not found") + +# find node000 using a dedicated function +n = mesh.FindNodeClosestTo( -1,-1,-1 ) +if not n == node000: + raise Exception("FindNodeClosestTo() returns " + str( n ) + " != " + str( node000 )) + +# move node000 to a new location +x,y,z = -10, -10, -10 +n = mesh.MoveNode( n,x,y,z ) +if not n: + raise Exception("MoveNode() returns " + n) + +# check the coordinates of the node000 +xyz = mesh.GetNodeXYZ( node000 ) +if not ( xyz[0] == x and xyz[1] == y and xyz[2] == z) : + raise Exception("Wrong coordinates: " + str( xyz ) + " != " + str( [x,y,z] ))