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.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : readCoordinate.cxx
26 #include "MEDMEM_Exception.hxx"
27 #include "MEDMEM_define.hxx"
28 #include "MEDMEM_Mesh.hxx"
29 #include "MEDMEM_MedMeshDriver.hxx"
32 using namespace MEDMEM;
34 #define MED_TAILLE_PNOM 16
36 void usage(char * name)
38 cout << " " << name <<" <file name>"<< " <mesh name> " << " <interlace mode>" << endl;
39 cout << " " << "displays all Nodes Coordinates in mdump mode" << endl;
41 cout << " " << "mesh name is mandatory. Try mdump if necessary" << endl;
42 cout << " " << "values for interlace mode are : " << endl;
43 cout << " " << "MED_FULL_INTERLACE (default value) or MED_NO_INTERLACE" << endl;
47 int main (int argc, char ** argv) {
49 if (argc < 3) usage(argv[0]);
50 if (argc > 4) usage(argv[0]);
52 string fileName = argv[1];
53 string meshName = argv[2];
55 MED_EN::medModeSwitch Mode = MED_EN::MED_FULL_INTERLACE;
59 if ( comp == "MED_NO_INTERLACE" ) Mode = MED_EN::MED_NO_INTERLACE;
60 else if ( comp != "MED_FULL_INTERLACE") usage(argv[0]);
64 MESH * myMesh= new MESH() ;
65 myMesh->setName(meshName);
66 MED_MESH_RDONLY_DRIVER myMeshDriver(fileName,myMesh);
69 myMeshDriver.setMeshName(meshName);
72 catch (const exception & ex)
74 MESSAGE("Catch Exception : ");
83 catch (const exception & ex)
85 MESSAGE("Catch Exception : ");
90 int SpaceDimension = myMesh->getSpaceDimension() ;
91 int MeshDimension = myMesh->getMeshDimension() ;
92 int NumberOfNodes = myMesh->getNumberOfNodes() ;
94 cout << "(************************)"<<endl;
95 cout << "(* NOEUDS DU MAILLAGE : *)"<<endl;
96 cout << "(************************)"<<endl;
98 string typeRepere = myMesh->getCoordinatesSystem();
99 if ( typeRepere.size() == 0 ) typeRepere ="0";
100 cout << "- Type de repere des coordonnees : " << typeRepere << endl;
102 string chainevide(MED_TAILLE_PNOM+2,' ');
103 cout << "- Nom des coordonnees : " << endl ;
104 const string * CoordinatesNames = myMesh->getCoordinatesNames() ;
105 for (int i=0; i < SpaceDimension ; i++)
107 string bonnelongueur=chainevide;
108 bonnelongueur.replace(1,CoordinatesNames[i].size(),CoordinatesNames[i]);
109 cout << bonnelongueur;
113 cout << "- Unites des coordonnees : " << endl ;
114 const string * CoordinatesUnits = myMesh->getCoordinatesUnits() ;
115 for ( int i=0; i < SpaceDimension ; i++)
117 string bonnelongueur=chainevide;
118 bonnelongueur.replace(1,CoordinatesUnits[i].size(),CoordinatesUnits[i]);
119 cout << bonnelongueur;
123 const double * Coordinates = myMesh->getCoordinates(Mode) ;
124 cout << "- Coordonnees des noeuds : " << endl;
125 for (int i=0; i < SpaceDimension*NumberOfNodes; i++)
127 fprintf(stdout," %f ",Coordinates[i]);