]> SALOME platform Git repositories - modules/med.git/blob - src/MEDMEM/test_MEDMEM_Array.cxx
Salome HOME
NRI : Merge from V1_2.
[modules/med.git] / src / MEDMEM / test_MEDMEM_Array.cxx
1 //  MED MEDMEM : MED files in memory
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
6 //  This library is free software; you can redistribute it and/or 
7 //  modify it under the terms of the GNU Lesser General Public 
8 //  License as published by the Free Software Foundation; either 
9 //  version 2.1 of the License. 
10 // 
11 //  This library is distributed in the hope that it will be useful, 
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
14 //  Lesser General Public License for more details. 
15 // 
16 //  You should have received a copy of the GNU Lesser General Public 
17 //  License along with this library; if not, write to the Free Software 
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : test_MEDMEM_Array.cxx
25 //  Module : MED
26
27 using namespace std;
28 #include "utilities.h"
29 #include "MEDMEM_Array.hxx"
30
31 int main (int argc, char ** argv) {
32
33   int SpaceDimension = 3 ;
34   int NumberOfNodes = 4 ; 
35   MEDARRAY<int> * myArray = new MEDARRAY<int>(SpaceDimension,NumberOfNodes,MED_FULL_INTERLACE) ;
36
37   //const int * value = myArray->get(MED_FULL_INTERLACE) ;
38   for (int i=1; i<=NumberOfNodes; i++)
39     for (int j=1; j<=SpaceDimension; j++)
40       myArray->setIJ(i,j,i) ;
41   
42   int numberof ;
43   MESSAGE("Show all 1 :");
44   numberof = myArray->getLeadingValue() ;
45   for (int i=1; i<=myArray->getLengthValue() ; i++) {
46     //int * node = myArray->getI(MED_FULL_INTERLACE,i) ;
47     const int * node = myArray->getRow(i) ;
48     cout << " - " ;
49     for (int j=0;j<numberof;j++)
50       cout << node[j] << " " ;
51     cout << endl ;
52   }
53   MESSAGE("Show all 2 :");
54   numberof = myArray->getLengthValue() ;
55   for (int i=1; i<=myArray->getLeadingValue() ; i++) {
56     //int * node = myArray->getJ(MED_NO_INTERLACE,i) ;
57     const int * node = myArray->getColumn(i) ;
58     cout << " - " ;
59     for (int j=0;j<numberof;j++)
60       cout << node[j] << " " ;
61     cout << endl ;
62   }
63   MESSAGE("Show all 3 :");
64   numberof = myArray->getLeadingValue() ;
65   for (int i=1; i<=myArray->getLengthValue() ; i++) {
66     cout << " - " ;
67     for (int j=1;j<numberof+1;j++)
68       cout << myArray->getIJ(i,j) << " " ;
69     cout << endl ;
70   }
71
72   MESSAGE("Show all 0 :");
73   numberof = myArray->getLeadingValue() ;
74   int length = myArray->getLengthValue() ;
75   const int * NoInterlaceArray = myArray->get(MED_NO_INTERLACE) ;
76   for (int i=0; i<length ; i++) {
77     cout << " - " ;
78     for (int j=0;j<numberof;j++)
79       cout << NoInterlaceArray[j*length+i] << " " ;
80     cout << endl ;
81   }
82
83   delete myArray ;
84
85   return 0 ;
86 }