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