Salome HOME
split zone tools - disable debtrace mess in release mode
[modules/hydro.git] / src / HYDROTools / interpolZ.py
index d803355bc49c057f5a8325e2bea57168e0e54213..93daf47ba89e217ad2e0f9da190e8466626f74db 100644 (file)
@@ -156,7 +156,7 @@ from salome.smesh import smeshBuilder
 
 smesh = smeshBuilder.New(theStudy)
 
-def interpolZ(nomCas, fichierMaillage, dicoGroupeRegion, zUndef):
+def interpolZ(nomCas, fichierMaillage, dicoGroupeRegion, zUndef, interpolMethod = 0):
   """
   interpolZ takes a 2D (x,y) mesh and calls the active instance of module HYDRO
   to interpolate the bathymetry/altimetry on the mesh nodes, to produce the Z value of each node.
@@ -166,6 +166,7 @@ def interpolZ(nomCas, fichierMaillage, dicoGroupeRegion, zUndef):
   dicoGroupeRegion: python dictionary giving the coorespondance of mesh groups to HYDRO regions.
                     Key: face group name, value: region name in the HYDRO Case
   zUndef: Z value to use for nodes outside the regions (there must be none if the case is correct).
+  interpolMethod: integer value, default 0 = nearest point on bathymetry, 1 = linear interpolation
   return <fichierMaillage>Z.med : med file with Z value on nodes
   return <fichierMaillage>F.med : an exact copy of <fichierMaillage>Z.med
   """
@@ -190,6 +191,13 @@ def interpolZ(nomCas, fichierMaillage, dicoGroupeRegion, zUndef):
   ([maillagePlat], status) = smesh.CreateMeshesFromMED(fichierMaillage)
   groups = maillagePlat.GetGroups()
   
+  grpns = [grp for grp in groups if grp.GetType() == SMESH.NODE]
+  if len(grpns) == 0:
+    print "Problem! There are no groups of nodes in the mesh!"
+    print "Please create at least the groups of nodes corresponding to each region of the HYDRO case" 
+    return {}
+    
+  
   for grp in groups:
     if grp.GetType() == SMESH.NODE:
       grpName = grp.GetName()
@@ -213,7 +221,7 @@ def interpolZ(nomCas, fichierMaillage, dicoGroupeRegion, zUndef):
       #print xyz
       vx.append(xyz[0])
       vy.append(xyz[1])
-    vz = cas.GetAltitudesForPoints( vx, vy, region )
+    vz = cas.GetAltitudesForPoints( vx, vy, region, interpolMethod )
     minz = min(vz)
     maxz = max(vz)
     statz[grp.GetName()] = (minz, maxz)