Salome HOME
Merge tag 'V8_3_0a2' into ngr/python3_dev
[modules/smesh.git] / doc / salome / examples / modifying_meshes_ex15.py
index 49676d0eeaf8982c0232806bc65a1f64042a543f..efd5cfbf9b051a20e33693316dbbb31c44f7189a 100644 (file)
@@ -1,18 +1,27 @@
 # Moving Nodes
 
-from geompy import *
-from smesh import *
 
-box = MakeBoxDXDYDZ(200, 200, 200)
+import salome
+salome.salome_init()
 
-mesh = Mesh( box )
+from salome.geom import geomBuilder
+geompy = geomBuilder.New(salome.myStudy)
+
+import SMESH, SALOMEDS
+from salome.smesh import smeshBuilder
+smesh =  smeshBuilder.New(salome.myStudy)
+
+
+box = geompy.MakeBoxDXDYDZ(200, 200, 200)
+
+mesh = smesh.Mesh( box )
 mesh.Segment().AutomaticLength(0.1)
 mesh.Quadrangle()
 mesh.Compute()
 
-# find node at (0,0,0)
+# find node at (0,0,0) which is located on a geom vertex
 node000 = None
-for vId in SubShapeAllIDs( box, ShapeType["VERTEX"]):
+for vId in geompy.SubShapeAllIDs( box, geompy.ShapeType["VERTEX"]):
     if node000: break
     nodeIds = mesh.GetSubMeshNodesId( vId, True )
     for node in nodeIds:
@@ -26,18 +35,18 @@ for vId in SubShapeAllIDs( box, ShapeType["VERTEX"]):
 if not node000:
     raise "node000 not found"
 
-# find node000 using the tested function 
+# find node000 using a dedicated function 
 n = mesh.FindNodeClosestTo( -1,-1,-1 )
 if not n == node000:
-    raise "FindNodeClosestTo() returns " + str( n ) + " != " + str( 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 "MoveNode() returns " + 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 "Wrong coordinates: " + str( xyz ) + " != " + str( [x,y,z] )
+    raise Exception("Wrong coordinates: " + str( xyz ) + " != " + str( [x,y,z] ))