1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File : testUCellModel.cxx
25 #include "MEDMEM_Utilities.hxx"
27 #include "MEDMEM_CellModel.hxx"
28 #include "MEDMEM_define.hxx"
29 #include "MEDMEM_DriversDef.hxx"
32 using namespace MEDMEM;
33 using namespace MED_EN;
35 #define MED_NBR_GEOMETRIE_MAILLE 15
37 static 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_MED( "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_MED( "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_MED( "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_MED( "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 cout << "Nb d elements de dimension " << dim << " : ";
167 cout << tous[i].getNumberOfConstituents(dim)<< endl;
169 catch ( const std::exception &e )
171 cout << "------------------------------------" << endl;
172 cout << " Pb au getNumberOfConstituents() " << endl;
173 cout << "------------------------------------" << endl;
174 MESSAGE_MED( "catched exception : " << e.what() ) ;
175 return EXIT_FAILURE ;
179 cout << "------------------------------------" << endl;
180 cout << " Pb au getNumberOfConstituents() " << endl;
181 cout << "------------------------------------" << endl;
182 return EXIT_FAILURE ;
189 int** v1=tous[i].getConstituents(dim2);
190 if ( v1.size() != tous[i].getNumberOfConstituents(dim2) )
192 cout << "----------------------------" << endl;
193 cout << " Pb au getConstituents() " << endl;
194 cout << "----------------------------" << endl;
197 catch ( const std::exception &e )
199 cout << "-------------------------------" << endl;
200 cout << " Pb au getConstituents() " << endl;
201 cout << "-------------------------------" << endl;
202 MESSAGE_MED( "catched exception : " << e.what() ) ;
203 return EXIT_FAILURE ;
207 cout << "----------------------------" << endl;
208 cout << " Pb au getConstituents() " << endl;
209 cout << "----------------------------" << endl;
210 return EXIT_FAILURE ;
213 cout << "Types de ces elements " << endl;
215 set <medGeometryElement> setGeomElt;
216 medGeometryElement * vt;
220 vt=tous[i].getConstituentsType(dim2);
221 taille=tous[i].getNumberOfConstituents(dim2);
223 catch ( const std::exception &e )
225 cout << "-------------------------------" << endl;
226 cout << " Pb au getConstituentsType() " << endl;
227 cout << "-------------------------------" << endl;
228 MESSAGE_MED( "catched exception : " << e.what() ) ;
229 return EXIT_FAILURE ;
233 cout << "--------------------------------" << endl;
234 cout << " Pb au getConstituentsType() " << endl;
235 cout << "--------------------------------" << endl;
236 return EXIT_FAILURE ;
238 for (int k=0; k<taille;k++)
242 medGeometryElement me=tous[i].getConstituentType(dim2,k+1);
245 cout << "-------------------------------" << endl;
246 cout << " Pb au getConstituentType() " << endl;
247 cout << "-------------------------------" << endl;
249 setGeomElt.insert(me);
251 catch ( const std::exception &e )
253 cout << "-------------------------------" << endl;
254 cout << " Pb au getConstituentType() " << endl;
255 cout << "-------------------------------" << endl;
256 MESSAGE_MED( "catched exception : " << e.what() ) ;
257 return EXIT_FAILURE ;
261 cout << "--------------------------------" << endl;
262 cout << " Pb au getConstituentsType() " << endl;
263 cout << "--------------------------------" << endl;
264 return EXIT_FAILURE ;
269 set <medGeometryElement>::iterator iter_s;
270 for (iter_s=setGeomElt.begin() ;iter_s!=setGeomElt.end();iter_s++)
272 cout << geoNames[(*iter_s)] << endl;
275 cout << "Impression des coordonnées du 1er Element de ce type" << endl;
278 vector<int> v2=tous[i].getNodesConstituent(dim2,1);
279 for (int k=0; k<v2.size();k++)
281 cout << v2[k] << " ";
284 int verif=tous[i].getNodeConstituent(dim2,1,k+1);
287 cout << "-------------------------------" << endl;
288 cout << " Pb au getNodeConstituent() " << endl;
289 cout << "-------------------------------" << endl;
292 catch ( const std::exception &e )
294 cout << "-------------------------------" << endl;
295 cout << " Pb au getNodeConstituent() " << endl;
296 cout << "-------------------------------" << endl;
297 MESSAGE_MED( "catched exception : " << e.what() ) ;
298 return EXIT_FAILURE ;
302 cout << "-------------------------------" << endl;
303 cout << " Pb au getNodeConstituent() " << endl;
304 cout << "-------------------------------" << endl;
305 return EXIT_FAILURE ;
310 catch ( const std::exception &e )
312 cout << "-------------------------------" << endl;
313 cout << " Pb au getNodeConstituent() " << endl;
314 cout << "-------------------------------" << endl;
315 MESSAGE_MED( "catched exception : " << e.what() ) ;
316 return EXIT_FAILURE ;
320 cout << "--------------------------------" << endl;
321 cout << " Pb au getNodeConstituent() " << endl;
322 cout << "--------------------------------" << endl;
323 return EXIT_FAILURE ;
333 cout << "Informations particulieres - dimension " << dimension - 1 << endl;
334 set <medGeometryElement>::iterator iter_s;
335 for (iter_s=tous[i].getAllConstituentsType().begin() ;
336 iter_s!=tous[i].getAllConstituentsType().end();iter_s++)
338 cout << geoNames[*iter_s] << endl;
341 catch ( const std::exception &e )
343 cout << "-------------------------------" << endl;
344 cout << " Pb au getAllConstituentsType() " << endl;
345 cout << "-------------------------------" << endl;
346 MESSAGE_MED( "catched exception : " << e.what() ) ;
347 return EXIT_FAILURE ;
351 cout << "------------------------------------" << endl;
352 cout << " Pb au getAllConstituentsType() " << endl;
353 cout << "------------------------------------" << endl;
354 return EXIT_FAILURE ;
363 return EXIT_SUCCESS ;
366 // Return number of constituents foreach type (which dimension is _dimension-1).
367 map <medGeometryElement,int> getNumberOfConstituentsForeachType() const;