]> SALOME platform Git repositories - modules/hydro.git/blob - doc/salome/examples/h018_streamInterpolation.py
Salome HOME
porting tutorial scripts on SALOME 8.2.0
[modules/hydro.git] / doc / salome / examples / h018_streamInterpolation.py
1 # -*- coding: utf-8 -*-
2
3 ###
4 ### This file is generated automatically by SALOME v7.8.0 with dump python functionality
5 ###
6
7 import sys
8 import salome
9 import os
10 HYDRO_SAMPLES = os.path.join( os.environ["HYDRO_ROOT_DIR"], "bin/salome/test/HYDRO")
11
12
13
14 salome.salome_init()
15 theStudy = salome.myStudy
16
17 import salome_notebook
18 notebook = salome_notebook.NoteBook(theStudy)
19 #sys.path.insert( 0, r'/local00/home/B27118/projets/salome_hydro/bugs/V780H2016')
20
21 ###
22 ### HYDRO component
23 ###
24
25 from HYDROPy import *
26 from PyQt5.QtCore import *
27 from PyQt5.QtGui import *
28
29 hydro_doc = HYDROData_Document.Document( theStudy._get_StudyId() )
30
31 hydro_doc.SetLocalCS( 0.000, 0.000 )
32
33 Strickler_table_1 = hydro_doc.CreateObject( KIND_STRICKLER_TABLE )
34 Strickler_table_1.SetName( "Strickler table_1" )
35
36 Strickler_table_1.SetAttrName( "CODE_06" )
37
38 Strickler_table_1.Set( u"Pelouses et pâturages naturels", 1.0321 )
39 Strickler_table_1.SetAttrValue( u"Pelouses et pâturages naturels", "321" )
40 Strickler_table_1.SetColor( u"Pelouses et pâturages naturels", QColor( 204, 242, 77 ) )
41
42 Strickler_table_1.Set( u"Aéroports", 1.0124 )
43 Strickler_table_1.SetAttrValue( u"Aéroports", "124" )
44 Strickler_table_1.SetColor( u"Aéroports", QColor( 230, 204, 230 ) )
45
46 Strickler_table_1.Set( u"Systèmes culturaux et parcellaires complexes", 1.0242 )
47 Strickler_table_1.SetAttrValue( u"Systèmes culturaux et parcellaires complexes", "242" )
48 Strickler_table_1.SetColor( u"Systèmes culturaux et parcellaires complexes", QColor( 255, 230, 77 ) )
49
50 Strickler_table_1.Set( u"Cultures annuelles associées à des cultures permanentes", 1.0241 )
51 Strickler_table_1.SetAttrValue( u"Cultures annuelles associées à des cultures permanentes", "241" )
52 Strickler_table_1.SetColor( u"Cultures annuelles associées à des cultures permanentes", QColor( 255, 230, 166 ) )
53
54 Strickler_table_1.Set( u"Forêt et végétation arbustive en mutation", 1.0324 )
55 Strickler_table_1.SetAttrValue( u"Forêt et végétation arbustive en mutation", "324" )
56 Strickler_table_1.SetColor( u"Forêt et végétation arbustive en mutation", QColor( 166, 242, 0 ) )
57
58 Strickler_table_1.Set( u"Décharges", 1.0132 )
59 Strickler_table_1.SetAttrValue( u"Décharges", "132" )
60 Strickler_table_1.SetColor( u"Décharges", QColor( 166, 77, 0 ) )
61
62 Strickler_table_1.Set( u"Végétation clairsemée", 1.0333 )
63 Strickler_table_1.SetAttrValue( u"Végétation clairsemée", "333" )
64 Strickler_table_1.SetColor( u"Végétation clairsemée", QColor( 204, 255, 204 ) )
65
66 Strickler_table_1.Set( u"Prairies et autres surfaces toujours en herbe à usage agricole", 1.0231 )
67 Strickler_table_1.SetAttrValue( u"Prairies et autres surfaces toujours en herbe à usage agricole", "231" )
68 Strickler_table_1.SetColor( u"Prairies et autres surfaces toujours en herbe à usage agricole", QColor( 230, 230, 77 ) )
69
70 Strickler_table_1.Set( u"Périmètres irrigués en permanence", 1.0212 )
71 Strickler_table_1.SetAttrValue( u"Périmètres irrigués en permanence", "212" )
72 Strickler_table_1.SetColor( u"Périmètres irrigués en permanence", QColor( 255, 255, 0 ) )
73
74 Strickler_table_1.Set( u"Plans d'eau", 1.0512 )
75 Strickler_table_1.SetAttrValue( u"Plans d'eau", "512" )
76 Strickler_table_1.SetColor( u"Plans d'eau", QColor( 128, 242, 230 ) )
77
78 Strickler_table_1.Set( u"Territoires agroforestiers", 1.0244 )
79 Strickler_table_1.SetAttrValue( u"Territoires agroforestiers", "244" )
80 Strickler_table_1.SetColor( u"Territoires agroforestiers", QColor( 242, 204, 166 ) )
81
82 Strickler_table_1.Set( u"Forêts mélangées", 1.0313 )
83 Strickler_table_1.SetAttrValue( u"Forêts mélangées", "313" )
84 Strickler_table_1.SetColor( u"Forêts mélangées", QColor( 77, 255, 0 ) )
85
86 Strickler_table_1.Set( u"Glaciers et neiges éternelles", 1.0335 )
87 Strickler_table_1.SetAttrValue( u"Glaciers et neiges éternelles", "335" )
88 Strickler_table_1.SetColor( u"Glaciers et neiges éternelles", QColor( 166, 230, 204 ) )
89
90 Strickler_table_1.Set( u"Plages, dunes et sable", 1.0331 )
91 Strickler_table_1.SetAttrValue( u"Plages, dunes et sable", "331" )
92 Strickler_table_1.SetColor( u"Plages, dunes et sable", QColor( 230, 230, 230 ) )
93
94 Strickler_table_1.Set( u"Zones incendiées", 1.0334 )
95 Strickler_table_1.SetAttrValue( u"Zones incendiées", "334" )
96 Strickler_table_1.SetColor( u"Zones incendiées", QColor( 0, 0, 0 ) )
97
98 Strickler_table_1.Set( u"Tissu urbain continu", 1.0111 )
99 Strickler_table_1.SetAttrValue( u"Tissu urbain continu", "111" )
100 Strickler_table_1.SetColor( u"Tissu urbain continu", QColor( 230, 0, 77 ) )
101
102 Strickler_table_1.Set( u"Chantiers", 1.0133 )
103 Strickler_table_1.SetAttrValue( u"Chantiers", "133" )
104 Strickler_table_1.SetColor( u"Chantiers", QColor( 255, 77, 255 ) )
105
106 Strickler_table_1.Set( u"Estuaires", 1.0522 )
107 Strickler_table_1.SetAttrValue( u"Estuaires", "522" )
108 Strickler_table_1.SetColor( u"Estuaires", QColor( 166, 255, 230 ) )
109
110 Strickler_table_1.Set( u"Marais maritimes", 1.0421 )
111 Strickler_table_1.SetAttrValue( u"Marais maritimes", "421" )
112 Strickler_table_1.SetColor( u"Marais maritimes", QColor( 204, 204, 255 ) )
113
114 Strickler_table_1.Set( u"Forêts de conifères", 1.0312 )
115 Strickler_table_1.SetAttrValue( u"Forêts de conifères", "312" )
116 Strickler_table_1.SetColor( u"Forêts de conifères", QColor( 0, 166, 0 ) )
117
118 Strickler_table_1.Set( u"Surfaces essentiellement agricoles, interrompues par des espaces naturels importants", 1.0243 )
119 Strickler_table_1.SetAttrValue( u"Surfaces essentiellement agricoles, interrompues par des espaces naturels importants", "243" )
120 Strickler_table_1.SetColor( u"Surfaces essentiellement agricoles, interrompues par des espaces naturels importants", QColor( 230, 204, 77 ) )
121
122 Strickler_table_1.Set( u"Tourbières", 1.0412 )
123 Strickler_table_1.SetAttrValue( u"Tourbières", "412" )
124 Strickler_table_1.SetColor( u"Tourbières", QColor( 77, 77, 255 ) )
125
126 Strickler_table_1.Set( u"Extraction de matériaux", 1.0131 )
127 Strickler_table_1.SetAttrValue( u"Extraction de matériaux", "131" )
128 Strickler_table_1.SetColor( u"Extraction de matériaux", QColor( 166, 0, 204 ) )
129
130 Strickler_table_1.Set( u"Réseaux routier et ferroviaire et espaces associés", 1.0122 )
131 Strickler_table_1.SetAttrValue( u"Réseaux routier et ferroviaire et espaces associés", "122" )
132 Strickler_table_1.SetColor( u"Réseaux routier et ferroviaire et espaces associés", QColor( 204, 0, 0 ) )
133
134 Strickler_table_1.Set( u"Mers et océans", 1.0523 )
135 Strickler_table_1.SetAttrValue( u"Mers et océans", "523" )
136 Strickler_table_1.SetColor( u"Mers et océans", QColor( 230, 242, 255 ) )
137
138 Strickler_table_1.Set( u"Equipements sportifs et de loisirs", 1.0142 )
139 Strickler_table_1.SetAttrValue( u"Equipements sportifs et de loisirs", "142" )
140 Strickler_table_1.SetColor( u"Equipements sportifs et de loisirs", QColor( 255, 230, 255 ) )
141
142 Strickler_table_1.Set( u"Forêts de feuillus", 1.0311 )
143 Strickler_table_1.SetAttrValue( u"Forêts de feuillus", "311" )
144 Strickler_table_1.SetColor( u"Forêts de feuillus", QColor( 128, 255, 0 ) )
145
146 Strickler_table_1.Set( u"Vergers et petits fruits", 1.0222 )
147 Strickler_table_1.SetAttrValue( u"Vergers et petits fruits", "222" )
148 Strickler_table_1.SetColor( u"Vergers et petits fruits", QColor( 242, 166, 77 ) )
149
150 Strickler_table_1.Set( u"Végétation sclérophylle", 1.0323 )
151 Strickler_table_1.SetAttrValue( u"Végétation sclérophylle", "323" )
152 Strickler_table_1.SetColor( u"Végétation sclérophylle", QColor( 166, 230, 77 ) )
153
154 Strickler_table_1.Set( u"Landes et broussailles", 1.0322 )
155 Strickler_table_1.SetAttrValue( u"Landes et broussailles", "322" )
156 Strickler_table_1.SetColor( u"Landes et broussailles", QColor( 166, 255, 128 ) )
157
158 Strickler_table_1.Set( u"Tissu urbain discontinu", 1.0112 )
159 Strickler_table_1.SetAttrValue( u"Tissu urbain discontinu", "112" )
160 Strickler_table_1.SetColor( u"Tissu urbain discontinu", QColor( 255, 0, 0 ) )
161
162 Strickler_table_1.Set( u"Cours et voies d'eau", 1.0511 )
163 Strickler_table_1.SetAttrValue( u"Cours et voies d'eau", "511" )
164 Strickler_table_1.SetColor( u"Cours et voies d'eau", QColor( 0, 204, 242 ) )
165
166 Strickler_table_1.Set( u"Oliveraies", 1.0223 )
167 Strickler_table_1.SetAttrValue( u"Oliveraies", "223" )
168 Strickler_table_1.SetColor( u"Oliveraies", QColor( 230, 166, 0 ) )
169
170 Strickler_table_1.Set( u"Vignobles", 1.0221 )
171 Strickler_table_1.SetAttrValue( u"Vignobles", "221" )
172 Strickler_table_1.SetColor( u"Vignobles", QColor( 230, 128, 0 ) )
173
174 Strickler_table_1.Set( u"Rizières", 1.0213 )
175 Strickler_table_1.SetAttrValue( u"Rizières", "213" )
176 Strickler_table_1.SetColor( u"Rizières", QColor( 230, 230, 0 ) )
177
178 Strickler_table_1.Set( u"Zones portuaires", 1.0123 )
179 Strickler_table_1.SetAttrValue( u"Zones portuaires", "123" )
180 Strickler_table_1.SetColor( u"Zones portuaires", QColor( 230, 204, 204 ) )
181
182 Strickler_table_1.Set( u"Zones industrielles ou commerciales et installations publiques", 1.0121 )
183 Strickler_table_1.SetAttrValue( u"Zones industrielles ou commerciales et installations publiques", "121" )
184 Strickler_table_1.SetColor( u"Zones industrielles ou commerciales et installations publiques", QColor( 204, 77, 242 ) )
185
186 Strickler_table_1.Set( u"Marais salants", 1.0422 )
187 Strickler_table_1.SetAttrValue( u"Marais salants", "422" )
188 Strickler_table_1.SetColor( u"Marais salants", QColor( 230, 230, 255 ) )
189
190 Strickler_table_1.Set( u"Marais intérieurs", 1.0411 )
191 Strickler_table_1.SetAttrValue( u"Marais intérieurs", "411" )
192 Strickler_table_1.SetColor( u"Marais intérieurs", QColor( 166, 166, 255 ) )
193
194 Strickler_table_1.Set( u"Espaces verts urbains", 1.0141 )
195 Strickler_table_1.SetAttrValue( u"Espaces verts urbains", "141" )
196 Strickler_table_1.SetColor( u"Espaces verts urbains", QColor( 255, 166, 255 ) )
197
198 Strickler_table_1.Set( u"Lagunes littorales", 1.0521 )
199 Strickler_table_1.SetAttrValue( u"Lagunes littorales", "521" )
200 Strickler_table_1.SetColor( u"Lagunes littorales", QColor( 0, 255, 166 ) )
201
202 Strickler_table_1.Set( u"Roches nues", 1.0332 )
203 Strickler_table_1.SetAttrValue( u"Roches nues", "332" )
204 Strickler_table_1.SetColor( u"Roches nues", QColor( 204, 204, 204 ) )
205
206 Strickler_table_1.Set( u"Terres arables hors périmètres d'irrigation", 1.0211 )
207 Strickler_table_1.SetAttrValue( u"Terres arables hors périmètres d'irrigation", "211" )
208 Strickler_table_1.SetColor( u"Terres arables hors périmètres d'irrigation", QColor( 255, 255, 168 ) )
209
210 Strickler_table_1.Set( u"Zones intertidales", 1.0423 )
211 Strickler_table_1.SetAttrValue( u"Zones intertidales", "423" )
212 Strickler_table_1.SetColor( u"Zones intertidales", QColor( 166, 166, 230 ) )
213
214
215 Strickler_table_1.Update()
216
217 axe = hydro_doc.CreateObject( KIND_POLYLINEXY )
218 axe.SetName( "axe" )
219
220 axe.SetZLevel( 0 )
221
222 axe.AddSection( "Section_1", 1, 0 )
223 axe.AddPoint( 0, gp_XY( 107.09, -10.91 ) )
224 axe.AddPoint( 0, gp_XY( 102.60, 39.37 ) )
225 axe.AddPoint( 0, gp_XY( 70.28, 83.06 ) )
226 axe.AddPoint( 0, gp_XY( 28.39, 106.10 ) )
227 axe.AddPoint( 0, gp_XY( -14.11, 109.99 ) )
228
229 axe.Update()
230
231
232 domain = hydro_doc.CreateObject( KIND_POLYLINEXY )
233 domain.SetName( "domain" )
234
235 domain.SetZLevel( 3 )
236
237 domain.AddSection( "Section_1", 0, 1 )
238 domain.AddPoint( 0, gp_XY( 0.46, 0.37 ) )
239 domain.AddPoint( 0, gp_XY( 125.71, 0.18 ) )
240 domain.AddPoint( 0, gp_XY( 109.60, 112.58 ) )
241 domain.AddPoint( 0, gp_XY( 1.03, 123.51 ) )
242
243 domain.Update()
244
245
246 bathyFlat = hydro_doc.CreateObject( KIND_BATHYMETRY )
247 bathyFlat.SetName( "bathyFlat" )
248
249 bathyFlat.SetAltitudesInverted( 0 )
250 if not(bathyFlat.ImportFromFile( os.path.join(HYDRO_SAMPLES, "bathyFlat.xyz" ))):
251   raise ValueError('problem while loading bathymetry')
252
253 bathyFlat.Update()
254
255 profiles = hydro_doc.CreateObject( KIND_PROFILE )
256 profiles.SetName( "profiles" )
257 badProfilesIds=[]
258 isToProject=True
259 nbp = profiles.ImportFromFile(hydro_doc, os.path.join(HYDRO_SAMPLES, "profilsStream.xyz"), badProfilesIds, isToProject)
260 print "nombre profils: " , nbp
261 if not(nbp):
262   raise ValueError('problem while loading profiles')
263 #profiles.Update()
264
265 nomsprofs = ["Profile_%d"%i for i in range(1,nbp+1)]
266 seqProfs = hydro_doc.FindObjectsByNames(nomsprofs)
267
268
269 plaine = hydro_doc.CreateObject( KIND_IMMERSIBLE_ZONE )
270 plaine.SetName( "plaine" )
271
272 plaine.SetZLevel( 1 )
273
274 plaine.SetFillingColor( QColor( 185, 171, 101, 255 ) )
275
276 plaine.SetAltitudeObject( bathyFlat )
277 plaine.SetPolyline( domain )
278
279 plaine.Update()
280
281
282 Stream_1 = hydro_doc.CreateObject( KIND_STREAM )
283 Stream_1.SetName( "Stream_1" )
284
285 Stream_1.SetZLevel( 2 )
286
287 Stream_1.SetHydraulicAxis( axe )
288 for profil in seqProfs:
289   Stream_1.AddProfile(profil)
290
291 Stream_1.SetDDZ( 0.200 )
292 Stream_1.SetSpatialStep( 0.5 )
293
294 Stream_1.Update()
295
296
297 # Calculation case
298 Case_1 = hydro_doc.CreateObject( KIND_CALCULATION )
299 Case_1.SetName( "Case_1" )
300
301 Case_1.SetAssignmentMode( HYDROData_CalculationCase.MANUAL )
302 Case_1.AddGeometryObject( plaine )
303 Case_1.AddGeometryObject( Stream_1 )
304
305 case_geom_group = plaine.GetGroup( 0 )
306 Case_1.AddGeometryGroup( case_geom_group )
307 case_geom_group = Stream_1.GetGroup( 2 )
308 Case_1.AddGeometryGroup( case_geom_group )
309 case_geom_group = Stream_1.GetGroup( 0 )
310 Case_1.AddGeometryGroup( case_geom_group )
311 case_geom_group = Stream_1.GetGroup( 3 )
312 Case_1.AddGeometryGroup( case_geom_group )
313 case_geom_group = Stream_1.GetGroup( 1 )
314 Case_1.AddGeometryGroup( case_geom_group )
315 Case_1.SetBoundaryPolyline( domain )
316 Case_1.SetStricklerTable( Strickler_table_1 )
317
318 # Start the algorithm of the partition and assignment
319 Case_1.Update()
320 riveGauche = hydro_doc.FindObjectByName( "Case_1_Reg_1" )
321 Case_1_Zone_1 = hydro_doc.FindObjectByName( "Case_1_Zone_1" )
322 Case_1_Zone_1.SetColor( QColor( 156, 192, 64 ))
323 riveGauche.AddZone( Case_1_Zone_1 )
324 litMineur = hydro_doc.FindObjectByName( "Case_1_Reg_2" )
325 Case_1_Zone_2 = hydro_doc.FindObjectByName( "Case_1_Zone_2" )
326 Case_1_Zone_2.SetMergeType( HYDROData_Zone.Merge_Object )
327 Stream_1_Altitude_1 = hydro_doc.FindObjectByName( "Stream_1_Altitude_1" )
328 Case_1_Zone_2.SetMergeObject( Stream_1_Altitude_1 )
329 Case_1_Zone_2.SetColor( QColor( 64, 75, 192 ))
330 litMineur.AddZone( Case_1_Zone_2 )
331 riveDroite = hydro_doc.FindObjectByName( "Case_1_Reg_3" )
332 Case_1_Zone_3 = hydro_doc.FindObjectByName( "Case_1_Zone_3" )
333 Case_1_Zone_3.SetColor( QColor( 192, 109, 64 ))
334 riveDroite.AddZone( Case_1_Zone_3 )
335 riveGauche.SetName( "riveGauche" )
336 litMineur.SetName( "litMineur" )
337 riveDroite.SetName( "riveDroite" )
338
339 # Export of the calculation case
340 Case_1_entry = Case_1.Export( theStudy._get_StudyId() )
341
342 # Get geometry shape and print debug information
343 import GEOM
344 print "Entry:", Case_1_entry
345 HYDRO_Case_1 = salome.IDToObject( str( Case_1_entry ) )
346 print "Geom shape:", HYDRO_Case_1
347 print "Geom shape name:", HYDRO_Case_1.GetName()
348
349
350 ###
351 ### GEOM component
352 ###
353
354 import GEOM
355 from salome.geom import geomBuilder
356 import math
357 import SALOMEDS
358
359
360 geompy = geomBuilder.New(theStudy)
361
362 #geomObj_1 = geompy.RestoreShape("") # the shape string has not been dump for performance reason
363 #[geomObj_2,geomObj_3,geomObj_4] = geompy.SubShapeAll(geomObj_1, geompy.ShapeType["FACE"])
364 geomObj_5 = geompy.CreateGroup(geomObj_1, geompy.ShapeType["EDGE"])
365 geompy.UnionIDs(geomObj_5, [4, 12, 19, 23, 25, 21, 14, 9])
366 HYDRO_Case_1 = geompy.RestoreShape("") # the shape string has not been dump for performance reason
367 [riveGauche,litMineur,riveDroite] = geompy.SubShapeAll(HYDRO_Case_1, geompy.ShapeType["FACE"])
368 #listSubShapeIDs = geompy.SubShapeAllIDs(HYDRO_Case_1, geompy.ShapeType["VERTEX"])
369 #listSubShapeIDs = geompy.SubShapeAllIDs(HYDRO_Case_1, geompy.ShapeType["VERTEX"])
370 #listSubShapeIDs = geompy.SubShapeAllIDs(HYDRO_Case_1, geompy.ShapeType["EDGE"])
371 #listSubShapeIDs = geompy.SubShapeAllIDs(HYDRO_Case_1, geompy.ShapeType["EDGE"])
372 #listSubShapeIDs = geompy.SubShapeAllIDs(HYDRO_Case_1, geompy.ShapeType["EDGE"])
373 #listSubShapeIDs = geompy.SubShapeAllIDs(HYDRO_Case_1, geompy.ShapeType["EDGE"])
374 #listSubShapeIDs = geompy.SubShapeAllIDs(HYDRO_Case_1, geompy.ShapeType["EDGE"])
375 #listSubShapeIDs = geompy.SubShapeAllIDs(HYDRO_Case_1, geompy.ShapeType["EDGE"])
376 #listSubShapeIDs = geompy.SubShapeAllIDs(HYDRO_Case_1, geompy.ShapeType["EDGE"])
377 #listSubShapeIDs = geompy.SubShapeAllIDs(HYDRO_Case_1, geompy.ShapeType["EDGE"])
378 #listSubShapeIDs = geompy.SubShapeAllIDs(HYDRO_Case_1, geompy.ShapeType["EDGE"])
379 #listSubShapeIDs = geompy.SubShapeAllIDs(HYDRO_Case_1, geompy.ShapeType["EDGE"])
380 #listSubShapeIDs = geompy.SubShapeAllIDs(HYDRO_Case_1, geompy.ShapeType["EDGE"])
381 #listSubShapeIDs = geompy.SubShapeAllIDs(HYDRO_Case_1, geompy.ShapeType["EDGE"])
382 #listSubShapeIDs = geompy.SubShapeAllIDs(HYDRO_Case_1, geompy.ShapeType["EDGE"])
383 Case_1_plaine_Outer = geompy.CreateGroup(HYDRO_Case_1, geompy.ShapeType["EDGE"])
384 geompy.UnionIDs(Case_1_plaine_Outer, [4, 12, 19, 23, 25, 21, 14, 9])
385 sections = geompy.CreateGroup(HYDRO_Case_1, geompy.ShapeType["EDGE"])
386 geompy.UnionIDs(sections, [14, 12])
387 geompy.addToStudy( HYDRO_Case_1, 'HYDRO_Case_1' )
388 geompy.addToStudyInFather( HYDRO_Case_1, riveGauche, 'riveGauche' )
389 geompy.addToStudyInFather( HYDRO_Case_1, litMineur, 'litMineur' )
390 geompy.addToStudyInFather( HYDRO_Case_1, riveDroite, 'riveDroite' )
391 geompy.addToStudyInFather( HYDRO_Case_1, Case_1_plaine_Outer, 'Case_1_plaine_Outer' )
392 geompy.addToStudyInFather( HYDRO_Case_1, sections, 'sections' )
393
394 ###
395 ### SMESH component
396 ###
397
398 import  SMESH, SALOMEDS
399 from salome.smesh import smeshBuilder
400
401 smesh = smeshBuilder.New(theStudy)
402 plaine = smesh.Mesh(HYDRO_Case_1)
403 NETGEN_2D = plaine.Triangle(algo=smeshBuilder.NETGEN_1D2D)
404 NETGEN_2D_Parameters_1 = NETGEN_2D.Parameters()
405 NETGEN_2D_Parameters_1.SetMaxSize( 10 )
406 NETGEN_2D_Parameters_1.SetSecondOrder( 0 )
407 NETGEN_2D_Parameters_1.SetOptimize( 1 )
408 NETGEN_2D_Parameters_1.SetFineness( 3 )
409 NETGEN_2D_Parameters_1.SetMinSize( 1 )
410 NETGEN_2D_Parameters_1.SetUseSurfaceCurvature( 1 )
411 NETGEN_2D_Parameters_1.SetFuseEdges( 1 )
412 NETGEN_2D_Parameters_1.SetQuadAllowed( 0 )
413 Regular_1D = plaine.Segment(geom=litMineur)
414 litMineur_1 = Regular_1D.GetSubMesh()
415 Local_Length_1 = Regular_1D.LocalLength(3,None,1e-07)
416 QuadFromMedialAxis_1D2D = plaine.Quadrangle(algo=smeshBuilder.QUAD_MA_PROJ,geom=litMineur)
417 Regular_1D_1 = plaine.Segment(geom=sections)
418 sections_1 = Regular_1D_1.GetSubMesh()
419 Nb_Segments_1 = Regular_1D_1.NumberOfSegments(20)
420 isDone = plaine.SetMeshOrder( [ [ sections_1, litMineur_1 ] ])
421
422 isDone = plaine.Compute()
423 isDone = plaine.SplitQuadObject( plaine, 1 )
424
425 riveGauche_1 = plaine.GroupOnGeom(riveGauche,'riveGauche',SMESH.FACE)
426 litMineur_2 = plaine.GroupOnGeom(litMineur,'litMineur',SMESH.FACE)
427 riveDroite_1 = plaine.GroupOnGeom(riveDroite,'riveDroite',SMESH.FACE)
428 Case_1_plaine_Outer_1 = plaine.GroupOnGeom(Case_1_plaine_Outer,'Case_1_plaine_Outer',SMESH.EDGE)
429 sections_2 = plaine.GroupOnGeom(sections,'sections',SMESH.EDGE)
430 riveGauche_2 = plaine.GroupOnGeom(riveGauche,'riveGauche',SMESH.NODE)
431 litMineur_3 = plaine.GroupOnGeom(litMineur,'litMineur',SMESH.NODE)
432 riveDroite_2 = plaine.GroupOnGeom(riveDroite,'riveDroite',SMESH.NODE)
433 Case_1_plaine_Outer_2 = plaine.GroupOnGeom(Case_1_plaine_Outer,'Case_1_plaine_Outer',SMESH.NODE)
434 sections_3 = plaine.GroupOnGeom(sections,'sections',SMESH.NODE)
435 smesh.SetName(plaine, 'plaine')
436
437 try:
438   plaine.ExportMED( r'plaine.med', 0, SMESH.MED_V2_2, 1, None ,1)
439 except:
440   print 'ExportToMEDX() failed. Invalid file name?'
441
442 #controlMeshStats(plaine, 6190, 691, 12201)
443 #controlSubMeshStats(litMineur_2, 2384)
444 #controlSubMeshStats(riveDroite_1, 2400)
445 #controlSubMeshStats(riveGauche_1, 6585)
446
447 #----------------------
448 # --- Z interpolation with HYDRO
449 #----------------------
450
451 from salome.hydrotools.interpolZ import interpolZ, createZfield2
452 from salome.hydrotools.controls import controlStatZ
453
454 # --- case name in HYDRO
455 nomCas = 'Case_1'
456
457 # --- med file 2D(x,y) of the case produced by SMESH
458 fichierMaillage = med_file
459
460 # --- dictionary [med group name] = region name
461 dicoGroupeRegion= dict(litMineur  = 'litMineur',
462                        riveDroite = 'riveDroite',
463                        riveGauche = 'riveGauche',
464                        )
465 # --- value to use for Z when the node is not in a region (used to detect problems)
466 zUndef = 110
467
468 # --- Z interpolation on the bathymety/altimetry on the mesh nodes
469 statz = interpolZ(nomCas, fichierMaillage, dicoGroupeRegion, zUndef)
470 refstatz = {'riveDroite': (10.88, 32.47999954), 'riveGauche': (7.72, 71.38999939), 'litMineur': (2.06, 25.41)}
471 controlStatZ(statz, refstatz)
472
473 # --- add a field on nodes of type double with z values, named "BOTTOM"
474 createZfield2(fichierMaillage)
475
476
477
478 if salome.sg.hasDesktop():
479   salome.sg.updateObjBrowser(1)