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