+ MESSAGE ( "ComputeCAO avec Option1 = " << Option1 << ", Option2 = " << Option2 );
+
+ // A. Prealable
+ // A.1. Bases
+ int codret = 0;
+ // A.2. Le sous-répertoire de l'iteration en cours de traitement
+ char* DirCompute = myIteration->GetDirName();
+ // A.3. Le maillage résultat de l'iteration en cours de traitement
+ char* MeshFile = myIteration->GetMeshFile();
+
+ // B. Les données pour FrontTrack
+ // B.1. Le maillage à modifier
+ const std::string theInputMedFile = MeshFile;
+ MESSAGE ( ". theInputMedFile = " << theInputMedFile );
+
+ // B.2. Le maillage après modification : fichier identique
+ const std::string theOutputMedFile = MeshFile ;
+ MESSAGE ( ". theOutputMedFile = " << theInputMedFile );
+
+ // B.3. La liste des fichiers contenant les numéros des noeuds à bouger
+ std::vector< std::string > theInputNodeFiles ;
+ MESSAGE ( ". DirCompute = " << DirCompute );
+ int bilan ;
+ int icpt = 0 ;
+#ifndef WIN32
+ DIR *dp;
+ struct dirent *dirp;
+ dp = opendir(DirCompute);
+ while ( (dirp = readdir(dp)) != NULL )
+ {
+ std::string file_name(dirp->d_name);
+ bilan = file_name.find("fr") ;
+ if ( bilan != string::npos )
+ {
+ std::stringstream filename_total ;
+ filename_total << DirCompute << "/" << file_name ;
+ theInputNodeFiles.push_back(filename_total.str()) ;
+ icpt += 1 ;
+ }
+ }
+#else
+ HANDLE hFind = INVALID_HANDLE_VALUE;
+ WIN32_FIND_DATA ffd;
+ hFind = FindFirstFile(DirNameStart, &ffd);
+ if (INVALID_HANDLE_VALUE != hFind) {
+ while (FindNextFile(hFind, &ffd) != 0) {
+ std::string file_name(ffd.cFileName);
+ bilan = file_name.find("fr") ;
+ if ( bilan != string::npos )
+ {
+ std::stringstream filename_total ;
+ filename_total << DirCompute << "/" << file_name ;
+ theInputNodeFiles.push_back(filename_total.str()) ;
+ icpt += 1 ;
+ }
+ }
+ FindClose(hFind);
+ }
+#endif
+ for ( int i = 0; i < icpt; i++ )
+ { MESSAGE ( ". theInputNodeFiles["<< i << "] = " << theInputNodeFiles[i] ); }
+
+ // B.4. Le fichier de la CAO
+ HOMARD::ListBoundaryGroupType* ListBoundaryGroupType = myCase->GetBoundaryGroup();
+ std::string BoundaryName = std::string((*ListBoundaryGroupType)[0]);
+ MESSAGE ( ". BoundaryName = " << BoundaryName );
+ HOMARD::HOMARD_Boundary_var myBoundary = myStudyContext._mesBoundarys[BoundaryName];
+ const std::string theXaoFileName = myBoundary->GetDataFile();
+ MESSAGE ( ". theXaoFileName = " << theXaoFileName );
+
+ // B.5. Parallélisme
+ bool theIsParallel = false;
+
+ // C. Lancement des projections
+ MESSAGE ( ". Lancement des projections" );
+ FrontTrack* myFrontTrack = new FrontTrack();
+ myFrontTrack->track(theInputMedFile, theOutputMedFile, theInputNodeFiles, theXaoFileName, theIsParallel);
+
+ // D. Transfert des coordonnées modifiées dans le fichier historique de HOMARD
+ // On lance une exécution spéciale de HOMARD en attendant de savoir le faire avec MEDCoupling
+ MESSAGE ( ". Transfert des coordonnées" );
+ codret = ComputeCAObis(myIteration, Option1, Option2) ;
+
+ return codret ;
+}
+//=============================================================================
+//=============================================================================
+// Transfert des coordonnées en suivi de frontière CAO
+// Option1 >0 : appel depuis python
+// <0 : appel depuis GUI
+// Option2 : multiple de nombres premiers
+// 1 : aucune option
+// x2 : publication du maillage dans SMESH
+//=============================================================================
+CORBA::Long HOMARD_Gen_i::ComputeCAObis(HOMARD::HOMARD_Iteration_var myIteration, CORBA::Long Option1, CORBA::Long Option2)
+{
+ MESSAGE ( "ComputeCAObis, avec Option1 = " << Option1 << ", Option2 = " << Option2 );
+
+ // A. Prealable
+ int codret = 0;
+
+ // A.1. Controle de la possibilite d'agir
+ // A.1.1. Etat de l'iteration
+ int etat = myIteration->GetState();
+ MESSAGE ( "etat = "<<etat );
+ // A.1.2. L'iteration doit être calculee
+ if ( etat == 1 )
+ {
+ SALOME::ExceptionStruct es;
+ es.type = SALOME::BAD_PARAM;
+ es.text = "This iteration is not computed.";
+ throw SALOME::SALOME_Exception(es);
+ return 1 ;
+ }
+ // A.2. Numero de l'iteration
+ // siterp1 : numero de l'iteration a traiter
+ int NumeIter = myIteration->GetNumber();
+ std::string siterp1 ;
+ std::stringstream saux1 ;
+ saux1 << NumeIter ;
+ siterp1 = saux1.str() ;
+ if (NumeIter < 10) { siterp1 = "0" + siterp1 ; }
+ MESSAGE ( "siterp1 = "<<siterp1 );
+
+ // A.3. Le cas
+ const char* CaseName = myIteration->GetCaseName();
+ HOMARD::HOMARD_Cas_var myCase = myStudyContext._mesCas[CaseName];
+ ASSERT(!CORBA::is_nil(myCase));
+
+ // A.4. Le sous-répertoire de l'iteration a traiter
+ char* DirCompute = myIteration->GetDirName();
+ MESSAGE( ". DirCompute = " << DirCompute );
+
+ // C. Le fichier des messages
+ std::string LogFile = DirCompute ;
+ LogFile += "/Liste." + siterp1 + ".maj_coords.log" ;
+ MESSAGE (". LogFile = " << LogFile);
+ myIteration->SetFileInfo(LogFile.c_str());
+
+ // D. On passe dans le répertoire de l'iteration a calculer
+ MESSAGE ( ". On passe dans DirCompute = " << DirCompute );
+ CHDIR(DirCompute);
+
+ // E. Les données de l'exécution HOMARD
+ // E.1. L'objet du texte du fichier de configuration
+ HomardDriver* myDriver = new HomardDriver("", siterp1);
+ myDriver->TexteInit(DirCompute, LogFile, _Langue);
+
+ // E.2. Le maillage associe a l'iteration
+ const char* NomMesh = myIteration->GetMeshName();
+ MESSAGE ( ". NomMesh = " << NomMesh );
+ const char* MeshFile = myIteration->GetMeshFile();
+ MESSAGE ( ". MeshFile = " << MeshFile );
+
+ // E.3. Les données du traitement HOMARD
+ int iaux ;
+ myDriver->TexteMajCoords( NumeIter ) ;
+ iaux = 0 ;
+ myDriver->TexteMaillageHOMARD( DirCompute, siterp1, iaux ) ;
+ myDriver->TexteMaillage(NomMesh, MeshFile, 0);
+//
+ // E.4. Ecriture du texte dans le fichier
+ MESSAGE ( ". Ecriture du texte dans le fichier de configuration ; codret = "<<codret );
+ if (codret == 0)
+ { myDriver->CreeFichier(); }
+
+// F. Execution
+//
+ int codretexec = 1789 ;
+ if (codret == 0)
+ {
+ codretexec = myDriver->ExecuteHomard(Option1);
+ MESSAGE ( "Erreur en executant HOMARD : " << codretexec );
+ }
+
+ // G. Gestion des resultats
+ if (codret == 0)
+ {
+ // G.1. Le fichier des messages, dans tous les cas
+ const char* NomIteration = myIteration->GetName();
+ std::string Commentaire = "logmaj_coords" ;
+ PublishFileUnderIteration(NomIteration, LogFile.c_str(), Commentaire.c_str());
+ // G.2 Message d'erreur
+ if (codretexec != 0)
+ {
+ std::string text = "\n\nSee the file " + LogFile + "\n" ;
+ INFOS ( text ) ;
+ SALOME::ExceptionStruct es;
+ es.type = SALOME::BAD_PARAM;
+ es.text = CORBA::string_dup(text.c_str());
+ throw SALOME::SALOME_Exception(es);
+
+ // On force le succes pour pouvoir consulter le fichier log
+ codretexec = 0 ;
+ }
+ }
+
+ // H. Menage et retour dans le répertoire du cas
+ if (codret == 0) { delete myDriver; }
+
+ return codret ;
+}
+//=============================================================================
+// Creation d'un nom de sous-répertoire pour l'iteration au sein d'un répertoire parent
+// nomrep : nom du répertoire parent
+// num : le nom du sous-répertoire est sous la forme 'In', n est >= num
+//=============================================================================
+char* HOMARD_Gen_i::CreateDirNameIter(const char* nomrep, CORBA::Long num )
+{
+ MESSAGE ( "CreateDirNameIter : nomrep ="<< nomrep << ", num = "<<num);
+ // On verifie que le répertoire parent existe
+ int codret = CHDIR(nomrep) ;
+ if ( codret != 0 )
+ {
+ SALOME::ExceptionStruct es;
+ es.type = SALOME::BAD_PARAM;
+ es.text = "The directory of the case does not exist.";