Salome HOME
#17338 [CEA 17337] NETGEN3D regression - Illegal position in Geomsearch
[plugins/netgenplugin.git] / src / NETGENPlugin / NETGENPlugin_Mesher.cxx
index 6d585e057f8e7d490089e7a7488087d7e74558da..75f3758d6414e4f2140391febe30e04840b01b4d 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2019  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -90,18 +90,14 @@ namespace netgen {
   extern int OCCGenerateMesh (OCCGeometry&, Mesh*&, int, int, char*);
 #endif
   //extern void OCCSetLocalMeshSize(OCCGeometry & geom, Mesh & mesh);
-#if defined(NETGEN_V5) && defined(WIN32)
-  DLL_HEADER 
-#endif
+
+  NETGENPLUGIN_DLL_HEADER
   extern MeshingParameters mparam;
-#if defined(NETGEN_V5) && defined(WIN32)
-  DLL_HEADER 
-#endif
+
+  NETGENPLUGIN_DLL_HEADER
   extern volatile multithreadt multithread;
 
-#if defined(NETGEN_V5) && defined(WIN32)
-  DLL_HEADER 
-#endif
+  NETGENPLUGIN_DLL_HEADER
   extern bool merge_solids;
 
   // values used for occgeo.facemeshstatus
@@ -181,7 +177,7 @@ NETGENPlugin_Mesher::NETGENPlugin_Mesher (SMESH_Mesh*         mesh,
 
 //================================================================================
 /*!
- * Destuctor
+ * Destructor
  */
 //================================================================================
 
@@ -220,6 +216,7 @@ void NETGENPlugin_Mesher::SetSelfPointer( NETGENPlugin_Mesher ** ptr )
 void NETGENPlugin_Mesher::SetDefaultParameters()
 {
   netgen::MeshingParameters& mparams = netgen::mparam;
+  mparams = netgen::MeshingParameters();
   // maximal mesh edge size
   mparams.maxh            = 0;//NETGENPlugin_Hypothesis::GetDefaultMaxSize();
   mparams.minh            = 0;
@@ -285,53 +282,54 @@ void NETGENPlugin_Mesher::SetParameters(const NETGENPlugin_Hypothesis* hyp)
     netgen::MeshingParameters& mparams = netgen::mparam;
     // Initialize global NETGEN parameters:
     // maximal mesh segment size
-    mparams.maxh            = hyp->GetMaxSize();
+    mparams.maxh               = hyp->GetMaxSize();
     // maximal mesh element linear size
-    mparams.minh            = hyp->GetMinSize();
+    mparams.minh               = hyp->GetMinSize();
     // minimal number of segments per edge
-    mparams.segmentsperedge = hyp->GetNbSegPerEdge();
+    mparams.segmentsperedge    = hyp->GetNbSegPerEdge();
     // rate of growth of size between elements
-    mparams.grading         = hyp->GetGrowthRate();
+    mparams.grading            = hyp->GetGrowthRate();
     // safety factor for curvatures (elements per radius)
-    mparams.curvaturesafety = hyp->GetNbSegPerRadius();
+    mparams.curvaturesafety    = hyp->GetNbSegPerRadius();
     // create elements of second order
-    mparams.secondorder     = hyp->GetSecondOrder() ? 1 : 0;
+    mparams.secondorder        = hyp->GetSecondOrder() ? 1 : 0;
     // quad-dominated surface meshing
-    mparams.quad            = hyp->GetQuadAllowed() ? 1 : 0;
-    _optimize               = hyp->GetOptimize();
-    _fineness               = hyp->GetFineness();
-    mparams.uselocalh       = hyp->GetSurfaceCurvature();
-    netgen::merge_solids    = hyp->GetFuseEdges();
-    _chordalError           = hyp->GetChordalErrorEnabled() ? hyp->GetChordalError() : -1.;
-    _simpleHyp              = NULL;
+    mparams.quad               = hyp->GetQuadAllowed() ? 1 : 0;
+    _optimize                  = hyp->GetOptimize();
+    _fineness                  = hyp->GetFineness();
+    mparams.uselocalh          = hyp->GetSurfaceCurvature();
+    netgen::merge_solids       = hyp->GetFuseEdges();
+    _chordalError              = hyp->GetChordalErrorEnabled() ? hyp->GetChordalError() : -1.;
+    mparams.optsteps2d         = _optimize ? hyp->GetNbSurfOptSteps() : 0;
+    mparams.optsteps3d         = _optimize ? hyp->GetNbVolOptSteps()  : 0;
+    mparams.elsizeweight       = hyp->GetElemSizeWeight();
+    mparams.opterrpow          = hyp->GetWorstElemMeasure();
+    mparams.delaunay           = hyp->GetUseDelauney();
+    mparams.checkoverlap       = hyp->GetCheckOverlapping();
+    mparams.checkchartboundary = hyp->GetCheckChartBoundary();
+    _simpleHyp                 = NULL;
     // mesh size file
     mparams.meshsizefilename= hyp->GetMeshSizeFile().empty() ? 0 : hyp->GetMeshSizeFile().c_str();
 
     const NETGENPlugin_Hypothesis::TLocalSize& localSizes = hyp->GetLocalSizesAndEntries();
     if ( !localSizes.empty() )
     {
-      SMESH_Gen_i*              smeshGen_i = SMESH_Gen_i::GetSMESHGen();
-      CORBA::Object_var           anObject = smeshGen_i->GetNS()->Resolve("/myStudyManager");
-      SALOMEDS::StudyManager_var aStudyMgr = SALOMEDS::StudyManager::_narrow(anObject);
-      SALOMEDS::Study_var          myStudy = aStudyMgr->GetStudyByID(hyp->GetStudyId());
-      if ( !myStudy->_is_nil() )
+      SMESH_Gen_i* smeshGen_i = SMESH_Gen_i::GetSMESHGen();
+      NETGENPlugin_Hypothesis::TLocalSize::const_iterator it = localSizes.begin();
+      for ( ; it != localSizes.end() ; it++)
       {
-        NETGENPlugin_Hypothesis::TLocalSize::const_iterator it = localSizes.begin();
-        for ( ; it != localSizes.end() ; it++)
-        {
-          std::string entry = (*it).first;
-          double        val = (*it).second;
-          // --
-          GEOM::GEOM_Object_var aGeomObj;
-          SALOMEDS::SObject_var aSObj = myStudy->FindObjectID( entry.c_str() );
-          if ( !aSObj->_is_nil() ) {
-            CORBA::Object_var obj = aSObj->GetObject();
-            aGeomObj = GEOM::GEOM_Object::_narrow(obj);
-            aSObj->UnRegister();
-          }
-          TopoDS_Shape S = smeshGen_i->GeomObjectToShape( aGeomObj.in() );
-          ::SetLocalSize(S, val);
+        std::string entry = (*it).first;
+        double        val = (*it).second;
+        // --
+        GEOM::GEOM_Object_var aGeomObj;
+        SALOMEDS::SObject_var aSObj = SMESH_Gen_i::getStudyServant()->FindObjectID( entry.c_str() );
+        if ( !aSObj->_is_nil() ) {
+          CORBA::Object_var obj = aSObj->GetObject();
+          aGeomObj = GEOM::GEOM_Object::_narrow(obj);
+          aSObj->UnRegister();
         }
+        TopoDS_Shape S = smeshGen_i->GeomObjectToShape( aGeomObj.in() );
+        ::SetLocalSize(S, val);
       }
     }
   }
@@ -924,7 +922,7 @@ void NETGENPlugin_Mesher::PrepareOCCgeometry(netgen::OCCGeometry&     occgeo,
         if ( shape.ShapeType() != TopAbs_VERTEX )
           shape = subShapes( subShapes.FindIndex( shape ));// shape -> index -> oriented shape
         if ( shape.Orientation() >= TopAbs_INTERNAL )
-          shape.Orientation( TopAbs_FORWARD ); // isuue 0020676
+          shape.Orientation( TopAbs_FORWARD ); // issue 0020676
         switch ( shape.ShapeType() ) {
         case TopAbs_FACE  : occgeo.fmap.Add( shape ); break;
         case TopAbs_EDGE  : occgeo.emap.Add( shape ); break;
@@ -1110,8 +1108,8 @@ bool NETGENPlugin_Mesher::FillNgMesh(netgen::OCCGeometry&           occgeom,
         bool isForwad = ( fOri == eNotSeam.Orientation() || fOri >= TopAbs_INTERNAL );
 
         // get all nodes from connected <edges>
-        const bool isQuad = smDS->IsQuadratic();
-        StdMeshers_FaceSide fSide( face, edges, _mesh, isForwad, isQuad, &helper );
+        const bool skipMedium = netgen::mparam.secondorder;//smDS->IsQuadratic();
+        StdMeshers_FaceSide fSide( face, edges, _mesh, isForwad, skipMedium, &helper );
         const vector<UVPtStruct>& points = fSide.GetUVPtStruct();
         if ( points.empty() )
           return false; // invalid node params?
@@ -1375,9 +1373,11 @@ bool NETGENPlugin_Mesher::FillNgMesh(netgen::OCCGeometry&           occgeom,
           PShapeIteratorPtr solidIt=helper.GetAncestors(geomFace,*sm->GetFather(),TopAbs_SOLID);
           if ( const TopoDS_Shape * solid = solidIt->next() )
             sm = _mesh->GetSubMesh( *solid );
-          SMESH_ComputeErrorPtr& smError = sm->GetComputeError();
-          smError.reset( new SMESH_ComputeError(COMPERR_BAD_INPUT_MESH,"Not triangle sub-mesh"));
-          smError->myBadElements.push_back( f );
+          SMESH_BadInputElements* badElems =
+            new SMESH_BadInputElements( helper.GetMeshDS(), COMPERR_BAD_INPUT_MESH,
+                                        "Not triangle sub-mesh");
+          badElems->add( f );
+          sm->GetComputeError().reset( badElems );
           return false;
         }
 
@@ -1663,7 +1663,7 @@ namespace
   struct TIntVData
   {
     gp_XY uv;        //!< UV in face parametric space
-    int   ngId;      //!< ng id of corrsponding node
+    int   ngId;      //!< ng id of corresponding node
     gp_XY uvClose;   //!< UV of closest boundary node
     int   ngIdClose; //!< ng id of closest boundary node
   };
@@ -1876,6 +1876,7 @@ void NETGENPlugin_Mesher::AddIntVerticesInFaces(const netgen::OCCGeometry&     o
     }
 
   }
+  ngMesh.CalcSurfacesOfNode();
 }
 
 //================================================================================
@@ -1897,7 +1898,7 @@ void NETGENPlugin_Mesher::AddIntVerticesInSolids(const netgen::OCCGeometry&
   ofstream py(DUMP_TRIANGLES_SCRIPT);
   py << "import SMESH"<< endl
      << "from salome.smesh import smeshBuilder"<<endl
-     << "smesh = smeshBuilder.New(salome.myStudy)"<<endl
+     << "smesh = smeshBuilder.New()"<<endl
      << "m = smesh.Mesh(name='triangles')" << endl;
 #endif
   if ((int) nodeVec.size() < ngMesh.GetNP() )
@@ -2402,7 +2403,7 @@ int NETGENPlugin_Mesher::FillSMesh(const netgen::OCCGeometry&          occgeo,
     for ( ngID = i = 1; i < nodeVecSize; ++ngID, ++i )
     {
       gp_Pnt ngPnt( NGPOINT_COORDS( ngMesh.Point( ngID )));
-      gp_Pnt node ( SMESH_NodeXYZ ( nodeVec[ i ]));
+      gp_Pnt node ( SMESH_NodeXYZ (nodeVec_ACCESS(i) ));
       if ( ngPnt.SquareDistance( node ) < eps )
       {
         nodeVec[ ngID ] = nodeVec[ i ];
@@ -3040,8 +3041,9 @@ bool NETGENPlugin_Mesher::Compute()
       }
 
       // Build viscous layers
-      if ( _isViscousLayers2D ||
-           StdMeshers_ViscousLayers2D::HasProxyMesh( TopoDS::Face( occgeo.fmap(1) ), *_mesh ))
+      if (( _isViscousLayers2D ) ||
+          ( !occgeo.fmap.IsEmpty() &&
+            StdMeshers_ViscousLayers2D::HasProxyMesh( TopoDS::Face( occgeo.fmap(1) ), *_mesh )))
       {
         if ( !internals.hasInternalVertexInFace() ) {
           FillSMesh( occgeo, *_ngMesh, initState, *_mesh, nodeVec, comment );
@@ -3213,18 +3215,18 @@ bool NETGENPlugin_Mesher::Compute()
         if(netgen::multithread.terminate)
           return false;
 
-        if ( comment.empty() ) // do not overwrite a previos error
+        if ( comment.empty() ) // do not overwrite a previous error
           comment << text(err);
       }
       catch (Standard_Failure& ex)
       {
-        if ( comment.empty() ) // do not overwrite a previos error
+        if ( comment.empty() ) // do not overwrite a previous error
           comment << text(ex);
         err = 1;
       }
       catch (netgen::NgException exc)
       {
-        if ( comment.empty() ) // do not overwrite a previos error
+        if ( comment.empty() ) // do not overwrite a previous error
           comment << text(exc);
         err = 1;
       }
@@ -3245,17 +3247,17 @@ bool NETGENPlugin_Mesher::Compute()
           if(netgen::multithread.terminate)
             return false;
 
-          if ( comment.empty() ) // do not overwrite a previos error
+          if ( comment.empty() ) // do not overwrite a previous error
             comment << text(err);
         }
         catch (Standard_Failure& ex)
         {
-          if ( comment.empty() ) // do not overwrite a previos error
+          if ( comment.empty() ) // do not overwrite a previous error
             comment << text(ex);
         }
         catch (netgen::NgException exc)
         {
-          if ( comment.empty() ) // do not overwrite a previos error
+          if ( comment.empty() ) // do not overwrite a previous error
             comment << text(exc);
         }
       }
@@ -3272,7 +3274,10 @@ bool NETGENPlugin_Mesher::Compute()
           {
             const netgen::Segment & seg = _ngMesh->LineSegment (i);
             if ( seg.epgeominfo[ 0 ].edgenr == 0 )
+            {
               _ngMesh->DeleteSegment( i );
+              initState._nbSegments--;
+            }
           }
           _ngMesh->Compress();
         }
@@ -3288,12 +3293,12 @@ bool NETGENPlugin_Mesher::Compute()
       }
       catch (Standard_Failure& ex)
       {
-        if ( comment.empty() ) // do not overwrite a previos error
+        if ( comment.empty() ) // do not overwrite a previous error
           comment << "Exception in netgen at passing to 2nd order ";
       }
       catch (netgen::NgException exc)
       {
-        if ( comment.empty() ) // do not overwrite a previos error
+        if ( comment.empty() ) // do not overwrite a previous error
           comment << exc.What();
       }
     }
@@ -3313,12 +3318,22 @@ bool NETGENPlugin_Mesher::Compute()
     FillSMesh( occgeo, *_ngMesh, initState, *_mesh, nodeVec, comment, &quadHelper );
 
     if ( quadHelper.GetIsQuadratic() ) // remove free nodes
+    {
       for ( size_t i = 0; i < nodeVec.size(); ++i )
         if ( nodeVec[i] && nodeVec[i]->NbInverseElements() == 0 )
+        {
           _mesh->GetMeshDS()->RemoveFreeNode( nodeVec[i], 0, /*fromGroups=*/false );
+          nodeVec[i]=0;
+        }
+      for ( size_t i = nodeVec.size()-1; i > 0; --i ) // remove trailing removed nodes
+        if ( !nodeVec[i] )
+          nodeVec.resize( i );
+        else
+          break;
+    }
   }
   SMESH_ComputeErrorPtr readErr = ReadErrors(nodeVec);
-  if ( readErr && !readErr->myBadElements.empty() )
+  if ( readErr && readErr->HasBadElems() )
   {
     error = readErr;
     if ( !comment.empty() && !readErr->myComment.empty() ) comment += "\n";
@@ -3375,14 +3390,15 @@ bool NETGENPlugin_Mesher::Compute()
           SMESH_ComputeErrorPtr& smError = sm->GetComputeError();
           if ( !smComputed && ( !smError || smError->IsOK() ))
           {
-            smError.reset( new SMESH_ComputeError( *error ));
+            smError = error;
             if ( nbVol && SMESH_Algo::GetMeshError( sm ) == SMESH_Algo::MEr_OK )
             {
               smError->myName = COMPERR_WARNING;
             }
-            else if ( !smError->myBadElements.empty() ) // bad surface mesh
+            else if ( smError->HasBadElems() ) // bad surface mesh
             {
-              if ( !hasBadElemOnSolid( smError->myBadElements, sm ))
+              if ( !hasBadElemOnSolid
+                   ( static_cast<SMESH_BadInputElements*>( smError.get() )->myBadElements, sm ))
                 smError.reset();
             }
           }
@@ -3411,9 +3427,8 @@ bool NETGENPlugin_Mesher::Evaluate(MapShapeNbElems& aResMap)
   // Prepare OCC geometry
   // -------------------------
   netgen::OCCGeometry occgeo;
-  list< SMESH_subMesh* > meshedSM[4]; // for 0-3 dimensions
   NETGENPlugin_Internals internals( *_mesh, _shape, _isVolume );
-  PrepareOCCgeometry( occgeo, _shape, *_mesh, meshedSM, &internals );
+  PrepareOCCgeometry( occgeo, _shape, *_mesh, 0, &internals );
 
   bool tooManyElems = false;
   const int hugeNb = std::numeric_limits<int>::max() / 100;
@@ -3561,9 +3576,9 @@ bool NETGENPlugin_Mesher::Evaluate(MapShapeNbElems& aResMap)
     int nb1d = 0;
     if ( !tooManyElems )
     {
-      TopTools_MapOfShape egdes;
+      TopTools_MapOfShape edges;
       for (TopExp_Explorer exp1(F,TopAbs_EDGE); exp1.More(); exp1.Next())
-        if ( egdes.Add( exp1.Current() ))
+        if ( edges.Add( exp1.Current() ))
           nb1d += Edge2NbSeg.Find(exp1.Current());
     }
     int nbFaces = tooManyElems ? hugeNb : int( 4*anArea / (mparams.maxh*mparams.maxh*sqrt(3.)));
@@ -3712,8 +3727,10 @@ double NETGENPlugin_Mesher::GetProgress(const SMESH_Algo* holder,
 SMESH_ComputeErrorPtr
 NETGENPlugin_Mesher::ReadErrors(const vector<const SMDS_MeshNode* >& nodeVec)
 {
-  SMESH_ComputeErrorPtr err = SMESH_ComputeError::New
-    (COMPERR_BAD_INPUT_MESH, "Some edges multiple times in surface mesh");
+  if ( nodeVec.size() < 2 ) return SMESH_ComputeErrorPtr();
+  SMESH_BadInputElements* err =
+    new SMESH_BadInputElements( nodeVec.back()->GetMesh(), COMPERR_BAD_INPUT_MESH,
+                                "Some edges multiple times in surface mesh");
   SMESH_File file("test.out");
   vector<int> two(2);
   vector<int> three1(3), three2(3);
@@ -3773,7 +3790,7 @@ NETGENPlugin_Mesher::ReadErrors(const vector<const SMDS_MeshNode* >& nodeVec)
   if ( nbBadElems ) nbBadElems++; // avoid warning: variable set but not used
 #endif
 
-  return err;
+  return SMESH_ComputeErrorPtr( err );
 }
 
 //================================================================================
@@ -3790,10 +3807,10 @@ void NETGENPlugin_Mesher::toPython( const netgen::Mesh* ngMesh )
   ofstream outfile( pyFile, ios::out );
   if ( !outfile ) return;
 
-  outfile << "import salome, SMESH" << endl
-          << "from salome.smesh import smeshBuilder" << endl
-          << "smesh = smeshBuilder.New(salome.myStudy)" << endl
-          << "mesh = smesh.Mesh()" << endl << endl;
+  outfile << "import salome, SMESH" << std::endl
+          << "from salome.smesh import smeshBuilder" << std::endl
+          << "smesh = smeshBuilder.New()" << std::endl
+          << "mesh = smesh.Mesh()" << std::endl << std::endl;
 
   using namespace netgen;
   PointIndex pi;
@@ -3803,12 +3820,12 @@ void NETGENPlugin_Mesher::toPython( const netgen::Mesh* ngMesh )
     outfile << "mesh.AddNode( ";
     outfile << (*ngMesh)[pi](0) << ", ";
     outfile << (*ngMesh)[pi](1) << ", ";
-    outfile << (*ngMesh)[pi](2) << ") ## "<< pi << endl;
+    outfile << (*ngMesh)[pi](2) << ") ## "<< pi << std::endl;
   }
 
   int nbDom = ngMesh->GetNDomains();
   for ( int i = 0; i < nbDom; ++i )
-    outfile<< "grp" << i+1 << " = mesh.CreateEmptyGroup( SMESH.FACE, 'domain"<< i+1 << "')"<< endl;
+    outfile<< "grp" << i+1 << " = mesh.CreateEmptyGroup( SMESH.FACE, 'domain"<< i+1 << "')"<< std::endl;
 
   SurfaceElementIndex sei;
   for (sei = 0; sei < ngMesh->GetNSE(); sei++)
@@ -3818,14 +3835,14 @@ void NETGENPlugin_Mesher::toPython( const netgen::Mesh* ngMesh )
     for (int j = 0; j < sel.GetNP(); j++)
       outfile << sel[j] << ( j+1 < sel.GetNP() ? ", " : " ])");
     if ( sel.IsDeleted() ) outfile << " ## IsDeleted ";
-    outfile << endl;
+    outfile << std::endl;
 
     if ((*ngMesh)[sei].GetIndex())
     {
       if ( int dom1 = ngMesh->GetFaceDescriptor((*ngMesh)[sei].GetIndex ()).DomainIn())
-        outfile << "grp"<< dom1 <<".Add([ " << (int)sei+1 << " ])" << endl;
+        outfile << "grp"<< dom1 <<".Add([ " << (int)sei+1 << " ])" << std::endl;
       if ( int dom2 = ngMesh->GetFaceDescriptor((*ngMesh)[sei].GetIndex ()).DomainOut())
-        outfile << "grp"<< dom2 <<".Add([ " << (int)sei+1 << " ])" << endl;
+        outfile << "grp"<< dom2 <<".Add([ " << (int)sei+1 << " ])" << std::endl;
     }
   }
 
@@ -3835,7 +3852,7 @@ void NETGENPlugin_Mesher::toPython( const netgen::Mesh* ngMesh )
     outfile << "mesh.AddVolume([ ";
     for (int j = 0; j < el.GetNP(); j++)
       outfile << el[j] << ( j+1 < el.GetNP() ? ", " : " ])");
-    outfile << endl;
+    outfile << std::endl;
   }
 
   for (int i = 1; i <= ngMesh->GetNSeg(); i++)
@@ -3843,9 +3860,9 @@ void NETGENPlugin_Mesher::toPython( const netgen::Mesh* ngMesh )
     const Segment & seg = ngMesh->LineSegment (i);
     outfile << "mesh.AddEdge([ "
             << seg[0] << ", "
-            << seg[1] << " ])" << endl;
+            << seg[1] << " ])" << std::endl;
   }
-  cout << "Write " << pyFile << endl;
+  std::cout << "Write " << pyFile << std::endl;
 }
 
 //================================================================================
@@ -3966,7 +3983,7 @@ NETGENPlugin_Internals::NETGENPlugin_Internals( SMESH_Mesh&         mesh,
       {
         _intShapes.insert( meshDS->ShapeToIndex( f.Current() ));
 
-        // egdes
+        // edges
         list< TopoDS_Shape > edges;
         for ( e.Init( f.Current(), TopAbs_EDGE ); e.More(); e.Next())
           if ( SMESH_MesherHelper::NbAncestors( e.Current(), mesh, TopAbs_FACE ) > 1 )
@@ -4297,7 +4314,7 @@ NETGENPlugin_NetgenLibWrapper::NETGENPlugin_NetgenLibWrapper()
     netgen::myerr   = netgen::mycout;
     _coutBuffer     = std::cout.rdbuf();
 #ifdef _DEBUG_
-    cout << "NOTE: netgen output is redirected to file " << _outputFileName << endl;
+    std::cout << "NOTE: netgen output is redirected to file " << _outputFileName << std::endl;
 #else
     std::cout.rdbuf( netgen::mycout->rdbuf() );
 #endif
@@ -4403,10 +4420,10 @@ void NETGENPlugin_NetgenLibWrapper::removeOutputFile()
     }
     string    tmpDir = SALOMEDS_Tool::GetDirFromPath ( _outputFileName );
     string aFileName = SALOMEDS_Tool::GetNameFromPath( _outputFileName ) + ".out";
-    SALOMEDS::ListOfFileNames_var aFiles = new SALOMEDS::ListOfFileNames;
-    aFiles->length(1);
-    aFiles[0] = aFileName.c_str();
+    SALOMEDS_Tool::ListOfFiles aFiles;
+    aFiles.reserve(1);
+    aFiles.push_back(aFileName.c_str());
 
-    SALOMEDS_Tool::RemoveTemporaryFiles( tmpDir.c_str(), aFiles.in(), true );
+    SALOMEDS_Tool::RemoveTemporaryFiles( tmpDir.c_str(), aFiles, true );
   }
 }