Salome HOME
6d6435a61be2089176a390e2a357ac80bb03ffde
[modules/hydro.git] / doc / salome / examples / h014_caseDigueManualInterpolZ.py
1 # -*- coding: utf-8 -*-
2
3 import os
4 HYDRO_SAMPLES = os.path.join( os.environ["HYDRO_ROOT_DIR"], "bin/salome/test/HYDRO")
5
6 import sys
7 import salome
8
9 salome.salome_init()
10 theStudy = salome.myStudy
11
12 #----------------------
13 # --- HYDRO
14 #----------------------
15
16 from HYDROPy import *
17 from PyQt5.QtCore import *
18 from PyQt5.QtGui import *
19
20 hydro_doc = HYDROData_Document.Document( theStudy._get_StudyId() )
21
22 hydro_doc.SetLocalCS( 430000, 6.35e+06 )
23
24 garonne_ign_01 = hydro_doc.CreateObject( KIND_IMAGE )
25 garonne_ign_01.SetName( "garonne_ign_01" )
26
27 garonne_ign_01.SetZLevel( 0 )
28
29
30 if not(garonne_ign_01.LoadImage(os.path.join(HYDRO_SAMPLES, "garonne_ign_01.png" ))):
31   raise ValueError('problem while loading image')
32
33 garonne_ign_01.SetLocalPoints( QPoint( 40, 817 ),
34                                QPoint( 1325, 85 ) )
35
36 garonne_ign_01.SetGlobalPoints( 1,
37                                 QPointF( 471562, 6.36775e+06 ),
38                                 QPointF( 489400, 6.37702e+06 ) )
39
40 garonne_ign_01.Update()
41
42 garonne_ign_02 = hydro_doc.CreateObject( KIND_IMAGE )
43 garonne_ign_02.SetName( "garonne_ign_02" )
44
45 garonne_ign_02.SetZLevel( 1 )
46
47
48 if not(garonne_ign_02.LoadImage( os.path.join(HYDRO_SAMPLES, "garonne_ign_02.png" ))):
49   raise ValueError('problem while loading image')
50
51 garonne_ign_02.SetLocalPoints( QPoint( 1389, 447 ),
52                                QPoint( 784, 481 ) )
53
54 garonne_ign_02.SetGlobalPoints( 3,
55                                 QPointF( 631, 95 ),
56                                 QPointF( 26, 129 ) )
57 garonne_ign_02.SetTrsfReferenceImage( garonne_ign_01 )
58
59 garonne_ign_02.Update()
60
61 garonne = hydro_doc.CreateObject( KIND_POLYLINEXY )
62 garonne.SetName( "garonne" )
63
64 garonne.SetZLevel( 2 )
65
66 garonne.AddSection( "Section_1", 1, 1 )
67 garonne.AddPoint( 0, gp_XY( 38191.48, 33184.55 ) )
68 garonne.AddPoint( 0, gp_XY( 38553.78, 33013.53 ) )
69 garonne.AddPoint( 0, gp_XY( 38993.90, 32767.64 ) )
70 garonne.AddPoint( 0, gp_XY( 39678.58, 32533.58 ) )
71 garonne.AddPoint( 0, gp_XY( 40240.26, 32305.27 ) )
72 garonne.AddPoint( 0, gp_XY( 40717.94, 32193.70 ) )
73 garonne.AddPoint( 0, gp_XY( 41361.00, 32464.18 ) )
74 garonne.AddPoint( 0, gp_XY( 41831.41, 32626.69 ) )
75 garonne.AddPoint( 0, gp_XY( 41950.14, 32618.24 ) )
76 garonne.AddPoint( 0, gp_XY( 42524.97, 32419.61 ) )
77 garonne.AddPoint( 0, gp_XY( 42909.80, 32291.33 ) )
78 garonne.AddPoint( 0, gp_XY( 43177.03, 32269.95 ) )
79 garonne.AddPoint( 0, gp_XY( 43465.65, 32344.78 ) )
80 garonne.AddPoint( 0, gp_XY( 43754.27, 32152.37 ) )
81 garonne.AddPoint( 0, gp_XY( 44128.40, 31842.37 ) )
82 garonne.AddPoint( 0, gp_XY( 44003.90, 31269.93 ) )
83 garonne.AddPoint( 0, gp_XY( 44010.82, 30869.63 ) )
84 garonne.AddPoint( 0, gp_XY( 44064.26, 30655.84 ) )
85 garonne.AddPoint( 0, gp_XY( 44434.73, 30366.18 ) )
86 garonne.AddPoint( 0, gp_XY( 45208.04, 30484.81 ) )
87 garonne.AddPoint( 0, gp_XY( 45705.01, 30287.34 ) )
88 garonne.AddPoint( 0, gp_XY( 45933.89, 30046.87 ) )
89 garonne.AddPoint( 0, gp_XY( 46127.34, 29490.68 ) )
90 garonne.AddPoint( 0, gp_XY( 46111.60, 29226.08 ) )
91 garonne.AddPoint( 0, gp_XY( 46228.62, 28784.05 ) )
92 garonne.AddPoint( 0, gp_XY( 46247.64, 28449.75 ) )
93 garonne.AddPoint( 0, gp_XY( 46108.48, 28086.94 ) )
94 garonne.AddPoint( 0, gp_XY( 45618.52, 27553.74 ) )
95 garonne.AddPoint( 0, gp_XY( 45276.77, 27042.78 ) )
96 garonne.AddPoint( 0, gp_XY( 45001.89, 26273.15 ) )
97 garonne.AddPoint( 0, gp_XY( 45167.76, 25975.34 ) )
98 garonne.AddPoint( 0, gp_XY( 46018.15, 25848.84 ) )
99 garonne.AddPoint( 0, gp_XY( 46378.94, 25872.21 ) )
100 garonne.AddPoint( 0, gp_XY( 46885.57, 25937.64 ) )
101 garonne.AddPoint( 0, gp_XY( 47278.36, 25782.88 ) )
102 garonne.AddPoint( 0, gp_XY( 47153.86, 25728.04 ) )
103 garonne.AddPoint( 0, gp_XY( 46987.51, 25749.97 ) )
104 garonne.AddPoint( 0, gp_XY( 46658.26, 25715.71 ) )
105 garonne.AddPoint( 0, gp_XY( 45650.76, 25634.46 ) )
106 garonne.AddPoint( 0, gp_XY( 45122.63, 25748.21 ) )
107 garonne.AddPoint( 0, gp_XY( 44797.63, 26325.09 ) )
108 garonne.AddPoint( 0, gp_XY( 45114.51, 27168.75 ) )
109 garonne.AddPoint( 0, gp_XY( 45508.28, 27713.21 ) )
110 garonne.AddPoint( 0, gp_XY( 45994.19, 28382.53 ) )
111 garonne.AddPoint( 0, gp_XY( 45927.01, 29201.34 ) )
112 garonne.AddPoint( 0, gp_XY( 45756.39, 29859.47 ) )
113 garonne.AddPoint( 0, gp_XY( 45390.76, 30151.97 ) )
114 garonne.AddPoint( 0, gp_XY( 45039.85, 30120.84 ) )
115 garonne.AddPoint( 0, gp_XY( 44513.26, 30084.28 ) )
116 garonne.AddPoint( 0, gp_XY( 43923.42, 30426.28 ) )
117 garonne.AddPoint( 0, gp_XY( 43768.81, 30934.29 ) )
118 garonne.AddPoint( 0, gp_XY( 43820.10, 31425.20 ) )
119 garonne.AddPoint( 0, gp_XY( 43854.78, 31801.12 ) )
120 garonne.AddPoint( 0, gp_XY( 43479.64, 32053.54 ) )
121 garonne.AddPoint( 0, gp_XY( 42923.47, 32051.85 ) )
122 garonne.AddPoint( 0, gp_XY( 42493.64, 32187.97 ) )
123 garonne.AddPoint( 0, gp_XY( 42074.27, 32302.91 ) )
124 garonne.AddPoint( 0, gp_XY( 41624.75, 32330.93 ) )
125 garonne.AddPoint( 0, gp_XY( 41325.93, 32187.97 ) )
126 garonne.AddPoint( 0, gp_XY( 40879.52, 31987.29 ) )
127 garonne.AddPoint( 0, gp_XY( 40308.78, 32018.46 ) )
128 garonne.AddPoint( 0, gp_XY( 39782.86, 32207.17 ) )
129 garonne.AddPoint( 0, gp_XY( 38814.10, 32560.43 ) )
130 garonne.AddPoint( 0, gp_XY( 38302.17, 32903.70 ) )
131
132 garonne.Update()
133
134
135 domaine = hydro_doc.CreateObject( KIND_POLYLINEXY )
136 domaine.SetName( "domaine" )
137
138 domaine.SetZLevel( 3 )
139
140 domaine.AddSection( "Section_1", 0, 1 )
141 domaine.AddPoint( 0, gp_XY( 39901.15, 34762.30 ) );
142 domaine.AddPoint( 0, gp_XY( 38086.50, 29964.69 ) );
143 domaine.AddPoint( 0, gp_XY( 44835.83, 24264.97 ) );
144 domaine.AddPoint( 0, gp_XY( 46758.56, 25021.86 ) );
145 domaine.AddPoint( 0, gp_XY( 46757.20, 26601.21 ) );
146 domaine.AddPoint( 0, gp_XY( 48566.45, 30152.81 ) );
147 domaine.AddPoint( 0, gp_XY( 45532.36, 33239.83 ) );
148 domaine.AddPoint( 0, gp_XY( 43548.77, 34048.39 ) );
149
150 domaine.Update()
151
152
153 lit_majeur = hydro_doc.CreateObject( KIND_POLYLINEXY )
154 lit_majeur.SetName( "lit_majeur" )
155
156 lit_majeur.SetZLevel( 7 )
157
158 lit_majeur.AddSection( "Section_1", 1, 1 )
159 lit_majeur.AddPoint( 0, gp_XY( 41225.22, 34118.46 ) )
160 lit_majeur.AddPoint( 0, gp_XY( 41716.41, 33705.87 ) )
161 lit_majeur.AddPoint( 0, gp_XY( 42384.43, 33293.27 ) )
162 lit_majeur.AddPoint( 0, gp_XY( 42561.26, 32684.19 ) )
163 lit_majeur.AddPoint( 0, gp_XY( 42875.62, 32369.83 ) )
164 lit_majeur.AddPoint( 0, gp_XY( 43700.82, 32350.18 ) )
165 lit_majeur.AddPoint( 0, gp_XY( 44526.02, 31662.51 ) )
166 lit_majeur.AddPoint( 0, gp_XY( 45370.87, 31819.69 ) )
167 lit_majeur.AddPoint( 0, gp_XY( 46274.66, 31682.16 ) )
168 lit_majeur.AddPoint( 0, gp_XY( 46981.97, 31328.50 ) )
169 lit_majeur.AddPoint( 0, gp_XY( 47021.27, 30719.43 ) )
170 lit_majeur.AddPoint( 0, gp_XY( 47217.74, 30051.41 ) )
171 lit_majeur.AddPoint( 0, gp_XY( 47846.46, 29560.22 ) )
172 lit_majeur.AddPoint( 0, gp_XY( 48730.61, 28735.02 ) )
173 lit_majeur.AddPoint( 0, gp_XY( 48809.20, 27732.99 ) )
174 lit_majeur.AddPoint( 0, gp_XY( 49143.21, 27163.21 ) )
175 lit_majeur.AddPoint( 0, gp_XY( 49654.05, 26829.20 ) )
176 lit_majeur.AddPoint( 0, gp_XY( 49693.34, 25355.63 ) )
177 lit_majeur.AddPoint( 0, gp_XY( 48612.72, 23214.04 ) )
178 lit_majeur.AddPoint( 0, gp_XY( 47453.51, 23115.80 ) )
179 lit_majeur.AddPoint( 0, gp_XY( 46471.13, 24176.77 ) )
180 lit_majeur.AddPoint( 0, gp_XY( 45960.29, 25257.39 ) )
181 lit_majeur.AddPoint( 0, gp_XY( 44899.32, 25591.40 ) )
182 lit_majeur.AddPoint( 0, gp_XY( 44270.60, 26573.78 ) )
183 lit_majeur.AddPoint( 0, gp_XY( 43248.92, 27909.82 ) )
184 lit_majeur.AddPoint( 0, gp_XY( 42757.73, 28243.83 ) )
185 lit_majeur.AddPoint( 0, gp_XY( 42266.54, 28342.07 ) )
186 lit_majeur.AddPoint( 0, gp_XY( 41736.06, 28106.30 ) )
187 lit_majeur.AddPoint( 0, gp_XY( 41402.05, 28833.26 ) )
188 lit_majeur.AddPoint( 0, gp_XY( 40910.86, 28911.85 ) )
189 lit_majeur.AddPoint( 0, gp_XY( 40576.85, 29324.45 ) )
190 lit_majeur.AddPoint( 0, gp_XY( 40144.60, 29599.51 ) )
191 lit_majeur.AddPoint( 0, gp_XY( 39024.69, 30130.00 ) )
192 lit_majeur.AddPoint( 0, gp_XY( 38612.09, 30365.77 ) )
193 lit_majeur.AddPoint( 0, gp_XY( 38828.21, 33391.50 ) )
194
195 lit_majeur.Update()
196
197 axeDigue = hydro_doc.CreateObject( KIND_POLYLINEXY );
198 axeDigue.SetName( "axeDigue" );
199
200 axeDigue.SetZLevel( 8 );
201
202 axeDigue.AddSection( "Section_1", 1, 0 );
203 axeDigue.AddPoint( 0, gp_XY( 40961.39, 31800.95 ) );
204 axeDigue.AddPoint( 0, gp_XY( 41296.95, 31992.70 ) );
205 axeDigue.AddPoint( 0, gp_XY( 41656.48, 31872.85 ) );
206 axeDigue.AddPoint( 0, gp_XY( 42004.02, 31441.42 ) );
207 axeDigue.AddPoint( 0, gp_XY( 42123.86, 31021.97 ) );
208 axeDigue.AddPoint( 0, gp_XY( 42579.27, 30926.10 ) );
209 axeDigue.AddPoint( 0, gp_XY( 43082.60, 30638.48 ) );
210 axeDigue.AddPoint( 0, gp_XY( 43130.54, 30075.22 ) );
211 axeDigue.AddPoint( 0, gp_XY( 43538.00, 29763.63 ) );
212 axeDigue.AddPoint( 0, gp_XY( 44053.33, 29787.60 ) );
213 axeDigue.AddPoint( 0, gp_XY( 44736.43, 29847.52 ) );
214
215 axeDigue.Update();
216
217
218 Cloud_02 = hydro_doc.CreateObject( KIND_BATHYMETRY )
219 Cloud_02.SetName( "Cloud_02" )
220
221 Cloud_02.SetAltitudesInverted( 0 )
222 if not(Cloud_02.ImportFromFile( os.path.join(HYDRO_SAMPLES, "Cloud_02.xyz" ))):
223   raise ValueError('problem while loading bathymetry')
224
225 Cloud_02.Update()
226
227
228 garonne_point_L93 = hydro_doc.CreateObject( KIND_BATHYMETRY )
229 garonne_point_L93.SetName( "garonne_point_L93" )
230
231 garonne_point_L93.SetAltitudesInverted( 0 )
232 if not(garonne_point_L93.ImportFromFile( os.path.join(HYDRO_SAMPLES, "garonne_point_L93.xyz" ))):
233   raise ValueError('problem while loading bathymetry')
234
235 garonne_point_L93.Update()
236
237
238 altitudeDigue = hydro_doc.CreateObject( KIND_PROFILE );
239 altitudeDigue.SetName( "altitudeDigue" );
240
241 profile_points = [ gp_XY( 1, 23 ),
242                    gp_XY( 5000, 25.5 ) ];
243 altitudeDigue.SetParametricPoints( profile_points );
244
245 altitudeDigue.Update();
246
247
248 sectionDigue = hydro_doc.CreateObject( KIND_PROFILE );
249 sectionDigue.SetName( "sectionDigue" );
250
251 profile_points = [ gp_XY( -10, -10 ),
252                    gp_XY( -8, -1 ),
253                    gp_XY( 0, 0 ),
254                    gp_XY( 8, -1 ),
255                    gp_XY( 10, -10 ) ];
256 sectionDigue.SetParametricPoints( profile_points );
257
258 sectionDigue.Update();
259
260
261 axe3DDigue = hydro_doc.CreateObject( KIND_POLYLINE );
262 axe3DDigue.SetName( "axe3DDigue" );
263
264 axe3DDigue.SetPolylineXY( axeDigue );
265 axe3DDigue.SetProfileUZ( altitudeDigue.GetProfileUZ() );
266
267 axe3DDigue.Update();
268
269
270 litMineur = hydro_doc.CreateObject( KIND_IMMERSIBLE_ZONE )
271 litMineur.SetName( "litMineur" )
272
273 litMineur.SetZLevel( 6 )
274
275 litMineur.SetAltitudeObject( garonne_point_L93 )
276 litMineur.SetPolyline( garonne )
277
278 litMineur.Update()
279
280
281 litMajeur = hydro_doc.CreateObject( KIND_IMMERSIBLE_ZONE )
282 litMajeur.SetName( "litMajeur" )
283
284 litMajeur.SetZLevel( 5 )
285
286 litMajeur.SetFillingColor( QColor( 0, 170, 127, 255 ) )
287
288 litMajeur.SetAltitudeObject( Cloud_02 )
289 litMajeur.SetPolyline( lit_majeur )
290
291 litMajeur.Update()
292
293
294 domaineEtendu = hydro_doc.CreateObject( KIND_IMMERSIBLE_ZONE )
295 domaineEtendu.SetName( "domaineEtendu" )
296
297 domaineEtendu.SetZLevel( 4 )
298
299 domaineEtendu.SetFillingColor( QColor( 201, 203, 55, 255 ) )
300
301 domaineEtendu.SetAltitudeObject( Cloud_02 )
302 domaineEtendu.SetPolyline( domaine )
303
304 domaineEtendu.Update()
305
306
307 digue = hydro_doc.CreateObject( KIND_DIGUE );
308 digue.SetName( "digue" );
309
310 digue.SetZLevel( 9 );
311
312 digue.SetGuideLine( axe3DDigue );
313 digue.SetProfile( sectionDigue );
314 digue.SetEquiDistance( 50 );
315
316 digue.Update();
317
318
319 # Calculation case
320 garonne_2 = hydro_doc.CreateObject( KIND_CALCULATION )
321 garonne_2.SetName( "garonne_2" )
322
323 garonne_2.SetAssignmentMode( HYDROData_CalculationCase.MANUAL )
324 garonne_2.AddGeometryObject( litMineur )
325 garonne_2.AddGeometryObject( domaineEtendu )
326 garonne_2.AddGeometryObject( litMajeur )
327 garonne_2.AddGeometryObject( digue );
328
329 case_geom_group = domaineEtendu.GetGroup( 0 );
330 garonne_2.AddGeometryGroup( case_geom_group );
331 case_geom_group = litMineur.GetGroup( 0 );
332 garonne_2.AddGeometryGroup( case_geom_group );
333 case_geom_group = litMajeur.GetGroup( 0 );
334 garonne_2.AddGeometryGroup( case_geom_group );
335 case_geom_group = digue.GetGroup( 2 );
336 garonne_2.AddGeometryGroup( case_geom_group );
337 case_geom_group = digue.GetGroup( 0 );
338 garonne_2.AddGeometryGroup( case_geom_group );
339 case_geom_group = digue.GetGroup( 3 );
340 garonne_2.AddGeometryGroup( case_geom_group );
341 case_geom_group = digue.GetGroup( 1 );
342 garonne_2.AddGeometryGroup( case_geom_group );
343 garonne_2.SetBoundaryPolyline( domaine );
344
345 # Start the algorithm of the partition and assignment
346 garonne_2.Update();
347 garonne_2_litMineur = hydro_doc.FindObjectByName( "garonne_2_Reg_1" );
348 garonne_2_Zone_1 = hydro_doc.FindObjectByName( "garonne_2_Zone_1" );
349 garonne_2_Zone_1.SetMergeType( HYDROData_Zone.Merge_ZMIN )
350 garonne_2_litMineur.AddZone( garonne_2_Zone_1 );
351 garonne_2_riveDroite = hydro_doc.FindObjectByName( "garonne_2_Reg_2" );
352 garonne_2_Zone_2 = hydro_doc.FindObjectByName( "garonne_2_Zone_2" );
353 garonne_2_riveDroite.AddZone( garonne_2_Zone_2 );
354 garonne_2_Zone_3 = hydro_doc.FindObjectByName( "garonne_2_Zone_3" );
355 garonne_2_riveDroite.AddZone( garonne_2_Zone_3 );
356 garonne_2_riveGauche = hydro_doc.FindObjectByName( "garonne_2_Reg_3" );
357 garonne_2_Zone_4 = hydro_doc.FindObjectByName( "garonne_2_Zone_4" );
358 garonne_2_riveGauche.AddZone( garonne_2_Zone_4 );
359 garonne_2_Zone_5 = hydro_doc.FindObjectByName( "garonne_2_Zone_5" );
360 garonne_2_riveGauche.AddZone( garonne_2_Zone_5 );
361 garonne_2_digue = hydro_doc.FindObjectByName( "garonne_2_Reg_4" );
362 garonne_2_Zone_6 = hydro_doc.FindObjectByName( "garonne_2_Zone_6" );
363 garonne_2_Zone_6.SetMergeType( HYDROData_Zone.Merge_ZMAX )
364 garonne_2_digue.AddZone( garonne_2_Zone_6 );
365
366 garonne_2_litMineur.SetName("garonne_2_litMineur")
367 garonne_2_riveDroite.SetName("garonne_2_riveDroite")
368 garonne_2_riveGauche.SetName("garonne_2_riveGauche")
369 garonne_2_digue.SetName("garonne_2_digue")
370
371 # Export of the calculation case
372 garonne_2_entry = garonne_2.Export( theStudy._get_StudyId() )
373
374 #----------------------
375 # --- Geometry
376 #----------------------
377
378 # Get geometry shape and print debug information
379 import GEOM
380 from salome.geom import geomBuilder
381 import math
382 import SALOMEDS
383 from salome.hydrotools.controls import controlGeomProps
384
385 geompy = geomBuilder.New(theStudy)
386
387 print "Entry:", garonne_2_entry
388 HYDRO_garonne_2 = salome.IDToObject( str( garonne_2_entry ) )
389 print "Geom shape:", HYDRO_garonne_2
390 print "Geom shape name:", HYDRO_garonne_2.GetName()
391
392 [riveGauche,digue,litMineur,riveDroite] = geompy.ExtractShapes(HYDRO_garonne_2, geompy.ShapeType["FACE"], True)
393 geompy.addToStudyInFather( HYDRO_garonne_2, riveGauche, 'riveGauche' )
394 geompy.addToStudyInFather( HYDRO_garonne_2, digue, 'digue' )
395 geompy.addToStudyInFather( HYDRO_garonne_2, litMineur, 'litMineur' )
396 geompy.addToStudyInFather( HYDRO_garonne_2, riveDroite, 'riveDroite' )
397
398 SectionsGaronne = geompy.CreateGroup(HYDRO_garonne_2, geompy.ShapeType["EDGE"])
399 geompy.UnionIDs(SectionsGaronne, [4, 11])
400 geompy.addToStudyInFather( HYDRO_garonne_2, SectionsGaronne, 'SectionsGaronne' )
401
402 SectionsDigue = geompy.CreateGroup(HYDRO_garonne_2, geompy.ShapeType["EDGE"])
403 geompy.UnionIDs(SectionsDigue, [43, 48])
404 geompy.addToStudyInFather( HYDRO_garonne_2, SectionsDigue, 'SectionsDigue' )
405
406 # --- recreate subshapes already exported from HYDRO to get access from Python
407 #garonne_2_domaineEtendu_Outer = geompy.CreateGroup(HYDRO_garonne_2, geompy.ShapeType["EDGE"])
408 #geompy.UnionIDs(garonne_2_domaineEtendu_Outer, [4, 11, 17, 24, 26, 28, 14, 19, 20, 22, 31, 39, 41, 33, 35, 37])
409 #garonne_2_digue_Left_Bank = geompy.CreateGroup(HYDRO_garonne_2, geompy.ShapeType["EDGE"])
410 #geompy.UnionIDs(garonne_2_digue_Left_Bank, [43])
411 #garonne_2_digue_Outlet = geompy.CreateGroup(HYDRO_garonne_2, geompy.ShapeType["EDGE"])
412 #geompy.UnionIDs(garonne_2_digue_Outlet, [46])
413 #garonne_2_digue_Inlet = geompy.CreateGroup(HYDRO_garonne_2, geompy.ShapeType["EDGE"])
414 #geompy.UnionIDs(garonne_2_digue_Inlet, [50])
415 #garonne_2_litMineur_Outer = geompy.CreateGroup(HYDRO_garonne_2, geompy.ShapeType["EDGE"])
416 #geompy.UnionIDs(garonne_2_litMineur_Outer, [7, 9])
417 #garonne_2_digue_Right_Bank = geompy.CreateGroup(HYDRO_garonne_2, geompy.ShapeType["EDGE"])
418 #geompy.UnionIDs(garonne_2_digue_Right_Bank, [48])
419
420 controlGeomProps(geompy, riveGauche,  39490.835288, 35845737.590926)
421 controlGeomProps(geompy, digue,       10341.466108,   103090.760662)
422 controlGeomProps(geompy, litMineur,   30337.548492,  3488480.304388)
423 controlGeomProps(geompy, riveDroite,  32012.343241, 25998769.23615)
424
425 #----------------------
426 # --- Meshing
427 #----------------------
428
429 import  SMESH, SALOMEDS
430 from salome.smesh import smeshBuilder
431 from salome.hydrotools.controls import controlMeshStats, controlSubMeshStats
432
433 smesh = smeshBuilder.New(theStudy)
434
435 # --- algorithms and hypothesis
436 garonne_2 = smesh.Mesh(HYDRO_garonne_2)
437
438 NETGEN_2D = garonne_2.Triangle(algo=smeshBuilder.NETGEN_1D2D)
439 NETGEN_2D_Parameters = NETGEN_2D.Parameters()
440 NETGEN_2D_Parameters.SetMaxSize( 200 )
441 NETGEN_2D_Parameters.SetSecondOrder( 0 )
442 NETGEN_2D_Parameters.SetOptimize( 1 )
443 NETGEN_2D_Parameters.SetFineness( 4 )
444 NETGEN_2D_Parameters.SetMinSize( 50 )
445 NETGEN_2D_Parameters.SetUseSurfaceCurvature( 1 )
446 NETGEN_2D_Parameters.SetFuseEdges( 1 )
447 NETGEN_2D_Parameters.SetQuadAllowed( 0 )
448
449 algo2D_litMineur = garonne_2.Quadrangle(algo=smeshBuilder.QUAD_MA_PROJ,geom=litMineur)
450 algo1D_litMineur = garonne_2.Segment(geom=litMineur)
451 hypo1D_litMineur = algo1D_litMineur.LocalLength(100,None,1e-07)
452 subMesh_litMineur = algo1D_litMineur.GetSubMesh()
453 smesh.SetName(subMesh_litMineur, "litMineur")
454
455 algo1D_SectionsGaronne = garonne_2.Segment(geom=SectionsGaronne)
456 hypo1D_SectionsGaronne = algo1D_SectionsGaronne.NumberOfSegments(8)
457 hypo1D_SectionsGaronne.SetDistrType( 0 )
458 subMesh_SectionsGaronne = algo1D_SectionsGaronne.GetSubMesh()
459 smesh.SetName(subMesh_SectionsGaronne, "SectionsGaronne")
460
461 algo2D_digue = garonne_2.Quadrangle(algo=smeshBuilder.QUAD_MA_PROJ,geom=digue)
462 algo1D_digue = garonne_2.Segment(geom=digue)
463 hypo1D_digue = algo1D_digue.LocalLength(50,None,1e-07)
464 subMesh_digue = algo1D_digue.GetSubMesh()
465 smesh.SetName(subMesh_digue, "digue")
466
467 algo1D_SectionsDigue = garonne_2.Segment(geom=SectionsDigue)
468 hypo1D_SectionsDigue = algo1D_SectionsDigue.NumberOfSegments(4)
469 hypo1D_SectionsDigue.SetDistrType( 0 )
470 subMesh_SectionsDigue = algo1D_SectionsDigue.GetSubMesh()
471 smesh.SetName(subMesh_SectionsDigue, "SectionsDigue")
472
473 isDone = garonne_2.SetMeshOrder( [ [ subMesh_SectionsGaronne, subMesh_litMineur ], [ subMesh_SectionsDigue, subMesh_digue ]])
474
475 # --- compute mesh
476 isDone = garonne_2.Compute()
477 isDone = garonne_2.SplitQuadObject( garonne_2, 1 )
478 isDone = garonne_2.ReorientObject( garonne_2 )
479
480 # --- geometrical groups of edges
481 #garonne_2_litMineur_Outer_1 = garonne_2.GroupOnGeom(garonne_2_litMineur_Outer,'garonne_2_litMineur_Outer',SMESH.EDGE)
482 #garonne_2_domaineEtendu_Outer_1 = garonne_2.GroupOnGeom(garonne_2_domaineEtendu_Outer,'garonne_2_domaineEtendu_Outer',SMESH.EDGE)
483 #aval_1 = garonne_2.GroupOnGeom(aval,'aval',SMESH.EDGE)
484 #amont_1 = garonne_2.GroupOnGeom(amont,'amont',SMESH.EDGE)
485 #bordGaucheDomaine_1 = garonne_2.GroupOnGeom(bordGaucheDomaine,'bordGaucheDomaine',SMESH.EDGE)
486 #bordDroiteDomaine_1 = garonne_2.GroupOnGeom(bordDroiteDomaine,'bordDroiteDomaine',SMESH.EDGE)
487 SectionsGaronne_2 = garonne_2.GroupOnGeom(SectionsGaronne,'SectionsGaronne',SMESH.EDGE)
488 SectionsDigue_2 = garonne_2.GroupOnGeom(SectionsDigue,'SectionsDigue',SMESH.EDGE)
489
490 # --- geometrical groups of faces
491 riveGauche_1 = garonne_2.GroupOnGeom(riveGauche,'riveGauche',SMESH.FACE)
492 litMineur_2 = garonne_2.GroupOnGeom(litMineur,'litMineur',SMESH.FACE)
493 riveDroite_1 = garonne_2.GroupOnGeom(riveDroite,'riveDroite',SMESH.FACE)
494 digue_1 = garonne_2.GroupOnGeom(digue,'digue',SMESH.FACE)
495
496 # --- geometrical groups of nodes
497 #garonne_2_litMineur_Outer_2 = garonne_2.GroupOnGeom(garonne_2_litMineur_Outer,'garonne_2_litMineur_Outer',SMESH.NODE)
498 #garonne_2_domaineEtendu_Outer_2 = garonne_2.GroupOnGeom(garonne_2_domaineEtendu_Outer,'garonne_2_domaineEtendu_Outer',SMESH.NODE)
499 riveGauche_2 = garonne_2.GroupOnGeom(riveGauche,'riveGauche',SMESH.NODE)
500 litMineur_3 = garonne_2.GroupOnGeom(litMineur,'litMineur',SMESH.NODE)
501 riveDroite_2 = garonne_2.GroupOnGeom(riveDroite,'riveDroite',SMESH.NODE)
502 digue_2 = garonne_2.GroupOnGeom(digue,'digue',SMESH.NODE)
503 #aval_2 = garonne_2.GroupOnGeom(aval,'aval',SMESH.NODE)
504 #amont_2 = garonne_2.GroupOnGeom(amont,'amont',SMESH.NODE)
505 #bordGaucheDomaine_2 = garonne_2.GroupOnGeom(bordGaucheDomaine,'bordGaucheDomaine',SMESH.NODE)
506 #bordDroiteDomaine_2 = garonne_2.GroupOnGeom(bordDroiteDomaine,'bordDroiteDomaine',SMESH.NODE)
507 SectionsGaronne_3 = garonne_2.GroupOnGeom(SectionsGaronne,'SectionsGaronne',SMESH.NODE)
508
509
510 med_file = r'/tmp/garonne_2.med'
511
512 try:
513   os.remove(med_file)
514 except OSError:
515   pass
516
517
518 garonne_2.SetAutoColor( 1 )
519 garonne_2.ExportMED( med_file, 0, SMESH.MED_V2_2, 1, None ,1)
520
521 #controlMeshStats(garonne_2, 5247, 717, 10075)
522 #controlSubMeshStats(litMineur_2, 2384)
523 #controlSubMeshStats(riveDroite_1, 2348)
524 #controlSubMeshStats(riveGauche_1, 5343)
525 #controlSubMeshStats(digue_1, 0)
526 controlMeshStats(garonne_2, 6190, 691, 12201)
527 controlSubMeshStats(litMineur_2, 2384)
528 controlSubMeshStats(riveDroite_1, 2400)
529 controlSubMeshStats(riveGauche_1, 6585)
530 controlSubMeshStats(digue_1, 832)
531
532 if salome.sg.hasDesktop():
533   salome.sg.updateObjBrowser(1)
534
535 #----------------------
536 # --- Z interpolation with HYDRO
537 #----------------------
538
539 from salome.hydrotools.interpolZ import interpolZ, createZfield2
540 from salome.hydrotools.controls import controlStatZ
541
542 # --- case name in HYDRO
543 nomCas = 'garonne_2'
544
545 # --- med file 2D(x,y) of the case produced by SMESH
546 fichierMaillage = med_file
547
548 # --- dictionary [med group name] = region name
549 dicoGroupeRegion= dict(litMineur  = 'garonne_2_litMineur',
550                        riveDroite = 'garonne_2_riveDroite',
551                        riveGauche = 'garonne_2_riveGauche',
552                        digue      = 'garonne_2_digue',
553                        )
554 # --- value to use for Z when the node is not in a region (used to detect problems)
555 zUndef = 90
556
557 # --- Z interpolation on the bathymety/altimetry on the mesh nodes
558 statz = interpolZ(nomCas, fichierMaillage, dicoGroupeRegion, zUndef)
559 refstatz = {'riveDroite': (10.88, 32.47999954), 'riveGauche': (7.72, 71.38999939), 'litMineur': (2.06, 25.41), 'digue': (14.10,27.09)}
560 controlStatZ(statz, refstatz)
561
562 # --- add a field on nodes of type double with z values, named "BOTTOM"
563 createZfield2(fichierMaillage)