]> SALOME platform Git repositories - modules/hydro.git/blobdiff - src/HYDROTools/hydroGeoMeshUtils.py
Salome HOME
some functions for test scripts
[modules/hydro.git] / src / HYDROTools / hydroGeoMeshUtils.py
index ec96c526a049aff798546ff2c7f5810d2ef32172..04b31cf70ca36c5631772dc300986223be1f79d2 100644 (file)
@@ -1,8 +1,13 @@
 import sys
+import os
 import salome
 
 salome.salome_init()
 
+from HYDROPy import *
+from PyQt5.QtCore import *
+from PyQt5.QtGui import *
+
 def getChildrenInStudy(obj):
     """
     Given an object published in SALOME study (for instance a GEOM object), retreive its children.
@@ -20,3 +25,41 @@ def getChildrenInStudy(obj):
         children[itemName] = itemObj
         childIterator.Next()
     return children
+
+def importPolyline(document, shapeName, shapePath, suffix, iSpline, displayLevel):
+    """
+    """
+    shapeFile = os.path.join(shapePath, shapeName+".shp")
+    HYDROData_PolylineXY.ImportShapesFromFile(shapeFile)
+    shape = document.FindObjectByName(shapeName + suffix)
+    shapeType = 0 # polyline
+    if iSpline:
+        shapeType = 1 # polyline
+    for i in range(shape.NbSections()):
+        shape.SetSectionType(i, shapeType)
+        shape.Update()
+    shape.SetZLevel( displayLevel )
+    return shape
+
+def importBathymetry(document, bathyName, bathyPath):
+    """
+    """
+    bathy = document.CreateObject(KIND_BATHYMETRY)
+    bathy.SetName(bathyName)
+    bathy.SetAltitudesInverted(0)
+    if not(bathy.ImportFromFile( os.path.join(bathyPath, bathyName + '.xyz' ))):
+        raise ValueError('problem while loading bathymetry')
+    bathy.Update()
+    return bathy
+
+def createImmersibleZone(document, imzName, polyLine, bathy, isImmersible, displayLevel):
+    """
+    """
+    imz = document.CreateObject( KIND_IMMERSIBLE_ZONE )
+    imz.SetName( imzName )
+    imz.SetZLevel( displayLevel )
+    imz.SetAltitudeObject( bathy )
+    imz.SetPolyline( polyLine )
+    imz.SetIsSubmersible(isImmersible)
+    imz.Update()
+    return imz