Salome HOME
Merging with the MAN_SALOME2 branch
[modules/med.git] / src / MEDMEM / test_MEDMEM_SkyLineArray.cxx
1 using namespace std;
2 #include "utilities.h"
3 #include "MEDMEM_SkyLineArray.hxx"
4 using namespace MEDMEM;
5
6 int main (int argc, char ** argv) {
7
8   int NumberOfCell = 3 ; // 1 triangle,1 quadrangle,1 triangle
9   int Size = 10 ; // 10 nodes
10
11   int * index = new int[NumberOfCell+1] ;
12   index[0]=1;
13   index[1]=4;
14   index[2]=8;
15   index[3]=11;
16   int * value = new int[Size] ;
17   value[0]=1; // first
18   value[1]=2;
19   value[2]=5;
20   value[3]=2; // second
21   value[4]=3;
22   value[5]=5;
23   value[6]=6;
24   value[7]=3; // thirst
25   value[8]=4;
26   value[9]=6;
27   //  value[]=; // forth
28
29   MEDSKYLINEARRAY * myArray = new MEDSKYLINEARRAY(NumberOfCell,Size,index,value) ;
30
31   cout << "Show all 1 :" << endl ;
32   for (int i=1; i<NumberOfCell+1 ; i++) {
33     const int * cell = myArray->getI(i) ;
34     int numberof = myArray->getNumberOfI(i) ;
35     cout << " - " ;
36     for (int j=0;j<numberof;j++)
37       cout << cell[j] << " " ;
38     cout << endl ;
39   }
40   cout << "Show all 2 :" << endl ;
41   for (int i=1; i<NumberOfCell+1 ; i++) {
42     cout << " - " ;
43     int numberof = myArray->getNumberOfI(i) ;
44     for (int j=1;j<numberof+1;j++)
45       cout << myArray->getIJ(i,j) << " " ;
46     cout << endl ;
47   }
48
49   MEDSKYLINEARRAY * myArray2 = new MEDSKYLINEARRAY(*myArray) ;
50   delete myArray ;
51   
52   cout << "Show all 3 :" << endl ;
53   const int * index2 = myArray2->getIndex() ;
54   for (int i=1; i<=NumberOfCell ; i++) {
55     cout << " - " ;
56     for (int j=index2[i-1];j<index2[i];j++)
57       cout << myArray2->getIndexValue(j) << " " ;
58     cout << endl ;
59   }
60
61   delete myArray2 ;
62   delete[] index ;
63   delete[] value ;
64
65   return 0 ;
66 }
67