Back to index

salome-med  6.5.0
testUCellModel.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 //  File   : testUCellModel.cxx
00021 //  Module : MED
00022 //
00023 #include <set>
00024 #include <cstdlib> 
00025 #include "MEDMEM_Utilities.hxx"
00026 
00027 #include "MEDMEM_CellModel.hxx"
00028 #include "MEDMEM_define.hxx"
00029 #include "MEDMEM_DriversDef.hxx"
00030 
00031 using namespace std;
00032 using namespace MEDMEM;
00033 using namespace MED_EN;
00034 
00035 #define MED_NBR_GEOMETRIE_MAILLE 15
00036 
00037 static void usage(char * name)
00038 {
00039   cout << "    " << name << endl;
00040 }
00041 
00042 int main (int argc, char ** argv)
00043 {
00044 
00045   if (argc < 1) usage(argv[0]);
00046 
00047 
00048   cout << "CELLMODEL Test" << endl ;
00049   cout << "--------------" << endl;
00050 
00051   /*    -----------------------------------------------------
00052         Construction de tous les types de cellmodel possibles
00053         -----------------------------------------------------
00054   */
00055 
00056   CELLMODEL * tous  =new CELLMODEL[MED_NBR_GEOMETRIE_MAILLE ];
00057   const medGeometryElement  allCellType[MED_NBR_GEOMETRIE_MAILLE ]=
00058     {MED_POINT1, MED_SEG2,    MED_SEG3,   MED_TRIA3,
00059      MED_QUAD4,  MED_TRIA6,   MED_QUAD8,  MED_TETRA4,
00060      MED_PYRA5,  MED_PENTA6,  MED_HEXA8,  MED_TETRA10,
00061      MED_PYRA13, MED_PENTA15, MED_HEXA20 };
00062 
00063   for (int i=0; i<MED_NBR_GEOMETRIE_MAILLE ; i++)
00064     {
00065       tous[i]=CELLMODEL(allCellType[i]);
00066     }
00067 
00068   /*    -----------------------------------------------------
00069         Boucle sur  tous les types de cellmodel possibles
00070         - Chaque Méthode de cellmodel est appelee
00071         -----------------------------------------------------
00072   */
00073   for (int i=0; i<MED_NBR_GEOMETRIE_MAILLE ; i++)
00074     {
00075       cout << endl;
00076       cout << geoNames[tous[i].getType()] << endl;
00077       cout << "__________________"  << endl;
00078 
00079       try 
00080         {
00081           cout << "CellModel de Nom : " << tous[i].getName() << endl;
00082         }
00083       catch ( const std::exception &e )
00084         {
00085           cout << "-------------------------------" << endl;
00086           cout << "     Pb au getName()         " << endl;
00087           cout << "-------------------------------" << endl;
00088           MESSAGE_MED( "catched exception : " << e.what() ) ;
00089           return EXIT_FAILURE ;
00090         }
00091       catch (...)
00092         {
00093           cout << "-------------------------------" << endl;
00094           cout << "     Pb au getName()         " << endl;
00095           cout << "-------------------------------" << endl;
00096           return EXIT_FAILURE ;
00097         };
00098 
00099       try 
00100         {
00101           cout << "Nb de Vertexes   : " << tous[i].getNumberOfVertexes() << endl;
00102         }
00103       catch ( const std::exception &e )
00104         {
00105           cout << "-------------------------------" << endl;
00106           cout << "     Pb au getNumberOfVertexes()     " << endl;
00107           cout << "-------------------------------" << endl;
00108           MESSAGE_MED( "catched exception : " << e.what() ) ;
00109           return EXIT_FAILURE ;
00110         }
00111       catch (...)
00112         {
00113           cout << "---------------------------------------" << endl;
00114           cout << "     Pb au getNumberOfVertexes()     " << endl;
00115           cout << "---------------------------------------" << endl;
00116           return EXIT_FAILURE ;
00117         };
00118 
00119       try 
00120         {
00121           cout << "Nb de Noeuds     : " << tous[i].getNumberOfNodes() << endl;
00122         }
00123       catch ( const std::exception &e )
00124         {
00125           cout << "-------------------------------" << endl;
00126           cout << "     Pb au getNumberOfNodes()  " << endl;
00127           cout << "-------------------------------" << endl;
00128           MESSAGE_MED( "catched exception : " << e.what() ) ;
00129           return EXIT_FAILURE ;
00130         }
00131       catch (...)
00132         {
00133           cout << "---------------------------------" << endl;
00134           cout << "     Pb au getNumberOfNodes()  " << endl;
00135           cout << "---------------------------------" << endl;
00136           return EXIT_FAILURE ;
00137         };
00138 
00139       int dimension;
00140       try 
00141         {
00142           dimension=tous[i].getDimension();
00143           cout << "Dimension        : " << dimension << endl;   
00144         }
00145       catch ( const std::exception &e )
00146         {
00147           cout << "-------------------------------" << endl;
00148           cout << "     Pb au getDimension()    " << endl;
00149           cout << "-------------------------------" << endl;
00150           MESSAGE_MED( "catched exception : " << e.what() ) ;
00151           return EXIT_FAILURE ;
00152         }
00153       catch (...)
00154         {
00155           cout << "-------------------------------" << endl;
00156           cout << "     Pb au getDimension()    " << endl;
00157           cout << "-------------------------------" << endl;
00158           return EXIT_FAILURE ;
00159         }
00160 
00161       for (int dim=1; dim< dimension; dim++)
00162         {
00163           cout << "Nb d elements de dimension " << dim << " : ";
00164 
00165           try
00166             {
00167               cout << tous[i].getNumberOfConstituents(dim)<< endl;
00168             }
00169           catch ( const std::exception &e )
00170             {
00171               cout << "------------------------------------" << endl;
00172               cout << "  Pb au getNumberOfConstituents()   " << endl;
00173               cout << "------------------------------------" << endl;
00174               MESSAGE_MED( "catched exception : " << e.what() ) ;
00175               return EXIT_FAILURE ;
00176             }
00177           catch (...)
00178             {
00179               cout << "------------------------------------" << endl;
00180               cout << "  Pb au getNumberOfConstituents()   " << endl;
00181               cout << "------------------------------------" << endl;
00182               return EXIT_FAILURE ;
00183             };
00184         }
00185 /*
00186 
00187                 try
00188                 {
00189                         int** v1=tous[i].getConstituents(dim2);
00190                         if ( v1.size() != tous[i].getNumberOfConstituents(dim2) )
00191                         {
00192                                 cout << "----------------------------" << endl;
00193                                 cout << "  Pb au getConstituents()   " << endl;
00194                                 cout << "----------------------------" << endl;
00195                         }
00196                 }
00197                 catch ( const std::exception &e )
00198                 {
00199                         cout << "-------------------------------" << endl;
00200                         cout << "  Pb au getConstituents()   " << endl;
00201                         cout << "-------------------------------" << endl;
00202                         MESSAGE_MED( "catched exception : " << e.what() ) ;
00203                         return EXIT_FAILURE ;
00204                 }
00205                 catch (...)
00206                 {
00207                         cout << "----------------------------" << endl;
00208                         cout << "  Pb au getConstituents()   " << endl;
00209                         cout << "----------------------------" << endl;
00210                         return EXIT_FAILURE ;
00211                 };
00212 
00213                 cout << "Types de ces elements " << endl; 
00214 
00215                 set <medGeometryElement> setGeomElt;
00216                 medGeometryElement * vt;
00217                 int taille;
00218                 try
00219                 {
00220                         vt=tous[i].getConstituentsType(dim2); 
00221                         taille=tous[i].getNumberOfConstituents(dim2);
00222                 }
00223                 catch ( const std::exception &e )
00224                 {
00225                         cout << "-------------------------------" << endl;
00226                         cout << "  Pb au getConstituentsType()   " << endl;
00227                         cout << "-------------------------------" << endl;
00228                         MESSAGE_MED( "catched exception : " << e.what() ) ;
00229                         return EXIT_FAILURE ;
00230                 }
00231                 catch (...)
00232                 {
00233                         cout << "--------------------------------" << endl;
00234                         cout << "  Pb au getConstituentsType()   " << endl;
00235                         cout << "--------------------------------" << endl;
00236                         return EXIT_FAILURE ;
00237                 };
00238                 for (int k=0; k<taille;k++)
00239                 {
00240                         try
00241                         {
00242                                 medGeometryElement me=tous[i].getConstituentType(dim2,k+1);
00243                                 if  ( vt[k] != me )
00244                                 {
00245                                         cout << "-------------------------------" << endl;
00246                                         cout << "  Pb au getConstituentType()   " << endl;
00247                                         cout << "-------------------------------" << endl;
00248                                 }
00249                                 setGeomElt.insert(me);
00250                         }
00251                         catch ( const std::exception &e )
00252                         {
00253                                 cout << "-------------------------------" << endl;
00254                                 cout << "  Pb au getConstituentType()   " << endl;
00255                                 cout << "-------------------------------" << endl;
00256                                 MESSAGE_MED( "catched exception : " << e.what() ) ;
00257                                 return EXIT_FAILURE ;
00258                         }
00259                         catch (...)
00260                         {
00261                                 cout << "--------------------------------" << endl;
00262                                 cout << "  Pb au getConstituentsType()   " << endl;
00263                                 cout << "--------------------------------" << endl;
00264                                 return EXIT_FAILURE ;
00265                         }
00266                 }
00267 */
00268 /*
00269                 set <medGeometryElement>::iterator iter_s;
00270                 for (iter_s=setGeomElt.begin() ;iter_s!=setGeomElt.end();iter_s++)
00271                 {
00272                         cout << geoNames[(*iter_s)] << endl;    
00273                 }
00274                 
00275                 cout << "Impression des coordonnées du 1er Element de ce type" << endl;
00276                 try
00277                 {
00278                         vector<int> v2=tous[i].getNodesConstituent(dim2,1); 
00279                         for (int  k=0; k<v2.size();k++)
00280                         {
00281                                 cout << v2[k] << " ";
00282                                 try
00283                                 {
00284                                         int verif=tous[i].getNodeConstituent(dim2,1,k+1);
00285                                         if ( v2[k] != verif)
00286                                         {
00287                                                 cout << "-------------------------------" << endl;
00288                                                 cout << "  Pb au getNodeConstituent()   " << endl;
00289                                                 cout << "-------------------------------" << endl;
00290                                         }
00291                                 }
00292                                 catch ( const std::exception &e )
00293                                 {
00294                                         cout << "-------------------------------" << endl;
00295                                         cout << "  Pb au getNodeConstituent()   " << endl;
00296                                         cout << "-------------------------------" << endl;
00297                                         MESSAGE_MED( "catched exception : " << e.what() ) ;
00298                                         return EXIT_FAILURE ;
00299                                 }
00300                                 catch (...)
00301                                 {
00302                                         cout << "-------------------------------" << endl;
00303                                         cout << "  Pb au getNodeConstituent()   " << endl;
00304                                         cout << "-------------------------------" << endl;
00305                                         return EXIT_FAILURE ;
00306                                 }
00307                         }
00308                         cout << endl;
00309                 }
00310                 catch ( const std::exception &e )
00311                 {
00312                         cout << "-------------------------------" << endl;
00313                         cout << "  Pb au getNodeConstituent()    " << endl;
00314                         cout << "-------------------------------" << endl;
00315                         MESSAGE_MED( "catched exception : " << e.what() ) ;
00316                         return EXIT_FAILURE ;
00317                 }
00318                 catch (...)
00319                 {
00320                         cout << "--------------------------------" << endl;
00321                         cout << "  Pb au getNodeConstituent()    " << endl;
00322                         cout << "--------------------------------" << endl;
00323                         return EXIT_FAILURE ;
00324                 }
00325 */
00326 
00327       cout << endl;
00328 /*
00329         if ( dimension > 1 )
00330         {
00331                 try
00332                 {
00333                         cout << "Informations particulieres -  dimension " << dimension - 1 << endl;
00334                         set <medGeometryElement>::iterator iter_s;
00335                         for (iter_s=tous[i].getAllConstituentsType().begin() ;
00336                         iter_s!=tous[i].getAllConstituentsType().end();iter_s++)
00337                         {
00338                                 cout << geoNames[*iter_s] << endl;      
00339                         }
00340                 }
00341                 catch ( const std::exception &e )
00342                 {
00343                         cout << "-------------------------------" << endl;
00344                         cout << "  Pb au getAllConstituentsType()    " << endl;
00345                         cout << "-------------------------------" << endl;
00346                         MESSAGE_MED( "catched exception : " << e.what() ) ;
00347                         return EXIT_FAILURE ;
00348                 }
00349                 catch (...)
00350                 {
00351                         cout << "------------------------------------" << endl;
00352                         cout << "  Pb au getAllConstituentsType()    " << endl;
00353                         cout << "------------------------------------" << endl;
00354                         return EXIT_FAILURE ;
00355                 }
00356         }
00357 */
00358 
00359     }
00360 
00361   delete[] tous ;
00362 
00363   return EXIT_SUCCESS ;
00364 /*
00365   Reste a Tester
00366   // Return number of constituents foreach type (which dimension is _dimension-1).
00367   map <medGeometryElement,int>  getNumberOfConstituentsForeachType() const; 
00368 */
00369 }