smesh/doc/salome/examples/modifying_meshes_ex15.py

53 lines
1.3 KiB
Python
Raw Normal View History

2013-02-12 20:37:44 +06:00
# Moving Nodes
import salome
salome.salome_init_without_session()
from salome.geom import geomBuilder
2017-06-13 15:01:10 +05:00
geompy = geomBuilder.New()
2013-02-12 20:37:44 +06:00
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
2017-06-13 15:01:10 +05:00
smesh = smeshBuilder.New()
box = geompy.MakeBoxDXDYDZ(200, 200, 200)
mesh = smesh.Mesh( box )
2013-02-12 20:37:44 +06:00
mesh.Segment().AutomaticLength(0.1)
mesh.Quadrangle()
mesh.Compute()
# find node at (0,0,0) which is located on a geom vertex
2013-02-12 20:37:44 +06:00
node000 = None
for vId in geompy.SubShapeAllIDs( box, geompy.ShapeType["VERTEX"]):
2013-02-12 20:37:44 +06:00
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")
2013-02-12 20:37:44 +06:00
# find node000 using a dedicated function
2013-02-12 20:37:44 +06:00
n = mesh.FindNodeClosestTo( -1,-1,-1 )
if not n == node000:
2017-03-20 17:27:30 +05:00
raise Exception("FindNodeClosestTo() returns " + str( n ) + " != " + str( node000 ))
2013-02-12 20:37:44 +06:00
# move node000 to a new location
x,y,z = -10, -10, -10
n = mesh.MoveNode( n,x,y,z )
if not n:
2017-03-20 17:27:30 +05:00
raise Exception("MoveNode() returns " + n)
2013-02-12 20:37:44 +06:00
# check the coordinates of the node000
xyz = mesh.GetNodeXYZ( node000 )
if not ( xyz[0] == x and xyz[1] == y and xyz[2] == z) :
2017-03-20 17:27:30 +05:00
raise Exception("Wrong coordinates: " + str( xyz ) + " != " + str( [x,y,z] ))