]> SALOME platform Git repositories - modules/hydro.git/blob - doc/salome/examples/h008_simpleCase.py
Salome HOME
Corrections of examples path after install with scbi
[modules/hydro.git] / doc / salome / examples / h008_simpleCase.py
1 # -*- coding: utf-8 -*-
2
3 import os
4 HYDRO_SAMPLES = os.path.join( os.environ["HYDRO_ROOT_DIR"], "bin/salome/test")
5 HYDRO_TEST_RESOURCES = os.path.join(os.environ["HYDRO_DIR"], "bin", "salome", "test", "tmp_test")
6 if not os.path.isdir(HYDRO_TEST_RESOURCES):
7     os.mkdir(HYDRO_TEST_RESOURCES)
8
9 import tempfile
10 tmpdir = tempfile.mkdtemp()
11 print("tmpdir=",tmpdir)
12
13 import sys
14 import salome
15
16 salome.salome_init()
17
18 #----------------------
19 # --- HYDRO
20 #----------------------
21
22 from HYDROPy import *
23 from PyQt5.QtCore import *
24 from PyQt5.QtGui import *
25
26 from salome.hydrotools.hydroGeoMeshUtils import loadImage, GeolocaliseImageCoords, GeolocaliseImageReference
27 from salome.hydrotools.hydroGeoMeshUtils import importPolylines, importBathymetry, createImmersibleZone, mergePolylines, getChildrenInStudy
28
29 hydro_doc = HYDROData_Document.Document()
30
31 hydro_doc.SetLocalCS( 0, 0 )
32
33 simplePolylines = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "simplePolyline.shp"), True, 1)
34 imZone = createImmersibleZone(hydro_doc, "imZone", simplePolylines[0], None, True, 0)
35
36 # Calculation case
37 Case_1 = hydro_doc.CreateObject( KIND_CALCULATION )
38 Case_1.SetName( "Case_1" )
39
40 Case_1.SetAssignmentMode( HYDROData_CalculationCase.AUTOMATIC )
41 Case_1.AddGeometryObject( imZone )
42
43 case_geom_group = imZone.GetGroup( 0 );
44 Case_1.AddGeometryGroup( case_geom_group );
45 Case_1.SetBoundaryPolyline( simplePolylines[0] )
46
47 # Start the algorithm of the partition and assignment
48 Case_1.Update()
49
50 # Export of the calculation case
51 Case_1_entry = Case_1.Export()
52
53 #----------------------
54 # --- Geometry
55 #----------------------
56
57 # Get geometry shape and print debug information
58 import GEOM
59 from salome.geom import geomBuilder
60 import math
61 import SALOMEDS
62 from salome.hydrotools.controls import controlGeomProps
63
64 geompy = geomBuilder.New()
65
66 print("Entry:", Case_1_entry)
67 Case_1_geom = salome.IDToObject( str( Case_1_entry ) )
68 print("Geom shape:", Case_1_geom)
69 print("Geom shape name:", Case_1_geom.GetName())
70
71 controlGeomProps(geompy, Case_1_geom, 1218.7373973, 49578.1516521)
72
73 if salome.sg.hasDesktop():
74   salome.sg.updateObjBrowser()