Salome HOME
Correction d'une erreur sur le tri entre raffinement et déraffinement.
[modules/homard.git] / src / HOMARD / HOMARD_Cas.cxx
index 9683beb0dd93c2aaa760ba7acf5f3c19e19221f8..0aaea7006d7525615b160107ee88d56378eb6e8b 100644 (file)
@@ -1,33 +1,47 @@
-//  HOMARD HOMARD : implementaion of HOMARD idl descriptions
+//  HOMARD HOMARD : implementation of HOMARD idl descriptions
 //
-//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// Copyright (C) 2011-2014  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 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, or (at your option) any later version.
 //
-//  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+// 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
 //
 //  File   : HOMARD_Cas.cxx
 //  Author : Paul RASCLE, EDF
 //  Module : HOMARD
+//
+// Remarques :
+// L'ordre de description des fonctions est le meme dans tous les fichiers
+// HOMARD_aaaa.idl, HOMARD_aaaa.hxx, HOMARD_aaaa.cxx, HOMARD_aaaa_i.hxx, HOMARD_aaaa_i.cxx :
+// 1. Les generalites : Name, Delete, DumpPython, Dump, Restore
+// 2. Les caracteristiques
+// 3. Le lien avec les autres structures
+//
+// Quand les 2 fonctions Setxxx et Getxxx sont presentes, Setxxx est decrit en premier
 
 #include "HOMARD_Cas.hxx"
 #include "utilities.h"
+#include "HOMARD.hxx"
 #include <iostream>
+#include <sys/stat.h>
+
+#ifndef WIN32
+#include <unistd.h>
+#else
+#include <direct.h>
+#endif
 
 //=============================================================================
 /*!
@@ -36,7 +50,7 @@
  */
 //=============================================================================
 HOMARD_Cas::HOMARD_Cas():
-  _NomCas(""), _NomDir("/tmp"), _ConfType(1)
+  _Name(""), _NomDir("/tmp"), _ConfType(1)
 {
   MESSAGE("HOMARD_Cas");
 }
@@ -46,132 +60,111 @@ HOMARD_Cas::~HOMARD_Cas()
 {
   MESSAGE("~HOMARD_Cas");
 }
-
 //=============================================================================
-void HOMARD_Cas::SetDirName( const char* NomDir )
 //=============================================================================
-{
-     MESSAGE("SetDirName, NomDir :  "<<NomDir);
-     if (chdir(NomDir) == 0)
-     {
-       _NomDir = std::string( NomDir );
-     }
-    else 
-    {
-       // GERALD -- QMESSAGE BOX
-       // std::cerr << "Pb pour entrer dans le repertoire :  "<<NomDir << std::endl;
-       _NomDir = "/tmp";
-    };
-}
-
+// Generalites
 //=============================================================================
-std::string HOMARD_Cas::GetDirName() const
 //=============================================================================
+void HOMARD_Cas::SetName( const char* Name )
 {
-  return _NomDir;
+  _Name = std::string( Name );
 }
-
-//=============================================================================
-void HOMARD_Cas::SetName( const char* NomCas )
-//=============================================================================
-{
-  _NomCas = std::string( NomCas );
-}
-
 //=============================================================================
 std::string HOMARD_Cas::GetName() const
-//=============================================================================
 {
-  return _NomCas;
+  return _Name;
 }
-
-
 //=============================================================================
 std::string HOMARD_Cas::GetDumpPython() const
-//=============================================================================
 {
   std::ostringstream aScript;
-  aScript << "\t" <<_NomCas << ".SetDirName('";
-  aScript << _NomDir << "')\n";
-  aScript << "\t" <<_NomCas << ".SetConfType(";
+  aScript << "\t" <<_Name << ".SetDirName(\"";
+  aScript << _NomDir << "\")\n";
+  aScript << "\t" <<_Name << ".SetConfType(";
   aScript << _ConfType << ")\n";
 // Suivi de frontieres
   std::list<std::string>::const_iterator it = _ListBoundaryGroup.begin();
   while(it != _ListBoundaryGroup.end())
   {
-    aScript << "\t" <<_NomCas << ".AddBoundaryGroup('";
-    aScript << *it << "', '";
+    aScript << "\t" <<_Name << ".AddBoundaryGroup(\"";
+    aScript << *it << "\", \"";
     it++;
-    aScript << *it << "')\n";
+    aScript << *it << "\")\n";
     it++;
   }
+  if ( _Pyram > 0 )
+  {
+    aScript << "\t" <<_Name << ".SetPyram(";
+    aScript << _Pyram << ")\n";
+  }
+
   return aScript.str();
 }
-//AddBoundaryGroup( 'cyl_4', 'T2_INT' )
 //=============================================================================
-void HOMARD_Cas::AddIteration( const char* NomIteration )
 //=============================================================================
-{
-  _ListIter.push_back( std::string( NomIteration ) );
-}
-
+// Caracteristiques
 //=============================================================================
-const std::list<std::string>& HOMARD_Cas::GetIterations() const
 //=============================================================================
+int HOMARD_Cas::SetDirName( const char* NomDir )
 {
-  return _ListIter;
-}
+  MESSAGE("SetDirName,  NomDir : "<<NomDir);
+  MESSAGE("SetDirName, _NomDir : "<<_NomDir);
+  int erreur = 0 ;
+  // On vĂ©rifie qu'aucun calcul n'a eu lieu pour ce cas
+  MESSAGE("SetDirName, _ListIter.size() : "<<_ListIter.size());
+  if ( _ListIter.size() > 1 ) { erreur = 1 ; }
+  // Creation
+  if ( CHDIR(NomDir) == 0 )
+  { _NomDir = std::string( NomDir ); }
+  else
+  {
 
+#ifndef WIN32
+    if ( mkdir(NomDir, S_IRWXU|S_IRGRP|S_IXGRP) == 0 )
+#else
+    if ( _mkdir(NomDir) == 0 )
+#endif
+    {
+      if ( CHDIR(NomDir) == 0 ) { _NomDir = std::string( NomDir ); }
+      else                      { erreur = 2 ; }
+    }
+    else { erreur = 2 ; }
+  };
+  return erreur ;
+}
 //=============================================================================
-void HOMARD_Cas::SupprIterations()
-//=============================================================================
+std::string HOMARD_Cas::GetDirName() const
 {
-  _ListIter.clear();
+  return _NomDir;
 }
-
-//=============================================================================
-std::string HOMARD_Cas::GetIter0Name() const
 //=============================================================================
+int HOMARD_Cas::GetNumberofIter()
 {
-// Par construction de la liste, l'iteration a ete mise en tete.
-  return (*(_ListIter.begin()));
+  return _ListIter.size();
 }
-
 //=============================================================================
 void HOMARD_Cas::SetConfType( int Conftype )
-//=============================================================================
 {
   _ConfType = Conftype;
 }
 //=============================================================================
 const int HOMARD_Cas::GetConfType() const
-//=============================================================================
 {
   return _ConfType;
 }
-//=============================================================================
-int HOMARD_Cas::GetNumber() 
-//=============================================================================
-
-{
-  return _ListIter.size();
-}
 //
 // La boite englobante
 //
 //=============================================================================
 void HOMARD_Cas::SetBoundingBox( const std::vector<double>& extremas )
-//=============================================================================
 {
   _Boite.clear();
   _Boite.resize( extremas.size() );
   for ( int i = 0; i < extremas.size(); i++ )
     _Boite[i] = extremas[i];
 }
-
 //=============================================================================
 const std::vector<double>& HOMARD_Cas::GetBoundingBox() const
-//=============================================================================
 {
   return _Boite;
 }
@@ -179,20 +172,12 @@ const std::vector<double>& HOMARD_Cas::GetBoundingBox() const
 // Les groupes
 //
 //=============================================================================
-const std::list<std::string>& HOMARD_Cas::GetGroups() const
-//=============================================================================
-{
-  return _ListGroup;
-}
-//=============================================================================
-void HOMARD_Cas::SupprGroups()
-//=============================================================================
+void HOMARD_Cas::AddGroup( const char* Group )
 {
-  _ListGroup.clear();
+  _ListGroup.push_back(Group);
 }
 //=============================================================================
 void HOMARD_Cas::SetGroups( const std::list<std::string>& ListGroup )
-//=============================================================================
 {
   _ListGroup.clear();
   std::list<std::string>::const_iterator it = ListGroup.begin();
@@ -202,29 +187,68 @@ void HOMARD_Cas::SetGroups( const std::list<std::string>& ListGroup )
   }
 }
 //=============================================================================
-void HOMARD_Cas::AddGroup( const char* Group )
+const std::list<std::string>& HOMARD_Cas::GetGroups() const
 {
-  _ListGroup.push_back(Group);
+  return _ListGroup;
+}
+//=============================================================================
+void HOMARD_Cas::SupprGroups()
+{
+  _ListGroup.clear();
 }
 //
 // Les frontieres
 //
 //=============================================================================
-const std::list<std::string>& HOMARD_Cas::GetBoundaryGroup() const
+void HOMARD_Cas::AddBoundaryGroup( const char* Boundary, const char* Group )
+{
+  _ListBoundaryGroup.push_back( Boundary );
+  _ListBoundaryGroup.push_back( Group    );
+}
 //=============================================================================
+const std::list<std::string>& HOMARD_Cas::GetBoundaryGroup() const
 {
   return _ListBoundaryGroup;
 }
 //=============================================================================
-void HOMARD_Cas::AddBoundaryGroup( const char* Boundary, const char* Group )
+void HOMARD_Cas::SupprBoundaryGroup()
 {
-  _ListBoundaryGroup.push_back( Boundary );
-  _ListBoundaryGroup.push_back( Group    );
+  _ListBoundaryGroup.clear();
 }
 //=============================================================================
-void HOMARD_Cas::SupprBoundaryGroup()
+void HOMARD_Cas::SetPyram( int Pyram )
+{
+  _Pyram = Pyram;
+}
 //=============================================================================
+const int HOMARD_Cas::GetPyram() const
 {
-  _ListBoundaryGroup.clear();
+  return _Pyram;
+}
+//=============================================================================
+//=============================================================================
+// Liens avec les autres structures
+//=============================================================================
+//=============================================================================
+std::string HOMARD_Cas::GetIter0Name() const
+{
+// Par construction de la liste, l'iteration a ete mise en tete.
+  return (*(_ListIter.begin()));
+}
+//=============================================================================
+void HOMARD_Cas::AddIteration( const char* NomIteration )
+{
+  _ListIter.push_back( std::string( NomIteration ) );
 }
+//=============================================================================
+const std::list<std::string>& HOMARD_Cas::GetIterations() const
+{
+  return _ListIter;
+}
+//=============================================================================
+void HOMARD_Cas::SupprIterations()
+{
+  _ListIter.clear();
+}
+