]> SALOME platform Git repositories - modules/homard.git/blob - src/HOMARD/YACSDriver.cxx
Salome HOME
Destruction des schémas
[modules/homard.git] / src / HOMARD / YACSDriver.cxx
1 //  HOMARD HOMARD : implementation of HOMARD idl descriptions
2 //
3 // Copyright (C) 2011-2013  CEA/DEN, EDF R&D
4 //
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.
9 //
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.
14 //
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
18 //
19 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 //
21
22 // Pilote l'ecriture du fichier xml pour lancer un schema YACS
23
24 #include <cstring>
25 #include <unistd.h>
26 #include <sys/stat.h>
27
28 #include "Utils_SALOME_Exception.hxx"
29 #include "utilities.h"
30 #include "YACSDriver.hxx"
31
32 //=============================================================================
33 //=============================================================================
34 YACSDriver::YACSDriver(const std::string XMLFile, const std::string DirName):
35   _XMLFile( "" ), _DirName( "" ),
36   _Texte( "" ),
37   _Texte_parametres( "" ),
38   _noeud_1( "CreateHypothesis" ),
39   _bLu( false )
40 {
41   MESSAGE("XMLFile = "<<XMLFile<<", DirName ="<<DirName);
42   _XMLFile = XMLFile;
43   _DirName = DirName;
44 }
45 //=============================================================================
46 //=============================================================================
47 YACSDriver::~YACSDriver()
48 {
49 }
50 //===============================================================================
51 // Ajout d'une ligne simple
52 //===============================================================================
53 void YACSDriver::TexteAdd( const std::string ligne )
54 {
55 //   MESSAGE("TexteAdd, ligne ="<<ligne);
56 //
57   _Texte += ligne + "\n" ;
58 //
59 }
60 //===============================================================================
61 // Nom du fichier du maillage initial
62 //===============================================================================
63 void YACSDriver::Texte_DataInit_MeshFile( const std::string Meshfile )
64 {
65   MESSAGE("TexteInitMeshfile, Meshfile ="<<Meshfile);
66 //
67   _Texte += "         <value><string>" ;
68   _Texte += Meshfile ;
69   _Texte += "</string></value>\n" ;
70 //
71 }
72 //===============================================================================
73 // Le repertoire de calcul
74 // Le script de lancement
75 //===============================================================================
76 void YACSDriver::Texte_Alternance_Calcul_HOMARD_Calcul( const std::string FileName )
77 {
78   MESSAGE("Texte_Alternance_Calcul_HOMARD_Calcul, FileName : "<<FileName);
79 //
80   int position = FileName.find_last_of( '/' ) ;
81   std::string nomfic = FileName.substr( position+1 ) ;
82   position = nomfic.find_last_of( '.' ) ;;
83   nomfic = nomfic.substr( 0, position ) ;
84   MESSAGE("nomfic : "<<nomfic) ;
85 //
86   _Texte += "rep_calc = \"" + _DirName + "\"\n" ;
87   _Texte += "rep_script = os.path.dirname(\"" + FileName + "\")\n" ;
88   _Texte += "sys.path.append(rep_script)\n" ;
89   _Texte += "from " + nomfic + " import Script\n" ;
90 //
91 }
92 //===============================================================================
93 // Les options du cas
94 //===============================================================================
95 void YACSDriver::Texte_Iter_1_Case_Options( const std::string pythonTexte )
96 {
97   MESSAGE("Texte_Iter_1_Case_Options, pythonTexte\n"<<pythonTexte);
98 //
99   _Texte += "DirName = \"" + _DirName + "/HOMARD\"\n" ;
100   _Texte += "Case.SetDirName(DirName)\n" ;
101
102   Texte_python( pythonTexte, 1, "Case" ) ;
103 //
104 }
105 //===============================================================================
106 // La description des zones
107 // ZoneType : le type de la zone
108 // pythonStructure : le python correspondant a la zone
109 // methode : methode associee a la creation de la zone
110 // ZoneName : nom de la zone
111 //===============================================================================
112 std::string YACSDriver::Texte_Iter_1_Zone( int ZoneType, const std::string pythonStructure, const std::string methode, const std::string ZoneName )
113 {
114   MESSAGE("Texte_Iter_1_Zone, ZoneType = "<<ZoneType<<", pythonStructure = "<<pythonStructure);
115   MESSAGE("methode = "<<methode<<", ZoneName = "<<ZoneName );
116 //
117 // 1. Le nom du noeud
118   std::string noeud_2 = methode + "_" + ZoneName ;
119   std::string node = "Boucle_de_convergence.Alternance_Calcul_HOMARD.Adaptation.p0_Adaptation_HOMARD.HOMARD_Initialisation.p1_Iter_1." ;
120   node += noeud_2 ;
121 // 2. Texte de controle
122   std::string texte_control = Texte_control (_noeud_1, noeud_2) ;
123   _noeud_1 = noeud_2 ;
124 // 3. Definition du service
125   _Texte += "                           <service name=\"" + noeud_2 + "\">\n" ;
126   _Texte += "                              <node>Etude_Initialisation.SetCurrentStudy</node>\n" ;
127   _Texte += "                              <method>" + methode + "</method>\n" ;
128 // 4. Les inports
129 // 4.1. Le nom de la zone
130   _Texte += Texte_inport( "string", "ZoneName" ) ;
131    TexteParametre( node, "ZoneName", "string", ZoneName ) ;
132 // 4.2. Les valeurs numeriques
133 //      ATTENTION : les noms doivent etre les memes que dans Gen.xml, donc HOMARD_Gen.idl
134 // 4.2.1. Decodage des valeurs
135 // La chaine pythonStructure est de ce genre :
136 //   CreateZoneBox( "Zone_1", 0.144, 0.216, 0.096, 0.1464, 0.076, 0.12)
137   std::string ligne = pythonStructure ;
138 // On commence par ne garder que ce qui suit la premiere virgule
139   ligne = GetStringInTexte( ligne, ",", 1 );
140 // On boucle pour isoler toutes les chaines dans les virgules
141   std::string lignebis ;
142   std::string x0, x1, x2, x3, x4, x5, x6, x7, x8  ;
143   int iaux = 0  ;
144   while ( ligne != lignebis )
145   {
146     lignebis = GetStringInTexte ( ligne, ",", 0 ) ;
147 //     MESSAGE("lignebis = "<<lignebis );
148     if      ( iaux == 0 ) { x0 = lignebis ; }
149     else if ( iaux == 1 ) { x1 = lignebis ; }
150     else if ( iaux == 2 ) { x2 = lignebis ; }
151     else if ( iaux == 3 ) { x3 = lignebis ; }
152     else if ( iaux == 4 ) { x4 = lignebis ; }
153     else if ( iaux == 5 ) { x5 = lignebis ; }
154     else if ( iaux == 6 ) { x6 = lignebis ; }
155     else if ( iaux == 7 ) { x7 = lignebis ; }
156     ligne = GetStringInTexte( ligne, ",", 1 );
157     iaux += 1 ;
158   }
159 // La derniere valeur est toujours mise dans x8
160   x8 = GetStringInTexte ( ligne, ")", 0 ) ;
161   MESSAGE("coor = "<< x0<<","<<x1<< ","<< x2<< ","<< x3<<","<<x4<<","<<x5<<","<<x6<<","<<x7<<","<<x8);
162 // 4.2. Cas du parallelepipede (2)
163   if ( ZoneType == 2 )
164   {
165     _Texte += Texte_inport( "double", "Xmini" ) ;
166     _Texte += Texte_inport( "double", "Xmaxi" ) ;
167     _Texte += Texte_inport( "double", "Ymini" ) ;
168     _Texte += Texte_inport( "double", "Ymaxi" ) ;
169     _Texte += Texte_inport( "double", "Zmini" ) ;
170     _Texte += Texte_inport( "double", "Zmaxi" ) ;
171     TexteParametre( node, "Xmini", "double", x0 ) ;
172     TexteParametre( node, "Xmaxi", "double", x1 ) ;
173     TexteParametre( node, "Ymini", "double", x2 ) ;
174     TexteParametre( node, "Ymaxi", "double", x3 ) ;
175     TexteParametre( node, "Zmini", "double", x4 ) ;
176     TexteParametre( node, "Zmaxi", "double", x8 ) ;
177   }
178 //
179 // 4.2. Cas du rectangle (11, 12, 13)
180   else if ( ( ZoneType > 10 ) and ( ZoneType < 14 ) )
181   {
182     _Texte += Texte_inport( "double", "Umini" ) ;
183     _Texte += Texte_inport( "double", "Umaxi" ) ;
184     _Texte += Texte_inport( "double", "Vmini" ) ;
185     _Texte += Texte_inport( "double", "Vmaxi" ) ;
186     _Texte += Texte_inport( "long", "Orient" ) ;
187     TexteParametre( node, "Umini", "double", x0 ) ;
188     TexteParametre( node, "Umaxi", "double", x1 ) ;
189     TexteParametre( node, "Vmini", "double", x2 ) ;
190     TexteParametre( node, "Vmaxi", "double", x3 ) ;
191     TexteParametre( node, "Orient", "int", x8 ) ;
192   }
193 //
194 // 4.2. Cas du disque (31, 32, 33) ou du disque perce (61, 62, 63)
195   else if ( ( ( ZoneType > 30 ) and ( ZoneType < 34 ) ) or ( ( ZoneType > 60 ) and ( ZoneType < 64 ) ) )
196   {
197     _Texte += Texte_inport( "double", "Ucentre" ) ;
198     _Texte += Texte_inport( "double", "Vcentre" ) ;
199     _Texte += Texte_inport( "double", "Radius" ) ;
200     TexteParametre( node, "Ucentre", "double", x0 ) ;
201     TexteParametre( node, "Vcentre", "double", x1 ) ;
202     TexteParametre( node, "Radius", "double", x2 ) ;
203     if ( ZoneType > 60 )
204     {
205       _Texte += Texte_inport( "double", "InternalRadius" ) ;
206       TexteParametre( node, "InternalRadius", "double", x3 ) ;
207     }
208     _Texte += Texte_inport( "long", "Orient" ) ;
209     TexteParametre( node, "Orient", "int", x8 ) ;
210   }
211 //
212 // 4.2. Cas de la sphere (4)
213   else if ( ZoneType == 4 )
214   {
215     _Texte += Texte_inport( "double", "Xcentre" ) ;
216     _Texte += Texte_inport( "double", "Ycentre" ) ;
217     _Texte += Texte_inport( "double", "Zcentre" ) ;
218     _Texte += Texte_inport( "double", "Radius" ) ;
219     TexteParametre( node, "Xcentre", "double", x0 ) ;
220     TexteParametre( node, "Ycentre", "double", x1 ) ;
221     TexteParametre( node, "Zcentre", "double", x2 ) ;
222     TexteParametre( node, "Radius", "double", x8 ) ;
223   }
224 //
225 // 4.2. Cas du cylindre (5) ou du tuyau (7)
226   else if ( ZoneType == 5 or ZoneType == 7 )
227   {
228     _Texte += Texte_inport( "double", "Xcentre" ) ;
229     _Texte += Texte_inport( "double", "Ycentre" ) ;
230     _Texte += Texte_inport( "double", "Zcentre" ) ;
231     _Texte += Texte_inport( "double", "Xaxis" ) ;
232     _Texte += Texte_inport( "double", "Yaxis" ) ;
233     _Texte += Texte_inport( "double", "Zaxis" ) ;
234     _Texte += Texte_inport( "double", "Radius" ) ;
235     _Texte += Texte_inport( "double", "Height" ) ;
236     TexteParametre( node, "Xcentre", "double", x0 ) ;
237     TexteParametre( node, "Ycentre", "double", x1 ) ;
238     TexteParametre( node, "Zcentre", "double", x2 ) ;
239     TexteParametre( node, "Xaxis", "double", x3 ) ;
240     TexteParametre( node, "Yaxis", "double", x4 ) ;
241     TexteParametre( node, "Zaxis", "double", x5 ) ;
242     TexteParametre( node, "Radius", "double", x6 ) ;
243     if ( ZoneType == 5 )
244     {
245       TexteParametre( node, "Height", "double", x8 ) ;
246     }
247     else
248     {
249       _Texte += Texte_inport( "double", "InternalRadius" ) ;
250       TexteParametre( node, "Height", "double", x7 ) ;
251       TexteParametre( node, "InternalRadius", "double", x8 ) ;
252     }
253   }
254 //
255 // 4.2. Erreur
256   else
257   { ASSERT("Type de zone inconnu." == 0); }
258
259 //
260 // 5. La fin
261   _Texte += "                              <outport name=\"return\" type=\"HOMARD_Zone\"/>\n" ;
262   _Texte += "                           </service>\n" ;
263 //
264   return texte_control ;
265 //
266 }
267 //===============================================================================
268 // La description des frontieres
269 // BoundaryType : le type de la frontiere
270 // pythonStructure : le python correspondant a la frontiere
271 // methode : methode associee a la creation de la frontiere
272 // BoundaryName : nom de la frontiere
273 //===============================================================================
274 std::string YACSDriver::Texte_Iter_1_Boundary( int BoundaryType, const std::string pythonStructure, const std::string methode, const std::string BoundaryName )
275 {
276   MESSAGE("Texte_Iter_1_Boundary, BoundaryType = "<<BoundaryType<<", pythonStructure = "<<pythonStructure);
277   MESSAGE("methode = "<<methode<<", BoundaryName = "<<BoundaryName );
278 //
279 // 1. Le nom du noeud
280   std::string noeud_2 = methode + "_" + BoundaryName ;
281   std::string node = "Boucle_de_convergence.Alternance_Calcul_HOMARD.Adaptation.p0_Adaptation_HOMARD.HOMARD_Initialisation.p1_Iter_1." ;
282   node += noeud_2 ;
283 // 2. Texte de controle
284   std::string texte_control = Texte_control (_noeud_1, noeud_2) ;
285   _noeud_1 = noeud_2 ;
286 // 3. Definition du service
287   _Texte += "                           <service name=\"" + noeud_2 + "\">\n" ;
288   _Texte += "                              <node>Etude_Initialisation.SetCurrentStudy</node>\n" ;
289   _Texte += "                              <method>" + methode + "</method>\n" ;
290 // 4. Les inports
291 // 4.1. Le nom de la zone
292   _Texte += Texte_inport( "string", "BoundaryName" ) ;
293   TexteParametre( node, "BoundaryName", "string", BoundaryName ) ;
294 // 4.2. Les valeurs numeriques
295 //      ATTENTION : les noms doivent etre les memes que dans Gen.xml, donc HOMARD_Gen.idl
296 // 4.2.1. Decodage des valeurs
297 // La chaine pythonStructure est de ce genre :
298 //   CreateBoundaryCylinder('cyl_2', 17.5, -2.5, -12.5, -100., -75., -25., 50.)
299 //   CreateBoundaryDi("intersection", "PIQUAGE", "/scratch/D68518/Salome/script/sfr_2d_piquage.fr.med")
300   std::string ligne = pythonStructure ;
301 // On commence par ne garder que ce qui suit la premiere virgule
302   ligne = GetStringInTexte( ligne, ",", 1 );
303 // On boucle pour isoler toutes les chaines dans les virgules
304   std::string lignebis ;
305   std::string x0, x1, x2, x3, x4, x5, x6, x7  ;
306   int iaux = 0  ;
307   while ( ligne != lignebis )
308   {
309     lignebis = GetStringInTexte ( ligne, ",", 0 ) ;
310 //     MESSAGE("lignebis = "<<lignebis );
311     if      ( iaux == 0 ) { x0 = lignebis ; }
312     else if ( iaux == 1 ) { x1 = lignebis ; }
313     else if ( iaux == 2 ) { x2 = lignebis ; }
314     else if ( iaux == 3 ) { x3 = lignebis ; }
315     else if ( iaux == 4 ) { x4 = lignebis ; }
316     else if ( iaux == 5 ) { x5 = lignebis ; }
317     else if ( iaux == 6 ) { x6 = lignebis ; }
318     ligne = GetStringInTexte( ligne, ",", 1 );
319     iaux += 1 ;
320   }
321 // La derniere valeur est toujours mise dans x7
322   x7 = GetStringInTexte ( ligne, ")", 0 ) ;
323   MESSAGE("Valeurs = "<< x0<<", "<<x1<< ", "<< x2<< ", "<< x3<<", "<<x4<<", "<<x5<<", "<<x6<<", x7"<<x7);
324 //
325 // 4.2. Cas d une frontiere discrete (0)
326   if (BoundaryType == 0) // Cas d une frontiere discrete
327   {
328     _Texte += Texte_inport( "string", "MeshName" ) ;
329     TexteParametre( node, "MeshName", "string", x0 ) ;
330     _Texte += Texte_inport( "string", "FileName" ) ;
331     TexteParametre( node, "FileName", "string", x7 ) ;
332   }
333 // 4.2. Cas du cylindre (1)
334   else if ( BoundaryType == 1 )
335   {
336     _Texte += Texte_inport( "double", "Xcentre" ) ;
337     _Texte += Texte_inport( "double", "Ycentre" ) ;
338     _Texte += Texte_inport( "double", "Zcentre" ) ;
339     _Texte += Texte_inport( "double", "Xaxis" ) ;
340     _Texte += Texte_inport( "double", "Yaxis" ) ;
341     _Texte += Texte_inport( "double", "Zaxis" ) ;
342     _Texte += Texte_inport( "double", "Radius" ) ;
343     TexteParametre( node, "Xcentre", "double", x0 ) ;
344     TexteParametre( node, "Ycentre", "double", x1 ) ;
345     TexteParametre( node, "Zcentre", "double", x2 ) ;
346     TexteParametre( node, "Xaxis", "double", x3 ) ;
347     TexteParametre( node, "Yaxis", "double", x4 ) ;
348     TexteParametre( node, "Zaxis", "double", x5 ) ;
349     TexteParametre( node, "Radius", "double", x7 ) ;
350   }
351 //
352 // 4.2. Cas de la sphere (2)
353   else if ( BoundaryType == 2 )
354   {
355     _Texte += Texte_inport( "double", "Xcentre" ) ;
356     _Texte += Texte_inport( "double", "Ycentre" ) ;
357     _Texte += Texte_inport( "double", "Zcentre" ) ;
358     _Texte += Texte_inport( "double", "Radius" ) ;
359     TexteParametre( node, "Xcentre", "double", x0 ) ;
360     TexteParametre( node, "Ycentre", "double", x1 ) ;
361     TexteParametre( node, "Zcentre", "double", x2 ) ;
362     TexteParametre( node, "Radius", "double", x7 ) ;
363   }
364 //
365 // 4.2. Cas d un cone defini par un axe et un angle
366   else if ( BoundaryType == 3 )
367   {
368     _Texte += Texte_inport( "double", "Xaxis" ) ;
369     _Texte += Texte_inport( "double", "Yaxis" ) ;
370     _Texte += Texte_inport( "double", "Zaxis" ) ;
371     _Texte += Texte_inport( "double", "Angle" ) ;
372     _Texte += Texte_inport( "double", "Xcentre" ) ;
373     _Texte += Texte_inport( "double", "Ycentre" ) ;
374     _Texte += Texte_inport( "double", "Zcentre" ) ;
375     TexteParametre( node, "Xaxis", "double", x0 ) ;
376     TexteParametre( node, "Yaxis", "double", x1 ) ;
377     TexteParametre( node, "Zaxis", "double", x2 ) ;
378     TexteParametre( node, "Angle", "double", x3 ) ;
379     TexteParametre( node, "Xcentre", "double", x4 ) ;
380     TexteParametre( node, "Ycentre", "double", x5 ) ;
381     TexteParametre( node, "Zcentre", "double", x7 ) ;
382   }
383 //
384 // 4.2. Cas d un cone defini par les 2 rayons
385   else if ( BoundaryType == 4 )
386   {
387     _Texte += Texte_inport( "double", "Xcentre1" ) ;
388     _Texte += Texte_inport( "double", "Ycentre1" ) ;
389     _Texte += Texte_inport( "double", "Zcentre1" ) ;
390     _Texte += Texte_inport( "double", "Radius1" ) ;
391     _Texte += Texte_inport( "double", "Xcentre2" ) ;
392     _Texte += Texte_inport( "double", "Ycentre2" ) ;
393     _Texte += Texte_inport( "double", "Zcentre2" ) ;
394     _Texte += Texte_inport( "double", "Radius2" ) ;
395     TexteParametre( node, "Xcentre1", "double", x0 ) ;
396     TexteParametre( node, "Ycentre1", "double", x1 ) ;
397     TexteParametre( node, "Zcentre1", "double", x2 ) ;
398     TexteParametre( node, "Radius1", "double", x3 ) ;
399     TexteParametre( node, "Xcentre2", "double", x4 ) ;
400     TexteParametre( node, "Ycentre2", "double", x5 ) ;
401     TexteParametre( node, "Zcentre2", "double", x6 ) ;
402     TexteParametre( node, "Radius2", "double", x7 ) ;
403   }
404 //
405 // 4.2. Erreur
406   else
407   { ASSERT("Type de frontiere inconnu." == 0); }
408
409 //
410 // 5. La fin
411   _Texte += "                              <outport name=\"return\" type=\"HOMARD_Boundary\"/>\n" ;
412   _Texte += "                           </service>\n" ;
413 //
414   return texte_control ;
415 //
416 }
417 //===============================================================================
418 // Controle des enchainements de noeud dans le noeud Iter_1
419 //===============================================================================
420   std::string YACSDriver::Texte_Iter_1_control()
421 {
422   MESSAGE("Texte_Iter_1_control");
423 //
424   std::string texte ;
425   texte  = Texte_control ("CreateCase", "Case_Options") ;
426   texte += Texte_control ("Case_Options", "CreateHypothesis") ;
427 //
428   return texte ;
429 //
430 }
431 //===============================================================================
432 // Controle des enchainements de noeuds
433 // noeud_1 : noeud de depart
434 // noeud_2 : noeud d'arrivee
435 //===============================================================================
436   std::string YACSDriver::Texte_control( const std::string noeud_1, const std::string noeud_2 )
437 {
438   MESSAGE("Texte_control, noeud_1 = "<<noeud_1<<", noeud_2 = "<<noeud_2);
439 //
440   std::string texte ;
441   texte  = "                           <control> " ;
442   texte += "<fromnode>" + noeud_1 + "</fromnode>" ;
443   texte += " <tonode>"  + noeud_2 + "</tonode>" ;
444   texte += " </control>\n" ;
445
446   return texte ;
447 //
448 }
449 //===============================================================================
450 // Inport
451 // inport_type : type de la donnee a importer
452 // inport_nom : nom de la donnee a importer
453 //===============================================================================
454   std::string YACSDriver::Texte_inport( const std::string inport_type, const std::string inport_nom )
455 {
456 //   MESSAGE("Texte_control, inport_type = "<<inport_type<<", inport_nom = "<<inport_nom);
457 //
458   std::string texte ;
459   texte  = "                              <inport " ;
460   texte += "name=\"" + inport_nom + "\" " ;
461   texte += "type=\"" + inport_type + "\"" ;
462   texte += "/>\n" ;
463
464   return texte ;
465 //
466 }
467 //===============================================================================
468 // Le repertoire d'execution
469 //===============================================================================
470 void YACSDriver::Texte_HOMARD_Exec_DirName( )
471 {
472   MESSAGE("Texte_HOMARD_Exec_DirName");
473 //
474   _Texte += "DirName = \"" + _DirName + "\"\n" ;
475 //
476 }
477 //===============================================================================
478 // Le nom du maillage
479 //===============================================================================
480 void YACSDriver::Texte_HOMARD_Exec_MeshName( const std::string MeshName )
481 {
482   MESSAGE("Texte_HOMARD_Exec_MeshName pour "<<MeshName);
483 //
484   _Texte += "MeshName = \"" + MeshName + "\"\n" ;
485 //
486 }
487 //===============================================================================
488 // Manipulation des instructions python
489 // pythonTexte : le texte des instructions python a manipuler
490 // indice : numero de la premiere ligne voulue
491 // concept : nom du concept a inserer
492 //===============================================================================
493 void YACSDriver::Texte_python( const std::string pythonTexte, int indice, const std::string concept )
494 {
495   MESSAGE("Texte_python, pythonTexte\n"<<pythonTexte);
496   MESSAGE("indice = "<<indice<<", concept = "<<concept);
497 //
498 // Conversion de type
499   std::istringstream tout (pythonTexte) ;
500 //   MESSAGE("\ntout :"<<tout);
501   std::string ligne; // variable contenant chaque ligne de python
502   std::string ligne_bis ; // variable contenant la portion de ligne de python apres '.'
503   int cptr = 0 ;
504   indice -= 1 ;
505   while ( std::getline( tout, ligne ) )
506   {
507     if ( cptr > indice )
508     {
509       int position = ligne.find_first_of( "." ) ;
510 //       MESSAGE("\nposition : "<< position);
511       if ( position > 0 )
512       {
513         ligne_bis = ligne.substr( position );
514 //         MESSAGE("\nligne_bis : "<< ligne_bis);
515         _Texte += concept + ligne_bis + "\n" ;
516       }
517     }
518     cptr += 1 ;
519   }
520 //
521 }
522 //===============================================================================
523 // Creation d'un parametre
524 //===============================================================================
525 void YACSDriver::TexteParametre( const std::string node, const std::string port, const std::string type_value, const std::string value )
526 {
527 //
528 //   MESSAGE("TexteParametre");
529   _Texte_parametres += "   <parameter>\n" ;
530   _Texte_parametres += "      <tonode>" + node + "</tonode>" ;
531   _Texte_parametres += "<toport>" + port + "</toport>\n" ;
532   _Texte_parametres += "      <value><" + type_value + ">" + value + "</" + type_value + "></value>\n" ;
533   _Texte_parametres += "   </parameter>\n" ;
534 //
535 }
536 //===============================================================================
537 // Ajout des parametres
538 //===============================================================================
539 void YACSDriver::TexteAddParametres( )
540 {
541 //
542   MESSAGE("TexteAddParametres");
543   TexteAdd(_Texte_parametres) ;
544 //
545 }
546 //===============================================================================
547 void YACSDriver::CreeFichier( )
548 {
549 //
550   MESSAGE("CreeFichier sur le fichier "<<_XMLFile);
551   std::ofstream Fic(_XMLFile.c_str(), std::ios::out ) ;
552   if (Fic.is_open() == true) { Fic << _Texte << std::endl ; }
553   Fic.close() ;
554 //
555 }
556 //===============================================================================
557 // REMARQUE : on devrait utiliser le GetStringInTexte de HOMARD_Gen_i mais je ne sais pas
558 //            comment l'appeler. ALors je clone.
559 // Recuperation de la chaine de caracteres par rapport l'apparition d'un texte
560 // ligne : la ligne a manipuler
561 // texte : le texte a reperer
562 // option : 0 : la chaine avant le texte
563 //          1 : la chaine apres le texte
564 // Si le texte est absent, on retourne la chaine totale
565 //===============================================================================
566 std::string YACSDriver::GetStringInTexte( const std::string ligne, const std::string texte, int option )
567 {
568 //   MESSAGE("GetStringInTexte, recherche de '"<<texte<<"' dans '"<<ligne<<"'"<<", option = "<<option);
569 //
570   std::string chaine = ligne ;
571   int position = ligne.find_first_of( texte ) ;
572   if ( position > 0 )
573   {
574     if ( option == 0 ) { chaine = ligne.substr( 0, position ) ; }
575     else               { chaine = ligne.substr( position+1 ) ; }
576   }
577 // Conversion de type
578   return chaine ;
579 //
580 }