1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File : readCoordinate.cxx
24 #include "MEDMEM_Exception.hxx"
25 #include "MEDMEM_define.hxx"
26 #include "MEDMEM_Mesh.hxx"
27 #include "MEDMEM_MedMeshDriver.hxx"
30 using namespace MEDMEM;
32 #define MED_TAILLE_PNOM 16
34 static void usage(char * name)
36 cout << " " << name <<" <file name>"<< " <mesh name> " << " <interlace mode>" << endl;
37 cout << " " << "displays all Nodes Coordinates in mdump mode" << endl;
39 cout << " " << "mesh name is mandatory. Try mdump if necessary" << endl;
40 cout << " " << "values for interlace mode are : " << endl;
41 cout << " " << "MED_FULL_INTERLACE (default value) or MED_NO_INTERLACE" << endl;
45 int main (int argc, char ** argv) {
47 if (argc < 3) usage(argv[0]);
48 if (argc > 4) usage(argv[0]);
50 string fileName = argv[1];
51 string meshName = argv[2];
53 MED_EN::medModeSwitch Mode = MED_EN::MED_FULL_INTERLACE;
57 if ( comp == "MED_NO_INTERLACE" ) Mode = MED_EN::MED_NO_INTERLACE;
58 else if ( comp != "MED_FULL_INTERLACE") usage(argv[0]);
62 MESH * myMesh= new MESH;
63 myMesh->setName(meshName);
64 MED_MESH_RDONLY_DRIVER myMeshDriver(fileName,myMesh);
67 myMeshDriver.setMeshName(meshName);
70 catch (const exception & ex)
72 MESSAGE_MED("Catch Exception : ");
73 SCRUTE_MED(ex.what());
75 MESSAGE_MED("Open done");
81 catch (const exception & ex)
83 MESSAGE_MED("Catch Exception : ");
84 SCRUTE_MED(ex.what());
86 MESSAGE_MED("Read done");
88 int SpaceDimension = myMesh->getSpaceDimension() ;
89 int NumberOfNodes = myMesh->getNumberOfNodes() ;
91 cout << "(************************)"<<endl;
92 cout << "(* NOEUDS DU MAILLAGE : *)"<<endl;
93 cout << "(************************)"<<endl;
95 string typeRepere = myMesh->getCoordinatesSystem();
96 if ( typeRepere.size() == 0 ) typeRepere ="0";
97 cout << "- Type de repere des coordonnees : " << typeRepere << endl;
99 string chainevide(MED_TAILLE_PNOM+2,' ');
100 cout << "- Nom des coordonnees : " << endl ;
101 const string * CoordinatesNames = myMesh->getCoordinatesNames() ;
102 for (int i=0; i < SpaceDimension ; i++)
104 string bonnelongueur=chainevide;
105 bonnelongueur.replace(1,CoordinatesNames[i].size(),CoordinatesNames[i]);
106 cout << bonnelongueur;
110 cout << "- Unites des coordonnees : " << endl ;
111 const string * CoordinatesUnits = myMesh->getCoordinatesUnits() ;
112 for ( int i=0; i < SpaceDimension ; i++)
114 string bonnelongueur=chainevide;
115 bonnelongueur.replace(1,CoordinatesUnits[i].size(),CoordinatesUnits[i]);
116 cout << bonnelongueur;
120 const double * Coordinates = myMesh->getCoordinates(Mode) ;
121 cout << "- Coordonnees des noeuds : " << endl;
122 for (int i=0; i < SpaceDimension*NumberOfNodes; i++)
124 fprintf(stdout," %f ",Coordinates[i]);
128 myMesh->removeReference();