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
26 #include "utilities.h"
27 #include "MEDMEM_SkyLineArray.hxx"
30 using namespace MEDMEM;
32 int main (int argc, char ** argv)
35 int NumberOfCell = 3 ; // 1 triangle,1 quadrangle,1 triangle
36 int Size = 10 ; // 10 nodes
38 int * index = new int[NumberOfCell+1];
44 int * value = new int[Size];
56 MEDSKYLINEARRAY * myArray = new MEDSKYLINEARRAY(NumberOfCell,Size,index,value) ;
58 const int * ArrayIndex ;
61 ArrayIndex = myArray->getIndex() ;
63 catch ( const std::exception &e )
65 cout << "----------------" << endl;
66 cout << "pb avec getIndex" << endl;
67 cout << "----------------" << endl;
68 MESSAGE( "catched exception : " << e.what() ) ;
73 cout << "----------------" << endl;
74 cout << "pb avec getIndex" << endl;
75 cout << "----------------" << endl;
79 const int * ArrayValue ;
82 ArrayValue = myArray->getValue() ;
84 catch ( const std::exception &e )
86 cout << "----------------" << endl;
87 cout << "pb avec getValue" << endl;
88 cout << "----------------" << endl;
89 MESSAGE( "catched exception : " << e.what() ) ;
94 cout << "----------------" << endl;
95 cout << "pb avec getValue" << endl;
96 cout << "----------------" << endl;
103 ASSERT(myArray->getNumberOf()==NumberOfCell);
104 cout << myArray->getNumberOf() << endl;
106 catch ( const std::exception &e )
108 cout << "-------------------" << endl;
109 cout << "pb avec getNumberOf" << endl;
110 cout << "-------------------" << endl;
111 MESSAGE( "catched exception : " << e.what() ) ;
112 return EXIT_FAILURE ;
116 cout << "-------------------" << endl;
117 cout << "pb avec getNumberOf" << endl;
118 cout << "-------------------" << endl;
119 return EXIT_FAILURE ;
124 ASSERT(myArray->getLength()==Size);
125 cout << myArray->getLength() << endl;
127 catch ( const std::exception &e )
129 cout << "-------------------" << endl;
130 cout << "pb avec getLength" << endl;
131 cout << "-------------------" << endl;
132 MESSAGE( "catched exception : " << e.what() ) ;
133 return EXIT_FAILURE ;
137 cout << "-------------------" << endl;
138 cout << "pb avec getLength" << endl;
139 cout << "-------------------" << endl;
140 return EXIT_FAILURE ;
143 cout << "Show all :" << endl ;
144 for (int i=1; i< NumberOfCell+1 ; i++)
149 cell = myArray->getI(i) ;
151 catch ( const std::exception &e )
153 cout << "-----------------------------" << endl;
154 cout << "pb avec getI, valeur de i : " << i << endl;
155 cout << "-----------------------------" << endl;
156 MESSAGE( "catched exception : " << e.what() ) ;
157 return EXIT_FAILURE ;
161 cout << "-------------------" << endl;
162 cout << "pb avec getI, valeur de i : " << i << endl;
163 cout << "-------------------" << endl;
164 return EXIT_FAILURE ;
170 numberof= myArray->getNumberOfI(i) ;
171 ASSERT(numberof==index[i]-index[i-1]);
173 catch ( const std::exception &e )
175 cout << "----------------------------------" << endl;
176 cout << "pb avec getNumberOfI, valeur de i : " << i << endl;
177 cout << "----------------------------------" << endl;
178 MESSAGE( "catched exception : " << e.what() ) ;
179 return EXIT_FAILURE ;
183 cout << "----------------------------------" << endl;
184 cout << "pb avec getNumberOfI, valeur de i : " << i << endl;
185 cout << "----------------------------------" << endl;
186 return EXIT_FAILURE ;
190 for (int j=0;j<numberof;j++)
192 cout << cell[j] << " " ;
195 int verif=myArray->getIJ(i,j+1);
196 if (verif != cell[j])
198 cout << "----------------------------------" << endl;
199 cout << " incoherence dans les valeurs : " << endl;
200 cout << " cell[" << j << "] : " << cell[j] << endl;
201 cout << " getIJ(" << i <<"," << j << ") : " << verif << endl;
202 cout << "----------------------------------" << endl;
203 return EXIT_FAILURE ;
206 catch ( const std::exception &e )
208 cout << "----------------------------------" << endl;
209 cout << "pb avec getIJ, valeurs de i / j : " << i << " " << j<< endl;
210 cout << "----------------------------------" << endl;
211 MESSAGE( "catched exception : " << e.what() ) ;
212 return EXIT_FAILURE ;
216 cout << "----------------------------------" << endl;
217 cout << "pb avec getIJ, valeurs de i / j : " << i << " " << j<< endl;
218 cout << "----------------------------------" << endl;
219 return EXIT_FAILURE ;
229 MESSAGE("FIN normale du traitement");
230 return EXIT_SUCCESS ;
234 MEDSKYLINEARRAY( const MEDSKYLINEARRAY &myArray );
235 void setMEDSKYLINEARRAY( const med_int count, const med_int length, med_int* index , med_int* value ) ;