Back to index

salome-med  6.5.0
readEntete.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   : readEntete.cxx
00021 //  Module : MED
00022 //
00023 #include<string>
00024 #include "MEDMEM_Exception.hxx"
00025 #include "MEDMEM_define.hxx"
00026 #include "MEDMEM_Mesh.hxx"
00027 #include "MEDMEM_MedMeshDriver.hxx"
00028 #include "MEDMEM_DriversDef.hxx"
00029 
00030 using namespace std;
00031 using namespace MEDMEM;
00032 using namespace MED_EN;
00033 
00034 static void usage(char * name)
00035 {
00036   cout << "    " << name <<" <file name>"<< " <mesh name> " << " <interlace mode>" << endl;
00037   cout << "    " << "displays all Nodes Coordinates in mdump mode" << endl;
00038   cout << endl;
00039   cout << "    " << "mesh name is mandatory. Try mdump if necessary" << endl;
00040   cout << "    " << "values for interlace mode are  : " << endl;
00041   cout << "    " << "MED_FULL_INTERLACE (default value) or MED_NO_INTERLACE" << endl;
00042   exit(-1);
00043 }
00044 
00045 int main (int argc, char ** argv) {
00046   
00047   if (argc < 3) usage(argv[0]);
00048   if (argc > 4) usage(argv[0]);
00049 
00050   string fileName = argv[1];
00051   string meshName = argv[2];
00052 
00053   medModeSwitch Mode = MED_FULL_INTERLACE;
00054   if (argc==4)
00055   {
00056         string comp=argv[3];
00057         if ( comp == "MED_NO_INTERLACE" ) Mode = MED_NO_INTERLACE;
00058         else if ( comp != "MED_FULL_INTERLACE") usage(argv[0]);
00059   }
00060 
00061 
00062   MESH * myMesh= new MESH;
00063   myMesh->setName(meshName);
00064   MED_MESH_RDONLY_DRIVER myMeshDriver(fileName,myMesh);
00065   try
00066   {
00067        myMeshDriver.setMeshName(meshName);
00068        myMeshDriver.open();
00069   }
00070   catch (const exception & ex)
00071   {
00072          MESSAGE_MED("Catch Exception : ");
00073          SCRUTE_MED(ex.what());
00074   };
00075   MESSAGE_MED("Open done");
00076 
00077   try
00078   {
00079        myMeshDriver.read();
00080   }
00081   catch (const exception & ex)
00082   {
00083          MESSAGE_MED("Catch Exception : ");
00084          SCRUTE_MED(ex.what());
00085   };
00086   MESSAGE_MED("Read done");
00087   
00088   int SpaceDimension = myMesh->getSpaceDimension();
00089   int MeshDimension  = myMesh->getMeshDimension();
00090   int NumberOfNodes  = myMesh->getNumberOfNodes();
00091 
00092   cout << "(****************************)" << endl;
00093   cout << "(* INFORMATIONS GENERALES : *)" << endl;
00094   cout << "(****************************)" << endl;
00095 
00096   //  string chainevide(MED_TAILLE_PNOM+2,' ');
00097   cout << "- Nom du maillage : <<"    << meshName       << ">>" << endl;
00098   cout << "- Dimension d'espace : "<< SpaceDimension <<  endl;
00099   cout << "- Dimension du maillage : "<< MeshDimension <<  endl;
00100   cout << "- Pas de nom universel "   << endl ;
00101   cout << "- Nombre de noeuds : "     << NumberOfNodes  << " " << endl;
00102 
00103   int NumberOfTypes           = myMesh->getNumberOfTypes(MED_CELL);
00104   const medGeometryElement  * Types;
00105 
00106   cout << "- Nombre de Type de mailles : " << NumberOfTypes << endl;
00107 
00108   if (NumberOfTypes > 0)
00109     {
00110       Types = myMesh->getTypes(MED_CELL);
00111 
00112       cout << "  Types : ";
00113       for (int itype=0; itype<NumberOfTypes; itype++) cout << Types[itype] << " ";
00114       cout << endl;
00115 
00116       const list<medGeometryElement> currentEntity = meshEntities[MED_CELL];
00117       list<medGeometryElement>::const_iterator currentGeometry;
00118 
00119       for (currentGeometry  = currentEntity.begin();
00120            currentGeometry != currentEntity.end(); 
00121            currentGeometry++) 
00122         {
00123           cout << "- Nombre de mailles de type "; 
00124           cout << geoNames[(*currentGeometry)] << " : ";
00125           cout << myMesh->getNumberOfElements(MED_CELL,(MED_EN::medGeometryElement)(*currentGeometry));
00126           cout << " " << endl;
00127         }
00128     }
00129 
00130   NumberOfTypes = myMesh->getNumberOfTypes(MED_FACE);
00131   
00132   cout << "- Nombre de Type de faces : " << NumberOfTypes << endl;
00133 
00134   if (NumberOfTypes > 0)
00135     {
00136       Types = myMesh->getTypes(MED_FACE);
00137 
00138       cout << "  Types : ";
00139       for (int itype=0; itype<NumberOfTypes; itype++) cout << Types[itype] << " ";
00140       cout << endl;
00141 
00142       const list<medGeometryElement> currentEntity2 = meshEntities[MED_FACE];
00143       list<medGeometryElement>::const_iterator currentGeometry;
00144 
00145       for (currentGeometry  = currentEntity2.begin();
00146            currentGeometry != currentEntity2.end(); 
00147            currentGeometry++) 
00148         {
00149           cout << "- Nombre de faces de type "; 
00150           cout << geoNames[(*currentGeometry)] << " : ";
00151           cout << myMesh->getNumberOfElements(MED_FACE,(*currentGeometry));
00152           cout << " " << endl;
00153         }
00154     }
00155 
00156   NumberOfTypes = myMesh->getNumberOfTypes(MED_EDGE);
00157   
00158   cout << "- Nombre de Type de aretes : " << NumberOfTypes << endl;
00159 
00160   if (NumberOfTypes > 0)
00161     {
00162       Types = myMesh->getTypes(MED_EDGE);
00163 
00164       cout << "  Types : ";
00165       for (int itype=0; itype<NumberOfTypes; itype++) cout << Types[itype] << " ";
00166       cout << endl;
00167 
00168       const list<medGeometryElement> currentEntity3 = meshEntities[MED_EDGE];
00169       list<medGeometryElement>::const_iterator currentGeometry;
00170 
00171       for (currentGeometry  = currentEntity3.begin();
00172            currentGeometry != currentEntity3.end(); 
00173            currentGeometry++) 
00174         {
00175           cout << "- Nombre d'aretes de type "; 
00176           cout << geoNames[(*currentGeometry)] << " : ";
00177           cout << myMesh->getNumberOfElements(MED_EDGE,(*currentGeometry));
00178           cout << " " << endl;
00179         }
00180     }
00181 
00182   myMesh->removeReference();
00183 }