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 "MEDMEM_Utilities.hxx"
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 #define MED_NBR_GEOMETRIE_MAILLE 15
39 void usage(char * name)
41 cout << " " << name << endl;
44 int main (int argc, char ** argv)
47 if (argc < 1) usage(argv[0]);
50 cout << "CELLMODEL Test" << endl ;
51 cout << "--------------" << endl;
53 /* -----------------------------------------------------
54 Construction de tous les types de cellmodel possibles
55 -----------------------------------------------------
58 CELLMODEL * tous =new CELLMODEL[MED_NBR_GEOMETRIE_MAILLE ];
59 const medGeometryElement allCellType[MED_NBR_GEOMETRIE_MAILLE ]=
60 {MED_POINT1, MED_SEG2, MED_SEG3, MED_TRIA3,
61 MED_QUAD4, MED_TRIA6, MED_QUAD8, MED_TETRA4,
62 MED_PYRA5, MED_PENTA6, MED_HEXA8, MED_TETRA10,
63 MED_PYRA13, MED_PENTA15, MED_HEXA20 };
65 for (int i=0; i<MED_NBR_GEOMETRIE_MAILLE ; i++)
67 tous[i]=CELLMODEL(allCellType[i]);
70 /* -----------------------------------------------------
71 Boucle sur tous les types de cellmodel possibles
72 - Chaque Méthode de cellmodel est appelee
73 -----------------------------------------------------
75 for (int i=0; i<MED_NBR_GEOMETRIE_MAILLE ; i++)
78 cout << geoNames[tous[i].getType()] << endl;
79 cout << "__________________" << endl;
83 cout << "CellModel de Nom : " << tous[i].getName() << endl;
85 catch ( const std::exception &e )
87 cout << "-------------------------------" << endl;
88 cout << " Pb au getName() " << endl;
89 cout << "-------------------------------" << endl;
90 MESSAGE( "catched exception : " << e.what() ) ;
95 cout << "-------------------------------" << endl;
96 cout << " Pb au getName() " << endl;
97 cout << "-------------------------------" << endl;
103 cout << "Nb de Vertexes : " << tous[i].getNumberOfVertexes() << endl;
105 catch ( const std::exception &e )
107 cout << "-------------------------------" << endl;
108 cout << " Pb au getNumberOfVertexes() " << endl;
109 cout << "-------------------------------" << endl;
110 MESSAGE( "catched exception : " << e.what() ) ;
111 return EXIT_FAILURE ;
115 cout << "---------------------------------------" << endl;
116 cout << " Pb au getNumberOfVertexes() " << endl;
117 cout << "---------------------------------------" << endl;
118 return EXIT_FAILURE ;
123 cout << "Nb de Noeuds : " << tous[i].getNumberOfNodes() << endl;
125 catch ( const std::exception &e )
127 cout << "-------------------------------" << endl;
128 cout << " Pb au getNumberOfNodes() " << endl;
129 cout << "-------------------------------" << endl;
130 MESSAGE( "catched exception : " << e.what() ) ;
131 return EXIT_FAILURE ;
135 cout << "---------------------------------" << endl;
136 cout << " Pb au getNumberOfNodes() " << endl;
137 cout << "---------------------------------" << endl;
138 return EXIT_FAILURE ;
144 dimension=tous[i].getDimension();
145 cout << "Dimension : " << dimension << endl;
147 catch ( const std::exception &e )
149 cout << "-------------------------------" << endl;
150 cout << " Pb au getDimension() " << endl;
151 cout << "-------------------------------" << endl;
152 MESSAGE( "catched exception : " << e.what() ) ;
153 return EXIT_FAILURE ;
157 cout << "-------------------------------" << endl;
158 cout << " Pb au getDimension() " << endl;
159 cout << "-------------------------------" << endl;
160 return EXIT_FAILURE ;
163 for (int dim=1; dim< dimension; dim++)
165 int dim2=dimension - dim;
166 cout << "Nb d elements de dimension " << dim << " : ";
170 cout << tous[i].getNumberOfConstituents(dim)<< endl;
172 catch ( const std::exception &e )
174 cout << "------------------------------------" << endl;
175 cout << " Pb au getNumberOfConstituents() " << endl;
176 cout << "------------------------------------" << endl;
177 MESSAGE( "catched exception : " << e.what() ) ;
178 return EXIT_FAILURE ;
182 cout << "------------------------------------" << endl;
183 cout << " Pb au getNumberOfConstituents() " << endl;
184 cout << "------------------------------------" << endl;
185 return EXIT_FAILURE ;
192 int** v1=tous[i].getConstituents(dim2);
193 if ( v1.size() != tous[i].getNumberOfConstituents(dim2) )
195 cout << "----------------------------" << endl;
196 cout << " Pb au getConstituents() " << endl;
197 cout << "----------------------------" << endl;
200 catch ( const std::exception &e )
202 cout << "-------------------------------" << endl;
203 cout << " Pb au getConstituents() " << endl;
204 cout << "-------------------------------" << endl;
205 MESSAGE( "catched exception : " << e.what() ) ;
206 return EXIT_FAILURE ;
210 cout << "----------------------------" << endl;
211 cout << " Pb au getConstituents() " << endl;
212 cout << "----------------------------" << endl;
213 return EXIT_FAILURE ;
216 cout << "Types de ces elements " << endl;
218 set <medGeometryElement> setGeomElt;
219 medGeometryElement * vt;
223 vt=tous[i].getConstituentsType(dim2);
224 taille=tous[i].getNumberOfConstituents(dim2);
226 catch ( const std::exception &e )
228 cout << "-------------------------------" << endl;
229 cout << " Pb au getConstituentsType() " << endl;
230 cout << "-------------------------------" << endl;
231 MESSAGE( "catched exception : " << e.what() ) ;
232 return EXIT_FAILURE ;
236 cout << "--------------------------------" << endl;
237 cout << " Pb au getConstituentsType() " << endl;
238 cout << "--------------------------------" << endl;
239 return EXIT_FAILURE ;
241 for (int k=0; k<taille;k++)
245 medGeometryElement me=tous[i].getConstituentType(dim2,k+1);
248 cout << "-------------------------------" << endl;
249 cout << " Pb au getConstituentType() " << endl;
250 cout << "-------------------------------" << endl;
252 setGeomElt.insert(me);
254 catch ( const std::exception &e )
256 cout << "-------------------------------" << endl;
257 cout << " Pb au getConstituentType() " << endl;
258 cout << "-------------------------------" << endl;
259 MESSAGE( "catched exception : " << e.what() ) ;
260 return EXIT_FAILURE ;
264 cout << "--------------------------------" << endl;
265 cout << " Pb au getConstituentsType() " << endl;
266 cout << "--------------------------------" << endl;
267 return EXIT_FAILURE ;
272 set <medGeometryElement>::iterator iter_s;
273 for (iter_s=setGeomElt.begin() ;iter_s!=setGeomElt.end();iter_s++)
275 cout << geoNames[(*iter_s)] << endl;
278 cout << "Impression des coordonnées du 1er Element de ce type" << endl;
281 vector<int> v2=tous[i].getNodesConstituent(dim2,1);
282 for (int k=0; k<v2.size();k++)
284 cout << v2[k] << " ";
287 int verif=tous[i].getNodeConstituent(dim2,1,k+1);
290 cout << "-------------------------------" << endl;
291 cout << " Pb au getNodeConstituent() " << endl;
292 cout << "-------------------------------" << endl;
295 catch ( const std::exception &e )
297 cout << "-------------------------------" << endl;
298 cout << " Pb au getNodeConstituent() " << endl;
299 cout << "-------------------------------" << endl;
300 MESSAGE( "catched exception : " << e.what() ) ;
301 return EXIT_FAILURE ;
305 cout << "-------------------------------" << endl;
306 cout << " Pb au getNodeConstituent() " << endl;
307 cout << "-------------------------------" << endl;
308 return EXIT_FAILURE ;
313 catch ( const std::exception &e )
315 cout << "-------------------------------" << endl;
316 cout << " Pb au getNodeConstituent() " << endl;
317 cout << "-------------------------------" << endl;
318 MESSAGE( "catched exception : " << e.what() ) ;
319 return EXIT_FAILURE ;
323 cout << "--------------------------------" << endl;
324 cout << " Pb au getNodeConstituent() " << endl;
325 cout << "--------------------------------" << endl;
326 return EXIT_FAILURE ;
336 cout << "Informations particulieres - dimension " << dimension - 1 << endl;
337 set <medGeometryElement>::iterator iter_s;
338 for (iter_s=tous[i].getAllConstituentsType().begin() ;
339 iter_s!=tous[i].getAllConstituentsType().end();iter_s++)
341 cout << geoNames[*iter_s] << endl;
344 catch ( const std::exception &e )
346 cout << "-------------------------------" << endl;
347 cout << " Pb au getAllConstituentsType() " << endl;
348 cout << "-------------------------------" << endl;
349 MESSAGE( "catched exception : " << e.what() ) ;
350 return EXIT_FAILURE ;
354 cout << "------------------------------------" << endl;
355 cout << " Pb au getAllConstituentsType() " << endl;
356 cout << "------------------------------------" << endl;
357 return EXIT_FAILURE ;
366 return EXIT_SUCCESS ;
369 // Return number of constituents foreach type (which dimension is _dimension-1).
370 map <medGeometryElement,int> getNumberOfConstituentsForeachType() const;