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 : testUCoordinate.cxx
28 #include "utilities.h"
30 #include "MEDMEM_define.hxx"
31 #include "MEDMEM_Array.hxx"
32 #include "MEDMEM_Coordinate.hxx"
34 using namespace MEDMEM;
36 void usage(char * name)
38 cout << " " << name << endl;
41 int main (int argc, char ** argv)
45 if (argc < 1) usage(argv[0]);
47 const double pouieme = 0.009;
49 cout << "COORDINATE Test" << endl;
50 cout << "---------------" << endl;
55 string * noms = new string[3];
65 int * numbers=new int[5];
66 for (int i=0; i< 5; i++) numbers[i] =10+i;
68 MED_EN::medModeSwitch ModeFull=MED_EN::MED_FULL_INTERLACE;
69 MED_EN::medModeSwitch ModeNo=MED_EN::MED_NO_INTERLACE;
70 double coor[15] = {0,0,0,0,0,1,0,1,0,1,0,0,0.5,0.5,0.5} ;
71 ASSERT(SpaceDim*NbOfNodes == 15);
74 cout << " - mode : MED_FULL_INTERLACE" << endl;
75 cout << " - dimension de l espace : " << SpaceDim << endl;
76 cout << " - nombre de noeuds : " << NbOfNodes << endl;
78 double * coor1 = new double[SpaceDim*NbOfNodes];
79 for( int k=0 ; k<SpaceDim*NbOfNodes ; k++ )
82 MEDARRAY<double>* CoordinateArray = new MEDARRAY<double>(coor1,SpaceDim,NbOfNodes,ModeFull);
86 mycoo.setCoordinates(CoordinateArray);
88 catch ( const std::exception &e )
90 cout << "-------------------------------" << endl;
91 cout << "pb avec setCoordinates" << endl;
92 cout << "-------------------------------" << endl;
93 MESSAGE( "catched exception : " << e.what() ) ;
98 cout << "-------------------------------" << endl;
99 cout << "pb avec setCoordinates" << endl;
100 cout << "-------------------------------" << endl;
101 return EXIT_FAILURE ;
104 //--------------------------------------------------------------------//
105 // Tests des methodes //
107 // - setCoordinatesNames //
108 // - setCoordinatesUnits //
109 // - setCoordinatesSystem //
110 // - setNodesNumbers //
112 //--------------------------------------------------------------------//
115 mycoo.setCoordinatesNames(noms);
117 catch ( const std::exception &e )
119 cout << "-------------------------------" << endl;
120 cout << "pb avec setCoordinatesNames" << endl;
121 cout << "-------------------------------" << endl;
122 MESSAGE( "catched exception : " << e.what() ) ;
123 return EXIT_FAILURE ;
127 cout << "-------------------------------" << endl;
128 cout << "pb avec setCoordinatesNames" << endl;
129 cout << "-------------------------------" << endl;
130 return EXIT_FAILURE ;
135 mycoo.setCoordinatesUnits(units);
137 catch ( const std::exception &e )
139 cout << "-------------------------------" << endl;
140 cout << "pb avec setCoordinatesUnits" << endl;
141 cout << "-------------------------------" << endl;
142 MESSAGE( "catched exception : " << e.what() ) ;
143 return EXIT_FAILURE ;
147 cout << "-------------------------------" << endl;
148 cout << "pb avec setCoordinatesUnits" << endl;
149 cout << "-------------------------------" << endl;
150 return EXIT_FAILURE ;
155 mycoo.setCoordinatesSystem("cartesien");
157 catch ( const std::exception &e )
159 cout << "-------------------------------" << endl;
160 cout << "pb avec setCoordinatesSystem" << endl;
161 cout << "-------------------------------" << endl;
162 MESSAGE( "catched exception : " << e.what() ) ;
163 return EXIT_FAILURE ;
167 cout << "-------------------------------" << endl;
168 cout << "pb avec setCoordinatesSystem" << endl;
169 cout << "-------------------------------" << endl;
170 return EXIT_FAILURE ;
175 mycoo.setNodesNumbers(numbers);
177 catch ( const std::exception &e )
179 cout << "-------------------------------" << endl;
180 cout << "pb avec setNodesNumbers" << endl;
181 cout << "-------------------------------" << endl;
182 MESSAGE( "catched exception : " << e.what() ) ;
183 return EXIT_FAILURE ;
187 cout << "-------------------------------" << endl;
188 cout << "pb avec setNodesNumbers" << endl;
189 cout << "-------------------------------" << endl;
190 return EXIT_FAILURE ;
193 //--------------------------------------------------------------------//
194 // Tests des methodes //
196 // - getCoordinatesNames //
197 // - getCoordinatesUnits //
198 // - getCoordinatesUnit //
199 // - getCoordinatesSystem //
200 // - getNodesNumbers //
202 //--------------------------------------------------------------------//
204 cout << endl << " Relecture des Coordonnees" << endl << endl;
208 cout << " Le systeme est : " << mycoo.getCoordinatesSystem() << endl;
210 catch ( const std::exception &e )
212 cout << "-------------------------------" << endl;
213 cout << "pb avec getCoordinatesSystem" << endl;
214 cout << "-------------------------------" << endl;
215 MESSAGE( "catched exception : " << e.what() ) ;
216 return EXIT_FAILURE ;
220 cout << "-------------------------------" << endl;
221 cout << "pb avec getCoordinatesSystem" << endl;
222 cout << "-------------------------------" << endl;
223 return EXIT_FAILURE ;
226 const string * units2;
229 units2=mycoo.getCoordinatesUnits();
230 for (int axe = 0; axe < SpaceDim; axe++)
234 string verif = mycoo.getCoordinateUnit(axe+1);
235 if (verif != units2[axe])
236 cout << "Pb avec les noms des axes" << endl;
238 catch ( const std::exception &e )
240 cout << "-------------------------" << endl;
241 cout << "pb avec getCoordinateUnit" << endl;
242 cout << "-------------------------" << endl;
243 MESSAGE( "catched exception : " << e.what() ) ;
244 return EXIT_FAILURE ;
248 cout << "-------------------------" << endl;
249 cout << "pb avec getCoordinateUnit" << endl;
250 cout << "-------------------------" << endl;
251 return EXIT_FAILURE ;
255 catch ( const std::exception &e )
257 cout << "---------------------------" << endl;
258 cout << "pb avec getCoordinatesUnits" << endl;
259 cout << "---------------------------" << endl;
260 MESSAGE( "catched exception : " << e.what() ) ;
261 return EXIT_FAILURE ;
265 cout << "---------------------------" << endl;
266 cout << "pb avec getCoordinatesUnits" << endl;
267 cout << "---------------------------" << endl;
268 return EXIT_FAILURE ;
271 const string * noms2;
274 noms2=mycoo.getCoordinatesNames();
275 for (int axe = 0; axe < SpaceDim; axe++)
279 string verif = mycoo.getCoordinateName(axe+1);
280 if (verif != noms2[axe])
281 cout << "Pb avec les noms des axes" << endl;
283 catch ( const std::exception &e )
285 cout << "-------------------------" << endl;
286 cout << "pb avec getCoordinateName" << endl;
287 cout << "-------------------------" << endl;
288 MESSAGE( "catched exception : " << e.what() ) ;
289 return EXIT_FAILURE ;
293 cout << "-------------------------" << endl;
294 cout << "pb avec getCoordinateName" << endl;
295 cout << "-------------------------" << endl;
296 return EXIT_FAILURE ;
300 catch ( const std::exception &e )
302 cout << "---------------------------" << endl;
303 cout << "pb avec getCoordinatesNames" << endl;
304 cout << "---------------------------" << endl;
305 MESSAGE( "catched exception : " << e.what() ) ;
306 return EXIT_FAILURE ;
310 cout << "---------------------------" << endl;
311 cout << "pb avec getCoordinatesNames" << endl;
312 cout << "---------------------------" << endl;
313 return EXIT_FAILURE ;
319 const double * coor2=mycoo.getCoordinates(ModeFull);
321 for (int axe = 0; axe < SpaceDim; axe++)
324 cout << "Coordonnees sur l'Axe : " << noms2[axe] ;
325 cout << " dont l unite est " << units2[axe] << endl;
329 const double * coor3=mycoo.getCoordinateAxis(axe+1);
330 for (int num=0; num < NbOfNodes; num++)
334 const double d = mycoo.getCoordinate(num + 1,axe+1);
336 ASSERT(fabs(d - coor3[num]) < pouieme);
337 ASSERT(fabs(d - coor2[(num * SpaceDim)+axe]) < pouieme);
338 ASSERT(fabs(d - coor [(num * SpaceDim)+axe]) < pouieme);
340 catch ( const std::exception &e )
342 cout << "----------------------" << endl;
343 cout << "pb avec getCoordinates" << endl;
344 cout << "----------------------" << endl;
345 MESSAGE( "catched exception : " << e.what() ) ;
346 return EXIT_FAILURE ;
350 cout << "----------------------" << endl;
351 cout << "pb avec getCoordinates" << endl;
352 cout << "----------------------" << endl;
353 return EXIT_FAILURE ;
358 catch ( const std::exception &e )
360 cout << "-------------------------" << endl;
361 cout << "pb avec getCoordinateAxis" << endl;
362 cout << "-------------------------" << endl;
363 MESSAGE( "catched exception : " << e.what() ) ;
364 return EXIT_FAILURE ;
368 cout << "-------------------------" << endl;
369 cout << "pb avec getCoordinateAxis" << endl;
370 cout << "-------------------------" << endl;
371 return EXIT_FAILURE ;
375 catch ( const std::exception &e )
377 cout << "----------------------" << endl;
378 cout << "pb avec getCoordinates" << endl;
379 cout << "----------------------" << endl;
380 MESSAGE( "catched exception : " << e.what() ) ;
381 return EXIT_FAILURE ;
385 cout << "----------------------" << endl;
386 cout << "pb avec getCoordinates" << endl;
387 cout << "----------------------" << endl;
388 return EXIT_FAILURE ;
396 delete CoordinateArray ;
398 MESSAGE("FIN normale du traitement");
399 return EXIT_SUCCESS ;