Salome HOME
1932836d7fce85a3f7d7e94b910392613758a11e
[plugins/ghs3dprlplugin.git] / src / GHS3DPRLPlugin / GHS3DPRLPlugin_GHS3DPRL.cxx
1 // Copyright (C) 2007-2016  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
28 #include <SMDS_MeshElement.hxx>
29 #include <SMDS_MeshNode.hxx>
30 #include <SMESH_subMesh.hxx>
31
32 #include <TopExp_Explorer.hxx>
33 #include <OSD_File.hxx>
34
35 #include "utilities.h"
36
37 #ifndef WIN32
38 #include <sys/sysinfo.h>
39 #endif
40
41 #ifdef _DEBUG_
42 #define DUMP(txt) \
43 //  cout << txt
44 #else
45 #define DUMP(txt)
46 #endif
47
48 #include <SMESH_Gen.hxx>
49 #include <SMESHDS_Mesh.hxx>
50 #include <SMESH_ControlsDef.hxx>
51
52 #include <list>
53 #include <Standard_ProgramError.hxx>
54 #include <TCollection_AsciiString.hxx>
55 #include <TopTools_MapOfShape.hxx>
56 #include <TopoDS.hxx>
57 #include <BRepGProp.hxx>
58 #include <GProp_GProps.hxx>
59
60 using namespace std;
61
62 static void removeFile( const TCollection_AsciiString& fileName )
63 {
64   try {
65     OSD_File( fileName ).Remove();
66   }
67   catch ( Standard_ProgramError ) {
68     MESSAGE("Can't remove file: " << fileName.ToCString() << " ; file does not exist or permission denied");
69   }
70 }
71
72 //=============================================================================
73 GHS3DPRLPlugin_GHS3DPRL::GHS3DPRLPlugin_GHS3DPRL(int hypId, int studyId, SMESH_Gen* gen)
74   : SMESH_3D_Algo(hypId, studyId, gen)
75 {
76   MESSAGE("GHS3DPRLPlugin_GHS3DPRL::GHS3DPRLPlugin_GHS3DPRL");
77   _name = "MG-Tetra Parallel";
78   _shapeType = (1 << TopAbs_SHELL) | (1 << TopAbs_SOLID);// 1 bit /shape type
79   _countSubMesh=0;
80   _nodeRefNumber=0;
81   _compatibleHypothesis.push_back(GHS3DPRLPlugin_Hypothesis::GetHypType());
82 }
83
84 //=============================================================================
85 GHS3DPRLPlugin_GHS3DPRL::~GHS3DPRLPlugin_GHS3DPRL()
86 {
87   MESSAGE("GHS3DPRLPlugin_GHS3DPRL::~GHS3DPRLPlugin_GHS3DPRL");
88 }
89
90 //=============================================================================
91 bool GHS3DPRLPlugin_GHS3DPRL::CheckHypothesis
92                          (SMESH_Mesh& aMesh,
93                           const TopoDS_Shape& aShape,
94                           SMESH_Hypothesis::Hypothesis_Status& aStatus)
95 {
96   //MESSAGE("GHS3DPRLPlugin_GHS3DPRL::CheckHypothesis");
97   _hypothesis = NULL;
98
99   list<const SMESHDS_Hypothesis*>::const_iterator itl;
100   const SMESHDS_Hypothesis* theHyp;
101
102   const list<const SMESHDS_Hypothesis*>& hyps = GetUsedHypothesis(aMesh, aShape);
103   int nbHyp = hyps.size();
104   if (!nbHyp)
105   {
106     aStatus = SMESH_Hypothesis::HYP_OK;
107     return true;  // can work with no hypothesis
108   }
109
110   itl = hyps.begin();
111   theHyp = (*itl); // use only the first hypothesis
112
113   string hypName = theHyp->GetName();
114   if (hypName == GHS3DPRLPlugin_Hypothesis::GetHypType())
115   {
116     _hypothesis = static_cast<const GHS3DPRLPlugin_Hypothesis*> (theHyp);
117     ASSERT(_hypothesis);
118     aStatus = SMESH_Hypothesis::HYP_OK;
119   }
120   else
121     aStatus = SMESH_Hypothesis::HYP_INCOMPATIBLE;
122
123   return aStatus == SMESH_Hypothesis::HYP_OK;
124 }
125
126 //=======================================================================
127 // static bool writeGHS3DPRLFiles (const TCollection_AsciiString &  GHS3DPRL_In,
128 //                                 SMESHDS_Mesh *                   theMesh,
129 //                                 map <int,int> &                  theSmdsToGHS3DPRLIdMap,
130 //                                 map <int,const SMDS_MeshNode*> & theGHS3DPRLIdToNodeMap)
131 // {
132 //    bool Ok;
133 //    int ifam=0;
134 //    TCollection_AsciiString namefile(GHS3DPRL_In);
135 //    namefile+=".points";
136 //    removeFile(namefile);
137 //    ofstream theFile;
138 //    theFile.open(namefile.ToCString(),ios::out);
139 // #ifdef WIN32
140 //    Ok = theFile.is_open();
141 // #else
142 //    Ok=theFile.rdbuf()->is_open();
143 // #endif
144 //    if (!Ok)
145 //    {
146 //       INFOS("Can't write into "<<namefile.ToCString());
147 //       return false;
148 //    }
149 //    cout<<endl<<"writeGHS3DPRLFiles version tetra_hpc v2.1.11 "<<endl;
150 //    cout<<endl<<"Creating GHS3DPRL processed mesh file : "<<namefile<<endl;
151
152 //    int nbVertices=theMesh->NbNodes();
153 //    int nbFaces=theMesh->NbFaces();        //triangles or quadrangles
154 //    const char* space="  ";
155 //    //const int dummyint=1;                  //nrs,nsd,refnum=1 (for wrap)
156
157 //    // Writing SMESH points into GHS3DPRL File.points
158 //    theFile<<nbVertices<<endl;
159
160 //    int aSmdsNodeID=1;
161 //    const SMDS_MeshNode* node_2;
162 //    SMDS_NodeIteratorPtr itOnNode=theMesh->nodesIterator();
163 //    //int ifam=100;//test famille
164 //    theFile.precision(15); theFile.setf(ios::scientific,ios::floatfield);
165 //    //cout<<"set precision 15 on float\n";
166 //    while (itOnNode->more())
167 //    {
168 //       node_2 = itOnNode->next();
169 //       theSmdsToGHS3DPRLIdMap.insert(map <int,int>::value_type(node_2->GetID(),aSmdsNodeID));
170 //       theGHS3DPRLIdToNodeMap.insert(map <int,const SMDS_MeshNode*>::value_type(aSmdsNodeID,node_2));
171 //       theFile<<node_2->X()<<space<<node_2->Y()<<space<<node_2->Z()<<space<<ifam<<endl;
172 //       aSmdsNodeID++;
173 //       //if (aSmdsNodeID==11) ifam++;
174 //    }
175 //    //no specified points;
176 //    theFile.close();
177
178 //    namefile=GHS3DPRL_In+".faces";
179 //    removeFile(namefile);
180 //    theFile.open(namefile.ToCString(),ios::out);
181 // #ifdef WIN32
182 //    Ok=theFile.is_open();
183 // #else
184 //    Ok=theFile.rdbuf()->is_open();
185 // #endif
186 //    if (!Ok)
187 //    {
188 //       INFOS("Can't write into "<<namefile.ToCString());
189 //       return false;
190 //    }
191 //    cout<<endl<<"Creating GHS3DPRL processed mesh file : "<<namefile<<endl;
192
193 //    // Writing SMESH faces into GHS3DPRL File.faces
194 //    theFile<<nbFaces<<" 0"<<endl;   //NB_ELEMS DUMMY_INT
195 //                                    //" 0" is a reserved parameter
196
197 //    const SMDS_MeshElement* aFace;
198 //    map<int,int>::const_iterator itOnSmdsNode;
199 //    SMDS_ElemIteratorPtr itOnFaceNode;
200 //    SMDS_FaceIteratorPtr itOnSmdsFace = theMesh->facesIterator();
201 //    long nbNoTriangles=0;
202 //    int ifaces=0;
203 //    //ifam=300;
204 //    while (itOnSmdsFace->more())
205 //    {
206 //       aFace=itOnSmdsFace->next();
207 //       itOnFaceNode=aFace->nodesIterator();
208 //       const int nbNodes=aFace->NbNodes();
209 //       if (nbNodes!=3) nbNoTriangles++;
210 //       ifaces++;
211 //       theFile<<nbNodes<<space;        // NB_NODES
212 //       while (itOnFaceNode->more())
213 //       {
214 //           aSmdsNodeID=itOnFaceNode->next()->GetID();
215 //           itOnSmdsNode=theSmdsToGHS3DPRLIdMap.find(aSmdsNodeID);
216 //           ASSERT(itOnSmdsNode!=theSmdsToGHS3DPRLIdMap.end());
217 //           theFile<<space<<(*itOnSmdsNode).second; //NODE_1 NODE_2 ...
218 //       }
219 //       //(NB_NODES+1) times: DUMMY_INT
220 //       //if (ifaces==11) ifam++;
221 //       theFile<<space<<ifam;
222 //       for ( int i=1; i<=nbNodes; i++) theFile<<space<<200+i;
223 //       theFile<<endl;
224 //    }
225 //    theFile.close();
226
227 //    cout<<"Processed mesh files created, they contains :\n";
228 //    cout<<"    "<<nbVertices<<" vertices\n";
229 //    if (nbNoTriangles==0)
230 //       cout<<"    "<<nbFaces<<" faces\n\n";
231 //    else
232 //       cout<<"    "<<nbFaces<<" faces with "<<nbNoTriangles<<"faces no triangles\n\n";
233 //    return true;
234 // }
235
236
237 //=======================================================================
238
239 #define GHS3DPRLPlugin_BUFLENGTH 256
240 #define GHS3DPRLPlugin_ReadLine(aPtr,aBuf,aFile,aLineNb) \
241 {  aPtr = fgets( aBuf, GHS3DPRLPlugin_BUFLENGTH - 2, aFile ); aLineNb++; DUMP(endl); }
242
243
244 //=============================================================================
245 // Pass parameters to GHS3DPRL
246 void GHS3DPRLPlugin_GHS3DPRL::SetParameters(const GHS3DPRLPlugin_Hypothesis* hyp)
247 {
248   if (hyp) {
249     MESSAGE("GHS3DPRLPlugin_GHS3DPRL::SetParameters");
250     _MEDName = hyp->GetMEDName();  //"DOMAIN\0"
251     _NbPart = hyp->GetNbPart();
252     _KeepFiles = hyp->GetKeepFiles();
253     _Background = hyp->GetBackground();
254     _Multithread = hyp->GetMultithread();
255     //_ToMergeSubdomains = hyp->GetToMergeSubdomains();
256     _Gradation = hyp->GetGradation();
257     _MinSize = hyp->GetMinSize();
258     _MaxSize = hyp->GetMaxSize();
259   }
260 }
261
262 //=======================================================================
263 //before launching salome
264 //SALOME_TMP_DIR (for keep tepal intermediates files) could be set in user's directories
265 static TCollection_AsciiString getTmpDir()
266 {
267   TCollection_AsciiString aTmpDir;
268   char *Tmp_dir = getenv("SALOME_TMP_DIR");
269   if (Tmp_dir == NULL) Tmp_dir = getenv("TMP");
270   if(Tmp_dir != NULL)
271   {
272     aTmpDir = Tmp_dir;
273 #ifdef WIN32
274       if(aTmpDir.Value(aTmpDir.Length()) != '\\') aTmpDir+='\\';
275 #else
276       if(aTmpDir.Value(aTmpDir.Length()) != '/') aTmpDir+='/';
277 #endif
278   }
279   else
280   {
281 #ifdef WIN32
282       aTmpDir = TCollection_AsciiString("C:\\");
283 #else
284       aTmpDir = TCollection_AsciiString("/tmp/");
285 #endif
286   }
287   return aTmpDir;
288 }
289
290 //=============================================================================
291 // Here we are going to use the GHS3DPRL mesher for tetra-hpc (formerly tepal in v3 (2014))
292 bool GHS3DPRLPlugin_GHS3DPRL::Compute(SMESH_Mesh& theMesh,
293                                      const TopoDS_Shape& theShape)
294 {
295    bool Ok=false;
296    TCollection_AsciiString pluginerror("ghs3dprl: ");
297    SMESHDS_Mesh* meshDS = theMesh.GetMeshDS();
298    //cout<<"GetMeshDS done\n";
299    if (_countSubMesh==0){
300       MESSAGE("GHS3DPRLPlugin_GHS3DPRL::Compute for tetra-hpc");
301       _countTotal=0;
302       TopExp_Explorer expf(meshDS->ShapeToMesh(), TopAbs_SOLID);
303       for ( ; expf.More(); expf.Next() ) _countTotal++;
304    }
305    _countSubMesh++;
306    //cout<<"Compute _countSubMesh "<<_countSubMesh<<endl;
307    //no stuff if multiples submesh, multiple call compute
308    //mesh all in one pass tepal (the last)
309    if (_countSubMesh != _countTotal ) return true;
310
311    //stuff on last call 
312    if (_hypothesis==NULL){
313       pluginerror += "No existing parameters/hypothesis for GHS3DPRL";
314       cout <<"\n"<<pluginerror<<"\n\n";
315       error(COMPERR_ALGO_FAILED, pluginerror.ToCString() );
316       return false;
317    }
318    SetParameters(_hypothesis);
319    cout << "\n" << _name << " parameters:" << endl;
320    cout << "   generic path/name of MED Files = " << _MEDName << endl;
321    cout << "   number of partitions = " << _NbPart << endl;
322    cout << "   gradation = " << _Gradation << endl;
323    cout << "   min_size = " << _MinSize << endl;
324    cout << "   max_size = " << _MaxSize << endl;
325    cout << "   keep intermediates files (from tetra-hpc) = " << _KeepFiles << endl;
326    cout << "   background (from tetra-hpc) = " << _Background << "\n";
327    cout << "   multithread = " << _Multithread << "\n\n";
328
329       //string tmpDir=getTmpDir_new();
330       TCollection_AsciiString
331          tmpDir=getTmpDir(),
332          GHS3DPRL_In,
333          GHS3DPRL_Out,
334          GHS3DPRL_Outxml,
335          run_GHS3DPRL("tetrahpc2med "),
336          rm("rm -f "),
337          run_nokeep_files,
338          NbPart,
339          Gradation,
340          MinSize,
341          MaxSize,
342          fileskinmed(""),
343          fileskinmesh(""),
344          path,
345          casenamemed;  //_MEDName.c_str());
346
347       casenamemed += (char *)_MEDName.c_str();
348       int n=casenamemed.SearchFromEnd('/');
349       if (n>0) {
350          path=casenamemed.SubString(1,n);
351          casenamemed=casenamemed.SubString(n+1,casenamemed.Length()); 
352       }
353       else
354          path=tmpDir;
355
356       if (casenamemed.Length()>20){
357          casenamemed=casenamemed.SubString(1,20);
358          cerr<<"MEDName truncated (no more 20 characters) = "<<casenamemed<<endl;
359       }
360       //cout<<"path="<<path<<endl;
361       //cout<<"casenamemed="<<casenamemed<<endl;
362
363       map <int,int> aSmdsToGHS3DPRLIdMap;
364       map <int,const SMDS_MeshNode*> aGHS3DPRLIdToNodeMap;
365       GHS3DPRL_In = path + "GHS3DPRL";
366       GHS3DPRL_Out = path + casenamemed;
367       GHS3DPRL_Outxml = path + casenamemed + ".xml"; //master file
368       NbPart=_NbPart;
369       Gradation=_Gradation;
370       MinSize=_MinSize;
371       MaxSize=_MaxSize;
372       
373       //an example:
374       //tetrahpc2med --casename=/home/whoami/tmp/GHS3DPRL --number=5 --medname=DOMAIN 
375       //             --gradation=1.05 --min_size=1e-3 --max_size=1e-2
376       //             --verbose=0 --menu=no --launchtetra=yes;
377       
378       run_GHS3DPRL = run_GHS3DPRL +
379                      " --casename=" + GHS3DPRL_In + 
380                      " --number=" + NbPart +
381                      " --medname=" + GHS3DPRL_Out +
382                      " --launchtetra=yes" +
383                      " --gradation=" + Gradation +
384                      " --min_size=" + MinSize +
385                      " --max_size=" + MaxSize +
386                      " --verbose=3";
387       if (_Background) run_GHS3DPRL += " --background=yes"; else run_GHS3DPRL += " --background=no";
388       if (_Multithread) run_GHS3DPRL += " --multithread=yes"; else run_GHS3DPRL += " --multithread=no";
389       run_nokeep_files = rm +GHS3DPRL_In + "* " + path + "tetrahpc.log";
390       system( run_nokeep_files.ToCString() ); //clean files
391       run_nokeep_files = rm + GHS3DPRL_In + "* ";
392
393       cout<<"GHS3DPRL command :\n  "<<run_GHS3DPRL.ToCString()<<endl;
394       fileskinmesh=path + "GHS3DPRL.mesh";
395       cout<<"  Write input file for tetra_hpc.exe "<<fileskinmesh<<"...";
396       GHS3DPRL_Out = path + casenamemed;
397       removeFile( GHS3DPRL_Outxml ); //only the master xml file
398       //Ok=writeGHS3DPRLFiles(GHS3DPRL_In, meshDS, aSmdsToGHS3DPRLIdMap, aGHS3DPRLIdToNodeMap);
399       bool toCreateGroups = false;
400       theMesh.ExportGMF(fileskinmesh.ToCString(), meshDS, toCreateGroups );
401       cout<<" ...done\n";
402       //else {
403       //   cout<<" ...NOT done\n";
404       //   pluginerror = pluginerror + "problem writing input tepal files " + GHS3DPRL_In + ".mesh";
405
406       //Ecriture dans un fichier MED ?v2.? meme si not Ok
407       //create empty file -> avoid warning message
408       //med_idt fid=MEDouvrir((const char *)fileskinmed.ToCString(),MED_CREATION);
409       //med_err ret=MEDfermer(fid);
410       //fileskinmed=fileskinmed + "cp /home/wambeke/empty.med "+ path + "GHS3DPRL_skin.med";
411       //system( fileskinmed.ToCString() );
412       fileskinmed=path + "GHS3DPRL_skin.med";
413       cout<<"  Write file "<<fileskinmed<<"...";
414       theMesh.ExportMED(fileskinmed.ToCString(),"SKIN_INITIAL",true,1);
415       cout<<" ...done\n\n";
416
417
418       //sometimes it is better to wait flushing files on slow filesystem...
419       system( "sleep 3" );
420       //launch tetrahpc2med which launch mg-tetra_hpc.py which launch mg-tetra_hpc(_mpi?).exe
421       system( run_GHS3DPRL.ToCString() );
422       system( "sleep 3" );
423
424       if (_Background) {
425          pluginerror = pluginerror + "backgrounding... plugin is not waiting for output files "+ casenamemed + "_*.med";
426          cout<<pluginerror<<endl;
427          error(COMPERR_ALGO_FAILED, pluginerror.ToCString());
428          return false; //but it is not a problem but if true my message is overwritten
429          //return true; //but it is not a problem, 
430       }
431
432       // read a result, GHS3DPRL_Out is the name of master file (previous xml format)
433       FILE * aResultFile = fopen( GHS3DPRL_Outxml.ToCString(), "r" );
434       if (aResultFile){
435           //Ok = readResult( aResultFile, meshDS, theShape, aGHS3DPRLIdToNodeMap, GHS3DPRL_Out, _nodeRefNumber );
436           Ok = true;
437           Ok = false; //but it is not a problem but if true my message is overwritten
438           fclose(aResultFile);
439           cout<<"GHS3DPRL OK output master file "<<casenamemed<<".xml exist !\n\n";
440           pluginerror = pluginerror + "new tetraedra not in memory, but stored in files "+ casenamemed + "_*.med";
441           cout<<pluginerror<<endl;
442           error(COMPERR_ALGO_FAILED, pluginerror.ToCString());
443           if (!_KeepFiles) system( run_nokeep_files.ToCString() );
444       }
445       else{
446           Ok = false; //it is a problem AND my message is NOT overwritten
447           pluginerror = pluginerror + "output master file " + casenamemed + ".xml do not exist";
448           cout<<pluginerror<<endl;
449           error(COMPERR_ALGO_FAILED, pluginerror.ToCString() );
450           cout<<"GHS3DPRL KO output files "<<GHS3DPRL_Out<<" do not exist ! see intermediates files keeped:\n";
451           TCollection_AsciiString run_list_files("ls -alt ");
452           run_list_files +=  GHS3DPRL_Out + "* " + GHS3DPRL_In + "* " + path + "tetrahpc.log";
453           system( run_list_files.ToCString() );
454           cout<<endl;
455       }
456       _countSubMesh=0;
457
458
459     return Ok;
460 }
461
462
463
464 //=============================================================================
465 /*!
466  *  
467  */
468 //=============================================================================
469 bool GHS3DPRLPlugin_GHS3DPRL::Evaluate(SMESH_Mesh& aMesh,
470                                        const TopoDS_Shape& aShape,
471                                        MapShapeNbElems& aResMap)
472 {
473   int nbtri = 0, nbqua = 0;
474   double fullArea = 0.0;
475   for (TopExp_Explorer exp(aShape, TopAbs_FACE); exp.More(); exp.Next()) {
476     TopoDS_Face F = TopoDS::Face( exp.Current() );
477     SMESH_subMesh *sm = aMesh.GetSubMesh(F);
478     MapShapeNbElemsItr anIt = aResMap.find(sm);
479     if( anIt==aResMap.end() ) {
480       SMESH_ComputeErrorPtr& smError = sm->GetComputeError();
481       smError.reset( new SMESH_ComputeError(COMPERR_ALGO_FAILED,
482                                             "Submesh can not be evaluated",this));
483       return false;
484     }
485     std::vector<int> aVec = (*anIt).second;
486     nbtri += Max(aVec[SMDSEntity_Triangle],aVec[SMDSEntity_Quad_Triangle]);
487     nbqua += Max(aVec[SMDSEntity_Quadrangle],aVec[SMDSEntity_Quad_Quadrangle]);
488     GProp_GProps G;
489     BRepGProp::SurfaceProperties(F,G);
490     double anArea = G.Mass();
491     fullArea += anArea;
492   }
493
494   // collect info from edges
495   int nb0d_e = 0, nb1d_e = 0;
496   bool IsQuadratic = false;
497   bool IsFirst = true;
498   TopTools_MapOfShape tmpMap;
499   for (TopExp_Explorer exp(aShape, TopAbs_EDGE); exp.More(); exp.Next()) {
500     TopoDS_Edge E = TopoDS::Edge(exp.Current());
501     if( tmpMap.Contains(E) )
502       continue;
503     tmpMap.Add(E);
504     SMESH_subMesh *aSubMesh = aMesh.GetSubMesh(exp.Current());
505     MapShapeNbElemsItr anIt = aResMap.find(aSubMesh);
506     std::vector<int> aVec = (*anIt).second;
507     nb0d_e += aVec[SMDSEntity_Node];
508     nb1d_e += Max(aVec[SMDSEntity_Edge],aVec[SMDSEntity_Quad_Edge]);
509     if(IsFirst) {
510       IsQuadratic = (aVec[SMDSEntity_Quad_Edge] > aVec[SMDSEntity_Edge]);
511       IsFirst = false;
512     }
513   }
514   tmpMap.Clear();
515
516   double ELen = sqrt(2.* ( fullArea/(nbtri+nbqua*2) ) / sqrt(3.0) );
517
518   GProp_GProps G;
519   BRepGProp::VolumeProperties(aShape,G);
520   double aVolume = G.Mass();
521   double tetrVol = 0.1179*ELen*ELen*ELen;
522   double CoeffQuality = 0.9;
523   int nbVols = (int)aVolume/tetrVol/CoeffQuality;
524   int nb1d_f = (nbtri*3 + nbqua*4 - nb1d_e) / 2;
525   int nb1d_in = (int) ( nbVols*6 - nb1d_e - nb1d_f ) / 5;
526   std::vector<int> aVec(SMDSEntity_Last);
527   for(int i=0; i<SMDSEntity_Last; i++) aVec[i]=0;
528   if( IsQuadratic ) {
529     aVec[SMDSEntity_Node] = nb1d_in/6 + 1 + nb1d_in;
530     aVec[SMDSEntity_Quad_Tetra] = nbVols - nbqua*2;
531     aVec[SMDSEntity_Quad_Pyramid] = nbqua;
532   }
533   else {
534     aVec[SMDSEntity_Node] = nb1d_in/6 + 1;
535     aVec[SMDSEntity_Tetra] = nbVols - nbqua*2;
536     aVec[SMDSEntity_Pyramid] = nbqua;
537   }
538   SMESH_subMesh *sm = aMesh.GetSubMesh(aShape);
539   aResMap.insert(std::make_pair(sm,aVec));
540
541   return true;
542 }