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