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