Salome HOME
Corrections of examples path after install with scbi
[modules/hydro.git] / doc / salome / examples / h034_splitShapes.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
7 import tempfile
8 tmpdir = tempfile.mkdtemp()
9 print("tmpdir=",tmpdir)
10
11 # ----------------------------------------------------------------------------------
12 # --- domain extension
13
14 import sys
15 import salome
16
17 salome.salome_init()
18
19 offsetX = 430000.
20 offsetY = 6350000.
21
22 #----------------------
23 # --- HYDRO
24 #----------------------
25
26 from HYDROPy import *
27 from PyQt5.QtCore import *
28 from PyQt5.QtGui import *
29
30 from salome.hydrotools.hydroGeoMeshUtils import importPolylines, splitShapesAll, splitShapeTool
31
32 hydro_doc = HYDROData_Document.Document()
33 hydro_doc.SetLocalCS( offsetX, offsetY )
34
35 contours = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "contour.shp"), False, 0)
36 lmajeurs = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "lmajeur.shp"), True, 0)
37 lm2s = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "lm2.shp"), True, 0)
38 openPolys = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "openPoly.shp"), False, 0)
39
40 seq = contours + lmajeurs
41 shapeList = splitShapesAll(hydro_doc, seq)
42 if len(shapeList) != 8:
43     raise ValueError("Bad nunber of shapes after splitShapesAll, found %d instead of 8"%len(shapeList))
44
45 seq2 = contours + lm2s
46 shapeList2 = splitShapesAll(hydro_doc, seq2)
47 if len(shapeList2) != 16:
48     raise ValueError("Bad nunber of shapes after splitShapesAll, found %d instead of 16"%len(shapeList2))
49
50 seq3 = contours + lm2s + lmajeurs + openPolys
51 shapeList3 = splitShapesAll(hydro_doc, seq3)
52 if len(shapeList3) != 89:
53     raise ValueError("Bad nunber of shapes after splitShapesAll, found %d instead of 89"%len(shapeList3))
54
55 shapeList4 = splitShapeTool(hydro_doc, lmajeurs[0], contours[0])
56 if len(shapeList4) != 4:
57     raise ValueError("Bad nunber of shapes after splitShapeTool, found %d instead of 4"%len(shapeList4))
58
59 if salome.sg.hasDesktop():
60   salome.sg.updateObjBrowser()