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.
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