Salome HOME
22483: EDF 2772 SMESH: Define several 3D viscous layer hypotheses on the same Geometry
[plugins/netgenplugin.git] / src / NETGENPlugin / NETGENPlugin_NETGEN_2D_ONLY.cxx
1 // Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
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 // File      : NETGENPlugin_NETGEN_2D_ONLY.cxx
21 // Author    : Edward AGAPOV (OCC)
22 // Project   : SALOME
23 //
24 #include "NETGENPlugin_NETGEN_2D_ONLY.hxx"
25
26 #include "NETGENPlugin_Mesher.hxx"
27 #include "NETGENPlugin_Hypothesis_2D.hxx"
28
29 #include <SMDS_MeshElement.hxx>
30 #include <SMDS_MeshNode.hxx>
31 #include <SMESHDS_Mesh.hxx>
32 #include <SMESH_Comment.hxx>
33 #include <SMESH_Gen.hxx>
34 #include <SMESH_Mesh.hxx>
35 #include <SMESH_MesherHelper.hxx>
36 #include <SMESH_subMesh.hxx>
37 #include <StdMeshers_FaceSide.hxx>
38 #include <StdMeshers_LengthFromEdges.hxx>
39 #include <StdMeshers_MaxElementArea.hxx>
40 #include <StdMeshers_QuadranglePreference.hxx>
41 #include <StdMeshers_ViscousLayers2D.hxx>
42
43 #include <Precision.hxx>
44 #include <Standard_ErrorHandler.hxx>
45 #include <Standard_Failure.hxx>
46
47 #include <utilities.h>
48
49 #include <list>
50 #include <vector>
51 #include <limits>
52
53 /*
54   Netgen include files
55 */
56 namespace nglib {
57 #include <nglib.h>
58 }
59 #ifndef OCCGEOMETRY
60 #define OCCGEOMETRY
61 #endif
62 #include <occgeom.hpp>
63 #include <meshing.hpp>
64 //#include <meshtype.hpp>
65 namespace netgen {
66 #ifdef NETGEN_V5
67   extern int OCCGenerateMesh (OCCGeometry&, Mesh*&, MeshingParameters&, int, int);
68 #else
69   extern int OCCGenerateMesh (OCCGeometry&, Mesh*&, int, int, char*);
70 #endif
71   extern MeshingParameters mparam;
72 }
73
74 using namespace std;
75 using namespace netgen;
76 using namespace nglib;
77
78 //#define DUMP_SEGMENTS
79
80 //=============================================================================
81 /*!
82  *  
83  */
84 //=============================================================================
85
86 NETGENPlugin_NETGEN_2D_ONLY::NETGENPlugin_NETGEN_2D_ONLY(int hypId, int studyId,
87                                                          SMESH_Gen* gen)
88   : SMESH_2D_Algo(hypId, studyId, gen)
89 {
90   MESSAGE("NETGENPlugin_NETGEN_2D_ONLY::NETGENPlugin_NETGEN_2D_ONLY");
91   _name = "NETGEN_2D_ONLY";
92   
93   _shapeType = (1 << TopAbs_FACE);// 1 bit /shape type
94
95   _compatibleHypothesis.push_back("MaxElementArea");
96   _compatibleHypothesis.push_back("LengthFromEdges");
97   _compatibleHypothesis.push_back("QuadranglePreference");
98   _compatibleHypothesis.push_back("NETGEN_Parameters_2D");
99   _compatibleHypothesis.push_back("ViscousLayers2D");
100
101   _hypMaxElementArea = 0;
102   _hypLengthFromEdges = 0;
103   _hypQuadranglePreference = 0;
104   _hypParameters = 0;
105 }
106
107 //=============================================================================
108 /*!
109  *  
110  */
111 //=============================================================================
112
113 NETGENPlugin_NETGEN_2D_ONLY::~NETGENPlugin_NETGEN_2D_ONLY()
114 {
115   MESSAGE("NETGENPlugin_NETGEN_2D_ONLY::~NETGENPlugin_NETGEN_2D_ONLY");
116 }
117
118 //=============================================================================
119 /*!
120  *  
121  */
122 //=============================================================================
123
124 bool NETGENPlugin_NETGEN_2D_ONLY::CheckHypothesis (SMESH_Mesh&         aMesh,
125                                                    const TopoDS_Shape& aShape,
126                                                    Hypothesis_Status&  aStatus)
127 {
128   _hypMaxElementArea = 0;
129   _hypLengthFromEdges = 0;
130   _hypQuadranglePreference = 0;
131   _hypParameters = 0;
132   _progressByTic = -1;
133
134   const list<const SMESHDS_Hypothesis*>& hyps = GetUsedHypothesis(aMesh, aShape, false);
135
136   if (hyps.empty())
137   {
138     aStatus = HYP_OK; //SMESH_Hypothesis::HYP_MISSING;
139     return true;  // (PAL13464) can work with no hypothesis, LengthFromEdges is default one
140   }
141
142   aStatus = HYP_MISSING;
143
144   bool hasVL = false;
145   list<const SMESHDS_Hypothesis*>::const_iterator ith;
146   for (ith = hyps.begin(); ith != hyps.end(); ++ith )
147   {
148     const SMESHDS_Hypothesis* hyp = (*ith);
149
150     string hypName = hyp->GetName();
151
152     if      ( hypName == "MaxElementArea")
153       _hypMaxElementArea = static_cast<const StdMeshers_MaxElementArea*> (hyp);
154     else if ( hypName == "LengthFromEdges" )
155       _hypLengthFromEdges = static_cast<const StdMeshers_LengthFromEdges*> (hyp);
156     else if ( hypName == "QuadranglePreference" )
157       _hypQuadranglePreference = static_cast<const StdMeshers_QuadranglePreference*>(hyp);
158     else if ( hypName == "NETGEN_Parameters_2D" )
159       _hypParameters = static_cast<const NETGENPlugin_Hypothesis_2D*>(hyp);
160     else if ( hypName == StdMeshers_ViscousLayers2D::GetHypType() )
161       hasVL = true;
162     else {
163       aStatus = HYP_INCOMPATIBLE;
164       return false;
165     }
166   }
167
168   int nbHyps = bool(_hypMaxElementArea) + bool(_hypLengthFromEdges) + bool(_hypParameters );
169   if ( nbHyps > 1 )
170     aStatus = HYP_CONCURENT;
171   else if ( hasVL )
172     error( StdMeshers_ViscousLayers2D::CheckHypothesis( aMesh, aShape, aStatus ));
173   else
174     aStatus = HYP_OK;
175
176   return ( aStatus == HYP_OK );
177 }
178
179 //=============================================================================
180 /*!
181  *Here we are going to use the NETGEN mesher
182  */
183 //=============================================================================
184
185 bool NETGENPlugin_NETGEN_2D_ONLY::Compute(SMESH_Mesh&         aMesh,
186                                           const TopoDS_Shape& aShape)
187 {
188   netgen::multithread.terminate = 0;
189   netgen::multithread.task = "Surface meshing";
190
191   SMESHDS_Mesh* meshDS = aMesh.GetMeshDS();
192   int faceID = meshDS->ShapeToIndex( aShape );
193
194   SMESH_MesherHelper helper(aMesh);
195   _quadraticMesh = helper.IsQuadraticSubMesh(aShape);
196   helper.SetElementsOnShape( true );
197   const bool ignoreMediumNodes = _quadraticMesh;
198
199   // build viscous layers if required
200   TopoDS_Face F = TopoDS::Face( aShape/*.Oriented( TopAbs_FORWARD )*/);
201   if ( F.Orientation() != TopAbs_FORWARD &&
202        F.Orientation() != TopAbs_REVERSED )
203     F.Orientation( TopAbs_FORWARD ); // avoid pb with TopAbs_INTERNAL
204   SMESH_ProxyMesh::Ptr proxyMesh = StdMeshers_ViscousLayers2D::Compute( aMesh, F );
205   if ( !proxyMesh )
206     return false;
207
208   // ------------------------
209   // get all edges of a face
210   // ------------------------
211   TError problem;
212   TSideVector wires =
213     StdMeshers_FaceSide::GetFaceWires( F, aMesh, ignoreMediumNodes, problem, proxyMesh );
214   if ( problem && !problem->IsOK() )
215     return error( problem );
216   int nbWires = wires.size();
217   if ( nbWires == 0 )
218     return error( "Problem in StdMeshers_FaceSide::GetFaceWires()");
219   if ( wires[0]->NbSegments() < 3 ) // ex: a circle with 2 segments
220     return error(COMPERR_BAD_INPUT_MESH,
221                  SMESH_Comment("Too few segments: ")<<wires[0]->NbSegments());
222
223   // --------------------
224   // compute edge length
225   // --------------------
226
227   NETGENPlugin_Mesher aMesher( &aMesh, aShape, /*isVolume=*/false);
228   netgen::OCCGeometry occgeo;
229   aMesher.PrepareOCCgeometry( occgeo, F, aMesh );
230   occgeo.fmap.Clear(); // face can be reversed, which is wrong in this case (issue 19978)
231   occgeo.fmap.Add( F );
232
233   if ( _hypParameters )
234   {
235     aMesher.SetParameters(_hypParameters);
236   }
237   else
238   {
239     double edgeLength = 0;
240     if (_hypLengthFromEdges /*|| (!_hypLengthFromEdges && !_hypMaxElementArea)*/)
241     {
242       int nbSegments = 0;
243       for ( int iW = 0; iW < nbWires; ++iW )
244       {
245         edgeLength += wires[ iW ]->Length();
246         nbSegments += wires[ iW ]->NbSegments();
247       }
248       if ( nbSegments )
249         edgeLength /= nbSegments;
250     }
251     else if ( _hypMaxElementArea )
252     {
253       double maxArea = _hypMaxElementArea->GetMaxArea();
254       edgeLength = sqrt(2. * maxArea/sqrt(3.0));
255     }
256     else
257     {
258       // set edgeLength by a longest segment
259       double maxSeg2 = 0;
260       for ( int iW = 0; iW < nbWires; ++iW )
261       {
262         const UVPtStructVec& points = wires[ iW ]->GetUVPtStruct();
263         gp_Pnt pPrev = SMESH_TNodeXYZ( points[0].node );
264         for ( size_t i = 1; i < points.size(); ++i )
265         {
266           gp_Pnt p = SMESH_TNodeXYZ( points[i].node );
267           maxSeg2 = Max( maxSeg2, p.SquareDistance( pPrev ));
268           pPrev = p;
269         }
270       }
271       edgeLength = sqrt( maxSeg2 ) * 1.05;
272     }
273     if ( edgeLength < DBL_MIN )
274       edgeLength = occgeo.GetBoundingBox().Diam();
275
276     netgen::mparam.maxh = edgeLength;
277     netgen::mparam.minh = aMesher.GetDefaultMinSize( aShape, netgen::mparam.maxh );
278     netgen::mparam.quad = _hypQuadranglePreference ? 1 : 0;
279     netgen::mparam.grading = 0.4; // Moderate fineness by default
280   }
281   occgeo.face_maxh = netgen::mparam.maxh;
282
283   // -------------------------
284   // Make input netgen mesh
285   // -------------------------
286
287   // MESHCONST_ANALYSE step may lead to a failure, so we make an attempt
288   // w/o MESHCONST_ANALYSE at the second loop
289   int err = 1;
290   int iLoop = netgen::mparam.uselocalh ? 0 : 1; // uselocalh depends on 
291   for ( ; iLoop < 2; iLoop++ )
292   {
293     bool isMESHCONST_ANALYSE = false;
294     InitComputeError();
295
296     NETGENPlugin_NetgenLibWrapper ngLib;
297     netgen::Mesh * ngMesh = (netgen::Mesh*) ngLib._ngMesh;
298     ngLib._isComputeOk = false;
299
300 #ifndef NETGEN_V5
301     char *optstr = 0;
302 #endif
303     int startWith = MESHCONST_ANALYSE;
304     int endWith   = MESHCONST_ANALYSE;
305
306     if ( !_hypLengthFromEdges && !_hypMaxElementArea && iLoop == 0 )
307     {
308       isMESHCONST_ANALYSE = true;
309 #ifdef NETGEN_V5
310       err = netgen::OCCGenerateMesh(occgeo, ngMesh, netgen::mparam, startWith, endWith);
311 #else
312       err = netgen::OCCGenerateMesh(occgeo, ngMesh, startWith, endWith, optstr);
313 #endif
314       ngLib._ngMesh = 0;
315       ngLib.setMesh(( nglib::Ng_Mesh*) ngMesh );
316     }
317     else
318     {
319       Box<3> bb = occgeo.GetBoundingBox();
320       bb.Increase (bb.Diam()/10);
321       ngMesh->SetLocalH (bb.PMin(), bb.PMax(), netgen::mparam.grading);
322       ngMesh->SetGlobalH (netgen::mparam.maxh);
323     }
324     //cerr << "max " << netgen::mparam.maxh << " min " << netgen::mparam.minh << endl;
325
326     vector< const SMDS_MeshNode* > nodeVec;
327     problem = aMesher.AddSegmentsToMesh( *ngMesh, occgeo, wires, helper, nodeVec );
328     if ( problem && !problem->IsOK() )
329       return error( problem );
330
331     if ( iLoop == 0 )
332     {
333       // limit element size near existing segments
334       TopTools_IndexedMapOfShape edgeMap;
335       PShapeIteratorPtr solidIt = helper.GetAncestors( F, aMesh, TopAbs_SOLID );
336       while ( const TopoDS_Shape* solid = solidIt->next() )
337       {
338         TopExp_Explorer eExp( *solid, TopAbs_EDGE );
339         for ( ; eExp.More(); eExp.Next() )
340         {
341           const TopoDS_Shape& edge = eExp.Current();
342           if (( SMESH_Algo::isDegenerated( TopoDS::Edge( edge ))) ||
343               ( helper.IsSubShape( edge, aShape )) ||
344               ( !edgeMap.Add( edge )))
345             continue;
346           SMESHDS_SubMesh* smDS = aMesh.GetMeshDS()->MeshElements( edge );
347           if ( !smDS ) continue;
348           SMDS_ElemIteratorPtr segIt = smDS->GetElements();
349           while ( segIt->more() )
350           {
351             const SMDS_MeshElement* seg = segIt->next();
352             SMESH_TNodeXYZ n1 = seg->GetNode(0);
353             SMESH_TNodeXYZ n2 = seg->GetNode(1);
354             gp_XYZ p = 0.5 * ( n1 + n2 );
355             netgen::Point3d pi(p.X(), p.Y(), p.Z());
356             ngMesh->RestrictLocalH( pi, Max(( n1 - n2 ).Modulus(), netgen::mparam.minh ));
357           }
358         }
359       }
360     }
361
362     // -------------------------
363     // Generate surface mesh
364     // -------------------------
365
366     startWith = MESHCONST_MESHSURFACE;
367     endWith   = MESHCONST_OPTSURFACE;
368
369     netgen::mparam.uselocalh = true; // needed while optimization
370     try {
371       OCC_CATCH_SIGNALS;
372
373 #ifdef NETGEN_V5
374       err = netgen::OCCGenerateMesh(occgeo, ngMesh, netgen::mparam, startWith, endWith);
375 #else
376       err = netgen::OCCGenerateMesh(occgeo, ngMesh, startWith, endWith, optstr);
377 #endif
378       if(netgen::multithread.terminate)
379         return false;
380       if ( err )
381         error(SMESH_Comment("Error in netgen::OCCGenerateMesh() at ") << netgen::multithread.task);
382     }
383     catch (Standard_Failure& ex)
384     {
385       SMESH_Comment str("Exception in  netgen::OCCGenerateMesh()");
386       str << " at " << netgen::multithread.task
387           << ": " << ex.DynamicType()->Name();
388       if ( ex.GetMessageString() && strlen( ex.GetMessageString() ))
389         str << ": " << ex.GetMessageString();
390       error(str);
391       err = 1;
392     }
393     catch (...) {
394       SMESH_Comment str("Exception in  netgen::OCCGenerateMesh()");
395       str << " at " << netgen::multithread.task;
396       error(str);
397       err = 1;
398     }
399     if ( err /*&& !isMESHCONST_ANALYSE*/ && iLoop == 0 )
400     {
401       netgen::mparam.minh = netgen::mparam.maxh;
402       netgen::mparam.maxh = 0;
403       for ( int iW = 0; iW < wires.size(); ++iW )
404       {
405         StdMeshers_FaceSidePtr wire = wires[ iW ];
406         const vector<UVPtStruct>& uvPtVec = wire->GetUVPtStruct();
407         for ( size_t iP = 1; iP < uvPtVec.size(); ++iP )
408         {
409           SMESH_TNodeXYZ   p( uvPtVec[ iP ].node );
410           netgen::Point3d np( p.X(),p.Y(),p.Z());
411           double segLen = p.Distance( uvPtVec[ iP-1 ].node );
412           double   size = ngMesh->GetH( np );
413           netgen::mparam.minh = Min( netgen::mparam.minh, size );
414           netgen::mparam.maxh = Max( netgen::mparam.maxh, segLen );
415         }
416       }
417       //cerr << "min " << netgen::mparam.minh << " max " << netgen::mparam.maxh << endl;
418       netgen::mparam.minh *= 0.9;
419       netgen::mparam.maxh *= 1.1;
420
421       continue;
422     }
423
424     // ----------------------------------------------------
425     // Fill the SMESHDS with the generated nodes and faces
426     // ----------------------------------------------------
427
428     int nbNodes = ngMesh->GetNP();
429     int nbFaces = ngMesh->GetNSE();
430
431     int nbInputNodes = nodeVec.size()-1;
432     nodeVec.resize( nbNodes+1, 0 );
433
434     // add nodes
435     for ( int ngID = nbInputNodes + 1; ngID <= nbNodes; ++ngID )
436     {
437       const MeshPoint& ngPoint = ngMesh->Point( ngID );
438       SMDS_MeshNode * node = meshDS->AddNode(ngPoint(0), ngPoint(1), ngPoint(2));
439       nodeVec[ ngID ] = node;
440     }
441
442     // create faces
443     const bool reverse = false; //( aShape.Orientation() == TopAbs_REVERSED );
444     int i,j;
445     for ( i = 1; i <= nbFaces ; ++i )
446     {
447       const Element2d& elem = ngMesh->SurfaceElement(i);
448       vector<const SMDS_MeshNode*> nodes( elem.GetNP() );
449       for (j=1; j <= elem.GetNP(); ++j)
450       {
451         int pind = elem.PNum(j);
452         if ( pind < 1 )
453           break;
454         const SMDS_MeshNode* node = nodeVec[ pind ];
455         if ( reverse )
456           nodes[ nodes.size()-j ] = node;
457         else
458           nodes[ j-1 ] = node;
459         if ( node->GetPosition()->GetTypeOfPosition() == SMDS_TOP_3DSPACE )
460         {
461           const PointGeomInfo& pgi = elem.GeomInfoPi(j);
462           meshDS->SetNodeOnFace((SMDS_MeshNode*)node, faceID, pgi.u, pgi.v);
463         }
464       }
465       if ( j > elem.GetNP() )
466       {
467         SMDS_MeshFace* face = 0;
468         if ( elem.GetType() == TRIG )
469           face = helper.AddFace(nodes[0],nodes[1],nodes[2]);
470         else
471           face = helper.AddFace(nodes[0],nodes[1],nodes[2],nodes[3]);
472       }
473     }
474
475     ngLib._isComputeOk = !err;
476     break;
477
478   } // two attempts
479
480   return !err;
481 }
482
483 void NETGENPlugin_NETGEN_2D_ONLY::CancelCompute()
484 {
485   SMESH_Algo::CancelCompute();
486   netgen::multithread.terminate = 1;
487 }
488
489 //================================================================================
490 /*!
491  * \brief Return progress of Compute() [0.,1]
492  */
493 //================================================================================
494
495 double NETGENPlugin_NETGEN_2D_ONLY::GetProgress() const
496 {
497   const char* task1 = "Surface meshing";
498   //const char* task2 = "Optimizing surface";
499   double& progress = const_cast<NETGENPlugin_NETGEN_2D_ONLY*>( this )->_progress;
500   if ( _progressByTic < 0. &&
501        strncmp( netgen::multithread.task, task1, 3 ) == 0 )
502   {
503     progress = Min( 0.25, SMESH_Algo::GetProgressByTic() ); // [0, 0.25]
504   }
505   else //if ( strncmp( netgen::multithread.task, task2, 3 ) == 0)
506   {
507     if ( _progressByTic < 0 )
508     {
509       NETGENPlugin_NETGEN_2D_ONLY* me = (NETGENPlugin_NETGEN_2D_ONLY*) this;
510       me->_progressByTic = 0.25 / (_progressTic+1);
511     }
512     const_cast<NETGENPlugin_NETGEN_2D_ONLY*>( this )->_progressTic++;
513     progress = Max( progress, _progressByTic * _progressTic );
514   }
515   //cout << netgen::multithread.task << " " << _progressTic << endl;
516   return Min( progress, 0.99 );
517 }
518
519 //=============================================================================
520 /*!
521  *
522  */
523 //=============================================================================
524
525 bool NETGENPlugin_NETGEN_2D_ONLY::Evaluate(SMESH_Mesh& aMesh,
526                                            const TopoDS_Shape& aShape,
527                                            MapShapeNbElems& aResMap)
528 {
529   TopoDS_Face F = TopoDS::Face(aShape);
530   if(F.IsNull())
531     return false;
532
533   // collect info from edges
534   int nb0d = 0, nb1d = 0;
535   bool IsQuadratic = false;
536   bool IsFirst = true;
537   double fullLen = 0.0;
538   TopTools_MapOfShape tmpMap;
539   for (TopExp_Explorer exp(F, TopAbs_EDGE); exp.More(); exp.Next()) {
540     TopoDS_Edge E = TopoDS::Edge(exp.Current());
541     if( tmpMap.Contains(E) )
542       continue;
543     tmpMap.Add(E);
544     SMESH_subMesh *aSubMesh = aMesh.GetSubMesh(exp.Current());
545     MapShapeNbElemsItr anIt = aResMap.find(aSubMesh);
546     if( anIt==aResMap.end() ) {
547       SMESH_subMesh *sm = aMesh.GetSubMesh(F);
548       SMESH_ComputeErrorPtr& smError = sm->GetComputeError();
549       smError.reset( new SMESH_ComputeError(COMPERR_ALGO_FAILED,"Submesh can not be evaluated",this));
550       return false;
551     }
552     std::vector<int> aVec = (*anIt).second;
553     nb0d += aVec[SMDSEntity_Node];
554     nb1d += Max(aVec[SMDSEntity_Edge],aVec[SMDSEntity_Quad_Edge]);
555     double aLen = SMESH_Algo::EdgeLength(E);
556     fullLen += aLen;
557     if(IsFirst) {
558       IsQuadratic = (aVec[SMDSEntity_Quad_Edge] > aVec[SMDSEntity_Edge]);
559       IsFirst = false;
560     }
561   }
562   tmpMap.Clear();
563
564   // compute edge length
565   double ELen = 0;
566   if (_hypLengthFromEdges || !_hypLengthFromEdges && !_hypMaxElementArea) {
567     if ( nb1d > 0 )
568       ELen = fullLen / nb1d;
569   }
570   if ( _hypMaxElementArea ) {
571     double maxArea = _hypMaxElementArea->GetMaxArea();
572     ELen = sqrt(2. * maxArea/sqrt(3.0));
573   }
574   GProp_GProps G;
575   BRepGProp::SurfaceProperties(F,G);
576   double anArea = G.Mass();
577
578   const int hugeNb = numeric_limits<int>::max()/10;
579   if ( anArea / hugeNb > ELen*ELen )
580   {
581     SMESH_subMesh *sm = aMesh.GetSubMesh(F);
582     SMESH_ComputeErrorPtr& smError = sm->GetComputeError();
583     smError.reset( new SMESH_ComputeError(COMPERR_ALGO_FAILED,"Submesh can not be evaluated.\nToo small element length",this));
584     return false;
585   }
586   int nbFaces = (int) ( anArea / ( ELen*ELen*sqrt(3.) / 4 ) );
587   int nbNodes = (int) ( ( nbFaces*3 - (nb1d-1)*2 ) / 6 + 1 );
588   std::vector<int> aVec(SMDSEntity_Last);
589   for(int i=SMDSEntity_Node; i<SMDSEntity_Last; i++) aVec[i]=0;
590   if( IsQuadratic ) {
591     aVec[SMDSEntity_Node] = nbNodes;
592     aVec[SMDSEntity_Quad_Triangle] = nbFaces;
593   }
594   else {
595     aVec[SMDSEntity_Node] = nbNodes;
596     aVec[SMDSEntity_Triangle] = nbFaces;
597   }
598   SMESH_subMesh *sm = aMesh.GetSubMesh(F);
599   aResMap.insert(std::make_pair(sm,aVec));
600
601   return true;
602 }