Salome HOME
Copyrights update
[modules/med.git] / src / MEDMEM / test_MEDMEM_SkyLineArray.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_SkyLineArray.hxx"
21
22 using namespace std;
23 using namespace MEDMEM;
24
25 int main (int argc, char ** argv) {
26   int NumberOfCell = 3 ; // 1 triangle,1 quadrangle,1 triangle
27   int Size = 10 ; // 10 nodes
28
29   int * index = new int[NumberOfCell+1] ;
30   index[0]=1;
31   index[1]=4;
32   index[2]=8;
33   index[3]=11;
34   int * value = new int[Size] ;
35   value[0]=1; // first
36   value[1]=2;
37   value[2]=5;
38   value[3]=2; // second
39   value[4]=3;
40   value[5]=5;
41   value[6]=6;
42   value[7]=3; // thirst
43   value[8]=4;
44   value[9]=6;
45   //  value[]=; // forth
46
47   MEDSKYLINEARRAY * myArray = new MEDSKYLINEARRAY(NumberOfCell,Size,index,value) ;
48
49   cout << "Show all 1 :" << endl ;
50   for (int i=1; i<NumberOfCell+1 ; i++) {
51     const int * cell = myArray->getI(i) ;
52     int numberof = myArray->getNumberOfI(i) ;
53     cout << " - " ;
54     for (int j=0;j<numberof;j++)
55       cout << cell[j] << " " ;
56     cout << endl ;
57   }
58   cout << "Show all 2 :" << endl ;
59   for (int i=1; i<NumberOfCell+1 ; i++) {
60     cout << " - " ;
61     int numberof = myArray->getNumberOfI(i) ;
62     for (int j=1;j<numberof+1;j++)
63       cout << myArray->getIJ(i,j) << " " ;
64     cout << endl ;
65   }
66
67   MEDSKYLINEARRAY * myArray2 = new MEDSKYLINEARRAY(*myArray) ;
68   delete myArray ;
69   
70   cout << "Show all 3 :" << endl ;
71   const int * index2 = myArray2->getIndex() ;
72   for (int i=1; i<=NumberOfCell ; i++) {
73     cout << " - " ;
74     for (int j=index2[i-1];j<index2[i];j++)
75       cout << myArray2->getIndexValue(j) << " " ;
76     cout << endl ;
77   }
78
79   delete myArray2 ;
80   delete[] index ;
81   delete[] value ;
82
83   return 0 ;
84 }
85