]> SALOME platform Git repositories - modules/med.git/blob - src/MEDMEM/tests/testUSkyLineArray.cxx
Salome HOME
update from the MedMemory V1.0.1
[modules/med.git] / src / MEDMEM / tests / testUSkyLineArray.cxx
1 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
3 // 
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. 
8 // 
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. 
13 // 
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 
17 // 
18 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
19 //
20 //
21 //
22 //  File   : testUSkyLineArray.cxx
23 //  Module : MED
24
25 using namespace std;
26 #include <cstdlib>
27 #include "utilities.h"
28 #include "MEDMEM_SkyLineArray.hxx"
29
30 int main (int argc, char ** argv)
31 {
32
33   int NumberOfCell = 3 ; // 1 triangle,1 quadrangle,1 triangle
34   int Size = 10 ;        // 10 nodes
35
36   int * index = new int[NumberOfCell+1];
37   index[0]=1;
38   index[1]=4;
39   index[2]=8;
40   index[3]=11;
41
42   int * value = new int[Size];
43   value[0]=1; // first
44   value[1]=2;
45   value[2]=5;
46   value[3]=2; // second
47   value[4]=3;
48   value[5]=5;
49   value[6]=6;
50   value[7]=3; // thirst
51   value[8]=4;
52   value[9]=6;
53
54   MEDSKYLINEARRAY * myArray = new MEDSKYLINEARRAY(NumberOfCell,Size,index,value) ;
55
56   const int * ArrayIndex ;
57   try
58   {
59         ArrayIndex = myArray->getIndex() ;
60   }
61   catch ( const std::exception &e )
62   {
63         cout << "----------------" << endl;
64         cout << "pb avec getIndex" << endl;
65         cout << "----------------" << endl;
66         MESSAGE( "catched exception : " << e.what() ) ;
67         return EXIT_FAILURE ;
68   }
69   catch (...)
70   {
71         cout << "----------------" << endl;
72         cout << "pb avec getIndex" << endl;
73         cout << "----------------" << endl;
74         return EXIT_FAILURE ;
75   }
76
77   const int * ArrayValue ;
78   try
79   {
80         ArrayValue  = myArray->getValue() ;
81   }
82   catch ( const std::exception &e )
83   {
84         cout << "----------------" << endl;
85         cout << "pb avec getValue" << endl;
86         cout << "----------------" << endl;
87         MESSAGE( "catched exception : " << e.what() ) ;
88         return EXIT_FAILURE ;
89   }
90   catch (...)
91   {
92         cout << "----------------" << endl;
93         cout << "pb avec getValue" << endl;
94         cout << "----------------" << endl;
95         return EXIT_FAILURE ;
96   }
97
98
99   try
100   {
101         ASSERT(myArray->getNumberOf()==NumberOfCell);
102         cout << myArray->getNumberOf() << endl;
103   }
104   catch ( const std::exception &e )
105   {
106         cout << "-------------------" << endl;
107         cout << "pb avec getNumberOf" << endl;
108         cout << "-------------------" << endl;
109         MESSAGE( "catched exception : " << e.what() ) ;
110         return EXIT_FAILURE ;
111   }
112   catch (...)
113   {
114         cout << "-------------------" << endl;
115         cout << "pb avec getNumberOf" << endl;
116         cout << "-------------------" << endl;
117         return EXIT_FAILURE ;
118   }
119
120   try
121   {
122         ASSERT(myArray->getLength()==Size);
123         cout << myArray->getLength() << endl; 
124   }
125   catch ( const std::exception &e )
126   {
127         cout << "-------------------" << endl;
128         cout << "pb avec getLength" << endl;
129         cout << "-------------------" << endl;
130         MESSAGE( "catched exception : " << e.what() ) ;
131         return EXIT_FAILURE ;
132   }
133   catch (...)
134   {
135         cout << "-------------------" << endl;
136         cout << "pb avec getLength" << endl;
137         cout << "-------------------" << endl;
138         return EXIT_FAILURE ;
139   }
140
141   cout << "Show all :" << endl ;
142   for (int i=1; i< NumberOfCell+1 ; i++) 
143   {
144     const int * cell;
145     try
146     {
147         cell = myArray->getI(i) ;
148     }
149     catch ( const std::exception &e )
150     {
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 ;
156     }
157     catch (...)
158     {
159         cout << "-------------------" << endl;
160         cout << "pb avec getI, valeur de i : " << i << endl;
161         cout << "-------------------" << endl;
162         return EXIT_FAILURE ;
163     }
164
165     int numberof;
166     try
167     {
168         numberof= myArray->getNumberOfI(i) ;
169         ASSERT(numberof==index[i]-index[i-1]);
170     }
171     catch ( const std::exception &e )
172     {
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 ;
178     }
179     catch (...)
180     {
181         cout << "----------------------------------" << endl;
182         cout << "pb avec getNumberOfI, valeur de i : " << i << endl;
183         cout << "----------------------------------" << endl;
184         return EXIT_FAILURE ;
185     }
186
187     cout << " - " ;
188     for (int j=0;j<numberof;j++)
189     {
190         cout << cell[j] << " " ;
191         try
192         {
193                 int verif=myArray->getIJ(i,j+1);
194                 if (verif != cell[j])
195                 {
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 ;
202                 }
203         }
204         catch ( const std::exception &e )
205         {
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 ;
211         }
212         catch (...)
213         {
214                 cout << "----------------------------------" << endl;
215                 cout << "pb avec getIJ, valeurs de i / j : " << i << " " << j<< endl;
216                 cout << "----------------------------------" << endl;
217                 return EXIT_FAILURE ;
218         }
219     }
220     cout << endl ;
221   }
222
223   delete[] index ;
224   delete[] value ;
225
226   delete myArray;
227   MESSAGE("FIN normale du traitement");
228   return EXIT_SUCCESS ;
229
230
231 /*
232   MEDSKYLINEARRAY( const MEDSKYLINEARRAY &myArray );
233   void setMEDSKYLINEARRAY( const med_int count, const med_int length, med_int* index , med_int* value ) ;
234
235   
236 */
237 }