Salome HOME
16f89a30d5b8d5fd562dcba947497ef624371e5c
[modules/med.git] / src / MEDMEMBinTest / test_MEDMEM_Array.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
23 #include "MEDMEM_Array.hxx"
24
25 using namespace std;
26 using namespace MEDMEM;
27 int main (int argc, char ** argv) {
28
29   int SpaceDimension = 3 ;
30   int NumberOfNodes = 4 ; 
31   MEDARRAY<int> * myArray = new MEDARRAY<int>(SpaceDimension,NumberOfNodes,MED_EN::MED_FULL_INTERLACE) ;
32
33   //const int * value = myArray->get(MED_FULL_INTERLACE) ;
34   for (int i=1; i<=NumberOfNodes; i++)
35     for (int j=1; j<=SpaceDimension; j++)
36       myArray->setIJ(i,j,i) ;
37   
38   int numberof ;
39   MESSAGE_MED("Show all 1 :");
40   numberof = myArray->getLeadingValue() ;
41   for (int i=1; i<=myArray->getLengthValue() ; i++) {
42     //int * node = myArray->getI(MED_FULL_INTERLACE,i) ;
43     const int * node = myArray->getRow(i) ;
44     cout << " - " ;
45     for (int j=0;j<numberof;j++)
46       cout << node[j] << " " ;
47     cout << endl ;
48   }
49   MESSAGE_MED("Show all 2 :");
50   numberof = myArray->getLengthValue() ;
51   for (int i=1; i<=myArray->getLeadingValue() ; i++) {
52     //int * node = myArray->getJ(MED_NO_INTERLACE,i) ;
53     const int * node = myArray->getColumn(i) ;
54     cout << " - " ;
55     for (int j=0;j<numberof;j++)
56       cout << node[j] << " " ;
57     cout << endl ;
58   }
59   MESSAGE_MED("Show all 3 :");
60   numberof = myArray->getLeadingValue() ;
61   for (int i=1; i<=myArray->getLengthValue() ; i++) {
62     cout << " - " ;
63     for (int j=1;j<numberof+1;j++)
64       cout << myArray->getIJ(i,j) << " " ;
65     cout << endl ;
66   }
67
68   MESSAGE_MED("Show all 0 :");
69   numberof = myArray->getLeadingValue() ;
70   int length = myArray->getLengthValue() ;
71   const int * NoInterlaceArray = myArray->get(MED_EN::MED_NO_INTERLACE) ;
72   for (int i=0; i<length ; i++) {
73     cout << " - " ;
74     for (int j=0;j<numberof;j++)
75       cout << NoInterlaceArray[j*length+i] << " " ;
76     cout << endl ;
77   }
78
79   delete myArray ;
80
81   return 0 ;
82 }