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