Salome HOME
db4f829611840bf71bd44c96e55d872dae77b9ac
[plugins/ghs3dprlplugin.git] / src / GHS3DPRLPlugin / GHS3DPRLPlugin_GHS3DPRL.cxx
1 // Copyright (C) 2007-2021  CEA/DEN, EDF R&D
2 //
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, or (at your option) any later version.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 // ---
21 // File   : GHS3DPRLPlugin_GHS3DPRL.cxx
22 // Author : Christian VAN WAMBEKE (CEA) (from Hexotic plugin Lioka RAZAFINDRAZAKA)
23 // ---
24 //
25 #include "GHS3DPRLPlugin_GHS3DPRL.hxx"
26 #include "GHS3DPRLPlugin_Hypothesis.hxx"
27 #include "MG_TetraHPC_API.hxx"
28
29 #include <SMESHDS_Mesh.hxx>
30 #include <SMESH_Gen.hxx>
31 #include <SMESH_TypeDefs.hxx>
32 #include <SMESH_subMesh.hxx>
33 #include <SMESH_MesherHelper.hxx>
34
35 #include "utilities.h"
36
37 #include <list>
38
39 #include <BRepGProp.hxx>
40 #include <GProp_GProps.hxx>
41 #include <OSD_File.hxx>
42 #include <Standard_ProgramError.hxx>
43 #include <TCollection_AsciiString.hxx>
44 #include <TopExp_Explorer.hxx>
45 #include <TopTools_MapOfShape.hxx>
46 #include <TopoDS.hxx>
47 #include <TopoDS_Edge.hxx>
48 #include <TopoDS_Face.hxx>
49
50 #define GMFVERSION GmfDouble
51 #define GMFDIMENSION 3
52
53 using namespace std;
54
55 static void removeFile( const TCollection_AsciiString& fileName )
56 {
57   try {
58     OSD_File( fileName ).Remove();
59   }
60   catch ( Standard_ProgramError& ) {
61     MESSAGE("Can't remove file: " << fileName.ToCString() << " ; file does not exist or permission denied");
62   }
63 }
64
65 //=============================================================================
66 GHS3DPRLPlugin_GHS3DPRL::GHS3DPRLPlugin_GHS3DPRL(int hypId, SMESH_Gen* gen)
67   : SMESH_3D_Algo(hypId, gen)
68 {
69   MESSAGE("GHS3DPRLPlugin_GHS3DPRL::GHS3DPRLPlugin_GHS3DPRL");
70   _name = "MG-Tetra Parallel";
71   _shapeType = (1 << TopAbs_SHELL) | (1 << TopAbs_SOLID);// 1 bit /shape type
72   _onlyUnaryInput = false; // Compute() will be called on a compound of solids
73   _countSubMesh=0;
74   _nodeRefNumber=0;
75   _compatibleHypothesis.push_back(GHS3DPRLPlugin_Hypothesis::GetHypType());
76   _requireShape=false;
77 }
78
79 //=============================================================================
80 GHS3DPRLPlugin_GHS3DPRL::~GHS3DPRLPlugin_GHS3DPRL()
81 {
82   MESSAGE("GHS3DPRLPlugin_GHS3DPRL::~GHS3DPRLPlugin_GHS3DPRL");
83 }
84
85 //=============================================================================
86 bool GHS3DPRLPlugin_GHS3DPRL::CheckHypothesis
87                          (SMESH_Mesh& aMesh,
88                           const TopoDS_Shape& aShape,
89                           SMESH_Hypothesis::Hypothesis_Status& aStatus)
90 {
91   //MESSAGE("GHS3DPRLPlugin_GHS3DPRL::CheckHypothesis");
92   _hypothesis = NULL;
93
94   list<const SMESHDS_Hypothesis*>::const_iterator itl;
95   const SMESHDS_Hypothesis* theHyp;
96
97   const list<const SMESHDS_Hypothesis*>& hyps = GetUsedHypothesis(aMesh, aShape);
98   int nbHyp = hyps.size();
99   if (!nbHyp)
100   {
101     aStatus = SMESH_Hypothesis::HYP_MISSING;
102     return false;  // can't work with no hypothesis
103   }
104
105   itl = hyps.begin();
106   theHyp = (*itl); // use only the first hypothesis
107
108   string hypName = theHyp->GetName();
109   if (hypName == GHS3DPRLPlugin_Hypothesis::GetHypType())
110   {
111     _hypothesis = static_cast<const GHS3DPRLPlugin_Hypothesis*> (theHyp);
112     ASSERT(_hypothesis);
113     aStatus = SMESH_Hypothesis::HYP_OK;
114   }
115   else
116     aStatus = SMESH_Hypothesis::HYP_INCOMPATIBLE;
117
118   return aStatus == SMESH_Hypothesis::HYP_OK;
119 }
120
121 //=============================================================================
122 // Pass parameters to GHS3DPRL
123 void GHS3DPRLPlugin_GHS3DPRL::SetParameters(const GHS3DPRLPlugin_Hypothesis* hyp)
124 {
125   if (hyp) {
126     MESSAGE("GHS3DPRLPlugin_GHS3DPRL::SetParameters");
127     _MEDName     = hyp->GetMEDName();  //"DOMAIN\0"
128     _NbPart      = hyp->GetNbPart();
129     _KeepFiles   = hyp->GetKeepFiles();
130     _Background  = hyp->GetBackground();
131     _Multithread = hyp->GetMultithread();
132     _Gradation   = hyp->GetGradation();
133     _MinSize     = hyp->GetMinSize();
134     _MaxSize     = hyp->GetMaxSize();
135     _AdvOptions  = hyp->GetAdvancedOption();
136   }
137 }
138
139 //=======================================================================
140 //before launching salome
141 //SALOME_TMP_DIR (for keep tepal intermediates files) could be set in user's directories
142 static TCollection_AsciiString getTmpDir()
143 {
144   TCollection_AsciiString aTmpDir;
145   char *Tmp_dir = getenv("SALOME_TMP_DIR");
146   if (Tmp_dir == NULL) Tmp_dir = getenv("TMP");
147   if(Tmp_dir != NULL)
148   {
149     aTmpDir = Tmp_dir;
150 #ifdef WIN32
151       if(aTmpDir.Value(aTmpDir.Length()) != '\\') aTmpDir+='\\';
152 #else
153       if(aTmpDir.Value(aTmpDir.Length()) != '/') aTmpDir+='/';
154 #endif
155   }
156   else
157   {
158 #ifdef WIN32
159       aTmpDir = TCollection_AsciiString("C:\\");
160 #else
161       aTmpDir = TCollection_AsciiString("/tmp/");
162 #endif
163   }
164   return aTmpDir;
165 }
166
167 //=============================================================================
168 // Write a skin mesh into a GMF file or pass it to MG-TetraHPC API
169 static void exportGMF(MG_TetraHPC_API*    theTetraInput,
170                       const char*         theFile,
171                       const SMESHDS_Mesh* theMeshDS)
172 {
173   int meshID = theTetraInput->GmfOpenMesh( theFile, GmfWrite, GMFVERSION, GMFDIMENSION);
174   
175   // nodes
176   int iN = 0, nbNodes = theMeshDS->NbNodes();
177   theTetraInput->GmfSetKwd( meshID, GmfVertices, nbNodes );
178   std::map< const SMDS_MeshNode*, int, TIDCompare > node2IdMap;
179   SMDS_NodeIteratorPtr nodeIt = theMeshDS->nodesIterator();
180   SMESH_TNodeXYZ n;
181   while ( nodeIt->more() )
182   {
183     n.Set( nodeIt->next() );
184     theTetraInput->GmfSetLin( meshID, GmfVertices, n.X(), n.Y(), n.Z(), n._node->getshapeId() );
185     node2IdMap.insert( node2IdMap.end(), std::make_pair( n._node, ++iN ));
186   }
187
188   // triangles
189   SMDS_ElemIteratorPtr elemIt = theMeshDS->elementGeomIterator( SMDSGeom_TRIANGLE );
190   if ( elemIt->more() )
191   {
192     int nbTria = theMeshDS->GetMeshInfo().NbElements( SMDSGeom_TRIANGLE );
193     theTetraInput->GmfSetKwd(meshID, GmfTriangles, nbTria );
194     for ( int gmfID = 1; elemIt->more(); ++gmfID )
195     {
196       const SMDS_MeshElement* tria = elemIt->next();
197       theTetraInput->GmfSetLin(meshID, GmfTriangles, 
198                               node2IdMap[ tria->GetNode( 0 )],
199                               node2IdMap[ tria->GetNode( 1 )],
200                               node2IdMap[ tria->GetNode( 2 )],
201                               tria->getshapeId() );
202     }
203   }
204   theTetraInput->GmfCloseMesh( meshID );
205 }
206
207 //=============================================================================
208 // Here we are going to use the GHS3DPRL mesher for tetra-hpc (formerly tepal in v3 (2014))
209 bool GHS3DPRLPlugin_GHS3DPRL::Compute(SMESH_Mesh&         theMesh,
210                                       const TopoDS_Shape& /*theShape*/)
211 {
212   SMESH_MesherHelper helper( theMesh );
213   bool ok = Compute( theMesh, &helper );
214   return ok;
215 }
216
217 //=============================================================================
218 // Here we are going to use the GHS3DPRL mesher for tetra-hpc (formerly tepal in v3 (2014))
219 bool GHS3DPRLPlugin_GHS3DPRL::Compute(SMESH_Mesh&         theMesh,
220                                       SMESH_MesherHelper* /*theHelper*/)
221 {
222   bool Ok=false;
223   TCollection_AsciiString pluginerror("ghs3dprl: ");
224   SMESHDS_Mesh* meshDS = theMesh.GetMeshDS();
225   if ( theMesh.NbTriangles() == 0 )
226     return error( COMPERR_BAD_INPUT_MESH, "No triangles in the mesh" );
227
228   if (_hypothesis==NULL){
229     pluginerror += "No existing parameters/hypothesis for GHS3DPRL";
230     cout <<"\n"<<pluginerror<<"\n\n";
231     error(COMPERR_ALGO_FAILED, pluginerror.ToCString() );
232     return false;
233   }
234   SetParameters(_hypothesis);
235   cout << "\n" << _name << " parameters:" << endl;
236   cout << "   generic path/name of MED Files = " << _MEDName << endl;
237   cout << "   number of partitions = " << _NbPart << endl;
238   cout << "   gradation = " << _Gradation << endl;
239   cout << "   min_size = " << _MinSize << endl;
240   cout << "   max_size = " << _MaxSize << endl;
241   cout << "   keep intermediates files (from tetra-hpc) = " << _KeepFiles << endl;
242   cout << "   background (from tetra-hpc) = " << _Background << "\n";
243   cout << "   multithread = " << _Multithread << "\n\n";
244   cout << "   adv. options = '" << _AdvOptions << "'\n\n";
245
246   TCollection_AsciiString
247     tmpDir=getTmpDir(),
248     GHS3DPRL_In,
249     GHS3DPRL_Out,
250     GHS3DPRL_Out_Mesh,
251     GHS3DPRL_Outxml,
252     logFileName,
253     run_GHS3DPRL("tetrahpc2med "),
254     rm("rm -f "),
255     run_nokeep_files,
256     NbPart,
257     Gradation,
258     MinSize,
259     MaxSize,
260     fileskinmed(""),
261     fileskinmesh(""),
262     path,
263     casenamemed;  //_MEDName.c_str());
264   int res = 0;    // 0 is OK 
265
266   casenamemed += (char *)_MEDName.c_str();
267   int n=casenamemed.SearchFromEnd('/');
268   if (n>0) {
269     path=casenamemed.SubString(1,n);
270     casenamemed=casenamemed.SubString(n+1,casenamemed.Length());
271   }
272   else
273     path=tmpDir;
274
275   if (casenamemed.Length()>20){
276     casenamemed=casenamemed.SubString(1,20);
277     cerr<<"MEDName truncated (no more 20 characters) = "<<casenamemed<<endl;
278   }
279
280   map <int,int> aSmdsToGHS3DPRLIdMap;
281   map <int,const SMDS_MeshNode*> aGHS3DPRLIdToNodeMap;
282   _genericName = GHS3DPRLPlugin_Hypothesis::GetFileName(_hypothesis);
283   TCollection_AsciiString aGenericName((char*) _genericName.c_str() );
284   GHS3DPRL_In = aGenericName + ".mesh";
285   GHS3DPRL_Out = path + casenamemed;
286   GHS3DPRL_Out_Mesh = aGenericName + "_out.mesh";
287   GHS3DPRL_Outxml = path + casenamemed + ".xml"; //master file
288   logFileName = aGenericName + ".log"; // MG library output
289   NbPart=_NbPart;
290   Gradation=_Gradation;
291   MinSize=_MinSize;
292   MaxSize=_MaxSize;
293
294   //an example:
295   //tetrahpc2med --casename=/home/whoami/tmp/GHS3DPRL --number=5 --medname=DOMAIN
296   //             --gradation=1.05 --min_size=1e-3 --max_size=1e-2
297   //             --verbose=0 --menu=no --launchtetra=yes;
298
299   run_GHS3DPRL = run_GHS3DPRL +
300     " --casename=" + aGenericName +
301     " --number=" + NbPart +
302     " --medname=" + GHS3DPRL_Out +
303     " --launchtetra=yes" +
304     " --gradation=" + Gradation +
305     " --min_size=" + MinSize +
306     " --max_size=" + MaxSize +
307     " --verbose=3" +
308     " " + _AdvOptions.c_str();
309   if (_Background) run_GHS3DPRL += " --background=yes"; else run_GHS3DPRL += " --background=no";
310   if (_Multithread) run_GHS3DPRL += " --multithread=yes"; else run_GHS3DPRL += " --multithread=no";
311   run_nokeep_files = rm +GHS3DPRL_In + "* " + path + "tetrahpc.log";
312   system( run_nokeep_files.ToCString() ); //clean files
313   run_nokeep_files = rm + GHS3DPRL_In + "* ";
314
315   removeFile( GHS3DPRL_Outxml ); //only the master xml file
316
317   MG_TetraHPC_API mgTetraHPC( _computeCanceled, _progress );
318   bool useLib = ( mgTetraHPC.IsLibrary() && !_Background && _Multithread );
319   if ( !useLib )
320     mgTetraHPC.SetUseExecutable();
321
322   exportGMF( &mgTetraHPC, GHS3DPRL_In.ToCString(), meshDS );
323
324   if ( true /*useLib*/ )
325   {
326     TCollection_AsciiString cmd = TCollection_AsciiString();
327     if (_Multithread)
328       cmd += "mg-tetra_hpc.exe";
329     else
330       cmd = cmd + "mpirun --n " + NbPart + " mg-tetra_hpc_mpi.exe";
331     cmd = cmd + " --in=" + GHS3DPRL_In;
332     if (_Multithread)
333       cmd = cmd +" --max_number_of_threads=" + NbPart;
334     cmd = cmd + " --gradation=" + Gradation;
335     cmd = cmd + " --min_size=" + MinSize;
336     cmd = cmd + " --max_size=" + MaxSize;
337     cmd = cmd + " --verbose=3";
338     cmd = cmd + " --out=" + GHS3DPRL_Out_Mesh;
339     cmd = cmd + " " + _AdvOptions.c_str();
340     cmd = cmd + " 1>" + logFileName;
341
342     cout << endl
343          << "  Run mg-tetra_hpc as library. Creating a mesh file " << GHS3DPRL_Out_Mesh << endl
344          << "  Creating a log file : " << logFileName << endl << endl;
345     mgTetraHPC.SetLogFile( logFileName.ToCString() );
346
347     std::string log;
348     Ok = mgTetraHPC.Compute( cmd.ToCString(), log );
349
350     if (!Ok)
351     {
352       std::cout << "Error: " << std::endl;
353       std::cout << log << std::endl;
354       // try to guess an error from the output log
355       std::string log2 = mgTetraHPC.GetLog();
356       if ( log2.find(" Dlim "   ) != std::string::npos ||
357           log2.find(" license ") != std::string::npos )
358         return error("License problem");
359       std::cout << log2 << std::endl;
360       if ( log2.find("You are using an empty MPI stubs library") != std::string::npos )
361       {
362         std:string msg = "You are using an empty MPI stubs library. Please build it first to be able to use mg-tetra_hpc_mpi.exe.\n";
363         msg += "./salome context\n";
364         msg += "cd $MESHGEMSHOME/stubs\n";
365         msg += "mpicc meshgems_mpi.c -DMESHGEMS_LINUX_BUILD -I../include -shared -fPIC -o $MESHGEMSHOME/lib/Linux_64/libmeshgems_mpi.so";
366         return error(msg);
367       }
368       return error(log);
369     }
370
371     // set --launchtetra=no
372     int yesPos = run_GHS3DPRL.Search("launchtetra") + sizeof("launchtetra");
373     run_GHS3DPRL.SetValue( yesPos+0, 'n' );
374     run_GHS3DPRL.SetValue( yesPos+1, 'o' );
375     run_GHS3DPRL.SetValue( yesPos+2, ' ' );
376   }
377   else
378   {
379     cout<<"  Write input file for mg-tetra_hpc "<<fileskinmesh<<"...";
380     cout<<" ...done\n";
381   }
382   // if mpi, convert meshes to med with xml master file
383   if (!_Multithread)
384   {
385     fileskinmed=path + casenamemed + "_skin.med";
386     cout<<"  Write file "<<fileskinmed<<"...";
387     theMesh.ExportMED(fileskinmed.ToCString(),"SKIN_INITIAL",true);
388     cout<<" ...done\n\n";
389
390     cout<<"GHS3DPRL command :\n  "<<run_GHS3DPRL.ToCString()<<endl;
391     //sometimes it is better to wait flushing files on slow filesystem...
392     system( "sleep 3" );
393     //launch tetrahpc2med which launch mg-tetra_hpc.py which launch mg-tetra_hpc(_mpi?).exe
394     std::cout << "run_GHS3DPRL cmd: " << run_GHS3DPRL << std::endl;
395     res = system( run_GHS3DPRL.ToCString() );
396     if (res > 0)
397     {
398       pluginerror = pluginerror + "PROBLEM tetrahpc2med command";
399       cout<<pluginerror<<endl;
400       error(COMPERR_ALGO_FAILED, pluginerror.ToCString());
401       return false; //but it is not a problem but if true my message is overwritten
402     }
403     system( "sleep 3" );
404
405     if (_Background) {
406       pluginerror = pluginerror + "backgrounding... plugin is not waiting for output files "+ path +casenamemed + "_*.med";
407       cout<<pluginerror<<endl;
408       error(COMPERR_NO_MESH_ON_SHAPE, pluginerror.ToCString());
409       return false; //but it is not a problem but if true my message is overwritten
410       //return true; //but it is not a problem,
411     }
412
413     // read a result, GHS3DPRL_Out is the name of master file (previous xml format)
414     FILE * aResultFile = fopen( GHS3DPRL_Outxml.ToCString(), "r" );
415     if (aResultFile){
416       Ok = true;
417       fclose(aResultFile);
418       cout<<"GHS3DPRL OK output master file "<<casenamemed<<".xml exist !\n\n";
419       pluginerror = pluginerror + "MG-tetra_hpc mesh(es) not loaded in memory, are stored in files "+ path + casenamemed + "_*.med";
420       cout<<pluginerror<<endl;
421       error(COMPERR_WARNING, pluginerror.ToCString() );
422       if (!_KeepFiles) system( run_nokeep_files.ToCString() );
423     }
424     else{
425       Ok = false; //it is a problem AND my message is NOT overwritten
426       pluginerror = pluginerror + "output master file " + casenamemed + ".xml do not exist";
427       cout<<pluginerror<<endl;
428       error(COMPERR_ALGO_FAILED, pluginerror.ToCString() );
429       cout<<"GHS3DPRL KO output files "<<GHS3DPRL_Out<<" do not exist ! see intermediates files keeped:\n";
430       TCollection_AsciiString run_list_files("ls -alt ");
431       run_list_files +=  GHS3DPRL_Out + "* " + GHS3DPRL_In + "* " + logFileName;
432       system( run_list_files.ToCString() );
433       cout<<endl;
434     }
435   }
436   else
437     Ok = true;
438
439   return Ok;
440 }
441
442
443
444 //=============================================================================
445 /*!
446  *
447  */
448 //=============================================================================
449 bool GHS3DPRLPlugin_GHS3DPRL::Evaluate(SMESH_Mesh& aMesh,
450                                        const TopoDS_Shape& aShape,
451                                        MapShapeNbElems& aResMap)
452 {
453   smIdType nbtri = 0, nbqua = 0;
454   double fullArea = 0.0;
455   for (TopExp_Explorer exp(aShape, TopAbs_FACE); exp.More(); exp.Next()) {
456     TopoDS_Face F = TopoDS::Face( exp.Current() );
457     SMESH_subMesh *sm = aMesh.GetSubMesh(F);
458     MapShapeNbElemsItr anIt = aResMap.find(sm);
459     if( anIt==aResMap.end() ) {
460       SMESH_ComputeErrorPtr& smError = sm->GetComputeError();
461       smError.reset( new SMESH_ComputeError(COMPERR_ALGO_FAILED,
462                                             "Submesh can not be evaluated",this));
463       return false;
464     }
465     std::vector<smIdType> aVec = (*anIt).second;
466     nbtri += std::max(aVec[SMDSEntity_Triangle],aVec[SMDSEntity_Quad_Triangle]);
467     nbqua += std::max(aVec[SMDSEntity_Quadrangle],aVec[SMDSEntity_Quad_Quadrangle]);
468     GProp_GProps G;
469     BRepGProp::SurfaceProperties(F,G);
470     double anArea = G.Mass();
471     fullArea += anArea;
472   }
473
474   // collect info from edges
475   smIdType nb0d_e = 0, nb1d_e = 0;
476   bool IsQuadratic = false;
477   bool IsFirst = true;
478   TopTools_MapOfShape tmpMap;
479   for (TopExp_Explorer exp(aShape, TopAbs_EDGE); exp.More(); exp.Next()) {
480     const TopoDS_Edge& E = TopoDS::Edge(exp.Current());
481     if( tmpMap.Contains(E) )
482       continue;
483     tmpMap.Add(E);
484     SMESH_subMesh *aSubMesh = aMesh.GetSubMesh(exp.Current());
485     MapShapeNbElemsItr anIt = aResMap.find(aSubMesh);
486     std::vector<smIdType> aVec = (*anIt).second;
487     nb0d_e += aVec[SMDSEntity_Node];
488     nb1d_e += std::max(aVec[SMDSEntity_Edge],aVec[SMDSEntity_Quad_Edge]);
489     if(IsFirst) {
490       IsQuadratic = (aVec[SMDSEntity_Quad_Edge] > aVec[SMDSEntity_Edge]);
491       IsFirst = false;
492     }
493   }
494   tmpMap.Clear();
495
496   double ELen = sqrt(2.* ( fullArea/(nbtri+nbqua*2) ) / sqrt(3.0) );
497
498   GProp_GProps G;
499   BRepGProp::VolumeProperties(aShape,G);
500   double aVolume = G.Mass();
501   double tetrVol = 0.1179*ELen*ELen*ELen;
502   double CoeffQuality = 0.9;
503   smIdType nbVols = (smIdType)aVolume/tetrVol/CoeffQuality;
504   smIdType nb1d_f = (nbtri*3 + nbqua*4 - nb1d_e) / 2;
505   smIdType nb1d_in = (smIdType) ( nbVols*6 - nb1d_e - nb1d_f ) / 5;
506   std::vector<smIdType> aVec(SMDSEntity_Last);
507   for(smIdType i=0; i<SMDSEntity_Last; i++) aVec[i]=0;
508   if( IsQuadratic ) {
509     aVec[SMDSEntity_Node] = nb1d_in/6 + 1 + nb1d_in;
510     aVec[SMDSEntity_Quad_Tetra] = nbVols - nbqua*2;
511     aVec[SMDSEntity_Quad_Pyramid] = nbqua;
512   }
513   else {
514     aVec[SMDSEntity_Node] = nb1d_in/6 + 1;
515     aVec[SMDSEntity_Tetra] = nbVols - nbqua*2;
516     aVec[SMDSEntity_Pyramid] = nbqua;
517   }
518   SMESH_subMesh *sm = aMesh.GetSubMesh(aShape);
519   aResMap.insert(std::make_pair(sm,aVec));
520
521   return true;
522 }