]> SALOME platform Git repositories - modules/med.git/blob - src/MEDMEM/tests/testUCellModel.cxx
Salome HOME
sources v1.2
[modules/med.git] / src / MEDMEM / tests / testUCellModel.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   : testUCellModel.cxx
23 //  Module : MED
24
25 using namespace std;
26 #include <set>
27 #include <cstdlib> 
28 #include "utilities.h"
29
30 #include "MEDMEM_CellModel.hxx"
31 #include "MEDMEM_define.hxx"
32 #include "MEDMEM_DriversDef.hxx"
33
34 void usage(char * name)
35 {
36   cout << "    " << name << endl;
37 }
38
39 int main (int argc, char ** argv)
40 {
41
42   if (argc < 1) usage(argv[0]);
43
44
45   cout << "CELLMODEL Test" << endl ;
46   cout << "--------------" << endl;
47
48 /*      -----------------------------------------------------
49         Construction de tous les types de cellmodel possibles
50         -----------------------------------------------------
51 */
52
53    CELLMODEL * tous  =new CELLMODEL[MED_NBR_GEOMETRIE_MAILLE ];
54    const medGeometryElement  allCellType[MED_NBR_GEOMETRIE_MAILLE ]=
55              {MED_POINT1, MED_SEG2,    MED_SEG3,   MED_TRIA3,
56               MED_QUAD4,  MED_TRIA6,   MED_QUAD8,  MED_TETRA4,
57               MED_PYRA5,  MED_PENTA6,  MED_HEXA8,  MED_TETRA10,
58               MED_PYRA13, MED_PENTA15, MED_HEXA20 };
59
60   for (int i=0; i<MED_NBR_GEOMETRIE_MAILLE ; i++)
61   {
62         tous[i]=CELLMODEL(allCellType[i]);
63   }
64
65 /*      -----------------------------------------------------
66         Boucle sur  tous les types de cellmodel possibles
67         - Chaque Méthode de cellmodel est appelee
68         -----------------------------------------------------
69 */
70   for (int i=0; i<MED_NBR_GEOMETRIE_MAILLE ; i++)
71   {
72         cout << endl;
73         cout << MED_FR::geoNames[(MED_FR::med_geometrie_element)tous[i].getType()] << endl;
74         cout << "__________________"  << endl;
75
76         try 
77         {
78                 cout << "CellModel de Nom : " << tous[i].getName() << endl;
79         }
80         catch ( const std::exception &e )
81         {
82                 cout << "-------------------------------" << endl;
83                 cout << "       Pb au getName()         " << endl;
84                 cout << "-------------------------------" << endl;
85                 MESSAGE( "catched exception : " << e.what() ) ;
86                 return EXIT_FAILURE ;
87         }
88         catch (...)
89         {
90                 cout << "-------------------------------" << endl;
91                 cout << "       Pb au getName()         " << endl;
92                 cout << "-------------------------------" << endl;
93                 return EXIT_FAILURE ;
94         };
95
96         try 
97         {
98                 cout << "Nb de Vertexes   : " << tous[i].getNumberOfVertexes() << endl;
99         }
100         catch ( const std::exception &e )
101         {
102                 cout << "-------------------------------" << endl;
103                 cout << "       Pb au getNumberOfVertexes()     " << endl;
104                 cout << "-------------------------------" << endl;
105                 MESSAGE( "catched exception : " << e.what() ) ;
106                 return EXIT_FAILURE ;
107         }
108         catch (...)
109         {
110                 cout << "---------------------------------------" << endl;
111                 cout << "       Pb au getNumberOfVertexes()     " << endl;
112                 cout << "---------------------------------------" << endl;
113                 return EXIT_FAILURE ;
114         };
115
116         try 
117         {
118                 cout << "Nb de Noeuds     : " << tous[i].getNumberOfNodes() << endl;
119         }
120         catch ( const std::exception &e )
121         {
122                 cout << "-------------------------------" << endl;
123                 cout << "       Pb au getNumberOfNodes()  " << endl;
124                 cout << "-------------------------------" << endl;
125                 MESSAGE( "catched exception : " << e.what() ) ;
126                 return EXIT_FAILURE ;
127         }
128         catch (...)
129         {
130                 cout << "---------------------------------" << endl;
131                 cout << "       Pb au getNumberOfNodes()  " << endl;
132                 cout << "---------------------------------" << endl;
133                 return EXIT_FAILURE ;
134         };
135
136         int dimension;
137         try 
138         {
139                 dimension=tous[i].getDimension();
140                 cout << "Dimension        : " << dimension << endl;     
141         }
142         catch ( const std::exception &e )
143         {
144                 cout << "-------------------------------" << endl;
145                 cout << "       Pb au getDimension()    " << endl;
146                 cout << "-------------------------------" << endl;
147                 MESSAGE( "catched exception : " << e.what() ) ;
148                 return EXIT_FAILURE ;
149         }
150         catch (...)
151         {
152                 cout << "-------------------------------" << endl;
153                 cout << "       Pb au getDimension()    " << endl;
154                 cout << "-------------------------------" << endl;
155                 return EXIT_FAILURE ;
156         }
157
158         for (int dim=1; dim< dimension; dim++)
159         {
160                 int dim2=dimension - dim;
161                 cout << "Nb d elements de dimension " << dim << " : ";
162
163                 try
164                 {
165                         cout << tous[i].getNumberOfConstituents(dim)<< endl;
166                 }
167                 catch ( const std::exception &e )
168                 {
169                         cout << "------------------------------------" << endl;
170                         cout << "  Pb au getNumberOfConstituents()   " << endl;
171                         cout << "------------------------------------" << endl;
172                         MESSAGE( "catched exception : " << e.what() ) ;
173                         return EXIT_FAILURE ;
174                 }
175                 catch (...)
176                 {
177                         cout << "------------------------------------" << endl;
178                         cout << "  Pb au getNumberOfConstituents()   " << endl;
179                         cout << "------------------------------------" << endl;
180                         return EXIT_FAILURE ;
181                 };
182         }
183 /*
184
185                 try
186                 {
187                         int** v1=tous[i].getConstituents(dim2);
188                         if ( v1.size() != tous[i].getNumberOfConstituents(dim2) )
189                         {
190                                 cout << "----------------------------" << endl;
191                                 cout << "  Pb au getConstituents()   " << endl;
192                                 cout << "----------------------------" << endl;
193                         }
194                 }
195                 catch ( const std::exception &e )
196                 {
197                         cout << "-------------------------------" << endl;
198                         cout << "  Pb au getConstituents()   " << endl;
199                         cout << "-------------------------------" << endl;
200                         MESSAGE( "catched exception : " << e.what() ) ;
201                         return EXIT_FAILURE ;
202                 }
203                 catch (...)
204                 {
205                         cout << "----------------------------" << endl;
206                         cout << "  Pb au getConstituents()   " << endl;
207                         cout << "----------------------------" << endl;
208                         return EXIT_FAILURE ;
209                 };
210
211                 cout << "Types de ces elements " << endl; 
212
213                 set <medGeometryElement> setGeomElt;
214                 medGeometryElement * vt;
215                 int taille;
216                 try
217                 {
218                         vt=tous[i].getConstituentsType(dim2); 
219                         taille=tous[i].getNumberOfConstituents(dim2);
220                 }
221                 catch ( const std::exception &e )
222                 {
223                         cout << "-------------------------------" << endl;
224                         cout << "  Pb au getConstituentsType()   " << endl;
225                         cout << "-------------------------------" << endl;
226                         MESSAGE( "catched exception : " << e.what() ) ;
227                         return EXIT_FAILURE ;
228                 }
229                 catch (...)
230                 {
231                         cout << "--------------------------------" << endl;
232                         cout << "  Pb au getConstituentsType()   " << endl;
233                         cout << "--------------------------------" << endl;
234                         return EXIT_FAILURE ;
235                 };
236                 for (int k=0; k<taille;k++)
237                 {
238                         try
239                         {
240                                 medGeometryElement me=tous[i].getConstituentType(dim2,k+1);
241                                 if  ( vt[k] != me )
242                                 {
243                                         cout << "-------------------------------" << endl;
244                                         cout << "  Pb au getConstituentType()   " << endl;
245                                         cout << "-------------------------------" << endl;
246                                 }
247                                 setGeomElt.insert(me);
248                         }
249                         catch ( const std::exception &e )
250                         {
251                                 cout << "-------------------------------" << endl;
252                                 cout << "  Pb au getConstituentType()   " << endl;
253                                 cout << "-------------------------------" << endl;
254                                 MESSAGE( "catched exception : " << e.what() ) ;
255                                 return EXIT_FAILURE ;
256                         }
257                         catch (...)
258                         {
259                                 cout << "--------------------------------" << endl;
260                                 cout << "  Pb au getConstituentsType()   " << endl;
261                                 cout << "--------------------------------" << endl;
262                                 return EXIT_FAILURE ;
263                         }
264                 }
265
266 /*
267                 set <medGeometryElement>::iterator iter_s;
268                 for (iter_s=setGeomElt.begin() ;iter_s!=setGeomElt.end();iter_s++)
269                 {
270                         cout << MED_FR::geoNames[(MED_FR::med_geometrie_element)(*iter_s)] << endl;     
271                 }
272                 
273                 cout << "Impression des coordonnées du 1er Element de ce type" << endl;
274                 try
275                 {
276                         vector<int> v2=tous[i].getNodesConstituent(dim2,1); 
277                         for (int  k=0; k<v2.size();k++)
278                         {
279                                 cout << v2[k] << " ";
280                                 try
281                                 {
282                                         int verif=tous[i].getNodeConstituent(dim2,1,k+1);
283                                         if ( v2[k] != verif)
284                                         {
285                                                 cout << "-------------------------------" << endl;
286                                                 cout << "  Pb au getNodeConstituent()   " << endl;
287                                                 cout << "-------------------------------" << endl;
288                                         }
289                                 }
290                                 catch ( const std::exception &e )
291                                 {
292                                         cout << "-------------------------------" << endl;
293                                         cout << "  Pb au getNodeConstituent()   " << endl;
294                                         cout << "-------------------------------" << endl;
295                                         MESSAGE( "catched exception : " << e.what() ) ;
296                                         return EXIT_FAILURE ;
297                                 }
298                                 catch (...)
299                                 {
300                                         cout << "-------------------------------" << endl;
301                                         cout << "  Pb au getNodeConstituent()   " << endl;
302                                         cout << "-------------------------------" << endl;
303                                         return EXIT_FAILURE ;
304                                 }
305                         }
306                         cout << endl;
307                 }
308                 catch ( const std::exception &e )
309                 {
310                         cout << "-------------------------------" << endl;
311                         cout << "  Pb au getNodeConstituent()    " << endl;
312                         cout << "-------------------------------" << endl;
313                         MESSAGE( "catched exception : " << e.what() ) ;
314                         return EXIT_FAILURE ;
315                 }
316                 catch (...)
317                 {
318                         cout << "--------------------------------" << endl;
319                         cout << "  Pb au getNodeConstituent()    " << endl;
320                         cout << "--------------------------------" << endl;
321                         return EXIT_FAILURE ;
322                 }
323 */
324
325         cout << endl;
326 /*
327         if ( dimension > 1 )
328         {
329                 try
330                 {
331                         cout << "Informations particulieres -  dimension " << dimension - 1 << endl;
332                         set <medGeometryElement>::iterator iter_s;
333                         for (iter_s=tous[i].getAllConstituentsType().begin() ;
334                         iter_s!=tous[i].getAllConstituentsType().end();iter_s++)
335                         {
336                                 cout << MED_FR::geoNames[(MED_FR::med_geometrie_element)(*iter_s)] << endl;     
337                         }
338                 }
339                 catch ( const std::exception &e )
340                 {
341                         cout << "-------------------------------" << endl;
342                         cout << "  Pb au getAllConstituentsType()    " << endl;
343                         cout << "-------------------------------" << endl;
344                         MESSAGE( "catched exception : " << e.what() ) ;
345                         return EXIT_FAILURE ;
346                 }
347                 catch (...)
348                 {
349                         cout << "------------------------------------" << endl;
350                         cout << "  Pb au getAllConstituentsType()    " << endl;
351                         cout << "------------------------------------" << endl;
352                         return EXIT_FAILURE ;
353                 }
354         }
355 */
356
357   }
358
359   delete[] tous ;
360
361   return EXIT_SUCCESS ;
362 /*
363 Reste a Tester
364   // Return number of constituents foreach type (which dimension is _dimension-1).
365   map <medGeometryElement,int>  getNumberOfConstituentsForeachType() const; 
366 */
367 }