Salome HOME
Merge from V6_main_20120808 08Aug12
[modules/med.git] / src / MEDMEMBinTest / tests / testUArray.cxx
index 78ea24b64925a38f6ac37cc56693b40c1f6c1a08..d274302692f2462c5fa60b21ebca3af001eb5534 100755 (executable)
@@ -1,72 +1,70 @@
-//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
 //
-//  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// 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.
+// 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.
 //
-//  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
 //
-//  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
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+
 //  File   : testUArray.cxx
 //  Module : MED
 //
-#include <cstdlib>     // pour l'acces à EXIT_SUCCESS et EXIT_FAILURE
+#include <cstdlib>      // pour l'acces à EXIT_SUCCESS et EXIT_FAILURE
 #include "MEDMEM_Utilities.hxx"
 #include "MEDMEM_Array.hxx"
 
 using namespace std;
 using namespace MEDMEM;
 
-void imprime(string titre,const int * myValues,const int * myOthers, int lignes, int colonnes)
+static void imprime(string titre,const int * myValues,const int * myOthers, int lignes, int colonnes)
 {
-  cout << "            " <<titre << endl<< endl;
+  cout << "             " <<titre << endl<< endl;
   cout << "Full Interlace : " << endl;
   if (myValues != NULL)
   {
-       for (int i=0; i<lignes; i++)
-       {
-               cout << " - ";
-               for (int k=0; k< colonnes; k++)
-               {
-                       cout << myValues[k + i * colonnes]<< " " ; 
-               }
-               cout << endl;
-       }
+        for (int i=0; i<lignes; i++)
+        {
+                cout << " - ";
+                for (int k=0; k< colonnes; k++)
+                {
+                        cout << myValues[k + i * colonnes]<< " " ; 
+                }
+                cout << endl;
+        }
   }
   else
   {
-               cout << "Pointeur Null : pas de valeur" << endl << endl;
+                cout << "Pointeur Null : pas de valeur" << endl << endl;
   }
   cout << endl;
   cout << "No Interlace : " << endl;
 
   if (myOthers != NULL)
   {
-       for (int k=0; k< colonnes; k++)
-       {
-               cout << " - ";
-               for (int i=0; i<lignes; i++)
-               {
-                       cout << myOthers[i + k*lignes]<< " " ; 
-               }
-               cout << endl;
-       }
+        for (int k=0; k< colonnes; k++)
+        {
+                cout << " - ";
+                for (int i=0; i<lignes; i++)
+                {
+                        cout << myOthers[i + k*lignes]<< " " ; 
+                }
+                cout << endl;
+        }
   }
   else
   {
-               cout << "Pointeur Null : pas de valeur" << endl << endl;
+                cout << "Pointeur Null : pas de valeur" << endl << endl;
   }
   cout << endl;
 }
@@ -75,13 +73,13 @@ int main (int argc, char ** argv)
 {
 
   /* ---------------------------------------------------------- */
-  /*                                                           */
-  /*                   INITIALISATION                          */
-  /*                                                           */
-  /* - constructeur new MEDARRAY<int>(int,int,mode)            */
-  /* - get sur le pointeur MED_FULL_INTERLACE                  */
+  /*                                                            */
+  /*                    INITIALISATION                          */
+  /*                                                            */
+  /* - constructeur new MEDARRAY<int>(int,int,mode)             */
+  /* - get sur le pointeur MED_FULL_INTERLACE                   */
   /* - initialisation des valeurs (coordonnées ieme elt = I+1)  */
-  /* - get sur le pointeur MED_NO_INTERLACE                    */
+  /* - get sur le pointeur MED_NO_INTERLACE                     */
   /* ---------------------------------------------------------- */
 
   int SpaceDimension = 3;
@@ -97,11 +95,11 @@ int main (int argc, char ** argv)
 
   for (int i=0; i<NumberOfNodes; i++)
   {
-       for (int k=0; k<SpaceDimension; k++)
-       {
-         //myValues[i* SpaceDimension +k]=i + 1; 
-         myArrayfull->setIJ(i+1,k+1,i+1) ;
-       }
+        for (int k=0; k<SpaceDimension; k++)
+        {
+          //myValues[i* SpaceDimension +k]=i + 1; 
+          myArrayfull->setIJ(i+1,k+1,i+1) ;
+        }
   }
   
   const int * myOthers = myArrayfull->get(MED_EN::MED_NO_INTERLACE) ;
@@ -116,11 +114,11 @@ int main (int argc, char ** argv)
 
   for (int k=0; k<SpaceDimension; k++)
   {
-       for (int i=0; i<NumberOfNodes; i++)
-       {
-         //myValuesno[i +k*NumberOfNodes]=k + 1; 
-         myArrayno->setIJ(i+1,k+1,k+1) ;
-       }
+        for (int i=0; i<NumberOfNodes; i++)
+        {
+          //myValuesno[i +k*NumberOfNodes]=k + 1; 
+          myArrayno->setIJ(i+1,k+1,k+1) ;
+        }
   }
   
   const int * myOthersno = myArrayno->get(MED_EN::MED_FULL_INTERLACE) ;
@@ -130,36 +128,36 @@ int main (int argc, char ** argv)
 
 
   /* ---------------------------------------------------------- */
-  /*                                                           */
-  /*                   Tests des Fonctions Set                 */
-  /*                                                           */
-  /* - setI sur l'element 1 avec des coordonnees a 100         */
-  /* - setJ sur l'element 1 avec des coordonnees a 100         */
-  /* - setIJ sur (1,2) avec une coordonnee = 1992              */
-  /* - set   avec l ensemble des coordonnes remises à i                */
+  /*                                                            */
+  /*                    Tests des Fonctions Set                 */
+  /*                                                            */
+  /* - setI sur l'element 1 avec des coordonnees a 100          */
+  /* - setJ sur l'element 1 avec des coordonnees a 100          */
+  /* - setIJ sur (1,2) avec une coordonnee = 1992               */
+  /* - set   avec l ensemble des coordonnes remises à i              */
   /* ---------------------------------------------------------- */
 
 
   int * myNewLine = new int[SpaceDimension];
   for (int i = 0; i < SpaceDimension; i++) 
-       myNewLine[i] = myValues[i] * 100;
+        myNewLine[i] = myValues[i] * 100;
   try
   {
-       myArrayfull->setI(1, myNewLine);
+        myArrayfull->setI(1, myNewLine);
   }
   catch ( const std::exception &e )
   {
-       cout << "--------------" << endl;
+        cout << "--------------" << endl;
         cout << "   Pb au setI " << endl;
         cout << "--------------" << endl;
-       MESSAGE_MED( "catched exception : " << e.what() ) ;
-       return EXIT_FAILURE ;
+        MESSAGE_MED( "catched exception : " << e.what() ) ;
+        return EXIT_FAILURE ;
   }
   catch (...)
   {
-       cout << "---------------" << endl;
-               cout << "   Pb au setI   " << endl;
-               cout << "---------------" << endl;
+        cout << "---------------" << endl;
+        cout << "   Pb au setI   " << endl;
+        cout << "---------------" << endl;
   }
 
   delete [] myNewLine;
@@ -167,24 +165,24 @@ int main (int argc, char ** argv)
 
   int * myNewCol = new int[NumberOfNodes];
   for (int i = 0; i < NumberOfNodes; i++) 
-       myNewCol[i] = 100;
+        myNewCol[i] = 100;
   try
   {
-       myArrayno->setJ(1, myNewCol);
+        myArrayno->setJ(1, myNewCol);
   }
   catch ( const std::exception &e )
   {
-       cout << "--------------" << endl;
+        cout << "--------------" << endl;
         cout << "   Pb au setJ " << endl;
         cout << "--------------" << endl;
-       MESSAGE_MED( "catched exception : " << e.what() ) ;
-       return EXIT_FAILURE ;
+        MESSAGE_MED( "catched exception : " << e.what() ) ;
+        return EXIT_FAILURE ;
   }
   catch (...)
   {
-       cout << "---------------" << endl;
-               cout << "   Pb au setJ   " << endl;
-               cout << "---------------" << endl;
+        cout << "---------------" << endl;
+        cout << "   Pb au setJ   " << endl;
+        cout << "---------------" << endl;
   }
 
   delete [] myNewCol;
@@ -192,21 +190,21 @@ int main (int argc, char ** argv)
 
   try
   {
-       myArrayfull->setIJ(1,2,1992);
+        myArrayfull->setIJ(1,2,1992);
   }
   catch ( const std::exception &e )
   {
-       cout << "---------------------------" << endl;
+        cout << "---------------------------" << endl;
         cout << "   Pb au setIJ()  de 1 , 2 "  << endl;
-       cout << "---------------------------" << endl;
-       MESSAGE_MED( "catched exception : " << e.what() ) ;
-       return EXIT_FAILURE ;
+        cout << "---------------------------" << endl;
+        MESSAGE_MED( "catched exception : " << e.what() ) ;
+        return EXIT_FAILURE ;
   }
   catch (...)
   {
-       cout << "-----------------------------" << endl;
+        cout << "-----------------------------" << endl;
         cout << "   Pb au setIJ()  de 1 , 2 "  << endl;
-       cout << "-----------------------------" << endl;
+        cout << "-----------------------------" << endl;
   }
 
   imprime("1er element : 2ieme coordonnee = 1992",myValues,myOthers,NumberOfNodes,SpaceDimension);
@@ -214,21 +212,21 @@ int main (int argc, char ** argv)
 
   try
   {
-       myArrayno->setIJ(1,2,1992);
+        myArrayno->setIJ(1,2,1992);
   }
   catch ( const std::exception &e )
   {
-       cout << "---------------------------" << endl;
+        cout << "---------------------------" << endl;
         cout << "   Pb au setIJ()  de 1 , 2 "  << endl;
-       cout << "---------------------------" << endl;
-       MESSAGE_MED( "catched exception : " << e.what() ) ;
-       return EXIT_FAILURE ;
+        cout << "---------------------------" << endl;
+        MESSAGE_MED( "catched exception : " << e.what() ) ;
+        return EXIT_FAILURE ;
   }
   catch (...)
   {
-       cout << "-----------------------------" << endl;
+        cout << "-----------------------------" << endl;
         cout << "   Pb au setIJ()  de 1 , 2 "  << endl;
-       cout << "-----------------------------" << endl;
+        cout << "-----------------------------" << endl;
   }
 
   imprime("1er element : 2ieme coordonnee = 1992",myValues,myOthers,NumberOfNodes,SpaceDimension);
@@ -236,58 +234,58 @@ int main (int argc, char ** argv)
   int * mynewvalues= new int [ NumberOfNodes*SpaceDimension ];
   for (int i=0; i<NumberOfNodes*SpaceDimension; i++)
   {
-       mynewvalues[i]=i;
+        mynewvalues[i]=i;
   }
   try
   {
-       myArrayfull->set(MED_EN::MED_FULL_INTERLACE,mynewvalues);
-       myValues = myArrayfull->get(MED_EN::MED_FULL_INTERLACE);
-       myOthers = myArrayfull->get(MED_EN::MED_NO_INTERLACE);
+        myArrayfull->set(MED_EN::MED_FULL_INTERLACE,mynewvalues);
+        myValues = myArrayfull->get(MED_EN::MED_FULL_INTERLACE);
+        myOthers = myArrayfull->get(MED_EN::MED_NO_INTERLACE);
   }
   catch ( const std::exception &e )
   {
-       cout << "-------------" << endl;
+        cout << "-------------" << endl;
         cout << "   Pb au set "  << endl;
-       cout << "-------------" << endl;
-       MESSAGE_MED( "catched exception : " << e.what() ) ;
-       return EXIT_FAILURE ;
+        cout << "-------------" << endl;
+        MESSAGE_MED( "catched exception : " << e.what() ) ;
+        return EXIT_FAILURE ;
   }
   catch (...)
   {
-       cout << "--------------" << endl;
+        cout << "--------------" << endl;
         cout << "   Pb au set "  << endl;
-       cout << "--------------" << endl;
+        cout << "--------------" << endl;
   }
   imprime("remise valeur a i sur myArrayfull med full interlace",myValues,myOthers,NumberOfNodes,SpaceDimension);
 
   try
   {
-       myArrayno->set(MED_EN::MED_FULL_INTERLACE,mynewvalues);
-       myValuesno = myArrayfull->get(MED_EN::MED_FULL_INTERLACE);
+        myArrayno->set(MED_EN::MED_FULL_INTERLACE,mynewvalues);
+        myValuesno = myArrayfull->get(MED_EN::MED_FULL_INTERLACE);
         myOthersno = NULL;
   }
   catch ( const std::exception &e )
   {
-       cout << "-------------" << endl;
+        cout << "-------------" << endl;
         cout << "   Pb au set "  << endl;
-       cout << "-------------" << endl;
-       MESSAGE_MED( "catched exception : " << e.what() ) ;
-       return EXIT_FAILURE ;
+        cout << "-------------" << endl;
+        MESSAGE_MED( "catched exception : " << e.what() ) ;
+        return EXIT_FAILURE ;
   }
   catch (...)
   {
-       cout << "--------------" << endl;
+        cout << "--------------" << endl;
         cout << "   Pb au setI "  << endl;
-       cout << "--------------" << endl;
+        cout << "--------------" << endl;
   }
   imprime("set full interlace de myArrayno",myValuesno,myOthersno,NumberOfNodes,SpaceDimension);
 
   /* ---------------------------------------------------------- */
-  /*                                                           */
-  /*                Tests des constructeurs                    */
-  /*               Tests des Fonctions Get                     */
-  /*                                                           */
-  /*                                                           */
+  /*                                                            */
+  /*                Tests des constructeurs                     */
+  /*                Tests des Fonctions Get                     */
+  /*                                                            */
+  /*                                                            */
   /* ---------------------------------------------------------- */
 
   MEDARRAY<int> * myArrayShare = new MEDARRAY<int>( *myArrayfull);