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"
30 int main (int argc, char ** argv)
33 int NumberOfCell = 3 ; // 1 triangle,1 quadrangle,1 triangle
34 int Size = 10 ; // 10 nodes
36 int * index = new int[NumberOfCell+1];
42 int * value = new int[Size];
54 MEDSKYLINEARRAY * myArray = new MEDSKYLINEARRAY(NumberOfCell,Size,index,value) ;
56 const int * ArrayIndex ;
59 ArrayIndex = myArray->getIndex() ;
61 catch ( const std::exception &e )
63 cout << "----------------" << endl;
64 cout << "pb avec getIndex" << endl;
65 cout << "----------------" << endl;
66 MESSAGE( "catched exception : " << e.what() ) ;
71 cout << "----------------" << endl;
72 cout << "pb avec getIndex" << endl;
73 cout << "----------------" << endl;
77 const int * ArrayValue ;
80 ArrayValue = myArray->getValue() ;
82 catch ( const std::exception &e )
84 cout << "----------------" << endl;
85 cout << "pb avec getValue" << endl;
86 cout << "----------------" << endl;
87 MESSAGE( "catched exception : " << e.what() ) ;
92 cout << "----------------" << endl;
93 cout << "pb avec getValue" << endl;
94 cout << "----------------" << endl;
101 ASSERT(myArray->getNumberOf()==NumberOfCell);
102 cout << myArray->getNumberOf() << endl;
104 catch ( const std::exception &e )
106 cout << "-------------------" << endl;
107 cout << "pb avec getNumberOf" << endl;
108 cout << "-------------------" << endl;
109 MESSAGE( "catched exception : " << e.what() ) ;
110 return EXIT_FAILURE ;
114 cout << "-------------------" << endl;
115 cout << "pb avec getNumberOf" << endl;
116 cout << "-------------------" << endl;
117 return EXIT_FAILURE ;
122 ASSERT(myArray->getLength()==Size);
123 cout << myArray->getLength() << endl;
125 catch ( const std::exception &e )
127 cout << "-------------------" << endl;
128 cout << "pb avec getLength" << endl;
129 cout << "-------------------" << endl;
130 MESSAGE( "catched exception : " << e.what() ) ;
131 return EXIT_FAILURE ;
135 cout << "-------------------" << endl;
136 cout << "pb avec getLength" << endl;
137 cout << "-------------------" << endl;
138 return EXIT_FAILURE ;
141 cout << "Show all :" << endl ;
142 for (int i=1; i< NumberOfCell+1 ; i++)
147 cell = myArray->getI(i) ;
149 catch ( const std::exception &e )
151 cout << "-----------------------------" << endl;
152 cout << "pb avec getI, valeur de i : " << i << endl;
153 cout << "-----------------------------" << endl;
154 MESSAGE( "catched exception : " << e.what() ) ;
155 return EXIT_FAILURE ;
159 cout << "-------------------" << endl;
160 cout << "pb avec getI, valeur de i : " << i << endl;
161 cout << "-------------------" << endl;
162 return EXIT_FAILURE ;
168 numberof= myArray->getNumberOfI(i) ;
169 ASSERT(numberof==index[i]-index[i-1]);
171 catch ( const std::exception &e )
173 cout << "----------------------------------" << endl;
174 cout << "pb avec getNumberOfI, valeur de i : " << i << endl;
175 cout << "----------------------------------" << endl;
176 MESSAGE( "catched exception : " << e.what() ) ;
177 return EXIT_FAILURE ;
181 cout << "----------------------------------" << endl;
182 cout << "pb avec getNumberOfI, valeur de i : " << i << endl;
183 cout << "----------------------------------" << endl;
184 return EXIT_FAILURE ;
188 for (int j=0;j<numberof;j++)
190 cout << cell[j] << " " ;
193 int verif=myArray->getIJ(i,j+1);
194 if (verif != cell[j])
196 cout << "----------------------------------" << endl;
197 cout << " incoherence dans les valeurs : " << endl;
198 cout << " cell[" << j << "] : " << cell[j] << endl;
199 cout << " getIJ(" << i <<"," << j << ") : " << verif << endl;
200 cout << "----------------------------------" << endl;
201 return EXIT_FAILURE ;
204 catch ( const std::exception &e )
206 cout << "----------------------------------" << endl;
207 cout << "pb avec getIJ, valeurs de i / j : " << i << " " << j<< endl;
208 cout << "----------------------------------" << endl;
209 MESSAGE( "catched exception : " << e.what() ) ;
210 return EXIT_FAILURE ;
214 cout << "----------------------------------" << endl;
215 cout << "pb avec getIJ, valeurs de i / j : " << i << " " << j<< endl;
216 cout << "----------------------------------" << endl;
217 return EXIT_FAILURE ;
227 MESSAGE("FIN normale du traitement");
228 return EXIT_SUCCESS ;
232 MEDSKYLINEARRAY( const MEDSKYLINEARRAY &myArray );
233 void setMEDSKYLINEARRAY( const med_int count, const med_int length, med_int* index , med_int* value ) ;