1 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
18 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
22 // File : testUSkyLineArray.cxx
27 #include "utilities.h"
28 #include "MEDMEM_SkyLineArray.hxx"
29 using namespace MEDMEM;
31 int main (int argc, char ** argv)
34 int NumberOfCell = 3 ; // 1 triangle,1 quadrangle,1 triangle
35 int Size = 10 ; // 10 nodes
37 int * index = new int[NumberOfCell+1];
43 int * value = new int[Size];
55 MEDSKYLINEARRAY * myArray = new MEDSKYLINEARRAY(NumberOfCell,Size,index,value) ;
57 const int * ArrayIndex ;
60 ArrayIndex = myArray->getIndex() ;
62 catch ( const std::exception &e )
64 cout << "----------------" << endl;
65 cout << "pb avec getIndex" << endl;
66 cout << "----------------" << endl;
67 MESSAGE( "catched exception : " << e.what() ) ;
72 cout << "----------------" << endl;
73 cout << "pb avec getIndex" << endl;
74 cout << "----------------" << endl;
78 const int * ArrayValue ;
81 ArrayValue = myArray->getValue() ;
83 catch ( const std::exception &e )
85 cout << "----------------" << endl;
86 cout << "pb avec getValue" << endl;
87 cout << "----------------" << endl;
88 MESSAGE( "catched exception : " << e.what() ) ;
93 cout << "----------------" << endl;
94 cout << "pb avec getValue" << endl;
95 cout << "----------------" << endl;
102 ASSERT(myArray->getNumberOf()==NumberOfCell);
103 cout << myArray->getNumberOf() << endl;
105 catch ( const std::exception &e )
107 cout << "-------------------" << endl;
108 cout << "pb avec getNumberOf" << endl;
109 cout << "-------------------" << endl;
110 MESSAGE( "catched exception : " << e.what() ) ;
111 return EXIT_FAILURE ;
115 cout << "-------------------" << endl;
116 cout << "pb avec getNumberOf" << endl;
117 cout << "-------------------" << endl;
118 return EXIT_FAILURE ;
123 ASSERT(myArray->getLength()==Size);
124 cout << myArray->getLength() << endl;
126 catch ( const std::exception &e )
128 cout << "-------------------" << endl;
129 cout << "pb avec getLength" << endl;
130 cout << "-------------------" << endl;
131 MESSAGE( "catched exception : " << e.what() ) ;
132 return EXIT_FAILURE ;
136 cout << "-------------------" << endl;
137 cout << "pb avec getLength" << endl;
138 cout << "-------------------" << endl;
139 return EXIT_FAILURE ;
142 cout << "Show all :" << endl ;
143 for (int i=1; i< NumberOfCell+1 ; i++)
148 cell = myArray->getI(i) ;
150 catch ( const std::exception &e )
152 cout << "-----------------------------" << endl;
153 cout << "pb avec getI, valeur de i : " << i << endl;
154 cout << "-----------------------------" << endl;
155 MESSAGE( "catched exception : " << e.what() ) ;
156 return EXIT_FAILURE ;
160 cout << "-------------------" << endl;
161 cout << "pb avec getI, valeur de i : " << i << endl;
162 cout << "-------------------" << endl;
163 return EXIT_FAILURE ;
169 numberof= myArray->getNumberOfI(i) ;
170 ASSERT(numberof==index[i]-index[i-1]);
172 catch ( const std::exception &e )
174 cout << "----------------------------------" << endl;
175 cout << "pb avec getNumberOfI, valeur de i : " << i << endl;
176 cout << "----------------------------------" << endl;
177 MESSAGE( "catched exception : " << e.what() ) ;
178 return EXIT_FAILURE ;
182 cout << "----------------------------------" << endl;
183 cout << "pb avec getNumberOfI, valeur de i : " << i << endl;
184 cout << "----------------------------------" << endl;
185 return EXIT_FAILURE ;
189 for (int j=0;j<numberof;j++)
191 cout << cell[j] << " " ;
194 int verif=myArray->getIJ(i,j+1);
195 if (verif != cell[j])
197 cout << "----------------------------------" << endl;
198 cout << " incoherence dans les valeurs : " << endl;
199 cout << " cell[" << j << "] : " << cell[j] << endl;
200 cout << " getIJ(" << i <<"," << j << ") : " << verif << endl;
201 cout << "----------------------------------" << endl;
202 return EXIT_FAILURE ;
205 catch ( const std::exception &e )
207 cout << "----------------------------------" << endl;
208 cout << "pb avec getIJ, valeurs de i / j : " << i << " " << j<< endl;
209 cout << "----------------------------------" << endl;
210 MESSAGE( "catched exception : " << e.what() ) ;
211 return EXIT_FAILURE ;
215 cout << "----------------------------------" << endl;
216 cout << "pb avec getIJ, valeurs de i / j : " << i << " " << j<< endl;
217 cout << "----------------------------------" << endl;
218 return EXIT_FAILURE ;
228 MESSAGE("FIN normale du traitement");
229 return EXIT_SUCCESS ;
233 MEDSKYLINEARRAY( const MEDSKYLINEARRAY &myArray );
234 void setMEDSKYLINEARRAY( const med_int count, const med_int length, med_int* index , med_int* value ) ;