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"
33 using namespace MEDMEM;
35 void usage(char * name)
37 cout << " " << name << endl;
40 int main (int argc, char ** argv)
43 if (argc < 1) usage(argv[0]);
46 cout << "CELLMODEL Test" << endl ;
47 cout << "--------------" << endl;
49 /* -----------------------------------------------------
50 Construction de tous les types de cellmodel possibles
51 -----------------------------------------------------
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 };
61 for (int i=0; i<MED_NBR_GEOMETRIE_MAILLE ; i++)
63 tous[i]=CELLMODEL(allCellType[i]);
66 /* -----------------------------------------------------
67 Boucle sur tous les types de cellmodel possibles
68 - Chaque Méthode de cellmodel est appelee
69 -----------------------------------------------------
71 for (int i=0; i<MED_NBR_GEOMETRIE_MAILLE ; i++)
74 cout << MED_FR::geoNames[(MED_FR::med_geometrie_element)tous[i].getType()] << endl;
75 cout << "__________________" << endl;
79 cout << "CellModel de Nom : " << tous[i].getName() << endl;
81 catch ( const std::exception &e )
83 cout << "-------------------------------" << endl;
84 cout << " Pb au getName() " << endl;
85 cout << "-------------------------------" << endl;
86 MESSAGE( "catched exception : " << e.what() ) ;
91 cout << "-------------------------------" << endl;
92 cout << " Pb au getName() " << endl;
93 cout << "-------------------------------" << endl;
99 cout << "Nb de Vertexes : " << tous[i].getNumberOfVertexes() << endl;
101 catch ( const std::exception &e )
103 cout << "-------------------------------" << endl;
104 cout << " Pb au getNumberOfVertexes() " << endl;
105 cout << "-------------------------------" << endl;
106 MESSAGE( "catched exception : " << e.what() ) ;
107 return EXIT_FAILURE ;
111 cout << "---------------------------------------" << endl;
112 cout << " Pb au getNumberOfVertexes() " << endl;
113 cout << "---------------------------------------" << endl;
114 return EXIT_FAILURE ;
119 cout << "Nb de Noeuds : " << tous[i].getNumberOfNodes() << endl;
121 catch ( const std::exception &e )
123 cout << "-------------------------------" << endl;
124 cout << " Pb au getNumberOfNodes() " << endl;
125 cout << "-------------------------------" << endl;
126 MESSAGE( "catched exception : " << e.what() ) ;
127 return EXIT_FAILURE ;
131 cout << "---------------------------------" << endl;
132 cout << " Pb au getNumberOfNodes() " << endl;
133 cout << "---------------------------------" << endl;
134 return EXIT_FAILURE ;
140 dimension=tous[i].getDimension();
141 cout << "Dimension : " << dimension << endl;
143 catch ( const std::exception &e )
145 cout << "-------------------------------" << endl;
146 cout << " Pb au getDimension() " << endl;
147 cout << "-------------------------------" << endl;
148 MESSAGE( "catched exception : " << e.what() ) ;
149 return EXIT_FAILURE ;
153 cout << "-------------------------------" << endl;
154 cout << " Pb au getDimension() " << endl;
155 cout << "-------------------------------" << endl;
156 return EXIT_FAILURE ;
159 for (int dim=1; dim< dimension; dim++)
161 int dim2=dimension - dim;
162 cout << "Nb d elements de dimension " << dim << " : ";
166 cout << tous[i].getNumberOfConstituents(dim)<< endl;
168 catch ( const std::exception &e )
170 cout << "------------------------------------" << endl;
171 cout << " Pb au getNumberOfConstituents() " << endl;
172 cout << "------------------------------------" << endl;
173 MESSAGE( "catched exception : " << e.what() ) ;
174 return EXIT_FAILURE ;
178 cout << "------------------------------------" << endl;
179 cout << " Pb au getNumberOfConstituents() " << endl;
180 cout << "------------------------------------" << endl;
181 return EXIT_FAILURE ;
188 int** v1=tous[i].getConstituents(dim2);
189 if ( v1.size() != tous[i].getNumberOfConstituents(dim2) )
191 cout << "----------------------------" << endl;
192 cout << " Pb au getConstituents() " << endl;
193 cout << "----------------------------" << endl;
196 catch ( const std::exception &e )
198 cout << "-------------------------------" << endl;
199 cout << " Pb au getConstituents() " << endl;
200 cout << "-------------------------------" << endl;
201 MESSAGE( "catched exception : " << e.what() ) ;
202 return EXIT_FAILURE ;
206 cout << "----------------------------" << endl;
207 cout << " Pb au getConstituents() " << endl;
208 cout << "----------------------------" << endl;
209 return EXIT_FAILURE ;
212 cout << "Types de ces elements " << endl;
214 set <medGeometryElement> setGeomElt;
215 medGeometryElement * vt;
219 vt=tous[i].getConstituentsType(dim2);
220 taille=tous[i].getNumberOfConstituents(dim2);
222 catch ( const std::exception &e )
224 cout << "-------------------------------" << endl;
225 cout << " Pb au getConstituentsType() " << endl;
226 cout << "-------------------------------" << endl;
227 MESSAGE( "catched exception : " << e.what() ) ;
228 return EXIT_FAILURE ;
232 cout << "--------------------------------" << endl;
233 cout << " Pb au getConstituentsType() " << endl;
234 cout << "--------------------------------" << endl;
235 return EXIT_FAILURE ;
237 for (int k=0; k<taille;k++)
241 medGeometryElement me=tous[i].getConstituentType(dim2,k+1);
244 cout << "-------------------------------" << endl;
245 cout << " Pb au getConstituentType() " << endl;
246 cout << "-------------------------------" << endl;
248 setGeomElt.insert(me);
250 catch ( const std::exception &e )
252 cout << "-------------------------------" << endl;
253 cout << " Pb au getConstituentType() " << endl;
254 cout << "-------------------------------" << endl;
255 MESSAGE( "catched exception : " << e.what() ) ;
256 return EXIT_FAILURE ;
260 cout << "--------------------------------" << endl;
261 cout << " Pb au getConstituentsType() " << endl;
262 cout << "--------------------------------" << endl;
263 return EXIT_FAILURE ;
268 set <medGeometryElement>::iterator iter_s;
269 for (iter_s=setGeomElt.begin() ;iter_s!=setGeomElt.end();iter_s++)
271 cout << MED_FR::geoNames[(MED_FR::med_geometrie_element)(*iter_s)] << endl;
274 cout << "Impression des coordonnées du 1er Element de ce type" << endl;
277 vector<int> v2=tous[i].getNodesConstituent(dim2,1);
278 for (int k=0; k<v2.size();k++)
280 cout << v2[k] << " ";
283 int verif=tous[i].getNodeConstituent(dim2,1,k+1);
286 cout << "-------------------------------" << endl;
287 cout << " Pb au getNodeConstituent() " << endl;
288 cout << "-------------------------------" << endl;
291 catch ( const std::exception &e )
293 cout << "-------------------------------" << endl;
294 cout << " Pb au getNodeConstituent() " << endl;
295 cout << "-------------------------------" << endl;
296 MESSAGE( "catched exception : " << e.what() ) ;
297 return EXIT_FAILURE ;
301 cout << "-------------------------------" << endl;
302 cout << " Pb au getNodeConstituent() " << endl;
303 cout << "-------------------------------" << endl;
304 return EXIT_FAILURE ;
309 catch ( const std::exception &e )
311 cout << "-------------------------------" << endl;
312 cout << " Pb au getNodeConstituent() " << endl;
313 cout << "-------------------------------" << endl;
314 MESSAGE( "catched exception : " << e.what() ) ;
315 return EXIT_FAILURE ;
319 cout << "--------------------------------" << endl;
320 cout << " Pb au getNodeConstituent() " << endl;
321 cout << "--------------------------------" << endl;
322 return EXIT_FAILURE ;
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++)
337 cout << MED_FR::geoNames[(MED_FR::med_geometrie_element)(*iter_s)] << endl;
340 catch ( const std::exception &e )
342 cout << "-------------------------------" << endl;
343 cout << " Pb au getAllConstituentsType() " << endl;
344 cout << "-------------------------------" << endl;
345 MESSAGE( "catched exception : " << e.what() ) ;
346 return EXIT_FAILURE ;
350 cout << "------------------------------------" << endl;
351 cout << " Pb au getAllConstituentsType() " << endl;
352 cout << "------------------------------------" << endl;
353 return EXIT_FAILURE ;
362 return EXIT_SUCCESS ;
365 // Return number of constituents foreach type (which dimension is _dimension-1).
366 map <medGeometryElement,int> getNumberOfConstituentsForeachType() const;