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
27 #include "utilities.h"
29 #include "MEDMEM_CellModel.hxx"
30 #include "MEDMEM_define.hxx"
31 #include "MEDMEM_DriversDef.hxx"
34 using namespace MEDMEM;
35 using namespace MED_EN;
37 void usage(char * name)
39 cout << " " << name << endl;
42 int main (int argc, char ** argv)
45 if (argc < 1) usage(argv[0]);
48 cout << "CELLMODEL Test" << endl ;
49 cout << "--------------" << endl;
51 /* -----------------------------------------------------
52 Construction de tous les types de cellmodel possibles
53 -----------------------------------------------------
56 CELLMODEL * tous =new CELLMODEL[MED_NBR_GEOMETRIE_MAILLE ];
57 const medGeometryElement allCellType[MED_NBR_GEOMETRIE_MAILLE ]=
58 {MED_POINT1, MED_SEG2, MED_SEG3, MED_TRIA3,
59 MED_QUAD4, MED_TRIA6, MED_QUAD8, MED_TETRA4,
60 MED_PYRA5, MED_PENTA6, MED_HEXA8, MED_TETRA10,
61 MED_PYRA13, MED_PENTA15, MED_HEXA20 };
63 for (int i=0; i<MED_NBR_GEOMETRIE_MAILLE ; i++)
65 tous[i]=CELLMODEL(allCellType[i]);
68 /* -----------------------------------------------------
69 Boucle sur tous les types de cellmodel possibles
70 - Chaque Méthode de cellmodel est appelee
71 -----------------------------------------------------
73 for (int i=0; i<MED_NBR_GEOMETRIE_MAILLE ; i++)
76 cout << geoNames[tous[i].getType()] << endl;
77 cout << "__________________" << endl;
81 cout << "CellModel de Nom : " << tous[i].getName() << endl;
83 catch ( const std::exception &e )
85 cout << "-------------------------------" << endl;
86 cout << " Pb au getName() " << endl;
87 cout << "-------------------------------" << endl;
88 MESSAGE( "catched exception : " << e.what() ) ;
93 cout << "-------------------------------" << endl;
94 cout << " Pb au getName() " << endl;
95 cout << "-------------------------------" << endl;
101 cout << "Nb de Vertexes : " << tous[i].getNumberOfVertexes() << endl;
103 catch ( const std::exception &e )
105 cout << "-------------------------------" << endl;
106 cout << " Pb au getNumberOfVertexes() " << endl;
107 cout << "-------------------------------" << endl;
108 MESSAGE( "catched exception : " << e.what() ) ;
109 return EXIT_FAILURE ;
113 cout << "---------------------------------------" << endl;
114 cout << " Pb au getNumberOfVertexes() " << endl;
115 cout << "---------------------------------------" << endl;
116 return EXIT_FAILURE ;
121 cout << "Nb de Noeuds : " << tous[i].getNumberOfNodes() << endl;
123 catch ( const std::exception &e )
125 cout << "-------------------------------" << endl;
126 cout << " Pb au getNumberOfNodes() " << endl;
127 cout << "-------------------------------" << endl;
128 MESSAGE( "catched exception : " << e.what() ) ;
129 return EXIT_FAILURE ;
133 cout << "---------------------------------" << endl;
134 cout << " Pb au getNumberOfNodes() " << endl;
135 cout << "---------------------------------" << endl;
136 return EXIT_FAILURE ;
142 dimension=tous[i].getDimension();
143 cout << "Dimension : " << dimension << endl;
145 catch ( const std::exception &e )
147 cout << "-------------------------------" << endl;
148 cout << " Pb au getDimension() " << endl;
149 cout << "-------------------------------" << endl;
150 MESSAGE( "catched exception : " << e.what() ) ;
151 return EXIT_FAILURE ;
155 cout << "-------------------------------" << endl;
156 cout << " Pb au getDimension() " << endl;
157 cout << "-------------------------------" << endl;
158 return EXIT_FAILURE ;
161 for (int dim=1; dim< dimension; dim++)
163 int dim2=dimension - dim;
164 cout << "Nb d elements de dimension " << dim << " : ";
168 cout << tous[i].getNumberOfConstituents(dim)<< endl;
170 catch ( const std::exception &e )
172 cout << "------------------------------------" << endl;
173 cout << " Pb au getNumberOfConstituents() " << endl;
174 cout << "------------------------------------" << endl;
175 MESSAGE( "catched exception : " << e.what() ) ;
176 return EXIT_FAILURE ;
180 cout << "------------------------------------" << endl;
181 cout << " Pb au getNumberOfConstituents() " << endl;
182 cout << "------------------------------------" << endl;
183 return EXIT_FAILURE ;
190 int** v1=tous[i].getConstituents(dim2);
191 if ( v1.size() != tous[i].getNumberOfConstituents(dim2) )
193 cout << "----------------------------" << endl;
194 cout << " Pb au getConstituents() " << endl;
195 cout << "----------------------------" << endl;
198 catch ( const std::exception &e )
200 cout << "-------------------------------" << endl;
201 cout << " Pb au getConstituents() " << endl;
202 cout << "-------------------------------" << endl;
203 MESSAGE( "catched exception : " << e.what() ) ;
204 return EXIT_FAILURE ;
208 cout << "----------------------------" << endl;
209 cout << " Pb au getConstituents() " << endl;
210 cout << "----------------------------" << endl;
211 return EXIT_FAILURE ;
214 cout << "Types de ces elements " << endl;
216 set <medGeometryElement> setGeomElt;
217 medGeometryElement * vt;
221 vt=tous[i].getConstituentsType(dim2);
222 taille=tous[i].getNumberOfConstituents(dim2);
224 catch ( const std::exception &e )
226 cout << "-------------------------------" << endl;
227 cout << " Pb au getConstituentsType() " << endl;
228 cout << "-------------------------------" << endl;
229 MESSAGE( "catched exception : " << e.what() ) ;
230 return EXIT_FAILURE ;
234 cout << "--------------------------------" << endl;
235 cout << " Pb au getConstituentsType() " << endl;
236 cout << "--------------------------------" << endl;
237 return EXIT_FAILURE ;
239 for (int k=0; k<taille;k++)
243 medGeometryElement me=tous[i].getConstituentType(dim2,k+1);
246 cout << "-------------------------------" << endl;
247 cout << " Pb au getConstituentType() " << endl;
248 cout << "-------------------------------" << endl;
250 setGeomElt.insert(me);
252 catch ( const std::exception &e )
254 cout << "-------------------------------" << endl;
255 cout << " Pb au getConstituentType() " << endl;
256 cout << "-------------------------------" << endl;
257 MESSAGE( "catched exception : " << e.what() ) ;
258 return EXIT_FAILURE ;
262 cout << "--------------------------------" << endl;
263 cout << " Pb au getConstituentsType() " << endl;
264 cout << "--------------------------------" << endl;
265 return EXIT_FAILURE ;
270 set <medGeometryElement>::iterator iter_s;
271 for (iter_s=setGeomElt.begin() ;iter_s!=setGeomElt.end();iter_s++)
273 cout << geoNames[(*iter_s)] << endl;
276 cout << "Impression des coordonnées du 1er Element de ce type" << endl;
279 vector<int> v2=tous[i].getNodesConstituent(dim2,1);
280 for (int k=0; k<v2.size();k++)
282 cout << v2[k] << " ";
285 int verif=tous[i].getNodeConstituent(dim2,1,k+1);
288 cout << "-------------------------------" << endl;
289 cout << " Pb au getNodeConstituent() " << endl;
290 cout << "-------------------------------" << endl;
293 catch ( const std::exception &e )
295 cout << "-------------------------------" << endl;
296 cout << " Pb au getNodeConstituent() " << endl;
297 cout << "-------------------------------" << endl;
298 MESSAGE( "catched exception : " << e.what() ) ;
299 return EXIT_FAILURE ;
303 cout << "-------------------------------" << endl;
304 cout << " Pb au getNodeConstituent() " << endl;
305 cout << "-------------------------------" << endl;
306 return EXIT_FAILURE ;
311 catch ( const std::exception &e )
313 cout << "-------------------------------" << endl;
314 cout << " Pb au getNodeConstituent() " << endl;
315 cout << "-------------------------------" << endl;
316 MESSAGE( "catched exception : " << e.what() ) ;
317 return EXIT_FAILURE ;
321 cout << "--------------------------------" << endl;
322 cout << " Pb au getNodeConstituent() " << endl;
323 cout << "--------------------------------" << endl;
324 return EXIT_FAILURE ;
334 cout << "Informations particulieres - dimension " << dimension - 1 << endl;
335 set <medGeometryElement>::iterator iter_s;
336 for (iter_s=tous[i].getAllConstituentsType().begin() ;
337 iter_s!=tous[i].getAllConstituentsType().end();iter_s++)
339 cout << geoNames[*iter_s] << endl;
342 catch ( const std::exception &e )
344 cout << "-------------------------------" << endl;
345 cout << " Pb au getAllConstituentsType() " << endl;
346 cout << "-------------------------------" << endl;
347 MESSAGE( "catched exception : " << e.what() ) ;
348 return EXIT_FAILURE ;
352 cout << "------------------------------------" << endl;
353 cout << " Pb au getAllConstituentsType() " << endl;
354 cout << "------------------------------------" << endl;
355 return EXIT_FAILURE ;
364 return EXIT_SUCCESS ;
367 // Return number of constituents foreach type (which dimension is _dimension-1).
368 map <medGeometryElement,int> getNumberOfConstituentsForeachType() const;