1 // HOMARD HOMARD : implementation of HOMARD idl descriptions
3 // Copyright (C) 2011-2023 CEA, EDF
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // Pilote l'ecriture du fichier xml pour lancer un schema YACS
30 #include "YACSDriver.hxx"
32 #include "Utils_SALOME_Exception.hxx"
33 #include "utilities.h"
35 //=============================================================================
36 //=============================================================================
37 YACSDriver::YACSDriver(const std::string XMLFile, const std::string DirName, const std::string LangueShort):
38 _XMLFile( "" ), _DirName( "" ),
40 _Texte_parametres( "" ),
41 _noeud_1( "CreateCase" ),
45 MESSAGE("XMLFile = "<<XMLFile<<", DirName ="<<DirName);
48 _LangueShort = LangueShort;
50 //=============================================================================
51 //=============================================================================
52 YACSDriver::~YACSDriver()
55 //===============================================================================
56 // Ajout d'une ligne simple
57 //===============================================================================
58 void YACSDriver::TexteAdd( const std::string ligne )
60 // MESSAGE("TexteAdd, ligne ="<<ligne);
62 _Texte += ligne + "\n" ;
65 //===============================================================================
66 // Nom du fichier du maillage initial
67 //===============================================================================
68 void YACSDriver::Texte_DataInit_MeshFile( const std::string Meshfile )
70 MESSAGE("TexteInitMeshfile, Meshfile ="<<Meshfile);
72 _Texte += " <value><string>" ;
74 _Texte += "</string></value>\n" ;
77 //===============================================================================
78 // Le repertoire de calcul
79 // Le script de lancement
80 //===============================================================================
81 void YACSDriver::Texte_Alternance_Calcul_HOMARD_Calcul( const std::string FileName )
83 MESSAGE("Texte_Alternance_Calcul_HOMARD_Calcul, FileName : "<<FileName);
85 int position = FileName.find_last_of( '/' ) ;
86 std::string nomfic = FileName.substr( position+1 ) ;
87 position = nomfic.find_last_of( '.' ) ;;
88 nomfic = nomfic.substr( 0, position ) ;
89 MESSAGE("nomfic : "<<nomfic) ;
91 _Texte += "rep_calc = \"" + _DirName + "\"\n" ;
92 _Texte += "rep_script = os.path.dirname(\"" + FileName + "\")\n" ;
93 _Texte += "sys.path.append(rep_script)\n" ;
94 _Texte += "from " + nomfic + " import Script\n" ;
97 //===============================================================================
99 //===============================================================================
100 void YACSDriver::Texte_Iter_1_Case_Options( const std::string pythonTexte )
102 MESSAGE("Texte_Iter_1_Case_Options, pythonTexte\n"<<pythonTexte);
104 _Texte += "DirName = \"" + _DirName + "/HOMARD\"\n" ;
105 _Texte += "Case.SetDirName(DirName)\n" ;
107 Texte_python_1( pythonTexte, 1, "Case" ) ;
110 //===============================================================================
111 // La description des zones
112 // ZoneType : le type de la zone
113 // pythonStructure : le python correspondant a la zone
114 // methode : methode associee a la creation de la zone
115 // ZoneName : nom de la zone
116 //===============================================================================
117 std::string YACSDriver::Texte_Iter_1_Zone( int ZoneType, const std::string pythonStructure, const std::string methode, const std::string ZoneName )
119 MESSAGE("Texte_Iter_1_Zone, ZoneType = "<<ZoneType<<", pythonStructure = "<<pythonStructure);
120 MESSAGE("methode = "<<methode<<", ZoneName = "<<ZoneName );
122 // 1. Le nom du noeud
123 std::string noeud_2 = methode + "_" + ZoneName ;
125 if ( _LangueShort == "fr" ) { node = "Boucle_de_convergence.Alternance_Calcul_HOMARD" ; }
126 else { node = "Convergence_Loop.Alternation_Computation_HOMARD" ; }
127 node += ".Adaptation.p0_Adaptation_HOMARD.HOMARD_Initialisation.p1_Iter_1." ;
129 // 2. Texte de controle : le noeud precedent est _noeud_1, le noeud courant noeud_2.
130 // A la fin, on bascule le courant dans le precedent
131 std::string texte_control = Texte_control (_noeud_1, noeud_2, 1) ;
133 // 3. Definition du service
135 _Texte += " <service name=\"" + noeud_2 + "\">\n" ;
136 INFOS("_LangueShort = "<<_LangueShort );
137 if ( _LangueShort == "fr" ) { motcle = "Etude_Initialisation" ; }
138 else { motcle = "Study_Initialisation" ; }
139 INFOS("motcle = "<<motcle );
140 _Texte += " <node>" + motcle + ".UpdateStudy</node>\n" ;
141 _Texte += " <method>" + methode + "</method>\n" ;
143 // 4.1. Le nom de la zone
144 _Texte += Texte_inport( "string", "ZoneName" ) ;
145 TexteParametre( node, "ZoneName", "string", ZoneName ) ;
146 // 4.2. Les valeurs numeriques
147 // ATTENTION : les noms doivent etre les memes que dans Gen.xml, donc HOMARD_Gen.idl
148 // 4.2.1. Decodage des valeurs
149 // La chaine pythonStructure est de ce genre :
150 // CreateZoneBox( "Zone_1", 0.144, 0.216, 0.096, 0.1464, 0.076, 0.12)
151 std::string ligne = pythonStructure ;
152 // On commence par ne garder que ce qui suit la premiere virgule
153 ligne = GetStringInTexte( ligne, ",", 1 );
154 // On boucle pour isoler toutes les chaines dans les virgules
155 std::string lignebis ;
156 std::string x0, x1, x2, x3, x4, x5, x6, x7, x8 ;
158 while ( ligne != lignebis )
160 lignebis = GetStringInTexte ( ligne, ",", 0 ) ;
161 // MESSAGE("lignebis = "<<lignebis );
162 if ( iaux == 0 ) { x0 = lignebis ; }
163 else if ( iaux == 1 ) { x1 = lignebis ; }
164 else if ( iaux == 2 ) { x2 = lignebis ; }
165 else if ( iaux == 3 ) { x3 = lignebis ; }
166 else if ( iaux == 4 ) { x4 = lignebis ; }
167 else if ( iaux == 5 ) { x5 = lignebis ; }
168 else if ( iaux == 6 ) { x6 = lignebis ; }
169 else if ( iaux == 7 ) { x7 = lignebis ; }
170 ligne = GetStringInTexte( ligne, ",", 1 );
173 // La derniere valeur est toujours mise dans x8
174 x8 = GetStringInTexte ( ligne, ")", 0 ) ;
175 MESSAGE("coor = "<< x0<<","<<x1<< ","<< x2<< ","<< x3<<","<<x4<<","<<x5<<","<<x6<<","<<x7<<","<<x8);
176 // 4.2.2. Cas du parallelepipede (2)
179 _Texte += Texte_inport( "double", "Xmini" ) ;
180 _Texte += Texte_inport( "double", "Xmaxi" ) ;
181 _Texte += Texte_inport( "double", "Ymini" ) ;
182 _Texte += Texte_inport( "double", "Ymaxi" ) ;
183 _Texte += Texte_inport( "double", "Zmini" ) ;
184 _Texte += Texte_inport( "double", "Zmaxi" ) ;
185 TexteParametre( node, "Xmini", "double", x0 ) ;
186 TexteParametre( node, "Xmaxi", "double", x1 ) ;
187 TexteParametre( node, "Ymini", "double", x2 ) ;
188 TexteParametre( node, "Ymaxi", "double", x3 ) ;
189 TexteParametre( node, "Zmini", "double", x4 ) ;
190 TexteParametre( node, "Zmaxi", "double", x8 ) ;
193 // 4.2.3. Cas du rectangle (11, 12, 13)
194 else if ( ( ZoneType > 10 ) && ( ZoneType < 14 ) )
196 _Texte += Texte_inport( "double", "Umini" ) ;
197 _Texte += Texte_inport( "double", "Umaxi" ) ;
198 _Texte += Texte_inport( "double", "Vmini" ) ;
199 _Texte += Texte_inport( "double", "Vmaxi" ) ;
200 _Texte += Texte_inport( "long", "Orient" ) ;
201 TexteParametre( node, "Umini", "double", x0 ) ;
202 TexteParametre( node, "Umaxi", "double", x1 ) ;
203 TexteParametre( node, "Vmini", "double", x2 ) ;
204 TexteParametre( node, "Vmaxi", "double", x3 ) ;
205 TexteParametre( node, "Orient", "int", x8 ) ;
208 // 4.2.4. Cas du disque (31, 32, 33) ou du disque perce (61, 62, 63)
209 else if ( ( ( ZoneType > 30 ) && ( ZoneType < 34 ) ) || ( ( ZoneType > 60 ) && ( ZoneType < 64 ) ) )
211 _Texte += Texte_inport( "double", "Ucentre" ) ;
212 _Texte += Texte_inport( "double", "Vcentre" ) ;
213 _Texte += Texte_inport( "double", "Radius" ) ;
214 TexteParametre( node, "Ucentre", "double", x0 ) ;
215 TexteParametre( node, "Vcentre", "double", x1 ) ;
216 TexteParametre( node, "Radius", "double", x2 ) ;
219 _Texte += Texte_inport( "double", "InternalRadius" ) ;
220 TexteParametre( node, "InternalRadius", "double", x3 ) ;
222 _Texte += Texte_inport( "long", "Orient" ) ;
223 TexteParametre( node, "Orient", "int", x8 ) ;
226 // 4.2.5. Cas de la sphere (4)
227 else if ( ZoneType == 4 )
229 _Texte += Texte_inport( "double", "Xcentre" ) ;
230 _Texte += Texte_inport( "double", "Ycentre" ) ;
231 _Texte += Texte_inport( "double", "Zcentre" ) ;
232 _Texte += Texte_inport( "double", "Radius" ) ;
233 TexteParametre( node, "Xcentre", "double", x0 ) ;
234 TexteParametre( node, "Ycentre", "double", x1 ) ;
235 TexteParametre( node, "Zcentre", "double", x2 ) ;
236 TexteParametre( node, "Radius", "double", x8 ) ;
239 // 4.2.6. Cas du cylindre (5) ou du tuyau (7)
240 else if ( ZoneType == 5 || ZoneType == 7 )
242 _Texte += Texte_inport( "double", "Xcentre" ) ;
243 _Texte += Texte_inport( "double", "Ycentre" ) ;
244 _Texte += Texte_inport( "double", "Zcentre" ) ;
245 _Texte += Texte_inport( "double", "Xaxis" ) ;
246 _Texte += Texte_inport( "double", "Yaxis" ) ;
247 _Texte += Texte_inport( "double", "Zaxis" ) ;
248 _Texte += Texte_inport( "double", "Radius" ) ;
249 _Texte += Texte_inport( "double", "Height" ) ;
250 TexteParametre( node, "Xcentre", "double", x0 ) ;
251 TexteParametre( node, "Ycentre", "double", x1 ) ;
252 TexteParametre( node, "Zcentre", "double", x2 ) ;
253 TexteParametre( node, "Xaxis", "double", x3 ) ;
254 TexteParametre( node, "Yaxis", "double", x4 ) ;
255 TexteParametre( node, "Zaxis", "double", x5 ) ;
256 TexteParametre( node, "Radius", "double", x6 ) ;
259 TexteParametre( node, "Height", "double", x8 ) ;
263 _Texte += Texte_inport( "double", "InternalRadius" ) ;
264 TexteParametre( node, "Height", "double", x7 ) ;
265 TexteParametre( node, "InternalRadius", "double", x8 ) ;
271 { VERIFICATION("Type de zone inconnu." == 0); }
275 _Texte += " <outport name=\"return\" type=\"HOMARD_Zone\"/>\n" ;
276 _Texte += " </service>\n" ;
278 return texte_control ;
281 //===============================================================================
282 // La description des frontieres
283 // BoundaryType : le type de la frontiere
284 // pythonStructure : le python correspondant a la frontiere
285 // methode : methode associee a la creation de la frontiere
286 // BoundaryName : nom de la frontiere
287 // MeshName : nom du maillage dans le cas d'une frontiere discrete
288 // MeshFile : nom du fichier du maillage dans le cas d'une frontiere discrete
289 //===============================================================================
290 std::string YACSDriver::Texte_Iter_1_Boundary( int BoundaryType, const std::string pythonStructure, const std::string methode, const std::string BoundaryName, const std::string MeshName, const std::string MeshFile )
292 MESSAGE("Texte_Iter_1_Boundary, BoundaryType = "<<BoundaryType<<", pythonStructure = "<<pythonStructure);
293 MESSAGE("methode = "<<methode<<", BoundaryName = "<<BoundaryName );
294 if (BoundaryType == 0) { MESSAGE("MeshName = "<<MeshName<<", MeshFile = "<<MeshFile ); }
296 // 1. Le nom du noeud
297 std::string noeud_2 = methode + "_" + BoundaryName ;
299 if ( _LangueShort == "fr" ) { node = "Boucle_de_convergence.Alternance_Calcul_HOMARD" ; }
300 else { node = "Convergence_Loop.Alternation_Computation_HOMARD" ; }
301 node += ".Adaptation.p0_Adaptation_HOMARD.HOMARD_Initialisation.p1_Iter_1." ;
303 // 2. Texte de controle : le noeud precedent est _noeud_1, le noeud courant noeud_2.
304 // A la fin, on bascule le courant dans le precedent
305 std::string texte_control = Texte_control (_noeud_1, noeud_2, 1) ;
307 // 3. Definition du service
309 _Texte += " <service name=\"" + noeud_2 + "\">\n" ;
310 if ( _LangueShort == "fr" ) { motcle = "Etude_Initialisation" ; }
311 else { motcle = "Study_Initialisation" ; }
312 _Texte += " <node>" + motcle + ".UpdateStudy</node>\n" ;
313 _Texte += " <method>" + methode + "</method>\n" ;
315 // ATTENTION : les noms doivent etre les memes que dans Gen.xml, donc HOMARD_Gen.idl
316 // 4.1. Le nom de la frontiere
317 _Texte += Texte_inport( "string", "BoundaryName" ) ;
318 TexteParametre( node, "BoundaryName", "string", BoundaryName ) ;
319 // 4.2. Cas d une frontiere discrete
320 if (BoundaryType == 0)
322 _Texte += Texte_inport( "string", "MeshName" ) ;
323 TexteParametre( node, "MeshName", "string", MeshName ) ;
324 _Texte += Texte_inport( "string", "FileName" ) ;
325 TexteParametre( node, "FileName", "string", MeshFile ) ;
327 // 4.3. Cas d'une frontiere analytique : les valeurs numeriques
330 // 4.3.1. Decodage des valeurs
331 // La chaine pythonStructure est de ce genre :
332 // CreateBoundaryCylinder('cyl_2', 17.5, -2.5, -12.5, -100., -75., -25., 50.)
333 // CreateBoundaryDi("intersection", "PIQUAGE", "/scratch/D68518/Salome/script/sfr_2d_piquage.fr.med")
334 std::string ligne = pythonStructure ;
335 // On commence par ne garder que ce qui suit la premiere virgule
336 ligne = GetStringInTexte( ligne, ",", 1 );
337 // On boucle pour isoler toutes les chaines dans les virgules
338 std::string lignebis ;
339 std::string x0, x1, x2, x3, x4, x5, x6, x7 ;
341 while ( ligne != lignebis )
343 lignebis = GetStringInTexte ( ligne, ",", 0 ) ;
344 // MESSAGE("lignebis = "<<lignebis );
345 if ( iaux == 0 ) { x0 = lignebis ; }
346 else if ( iaux == 1 ) { x1 = lignebis ; }
347 else if ( iaux == 2 ) { x2 = lignebis ; }
348 else if ( iaux == 3 ) { x3 = lignebis ; }
349 else if ( iaux == 4 ) { x4 = lignebis ; }
350 else if ( iaux == 5 ) { x5 = lignebis ; }
351 else if ( iaux == 6 ) { x6 = lignebis ; }
352 ligne = GetStringInTexte( ligne, ",", 1 );
355 // La derniere valeur est toujours mise dans x7
356 x7 = GetStringInTexte ( ligne, ")", 0 ) ;
357 MESSAGE("Valeurs = "<< x0<<", "<<x1<< ", "<< x2<< ", "<< x3<<", "<<x4<<", "<<x5<<", "<<x6<<", x7"<<x7);
359 // 4.3.2. Cas du cylindre (1)
360 if ( BoundaryType == 1 )
362 _Texte += Texte_inport( "double", "Xcentre" ) ;
363 _Texte += Texte_inport( "double", "Ycentre" ) ;
364 _Texte += Texte_inport( "double", "Zcentre" ) ;
365 _Texte += Texte_inport( "double", "Xaxis" ) ;
366 _Texte += Texte_inport( "double", "Yaxis" ) ;
367 _Texte += Texte_inport( "double", "Zaxis" ) ;
368 _Texte += Texte_inport( "double", "Radius" ) ;
369 TexteParametre( node, "Xcentre", "double", x0 ) ;
370 TexteParametre( node, "Ycentre", "double", x1 ) ;
371 TexteParametre( node, "Zcentre", "double", x2 ) ;
372 TexteParametre( node, "Xaxis", "double", x3 ) ;
373 TexteParametre( node, "Yaxis", "double", x4 ) ;
374 TexteParametre( node, "Zaxis", "double", x5 ) ;
375 TexteParametre( node, "Radius", "double", x7 ) ;
378 // 4.3.3. Cas de la sphere (2)
379 else if ( BoundaryType == 2 )
381 _Texte += Texte_inport( "double", "Xcentre" ) ;
382 _Texte += Texte_inport( "double", "Ycentre" ) ;
383 _Texte += Texte_inport( "double", "Zcentre" ) ;
384 _Texte += Texte_inport( "double", "Radius" ) ;
385 TexteParametre( node, "Xcentre", "double", x0 ) ;
386 TexteParametre( node, "Ycentre", "double", x1 ) ;
387 TexteParametre( node, "Zcentre", "double", x2 ) ;
388 TexteParametre( node, "Radius", "double", x7 ) ;
391 // 4.3.4. Cas d un cone defini par un axe et un angle
392 else if ( BoundaryType == 3 )
394 _Texte += Texte_inport( "double", "Xaxis" ) ;
395 _Texte += Texte_inport( "double", "Yaxis" ) ;
396 _Texte += Texte_inport( "double", "Zaxis" ) ;
397 _Texte += Texte_inport( "double", "Angle" ) ;
398 _Texte += Texte_inport( "double", "Xcentre" ) ;
399 _Texte += Texte_inport( "double", "Ycentre" ) ;
400 _Texte += Texte_inport( "double", "Zcentre" ) ;
401 TexteParametre( node, "Xaxis", "double", x0 ) ;
402 TexteParametre( node, "Yaxis", "double", x1 ) ;
403 TexteParametre( node, "Zaxis", "double", x2 ) ;
404 TexteParametre( node, "Angle", "double", x3 ) ;
405 TexteParametre( node, "Xcentre", "double", x4 ) ;
406 TexteParametre( node, "Ycentre", "double", x5 ) ;
407 TexteParametre( node, "Zcentre", "double", x7 ) ;
410 // 4.3.5. Cas d un cone defini par les 2 rayons
411 else if ( BoundaryType == 4 )
413 _Texte += Texte_inport( "double", "Xcentre1" ) ;
414 _Texte += Texte_inport( "double", "Ycentre1" ) ;
415 _Texte += Texte_inport( "double", "Zcentre1" ) ;
416 _Texte += Texte_inport( "double", "Radius1" ) ;
417 _Texte += Texte_inport( "double", "Xcentre2" ) ;
418 _Texte += Texte_inport( "double", "Ycentre2" ) ;
419 _Texte += Texte_inport( "double", "Zcentre2" ) ;
420 _Texte += Texte_inport( "double", "Radius2" ) ;
421 TexteParametre( node, "Xcentre1", "double", x0 ) ;
422 TexteParametre( node, "Ycentre1", "double", x1 ) ;
423 TexteParametre( node, "Zcentre1", "double", x2 ) ;
424 TexteParametre( node, "Radius1", "double", x3 ) ;
425 TexteParametre( node, "Xcentre2", "double", x4 ) ;
426 TexteParametre( node, "Ycentre2", "double", x5 ) ;
427 TexteParametre( node, "Zcentre2", "double", x6 ) ;
428 TexteParametre( node, "Radius2", "double", x7 ) ;
430 // 4.3.6. Cas du tore (5)
431 else if ( BoundaryType == 5 )
433 _Texte += Texte_inport( "double", "Xcentre" ) ;
434 _Texte += Texte_inport( "double", "Ycentre" ) ;
435 _Texte += Texte_inport( "double", "Zcentre" ) ;
436 _Texte += Texte_inport( "double", "Xaxis" ) ;
437 _Texte += Texte_inport( "double", "Yaxis" ) ;
438 _Texte += Texte_inport( "double", "Zaxis" ) ;
439 _Texte += Texte_inport( "double", "RRev" ) ;
440 _Texte += Texte_inport( "double", "RPri" ) ;
441 TexteParametre( node, "Xcentre", "double", x0 ) ;
442 TexteParametre( node, "Ycentre", "double", x1 ) ;
443 TexteParametre( node, "Zcentre", "double", x2 ) ;
444 TexteParametre( node, "Xaxis", "double", x3 ) ;
445 TexteParametre( node, "Yaxis", "double", x4 ) ;
446 TexteParametre( node, "Zaxis", "double", x5 ) ;
447 TexteParametre( node, "RRev", "double", x6 ) ;
448 TexteParametre( node, "RPri", "double", x7 ) ;
453 { VERIFICATION("Type de frontiere inconnu." == 0); }
457 _Texte += " <outport name=\"return\" type=\"HOMARD_Boundary\"/>\n" ;
458 _Texte += " </service>\n" ;
460 return texte_control ;
463 //===============================================================================
464 // Fin du controle des enchainements de noeud dans le noeud Iter_1
465 //===============================================================================
466 std::string YACSDriver::Texte_Iter_1_control()
468 MESSAGE("Texte_Iter_1_control");
471 texte = Texte_control (_noeud_1, "CreateHypothesis", 1) ;
472 texte += Texte_control ("CreateHypothesis", "Case_Options", 0) ;
477 //===============================================================================
478 // Controle des enchainements de noeuds
479 // noeud_1 : noeud de depart
480 // noeud_2 : noeud d'arrivee
481 // option : 0 : sans caractere de saut de ligne a la fin
482 // 1 : avec caractere de saut de ligne a la fin
483 //===============================================================================
484 std::string YACSDriver::Texte_control( const std::string noeud_1, const std::string noeud_2, int option )
486 MESSAGE("Texte_control, noeud_1 = "<<noeud_1<<", noeud_2 = "<<noeud_2<<", option = "<<option);
489 texte = " <control> " ;
490 texte += "<fromnode>" + noeud_1 + "</fromnode>" ;
491 texte += " <tonode>" + noeud_2 + "</tonode>" ;
492 texte += " </control>" ;
493 if ( option == 1 ) { texte += "\n" ; }
498 //===============================================================================
500 // inport_type : type de la donnee a importer
501 // inport_nom : nom de la donnee a importer
502 //===============================================================================
503 std::string YACSDriver::Texte_inport( const std::string inport_type, const std::string inport_nom )
505 // MESSAGE("Texte_inport, inport_type = "<<inport_type<<", inport_nom = "<<inport_nom);
508 texte = " <inport " ;
509 texte += "name=\"" + inport_nom + "\" " ;
510 texte += "type=\"" + inport_type + "\"" ;
516 //===============================================================================
517 // Le repertoire d'execution
518 //===============================================================================
519 void YACSDriver::Texte_HOMARD_Exec_DirName( )
521 MESSAGE("Texte_HOMARD_Exec_DirName");
523 _Texte += "DirName = \"" + _DirName + "\"\n" ;
526 //===============================================================================
527 // Le nom du maillage
528 //===============================================================================
529 void YACSDriver::Texte_HOMARD_Exec_MeshName( const std::string MeshName )
531 MESSAGE("Texte_HOMARD_Exec_MeshName pour "<<MeshName);
533 _Texte += "MeshName = \"" + MeshName + "\"\n" ;
536 //===============================================================================
537 // Manipulation des instructions python - 1
538 // pythonTexte : le texte des instructions python a manipuler
539 // indice : numero de la premiere ligne voulue
540 // concept : nom du concept a inserer
541 //===============================================================================
542 void YACSDriver::Texte_python_1( const std::string pythonTexte, int indice, const std::string concept )
544 MESSAGE("Texte_python_1, pythonTexte\n"<<pythonTexte);
545 MESSAGE("indice = "<<indice<<", concept = "<<concept);
547 // Conversion de type
548 std::istringstream tout (pythonTexte) ;
549 // MESSAGE("\ntout :"<<tout);
550 std::string ligne; // variable contenant chaque ligne de python
551 std::string ligne_bis ; // variable contenant la portion de ligne de python apres '.'
554 while ( std::getline( tout, ligne ) )
558 int position = ligne.find_first_of( "." ) ;
559 MESSAGE("\nposition : "<< position);
562 ligne_bis = ligne.substr( position );
563 MESSAGE("\nligne_bis : "<< ligne_bis);
564 _Texte += concept + ligne_bis + "\n" ;
571 //===============================================================================
572 // Manipulation des instructions python - 2
573 // pythonTexte : le texte des instructions python a manipuler
574 // mot_cle : mot-cle dans les lignes a inserer
575 // concept : nom du concept a inserer
576 //===============================================================================
577 void YACSDriver::Texte_python_2( const std::string pythonTexte, const std::string mot_cle, const std::string concept )
579 MESSAGE("Texte_python_2, pythonTexte\n"<<pythonTexte);
580 MESSAGE("mot_cle = "<<mot_cle<<", concept = "<<concept);
582 // Conversion de type
583 std::istringstream tout (pythonTexte) ;
584 // MESSAGE("\ntout :"<<tout);
585 std::string ligne; // variable contenant chaque ligne de python
586 std::string ligne_bis ; // variable contenant la portion de ligne de python apres '.'
587 while ( std::getline( tout, ligne ) )
589 int reperage = ligne.find( mot_cle ) ;
592 int position = ligne.find_first_of( "." ) ;
593 // MESSAGE("\nposition : "<< position);
596 ligne_bis = ligne.substr( position );
597 // MESSAGE("\nligne_bis : "<< ligne_bis);
598 _Texte += concept + ligne_bis + "\n" ;
604 //===============================================================================
605 // Parametres de tests de convergence
606 //===============================================================================
607 void YACSDriver::TexteAnalyse_Test_Convergence( int MaxIter, int MaxNode, int MaxElem )
610 // MESSAGE("TexteAnalyse_Test_Convergence");
612 std::ostringstream oss1;
615 _Texte += "MaxIter = " + chaine + "\n" ;
616 std::ostringstream oss2;
619 _Texte += "MaxNode = " + chaine + "\n" ;
620 std::ostringstream oss3;
623 _Texte += "MaxElem = " + chaine + "\n" ;
626 //===============================================================================
627 // Creation d'un parametre
628 //===============================================================================
629 void YACSDriver::TexteParametre( const std::string node, const std::string port, const std::string type_value, const std::string value )
632 // MESSAGE("TexteParametre");
633 _Texte_parametres += " <parameter>\n" ;
634 _Texte_parametres += " <tonode>" + node + "</tonode>" ;
635 _Texte_parametres += "<toport>" + port + "</toport>\n" ;
636 _Texte_parametres += " <value><" + type_value + ">" + value + "</" + type_value + "></value>\n" ;
637 _Texte_parametres += " </parameter>\n" ;
640 //===============================================================================
641 // Ajout des parametres
642 //===============================================================================
643 void YACSDriver::TexteAddParametres( )
646 MESSAGE("TexteAddParametres");
647 TexteAdd(_Texte_parametres) ;
650 //===============================================================================
651 void YACSDriver::CreeFichier( )
654 MESSAGE("CreeFichier sur le fichier "<<_XMLFile);
655 std::ofstream Fic(_XMLFile.c_str(), std::ios::out ) ;
656 if (Fic.is_open() == true) { Fic << _Texte << std::endl ; }
660 //===============================================================================
661 // REMARQUE : on devrait utiliser le GetStringInTexte de HOMARD_Gen_i mais je ne sais pas
662 // comment l'appeler. ALors je clone.
663 // Recuperation de la chaine de caracteres par rapport l'apparition d'un texte
664 // ligne : la ligne a manipuler
665 // texte : le texte a reperer
666 // option : 0 : la chaine avant le texte
667 // 1 : la chaine apres le texte
668 // Si le texte est absent, on retourne la chaine totale
669 //===============================================================================
670 std::string YACSDriver::GetStringInTexte( const std::string ligne, const std::string texte, int option )
672 // MESSAGE("GetStringInTexte, recherche de '"<<texte<<"' dans '"<<ligne<<"'"<<", option = "<<option);
674 std::string chaine = ligne ;
675 int position = ligne.find_first_of( texte ) ;
678 if ( option == 0 ) { chaine = ligne.substr( 0, position ) ; }
679 else { chaine = ligne.substr( position+1 ) ; }
681 // Conversion de type