Salome HOME
Show a true reason of failure instead of "mg-tetra.exe: command not found"
authoreap <eap@opencascade.com>
Fri, 29 Jan 2016 12:42:39 +0000 (15:42 +0300)
committereap <eap@opencascade.com>
Fri, 29 Jan 2016 12:42:39 +0000 (15:42 +0300)
src/GHS3DPlugin/GHS3DPlugin_GHS3D.cxx

index afecbfd634cfa40e5af9d0a968b0a2feb017d047..0fc1457cb33f861abed935b261ce886b04019a93 100644 (file)
@@ -79,6 +79,7 @@
 #include <sys/sysinfo.h>
 #endif
 #include <algorithm>
+#include <errno.h>
 
 #define castToNode(n) static_cast<const SMDS_MeshNode *>( n );
 
@@ -220,59 +221,42 @@ TopoDS_Shape GHS3DPlugin_GHS3D::entryToShape(std::string entry)
 //purpose  : 
 //=======================================================================
 
-static TopoDS_Shape findShape(const SMDS_MeshNode *aNode[],
-                              TopoDS_Shape        aShape,
-                              const TopoDS_Shape  shape[],
-                              double**            box,
-                              const int           nShape,
-                              TopAbs_State *      state = 0)
-{
-  gp_XYZ aPnt(0,0,0);
-  int j, iShape, nbNode = 4;
-
-  for ( j=0; j<nbNode; j++ ) {
-    gp_XYZ p ( aNode[j]->X(), aNode[j]->Y(), aNode[j]->Z() );
-    if ( aNode[j]->GetPosition()->GetTypeOfPosition() == SMDS_TOP_3DSPACE ) {
-      aPnt = p;
-      break;
-    }
-    aPnt += p / nbNode;
-  }
-
-  BRepClass3d_SolidClassifier SC (aShape, aPnt, Precision::Confusion());
-  if (state) *state = SC.State();
-  if ( SC.State() != TopAbs_IN || aShape.IsNull() || aShape.ShapeType() != TopAbs_SOLID) {
-    for (iShape = 0; iShape < nShape; iShape++) {
-      aShape = shape[iShape];
-      if ( !( aPnt.X() < box[iShape][0] || box[iShape][1] < aPnt.X() ||
-              aPnt.Y() < box[iShape][2] || box[iShape][3] < aPnt.Y() ||
-              aPnt.Z() < box[iShape][4] || box[iShape][5] < aPnt.Z()) ) {
-        BRepClass3d_SolidClassifier SC (aShape, aPnt, Precision::Confusion());
-        if (state) *state = SC.State();
-        if (SC.State() == TopAbs_IN)
-          break;
-      }
-    }
-  }
-  return aShape;
-}
-
-//=======================================================================
-//function : readMapIntLine
-//purpose  : 
-//=======================================================================
+// static TopoDS_Shape findShape(const SMDS_MeshNode *aNode[],
+//                               TopoDS_Shape        aShape,
+//                               const TopoDS_Shape  shape[],
+//                               double**            box,
+//                               const int           nShape,
+//                               TopAbs_State *      state = 0)
+// {
+//   gp_XYZ aPnt(0,0,0);
+//   int j, iShape, nbNode = 4;
 
-static char* readMapIntLine(char* ptr, int tab[]) {
-  long int intVal;
-  std::cout << std::endl;
+//   for ( j=0; j<nbNode; j++ ) {
+//     gp_XYZ p ( aNode[j]->X(), aNode[j]->Y(), aNode[j]->Z() );
+//     if ( aNode[j]->GetPosition()->GetTypeOfPosition() == SMDS_TOP_3DSPACE ) {
+//       aPnt = p;
+//       break;
+//     }
+//     aPnt += p / nbNode;
+//   }
 
-  for ( int i=0; i<17; i++ ) {
-    intVal = strtol(ptr, &ptr, 10);
-    if ( i < 3 )
-      tab[i] = intVal;
-  }
-  return ptr;
-}
+//   BRepClass3d_SolidClassifier SC (aShape, aPnt, Precision::Confusion());
+//   if (state) *state = SC.State();
+//   if ( SC.State() != TopAbs_IN || aShape.IsNull() || aShape.ShapeType() != TopAbs_SOLID) {
+//     for (iShape = 0; iShape < nShape; iShape++) {
+//       aShape = shape[iShape];
+//       if ( !( aPnt.X() < box[iShape][0] || box[iShape][1] < aPnt.X() ||
+//               aPnt.Y() < box[iShape][2] || box[iShape][3] < aPnt.Y() ||
+//               aPnt.Z() < box[iShape][4] || box[iShape][5] < aPnt.Z()) ) {
+//         BRepClass3d_SolidClassifier SC (aShape, aPnt, Precision::Confusion());
+//         if (state) *state = SC.State();
+//         if (SC.State() == TopAbs_IN)
+//           break;
+//       }
+//     }
+//   }
+//   return aShape;
+// }
 
 //================================================================================
 /*!
@@ -468,521 +452,6 @@ static int findShapeID(SMESH_Mesh&          mesh,
     return meshDS->ShapeToIndex( solids(2) );
 }
 
-// //=======================================================================
-// //function : countShape
-// //purpose  :
-// //=======================================================================
-// 
-// template < class Mesh, class Shape >
-// static int countShape( Mesh* mesh, Shape shape ) {
-//   TopExp_Explorer expShape ( mesh->ShapeToMesh(), shape );
-//   TopTools_MapOfShape mapShape;
-//   int nbShape = 0;
-//   for ( ; expShape.More(); expShape.Next() ) {
-//     if (mapShape.Add(expShape.Current())) {
-//       nbShape++;
-//     }
-//   }
-//   return nbShape;
-// }
-// 
-// //=======================================================================
-// //function : getShape
-// //purpose  :
-// //=======================================================================
-// 
-// template < class Mesh, class Shape, class Tab >
-// void getShape(Mesh* mesh, Shape shape, Tab *t_Shape) {
-//   TopExp_Explorer expShape ( mesh->ShapeToMesh(), shape );
-//   TopTools_MapOfShape mapShape;
-//   for ( int i=0; expShape.More(); expShape.Next() ) {
-//     if (mapShape.Add(expShape.Current())) {
-//       t_Shape[i] = expShape.Current();
-//       i++;
-//     }
-//   }
-//   return;
-// }
-// 
-// // //=======================================================================
-// // //function : findEdgeID
-// // //purpose  :
-// // //=======================================================================
-// 
-// static int findEdgeID(const SMDS_MeshNode* aNode,
-//                       const SMESHDS_Mesh*  theMesh,
-//                       const int            nEdge,
-//                       const TopoDS_Shape*  t_Edge) {
-// 
-//   TopoDS_Shape aPntShape, foundEdge;
-//   TopoDS_Vertex aVertex;
-//   gp_Pnt aPnt( aNode->X(), aNode->Y(), aNode->Z() );
-// 
-//   int foundInd, ind;
-//   double nearest = RealLast(), *t_Dist;
-//   double epsilon = Precision::Confusion();
-// 
-//   t_Dist = new double[ nEdge ];
-//   aPntShape = BRepBuilderAPI_MakeVertex( aPnt ).Shape();
-//   aVertex   = TopoDS::Vertex( aPntShape );
-// 
-//   for ( ind=0; ind < nEdge; ind++ ) {
-//     BRepExtrema_DistShapeShape aDistance ( aVertex, t_Edge[ind] );
-//     t_Dist[ind] = aDistance.Value();
-//     if ( t_Dist[ind] < nearest ) {
-//       nearest   = t_Dist[ind];
-//       foundEdge = t_Edge[ind];
-//       foundInd  = ind;
-//       if ( nearest < epsilon )
-//         ind = nEdge;
-//     }
-//   }
-// 
-//   delete [] t_Dist;
-//   return theMesh->ShapeToIndex( foundEdge );
-// }
-// 
-// 
-// // =======================================================================
-// // function : readGMFFile
-// // purpose  : read GMF file with geometry associated to mesh
-// // =======================================================================
-// 
-// static bool readGMFFile(const int                       fileOpen,
-//                         const char*                     theFileName, 
-//                         SMESH_Mesh&                     theMesh,
-//                         const int                       nbShape,
-//                         const TopoDS_Shape*             tabShape,
-//                         double**                        tabBox,
-//                         map <int,const SMDS_MeshNode*>& theGhs3dIdToNodeMap,
-//                         bool                            toMeshHoles,
-//                         int                             nbEnforcedVertices,
-//                         int                             nbEnforcedNodes)
-// {
-//   TopoDS_Shape aShape;
-//   TopoDS_Vertex aVertex;
-//   SMESHDS_Mesh* theMeshDS = theMesh.GetMeshDS();
-//   int nbElem = 0, nbRef = 0, IdShapeRef = 1;
-//   int *tabID;
-//   int aGMFNodeID = 0;
-//   int compoundID =
-//     nbShape ? theMeshDS->ShapeToIndex( tabShape[0] ) : theMeshDS->ShapeToIndex( theMeshDS->ShapeToMesh() );
-//   int tetraShapeID = compoundID;
-//   double epsilon = Precision::Confusion();
-//   int *nodeAssigne, *GMFNodeAssigne;
-//   SMDS_MeshNode** GMFNode;
-//   TopoDS_Shape *tabCorner, *tabEdge;
-//   std::map <GmfKwdCod,int> tabRef;
-//   
-//   
-//   int ver, dim;
-//   MESSAGE("Read " << theFileName << " file");
-//   int InpMsh = GmfOpenMesh(theFileName, GmfRead, &ver, &dim);
-//   if (!InpMsh)
-//     return false;
-//   
-//   // ===========================
-//   // Fill the tabID array: BEGIN
-//   // ===========================
-//   
-//   /*
-//   The output .mesh file does not contain yet the subdomain-info (Ghs3D 4.2)
-//   */
-//   Kernel_Utils::Localizer loc;
-//   struct stat status;
-//   size_t      length;
-// 
-//   char *ptr, *mapPtr;
-//   char *tetraPtr;
-//   int *tab = new int[3];
-//   
-//   // Read the file state
-//   fstat(fileOpen, &status);
-//   length   = status.st_size;
-//   
-//   // Mapping the result file into memory
-// #ifdef WIN32
-//   HANDLE fd = CreateFile(theFileName, GENERIC_READ, FILE_SHARE_READ,
-//                          NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
-//   HANDLE hMapObject = CreateFileMapping(fd, NULL, PAGE_READONLY,
-//                                         0, (DWORD)length, NULL);
-//   ptr = ( char* ) MapViewOfFile(hMapObject, FILE_MAP_READ, 0, 0, 0 );
-// #else
-//   ptr = (char *) mmap(0,length,PROT_READ,MAP_PRIVATE,fileOpen,0);
-// #endif
-//   mapPtr = ptr;
-// 
-//   ptr      = readMapIntLine(ptr, tab);
-//   tetraPtr = ptr;
-// 
-//   nbElem            = tab[0];
-//   int nbNodes       = tab[1];
-//   
-//   for (int i=0; i < 4*nbElem; i++)
-//     strtol(ptr, &ptr, 10);
-//   
-//   for (int iNode=1; iNode <= nbNodes; iNode++)
-//     for (int iCoor=0; iCoor < 3; iCoor++)
-//       strtod(ptr, &ptr);
-// 
-//     
-//   // Reading the number of triangles which corresponds to the number of sub-domains
-//   int nbTriangle = strtol(ptr, &ptr, 10);
-// 
-//   
-//   // The keyword does not exist yet => to update when it is created
-// //   int nbSubdomains = GmfStatKwd(InpMsh, GmfSubdomain);
-// //   int id_tri[3];
-// 
-// 
-//   tabID = new int[nbTriangle];
-//   for (int i=0; i < nbTriangle; i++) {
-//     tabID[i] = 0;
-//     int nodeId1, nodeId2, nodeId3;
-//     // find the solid corresponding to MG-Tetra sub-domain following
-//     // the technique proposed in MG-Tetra manual in chapter
-//     // "B.4 Subdomain (sub-region) assignment"
-// 
-//     nodeId1 = strtol(ptr, &ptr, 10);
-//     nodeId2 = strtol(ptr, &ptr, 10);
-//     nodeId3 = strtol(ptr, &ptr, 10);
-// 
-// //   // The keyword does not exist yet => to update when it is created
-// //     GmfGetLin(InpMsh, GmfSubdomain, &id_tri[0], &id_tri[1], &id_tri[2]);
-// //     nodeId1 = id_tri[0];
-// //     nodeId2 = id_tri[1];
-// //     nodeId3 = id_tri[2];
-// 
-//     if ( nbTriangle > 1 ) {
-//       // get the nodes indices
-//       const SMDS_MeshNode* n1 = theGhs3dIdToNodeMap[ nodeId1 ];
-//       const SMDS_MeshNode* n2 = theGhs3dIdToNodeMap[ nodeId2 ];
-//       const SMDS_MeshNode* n3 = theGhs3dIdToNodeMap[ nodeId3 ];
-//       try {
-//         OCC_CATCH_SIGNALS;
-//         tabID[i] = findShapeID( theMesh, n1, n2, n3, toMeshHoles );
-//         // -- 0020330: Pb with MG-Tetra as a submesh
-//         // check that found shape is to be meshed
-//         if ( tabID[i] > 0 ) {
-//           const TopoDS_Shape& foundShape = theMeshDS->IndexToShape( tabID[i] );
-//           bool isToBeMeshed = false;
-//           for ( int iS = 0; !isToBeMeshed && iS < nbShape; ++iS )
-//             isToBeMeshed = foundShape.IsSame( tabShape[ iS ]);
-//           if ( !isToBeMeshed )
-//             tabID[i] = HOLE_ID;
-//         }
-//         // END -- 0020330: Pb with MG-Tetra as a submesh
-// #ifdef _DEBUG_
-//         std::cout << i+1 << " subdomain: findShapeID() returns " << tabID[i] << std::endl;
-// #endif
-//       }
-//       catch ( Standard_Failure & ex)
-//       {
-// #ifdef _DEBUG_
-//         std::cout << i+1 << " subdomain: Exception caugt: " << ex.GetMessageString() << std::endl;
-// #endif
-//       }
-//       catch (...) {
-// #ifdef _DEBUG_
-//         std::cout << i+1 << " subdomain: unknown exception caught " << std::endl;
-// #endif
-//       }
-//     }
-//   }
-//   
-//   // ===========================
-//   // Fill the tabID array: END
-//   // ===========================
-//   
-// 
-//   tabRef[GmfVertices]       = 3;
-//   tabRef[GmfCorners]        = 1;
-//   tabRef[GmfEdges]          = 2;
-//   tabRef[GmfRidges]         = 1;
-//   tabRef[GmfTriangles]      = 3;
-// //   tabRef[GmfQuadrilaterals] = 4;
-//   tabRef[GmfTetrahedra]     = 4;
-// //   tabRef[GmfHexahedra]      = 8;
-//   
-//   SMDS_NodeIteratorPtr itOnGMFInputNode = theMeshDS->nodesIterator();
-//   while ( itOnGMFInputNode->more() )
-//     theMeshDS->RemoveNode( itOnGMFInputNode->next() );
-// 
-//   
-//   int nbVertices = GmfStatKwd(InpMsh, GmfVertices);
-//   int nbCorners = max(countShape( theMeshDS, TopAbs_VERTEX ) , GmfStatKwd(InpMsh, GmfCorners));
-//   int nbShapeEdge = countShape( theMeshDS, TopAbs_EDGE );
-// 
-//   tabCorner       = new TopoDS_Shape[ nbCorners ];
-//   tabEdge         = new TopoDS_Shape[ nbShapeEdge ];
-//   nodeAssigne     = new int[ nbVertices + 1 ];
-//   GMFNodeAssigne  = new int[ nbVertices + 1 ];
-//   GMFNode         = new SMDS_MeshNode*[ nbVertices + 1 ];
-// 
-//   getShape(theMeshDS, TopAbs_VERTEX, tabCorner);
-//   getShape(theMeshDS, TopAbs_EDGE,   tabEdge);
-// 
-//   std::map <GmfKwdCod,int>::const_iterator it = tabRef.begin();
-//   for ( ; it != tabRef.end() ; ++it)
-//   {
-// //     int dummy;
-//     GmfKwdCod token = it->first;
-//     nbRef    = it->second;
-// 
-//     nbElem = GmfStatKwd(InpMsh, token);
-//     if (nbElem > 0) {
-//       GmfGotoKwd(InpMsh, token);
-//       std::cout << "Read " << nbElem;
-//     }
-//     else
-//       continue;
-// 
-//     int id[nbElem*tabRef[token]];
-//     int ghs3dShapeID[nbElem];
-// 
-//     if (token == GmfVertices) {
-//       std::cout << " vertices" << std::endl;
-//       int aGMFID;
-// 
-//       float VerTab_f[nbElem][3];
-//       double VerTab_d[nbElem][3];
-//       SMDS_MeshNode * aGMFNode;
-// 
-//       for ( int iElem = 0; iElem < nbElem; iElem++ ) {
-//         aGMFID = iElem + 1;
-//         if (ver == GmfFloat) {
-//           GmfGetLin(InpMsh, token, &VerTab_f[nbElem][0], &VerTab_f[nbElem][1], &VerTab_f[nbElem][2], &ghs3dShapeID[iElem]);
-//           aGMFNode = theMeshDS->AddNode(VerTab_f[nbElem][0], VerTab_f[nbElem][1], VerTab_f[nbElem][2]);
-//         }
-//         else {
-//           GmfGetLin(InpMsh, token, &VerTab_d[nbElem][0], &VerTab_d[nbElem][1], &VerTab_d[nbElem][2], &ghs3dShapeID[iElem]);
-//           aGMFNode = theMeshDS->AddNode(VerTab_d[nbElem][0], VerTab_d[nbElem][1], VerTab_d[nbElem][2]);
-//         }
-//         GMFNode[ aGMFID ] = aGMFNode;
-//         nodeAssigne[ aGMFID ] = 0;
-//         GMFNodeAssigne[ aGMFID ] = 0;
-//       }
-//     }
-//     else if (token == GmfCorners && nbElem > 0) {
-//       std::cout << " corners" << std::endl;
-//       for ( int iElem = 0; iElem < nbElem; iElem++ )
-//         GmfGetLin(InpMsh, token, &id[iElem*tabRef[token]]);
-//     }
-//     else if (token == GmfRidges && nbElem > 0) {
-//       std::cout << " ridges" << std::endl;
-//       for ( int iElem = 0; iElem < nbElem; iElem++ )
-//         GmfGetLin(InpMsh, token, &id[iElem*tabRef[token]]);
-//     }
-//     else if (token == GmfEdges && nbElem > 0) {
-//       std::cout << " edges" << std::endl;
-//       for ( int iElem = 0; iElem < nbElem; iElem++ )
-//         GmfGetLin(InpMsh, token, &id[iElem*tabRef[token]], &id[iElem*tabRef[token]+1], &ghs3dShapeID[iElem]);
-//     }
-//     else if (token == GmfTriangles && nbElem > 0) {
-//       std::cout << " triangles" << std::endl;
-//       for ( int iElem = 0; iElem < nbElem; iElem++ )
-//         GmfGetLin(InpMsh, token, &id[iElem*tabRef[token]], &id[iElem*tabRef[token]+1], &id[iElem*tabRef[token]+2], &ghs3dShapeID[iElem]);
-//     }
-// //     else if (token == GmfQuadrilaterals && nbElem > 0) {
-// //       std::cout << " Quadrilaterals" << std::endl;
-// //       for ( int iElem = 0; iElem < nbElem; iElem++ )
-// //         GmfGetLin(InpMsh, token, &id[iElem*tabRef[token]], &id[iElem*tabRef[token]+1], &id[iElem*tabRef[token]+2], &id[iElem*tabRef[token]+3], &ghs3dShapeID[iElem]);
-// //     }
-//     else if (token == GmfTetrahedra && nbElem > 0) {
-//       std::cout << " Tetrahedra" << std::endl;
-//       for ( int iElem = 0; iElem < nbElem; iElem++ )
-//         GmfGetLin(InpMsh, token, 
-//                   &id[iElem*tabRef[token]], 
-//                   &id[iElem*tabRef[token]+1], 
-//                   &id[iElem*tabRef[token]+2], 
-//                   &id[iElem*tabRef[token]+3], 
-//                   &ghs3dShapeID[iElem]);
-//     }
-// //     else if (token == GmfHexahedra && nbElem > 0) {
-// //       std::cout << " Hexahedra" << std::endl;
-// //       for ( int iElem = 0; iElem < nbElem; iElem++ )
-// //         GmfGetLin(InpMsh, token, &id[iElem*tabRef[token]], &id[iElem*tabRef[token]+1], &id[iElem*tabRef[token]+2], &id[iElem*tabRef[token]+3],
-// //                   &id[iElem*tabRef[token]+4], &id[iElem*tabRef[token]+5], &id[iElem*tabRef[token]+6], &id[iElem*tabRef[token]+7], &ghs3dShapeID[iElem]);
-// //     }
-// 
-//     switch (token) {
-//     case GmfCorners:
-//     case GmfRidges:
-//     case GmfEdges:
-//     case GmfTriangles:
-// //     case GmfQuadrilaterals:
-//     case GmfTetrahedra:
-// //     case GmfHexahedra:
-//     {
-//       int nodeDim, shapeID, *nodeID;
-//       const SMDS_MeshNode** node;
-// //       std::vector< SMDS_MeshNode* > enfNode( nbRef );
-//       SMDS_MeshElement * aGMFElement;
-//       
-//       node    = new const SMDS_MeshNode*[nbRef];
-//       nodeID  = new int[ nbRef ];
-// 
-//       for ( int iElem = 0; iElem < nbElem; iElem++ )
-//       {
-//         for ( int iRef = 0; iRef < nbRef; iRef++ )
-//         {
-//           aGMFNodeID = id[iElem*tabRef[token]+iRef]; // read nbRef aGMFNodeID
-//           node  [ iRef ] = GMFNode[ aGMFNodeID ];
-//           nodeID[ iRef ] = aGMFNodeID;
-//         }
-// 
-//         switch (token)
-//         {
-//         case GmfCorners: {
-//           nodeDim = 1;
-//           gp_Pnt GMFPnt ( node[0]->X(), node[0]->Y(), node[0]->Z() );
-//           for ( int i=0; i<nbElem; i++ ) {
-//             aVertex = TopoDS::Vertex( tabCorner[i] );
-//             gp_Pnt aPnt = BRep_Tool::Pnt( aVertex );
-//             if ( aPnt.Distance( GMFPnt ) < epsilon )
-//               break;
-//           }
-//           break;
-//         }
-//         case GmfEdges: {
-//           nodeDim = 2;
-//           aGMFElement = theMeshDS->AddEdge( node[0], node[1] );
-//           int iNode = 1;
-//           if ( GMFNodeAssigne[ nodeID[0] ] == 0 || GMFNodeAssigne[ nodeID[0] ] == 2 )
-//             iNode = 0;
-//           shapeID = findEdgeID( node[iNode], theMeshDS, nbShapeEdge, tabEdge );
-//           break;
-//         }
-//         case GmfRidges:
-//           break;
-//         case GmfTriangles: {
-//           nodeDim = 3;
-//           aGMFElement = theMeshDS->AddFace( node[0], node[1], node[2]);
-//           shapeID = -1;
-//           break;
-//         }
-// //         case GmfQuadrilaterals: {
-// //           nodeDim = 4;
-// //           aGMFElement = theMeshDS->AddFace( node[0], node[1], node[2], node[3] );
-// //           shapeID = -1;
-// //           break;
-// //         }
-//         case GmfTetrahedra: {
-//           
-//           // IN WORK
-//           TopoDS_Shape aSolid;
-//           // We always run MG-Tetra with "to mesh holes"==TRUE but we must not create
-//           // tetras within holes depending on hypo option,
-//           // so we first check if aTet is inside a hole and then create it 
-//           if ( nbTriangle > 1 ) {
-//             tetraShapeID = HOLE_ID; // negative tetraShapeID means not to create tetras if !toMeshHoles
-//             int aGhs3dShapeID = ghs3dShapeID[iElem] - IdShapeRef;
-//             if ( tabID[ aGhs3dShapeID ] == 0 ) {
-//               TopAbs_State state;
-//               aSolid = findShape(node, aSolid, tabShape, tabBox, nbShape, &state);
-//               if ( toMeshHoles || state == TopAbs_IN )
-//                 tetraShapeID = theMeshDS->ShapeToIndex( aSolid );
-//               tabID[ aGhs3dShapeID ] = tetraShapeID;
-//             }
-//             else
-//               tetraShapeID = tabID[ aGhs3dShapeID ];
-//           }
-//           else if ( nbShape > 1 ) {
-//             // Case where nbTriangle == 1 while nbShape == 2 encountered
-//             // with compound of 2 boxes and "To mesh holes"==False,
-//             // so there are no subdomains specified for each tetrahedron.
-//             // Try to guess a solid by a node already bound to shape
-//             tetraShapeID = 0;
-//             for ( int i=0; i<4 && tetraShapeID==0; i++ ) {
-//               if ( nodeAssigne[ nodeID[i] ] == 1 &&
-//                   node[i]->GetPosition()->GetTypeOfPosition() == SMDS_TOP_3DSPACE &&
-//                   node[i]->getshapeId() > 1 )
-//               {
-//                 tetraShapeID = node[i]->getshapeId();
-//               }
-//             }
-//             if ( tetraShapeID==0 ) {
-//               aSolid = findShape(node, aSolid, tabShape, tabBox, nbShape);
-//               tetraShapeID = theMeshDS->ShapeToIndex( aSolid );
-//             }
-//           }
-//           // set new nodes and tetrahedron onto the shape
-//           for ( int i=0; i<4; i++ ) {
-//             if ( nodeAssigne[ nodeID[i] ] == 0 ) {
-//               if ( tetraShapeID != HOLE_ID )
-//                 theMeshDS->SetNodeInVolume( node[i], tetraShapeID );
-//               nodeAssigne[ nodeID[i] ] = tetraShapeID;
-//             }
-//           }
-//           if ( toMeshHoles || tetraShapeID != HOLE_ID ) {
-//             aGMFElement = theMeshDS->AddVolume( node[1], node[0], node[2], node[3] );
-//             theMeshDS->SetMeshElementOnShape( aGMFElement, tetraShapeID );
-//           }
-//           
-//           // IN WORK
-//           
-//           nodeDim = 5;
-//           break;
-//         }
-// //         case GmfHexahedra: {
-// //           nodeDim = 6;
-// //           aGMFElement = theMeshDS->AddVolume( node[0], node[3], node[2], node[1],
-// //                                             node[4], node[7], node[6], node[5] );
-// //           break;
-// //         }
-//         default: continue;
-//         }
-//         if (token != GmfRidges)
-//         {
-//           for ( int i=0; i<nbRef; i++ ) {
-//               if ( GMFNodeAssigne[ nodeID[i] ] == 0 ) {
-//                 if      ( token == GmfCorners )   theMeshDS->SetNodeOnVertex( node[0], aVertex );
-//                 else if ( token == GmfEdges )     theMeshDS->SetNodeOnEdge( node[i], shapeID );
-//                 else if ( token == GmfTriangles ) theMeshDS->SetNodeOnFace( node[i], shapeID );
-//                 GMFNodeAssigne[ nodeID[i] ] = nodeDim;
-//               }
-//             }
-//             if ( token != "Corners" )
-//               theMeshDS->SetMeshElementOnShape( aGMFElement, shapeID );
-//         }
-//       } // for
-//       
-//       if ( !toMeshHoles ) {
-//         map <int,const SMDS_MeshNode*>::iterator itOnNode = theGhs3dIdToNodeMap.find( nbVertices-(nbEnforcedVertices+nbEnforcedNodes) );
-//         for ( ; itOnNode != theGhs3dIdToNodeMap.end(); ++itOnNode) {
-//           if ( nodeAssigne[ itOnNode->first ] == HOLE_ID )
-//             theMeshDS->RemoveFreeNode( itOnNode->second, 0 );
-//         }
-//       }
-//       
-//       delete [] node;
-//       delete [] nodeID;
-//       break;
-//       } // case GmfTetrahedra
-//     } // switch(token)
-//   } // for
-//   cout << std::endl;
-//   
-// #ifdef WIN32
-//   UnmapViewOfFile(mapPtr);
-//   CloseHandle(hMapObject);
-//   CloseHandle(fd);
-// #else
-//   munmap(mapPtr, length);
-// #endif
-//   close(fileOpen);
-//   
-//   delete [] tabID;
-//   delete [] tabCorner;
-//   delete [] tabEdge;
-//   delete [] nodeAssigne;
-//   delete [] GMFNodeAssigne;
-//   delete [] GMFNode;
-//   
-//   return true;
-// }
-
-
 //=======================================================================
 //function : addElemInMeshGroup
 //purpose  : Update or create groups in mesh
@@ -1218,7 +687,7 @@ static bool readGMFFile(const char*                     theFile,
         GmfGetLin( InpMsh, GmfSubDomainFromGeom,
                    &faceNbNodes, &faceIndex, &orientation, &domainNb);
         solidIDByDomain[ domainNb ] = 1;
-        if ( 0 < faceIndex && faceIndex-1 < theFaceByGhs3dId.size() )
+        if ( 0 < faceIndex && faceIndex-1 < (int)theFaceByGhs3dId.size() )
         {
           const SMDS_MeshElement* face = theFaceByGhs3dId[ faceIndex-1 ];
           const SMDS_MeshNode* nn[3] = { face->GetNode(0),
@@ -1328,7 +797,7 @@ static bool readGMFFile(const char*                     theFile,
           
           aGMFID = iElem -nbInitialNodes +1;
           GMFNode[ aGMFID ] = aGMFNode;
-          if (aGMFID-1 < aNodeGroupByGhs3dId.size() && !aNodeGroupByGhs3dId.at(aGMFID-1).empty())
+          if (aGMFID-1 < (int)aNodeGroupByGhs3dId.size() && !aNodeGroupByGhs3dId.at(aGMFID-1).empty())
             addElemInMeshGroup(theHelper->GetMesh(), aGMFNode, aNodeGroupByGhs3dId.at(aGMFID-1), groupsToRemove);
         }
       }
@@ -1520,6 +989,7 @@ static bool readGMFFile(const char*                     theFile,
       } // loop on elements of one type
       break;
     } // case ...
+    default:;
     } // switch (token)
   } // loop on tabRef
 
@@ -1600,7 +1070,7 @@ static bool writeGMFFile(const char*                                     theMesh
   bool isOK;
   SMESH_Mesh* theMesh = theHelper.GetMesh();
   const bool hasGeom = theMesh->HasShapeToMesh();
-  auto_ptr< SMESH_ElementSearcher > pntCls
+  SMESHUtils::Deleter< SMESH_ElementSearcher > pntCls
     ( SMESH_MeshAlgos::GetElementSearcher(*theMesh->GetMeshDS()));
   
   int nbEnforcedVertices = theEnforcedVertices.size();
@@ -1769,7 +1239,7 @@ static bool writeGMFFile(const char*                                     theMesh
   n2id = anEnforcedNodeToGhs3dIdMap.begin();
   for ( ; n2id != anEnforcedNodeToGhs3dIdMap.end(); ++ n2id)
   {
-    if (n2id->second > aNodeToGhs3dIdMap.size()) {
+    if (n2id->second > (int)aNodeToGhs3dIdMap.size()) {
       theEnforcedNodeByGhs3dId[ n2id->second - aNodeToGhs3dIdMap.size() - 1 ] = n2id->first; // MG-Tetra ids count from 1
     }
   }
@@ -2122,1216 +1592,6 @@ static bool writeGMFFile(const char*                                     theMesh
   
 }
 
-// static bool writeGMFFile(const char*                                    theMeshFileName,
-//                         const char*                                     theRequiredFileName,
-//                         const char*                                     theSolFileName,
-//                         SMESH_MesherHelper&                             theHelper,
-//                         const SMESH_ProxyMesh&                          theProxyMesh,
-//                         std::map <int,int> &                            theNodeId2NodeIndexMap,
-//                         std::map <int,int> &                            theSmdsToGhs3dIdMap,
-//                         std::map <int,const SMDS_MeshNode*> &           theGhs3dIdToNodeMap,
-//                         TIDSortedNodeSet &                              theEnforcedNodes,
-//                         TIDSortedElemSet &                              theEnforcedEdges,
-//                         TIDSortedElemSet &                              theEnforcedTriangles,
-// //                         TIDSortedElemSet &                              theEnforcedQuadrangles,
-//                         GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertexCoordsValues & theEnforcedVertices)
-// {
-//   MESSAGE("writeGMFFile with geometry");
-//   int idx, idxRequired, idxSol;
-//   int nbv, nbev, nben, aGhs3dID = 0;
-//   const int dummyint = 0;
-//   GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertexCoordsValues::const_iterator vertexIt;
-//   std::vector<double> enfVertexSizes;
-//   TIDSortedNodeSet::const_iterator enfNodeIt;
-//   const SMDS_MeshNode* node;
-//   SMDS_NodeIteratorPtr nodeIt;
-// 
-//   idx = GmfOpenMesh(theMeshFileName, GmfWrite, GMFVERSION, GMFDIMENSION);
-//   if (!idx)
-//     return false;
-//   
-//   SMESHDS_Mesh * theMeshDS = theHelper.GetMeshDS();
-//   
-//   /* ========================== NODES ========================== */
-//   // NB_NODES
-//   nbv = theMeshDS->NbNodes();
-//   if ( nbv == 0 )
-//     return false;
-//   nbev = theEnforcedVertices.size();
-//   nben = theEnforcedNodes.size();
-//   
-//   // Issue 020674: EDF 870 SMESH: Mesh generated by Netgen not usable by MG-Tetra
-//   // The problem is in nodes on degenerated edges, we need to skip nodes which are free
-//   // and replace not-free nodes on edges by the node on vertex
-//   TNodeNodeMap n2nDegen; // map a node on degenerated edge to a node on vertex
-//   TNodeNodeMap::iterator n2nDegenIt;
-//   if ( theHelper.HasDegeneratedEdges() )
-//   {
-//     set<int> checkedSM;
-//     for (TopExp_Explorer e(theMeshDS->ShapeToMesh(), TopAbs_EDGE ); e.More(); e.Next())
-//     {
-//       SMESH_subMesh* sm = theHelper.GetMesh()->GetSubMesh( e.Current() );
-//       if ( checkedSM.insert( sm->GetId() ).second && theHelper.IsDegenShape(sm->GetId() ))
-//       {
-//         if ( SMESHDS_SubMesh* smDS = sm->GetSubMeshDS() )
-//         {
-//           TopoDS_Shape vertex = TopoDS_Iterator( e.Current() ).Value();
-//           const SMDS_MeshNode* vNode = SMESH_Algo::VertexNode( TopoDS::Vertex( vertex ), theMeshDS);
-//           {
-//             SMDS_NodeIteratorPtr nIt = smDS->GetNodes();
-//             while ( nIt->more() )
-//               n2nDegen.insert( make_pair( nIt->next(), vNode ));
-//           }
-//         }
-//       }
-//     }
-//   }
-//   
-//   const bool isQuadMesh = 
-//     theHelper.GetMesh()->NbEdges( ORDER_QUADRATIC ) ||
-//     theHelper.GetMesh()->NbFaces( ORDER_QUADRATIC ) ||
-//     theHelper.GetMesh()->NbVolumes( ORDER_QUADRATIC );
-// 
-//   std::vector<std::vector<double> > VerTab;
-//   std::set<std::vector<double> > VerMap;
-//   VerTab.clear();
-//   std::vector<double> aVerTab;
-//   // Loop from 1 to NB_NODES
-// 
-//   nodeIt = theMeshDS->nodesIterator();
-//   
-//   while ( nodeIt->more() )
-//   {
-//     node = nodeIt->next();
-//     if ( isQuadMesh && theHelper.IsMedium( node )) // Issue 0021238
-//       continue;
-//     if ( n2nDegen.count( node ) ) // Issue 0020674
-//       continue;
-// 
-//     std::vector<double> coords;
-//     coords.push_back(node->X());
-//     coords.push_back(node->Y());
-//     coords.push_back(node->Z());
-//     if (VerMap.find(coords) != VerMap.end()) {
-//       aGhs3dID = theSmdsToGhs3dIdMap[node->GetID()];
-//       theGhs3dIdToNodeMap[theSmdsToGhs3dIdMap[node->GetID()]] = node;
-//       continue;
-//     }
-//     VerTab.push_back(coords);
-//     VerMap.insert(coords);
-//     aGhs3dID++;
-//     theSmdsToGhs3dIdMap.insert( make_pair( node->GetID(), aGhs3dID ));
-//     theGhs3dIdToNodeMap.insert( make_pair( aGhs3dID, node ));
-//   }
-//   
-//   
-//   /* ENFORCED NODES ========================== */
-//   if (nben) {
-//     std::cout << "Add " << nben << " enforced nodes to input .mesh file" << std::endl;
-//     for(enfNodeIt = theEnforcedNodes.begin() ; enfNodeIt != theEnforcedNodes.end() ; ++enfNodeIt) {
-//       double x = (*enfNodeIt)->X();
-//       double y = (*enfNodeIt)->Y();
-//       double z = (*enfNodeIt)->Z();
-//       // Test if point is inside shape to mesh
-//       gp_Pnt myPoint(x,y,z);
-//       BRepClass3d_SolidClassifier scl(theMeshDS->ShapeToMesh());
-//       scl.Perform(myPoint, 1e-7);
-//       TopAbs_State result = scl.State();
-//       if ( result != TopAbs_IN )
-//         continue;
-//       std::vector<double> coords;
-//       coords.push_back(x);
-//       coords.push_back(y);
-//       coords.push_back(z);
-//       if (theEnforcedVertices.find(coords) != theEnforcedVertices.end())
-//         continue;
-//       if (VerMap.find(coords) != VerMap.end())
-//         continue;
-//       VerTab.push_back(coords);
-//       VerMap.insert(coords);
-//       aGhs3dID++;
-//       theNodeId2NodeIndexMap.insert( make_pair( (*enfNodeIt)->GetID(), aGhs3dID ));
-//     }
-//   }
-//     
-//   
-//   /* ENFORCED VERTICES ========================== */
-//   int solSize = 0;
-//   std::vector<std::vector<double> > ReqVerTab;
-//   ReqVerTab.clear();
-//   if (nbev) {
-//     std::cout << "Add " << nbev << " enforced vertices to input .mesh file" << std::endl;
-//     for(vertexIt = theEnforcedVertices.begin() ; vertexIt != theEnforcedVertices.end() ; ++vertexIt) {
-//       double x = vertexIt->first[0];
-//       double y = vertexIt->first[1];
-//       double z = vertexIt->first[2];
-//       // Test if point is inside shape to mesh
-//       gp_Pnt myPoint(x,y,z);
-//       BRepClass3d_SolidClassifier scl(theMeshDS->ShapeToMesh());
-//       scl.Perform(myPoint, 1e-7);
-//       TopAbs_State result = scl.State();
-//       if ( result != TopAbs_IN )
-//         continue;
-//       enfVertexSizes.push_back(vertexIt->second);
-//       std::vector<double> coords;
-//       coords.push_back(x);
-//       coords.push_back(y);
-//       coords.push_back(z);
-//       if (VerMap.find(coords) != VerMap.end())
-//         continue;
-//       ReqVerTab.push_back(coords);
-//       VerMap.insert(coords);
-//       solSize++;
-//     }
-//   }
-// 
-//   
-//   /* ========================== FACES ========================== */
-//   
-//   int nbTriangles = 0/*, nbQuadrangles = 0*/, aSmdsID;
-//   TopTools_IndexedMapOfShape facesMap, trianglesMap/*, quadranglesMap*/;
-//   TIDSortedElemSet::const_iterator elemIt;
-//   const SMESHDS_SubMesh* theSubMesh;
-//   TopoDS_Shape aShape;
-//   SMDS_ElemIteratorPtr itOnSubMesh, itOnSubFace;
-//   const SMDS_MeshElement* aFace;
-//   map<int,int>::const_iterator itOnMap;
-//   std::vector<std::vector<int> > tt, qt,et;
-//   tt.clear();
-//   qt.clear();
-//   et.clear();
-//   std::vector<int> att, aqt, aet;
-//   
-//   TopExp::MapShapes( theMeshDS->ShapeToMesh(), TopAbs_FACE, facesMap );
-// 
-//   for ( int i = 1; i <= facesMap.Extent(); ++i )
-//     if (( theSubMesh  = theProxyMesh.GetSubMesh( facesMap(i))))
-//     {
-//       SMDS_ElemIteratorPtr it = theSubMesh->GetElements();
-//       while (it->more())
-//       {
-//         const SMDS_MeshElement *elem = it->next();
-//         int nbCornerNodes = elem->NbCornerNodes();
-//         if (nbCornerNodes == 3)
-//         {
-//           trianglesMap.Add(facesMap(i));
-//           nbTriangles ++;
-//         }
-// //         else if (nbCornerNodes == 4)
-// //         {
-// //           quadranglesMap.Add(facesMap(i));
-// //           nbQuadrangles ++;
-// //         }
-//       }
-//     }
-//     
-//   /* TRIANGLES ========================== */
-//   if (nbTriangles) {
-//     for ( int i = 1; i <= trianglesMap.Extent(); i++ )
-//     {
-//       aShape = trianglesMap(i);
-//       theSubMesh = theProxyMesh.GetSubMesh(aShape);
-//       if ( !theSubMesh ) continue;
-//       itOnSubMesh = theSubMesh->GetElements();
-//       while ( itOnSubMesh->more() )
-//       {
-//         aFace = itOnSubMesh->next();
-//         itOnSubFace = aFace->nodesIterator();
-//         att.clear();
-//         for ( int j = 0; j < 3; ++j ) {
-//           // find MG-Tetra ID
-//           node = castToNode( itOnSubFace->next() );
-//           if (( n2nDegenIt = n2nDegen.find( node )) != n2nDegen.end() )
-//             node = n2nDegenIt->second;
-//           aSmdsID = node->GetID();
-//           itOnMap = theSmdsToGhs3dIdMap.find( aSmdsID );
-//           ASSERT( itOnMap != theSmdsToGhs3dIdMap.end() );
-//           att.push_back((*itOnMap).second);
-//         }
-//         tt.push_back(att);
-//       }
-//     }
-//   }
-// 
-//   if (theEnforcedTriangles.size()) {
-//     std::cout << "Add " << theEnforcedTriangles.size() << " enforced triangles to input .mesh file" << std::endl;
-//     // Iterate over the enforced triangles
-//     for(elemIt = theEnforcedTriangles.begin() ; elemIt != theEnforcedTriangles.end() ; ++elemIt) {
-//       aFace = (*elemIt);
-//       itOnSubFace = aFace->nodesIterator();
-//       bool isOK = true;
-//       att.clear();
-//       
-//       for ( int j = 0; j < 3; ++j ) {
-//         node = castToNode( itOnSubFace->next() );
-//         if (( n2nDegenIt = n2nDegen.find( node )) != n2nDegen.end() )
-//           node = n2nDegenIt->second;
-// //         std::cout << node;
-//         double x = node->X();
-//         double y = node->Y();
-//         double z = node->Z();
-//         // Test if point is inside shape to mesh
-//         gp_Pnt myPoint(x,y,z);
-//         BRepClass3d_SolidClassifier scl(theMeshDS->ShapeToMesh());
-//         scl.Perform(myPoint, 1e-7);
-//         TopAbs_State result = scl.State();
-//         if ( result != TopAbs_IN ) {
-//           isOK = false;
-//           theEnforcedTriangles.erase(elemIt);
-//           continue;
-//         }
-//         std::vector<double> coords;
-//         coords.push_back(x);
-//         coords.push_back(y);
-//         coords.push_back(z);
-//         if (VerMap.find(coords) != VerMap.end()) {
-//           att.push_back(theNodeId2NodeIndexMap[node->GetID()]);
-//           continue;
-//         }
-//         VerTab.push_back(coords);
-//         VerMap.insert(coords);
-//         aGhs3dID++;
-//         theNodeId2NodeIndexMap.insert( make_pair( node->GetID(), aGhs3dID ));
-//         att.push_back(aGhs3dID);
-//       }
-//       if (isOK)
-//         tt.push_back(att);
-//     }
-//   }
-// 
-// 
-//   /* ========================== EDGES ========================== */
-// 
-//   if (theEnforcedEdges.size()) {
-//     // Iterate over the enforced edges
-//     std::cout << "Add " << theEnforcedEdges.size() << " enforced edges to input .mesh file" << std::endl;
-//     for(elemIt = theEnforcedEdges.begin() ; elemIt != theEnforcedEdges.end() ; ++elemIt) {
-//       aFace = (*elemIt);
-//       bool isOK = true;
-//       itOnSubFace = aFace->nodesIterator();
-//       aet.clear();
-//       for ( int j = 0; j < 2; ++j ) {
-//         node = castToNode( itOnSubFace->next() );
-//         if (( n2nDegenIt = n2nDegen.find( node )) != n2nDegen.end() )
-//           node = n2nDegenIt->second;
-//         double x = node->X();
-//         double y = node->Y();
-//         double z = node->Z();
-//         // Test if point is inside shape to mesh
-//         gp_Pnt myPoint(x,y,z);
-//         BRepClass3d_SolidClassifier scl(theMeshDS->ShapeToMesh());
-//         scl.Perform(myPoint, 1e-7);
-//         TopAbs_State result = scl.State();
-//         if ( result != TopAbs_IN ) {
-//           isOK = false;
-//           theEnforcedEdges.erase(elemIt);
-//           continue;
-//         }
-//         std::vector<double> coords;
-//         coords.push_back(x);
-//         coords.push_back(y);
-//         coords.push_back(z);
-//         if (VerMap.find(coords) != VerMap.end()) {
-//           aet.push_back(theNodeId2NodeIndexMap[node->GetID()]);
-//           continue;
-//         }
-//         VerTab.push_back(coords);
-//         VerMap.insert(coords);
-//         
-//         aGhs3dID++;
-//         theNodeId2NodeIndexMap.insert( make_pair( node->GetID(), aGhs3dID ));
-//         aet.push_back(aGhs3dID);
-//       }
-//       if (isOK)
-//         et.push_back(aet);
-//     }
-//   }
-// 
-// 
-//   /* Write vertices number */
-//   MESSAGE("Number of vertices: "<<aGhs3dID);
-//   MESSAGE("Size of vector: "<<VerTab.size());
-//   GmfSetKwd(idx, GmfVertices, aGhs3dID/*+solSize*/);
-//   for (int i=0;i<aGhs3dID;i++)
-//     GmfSetLin(idx, GmfVertices, VerTab[i][0], VerTab[i][1], VerTab[i][2], dummyint);
-// //   for (int i=0;i<solSize;i++) {
-// //     std::cout << ReqVerTab[i][0] <<" "<< ReqVerTab[i][1] << " "<< ReqVerTab[i][2] << std::endl;
-// //     GmfSetLin(idx, GmfVertices, ReqVerTab[i][0], ReqVerTab[i][1], ReqVerTab[i][2], dummyint);
-// //   }
-// 
-//   if (solSize) {
-//     idxRequired = GmfOpenMesh(theRequiredFileName, GmfWrite, GMFVERSION, GMFDIMENSION);
-//     if (!idxRequired) {
-//       GmfCloseMesh(idx);
-//       return false;
-//     }
-//     idxSol = GmfOpenMesh(theSolFileName, GmfWrite, GMFVERSION, GMFDIMENSION);
-//     if (!idxSol){
-//       GmfCloseMesh(idx);
-//       if (idxRequired)
-//         GmfCloseMesh(idxRequired);
-//       return false;
-//     }
-//     
-//     int TypTab[] = {GmfSca};
-//     GmfSetKwd(idxRequired, GmfVertices, solSize);
-//     GmfSetKwd(idxSol, GmfSolAtVertices, solSize, 1, TypTab);
-//     
-//     for (int i=0;i<solSize;i++) {
-//       double solTab[] = {enfVertexSizes.at(i)};
-//       GmfSetLin(idxRequired, GmfVertices, ReqVerTab[i][0], ReqVerTab[i][1], ReqVerTab[i][2], dummyint);
-//       GmfSetLin(idxSol, GmfSolAtVertices, solTab);
-//     }
-//     GmfCloseMesh(idxRequired);
-//     GmfCloseMesh(idxSol);
-//   }
-//   
-//   /* Write triangles number */
-//   if (tt.size()) {
-//     GmfSetKwd(idx, GmfTriangles, tt.size());
-//     for (int i=0;i<tt.size();i++)
-//       GmfSetLin(idx, GmfTriangles, tt[i][0], tt[i][1], tt[i][2], dummyint);
-//   }  
-//   
-//   /* Write edges number */
-//   if (et.size()) {
-//     GmfSetKwd(idx, GmfEdges, et.size());
-//     for (int i=0;i<et.size();i++)
-//       GmfSetLin(idx, GmfEdges, et[i][0], et[i][1], dummyint);
-//   }
-// 
-//   /* QUADRANGLES ========================== */
-//   // TODO: add pyramids ?
-// //   if (nbQuadrangles) {
-// //     for ( int i = 1; i <= quadranglesMap.Extent(); i++ )
-// //     {
-// //       aShape = quadranglesMap(i);
-// //       theSubMesh = theProxyMesh.GetSubMesh(aShape);
-// //       if ( !theSubMesh ) continue;
-// //       itOnSubMesh = theSubMesh->GetElements();
-// //       for ( int j = 0; j < 4; ++j )
-// //       {
-// //         aFace = itOnSubMesh->next();
-// //         itOnSubFace = aFace->nodesIterator();
-// //         aqt.clear();
-// //         while ( itOnSubFace->more() ) {
-// //           // find MG-Tetra ID
-// //           aSmdsID = itOnSubFace->next()->GetID();
-// //           itOnMap = theSmdsToGhs3dIdMap.find( aSmdsID );
-// //           ASSERT( itOnMap != theSmdsToGhs3dIdMap.end() );
-// //           aqt.push_back((*itOnMap).second);
-// //         }
-// //         qt.push_back(aqt);
-// //       }
-// //     }
-// //   }
-// // 
-// //   if (theEnforcedQuadrangles.size()) {
-// //     // Iterate over the enforced triangles
-// //     for(elemIt = theEnforcedQuadrangles.begin() ; elemIt != theEnforcedQuadrangles.end() ; ++elemIt) {
-// //       aFace = (*elemIt);
-// //       bool isOK = true;
-// //       itOnSubFace = aFace->nodesIterator();
-// //       aqt.clear();
-// //       for ( int j = 0; j < 4; ++j ) {
-// //         int aNodeID = itOnSubFace->next()->GetID();
-// //         itOnMap = theNodeId2NodeIndexMap.find(aNodeID);
-// //         if (itOnMap != theNodeId2NodeIndexMap.end())
-// //           aqt.push_back((*itOnMap).second);
-// //         else {
-// //           isOK = false;
-// //           theEnforcedQuadrangles.erase(elemIt);
-// //           break;
-// //         }
-// //       }
-// //       if (isOK)
-// //         qt.push_back(aqt);
-// //     }
-// //   }
-// //  
-//   
-// //   /* Write quadrilaterals number */
-// //   if (qt.size()) {
-// //     GmfSetKwd(idx, GmfQuadrilaterals, qt.size());
-// //     for (int i=0;i<qt.size();i++)
-// //       GmfSetLin(idx, GmfQuadrilaterals, qt[i][0], qt[i][1], qt[i][2], qt[i][3], dummyint);
-// //   }
-// 
-//   GmfCloseMesh(idx);
-//   return true;
-// }
-
-
-//=======================================================================
-//function : writeFaces
-//purpose  : 
-//=======================================================================
-
-static bool writeFaces (ofstream &              theFile,
-                        const SMESH_ProxyMesh&  theMesh,
-                        const TopoDS_Shape&     theShape,
-                        const map <int,int> &   theSmdsToGhs3dIdMap,
-                        const map <int,int> &   theEnforcedNodeIdToGhs3dIdMap,
-                        GHS3DPlugin_Hypothesis::TIDSortedElemGroupMap & theEnforcedEdges,
-                        GHS3DPlugin_Hypothesis::TIDSortedElemGroupMap & theEnforcedTriangles)
-{
-  // record structure:
-  //
-  // NB_ELEMS DUMMY_INT
-  // Loop from 1 to NB_ELEMS
-  // NB_NODES NODE_NB_1 NODE_NB_2 ... (NB_NODES + 1) times: DUMMY_INT
-
-  TopoDS_Shape aShape;
-  const SMESHDS_SubMesh* theSubMesh;
-  const SMDS_MeshElement* aFace;
-  const char* space    = "  ";
-  const int   dummyint = 0;
-  map<int,int>::const_iterator itOnMap;
-  SMDS_ElemIteratorPtr itOnSubMesh, itOnSubFace;
-  int nbNodes, aSmdsID;
-
-  TIDSortedElemSet::const_iterator elemIt;
-  int nbEnforcedEdges       = theEnforcedEdges.size();
-  int nbEnforcedTriangles   = theEnforcedTriangles.size();
-
-  // count triangles bound to geometry
-  int nbTriangles = 0;
-
-  TopTools_IndexedMapOfShape facesMap, trianglesMap;
-  TopExp::MapShapes( theShape, TopAbs_FACE, facesMap );
-  
-  int nbFaces = facesMap.Extent();
-
-  for ( int i = 1; i <= nbFaces; ++i )
-    if (( theSubMesh  = theMesh.GetSubMesh( facesMap(i))))
-      nbTriangles += theSubMesh->NbElements();
-  std::string tmpStr;
-  (nbFaces == 0 || nbFaces == 1) ? tmpStr = " shape " : tmpStr = " shapes " ;
-  std::cout << "    " << nbFaces << tmpStr << "of 2D dimension";
-  int nbEnforcedElements = nbEnforcedEdges+nbEnforcedTriangles;
-  if (nbEnforcedElements > 0) {
-    (nbEnforcedElements == 1) ? tmpStr = "shape:" : tmpStr = "shapes:";
-    std::cout << " and" << std::endl;
-    std::cout << "    " << nbEnforcedElements 
-                        << " enforced " << tmpStr << std::endl;
-  }
-  else
-    std::cout << std::endl;
-  if (nbEnforcedEdges) {
-    (nbEnforcedEdges == 1) ? tmpStr = "edge" : tmpStr = "edges";
-    std::cout << "      " << nbEnforcedEdges << " enforced " << tmpStr << std::endl;
-  }
-  if (nbEnforcedTriangles) {
-    (nbEnforcedTriangles == 1) ? tmpStr = "triangle" : tmpStr = "triangles";
-    std::cout << "      " << nbEnforcedTriangles << " enforced " << tmpStr << std::endl;
-  }
-  std::cout << std::endl;
-
-//   theFile << space << nbTriangles << space << dummyint << std::endl;
-  std::ostringstream globalStream, localStream, aStream;
-
-  for ( int i = 1; i <= facesMap.Extent(); i++ )
-  {
-    aShape = facesMap(i);
-    theSubMesh = theMesh.GetSubMesh(aShape);
-    if ( !theSubMesh ) continue;
-    itOnSubMesh = theSubMesh->GetElements();
-    while ( itOnSubMesh->more() )
-    {
-      aFace = itOnSubMesh->next();
-      nbNodes = aFace->NbCornerNodes();
-
-      localStream << nbNodes << space;
-
-      itOnSubFace = aFace->nodesIterator();
-      for ( int j = 0; j < 3; ++j ) {
-        // find MG-Tetra ID
-        aSmdsID = itOnSubFace->next()->GetID();
-        itOnMap = theSmdsToGhs3dIdMap.find( aSmdsID );
-        // if ( itOnMap == theSmdsToGhs3dIdMap.end() ) {
-        //   cout << "not found node: " << aSmdsID << endl;
-        //   return false;
-        // }
-        ASSERT( itOnMap != theSmdsToGhs3dIdMap.end() );
-
-        localStream << (*itOnMap).second << space ;
-      }
-
-      // (NB_NODES + 1) times: DUMMY_INT
-      for ( int j=0; j<=nbNodes; j++)
-        localStream << dummyint << space ;
-
-      localStream << std::endl;
-    }
-  }
-  
-  globalStream << localStream.str();
-  localStream.str("");
-
-  //
-  //        FACES : END
-  //
-
-//   //
-//   //        ENFORCED EDGES : BEGIN
-//   //
-//   
-//   // Iterate over the enforced edges
-//   int usedEnforcedEdges = 0;
-//   bool isOK;
-//   for(elemIt = theEnforcedEdges.begin() ; elemIt != theEnforcedEdges.end() ; ++elemIt) {
-//     aFace = (*elemIt);
-//     isOK = true;
-//     itOnSubFace = aFace->nodesIterator();
-//     aStream.str("");
-//     aStream << "2" << space ;
-//     for ( int j = 0; j < 2; ++j ) {
-//       aSmdsID = itOnSubFace->next()->GetID();
-//       itOnMap = theEnforcedNodeIdToGhs3dIdMap.find(aSmdsID);
-//       if (itOnMap != theEnforcedNodeIdToGhs3dIdMap.end())
-//         aStream << (*itOnMap).second << space;
-//       else {
-//         isOK = false;
-//         break;
-//       }
-//     }
-//     if (isOK) {
-//       for ( int j=0; j<=2; j++)
-//         aStream << dummyint << space ;
-// //       aStream << dummyint << space << dummyint;
-//       localStream << aStream.str() << std::endl;
-//       usedEnforcedEdges++;
-//     }
-//   }
-//   
-//   if (usedEnforcedEdges) {
-//     globalStream << localStream.str();
-//     localStream.str("");
-//   }
-// 
-//   //
-//   //        ENFORCED EDGES : END
-//   //
-//   //
-// 
-//   //
-//   //        ENFORCED TRIANGLES : BEGIN
-//   //
-//     // Iterate over the enforced triangles
-//   int usedEnforcedTriangles = 0;
-//   for(elemIt = theEnforcedTriangles.begin() ; elemIt != theEnforcedTriangles.end() ; ++elemIt) {
-//     aFace = (*elemIt);
-//     nbNodes = aFace->NbCornerNodes();
-//     isOK = true;
-//     itOnSubFace = aFace->nodesIterator();
-//     aStream.str("");
-//     aStream << nbNodes << space ;
-//     for ( int j = 0; j < 3; ++j ) {
-//       aSmdsID = itOnSubFace->next()->GetID();
-//       itOnMap = theEnforcedNodeIdToGhs3dIdMap.find(aSmdsID);
-//       if (itOnMap != theEnforcedNodeIdToGhs3dIdMap.end())
-//         aStream << (*itOnMap).second << space;
-//       else {
-//         isOK = false;
-//         break;
-//       }
-//     }
-//     if (isOK) {
-//       for ( int j=0; j<=3; j++)
-//         aStream << dummyint << space ;
-//       localStream << aStream.str() << std::endl;
-//       usedEnforcedTriangles++;
-//     }
-//   }
-//   
-//   if (usedEnforcedTriangles) {
-//     globalStream << localStream.str();
-//     localStream.str("");
-//   }
-// 
-//   //
-//   //        ENFORCED TRIANGLES : END
-//   //
-  
-  theFile
-  << nbTriangles/*+usedEnforcedTriangles+usedEnforcedEdges*/
-  << " 0" << std::endl
-  << globalStream.str();
-
-  return true;
-}
-
-//=======================================================================
-//function : writePoints
-//purpose  : 
-//=======================================================================
-
-static bool writePoints (ofstream &                       theFile,
-                         SMESH_MesherHelper&              theHelper,
-                         map <int,int> &                  theSmdsToGhs3dIdMap,
-                         map <int,int> &                  theEnforcedNodeIdToGhs3dIdMap,
-                         map <int,const SMDS_MeshNode*> & theGhs3dIdToNodeMap,
-                         GHS3DPlugin_Hypothesis::TID2SizeMap & theNodeIDToSizeMap,
-                         GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertexCoordsValues & theEnforcedVertices,
-                         GHS3DPlugin_Hypothesis::TIDSortedNodeGroupMap & theEnforcedNodes,
-                         GHS3DPlugin_Hypothesis::TIDSortedElemGroupMap & theEnforcedEdges,
-                         GHS3DPlugin_Hypothesis::TIDSortedElemGroupMap & theEnforcedTriangles)
-{
-  // record structure:
-  //
-  // NB_NODES
-  // Loop from 1 to NB_NODES
-  //   X Y Z DUMMY_INT
-
-  SMESHDS_Mesh * theMeshDS = theHelper.GetMeshDS();
-  int nbNodes = theMeshDS->NbNodes();
-  if ( nbNodes == 0 )
-    return false;
-  
-  int nbEnforcedVertices = theEnforcedVertices.size();
-  int nbEnforcedNodes    = theEnforcedNodes.size();
-  
-  const TopoDS_Shape shapeToMesh = theMeshDS->ShapeToMesh();
-  
-  int aGhs3dID = 1;
-  SMDS_NodeIteratorPtr nodeIt = theMeshDS->nodesIterator();
-  const SMDS_MeshNode* node;
-
-  // Issue 020674: EDF 870 SMESH: Mesh generated by Netgen not usable by MG-Tetra
-  // The problem is in nodes on degenerated edges, we need to skip nodes which are free
-  // and replace not-free nodes on degenerated edges by the node on vertex
-  TNodeNodeMap n2nDegen; // map a node on degenerated edge to a node on vertex
-  TNodeNodeMap::iterator n2nDegenIt;
-  if ( theHelper.HasDegeneratedEdges() )
-  {
-    set<int> checkedSM;
-    for (TopExp_Explorer e(theMeshDS->ShapeToMesh(), TopAbs_EDGE ); e.More(); e.Next())
-    {
-      SMESH_subMesh* sm = theHelper.GetMesh()->GetSubMesh( e.Current() );
-      if ( checkedSM.insert( sm->GetId() ).second && theHelper.IsDegenShape(sm->GetId() ))
-      {
-        if ( SMESHDS_SubMesh* smDS = sm->GetSubMeshDS() )
-        {
-          TopoDS_Shape vertex = TopoDS_Iterator( e.Current() ).Value();
-          const SMDS_MeshNode* vNode = SMESH_Algo::VertexNode( TopoDS::Vertex( vertex ), theMeshDS);
-          {
-            SMDS_NodeIteratorPtr nIt = smDS->GetNodes();
-            while ( nIt->more() )
-              n2nDegen.insert( make_pair( nIt->next(), vNode ));
-          }
-        }
-      }
-    }
-    nbNodes -= n2nDegen.size();
-  }
-
-  const bool isQuadMesh = 
-    theHelper.GetMesh()->NbEdges( ORDER_QUADRATIC ) ||
-    theHelper.GetMesh()->NbFaces( ORDER_QUADRATIC ) ||
-    theHelper.GetMesh()->NbVolumes( ORDER_QUADRATIC );
-  if ( isQuadMesh )
-  {
-    // descrease nbNodes by nb of medium nodes
-    while ( nodeIt->more() )
-    {
-      node = nodeIt->next();
-      if ( !theHelper.IsDegenShape( node->getshapeId() ))
-        nbNodes -= int( theHelper.IsMedium( node ));
-    }
-    nodeIt = theMeshDS->nodesIterator();
-  }
-
-  const char* space    = "  ";
-  const int   dummyint = 0;
-
-  std::string tmpStr;
-  (nbNodes == 0 || nbNodes == 1) ? tmpStr = " node" : tmpStr = " nodes";
-  // NB_NODES
-  std::cout << std::endl;
-  std::cout << "The initial 2D mesh contains :" << std::endl;
-  std::cout << "    " << nbNodes << tmpStr << std::endl;
-  if (nbEnforcedVertices > 0) {
-    (nbEnforcedVertices == 1) ? tmpStr = "vertex" : tmpStr = "vertices";
-    std::cout << "    " << nbEnforcedVertices << " enforced " << tmpStr << std::endl;
-  }
-  if (nbEnforcedNodes > 0) {
-    (nbEnforcedNodes == 1) ? tmpStr = "node" : tmpStr = "nodes";
-    std::cout << "    " << nbEnforcedNodes << " enforced " << tmpStr << std::endl;
-  }
-  std::cout << std::endl;
-  std::cout << "Start writing in 'points' file ..." << std::endl;
-
-  theFile << nbNodes << std::endl;
-
-  // Loop from 1 to NB_NODES
-
-  while ( nodeIt->more() )
-  {
-    node = nodeIt->next();
-    if ( isQuadMesh && theHelper.IsMedium( node )) // Issue 0021238
-      continue;
-    if ( n2nDegen.count( node ) ) // Issue 0020674
-      continue;
-
-    theSmdsToGhs3dIdMap.insert( make_pair( node->GetID(), aGhs3dID ));
-    theGhs3dIdToNodeMap.insert( make_pair( aGhs3dID, node ));
-    aGhs3dID++;
-
-    // X Y Z DUMMY_INT
-    theFile
-    << node->X() << space 
-    << node->Y() << space 
-    << node->Z() << space 
-    << dummyint;
-
-    theFile << std::endl;
-
-  }
-  
-  // Iterate over the enforced nodes
-  std::map<int,double> enfVertexIndexSizeMap;
-  if (nbEnforcedNodes) {
-    GHS3DPlugin_Hypothesis::TIDSortedNodeGroupMap::const_iterator nodeIt = theEnforcedNodes.begin();
-    for( ; nodeIt != theEnforcedNodes.end() ; ++nodeIt) {
-      double x = nodeIt->first->X();
-      double y = nodeIt->first->Y();
-      double z = nodeIt->first->Z();
-      // Test if point is inside shape to mesh
-      gp_Pnt myPoint(x,y,z);
-      BRepClass3d_SolidClassifier scl(shapeToMesh);
-      scl.Perform(myPoint, 1e-7);
-      TopAbs_State result = scl.State();
-      if ( result != TopAbs_IN )
-        continue;
-      std::vector<double> coords;
-      coords.push_back(x);
-      coords.push_back(y);
-      coords.push_back(z);
-      if (theEnforcedVertices.find(coords) != theEnforcedVertices.end())
-        continue;
-        
-//      double size = theNodeIDToSizeMap.find(nodeIt->first->GetID())->second;
-  //       theGhs3dIdToNodeMap.insert( make_pair( nbNodes + i, (*nodeIt) ));
-  //       MESSAGE("Adding enforced node (" << x << "," << y <<"," << z << ")");
-      // X Y Z PHY_SIZE DUMMY_INT
-      theFile
-      << x << space 
-      << y << space 
-      << z << space
-      << -1 << space
-      << dummyint << space;
-      theFile << std::endl;
-      theEnforcedNodeIdToGhs3dIdMap.insert( make_pair( nodeIt->first->GetID(), aGhs3dID ));
-      enfVertexIndexSizeMap[aGhs3dID] = -1;
-      aGhs3dID++;
-  //     else
-  //         MESSAGE("Enforced vertex (" << x << "," << y <<"," << z << ") is not inside the geometry: it was not added ");
-    }
-  }
-  
-  if (nbEnforcedVertices) {
-    // Iterate over the enforced vertices
-    GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertexCoordsValues::const_iterator vertexIt = theEnforcedVertices.begin();
-    for( ; vertexIt != theEnforcedVertices.end() ; ++vertexIt) {
-      double x = vertexIt->first[0];
-      double y = vertexIt->first[1];
-      double z = vertexIt->first[2];
-      // Test if point is inside shape to mesh
-      gp_Pnt myPoint(x,y,z);
-      BRepClass3d_SolidClassifier scl(shapeToMesh);
-      scl.Perform(myPoint, 1e-7);
-      TopAbs_State result = scl.State();
-      if ( result != TopAbs_IN )
-        continue;
-      MESSAGE("Adding enforced vertex (" << x << "," << y <<"," << z << ") = " << vertexIt->second);
-      // X Y Z PHY_SIZE DUMMY_INT
-      theFile
-      << x << space 
-      << y << space 
-      << z << space
-      << vertexIt->second << space 
-      << dummyint << space;
-      theFile << std::endl;
-      enfVertexIndexSizeMap[aGhs3dID] = vertexIt->second;
-      aGhs3dID++;
-    }
-  }
-  
-  
-  std::cout << std::endl;
-  std::cout << "End writing in 'points' file." << std::endl;
-
-  return true;
-}
-
-//=======================================================================
-//function : readResultFile
-//purpose  : readResultFile with geometry
-//=======================================================================
-
-// static bool readResultFile(const int                       fileOpen,
-// #ifdef WIN32
-//                            const char*                     fileName,
-// #endif
-//                            GHS3DPlugin_GHS3D*              theAlgo,
-//                            SMESH_MesherHelper&             theHelper,
-//                            TopoDS_Shape                    tabShape[],
-//                            double**                        tabBox,
-//                            const int                       nbShape,
-//                            map <int,const SMDS_MeshNode*>& theGhs3dIdToNodeMap,
-//                            std::map <int,int> &            theNodeId2NodeIndexMap,
-//                            bool                            toMeshHoles,
-//                            int                             nbEnforcedVertices,
-//                            int                             nbEnforcedNodes,
-//                            GHS3DPlugin_Hypothesis::TIDSortedElemGroupMap & theEnforcedEdges,
-//                            GHS3DPlugin_Hypothesis::TIDSortedElemGroupMap & theEnforcedTriangles,
-//                            bool                            toMakeGroupsOfDomains)
-// {
-//   MESSAGE("GHS3DPlugin_GHS3D::readResultFile()");
-//   Kernel_Utils::Localizer loc;
-//   struct stat status;
-//   size_t      length;
-  
-//   std::string tmpStr;
-
-//   char *ptr, *mapPtr;
-//   char *tetraPtr;
-//   char *shapePtr;
-
-//   SMESHDS_Mesh* theMeshDS = theHelper.GetMeshDS();
-
-//   int nbElems, nbNodes, nbInputNodes;
-//   int nbTriangle;
-//   int ID, shapeID, ghs3dShapeID;
-//   int IdShapeRef = 1;
-//   int compoundID =
-//     nbShape ? theMeshDS->ShapeToIndex( tabShape[0] ) : theMeshDS->ShapeToIndex( theMeshDS->ShapeToMesh() );
-
-//   int *tab, *tabID, *nodeID, *nodeAssigne;
-//   double *coord;
-//   const SMDS_MeshNode **node;
-
-//   tab    = new int[3];
-//   nodeID = new int[4];
-//   coord  = new double[3];
-//   node   = new const SMDS_MeshNode*[4];
-
-//   TopoDS_Shape aSolid;
-//   SMDS_MeshNode * aNewNode;
-//   map <int,const SMDS_MeshNode*>::iterator itOnNode;
-//   SMDS_MeshElement* aTet;
-// #ifdef _DEBUG_
-//   set<int> shapeIDs;
-// #endif
-
-//   // Read the file state
-//   fstat(fileOpen, &status);
-//   length   = status.st_size;
-
-//   // Mapping the result file into memory
-// #ifdef WIN32
-//   HANDLE fd = CreateFile(fileName, GENERIC_READ, FILE_SHARE_READ,
-//                          NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
-//   HANDLE hMapObject = CreateFileMapping(fd, NULL, PAGE_READONLY,
-//                                         0, (DWORD)length, NULL);
-//   ptr = ( char* ) MapViewOfFile(hMapObject, FILE_MAP_READ, 0, 0, 0 );
-// #else
-//   ptr = (char *) mmap(0,length,PROT_READ,MAP_PRIVATE,fileOpen,0);
-// #endif
-//   mapPtr = ptr;
-
-//   ptr      = readMapIntLine(ptr, tab);
-//   tetraPtr = ptr;
-
-//   nbElems      = tab[0];
-//   nbNodes      = tab[1];
-//   nbInputNodes = tab[2];
-
-//   nodeAssigne = new int[ nbNodes+1 ];
-
-//   if (nbShape > 0)
-//     aSolid = tabShape[0];
-
-//   // Reading the nodeId
-//   for (int i=0; i < 4*nbElems; i++)
-//     strtol(ptr, &ptr, 10);
-
-//   MESSAGE("nbInputNodes: "<<nbInputNodes);
-//   MESSAGE("nbEnforcedVertices: "<<nbEnforcedVertices);
-//   MESSAGE("nbEnforcedNodes: "<<nbEnforcedNodes);
-//   // Reading the nodeCoor and update the nodeMap
-//   for (int iNode=1; iNode <= nbNodes; iNode++) {
-//     if(theAlgo->computeCanceled())
-//       return false;
-//     for (int iCoor=0; iCoor < 3; iCoor++)
-//       coord[ iCoor ] = strtod(ptr, &ptr);
-//     nodeAssigne[ iNode ] = 1;
-//     if ( iNode > (nbInputNodes-(nbEnforcedVertices+nbEnforcedNodes)) ) {
-//       // Creating SMESH nodes
-//       // - for enforced vertices
-//       // - for vertices of forced edges
-//       // - for MG-Tetra nodes
-//       nodeAssigne[ iNode ] = 0;
-//       aNewNode = theMeshDS->AddNode( coord[0],coord[1],coord[2] );
-//       theGhs3dIdToNodeMap.insert(theGhs3dIdToNodeMap.end(), make_pair( iNode, aNewNode ));
-//     }
-//   }
-
-//   // Reading the number of triangles which corresponds to the number of sub-domains
-//   nbTriangle = strtol(ptr, &ptr, 10);
-
-//   tabID = new int[nbTriangle];
-//   for (int i=0; i < nbTriangle; i++) {
-//     if(theAlgo->computeCanceled())
-//       return false;
-//     tabID[i] = 0;
-//     // find the solid corresponding to MG-Tetra sub-domain following
-//     // the technique proposed in MG-Tetra manual in chapter
-//     // "B.4 Subdomain (sub-region) assignment"
-//     int nodeId1 = strtol(ptr, &ptr, 10);
-//     int nodeId2 = strtol(ptr, &ptr, 10);
-//     int nodeId3 = strtol(ptr, &ptr, 10);
-//     if ( nbTriangle > 1 ) {
-//       const SMDS_MeshNode* n1 = theGhs3dIdToNodeMap[ nodeId1 ];
-//       const SMDS_MeshNode* n2 = theGhs3dIdToNodeMap[ nodeId2 ];
-//       const SMDS_MeshNode* n3 = theGhs3dIdToNodeMap[ nodeId3 ];
-//       if (!n1 || !n2 || !n3) {
-//         tabID[i] = HOLE_ID;
-//         continue;
-//       }
-//       try {
-//         OCC_CATCH_SIGNALS;
-//         tabID[i] = findShapeID( *theHelper.GetMesh(), n1, n2, n3, toMeshHoles );
-//         // -- 0020330: Pb with MG-Tetra as a submesh
-//         // check that found shape is to be meshed
-//         if ( tabID[i] > 0 ) {
-//           const TopoDS_Shape& foundShape = theMeshDS->IndexToShape( tabID[i] );
-//           bool isToBeMeshed = false;
-//           for ( int iS = 0; !isToBeMeshed && iS < nbShape; ++iS )
-//             isToBeMeshed = foundShape.IsSame( tabShape[ iS ]);
-//           if ( !isToBeMeshed )
-//             tabID[i] = HOLE_ID;
-//         }
-//         // END -- 0020330: Pb with MG-Tetra as a submesh
-// #ifdef _DEBUG_
-//         std::cout << i+1 << " subdomain: findShapeID() returns " << tabID[i] << std::endl;
-// #endif
-//       }
-//       catch ( Standard_Failure & ex)
-//       {
-// #ifdef _DEBUG_
-//         std::cout << i+1 << " subdomain: Exception caugt: " << ex.GetMessageString() << std::endl;
-// #endif
-//       }
-//       catch (...) {
-// #ifdef _DEBUG_
-//         std::cout << i+1 << " subdomain: unknown exception caught " << std::endl;
-// #endif
-//       }
-//     }
-//   }
-
-//   shapePtr = ptr;
-
-//   if ( nbTriangle <= nbShape ) // no holes
-//     toMeshHoles = true; // not avoid creating tetras in holes
-
-//   // IMP 0022172: [CEA 790] create the groups corresponding to domains
-//   std::vector< std::vector< const SMDS_MeshElement* > > elemsOfDomain( Max( nbTriangle, nbShape ));
-
-//   // Associating the tetrahedrons to the shapes
-//   shapeID = compoundID;
-//   for (int iElem = 0; iElem < nbElems; iElem++) {
-//     if(theAlgo->computeCanceled())
-//       return false;
-//     for (int iNode = 0; iNode < 4; iNode++) {
-//       ID = strtol(tetraPtr, &tetraPtr, 10);
-//       itOnNode = theGhs3dIdToNodeMap.find(ID);
-//       node[ iNode ] = itOnNode->second;
-//       nodeID[ iNode ] = ID;
-//     }
-//     // We always run MG-Tetra with "to mesh holes"==TRUE but we must not create
-//     // tetras within holes depending on hypo option,
-//     // so we first check if aTet is inside a hole and then create it 
-//     //aTet = theMeshDS->AddVolume( node[1], node[0], node[2], node[3] );
-//     ghs3dShapeID = 0; // domain ID
-//     if ( nbTriangle > 1 ) {
-//       shapeID = HOLE_ID; // negative shapeID means not to create tetras if !toMeshHoles
-//       ghs3dShapeID = strtol(shapePtr, &shapePtr, 10) - IdShapeRef;
-//       if ( tabID[ ghs3dShapeID ] == 0 ) {
-//         TopAbs_State state;
-//         aSolid = findShape(node, aSolid, tabShape, tabBox, nbShape, &state);
-//         if ( toMeshHoles || state == TopAbs_IN )
-//           shapeID = theMeshDS->ShapeToIndex( aSolid );
-//         tabID[ ghs3dShapeID ] = shapeID;
-//       }
-//       else
-//         shapeID = tabID[ ghs3dShapeID ];
-//     }
-//     else if ( nbShape > 1 ) {
-//       // Case where nbTriangle == 1 while nbShape == 2 encountered
-//       // with compound of 2 boxes and "To mesh holes"==False,
-//       // so there are no subdomains specified for each tetrahedron.
-//       // Try to guess a solid by a node already bound to shape
-//       shapeID = 0;
-//       for ( int i=0; i<4 && shapeID==0; i++ ) {
-//         if ( nodeAssigne[ nodeID[i] ] == 1 &&
-//              node[i]->GetPosition()->GetTypeOfPosition() == SMDS_TOP_3DSPACE &&
-//              node[i]->getshapeId() > 1 )
-//         {
-//           shapeID = node[i]->getshapeId();
-//         }
-//       }
-//       if ( shapeID==0 ) {
-//         aSolid = findShape(node, aSolid, tabShape, tabBox, nbShape);
-//         shapeID = theMeshDS->ShapeToIndex( aSolid );
-//       }
-//     }
-//     // set new nodes and tetrahedron onto the shape
-//     for ( int i=0; i<4; i++ ) {
-//       if ( nodeAssigne[ nodeID[i] ] == 0 ) {
-//         if ( shapeID != HOLE_ID )
-//           theMeshDS->SetNodeInVolume( node[i], shapeID );
-//         nodeAssigne[ nodeID[i] ] = shapeID;
-//       }
-//     }
-//     if ( toMeshHoles || shapeID != HOLE_ID ) {
-//       aTet = theHelper.AddVolume( node[1], node[0], node[2], node[3],
-//                                   /*id=*/0, /*force3d=*/false);
-//       theMeshDS->SetMeshElementOnShape( aTet, shapeID );
-//       if ( toMakeGroupsOfDomains )
-//       {
-//         if ( int( elemsOfDomain.size() ) < ghs3dShapeID+1 )
-//           elemsOfDomain.resize( ghs3dShapeID+1 );
-//         elemsOfDomain[ ghs3dShapeID ].push_back( aTet );
-//       }
-//     }
-// #ifdef _DEBUG_
-//     shapeIDs.insert( shapeID );
-// #endif
-//   }
-//   if ( toMakeGroupsOfDomains )
-//     makeDomainGroups( elemsOfDomain, &theHelper );
-  
-//   // Add enforced elements
-//   GHS3DPlugin_Hypothesis::TIDSortedElemGroupMap::const_iterator elemIt;
-//   const SMDS_MeshElement* anElem;
-//   SMDS_ElemIteratorPtr itOnEnfElem;
-//   map<int,int>::const_iterator itOnMap;
-//   shapeID = compoundID;
-//   // Enforced edges
-//   if (theEnforcedEdges.size()) {
-//     (theEnforcedEdges.size() <= 1) ? tmpStr = " enforced edge" : " enforced edges";
-//     std::cout << "Add " << theEnforcedEdges.size() << tmpStr << std::endl;
-//     std::vector< const SMDS_MeshNode* > node( 2 );
-//     // Iterate over the enforced edges
-//     for(elemIt = theEnforcedEdges.begin() ; elemIt != theEnforcedEdges.end() ; ++elemIt) {
-//       anElem = elemIt->first;
-//       bool addElem = true;
-//       itOnEnfElem = anElem->nodesIterator();
-//       for ( int j = 0; j < 2; ++j ) {
-//         int aNodeID = itOnEnfElem->next()->GetID();
-//         itOnMap = theNodeId2NodeIndexMap.find(aNodeID);
-//         if (itOnMap != theNodeId2NodeIndexMap.end()) {
-//           itOnNode = theGhs3dIdToNodeMap.find((*itOnMap).second);
-//           if (itOnNode != theGhs3dIdToNodeMap.end()) {
-//             node.push_back((*itOnNode).second);
-// //             shapeID =(*itOnNode).second->getshapeId();
-//           }
-//           else
-//             addElem = false;
-//         }
-//         else
-//           addElem = false;
-//       }
-//       if (addElem) {
-//         aTet = theHelper.AddEdge( node[0], node[1], 0,  false);
-//         theMeshDS->SetMeshElementOnShape( aTet, shapeID );
-//       }
-//     }
-//   }
-//   // Enforced faces
-//   if (theEnforcedTriangles.size()) {
-//     (theEnforcedTriangles.size() <= 1) ? tmpStr = " enforced triangle" : " enforced triangles";
-//     std::cout << "Add " << theEnforcedTriangles.size() << " enforced triangles" << std::endl;
-//     std::vector< const SMDS_MeshNode* > node( 3 );
-//     // Iterate over the enforced triangles
-//     for(elemIt = theEnforcedTriangles.begin() ; elemIt != theEnforcedTriangles.end() ; ++elemIt) {
-//       anElem = elemIt->first;
-//       bool addElem = true;
-//       itOnEnfElem = anElem->nodesIterator();
-//       for ( int j = 0; j < 3; ++j ) {
-//         int aNodeID = itOnEnfElem->next()->GetID();
-//         itOnMap = theNodeId2NodeIndexMap.find(aNodeID);
-//         if (itOnMap != theNodeId2NodeIndexMap.end()) {
-//           itOnNode = theGhs3dIdToNodeMap.find((*itOnMap).second);
-//           if (itOnNode != theGhs3dIdToNodeMap.end()) {
-//             node.push_back((*itOnNode).second);
-// //             shapeID =(*itOnNode).second->getshapeId();
-//           }
-//           else
-//             addElem = false;
-//         }
-//         else
-//           addElem = false;
-//       }
-//       if (addElem) {
-//         aTet = theHelper.AddFace( node[0], node[1], node[2], 0,  false);
-//         theMeshDS->SetMeshElementOnShape( aTet, shapeID );
-//       }
-//     }
-//   }
-
-//   // Remove nodes of tetras inside holes if !toMeshHoles
-//   if ( !toMeshHoles ) {
-//     itOnNode = theGhs3dIdToNodeMap.find( nbInputNodes );
-//     for ( ; itOnNode != theGhs3dIdToNodeMap.end(); ++itOnNode) {
-//       ID = itOnNode->first;
-//       if ( nodeAssigne[ ID ] == HOLE_ID )
-//         theMeshDS->RemoveFreeNode( itOnNode->second, 0 );
-//     }
-//   }
-
-  
-//   if ( nbElems ) {
-//     (nbElems <= 1) ? tmpStr = " tetrahedra" : " tetrahedrons";
-//     cout << nbElems << tmpStr << " have been associated to " << nbShape;
-//     (nbShape <= 1) ? tmpStr = " shape" : " shapes";
-//     cout << tmpStr << endl;
-//   }
-// #ifdef WIN32
-//   UnmapViewOfFile(mapPtr);
-//   CloseHandle(hMapObject);
-//   CloseHandle(fd);
-// #else
-//   munmap(mapPtr, length);
-// #endif
-//   close(fileOpen);
-
-//   delete [] tab;
-//   delete [] tabID;
-//   delete [] nodeID;
-//   delete [] coord;
-//   delete [] node;
-//   delete [] nodeAssigne;
-
-// #ifdef _DEBUG_
-//   shapeIDs.erase(-1);
-//   if ( shapeIDs.size() != nbShape ) {
-//     (shapeIDs.size() <= 1) ? tmpStr = " solid" : " solids";
-//     std::cout << "Only " << shapeIDs.size() << tmpStr << " of " << nbShape << " found" << std::endl;
-//     for (int i=0; i<nbShape; i++) {
-//       shapeID = theMeshDS->ShapeToIndex( tabShape[i] );
-//       if ( shapeIDs.find( shapeID ) == shapeIDs.end() )
-//         std::cout << "  Solid #" << shapeID << " not found" << std::endl;
-//     }
-//   }
-// #endif
-
-//   return true;
-// }
-
-
 //=============================================================================
 /*!
  *Here we are going to use the MG-Tetra mesher with geometry
@@ -3570,10 +1830,14 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh&         theMesh,
 
   _compute_canceled = false;
 
-  system( cmd.ToCString() ); // run
+  int err = system( cmd.ToCString() ); // run
 
-  std::cout << std::endl;
-  std::cout << "End of MG-Tetra execution !" << std::endl;
+  std::string errStr;
+  if ( err )
+    errStr = SMESH_Comment("system(mg-tetra.exe ...) command failed with error: ")
+      << strerror( errno );
+  else
+    std::cout << std::endl << "End of MG-Tetra execution !" << std::endl;
 
   // --------------
   // read a result
@@ -3644,8 +1908,8 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh&         theMesh,
   {
     // the log file is empty
     removeFile( aLogFileName );
-    INFOS( "MG-Tetra Error, command '" << cmd.ToCString() << "' failed" );
-    error(COMPERR_ALGO_FAILED, "mg-tetra.exe: command not found" );
+    INFOS( "MG-Tetra Error, " << errStr);
+    error(COMPERR_ALGO_FAILED, errStr);
   }
 
   if ( !_keepFiles ) {
@@ -3839,10 +2103,14 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh&         theMesh,
 
   _compute_canceled = false;
 
-  system( cmd.ToCString() ); // run
+  int err = system( cmd.ToCString() ); // run
 
-  std::cout << std::endl;
-  std::cout << "End of MG-Tetra execution !" << std::endl;
+  std::string errStr;
+  if ( err )
+    errStr = SMESH_Comment("system(mg-tetra.exe ...) command failed with error: ")
+      << strerror( errno );
+  else
+    std::cout << std::endl << "End of MG-Tetra execution !" << std::endl;
 
   // --------------
   // read a result
@@ -3885,8 +2153,8 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh&         theMesh,
   else {
     // the log file is empty
     removeFile( aLogFileName );
-    INFOS( "MG-Tetra Error, command '" << cmd.ToCString() << "' failed" );
-    error(COMPERR_ALGO_FAILED, "mg-tetra.exe: command not found" );
+    INFOS( "MG-Tetra Error, " << errStr);
+    error(COMPERR_ALGO_FAILED, errStr);
   }
 
   if ( !_keepFiles )
@@ -4549,7 +2817,7 @@ const SMDS_MeshElement* _Ghs2smdsConvertor::getElement(const vector<int>& ghsNod
       nodes[ i ] = in->second;
     }
     else {
-      if ( ghsNode < 1 || ghsNode > _nodeByGhsId->size() )
+      if ( ghsNode < 1 || ghsNode > (int)_nodeByGhsId->size() )
         return 0;
       nodes[ i ] = (*_nodeByGhsId)[ ghsNode-1 ];
     }