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 : testUCellModel.cxx
28 #include "utilities.h"
30 #include "MEDMEM_CellModel.hxx"
31 #include "MEDMEM_define.hxx"
32 #include "MEDMEM_DriversDef.hxx"
34 void usage(char * name)
36 cout << " " << name << endl;
39 int main (int argc, char ** argv)
42 if (argc < 1) usage(argv[0]);
45 cout << "CELLMODEL Test" << endl ;
46 cout << "--------------" << endl;
48 /* -----------------------------------------------------
49 Construction de tous les types de cellmodel possibles
50 -----------------------------------------------------
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 };
60 for (int i=0; i<MED_NBR_GEOMETRIE_MAILLE ; i++)
62 tous[i]=CELLMODEL(allCellType[i]);
65 /* -----------------------------------------------------
66 Boucle sur tous les types de cellmodel possibles
67 - Chaque Méthode de cellmodel est appelee
68 -----------------------------------------------------
70 for (int i=0; i<MED_NBR_GEOMETRIE_MAILLE ; i++)
73 cout << MED_FR::geoNames[(MED_FR::med_geometrie_element)tous[i].getType()] << endl;
74 cout << "__________________" << endl;
78 cout << "CellModel de Nom : " << tous[i].getName() << endl;
80 catch ( const std::exception &e )
82 cout << "-------------------------------" << endl;
83 cout << " Pb au getName() " << endl;
84 cout << "-------------------------------" << endl;
85 MESSAGE( "catched exception : " << e.what() ) ;
90 cout << "-------------------------------" << endl;
91 cout << " Pb au getName() " << endl;
92 cout << "-------------------------------" << endl;
98 cout << "Nb de Vertexes : " << tous[i].getNumberOfVertexes() << endl;
100 catch ( const std::exception &e )
102 cout << "-------------------------------" << endl;
103 cout << " Pb au getNumberOfVertexes() " << endl;
104 cout << "-------------------------------" << endl;
105 MESSAGE( "catched exception : " << e.what() ) ;
106 return EXIT_FAILURE ;
110 cout << "---------------------------------------" << endl;
111 cout << " Pb au getNumberOfVertexes() " << endl;
112 cout << "---------------------------------------" << endl;
113 return EXIT_FAILURE ;
118 cout << "Nb de Noeuds : " << tous[i].getNumberOfNodes() << endl;
120 catch ( const std::exception &e )
122 cout << "-------------------------------" << endl;
123 cout << " Pb au getNumberOfNodes() " << endl;
124 cout << "-------------------------------" << endl;
125 MESSAGE( "catched exception : " << e.what() ) ;
126 return EXIT_FAILURE ;
130 cout << "---------------------------------" << endl;
131 cout << " Pb au getNumberOfNodes() " << endl;
132 cout << "---------------------------------" << endl;
133 return EXIT_FAILURE ;
139 dimension=tous[i].getDimension();
140 cout << "Dimension : " << dimension << endl;
142 catch ( const std::exception &e )
144 cout << "-------------------------------" << endl;
145 cout << " Pb au getDimension() " << endl;
146 cout << "-------------------------------" << endl;
147 MESSAGE( "catched exception : " << e.what() ) ;
148 return EXIT_FAILURE ;
152 cout << "-------------------------------" << endl;
153 cout << " Pb au getDimension() " << endl;
154 cout << "-------------------------------" << endl;
155 return EXIT_FAILURE ;
158 for (int dim=1; dim< dimension; dim++)
160 int dim2=dimension - dim;
161 cout << "Nb d elements de dimension " << dim << " : ";
165 cout << tous[i].getNumberOfConstituents(dim)<< endl;
167 catch ( const std::exception &e )
169 cout << "------------------------------------" << endl;
170 cout << " Pb au getNumberOfConstituents() " << endl;
171 cout << "------------------------------------" << endl;
172 MESSAGE( "catched exception : " << e.what() ) ;
173 return EXIT_FAILURE ;
177 cout << "------------------------------------" << endl;
178 cout << " Pb au getNumberOfConstituents() " << endl;
179 cout << "------------------------------------" << endl;
180 return EXIT_FAILURE ;
187 int** v1=tous[i].getConstituents(dim2);
188 if ( v1.size() != tous[i].getNumberOfConstituents(dim2) )
190 cout << "----------------------------" << endl;
191 cout << " Pb au getConstituents() " << endl;
192 cout << "----------------------------" << endl;
195 catch ( const std::exception &e )
197 cout << "-------------------------------" << endl;
198 cout << " Pb au getConstituents() " << endl;
199 cout << "-------------------------------" << endl;
200 MESSAGE( "catched exception : " << e.what() ) ;
201 return EXIT_FAILURE ;
205 cout << "----------------------------" << endl;
206 cout << " Pb au getConstituents() " << endl;
207 cout << "----------------------------" << endl;
208 return EXIT_FAILURE ;
211 cout << "Types de ces elements " << endl;
213 set <medGeometryElement> setGeomElt;
214 medGeometryElement * vt;
218 vt=tous[i].getConstituentsType(dim2);
219 taille=tous[i].getNumberOfConstituents(dim2);
221 catch ( const std::exception &e )
223 cout << "-------------------------------" << endl;
224 cout << " Pb au getConstituentsType() " << endl;
225 cout << "-------------------------------" << endl;
226 MESSAGE( "catched exception : " << e.what() ) ;
227 return EXIT_FAILURE ;
231 cout << "--------------------------------" << endl;
232 cout << " Pb au getConstituentsType() " << endl;
233 cout << "--------------------------------" << endl;
234 return EXIT_FAILURE ;
236 for (int k=0; k<taille;k++)
240 medGeometryElement me=tous[i].getConstituentType(dim2,k+1);
243 cout << "-------------------------------" << endl;
244 cout << " Pb au getConstituentType() " << endl;
245 cout << "-------------------------------" << endl;
247 setGeomElt.insert(me);
249 catch ( const std::exception &e )
251 cout << "-------------------------------" << endl;
252 cout << " Pb au getConstituentType() " << endl;
253 cout << "-------------------------------" << endl;
254 MESSAGE( "catched exception : " << e.what() ) ;
255 return EXIT_FAILURE ;
259 cout << "--------------------------------" << endl;
260 cout << " Pb au getConstituentsType() " << endl;
261 cout << "--------------------------------" << endl;
262 return EXIT_FAILURE ;
267 set <medGeometryElement>::iterator iter_s;
268 for (iter_s=setGeomElt.begin() ;iter_s!=setGeomElt.end();iter_s++)
270 cout << MED_FR::geoNames[(MED_FR::med_geometrie_element)(*iter_s)] << endl;
273 cout << "Impression des coordonnées du 1er Element de ce type" << endl;
276 vector<int> v2=tous[i].getNodesConstituent(dim2,1);
277 for (int k=0; k<v2.size();k++)
279 cout << v2[k] << " ";
282 int verif=tous[i].getNodeConstituent(dim2,1,k+1);
285 cout << "-------------------------------" << endl;
286 cout << " Pb au getNodeConstituent() " << endl;
287 cout << "-------------------------------" << endl;
290 catch ( const std::exception &e )
292 cout << "-------------------------------" << endl;
293 cout << " Pb au getNodeConstituent() " << endl;
294 cout << "-------------------------------" << endl;
295 MESSAGE( "catched exception : " << e.what() ) ;
296 return EXIT_FAILURE ;
300 cout << "-------------------------------" << endl;
301 cout << " Pb au getNodeConstituent() " << endl;
302 cout << "-------------------------------" << endl;
303 return EXIT_FAILURE ;
308 catch ( const std::exception &e )
310 cout << "-------------------------------" << endl;
311 cout << " Pb au getNodeConstituent() " << endl;
312 cout << "-------------------------------" << endl;
313 MESSAGE( "catched exception : " << e.what() ) ;
314 return EXIT_FAILURE ;
318 cout << "--------------------------------" << endl;
319 cout << " Pb au getNodeConstituent() " << endl;
320 cout << "--------------------------------" << endl;
321 return EXIT_FAILURE ;
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++)
336 cout << MED_FR::geoNames[(MED_FR::med_geometrie_element)(*iter_s)] << endl;
339 catch ( const std::exception &e )
341 cout << "-------------------------------" << endl;
342 cout << " Pb au getAllConstituentsType() " << endl;
343 cout << "-------------------------------" << endl;
344 MESSAGE( "catched exception : " << e.what() ) ;
345 return EXIT_FAILURE ;
349 cout << "------------------------------------" << endl;
350 cout << " Pb au getAllConstituentsType() " << endl;
351 cout << "------------------------------------" << endl;
352 return EXIT_FAILURE ;
361 return EXIT_SUCCESS ;
364 // Return number of constituents foreach type (which dimension is _dimension-1).
365 map <medGeometryElement,int> getNumberOfConstituentsForeachType() const;