]> SALOME platform Git repositories - modules/homard.git/blobdiff - src/HOMARD_I/HOMARD_Gen_i.cxx
Salome HOME
Merge from V6_main_20120808 08Aug12
[modules/homard.git] / src / HOMARD_I / HOMARD_Gen_i.cxx
index cc2ac949bde9ea684f8508aaa001b8700d0c380d..9415aa68d141f8176c5f2c7846ecac788cba3646 100755 (executable)
@@ -1,3 +1,22 @@
+// Copyright (C) 2011-2012  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
 #include "HOMARD_Gen_i.hxx"
 #include "HOMARD_Cas_i.hxx"
 #include "HOMARD_Hypothesis_i.hxx"
 
 using  namespace std;
 
+//=======================================================================
+//function : RemoveTabulation
+//purpose  :
+//=======================================================================
+std::string RemoveTabulation( std::string theScript )
+{
+  std::string::size_type aPos = 0;
+  while( aPos < theScript.length() )
+  {
+    aPos = theScript.find( "\n\t", aPos );
+    if( aPos == std::string::npos )
+      break;
+    theScript.replace( aPos, 2, "\n" );
+    aPos++;
+  }
+  return theScript;
+}
+
 //=============================================================================
 /*!
  *  standard constructor
  */
 //=============================================================================
-HOMARD_Gen_i::HOMARD_Gen_i(CORBA::ORB_ptr orb,
-                          PortableServer::POA_ptr poa,
-                          PortableServer::ObjectId * contId, 
-                          const char *instanceName, 
-                          const char *interfaceName) :
-  Engines_Component_i(orb, poa, contId, instanceName, interfaceName)
-{
-  MESSAGE("activate object");
+HOMARD_Gen_i::HOMARD_Gen_i( CORBA::ORB_ptr orb,
+                            PortableServer::POA_ptr poa,
+                            PortableServer::ObjectId * contId,
+                            const char *instanceName,
+                            const char *interfaceName) :
+Engines_Component_i(orb, poa, contId, instanceName, interfaceName)
+{
+  MESSAGE("constructor");
   _thisObj = this;
   _id = _poa->activate_object(_thisObj);
 
@@ -63,15 +100,15 @@ HOMARD_Gen_i::~HOMARD_Gen_i()
 }
 //=============================================================================
 /*!
- *  Ajoute le composant homard dans l etude si necessaire 
+ *  Ajoute le composant homard dans l etude si necessaire
  */
 //=============================================================================
 void HOMARD_Gen_i::addInStudy(SALOMEDS::Study_ptr theStudy)
 {
   ASSERT(!CORBA::is_nil(theStudy));
-  MESSAGE("addInStudy: current study ID = " << GetCurrentStudyID());
+  MESSAGE("addInStudy: ajout eventuel du composant HOMARD dans current study ID = " << GetCurrentStudyID()) ;
   SALOMEDS::StudyBuilder_var myBuilder = theStudy->NewBuilder();
+
   // Create SComponent labelled 'homard' if it doesn't already exit
   SALOMEDS::SComponent_var homardFather = theStudy->FindComponent(ComponentDataType());
   if (CORBA::is_nil(homardFather))
@@ -81,15 +118,15 @@ void HOMARD_Gen_i::addInStudy(SALOMEDS::Study_ptr theStudy)
 
     bool aLocked = theStudy->GetProperties()->IsLocked();
     if (aLocked) theStudy->GetProperties()->SetLocked(false);
-    
+
     homardFather = myBuilder->NewComponent(ComponentDataType());
     SALOMEDS::GenericAttribute_var anAttr = myBuilder->FindOrCreateAttribute(homardFather,"AttributeName");
     SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
     CORBA::Object_var objVarN = _NS->Resolve("/Kernel/ModulCatalog");
-    SALOME_ModuleCatalog::ModuleCatalog_var Catalogue = 
+    SALOME_ModuleCatalog::ModuleCatalog_var Catalogue =
                 SALOME_ModuleCatalog::ModuleCatalog::_narrow(objVarN);
     SALOME_ModuleCatalog::Acomponent_var Comp = Catalogue->GetComponent(ComponentDataType());
-    if (!Comp->_is_nil()) 
+    if (!Comp->_is_nil())
     {
       aName->SetValue(ComponentDataType());
     }
@@ -126,7 +163,7 @@ SALOMEDS::Study_ptr HOMARD_Gen_i::GetCurrentStudy()
 }
 
 //=============================================================================
-int HOMARD_Gen_i::GetCurrentStudyID()
+CORBA::Long HOMARD_Gen_i::GetCurrentStudyID()
 //=============================================================================
 {
   return myCurrentStudy->_is_nil() ? -1 : myCurrentStudy->StudyId();
@@ -135,15 +172,8 @@ int HOMARD_Gen_i::GetCurrentStudyID()
 //=============================================================================
 void HOMARD_Gen_i::AssociateCaseIter(const char* nomCas, const char* nomIter, const char* labelIter)
 {
-  MESSAGE( "AssociateCaseIter " << nomCas << " ," << nomIter << ","  << labelIter );
-  if (CORBA::is_nil(myCurrentStudy))
-  {
-      SALOME::ExceptionStruct es;
-      es.type = SALOME::BAD_PARAM;
-      es.text = "Invalid Study Context ";
-      throw SALOME::SALOME_Exception(es);
-      return ;
-  };
+  MESSAGE( "AssociateCaseIter : " << nomCas << " ," << nomIter << ","  << labelIter );
+  IsValidStudy () ;
 
   HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
   if (CORBA::is_nil(myCase))
@@ -178,7 +208,7 @@ void HOMARD_Gen_i::AssociateCaseIter(const char* nomCas, const char* nomIter, co
 
   aStudyBuilder->NewCommand();
   SALOMEDS::SObject_var newStudyIter = aStudyBuilder->NewObject(aCasSO);
-  PublishInStudyAttr(aStudyBuilder, newStudyIter, nomIter , labelIter, 
+  PublishInStudyAttr(aStudyBuilder, newStudyIter, nomIter , labelIter,
                      "iter_non_calculee.png", _orb->object_to_string(myIteration)) ;
   aStudyBuilder->CommitCommand();
 
@@ -187,10 +217,10 @@ void HOMARD_Gen_i::AssociateCaseIter(const char* nomCas, const char* nomIter, co
 }
 
 //=====================================================================================
-void HOMARD_Gen_i::SetEtatIter(const char* nomIter, const bool EtatCalcul)
+void HOMARD_Gen_i::SetEtatIter(const char* nomIter, const CORBA::Boolean EtatCalcul)
 //=====================================================================================
 {
-  MESSAGE( "SetEtatIter, nomIter  = " << nomIter << " etat " << EtatCalcul );
+  MESSAGE( "SetEtatIter : nomIter  = " << nomIter << " etat " << EtatCalcul );
   HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[nomIter];
   if (CORBA::is_nil(myIteration))
   {
@@ -215,21 +245,50 @@ void HOMARD_Gen_i::SetEtatIter(const char* nomIter, const bool EtatCalcul)
   };
 
   int number = myIteration->GetNumber() ;
-  if ( number == 0 )  
-      PublishInStudyAttr(aStudyBuilder, aIterSO, NULL , NULL, "iter0.png", NULL) ;
-  else if (EtatCalcul) 
-      PublishInStudyAttr(aStudyBuilder, aIterSO, NULL, NULL, "iter_calculee.png", NULL) ;
-  else                 
-      PublishInStudyAttr(aStudyBuilder, aIterSO, NULL, NULL, "iter_non_calculee.png", NULL) ;
+  const char* icone ;
+  if ( number == 0 )
+    icone = "iter0.png" ;
+  else if (EtatCalcul)
+    icone = "iter_calculee.png" ;
+  else
+    icone = "iter_non_calculee.png" ;
+  PublishInStudyAttr(aStudyBuilder, aIterSO, NULL , NULL, icone, NULL) ;
 
   aStudyBuilder->CommitCommand();
 
 }
 //=====================================================================================
+void HOMARD_Gen_i::InvalideBoundary(const char* BoundaryName)
+//=====================================================================================
+{
+  MESSAGE( "InvalideBoundary : BoundaryName    = " << BoundaryName  );
+  HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName];
+  if (CORBA::is_nil(myBoundary))
+  {
+      SALOME::ExceptionStruct es;
+      es.type = SALOME::BAD_PARAM;
+      es.text = "Invalid Boundary ";
+      throw SALOME::SALOME_Exception(es);
+      return ;
+  };
+  SALOME::ExceptionStruct es;
+  es.type = SALOME::BAD_PARAM;
+  es.text = "No change is allowed in boundary. Ask for evolution.";
+  throw SALOME::SALOME_Exception(es);
+  return ;
+/*  HOMARD::listeHypo* maListe = myBoundary->GetHypo();
+  int numberOfHypo = maListe->length();
+  for (int NumeHypo = 0; NumeHypo< numberOfHypo; NumeHypo++)
+  {
+      std::string nomHypo = std::string((*maListe)[NumeHypo]);
+      InvalideHypo(nomHypo.c_str());
+  }*/
+}
+//=====================================================================================
 void HOMARD_Gen_i::InvalideZone(const char* ZoneName)
 //=====================================================================================
 {
-  MESSAGE( "InvalideZone, ZoneName    = " << ZoneName  );
+  MESSAGE( "InvalideZone : ZoneName    = " << ZoneName  );
   HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[ZoneName];
   if (CORBA::is_nil(myZone))
   {
@@ -251,7 +310,7 @@ void HOMARD_Gen_i::InvalideZone(const char* ZoneName)
 void HOMARD_Gen_i::InvalideHypo(const char* nomHypo)
 //=====================================================================================
 {
-  MESSAGE( "InvalideHypo, nomHypo    = " << nomHypo  );
+  MESSAGE( "InvalideHypo : nomHypo    = " << nomHypo  );
   HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypo];
   if (CORBA::is_nil(myHypo))
   {
@@ -275,7 +334,7 @@ void HOMARD_Gen_i::InvalideHypo(const char* nomHypo)
 void HOMARD_Gen_i::InvalideIter(const char* nomIter)
 //=====================================================================================
 {
-  MESSAGE("InvalideIter, nomIter    = " << nomIter);
+  MESSAGE("InvalideIter : nomIter    = " << nomIter);
   SetEtatIter(nomIter,false);
   HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[nomIter];
   if (CORBA::is_nil(myIteration))
@@ -297,7 +356,7 @@ void HOMARD_Gen_i::InvalideIter(const char* nomIter)
 
   SALOMEDS::SObject_var aIterSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myIteration)));
   SALOMEDS::ChildIterator_var  aIter = myCurrentStudy->NewChildIterator(aIterSO);
-  for (; aIter->More(); aIter->Next()) 
+  for (; aIter->More(); aIter->Next())
   {
       SALOMEDS::SObject_var so = aIter->Value();
       SALOMEDS::GenericAttribute_var anAttr;
@@ -337,18 +396,10 @@ void HOMARD_Gen_i::InvalideIter(const char* nomIter)
 }
 //
 //=====================================================================================
-void HOMARD_Gen_i::AssociateHypoZone(const char* ZoneName, const char* nomHypothesis)
+void HOMARD_Gen_i::AssociateHypoZone(const char* nomHypothesis, const char* ZoneName, CORBA::Long TypeUse)
 {
-  MESSAGE ( " AssociateHypoZone, ZoneName= " << ZoneName << ", nomHypo = " << nomHypothesis);
-
-  if (CORBA::is_nil(myCurrentStudy))
-  {
-      SALOME::ExceptionStruct es;
-      es.type = SALOME::BAD_PARAM;
-      es.text = "Invalid Study Context ";
-      throw SALOME::SALOME_Exception(es);
-      return ;
-  };
+  MESSAGE ( "AssociateHypoZone : nomHypo = " << nomHypothesis << ", ZoneName= " << ZoneName << ", TypeUse = " << TypeUse);
+  IsValidStudy () ;
 
   HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypothesis];
   ASSERT(!CORBA::is_nil(myHypo));
@@ -367,22 +418,15 @@ void HOMARD_Gen_i::AssociateHypoZone(const char* ZoneName, const char* nomHypoth
   aStudyBuilder->CommitCommand();
 
   myZone->AddHypo(nomHypothesis);
-  myHypo->AddZone(ZoneName);
+  myHypo->AddZone(ZoneName, TypeUse);
+  MESSAGE ( "Fin de AssociateHypoZone");
 };
 
 //=====================================================================================
 void HOMARD_Gen_i::DissociateHypoZone(const char* ZoneName, const char* nomHypothesis)
 {
-  MESSAGE ( " DissociateHypoZone, ZoneName= " << ZoneName << ", nomHypo = " << nomHypothesis);
-
-  if (CORBA::is_nil(myCurrentStudy))
-  {
-      SALOME::ExceptionStruct es;
-      es.type = SALOME::BAD_PARAM;
-      es.text = "Invalid Study Context ";
-      throw SALOME::SALOME_Exception(es);
-      return ;
-  };
+  MESSAGE ( "DissociateHypoZone : ZoneName= " << ZoneName << ", nomHypo = " << nomHypothesis);
+  IsValidStudy () ;
 
   HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypothesis];
   ASSERT(!CORBA::is_nil(myHypo));
@@ -402,7 +446,7 @@ void HOMARD_Gen_i::DissociateHypoZone(const char* ZoneName, const char* nomHypot
   {
     SALOMEDS::SObject_var aHypObj = it->Value();
     SALOMEDS::SObject_var ptrObj;
-    if (aHypObj->ReferencedObject(ptrObj)) 
+    if (aHypObj->ReferencedObject(ptrObj))
     {
       if (std::string(ptrObj->GetName()) == std::string(aZoneSO->GetName()))
       {
@@ -421,15 +465,8 @@ void HOMARD_Gen_i::DissociateHypoZone(const char* ZoneName, const char* nomHypot
 //=============================================================================
 void HOMARD_Gen_i::AssociateIterIter(const char* nomIterParent, const char* nomIter)
 {
-  MESSAGE ( "AssociateIterIter, nomIter       = " << nomIter << " nomIterParent = " << nomIterParent);
-  if (CORBA::is_nil(myCurrentStudy))
-  {
-      SALOME::ExceptionStruct es;
-      es.type = SALOME::BAD_PARAM;
-      es.text = "Invalid Study Context ";
-      throw SALOME::SALOME_Exception(es);
-      return ;
-  };
+  MESSAGE ( "AssociateIterIter : nomIter       = " << nomIter << " nomIterParent = " << nomIterParent);
+  IsValidStudy () ;
 
   HOMARD::HOMARD_Iteration_var myIterationParent = myContextMap[GetCurrentStudyID()]._mesIterations[nomIterParent];
   ASSERT(!CORBA::is_nil(myIterationParent));
@@ -443,16 +480,8 @@ void HOMARD_Gen_i::AssociateIterIter(const char* nomIterParent, const char* nomI
 //===================================================================================
 void HOMARD_Gen_i::AssociateIterHypo(const char* nomIter, const char* nomHypo)
 {
-  MESSAGE("AssociateIterHypo, nomHypo = " << nomHypo << " nomIter = " << nomIter);
-
-  if (CORBA::is_nil(myCurrentStudy))
-  {
-      SALOME::ExceptionStruct es;
-      es.type = SALOME::BAD_PARAM;
-      es.text = "Invalid Study Context ";
-      throw SALOME::SALOME_Exception(es);
-      return ;
-  };
+  MESSAGE("AssociateIterHypo : nomHypo = " << nomHypo << " nomIter = " << nomIter);
+  IsValidStudy () ;
 
   HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypo];
   ASSERT(!CORBA::is_nil(myHypo));
@@ -472,7 +501,7 @@ void HOMARD_Gen_i::AssociateIterHypo(const char* nomIter, const char* nomHypo)
   aStudyBuilder->Addreference(aSubSO, aHypoSO);
 
   aStudyBuilder->CommitCommand();
-  
+
   myIteration->SetHypoName(nomHypo);
   myHypo->AddIteration(nomIter);
 };
@@ -490,17 +519,10 @@ CORBA::Boolean HOMARD_Gen_i::VerifieDir(const char* nomDir)
 }
 
 //=============================================================================
-HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCase(const char* nomCas, const char* MeshName, const char* FileName)
+HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCase(const char* nomCas, const char* MeshName, const char* MeshFile)
 {
-  MESSAGE ( "CreateCase, nomCas   = " << nomCas << "MeshName = " << MeshName );
-  if (CORBA::is_nil(myCurrentStudy))
-  {
-      SALOME::ExceptionStruct es;
-      es.type = SALOME::BAD_PARAM;
-      es.text = "Invalid Study Context ";
-      throw SALOME::SALOME_Exception(es);
-      return 0;
-  };
+  MESSAGE ( "CreateCase : nomCas = " << nomCas << ", MeshName = " << MeshName << ", MeshFile = " << MeshFile );
+  IsValidStudy () ;
 
   if ((myContextMap[GetCurrentStudyID()]._mesCas).find(nomCas)!=(myContextMap[GetCurrentStudyID()]._mesCas).end())
   {
@@ -518,15 +540,15 @@ HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCase(const char* nomCas, const char*
   myContextMap[GetCurrentStudyID()]._mesCas[nomCas] = myCase;
 
 
-  std::vector<double> LesExtremes =GetBoundingBoxInMedFile(FileName);
+  std::vector<double> LesExtremes =GetBoundingBoxInMedFile(MeshFile);
   HOMARD::extrema_var aSeq = new HOMARD::extrema();
-  if (LesExtremes.size()!=10) { return false; } 
+  if (LesExtremes.size()!=10) { return false; }
   aSeq->length(10);
   for (int i =0; i< LesExtremes.size(); i++)
        aSeq[i]=LesExtremes[i];
   myCase->SetBoundingBox(aSeq);
 
-  std::set<std::string> LesGroupes  =GetListeGroupesInMedFile(FileName);
+  std::set<std::string> LesGroupes  =GetListeGroupesInMedFile(MeshFile);
   HOMARD::ListGroupType_var aSeqGroupe = new HOMARD::ListGroupType;
   aSeqGroupe->length(LesGroupes.size());
   std::set<std::string>::const_iterator it;
@@ -554,14 +576,17 @@ HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCase(const char* nomCas, const char*
 
   anIter->SetDirName(DirName.str().c_str());
   anIter->SetName(nomIter.c_str());
-  anIter->SetMeshFile(FileName);
+  anIter->SetMeshFile(MeshFile);
   anIter->SetMeshName(MeshName);
   anIter->SetNumber(0);
 
   AssociateCaseIter (nomCas,nomIter.c_str(),"IterationHomard");
   SetEtatIter(nomIter.c_str(),true);
 //
-  PublishResultInSmesh(FileName, 0);
+  PublishResultInSmesh(MeshFile, 0);
+
+// Valeurs par defaut des filtrages
+  myCase->SetPyram(0);
 
   return HOMARD::HOMARD_Cas::_duplicate(myCase);
 }
@@ -569,14 +594,7 @@ HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCase(const char* nomCas, const char*
 //=============================================================================
 HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::GetCas(const char* nomCas)
 {
-  if (CORBA::is_nil(myCurrentStudy))
-  {
-      SALOME::ExceptionStruct es;
-      es.type = SALOME::BAD_PARAM;
-      es.text = "Invalid Study Context ";
-      throw SALOME::SALOME_Exception(es);
-      return 0;
-  };
+  IsValidStudy () ;
   HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
   if (CORBA::is_nil(myCase))
   {
@@ -586,20 +604,14 @@ HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::GetCas(const char* nomCas)
       throw SALOME::SALOME_Exception(es);
       return 0;
   };
+
   return HOMARD::HOMARD_Cas::_duplicate(myCase);
 }
 
 //=============================================================================
 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::GetZone(const char* ZoneName)
 {
-  if (CORBA::is_nil(myCurrentStudy))
-  {
-      SALOME::ExceptionStruct es;
-      es.type = SALOME::BAD_PARAM;
-      es.text = "Invalid Study Context ";
-      throw SALOME::SALOME_Exception(es);
-      return 0;
-  };
+  IsValidStudy () ;
   HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[ZoneName];
   ASSERT(!CORBA::is_nil(myZone));
   return HOMARD::HOMARD_Zone::_duplicate(myZone);
@@ -608,15 +620,9 @@ HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::GetZone(const char* ZoneName)
 //=============================================================================
 HOMARD::HOMARD_Hypothesis_ptr HOMARD_Gen_i::GetHypothesis(const char* nomHypothesis)
 {
-  if (CORBA::is_nil(myCurrentStudy))
-  {
-      SALOME::ExceptionStruct es;
-      es.type = SALOME::BAD_PARAM;
-      es.text = "Invalid Study Context ";
-      throw SALOME::SALOME_Exception(es);
-      return 0;
-  };
-
+  MESSAGE ( "GetHypothesis : nomHypothesis = " << nomHypothesis );
+  IsValidStudy () ;
+  MESSAGE ( "GetHypothesis : GetCurrentStudyID() = " << GetCurrentStudyID() );
   HOMARD::HOMARD_Hypothesis_var myHypothesis = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypothesis];
   ASSERT(!CORBA::is_nil(myHypothesis));
   return HOMARD::HOMARD_Hypothesis::_duplicate(myHypothesis);
@@ -625,14 +631,7 @@ HOMARD::HOMARD_Hypothesis_ptr HOMARD_Gen_i::GetHypothesis(const char* nomHypothe
 //=============================================================================
 HOMARD::HOMARD_Iteration_ptr  HOMARD_Gen_i::GetIteration(const char* nomIteration)
 {
-  if (CORBA::is_nil(myCurrentStudy))
-  {
-      SALOME::ExceptionStruct es;
-      es.type = SALOME::BAD_PARAM;
-      es.text = "Invalid Study Context ";
-      throw SALOME::SALOME_Exception(es);
-      return 0;
-  };
+  IsValidStudy () ;
   HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[nomIteration];
   ASSERT(!CORBA::is_nil(myIteration));
   return HOMARD::HOMARD_Iteration::_duplicate(myIteration);
@@ -640,14 +639,7 @@ HOMARD::HOMARD_Iteration_ptr  HOMARD_Gen_i::GetIteration(const char* nomIteratio
 //=============================================================================
 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::GetBoundary(const char* nomBoundary)
 {
-  if (CORBA::is_nil(myCurrentStudy))
-  {
-      SALOME::ExceptionStruct es;
-      es.type = SALOME::BAD_PARAM;
-      es.text = "Invalid Study Context ";
-      throw SALOME::SALOME_Exception(es);
-      return 0;
-  };
+  IsValidStudy () ;
 
   HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[nomBoundary];
   ASSERT(!CORBA::is_nil(myBoundary));
@@ -657,15 +649,8 @@ HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::GetBoundary(const char* nomBoundary)
 //=============================================================================
 HOMARD::HOMARD_Hypothesis_ptr HOMARD_Gen_i::CreateHypothesis(const char* nomHypothesis)
 {
-  MESSAGE ( "CreateHypothesis, nomHypothesis  = " << nomHypothesis );
-  if (CORBA::is_nil(myCurrentStudy))
-  {
-      SALOME::ExceptionStruct es;
-      es.type = SALOME::BAD_PARAM;
-      es.text = "Invalid Study Context ";
-      throw SALOME::SALOME_Exception(es);
-      return 0;
-  };
+  MESSAGE ( "CreateHypothesis : nomHypothesis  = " << nomHypothesis );
+  IsValidStudy () ;
 
   if ((myContextMap[GetCurrentStudyID()]._mesHypotheses).find(nomHypothesis) != (myContextMap[GetCurrentStudyID()]._mesHypotheses).end())
   {
@@ -682,6 +667,11 @@ HOMARD::HOMARD_Hypothesis_ptr HOMARD_Gen_i::CreateHypothesis(const char* nomHypo
   SALOMEDS::SObject_var aSO;
   PublishInStudy(myCurrentStudy, aSO, myHypothesis, nomHypothesis);
 
+// Valeurs par defaut des options avancees
+  myHypothesis->SetNivMax(-1);
+  myHypothesis->SetDiamMin(-1.0);
+  myHypothesis->SetAdapInit(0);
+
   return HOMARD::HOMARD_Hypothesis::_duplicate(myHypothesis);
 }
 
@@ -689,15 +679,8 @@ HOMARD::HOMARD_Hypothesis_ptr HOMARD_Gen_i::CreateHypothesis(const char* nomHypo
 HOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::CreateIteration(const char* nomIteration, const char* nomIterParent)
 //============================================================================================================
 {
-  MESSAGE ("CreateIteration, nomIteration  = " << nomIteration << "nomIterParent = " << nomIterParent);
-  if (CORBA::is_nil(myCurrentStudy))
-  {
-      SALOME::ExceptionStruct es;
-      es.type = SALOME::BAD_PARAM;
-      es.text = "Invalid Study Context ";
-      throw SALOME::SALOME_Exception(es);
-      return 0;
-  };
+  MESSAGE ("CreateIteration : nomIteration  = " << nomIteration << "nomIterParent = " << nomIterParent);
+  IsValidStudy () ;
 
   HOMARD::HOMARD_Iteration_var myIterationParent = myContextMap[GetCurrentStudyID()]._mesIterations[nomIterParent];
   if (CORBA::is_nil(myIterationParent))
@@ -710,7 +693,7 @@ HOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::CreateIteration(const char* nomIterat
   };
 
   const char* nomCas = GetCaseName(nomIterParent);
-  MESSAGE ("CreateIteration, nomCas = " << nomCas);
+  MESSAGE ("CreateIteration : nomCas = " << nomCas);
   HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
   if (CORBA::is_nil(myCase))
   {
@@ -761,10 +744,10 @@ HOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::CreateIteration(const char* nomIterat
 // cas le plus frequent.
 // Si on a plusieurs branches, donc des iterations a meme niveau d'adaptation, utiliser
 // le nombre d'iterations du cas permet d'eviter les collisions.
-   std::stringstream FileName;
+   std::stringstream MeshFile;
    const char* nomDir = myCase->GetDirName();
-   FileName << nomDir << "/maill." << iaux.str() << ".med";
-   myIteration->SetMeshFile(FileName.str().c_str());
+   MeshFile << nomDir << "/maill." << iaux.str() << ".med";
+   myIteration->SetMeshFile(MeshFile.str().c_str());
 
 // Association avec le cas et l'iteration precedente
    std::string label = "IterationHomard_" + std::string(nomIterParent);
@@ -778,15 +761,8 @@ HOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::CreateIteration(const char* nomIterat
 //=============================================================================
 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundary(const char* BoundaryName, CORBA::Long BoundaryType)
 {
-  MESSAGE ("BoundaryName  = " << BoundaryName << ", BoundaryType = " << BoundaryType);
-  if (CORBA::is_nil(myCurrentStudy))
-  {
-      SALOME::ExceptionStruct es;
-      es.type = SALOME::BAD_PARAM;
-      es.text = "Invalid Study Context ";
-      throw SALOME::SALOME_Exception(es);
-      return 0;
-  };
+  MESSAGE ("CreateBoundary : BoundaryName  = " << BoundaryName << ", BoundaryType = " << BoundaryType);
+  IsValidStudy () ;
 
   if ((myContextMap[GetCurrentStudyID()]._mesBoundarys).find(BoundaryName)!=(myContextMap[GetCurrentStudyID()]._mesBoundarys).end())
   {
@@ -806,24 +782,48 @@ HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundary(const char* BoundaryNam
   SALOMEDS::SObject_var aSO;
   SALOMEDS::SObject_var aResultSO=PublishInStudy(myCurrentStudy, aSO, myBoundary, BoundaryName);
 
-// Limites par defaut pour initialiser en cas de lancement par python
+  return HOMARD::HOMARD_Boundary::_duplicate(myBoundary);
+}
+//=============================================================================
+HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundaryDi(const char* BoundaryName, const char* MeshName, const char* MeshFile)
+{
+  MESSAGE ("CreateBoundaryDi : BoundaryName  = " << BoundaryName << "MeshName = " << MeshName );
+  HOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 0);
+  myBoundary->SetMeshFile( MeshFile ) ;
+  myBoundary->SetMeshName( MeshName ) ;
 
   return HOMARD::HOMARD_Boundary::_duplicate(myBoundary);
 }
+//=============================================================================
+HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundaryCylinder(const char* BoundaryName,
+                                      CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
+                                      CORBA::Double Xaxis, CORBA::Double Yaxis, CORBA::Double Zaxis,
+                                      CORBA::Double Rayon)
+{
+  MESSAGE ("CreateBoundaryCylinder : BoundaryName  = " << BoundaryName ) ;
+  HOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 1) ;
+  myBoundary->SetCylinder( Xcentre, Ycentre, Zcentre, Xaxis, Yaxis, Zaxis, Rayon ) ;
+
+  return HOMARD::HOMARD_Boundary::_duplicate(myBoundary) ;
+}
+//=============================================================================
+HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundarySphere(const char* BoundaryName,
+                                      CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
+                                      CORBA::Double Rayon)
+{
+  MESSAGE ("CreateBoundarySphere : BoundaryName  = " << BoundaryName ) ;
+  HOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 2) ;
+  myBoundary->SetSphere( Xcentre, Ycentre, Zcentre, Rayon ) ;
+
+  return HOMARD::HOMARD_Boundary::_duplicate(myBoundary) ;
+}
 
 
 //=============================================================================
 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZone(const char* ZoneName, CORBA::Long ZoneType)
 {
-  MESSAGE ("ZoneName  = " << ZoneName << ", ZoneType = " << ZoneType);
-  if (CORBA::is_nil(myCurrentStudy))
-  {
-      SALOME::ExceptionStruct es;
-      es.type = SALOME::BAD_PARAM;
-      es.text = "Invalid Study Context ";
-      throw SALOME::SALOME_Exception(es);
-      return 0;
-  };
+  MESSAGE ("CreateZone : ZoneName  = " << ZoneName << ", ZoneType = " << ZoneType);
+  IsValidStudy () ;
 
   if ((myContextMap[GetCurrentStudyID()]._mesZones).find(ZoneName)!=(myContextMap[GetCurrentStudyID()]._mesZones).end())
   {
@@ -845,24 +845,166 @@ HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZone(const char* ZoneName, CORBA::Lo
 
   return HOMARD::HOMARD_Zone::_duplicate(myZone);
 }
+//=============================================================================
+HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneBox(const char* ZoneName,
+                                      CORBA::Double Xmini, CORBA::Double Xmaxi,
+                                      CORBA::Double Ymini, CORBA::Double Ymaxi,
+                                      CORBA::Double Zmini, CORBA::Double Zmaxi)
+{
+  MESSAGE ("CreateZoneBox : ZoneName  = " << ZoneName ) ;
+  HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 2) ;
+  myZone->SetBox ( Xmini, Xmaxi, Ymini, Ymaxi, Zmini, Zmaxi) ;
 
+  return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
+}
 //=============================================================================
-CORBA::Boolean HOMARD_Gen_i::Compute(const char* nomIteration, CORBA::Long etatMenage)
+HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneSphere(const char* ZoneName,
+                                      CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre, CORBA::Double Rayon)
 {
-  MESSAGE ( "Compute, calcul de " << nomIteration );
-  if (CORBA::is_nil(myCurrentStudy))
-  {
-      SALOME::ExceptionStruct es;
-      es.type = SALOME::BAD_PARAM;
-      es.text = "Invalid Study Context ";
-      throw SALOME::SALOME_Exception(es);
-      return 0;
-  };
+  MESSAGE ("CreateZoneSphere : ZoneName  = " << ZoneName ) ;
+  HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 4) ;
+  myZone->SetSphere( Xcentre, Ycentre, Zcentre, Rayon ) ;
+
+  return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
+}
+//=============================================================================
+HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneCylinder(const char* ZoneName,
+                                      CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
+                                      CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe,
+                                      CORBA::Double Rayon, CORBA::Double Haut)
+{
+  MESSAGE ("CreateZoneCylinder : ZoneName  = " << ZoneName ) ;
+  HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 5) ;
+  myZone->SetCylinder( Xcentre, Ycentre, Zcentre, Xaxe, Yaxe, Zaxe, Rayon, Haut ) ;
+
+  return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
+}
+//=============================================================================
+HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZonePipe(const char* ZoneName,
+                                      CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
+                                      CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe,
+                                      CORBA::Double Rayon, CORBA::Double Haut, CORBA::Double Rayonint)
+{
+  MESSAGE ("CreateZonePipe : ZoneName  = " << ZoneName ) ;
+  HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 7) ;
+  myZone->SetPipe( Xcentre, Ycentre, Zcentre, Xaxe, Yaxe, Zaxe, Rayon, Haut, Rayonint ) ;
+
+  return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
+}
+//=============================================================================
+HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneBox2D(const char* ZoneName,
+                                      CORBA::Double Umini, CORBA::Double Umaxi,
+                                      CORBA::Double Vmini, CORBA::Double Vmaxi,
+                                      CORBA::Long Orient)
+{
+  MESSAGE ("CreateZoneBox2D : ZoneName  = " << ZoneName ) ;
+//   MESSAGE ("Umini = " << Umini << ", Umaxi =" << Umaxi ) ;
+//   MESSAGE ("Vmini = " << Vmini << ", Vmaxi =" << Vmaxi ) ;
+//   MESSAGE ("Orient = " << Orient ) ;
+
+  double Xmini, Xmaxi ;
+  double Ymini, Ymaxi ;
+  double Zmini, Zmaxi ;
+  if ( Orient == 1 )
+  { Xmini = Umini ;
+    Xmaxi = Umaxi ;
+    Ymini = Vmini ;
+    Ymaxi = Vmaxi ;
+    Zmini = 0. ;
+    Zmaxi = 0. ; }
+  else if ( Orient == 2 )
+  { Xmini = 0. ;
+    Xmaxi = 0. ;
+    Ymini = Umini ;
+    Ymaxi = Umaxi ;
+    Zmini = Vmini ;
+    Zmaxi = Vmaxi ; }
+  else if ( Orient == 3 )
+  { Xmini = Vmini ;
+    Xmaxi = Vmaxi ;
+    Ymini = 0. ;
+    Ymaxi = 0. ;
+    Zmini = Umini ;
+    Zmaxi = Umaxi ; }
+  else { ASSERT( Orient >= 1 and Orient <= 3 ) ; }
+
+  HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 10+Orient) ;
+  myZone->SetBox ( Xmini, Xmaxi, Ymini, Ymaxi, Zmini, Zmaxi) ;
+
+  return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
+}
+//=============================================================================
+HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneDisk(const char* ZoneName,
+                                      CORBA::Double Ucentre, CORBA::Double Vcentre,
+                                      CORBA::Double Rayon,
+                                      CORBA::Long Orient)
+{
+  MESSAGE ("CreateZoneDisk : ZoneName  = " << ZoneName ) ;
+  double Xcentre ;
+  double Ycentre ;
+  double Zcentre ;
+  if ( Orient == 1 )
+  { Xcentre = Ucentre ;
+    Ycentre = Vcentre ;
+    Zcentre = 0. ; }
+  else if ( Orient == 2 )
+  { Xcentre = 0. ;
+    Ycentre = Ucentre ;
+    Zcentre = Vcentre ; }
+  else if ( Orient == 3 )
+  { Xcentre = Vcentre ;
+    Ycentre = 0. ;
+    Zcentre = Ucentre ; }
+  else { ASSERT( Orient >= 1 and Orient <= 3 ) ; }
+
+  HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 30+Orient) ;
+  myZone->SetCylinder( Xcentre, Ycentre, Zcentre, 0., 0., 1., Rayon, 1. ) ;
+
+  return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
+}
+//=============================================================================
+HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneDiskWithHole(const char* ZoneName,
+                                      CORBA::Double Ucentre, CORBA::Double Vcentre,
+                                      CORBA::Double Rayon, CORBA::Double Rayonint,
+                                      CORBA::Long Orient)
+{
+  MESSAGE ("CreateZoneDiskWithHole : ZoneName  = " << ZoneName ) ;
+  double Xcentre ;
+  double Ycentre ;
+  double Zcentre ;
+  if ( Orient == 1 )
+  { Xcentre = Ucentre ;
+    Ycentre = Vcentre ;
+    Zcentre = 0. ; }
+  else if ( Orient == 2 )
+  { Xcentre = 0. ;
+    Ycentre = Ucentre ;
+    Zcentre = Vcentre ; }
+  else if ( Orient == 3 )
+  { Xcentre = Vcentre ;
+    Ycentre = 0. ;
+    Zcentre = Ucentre ; }
+  else { ASSERT( Orient >= 1 and Orient <= 3 ) ; }
+
+  HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 60+Orient) ;
+  myZone->SetPipe( Xcentre, Ycentre, Zcentre, 0., 0., 1., Rayon, 1., Rayonint ) ;
+
+  return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
+}
+
+
+
+
+//=============================================================================
+CORBA::Long HOMARD_Gen_i::Compute(const char* nomIteration, CORBA::Long etatMenage)
+{
+  MESSAGE ( "Compute : calcul de " << nomIteration );
+  IsValidStudy () ;
 
   HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[nomIteration];
   ASSERT(!CORBA::is_nil(myIteration));
 
-// on ne calcule pas l iteration 0 
+// on ne calcule pas l iteration 0
   int NumeIter = myIteration->GetNumber();
   if ( NumeIter == 0 )
   {
@@ -870,7 +1012,7 @@ CORBA::Boolean HOMARD_Gen_i::Compute(const char* nomIteration, CORBA::Long etatM
       es.type = SALOME::BAD_PARAM;
       es.text = "This iteration is the first of the case and cannot be computed.";
       throw SALOME::SALOME_Exception(es);
-      return 0;
+      return 1;
   };
 
 // on verifie qu il y a une hypothese (erreur improbable);
@@ -879,16 +1021,14 @@ CORBA::Boolean HOMARD_Gen_i::Compute(const char* nomIteration, CORBA::Long etatM
   {
       SALOME::ExceptionStruct es;
       es.type = SALOME::BAD_PARAM;
-      es.text = "Invalid Study Context ";
-      es.text= "This iteration  has no associated hypothese";
+      es.text= "This iteration does not have any associated hypothesis.";
       throw SALOME::SALOME_Exception(es);
-      return 0;
+      return 2;
   }
   HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypo];
   ASSERT(!CORBA::is_nil(myHypo));
 
 
-
   // A.4. L'iteration parent
   const char* nomIterationParent = myIteration->GetIterParent();
   HOMARD::HOMARD_Iteration_var myIterationParent = myContextMap[GetCurrentStudyID()]._mesIterations[nomIterationParent];
@@ -903,7 +1043,12 @@ CORBA::Boolean HOMARD_Gen_i::Compute(const char* nomIteration, CORBA::Long etatM
       throw SALOME::SALOME_Exception(es);
       return 0;
       */
-      Compute(nomIterationParent, etatMenage);
+      int codret = Compute(nomIterationParent, etatMenage);
+      if (codret != 0)
+      {
+        // GERALD -- QMESSAGE BOX
+        ASSERT("Pb au calcul de l'iteration precedente" == 0);
+      }
   };
 
   const char* nomCas = myIteration->GetCaseName();
@@ -921,7 +1066,6 @@ CORBA::Boolean HOMARD_Gen_i::Compute(const char* nomIteration, CORBA::Long etatM
   std::string siterp1 = saux1.str() ;
   if (NumeIter < 10) { siterp1 = "0" + siterp1 ; }
 
-  // A.3. Hypothese associee
   // B. Les repertoires
   // B.1. Le repertoire du cas
   const char* nomDir = myCase->GetDirName();
@@ -985,7 +1129,7 @@ CORBA::Boolean HOMARD_Gen_i::Compute(const char* nomIteration, CORBA::Long etatM
           std::string text = "Directory : " + DirCompute.str() + "is not empty";
           es.text = CORBA::string_dup(text.c_str());
           throw SALOME::SALOME_Exception(es);
-          return false;
+          return 3;
        }
     }
   }
@@ -1042,7 +1186,7 @@ CORBA::Boolean HOMARD_Gen_i::Compute(const char* nomIteration, CORBA::Long etatM
           std::string text = "MeshFile : " + std::string(MeshFile) + " already exists ";
           es.text = CORBA::string_dup(text.c_str());
           throw SALOME::SALOME_Exception(es);
-          return false;
+          return 4;
      }
      else
      {
@@ -1055,7 +1199,7 @@ CORBA::Boolean HOMARD_Gen_i::Compute(const char* nomIteration, CORBA::Long etatM
           std::string text = "PB with meshfile destruction ";
           es.text = CORBA::string_dup(text.c_str());
           throw SALOME::SALOME_Exception(es);
-          return false;
+          return 5;
          }
       }
   }
@@ -1063,7 +1207,7 @@ CORBA::Boolean HOMARD_Gen_i::Compute(const char* nomIteration, CORBA::Long etatM
   {
      codret = 0 ;
   };
+
 
   // D.4. Les types de raffinement et de deraffinement
   // Les appels corba sont lourds, il vaut mieux les grouper
@@ -1088,27 +1232,40 @@ CORBA::Boolean HOMARD_Gen_i::Compute(const char* nomIteration, CORBA::Long etatM
   if (TypeAdap == 0)
   {
     HOMARD::listeZonesHypo* ListZone = myHypo->GetZones();
-    int numberOfZones = ListZone->length();
+    int numberOfZonesx2 = ListZone->length();
+    int NumZone ;
 
-    for (int NumZone = 0; NumZone< numberOfZones; NumZone++)
+    for (int iaux = 0; iaux< numberOfZonesx2; iaux++)
     {
-      std::string ZoneName = std::string((*ListZone)[NumZone]);
+      std::string ZoneName = std::string((*ListZone)[iaux]);
       MESSAGE ( "... ZoneName = " << ZoneName);
       HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[ZoneName];
       ASSERT(!CORBA::is_nil(myZone));
 
       int ZoneType = myZone->GetZoneType();
-      MESSAGE ( "... ZoneType = " << ZoneType);
-      if (ZoneType == 2) // Cas d un parallelepipede
+      std::string TypeUsestr = std::string((*ListZone)[iaux+1]);
+      int TypeUse = atoi( TypeUsestr.c_str() );
+      MESSAGE ( "... ZoneType = " << ZoneType << ", TypeUse = "<<TypeUse);
+      NumZone = iaux/2 + 1 ;
+      HOMARD::double_array* zone = myZone->GetCoords();
+      if ( ZoneType == 2 or ( ZoneType>=11 and ZoneType <=13 ) ) // Cas d un parallelepipede ou d'un rectangle
       {
-        HOMARD::double_array* zone = myZone->GetBox();
-        myDriver->TexteZone(NumZone+1, ZoneType, (*zone)[0], (*zone)[1], (*zone)[2], (*zone)[3], (*zone)[4], (*zone)[5]);
+        myDriver->TexteZone(NumZone, ZoneType, TypeUse, (*zone)[0], (*zone)[1], (*zone)[2], (*zone)[3], (*zone)[4], (*zone)[5], 0., 0., 0.);
       }
-      else if (ZoneType == 4) // Cas d une sphere
+      else if ( ZoneType == 4 ) // Cas d une sphere
       {
-        HOMARD::double_array* zone = myZone->GetSphere();
-        myDriver->TexteZone(NumZone+1, ZoneType, (*zone)[0], (*zone)[1], (*zone)[2], (*zone)[3], 0., 0.);
+        myDriver->TexteZone(NumZone, ZoneType, TypeUse, (*zone)[0], (*zone)[1], (*zone)[2], (*zone)[3], 0., 0., 0., 0., 0.);
       }
+      else if ( ZoneType == 5 or ( ZoneType>=31 and ZoneType <=33 ) ) // Cas d un cylindre ou d'un disque
+      {
+        myDriver->TexteZone(NumZone, ZoneType, TypeUse, (*zone)[0], (*zone)[1], (*zone)[2], (*zone)[3], (*zone)[4], (*zone)[5], (*zone)[6], (*zone)[7], 0.);
+      }
+      else if ( ZoneType == 7 or ( ZoneType>=61 and ZoneType <=63 ) ) // Cas d un tuyau ou disque perce
+      {
+        myDriver->TexteZone(NumZone, ZoneType, TypeUse, (*zone)[0], (*zone)[1], (*zone)[2], (*zone)[3], (*zone)[4], (*zone)[5], (*zone)[6], (*zone)[7], (*zone)[8]);
+      }
+      else { ASSERT("ZoneType est incorrect." == 0) ; }
+      iaux += 1 ;
     }
   }
   // E.3. Ajout des informations liees aux champs eventuels
@@ -1137,11 +1294,14 @@ CORBA::Boolean HOMARD_Gen_i::Compute(const char* nomIteration, CORBA::Long etatM
     double ThreshR = aInfosHypo->ThreshR;
     int TypeThC = aInfosHypo->TypeThC;
     double ThreshC = aInfosHypo->ThreshC;
+//  Saut entre mailles ou non ?
+    int UsField = aInfosHypo->UsField;
+    MESSAGE( ". UsField = " << UsField );
 //  L'usage des composantes
     int UsCmpI = aInfosHypo->UsCmpI;
     MESSAGE( ". UsCmpI = " << UsCmpI );
 //
-    myDriver->TexteField(FieldName, FieldFile, TimeStep, Rank, TypeThR, ThreshR, TypeThC, ThreshC, UsCmpI);
+    myDriver->TexteField(FieldName, FieldFile, TimeStep, Rank, TypeThR, ThreshR, TypeThC, ThreshC, UsField, UsCmpI);
 //
 //  Les composantes
     HOMARD::listeComposantsHypo* mescompo = myHypo->GetListComp();
@@ -1170,42 +1330,79 @@ CORBA::Boolean HOMARD_Gen_i::Compute(const char* nomIteration, CORBA::Long etatM
   }
 
   // E.5. Ajout des informations liees a l'eventuel suivi de frontiere
+  // On ecrit d'abord la definition des frontieres, puis les liens avec les groupes
+  std::list<std::string>  ListeBoundaryTraitees ;
   HOMARD::ListBoundaryGroupType* ListBoundaryGroupType = myCase->GetBoundaryGroup();
   int numberOfitems = ListBoundaryGroupType->length();
   MESSAGE ( "... number of string for Boundary+Group = " << numberOfitems);
   int BoundaryOption = 1 ;
   int NumBoundaryAnalytical = 0 ;
   for (int NumBoundary = 0; NumBoundary< numberOfitems; NumBoundary=NumBoundary+2)
+  {
+    std::string BoundaryName = std::string((*ListBoundaryGroupType)[NumBoundary]);
+    MESSAGE ( "... BoundaryName = " << BoundaryName);
+    int A_faire = 1 ;
+    std::list<std::string>::const_iterator it = ListeBoundaryTraitees.begin();
+    while (it != ListeBoundaryTraitees.end())
+    {
+      MESSAGE ( "... BoundaryNameTraitee = " << *it);
+      if ( BoundaryName == *it ) { A_faire = 0 ; }
+      it++;
+    }
+    if ( A_faire == 1 )
+    {
+// Caracteristiques de la frontiere
+      HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName];
+      ASSERT(!CORBA::is_nil(myBoundary));
+      int BoundaryType = myBoundary->GetBoundaryType();
+      MESSAGE ( "... BoundaryType = " << BoundaryType );
+// Ecriture selon le type
+      if (BoundaryType == 0) // Cas d une frontiere discrete
+      {
+        const char* MeshName = myBoundary->GetMeshName() ;
+        const char* MeshFile = myBoundary->GetMeshFile() ;
+        myDriver->TexteBoundaryDi( MeshName, MeshFile);
+        BoundaryOption = BoundaryOption*2 ;
+      }
+      else // Cas d une frontiere analytique
+      {
+        NumBoundaryAnalytical++ ;
+        HOMARD::double_array* coor = myBoundary->GetCoords();
+        if (BoundaryType == 1) // Cas d un cylindre
+        {
+          myDriver->TexteBoundaryAn(BoundaryName, NumBoundaryAnalytical, BoundaryType, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], (*coor)[4], (*coor)[5], (*coor)[6]);
+          BoundaryOption = BoundaryOption*3 ;
+        }
+        else if (BoundaryType == 2) // Cas d une sphere
+        {
+          myDriver->TexteBoundaryAn(BoundaryName, NumBoundaryAnalytical, BoundaryType, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], 0., 0., 0.);
+          BoundaryOption = BoundaryOption*3 ;
+        }
+      }
+// Memorisation du traitement
+      ListeBoundaryTraitees.push_back( BoundaryName );
+    }
+  }
+  NumBoundaryAnalytical = 0 ;
+  for (int NumBoundary = 0; NumBoundary< numberOfitems; NumBoundary=NumBoundary+2)
   {
     std::string BoundaryName = std::string((*ListBoundaryGroupType)[NumBoundary]);
     MESSAGE ( "... BoundaryName = " << BoundaryName);
     HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName];
     ASSERT(!CORBA::is_nil(myBoundary));
-    std::string GroupName = std::string((*ListBoundaryGroupType)[NumBoundary+1]);
-    MESSAGE ( "... GroupName = " << GroupName);
-
     int BoundaryType = myBoundary->GetBoundaryType();
     MESSAGE ( "... BoundaryType = " << BoundaryType );
+//  Recuperation du nom du groupe
+    std::string GroupName = std::string((*ListBoundaryGroupType)[NumBoundary+1]);
+    MESSAGE ( "... GroupName = " << GroupName);
     if (BoundaryType == 0) // Cas d une frontiere discrete
     {
-      const char* MeshName = myBoundary->GetMeshName() ;
-      const char* MeshFile = myBoundary->GetMeshFile() ;
-      myDriver->TexteBoundaryDi( MeshName, MeshFile);
-      BoundaryOption = BoundaryOption*2 ;
-    }
-    else if (BoundaryType == 1) // Cas d un cylindre
-    {
-      NumBoundaryAnalytical++ ;
-      HOMARD::double_array* coor = myBoundary->GetCylinder();
-      myDriver->TexteBoundaryAn(NumBoundaryAnalytical, BoundaryType, GroupName, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], (*coor)[4], (*coor)[5], (*coor)[6]);
-      BoundaryOption = BoundaryOption*3 ;
+      if ( GroupName.size() > 0 ) { myDriver->TexteBoundaryDiGr ( GroupName ) ; }
     }
-    else if (BoundaryType == 2) // Cas d une sphere
+    else // Cas d une frontiere analytique
     {
       NumBoundaryAnalytical++ ;
-      HOMARD::double_array* coor = myBoundary->GetSphere();
-      myDriver->TexteBoundaryAn(NumBoundaryAnalytical, BoundaryType, GroupName, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], 0., 0., 0.);
-      BoundaryOption = BoundaryOption*3 ;
+      myDriver->TexteBoundaryAnGr ( BoundaryName, NumBoundaryAnalytical, GroupName ) ;
     }
   }
   myDriver->TexteBoundaryOption(BoundaryOption);
@@ -1244,6 +1441,16 @@ CORBA::Boolean HOMARD_Gen_i::Compute(const char* nomIteration, CORBA::Long etatM
       }
     }
   }
+  // E.7. Ajout des options avancees
+  int Pyram = myCase->GetPyram();
+  MESSAGE ( ". Pyram = " << Pyram );
+  int NivMax = myHypo->GetNivMax();
+  MESSAGE ( ". NivMax = " << NivMax );
+  double DiamMin = myHypo->GetDiamMin() ;
+  MESSAGE ( ". DiamMin = " << DiamMin );
+  int AdapInit = myHypo->GetAdapInit();
+  MESSAGE ( ". AdapInit = " << AdapInit );
+  myDriver->TexteAdvanced(Pyram, NivMax, DiamMin, AdapInit);
 
   // F. Ecriture du texte dans le fichier
   if (codret == 0)
@@ -1253,11 +1460,12 @@ CORBA::Boolean HOMARD_Gen_i::Compute(const char* nomIteration, CORBA::Long etatM
 
 // G. Execution
 //
-  int codretexec = 1 ;
+  int codretexec = 12 ;
   if (codret == 0)
   {
     codretexec = myDriver->ExecuteHomard();
 //
+    MESSAGE ( "Erreur en executant HOMARD : " << codretexec );
     if (codretexec == 0)
     {
       SetEtatIter(nomIteration,true);
@@ -1297,7 +1505,7 @@ CORBA::Boolean HOMARD_Gen_i::Compute(const char* nomIteration, CORBA::Long etatM
       SALOME::ExceptionStruct es;
       es.type = SALOME::BAD_PARAM;
       std::string text = "Error during the adaptation.\n" ;
-      try 
+      try
       {
           ifstream fichier(MessFile.c_str(), ios::in);
           string ligne;
@@ -1318,8 +1526,7 @@ CORBA::Boolean HOMARD_Gen_i::Compute(const char* nomIteration, CORBA::Long etatM
     delete myDriver;
   }
   //
-  if (codret == 0) { return true; }
-  else { return false; }
+  return codretexec ;
 }
 
 //===========================================================================
@@ -1351,33 +1558,33 @@ SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy,
 // Controle de la non publication d'un objet de meme nom
    if ((!aHypo->_is_nil()) or (!aZone->_is_nil()) or (!aBoundary->_is_nil()))
     {
-         SALOMEDS::Study::ListOfSObject_var listSO = theStudy->FindObjectByName(theName, ComponentDataType());
-         if (listSO->length() >= 1)
-         {
-             MESSAGE("This name "<<theName<<" is already used "<<listSO->length()<<" time(s)");
-             std::cerr <<"This name "<<theName<<" is already used "<<listSO->length()<<" time(s)" << std::endl;
-             aResultSO = listSO[0];
-             return aResultSO._retn();
-         }
+      SALOMEDS::Study::ListOfSObject_var listSO = theStudy->FindObjectByName(theName, ComponentDataType());
+      if (listSO->length() >= 1)
+      {
+          MESSAGE("This name "<<theName<<" is already used "<<listSO->length()<<" time(s)");
+          std::cerr <<"This name "<<theName<<" is already used "<<listSO->length()<<" time(s)" << std::endl;
+          aResultSO = listSO[0];
+          return aResultSO._retn();
+      }
     }
 
   // Caracteristiques de l'etude
-    SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder();
-    aStudyBuilder->NewCommand();
-     if(!aCase->_is_nil())
-        aResultSO = PublishCaseInStudy(theStudy, aStudyBuilder, aCase, theName);
-     else if(!aHypo->_is_nil())
-        aResultSO = PublishHypotheseInStudy(theStudy, aStudyBuilder, aHypo, theName);
-     else if(!aZone->_is_nil())
-        aResultSO = PublishZoneInStudy(theStudy, aStudyBuilder, aZone, theName);
-     else if(!aBoundary->_is_nil())
-        aResultSO = PublishBoundaryInStudy(theStudy, aStudyBuilder, aBoundary, theName);
+  SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder();
+  aStudyBuilder->NewCommand();
+  if(!aCase->_is_nil())
+    aResultSO = PublishCaseInStudy(theStudy, aStudyBuilder, aCase, theName);
+  else if(!aHypo->_is_nil())
+    aResultSO = PublishHypotheseInStudy(theStudy, aStudyBuilder, aHypo, theName);
+  else if(!aZone->_is_nil())
+    aResultSO = PublishZoneInStudy(theStudy, aStudyBuilder, aZone, theName);
+  else if(!aBoundary->_is_nil())
+    aResultSO = PublishBoundaryInStudy(theStudy, aStudyBuilder, aBoundary, theName);
 
     aStudyBuilder->CommitCommand();
   return aResultSO._retn();
 };
 //=============================================================================
-SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishCaseInStudy(SALOMEDS::Study_ptr theStudy, 
+SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishCaseInStudy(SALOMEDS::Study_ptr theStudy,
                                                        SALOMEDS::StudyBuilder_var aStudyBuilder,
                                                        HOMARD::HOMARD_Cas_ptr theObject, const char* theName)
 {
@@ -1395,20 +1602,20 @@ SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishCaseInStudy(SALOMEDS::Study_ptr theSt
   }
 
   SALOMEDS::SComponent_var theFatherHomard = theStudy->FindComponent(ComponentDataType());
-  if (theFatherHomard->_is_nil()) 
+  if (theFatherHomard->_is_nil())
   {
-    MESSAGE("theFatherHomard->_is_nil()");      
+    MESSAGE("theFatherHomard->_is_nil()");
     return aResultSO._retn();
   }
 
   aResultSO = aStudyBuilder->NewObject(theFatherHomard);
-  PublishInStudyAttr(aStudyBuilder, aResultSO, theName, "CasHomard", "cas_calcule.png", 
+  PublishInStudyAttr(aStudyBuilder, aResultSO, theName, "CasHomard", "cas_calcule.png",
                      _orb->object_to_string(theObject) ) ;
   return aResultSO._retn();
 }
 
 //=============================================================================
-SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishZoneInStudy(SALOMEDS::Study_ptr theStudy, 
+SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishZoneInStudy(SALOMEDS::Study_ptr theStudy,
                     SALOMEDS::StudyBuilder_var aStudyBuilder,
                    HOMARD::HOMARD_Zone_ptr theObject, const char* theName)
 {
@@ -1416,18 +1623,18 @@ SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishZoneInStudy(SALOMEDS::Study_ptr theSt
   SALOMEDS::SObject_var aResultSO;
   SALOMEDS::GenericAttribute_var anAttr;
 
-  if (CORBA::is_nil(theObject)) 
+  if (CORBA::is_nil(theObject))
   {
     MESSAGE("HOMARD_Gen_i.cxx::theObject->_is_nil()");
     return aResultSO._retn();
   }
-  if (theStudy->_is_nil()) 
+  if (theStudy->_is_nil())
   {
     MESSAGE("HOMARD_Gen_i.cxx::theStudy->_is_nil()");
     return aResultSO._retn();
   }
   SALOMEDS::SComponent_var theFatherHomard = theStudy->FindComponent(ComponentDataType());
-  if (theFatherHomard->_is_nil()) 
+  if (theFatherHomard->_is_nil())
   {
     MESSAGE("theFatherHomard->_is_nil()");
     return aResultSO._retn();
@@ -1441,28 +1648,63 @@ SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishZoneInStudy(SALOMEDS::Study_ptr theSt
   SALOMEDS::SObject_var aSOZone;
   if (!theFatherHomard->FindSubObject(100, aSOZone))
   {
+    MESSAGE("Ajout de la categorie des zones");
     aSOZone = aStudyBuilder->NewObjectToTag(theFatherHomard, 100);
     PublishInStudyAttr(aStudyBuilder, aSOZone, "Zones", "ZoneList", "zone_icone_2.png", NULL ) ;
   }
+  else { MESSAGE("La categorie des zones existe deja."); }
 
   aResultSO = aStudyBuilder->NewObject(aSOZone);
+  const char* icone ;
   switch (ZoneType)
   {
+    case 11 :
+    { }
+    case 12 :
+    { }
+    case 13 :
+    { icone = "boxdxy_2.png" ;
+      break ;
+    }
     case 2 :
-    { PublishInStudyAttr(aStudyBuilder, aResultSO, theName, "ZoneHomard", 
-      "boxdxyz_2.png", _orb->object_to_string(theObject) ) ;
-      break; 
+    { icone = "boxdxyz_2.png" ;
+      break ;
     }
+    case 31 :
+    { }
+    case 32 :
+    { }
+    case 33 :
+    { icone = "disk_2.png" ;
+      break ;
+     }
     case 4 :
-    { PublishInStudyAttr(aStudyBuilder, aResultSO, theName, "ZoneHomard", 
-     "spherepoint_2.png", _orb->object_to_string(theObject) ) ;
-      break; 
+    { icone = "spherepoint_2.png" ;
+      break ;
+    }
+    case 5 :
+    { icone = "cylinderpointvector_2.png" ;
+      break ;
+    }
+    case 61 :
+    { }
+    case 62 :
+    { }
+    case 63 :
+    { icone = "diskwithhole_2.png" ;
+      break ;
+     }
+    case 7 :
+    { icone = "pipe_2.png" ;
+      break ;
     }
   }
+  PublishInStudyAttr(aStudyBuilder, aResultSO, theName, "ZoneHomard", icone, _orb->object_to_string(theObject) ) ;
+
   return aResultSO._retn();
 }
 //=============================================================================
-SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishBoundaryInStudy(SALOMEDS::Study_ptr theStudy, 
+SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishBoundaryInStudy(SALOMEDS::Study_ptr theStudy,
                    SALOMEDS::StudyBuilder_var aStudyBuilder,
                    HOMARD::HOMARD_Boundary_ptr theObject, const char* theName)
 {
@@ -1485,35 +1727,41 @@ SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishBoundaryInStudy(SALOMEDS::Study_ptr t
   SALOMEDS::SObject_var aSOBoundary;
   if (!theFatherHomard->FindSubObject(101, aSOBoundary))
   {
+    MESSAGE("Ajout de la categorie des boundarys");
     aSOBoundary = aStudyBuilder->NewObjectToTag(theFatherHomard, 101);
     PublishInStudyAttr(aStudyBuilder, aSOBoundary, "Boundaries", "BoundList", "zone_icone_2.png", NULL ) ;
   }
+  else { MESSAGE("La categorie des boundarys existe deja."); }
 
   aResultSO = aStudyBuilder->NewObject(aSOBoundary);
   CORBA::Long BoundaryType = myBoundary->GetBoundaryType();
+//   MESSAGE("BoundaryType : "<<BoundaryType);
+  const char* icone ;
+  const char* value ;
   switch (BoundaryType)
   {
     case 0 :
-    { PublishInStudyAttr(aStudyBuilder, aResultSO, theName, "BoundaryDiHomard", "mesh_tree_mesh.png",
-                          _orb->object_to_string(theObject));
-      break; 
+    { value = "BoundaryDiHomard" ;
+      icone = "mesh_tree_mesh.png" ;
+      break;
     }
     case 1 :
-    { PublishInStudyAttr(aStudyBuilder, aResultSO, theName, "BoundaryAnHomard", "cylinderpointvector_2.png", 
-                          _orb->object_to_string(theObject));
-      break; 
+    { value = "BoundaryAnHomard" ;
+      icone = "cylinderpointvector_2.png" ;
+      break;
     }
     case 2 :
-    { PublishInStudyAttr(aStudyBuilder, aResultSO, theName, "BoundaryAnHomard", "spherepoint_2.png", 
-                          _orb->object_to_string(theObject));
-      break; 
+    { value = "BoundaryAnHomard" ;
+      icone = "spherepoint_2.png" ;
+      break;
     }
   }
+  PublishInStudyAttr(aStudyBuilder, aResultSO, theName, value, icone, _orb->object_to_string(theObject));
   return aResultSO._retn();
 }
 
 //=============================================================================
-SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishHypotheseInStudy(SALOMEDS::Study_ptr theStudy, 
+SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishHypotheseInStudy(SALOMEDS::Study_ptr theStudy,
                    SALOMEDS::StudyBuilder_var aStudyBuilder,
                    HOMARD::HOMARD_Hypothesis_ptr theObject, const char* theName)
 {
@@ -1524,7 +1772,7 @@ SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishHypotheseInStudy(SALOMEDS::Study_ptr
   // On recupere le module pere dans l etude
   // On ajoute la categorie des hypotheses dans l etude si necessaire
   SALOMEDS::SComponent_var theFatherHomard = theStudy->FindComponent(ComponentDataType());
-  if (theFatherHomard->_is_nil()) 
+  if (theFatherHomard->_is_nil())
   {
     MESSAGE("theFatherHomard->_is_nil()");
     return aResultSO._retn();
@@ -1532,9 +1780,11 @@ SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishHypotheseInStudy(SALOMEDS::Study_ptr
   SALOMEDS::SObject_var aSOHypothese;
   if (!theFatherHomard->FindSubObject(0, aSOHypothese))
   {
+    MESSAGE("Ajout de la categorie des hypotheses");
     aSOHypothese = aStudyBuilder->NewObjectToTag(theFatherHomard, 0);
     PublishInStudyAttr(aStudyBuilder, aSOHypothese, "Hypothesis", "HypoList","hypotheses.png", NULL);
   }
+  else { MESSAGE("La categorie des hypotheses existe deja."); }
 
 // Creation du resultat dans l'etude
   aResultSO = aStudyBuilder->NewObject(aSOHypothese);
@@ -1584,14 +1834,8 @@ void HOMARD_Gen_i::PublishInStudyAttr(SALOMEDS::StudyBuilder_var aStudyBuilder,
 //=============================================================================
 HOMARD::listeCases* HOMARD_Gen_i::GetAllCases()
 {
-  if (CORBA::is_nil(myCurrentStudy))
-  {
-      SALOME::ExceptionStruct es;
-      es.type = SALOME::BAD_PARAM;
-      es.text = "Invalid Study Context ";
-      throw SALOME::SALOME_Exception(es);
-      return 0;
-  };
+  MESSAGE("GetAllCases");
+  IsValidStudy () ;
 
   HOMARD::listeCases_var ret = new HOMARD::listeCases;
   ret->length(myContextMap[GetCurrentStudyID()]._mesCas.size());
@@ -1609,14 +1853,8 @@ HOMARD::listeCases* HOMARD_Gen_i::GetAllCases()
 //=============================================================================
 HOMARD::listeHypotheses* HOMARD_Gen_i::GetAllHypotheses()
 {
-  if (CORBA::is_nil(myCurrentStudy))
-  {
-      SALOME::ExceptionStruct es;
-      es.type = SALOME::BAD_PARAM;
-      es.text = "Invalid Study Context ";
-      throw SALOME::SALOME_Exception(es);
-      return 0;
-  };
+  MESSAGE("GetAllHypotheses");
+  IsValidStudy () ;
 
   HOMARD::listeHypotheses_var ret = new HOMARD::listeHypotheses;
   ret->length(myContextMap[GetCurrentStudyID()]._mesHypotheses.size());
@@ -1634,14 +1872,8 @@ HOMARD::listeHypotheses* HOMARD_Gen_i::GetAllHypotheses()
 //=============================================================================
 HOMARD::listeZones* HOMARD_Gen_i::GetAllZones()
 {
-  if (CORBA::is_nil(myCurrentStudy))
-  {
-      SALOME::ExceptionStruct es;
-      es.type = SALOME::BAD_PARAM;
-      es.text = "Invalid Study Context ";
-      throw SALOME::SALOME_Exception(es);
-      return 0;
-  };
+  MESSAGE("GetAllZones");
+  IsValidStudy () ;
 
   HOMARD::listeZones_var ret = new HOMARD::listeZones;
   ret->length(myContextMap[GetCurrentStudyID()]._mesZones.size());
@@ -1659,20 +1891,14 @@ HOMARD::listeZones* HOMARD_Gen_i::GetAllZones()
 //=============================================================================
 HOMARD::listeIterations* HOMARD_Gen_i::GetAllIterations()
 {
-  if (CORBA::is_nil(myCurrentStudy))
-  {
-      SALOME::ExceptionStruct es;
-      es.type = SALOME::BAD_PARAM;
-      es.text = "Invalid Study Context ";
-      throw SALOME::SALOME_Exception(es);
-      return 0;
-  };
+  MESSAGE("GetAllIterations");
+  IsValidStudy () ;
 
   HOMARD::listeIterations_var ret = new HOMARD::listeIterations;
   ret->length(myContextMap[GetCurrentStudyID()]._mesIterations.size());
   std::map<std::string, HOMARD::HOMARD_Iteration_var>::const_iterator it;
   int i = 0;
-  for (it  = myContextMap[GetCurrentStudyID()]._mesIterations.begin(); 
+  for (it  = myContextMap[GetCurrentStudyID()]._mesIterations.begin();
   it != myContextMap[GetCurrentStudyID()]._mesIterations.end(); it++)
   {
     ret[i++] = CORBA::string_dup((*it).first.c_str());
@@ -1683,14 +1909,8 @@ HOMARD::listeIterations* HOMARD_Gen_i::GetAllIterations()
 //=============================================================================
 HOMARD::listeBoundarys* HOMARD_Gen_i::GetAllBoundarys()
 {
-  if (CORBA::is_nil(myCurrentStudy))
-  {
-      SALOME::ExceptionStruct es;
-      es.type = SALOME::BAD_PARAM;
-      es.text = "Invalid Study Context ";
-      throw SALOME::SALOME_Exception(es);
-      return 0;
-  };
+  MESSAGE("GetAllBoundarys");
+  IsValidStudy () ;
 
   HOMARD::listeBoundarys_var ret = new HOMARD::listeBoundarys;
   ret->length(myContextMap[GetCurrentStudyID()]._mesBoundarys.size());
@@ -1741,7 +1961,7 @@ void HOMARD_Gen_i::PublishResultInSmesh(const char* NomFich, CORBA::Long IconeTy
   {
 // On verifie que le fichier n est pas deja publie
     SALOMEDS::ChildIterator_var aIter = myCurrentStudy->NewChildIterator(aSmeshSO);
-    for (; aIter->More(); aIter->Next()) 
+    for (; aIter->More(); aIter->Next())
     {
        SALOMEDS::SObject_var  aSO = aIter->Value();
        SALOMEDS::GenericAttribute_var aGAttr;
@@ -1771,9 +1991,9 @@ void HOMARD_Gen_i::PublishResultInSmesh(const char* NomFich, CORBA::Long IconeTy
 
 // On met a jour les attributs AttributeExternalFileDef et AttributePixMap
   SMESH::mesh_array* mesMaillages=aSmeshEngine->CreateMeshesFromMED(NomFich, theStatus);
-  for (int i = 0; i < mesMaillages->length();  i++) 
+  for (int i = 0; i < mesMaillages->length();  i++)
   {
-    MESSAGE( ". Mise a jour des attributs");
+    MESSAGE( ". Mise a jour des attributs du maillage");
     SMESH::SMESH_Mesh_var monMaillage= (*mesMaillages)[i];
     SALOMEDS::SObject_var aSO=SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(monMaillage)));
     SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
@@ -1784,10 +2004,10 @@ void HOMARD_Gen_i::PublishResultInSmesh(const char* NomFich, CORBA::Long IconeTy
     SALOMEDS::AttributePixMap_var anAttr2 = SALOMEDS::AttributePixMap::_narrow(aPixMap);
 //  IconeType = 0 : fichier issu d'une importation
 //  IconeType = 1 : fichier issu d'une execution HOMARD
-    if ( IconeType == 0 )
-    { anAttr2->SetPixMap( "mesh_tree_importedmesh.png" ); }
-    else
-    { anAttr2->SetPixMap( "mesh_tree_mesh.png" ); }
+    const char* icone ;
+    if ( IconeType == 0 ) { icone = "mesh_tree_importedmesh.png" ; }
+    else                  { icone = "mesh_tree_mesh.png" ; }
+    anAttr2->SetPixMap( icone );
   }
 
 }
@@ -1814,7 +2034,7 @@ void HOMARD_Gen_i::DeleteResultInSmesh(const char* NomFich, const char* MeshName
 // On verifie que le fichier est deja publie
   SALOMEDS::StudyBuilder_var myBuilder = myCurrentStudy->NewBuilder();
   SALOMEDS::ChildIterator_var aIter = myCurrentStudy->NewChildIterator(aSmeshSO);
-  for (; aIter->More(); aIter->Next()) 
+  for (; aIter->More(); aIter->Next())
   {
      SALOMEDS::SObject_var  aSO = aIter->Value();
      SALOMEDS::GenericAttribute_var aGAttr;
@@ -1888,6 +2108,20 @@ void HOMARD_Gen_i::PublishFileUnderIteration(const char* NomIter, const char* No
   aStudyBuilder->CommitCommand();
 }
 
+//=====================================================================================
+void HOMARD_Gen_i::IsValidStudy( )
+//=====================================================================================
+{
+  MESSAGE( "IsValidStudy" );
+  if (CORBA::is_nil(myCurrentStudy))
+  {
+    SALOME::ExceptionStruct es;
+    es.type = SALOME::BAD_PARAM;
+    es.text = "Invalid Study Context";
+    throw SALOME::SALOME_Exception(es);
+  };
+  return ;
+}
 
 //===========================================================================
 //
@@ -1897,8 +2131,8 @@ void HOMARD_Gen_i::PublishFileUnderIteration(const char* NomIter, const char* No
 
 //===========================================================================
 SALOMEDS::TMPFile* HOMARD_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent,
-                                      const char* theURL,
-                                      bool isMultiFile)
+                                      const char* theURL,
+                                      CORBA::Boolean isMultiFile)
 {
   MESSAGE (" Save pour theURL = "<< theURL);
   SALOMEDS::TMPFile_var aStreamFile;
@@ -1988,22 +2222,26 @@ SALOMEDS::TMPFile* HOMARD_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent,
     }
   }
   // -> close file
+  MESSAGE ("close file");
   f.close();
 
-  // put temporary files  to the stream
+  // put temporary files to the stream
+  MESSAGE ("put temporary files to the stream");
   aStreamFile = SALOMEDS_Tool::PutFilesToStream(tmpDir.c_str(), aFileSeq.in(), isMultiFile);
 
   // remove temporary files
+  MESSAGE ("remove temporary files");
   if (!isMultiFile) SALOMEDS_Tool::RemoveTemporaryFiles(tmpDir.c_str(), aFileSeq.in(), true);
 
   // return data stream
+  MESSAGE ("return data stream");
   return aStreamFile._retn();
 };
 
 //===========================================================================
 SALOMEDS::TMPFile* HOMARD_Gen_i::SaveASCII(SALOMEDS::SComponent_ptr theComponent,
-                                           const char* theURL,
-                                           bool isMultiFile)
+                                           const char* theURL,
+                                           CORBA::Boolean isMultiFile)
 {
   // No specific ASCII persistence
   SALOMEDS::TMPFile_var aStreamFile = Save(theComponent, theURL, isMultiFile);
@@ -2014,7 +2252,7 @@ SALOMEDS::TMPFile* HOMARD_Gen_i::SaveASCII(SALOMEDS::SComponent_ptr theComponent
 CORBA::Boolean HOMARD_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent,
                                   const SALOMEDS::TMPFile& theStream,
                                   const char* theURL,
-                                  bool isMultiFile)
+                                  CORBA::Boolean isMultiFile)
 {
   MESSAGE (" Load pour theURL = "<< theURL);
   SALOMEDS::Study_var aStudy = theComponent->GetStudy();
@@ -2062,6 +2300,7 @@ CORBA::Boolean HOMARD_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent,
     std::string bounSignature = HOMARD::GetSignature(HOMARD::Boundary);
     if (line.substr(0, caseSignature.size()) == caseSignature) {
       // re-create case
+      MESSAGE (" Recreation du cas" );
       HOMARD::HOMARD_Cas_var aCase = newCase();
       PortableServer::ServantBase_var aServant = GetServant(aCase);
       HOMARD_Cas_i* aCaseServant = dynamic_cast<HOMARD_Cas_i*>(aServant.in());
@@ -2071,6 +2310,7 @@ CORBA::Boolean HOMARD_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent,
       }
     }
     else if (line.substr(0, zoneSignature.size()) == zoneSignature) {
+      MESSAGE (" Recreation de la zone" );
       // re-create zone
       HOMARD::HOMARD_Zone_var aZone = newZone();
       PortableServer::ServantBase_var aServant = GetServant(aZone);
@@ -2082,6 +2322,7 @@ CORBA::Boolean HOMARD_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent,
     }
     else if (line.substr(0, iterSignature.size()) == iterSignature) {
       // re-create iteration
+      MESSAGE (" Recreation de l iteration" );
       HOMARD::HOMARD_Iteration_var aIter = newIteration();
       PortableServer::ServantBase_var aServant = GetServant(aIter);
       HOMARD_Iteration_i* aIterServant = dynamic_cast<HOMARD_Iteration_i*>(aServant.in());
@@ -2092,6 +2333,7 @@ CORBA::Boolean HOMARD_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent,
     }
     else if (line.substr(0, hypoSignature.size()) == hypoSignature) {
       // re-create hypothesis
+      MESSAGE (" Recreation de l hypothese" );
       HOMARD::HOMARD_Hypothesis_var aHypo = newHypothesis();
       PortableServer::ServantBase_var aServant = GetServant(aHypo);
       HOMARD_Hypothesis_i* aHypoServant = dynamic_cast<HOMARD_Hypothesis_i*>(aServant.in());
@@ -2102,6 +2344,7 @@ CORBA::Boolean HOMARD_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent,
     }
     else if (line.substr(0, bounSignature.size()) == bounSignature) {
       // re-create boundary
+      MESSAGE (" Recreation de la frontiere" );
       HOMARD::HOMARD_Boundary_var aBoundary = newBoundary();
       PortableServer::ServantBase_var aServant = GetServant(aBoundary);
       HOMARD_Boundary_i* aBoundaryServant = dynamic_cast<HOMARD_Boundary_i*>(aServant.in());
@@ -2117,7 +2360,7 @@ CORBA::Boolean HOMARD_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent,
   f.close();
 
   // Remove temporary files created from the stream
-  if (!isMultiFile) 
+  if (!isMultiFile)
     SALOMEDS_Tool::RemoveTemporaryFiles(tmpDir.c_str(), aFileSeq.in(), true);
 
   return true;
@@ -2127,7 +2370,7 @@ CORBA::Boolean HOMARD_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent,
 CORBA::Boolean HOMARD_Gen_i::LoadASCII(SALOMEDS::SComponent_ptr theComponent,
                                        const SALOMEDS::TMPFile& theStream,
                                        const char* theURL,
-                                       bool isMultiFile)
+                                       CORBA::Boolean isMultiFile)
 {
   // No specific ASCII persistence
   return Load(theComponent, theStream, theURL, isMultiFile);
@@ -2202,7 +2445,7 @@ char* HOMARD_Gen_i::LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject,
 };
 
 //===========================================================================
-bool HOMARD_Gen_i::CanPublishInStudy(CORBA::Object_ptr theIOR) 
+CORBA::Boolean HOMARD_Gen_i::CanPublishInStudy(CORBA::Object_ptr theIOR)
 {
   if(CORBA::is_nil(myCurrentStudy))
     return false;
@@ -2232,7 +2475,7 @@ bool HOMARD_Gen_i::CanPublishInStudy(CORBA::Object_ptr theIOR)
 };
 
 //===========================================================================
-CORBA::Boolean HOMARD_Gen_i::CanCopy(SALOMEDS::SObject_ptr theObject) 
+CORBA::Boolean HOMARD_Gen_i::CanCopy(SALOMEDS::SObject_ptr theObject)
 {
   // No Copy/Paste support
   return false;
@@ -2325,6 +2568,7 @@ HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::newZone()
 //==========================================================================
 Engines::TMPFile* HOMARD_Gen_i::DumpPython(CORBA::Object_ptr theStudy,
                                        CORBA::Boolean isPublished,
+                                       CORBA::Boolean isMultiFile,
                                        CORBA::Boolean& isValidScript)
 {
    MESSAGE ("Entree dans DumpPython");
@@ -2343,10 +2587,15 @@ Engines::TMPFile* HOMARD_Gen_i::DumpPython(CORBA::Object_ptr theStudy,
    aScript += "\"\"\"\n";
    aScript += "__revision__ = \"V1.2\"\n";
    aScript += "import HOMARD\n";
-   aScript += "import salome\n";
+   if( isMultiFile )
+      aScript += "import salome\n";
    aScript += "homard = salome.lcc.FindOrLoadComponent('FactoryServer','HOMARD')\n";
-   aScript += "def RebuildData(theStudy):\n";
-   aScript += "\thomard.SetCurrentStudy(theStudy)\n";
+   if( isMultiFile ) {
+      aScript += "def RebuildData(theStudy):\n";
+      aScript += "\thomard.SetCurrentStudy(theStudy)\n";
+   }
+   else
+      aScript += "\thomard.SetCurrentStudy(salome.myStudy)\n";
 
 
    if (myContextMap[GetCurrentStudyID()]._mesBoundarys.size() > 0)
@@ -2371,8 +2620,8 @@ Engines::TMPFile* HOMARD_Gen_i::DumpPython(CORBA::Object_ptr theStudy,
     aScript +=  "\n# =====================";
    }
    std::map<std::string, HOMARD::HOMARD_Zone_var>::const_iterator it_zone;
-   for ( it_zone  = myContextMap[GetCurrentStudyID()]._mesZones.begin(); 
-         it_zone != myContextMap[GetCurrentStudyID()]._mesZones.end(); ++it_zone) 
+   for ( it_zone  = myContextMap[GetCurrentStudyID()]._mesZones.begin();
+         it_zone != myContextMap[GetCurrentStudyID()]._mesZones.end(); ++it_zone)
    {
     HOMARD::HOMARD_Zone_var maZone = (*it_zone).second;
     CORBA::String_var dumpCorbaZone = maZone->GetDumpPython();
@@ -2415,7 +2664,7 @@ Engines::TMPFile* HOMARD_Gen_i::DumpPython(CORBA::Object_ptr theStudy,
            std::string mesh0 = cMesh0.in();
            CORBA::String_var cMeshName0= myIteration->GetMeshName();
            std::string meshName0 = cMeshName0.in();
-           dumpCas += meshName0 + std::string("', '")+ mesh0 + std::string("')\n"); 
+           dumpCas += meshName0 + std::string("', '")+ mesh0 + std::string("')\n");
            CORBA::String_var dumpCorbaCase = myCase->GetDumpPython();
            std::string dumpCas2= dumpCorbaCase.in();
 
@@ -2426,8 +2675,8 @@ Engines::TMPFile* HOMARD_Gen_i::DumpPython(CORBA::Object_ptr theStudy,
    aScript += "#\n# Creation of the iterations" ;
    aScript += "\n# ==========================";
    std::map<std::string, HOMARD::HOMARD_Iteration_var>::const_iterator it_iter;
-   for (it_iter  = myContextMap[GetCurrentStudyID()]._mesIterations.begin(); 
-        it_iter != myContextMap[GetCurrentStudyID()]._mesIterations.end(); ++it_iter) 
+   for (it_iter  = myContextMap[GetCurrentStudyID()]._mesIterations.begin();
+        it_iter != myContextMap[GetCurrentStudyID()]._mesIterations.end(); ++it_iter)
    {
     HOMARD::HOMARD_Iteration_var aIter = (*it_iter).second;
     CORBA::String_var dumpCorbaIter = aIter->GetDumpPython();
@@ -2435,6 +2684,12 @@ Engines::TMPFile* HOMARD_Gen_i::DumpPython(CORBA::Object_ptr theStudy,
     aScript+=dumpIter;
    }
 
+    if( isMultiFile )
+      aScript += "\n\tpass";
+    aScript += "\n";
+
+    if( !isMultiFile ) // remove unnecessary tabulation
+      aScript = RemoveTabulation( aScript );
 
    const size_t aLen = strlen(aScript.c_str());
    char* aBuffer = new char[aLen+1];
@@ -2450,9 +2705,9 @@ Engines::TMPFile* HOMARD_Gen_i::DumpPython(CORBA::Object_ptr theStudy,
 extern "C"
 {
   PortableServer::ObjectId* HOMARDEngine_factory(CORBA::ORB_ptr orb,
-                                                 PortableServer::POA_ptr poa, 
+                                                 PortableServer::POA_ptr poa,
                                                  PortableServer::ObjectId* contId,
-                                                 const char* instanceName, 
+                                                 const char* instanceName,
                                                  const char* interfaceName)
   {
     MESSAGE("PortableServer::ObjectId* HOMARDEngine_factory()");