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"
31 void usage(char * name)
33 cout << " " << name <<" <file name>"<< " <mesh name> " << " <interlace mode>" << endl;
34 cout << " " << "displays all Nodes Coordinates in mdump mode" << endl;
36 cout << " " << "mesh name is mandatory. Try mdump if necessary" << endl;
37 cout << " " << "values for interlace mode are : " << endl;
38 cout << " " << "MED_FULL_INTERLACE (default value) or MED_NO_INTERLACE" << endl;
42 int main (int argc, char ** argv) {
44 if (argc < 3) usage(argv[0]);
45 if (argc > 4) usage(argv[0]);
47 string fileName = argv[1];
48 string meshName = argv[2];
50 medModeSwitch Mode = MED_FULL_INTERLACE;
54 if ( comp == "MED_NO_INTERLACE" ) Mode = MED_NO_INTERLACE;
55 else if ( comp != "MED_FULL_INTERLACE") usage(argv[0]);
59 MESH * myMesh= new MESH() ;
60 myMesh->setName(meshName);
61 MED_MESH_RDONLY_DRIVER myMeshDriver(fileName,myMesh);
64 myMeshDriver.setMeshName(meshName);
67 catch (const exception & ex)
69 MESSAGE("Catch Exception : ");
78 catch (const exception & ex)
80 MESSAGE("Catch Exception : ");
85 int SpaceDimension = myMesh->getSpaceDimension() ;
86 int MeshDimension = myMesh->getMeshDimension() ;
87 int NumberOfNodes = myMesh->getNumberOfNodes() ;
89 cout << "(************************)"<<endl;
90 cout << "(* NOEUDS DU MAILLAGE : *)"<<endl;
91 cout << "(************************)"<<endl;
93 string typeRepere = myMesh->getCoordinatesSystem();
94 if ( typeRepere.size() == 0 ) typeRepere ="0";
95 cout << "- Type de repere des coordonnees : " << typeRepere << endl;
97 string chainevide(MED_TAILLE_PNOM+2,' ');
98 cout << "- Nom des coordonnees : " << endl ;
99 const string * CoordinatesNames = myMesh->getCoordinatesNames() ;
100 for (int i=0; i < SpaceDimension ; i++)
102 string bonnelongueur=chainevide;
103 bonnelongueur.replace(1,CoordinatesNames[i].size(),CoordinatesNames[i]);
104 cout << bonnelongueur;
108 cout << "- Unites des coordonnees : " << endl ;
109 const string * CoordinatesUnits = myMesh->getCoordinatesUnits() ;
110 for ( int i=0; i < SpaceDimension ; i++)
112 string bonnelongueur=chainevide;
113 bonnelongueur.replace(1,CoordinatesUnits[i].size(),CoordinatesUnits[i]);
114 cout << bonnelongueur;
118 const double * Coordinates = myMesh->getCoordinates(Mode) ;
119 cout << "- Coordonnees des noeuds : " << endl;
120 for (int i=0; i < SpaceDimension*NumberOfNodes; i++)
122 fprintf(stdout," %f ",Coordinates[i]);