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"
35 void usage(char * name)
37 cout << " " << name << endl;
40 int main (int argc, char ** argv)
44 if (argc < 1) usage(argv[0]);
46 const double pouieme = 0.009;
48 cout << "COORDINATE Test" << endl;
49 cout << "---------------" << endl;
54 string * noms = new string[3];
64 int * numbers=new int[5];
65 for (int i=0; i< 5; i++) numbers[i] =10+i;
67 MED_EN::medModeSwitch ModeFull=MED_EN::MED_FULL_INTERLACE;
68 MED_EN::medModeSwitch ModeNo=MED_EN::MED_NO_INTERLACE;
69 double coor[15] = {0,0,0,0,0,1,0,1,0,1,0,0,0.5,0.5,0.5} ;
70 ASSERT(SpaceDim*NbOfNodes == 15);
73 cout << " - mode : MED_FULL_INTERLACE" << endl;
74 cout << " - dimension de l espace : " << SpaceDim << endl;
75 cout << " - nombre de noeuds : " << NbOfNodes << endl;
77 double * coor1 = new double[SpaceDim*NbOfNodes];
78 for( int k=0 ; k<SpaceDim*NbOfNodes ; k++ )
81 MEDARRAY<double>* CoordinateArray = new MEDARRAY<double>(coor1,SpaceDim,NbOfNodes,ModeFull);
85 mycoo.setCoordinates(CoordinateArray);
87 catch ( const std::exception &e )
89 cout << "-------------------------------" << endl;
90 cout << "pb avec setCoordinates" << endl;
91 cout << "-------------------------------" << endl;
92 MESSAGE( "catched exception : " << e.what() ) ;
97 cout << "-------------------------------" << endl;
98 cout << "pb avec setCoordinates" << endl;
99 cout << "-------------------------------" << endl;
100 return EXIT_FAILURE ;
103 //--------------------------------------------------------------------//
104 // Tests des methodes //
106 // - setCoordinatesNames //
107 // - setCoordinatesUnits //
108 // - setCoordinatesSystem //
109 // - setNodesNumbers //
111 //--------------------------------------------------------------------//
114 mycoo.setCoordinatesNames(noms);
116 catch ( const std::exception &e )
118 cout << "-------------------------------" << endl;
119 cout << "pb avec setCoordinatesNames" << endl;
120 cout << "-------------------------------" << endl;
121 MESSAGE( "catched exception : " << e.what() ) ;
122 return EXIT_FAILURE ;
126 cout << "-------------------------------" << endl;
127 cout << "pb avec setCoordinatesNames" << endl;
128 cout << "-------------------------------" << endl;
129 return EXIT_FAILURE ;
134 mycoo.setCoordinatesUnits(units);
136 catch ( const std::exception &e )
138 cout << "-------------------------------" << endl;
139 cout << "pb avec setCoordinatesUnits" << endl;
140 cout << "-------------------------------" << endl;
141 MESSAGE( "catched exception : " << e.what() ) ;
142 return EXIT_FAILURE ;
146 cout << "-------------------------------" << endl;
147 cout << "pb avec setCoordinatesUnits" << endl;
148 cout << "-------------------------------" << endl;
149 return EXIT_FAILURE ;
154 mycoo.setCoordinatesSystem("cartesien");
156 catch ( const std::exception &e )
158 cout << "-------------------------------" << endl;
159 cout << "pb avec setCoordinatesSystem" << endl;
160 cout << "-------------------------------" << endl;
161 MESSAGE( "catched exception : " << e.what() ) ;
162 return EXIT_FAILURE ;
166 cout << "-------------------------------" << endl;
167 cout << "pb avec setCoordinatesSystem" << endl;
168 cout << "-------------------------------" << endl;
169 return EXIT_FAILURE ;
174 mycoo.setNodesNumbers(numbers);
176 catch ( const std::exception &e )
178 cout << "-------------------------------" << endl;
179 cout << "pb avec setNodesNumbers" << endl;
180 cout << "-------------------------------" << endl;
181 MESSAGE( "catched exception : " << e.what() ) ;
182 return EXIT_FAILURE ;
186 cout << "-------------------------------" << endl;
187 cout << "pb avec setNodesNumbers" << endl;
188 cout << "-------------------------------" << endl;
189 return EXIT_FAILURE ;
192 //--------------------------------------------------------------------//
193 // Tests des methodes //
195 // - getCoordinatesNames //
196 // - getCoordinatesUnits //
197 // - getCoordinatesUnit //
198 // - getCoordinatesSystem //
199 // - getNodesNumbers //
201 //--------------------------------------------------------------------//
203 cout << endl << " Relecture des Coordonnees" << endl << endl;
207 cout << " Le systeme est : " << mycoo.getCoordinatesSystem() << endl;
209 catch ( const std::exception &e )
211 cout << "-------------------------------" << endl;
212 cout << "pb avec getCoordinatesSystem" << endl;
213 cout << "-------------------------------" << endl;
214 MESSAGE( "catched exception : " << e.what() ) ;
215 return EXIT_FAILURE ;
219 cout << "-------------------------------" << endl;
220 cout << "pb avec getCoordinatesSystem" << endl;
221 cout << "-------------------------------" << endl;
222 return EXIT_FAILURE ;
225 const string * units2;
228 units2=mycoo.getCoordinatesUnits();
229 for (int axe = 0; axe < SpaceDim; axe++)
233 string verif = mycoo.getCoordinateUnit(axe+1);
234 if (verif != units2[axe])
235 cout << "Pb avec les noms des axes" << endl;
237 catch ( const std::exception &e )
239 cout << "-------------------------" << endl;
240 cout << "pb avec getCoordinateUnit" << endl;
241 cout << "-------------------------" << endl;
242 MESSAGE( "catched exception : " << e.what() ) ;
243 return EXIT_FAILURE ;
247 cout << "-------------------------" << endl;
248 cout << "pb avec getCoordinateUnit" << endl;
249 cout << "-------------------------" << endl;
250 return EXIT_FAILURE ;
254 catch ( const std::exception &e )
256 cout << "---------------------------" << endl;
257 cout << "pb avec getCoordinatesUnits" << endl;
258 cout << "---------------------------" << endl;
259 MESSAGE( "catched exception : " << e.what() ) ;
260 return EXIT_FAILURE ;
264 cout << "---------------------------" << endl;
265 cout << "pb avec getCoordinatesUnits" << endl;
266 cout << "---------------------------" << endl;
267 return EXIT_FAILURE ;
270 const string * noms2;
273 noms2=mycoo.getCoordinatesNames();
274 for (int axe = 0; axe < SpaceDim; axe++)
278 string verif = mycoo.getCoordinateName(axe+1);
279 if (verif != noms2[axe])
280 cout << "Pb avec les noms des axes" << endl;
282 catch ( const std::exception &e )
284 cout << "-------------------------" << endl;
285 cout << "pb avec getCoordinateName" << endl;
286 cout << "-------------------------" << endl;
287 MESSAGE( "catched exception : " << e.what() ) ;
288 return EXIT_FAILURE ;
292 cout << "-------------------------" << endl;
293 cout << "pb avec getCoordinateName" << endl;
294 cout << "-------------------------" << endl;
295 return EXIT_FAILURE ;
299 catch ( const std::exception &e )
301 cout << "---------------------------" << endl;
302 cout << "pb avec getCoordinatesNames" << endl;
303 cout << "---------------------------" << endl;
304 MESSAGE( "catched exception : " << e.what() ) ;
305 return EXIT_FAILURE ;
309 cout << "---------------------------" << endl;
310 cout << "pb avec getCoordinatesNames" << endl;
311 cout << "---------------------------" << endl;
312 return EXIT_FAILURE ;
318 const double * coor2=mycoo.getCoordinates(ModeFull);
320 for (int axe = 0; axe < SpaceDim; axe++)
323 cout << "Coordonnees sur l'Axe : " << noms2[axe] ;
324 cout << " dont l unite est " << units2[axe] << endl;
328 const double * coor3=mycoo.getCoordinateAxis(axe+1);
329 for (int num=0; num < NbOfNodes; num++)
333 const double d = mycoo.getCoordinate(num + 1,axe+1);
335 ASSERT(fabs(d - coor3[num]) < pouieme);
336 ASSERT(fabs(d - coor2[(num * SpaceDim)+axe]) < pouieme);
337 ASSERT(fabs(d - coor [(num * SpaceDim)+axe]) < pouieme);
339 catch ( const std::exception &e )
341 cout << "----------------------" << endl;
342 cout << "pb avec getCoordinates" << endl;
343 cout << "----------------------" << endl;
344 MESSAGE( "catched exception : " << e.what() ) ;
345 return EXIT_FAILURE ;
349 cout << "----------------------" << endl;
350 cout << "pb avec getCoordinates" << endl;
351 cout << "----------------------" << endl;
352 return EXIT_FAILURE ;
357 catch ( const std::exception &e )
359 cout << "-------------------------" << endl;
360 cout << "pb avec getCoordinateAxis" << endl;
361 cout << "-------------------------" << endl;
362 MESSAGE( "catched exception : " << e.what() ) ;
363 return EXIT_FAILURE ;
367 cout << "-------------------------" << endl;
368 cout << "pb avec getCoordinateAxis" << endl;
369 cout << "-------------------------" << endl;
370 return EXIT_FAILURE ;
374 catch ( const std::exception &e )
376 cout << "----------------------" << endl;
377 cout << "pb avec getCoordinates" << endl;
378 cout << "----------------------" << endl;
379 MESSAGE( "catched exception : " << e.what() ) ;
380 return EXIT_FAILURE ;
384 cout << "----------------------" << endl;
385 cout << "pb avec getCoordinates" << endl;
386 cout << "----------------------" << endl;
387 return EXIT_FAILURE ;
395 delete CoordinateArray ;
397 MESSAGE("FIN normale du traitement");
398 return EXIT_SUCCESS ;