Back to index

salome-med  6.5.0
test_MEDMEM_SkyLineArray.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 #include "MEDMEM_SkyLineArray.hxx"
00023 
00024 using namespace std;
00025 using namespace MEDMEM;
00026 
00027 int main (int argc, char ** argv) {
00028   int NumberOfCell = 3 ; // 1 triangle,1 quadrangle,1 triangle
00029   int Size = 10 ; // 10 nodes
00030 
00031   int * index = new int[NumberOfCell+1] ;
00032   index[0]=1;
00033   index[1]=4;
00034   index[2]=8;
00035   index[3]=11;
00036   int * value = new int[Size] ;
00037   value[0]=1; // first
00038   value[1]=2;
00039   value[2]=5;
00040   value[3]=2; // second
00041   value[4]=3;
00042   value[5]=5;
00043   value[6]=6;
00044   value[7]=3; // thirst
00045   value[8]=4;
00046   value[9]=6;
00047   //  value[]=; // forth
00048 
00049   MEDSKYLINEARRAY * myArray = new MEDSKYLINEARRAY(NumberOfCell,Size,index,value) ;
00050 
00051   cout << "Show all 1 :" << endl ;
00052   for (int i=1; i<NumberOfCell+1 ; i++) {
00053     const int * cell = myArray->getI(i) ;
00054     int numberof = myArray->getNumberOfI(i) ;
00055     cout << " - " ;
00056     for (int j=0;j<numberof;j++)
00057       cout << cell[j] << " " ;
00058     cout << endl ;
00059   }
00060   cout << "Show all 2 :" << endl ;
00061   for (int i=1; i<NumberOfCell+1 ; i++) {
00062     cout << " - " ;
00063     int numberof = myArray->getNumberOfI(i) ;
00064     for (int j=1;j<numberof+1;j++)
00065       cout << myArray->getIJ(i,j) << " " ;
00066     cout << endl ;
00067   }
00068 
00069   MEDSKYLINEARRAY * myArray2 = new MEDSKYLINEARRAY(*myArray) ;
00070   delete myArray ;
00071   
00072   cout << "Show all 3 :" << endl ;
00073   const int * index2 = myArray2->getIndex() ;
00074   for (int i=1; i<=NumberOfCell ; i++) {
00075     cout << " - " ;
00076     for (int j=index2[i-1];j<index2[i];j++)
00077       cout << myArray2->getIndexValue(j) << " " ;
00078     cout << endl ;
00079   }
00080 
00081   delete myArray2 ;
00082   delete[] index ;
00083   delete[] value ;
00084 
00085   return 0 ;
00086 }
00087