1 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
22 // File : readCoordinate.cxx
27 #include "MEDMEM_Exception.hxx"
28 #include "MEDMEM_define.hxx"
29 #include "MEDMEM_Mesh.hxx"
30 using namespace MEDMEM;
32 void usage(char * name)
34 cout << " " << name <<" <file name>"<< " <mesh name> " << " <interlace mode>" << endl;
35 cout << " " << "displays all Nodes Coordinates in mdump mode" << endl;
37 cout << " " << "mesh name is mandatory. Try mdump if necessary" << endl;
38 cout << " " << "values for interlace mode are : " << endl;
39 cout << " " << "MED_FULL_INTERLACE (default value) or MED_NO_INTERLACE" << endl;
43 int main (int argc, char ** argv) {
45 if (argc < 3) usage(argv[0]);
46 if (argc > 4) usage(argv[0]);
48 string fileName = argv[1];
49 string meshName = argv[2];
51 medModeSwitch Mode = MED_FULL_INTERLACE;
55 if ( comp == "MED_NO_INTERLACE" ) Mode = MED_NO_INTERLACE;
56 else if ( comp != "MED_FULL_INTERLACE") usage(argv[0]);
60 MESH * myMesh= new MESH() ;
61 myMesh->setName(meshName);
62 MED_MESH_RDONLY_DRIVER myMeshDriver(fileName,myMesh);
65 myMeshDriver.setMeshName(meshName);
68 catch (const exception & ex)
70 MESSAGE("Catch Exception : ");
79 catch (const exception & ex)
81 MESSAGE("Catch Exception : ");
86 int SpaceDimension = myMesh->getSpaceDimension() ;
87 int MeshDimension = myMesh->getMeshDimension() ;
88 int NumberOfNodes = myMesh->getNumberOfNodes() ;
90 cout << "(************************)"<<endl;
91 cout << "(* NOEUDS DU MAILLAGE : *)"<<endl;
92 cout << "(************************)"<<endl;
94 string typeRepere = myMesh->getCoordinatesSystem();
95 if ( typeRepere.size() == 0 ) typeRepere ="0";
96 cout << "- Type de repere des coordonnees : " << typeRepere << endl;
98 string chainevide(MED_TAILLE_PNOM+2,' ');
99 cout << "- Nom des coordonnees : " << endl ;
100 const string * CoordinatesNames = myMesh->getCoordinatesNames() ;
101 for (int i=0; i < SpaceDimension ; i++)
103 string bonnelongueur=chainevide;
104 bonnelongueur.replace(1,CoordinatesNames[i].size(),CoordinatesNames[i]);
105 cout << bonnelongueur;
109 cout << "- Unites des coordonnees : " << endl ;
110 const string * CoordinatesUnits = myMesh->getCoordinatesUnits() ;
111 for ( int i=0; i < SpaceDimension ; i++)
113 string bonnelongueur=chainevide;
114 bonnelongueur.replace(1,CoordinatesUnits[i].size(),CoordinatesUnits[i]);
115 cout << bonnelongueur;
119 const double * Coordinates = myMesh->getCoordinates(Mode) ;
120 cout << "- Coordonnees des noeuds : " << endl;
121 for (int i=0; i < SpaceDimension*NumberOfNodes; i++)
123 fprintf(stdout," %f ",Coordinates[i]);