Salome HOME
Join modifications from branch CEAFor_V3_2_0
[tools/medcoupling.git] / doc / MEDMEM / MESHcoordinates.cxx
1 // Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
3 // 
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.
8 // 
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.
13 //
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
17 //
18 // See http://www.salome-platform.org/
19 //
20 #include "MEDMEM_Mesh.hxx"
21
22 using namespace MEDMEM ;
23 using namespace MED_EN ;
24
25 int main (int argc, char ** argv) {
26
27   const string MedFile = "pointe.med" ;
28   const string MeshName = "maa1" ;
29   MESH myMesh(MED_DRIVER,MedFile,MeshName) ;
30
31   cout << "Mesh name : " << myMesh.getName()  << endl << endl ; 
32
33   int SpaceDimension = myMesh.getSpaceDimension() ;
34   int NumberOfNodes = myMesh.getNumberOfNodes() ;
35   cout << "Space dimension  : " << SpaceDimension << endl << endl ; 
36   cout << "Number of nodes  : " << NumberOfNodes  << endl << endl ; 
37
38   cout << "Show Nodes Coordinates : " << endl ;
39
40   // coordinates names :
41   cout << "Name :" << endl ;
42   const string * CoordinatesNames = myMesh.getCoordinatesNames() ;
43   for(int i=0; i<SpaceDimension ; i++) {
44     cout << " - " << CoordinatesNames[i] << endl ;
45   }
46   // coordinates unit :
47   cout << "Unit :" << endl ;
48   const string * CoordinatesUnits = myMesh.getCoordinatesUnits() ;
49   for(int i=0; i<SpaceDimension ; i++) {
50     cout << " - " << CoordinatesUnits[i] << endl ;
51   }
52   // coordinates value
53   const double * Coordinates = 
54     myMesh.getCoordinates(MED_FULL_INTERLACE) ;
55   for(int i=0; i<NumberOfNodes ; i++) {
56     cout << "Nodes " << i+1 << " : " ;
57     for (int j=0; j<SpaceDimension ; j++)
58       cout << Coordinates[i*SpaceDimension+j] << " " ;
59     cout << endl ;
60   }
61   
62   return 0 ;
63 }