Back to index

salome-med  6.5.0
test_MEDMEM_Array.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 #include "MEDMEM_Array.hxx"
00024 
00025 using namespace std;
00026 using namespace MEDMEM;
00027 int main (int argc, char ** argv) {
00028 
00029   int SpaceDimension = 3 ;
00030   int NumberOfNodes = 4 ; 
00031   MEDARRAY<int> * myArray = new MEDARRAY<int>(SpaceDimension,NumberOfNodes,MED_EN::MED_FULL_INTERLACE) ;
00032 
00033   //const int * value = myArray->get(MED_FULL_INTERLACE) ;
00034   for (int i=1; i<=NumberOfNodes; i++)
00035     for (int j=1; j<=SpaceDimension; j++)
00036       myArray->setIJ(i,j,i) ;
00037   
00038   int numberof ;
00039   MESSAGE_MED("Show all 1 :");
00040   numberof = myArray->getLeadingValue() ;
00041   for (int i=1; i<=myArray->getLengthValue() ; i++) {
00042     //int * node = myArray->getI(MED_FULL_INTERLACE,i) ;
00043     const int * node = myArray->getRow(i) ;
00044     cout << " - " ;
00045     for (int j=0;j<numberof;j++)
00046       cout << node[j] << " " ;
00047     cout << endl ;
00048   }
00049   MESSAGE_MED("Show all 2 :");
00050   numberof = myArray->getLengthValue() ;
00051   for (int i=1; i<=myArray->getLeadingValue() ; i++) {
00052     //int * node = myArray->getJ(MED_NO_INTERLACE,i) ;
00053     const int * node = myArray->getColumn(i) ;
00054     cout << " - " ;
00055     for (int j=0;j<numberof;j++)
00056       cout << node[j] << " " ;
00057     cout << endl ;
00058   }
00059   MESSAGE_MED("Show all 3 :");
00060   numberof = myArray->getLeadingValue() ;
00061   for (int i=1; i<=myArray->getLengthValue() ; i++) {
00062     cout << " - " ;
00063     for (int j=1;j<numberof+1;j++)
00064       cout << myArray->getIJ(i,j) << " " ;
00065     cout << endl ;
00066   }
00067 
00068   MESSAGE_MED("Show all 0 :");
00069   numberof = myArray->getLeadingValue() ;
00070   int length = myArray->getLengthValue() ;
00071   const int * NoInterlaceArray = myArray->get(MED_EN::MED_NO_INTERLACE) ;
00072   for (int i=0; i<length ; i++) {
00073     cout << " - " ;
00074     for (int j=0;j<numberof;j++)
00075       cout << NoInterlaceArray[j*length+i] << " " ;
00076     cout << endl ;
00077   }
00078 
00079   delete myArray ;
00080 
00081   return 0 ;
00082 }