]> SALOME platform Git repositories - plugins/ghs3dplugin.git/commitdiff
Salome HOME
- Fix of bugs
authorgdd <gdd>
Sun, 6 Mar 2011 20:06:03 +0000 (20:06 +0000)
committergdd <gdd>
Sun, 6 Mar 2011 20:06:03 +0000 (20:06 +0000)
- Now .meshb files can be read
- New IDL function to test reading of GMF .mesh files:
bool importGMFMesh(const char* fileName)
- In .smesh file, add entries in keywords "RequiredVertices", "RequiredTriangles" and "RequiredQuadrangulars"

configure.ac
idl/GHS3DPlugin_Algorithm.idl
src/GHS3DPlugin/GHS3DPlugin_GHS3D.cxx
src/GHS3DPlugin/GHS3DPlugin_GHS3D.hxx
src/GHS3DPlugin/GHS3DPlugin_GHS3D_i.cxx
src/GHS3DPlugin/GHS3DPlugin_GHS3D_i.hxx

index ce67fd53146bea414b1f516053dfbfd4f54604cb..5bf9edfe0f64c9963047069a43fbfa81f629200c 100644 (file)
@@ -353,7 +353,7 @@ echo
 
 CHECK_GHS3D
 if test "${GHS3D_ok}" = "yes"; then
-        GHS3D_VERSION=`ghs3d --help |grep "TETMESH-GHS3D SOFTWARE"|awk '{print $3}'|awk -F- '{print $1}'|awk -F. '{print $1$2}'`
+        GHS3D_VERSION=`ghs3d -u |grep "TETMESH-GHS3D SOFTWARE"|awk '{print $3}'|awk -F- '{print $1}'|awk -F. '{print $1$2}'`
         AC_DEFINE_UNQUOTED(GHS3D_VERSION,${GHS3D_VERSION})
 fi
 
index 9c22a44d6e03caa38b8e7cff4f0c9caf69820396..99db25e9edc99ab0ab4905ae11350d0f6961f8ef 100644 (file)
@@ -46,6 +46,7 @@ module GHS3DPlugin
    */
   interface GHS3DPlugin_GHS3D : SMESH::SMESH_3D_Algo
   {
+    boolean importGMFMesh(in string aGMFFileName);
   };
 
   /*!
index 64e1cddca43786149f2eba6e9b30a8db0196daac..294179158387f9fe362b8155f02a587045a8044b 100644 (file)
@@ -33,11 +33,13 @@ extern "C"
 
 #include <Basics_Utils.hxx>
 
-#include "SMESH_Gen.hxx"
+//#include "SMESH_Gen.hxx"
+#include <SMESH_Client.hxx>
 #include "SMESH_Mesh.hxx"
 #include "SMESH_Comment.hxx"
 #include "SMESH_MesherHelper.hxx"
 #include "SMESH_MeshEditor.hxx"
+#include "SMESH_OctreeNode.hxx"
 
 #include "SMDS_MeshElement.hxx"
 #include "SMDS_MeshNode.hxx"
@@ -256,14 +258,239 @@ static char* readMapIntLine(char* ptr, int tab[]) {
 //   }
 //   return nbShape;
 // }
-//     Ok = writeGMFFile(aGMFFileName, aRequiredVerticesFileName, aSolFileName, &theMesh, *proxyMesh, 
-//                       aNodeByGhs3dId,
-//                       enforcedNodes, enforcedEdges, enforcedTriangles, enforcedQuadrangles,
-//                       enforcedVertices);
-
-static bool writeGMFFile(const TCollection_AsciiString&   theMeshFileName,
-                         const TCollection_AsciiString&   theRequiredVerticesFileName,
-                         const TCollection_AsciiString&   theSolFileName,
+
+//=======================================================================
+//function : readGMFFile
+//purpose  :
+//=======================================================================
+
+
+static bool readGMFFile(const char* theFile, SMESH_MesherHelper*   theHelper,
+                        TIDSortedNodeSet &                  theEnforcedNodes,
+                        TIDSortedElemSet &              theEnforcedTriangles,
+                        TIDSortedElemSet &             theEnforcedQuadrangles)
+{
+  SMESHDS_Mesh* theMesh = theHelper->GetMeshDS();
+
+  // ---------------------------------
+  // Read generated elements and nodes
+  // ---------------------------------
+
+//  std::string token;
+  int nbElem = 0, nbRef = 0;
+  int aGMFNodeID = 0, shapeID;
+  int *nodeAssigne;
+  std::map <GmfKwdCod,int> tabRef;
+  SMDS_MeshNode** GMFNode;
+
+//  int nbEnfTri = theEnforcedTriangles.size();
+//  int nbEnfQuad = theEnforcedQuadrangles.size();
+
+  tabRef[GmfVertices]       = 3;
+  tabRef[GmfCorners]        = 1;
+  tabRef[GmfEdges]          = 2;
+  tabRef[GmfRidges]         = 1;
+  tabRef[GmfTriangles]      = 3;
+  tabRef[GmfQuadrilaterals] = 4;
+  tabRef[GmfTetrahedra]     = 4;
+  tabRef[GmfHexahedra]      = 8;
+
+  theHelper->GetMesh()->Clear();
+
+  int ver, dim;
+  MESSAGE("Read " << theFile << " file");
+  int InpMsh = GmfOpenMesh(theFile, GmfRead, &ver, &dim);
+  if (!InpMsh)
+    return false;
+
+  int nbVertices = GmfStatKwd(InpMsh, GmfVertices);
+  GMFNode = new SMDS_MeshNode*[ nbVertices + 1 ];
+  nodeAssigne = new int[ nbVertices + 1 ];
+
+  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]];
+
+    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;
+//        TIDSortedNodeSet theEnforcedNodesCopy = theEnforcedNodes;
+//        SMESH_MeshEditor::TListOfListOfNodes aGroupsOfNodes;
+        if (ver == GmfFloat) {
+          GmfGetLin(InpMsh, token, &VerTab_f[nbElem][0], &VerTab_f[nbElem][1], &VerTab_f[nbElem][2], &dummy);
+          aGMFNode = theMesh->AddNode(VerTab_f[nbElem][0], VerTab_f[nbElem][1], VerTab_f[nbElem][2]);
+//          theEnforcedNodesCopy.insert(aGMFNode);
+//          if (!theEnforcedNodesCopy.insert(aGMFNode).second)
+//            std::cout << "No added into theEnforcedNodesCopy: " << aGMFNode;
+//          SMESH_OctreeNode::FindCoincidentNodes ( theEnforcedNodesCopy, &aGroupsOfNodes, 1e-5);
+        }
+        else {
+          GmfGetLin(InpMsh, token, &VerTab_d[nbElem][0], &VerTab_d[nbElem][1], &VerTab_d[nbElem][2], &dummy);
+          aGMFNode = theMesh->AddNode(VerTab_d[nbElem][0], VerTab_d[nbElem][1], VerTab_d[nbElem][2]);
+//          theEnforcedNodesCopy.insert(aGMFNode);
+//          if (!theEnforcedNodesCopy.insert(aGMFNode).second)
+//            std::cout << "No added into theEnforcedNodesCopy: " << aGMFNode;
+//          SMESH_OctreeNode::FindCoincidentNodes ( theEnforcedNodesCopy, &aGroupsOfNodes, 1e-5);
+        }
+        GMFNode[ aGMFID ] = aGMFNode;
+        nodeAssigne[ aGMFID ] = 0;
+//        if (aGroupsOfNodes.size()) {
+//          std::cout << "Coincident node found when adding " << aGMFNode;
+//          SMESH_MeshEditor::TListOfListOfNodes::iterator grIt = aGroupsOfNodes.begin();
+//          for ( ; grIt != aGroupsOfNodes.end(); grIt++) {
+//            list<const SMDS_MeshNode*>& nodes = *grIt;
+//            list<const SMDS_MeshNode*>::iterator nIt = nodes.begin();
+//            for ( ; nIt != nodes.end(); nIt++ )
+//              std::cout << *nIt;
+//          }
+////          theMesh->RemoveNode(aGMFNode);
+//        }
+      }
+    }
+    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], &dummy);
+    }
+    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], &dummy);
+    }
+    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], &dummy);
+    }
+    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], &dummy);
+    }
+    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], &dummy);
+    }
+
+    switch (token) {
+    case GmfCorners:
+    case GmfRidges:
+    case GmfEdges:
+    case GmfTriangles:
+    case GmfQuadrilaterals:
+    case GmfTetrahedra:
+    case GmfHexahedra: {
+      std::vector< SMDS_MeshNode* > node( nbRef );
+      std::vector< int >          nodeID( nbRef );
+      std::vector< SMDS_MeshNode* > enfNode( 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 GmfEdges:
+          theHelper->AddEdge( node[0], node[1] ); break;
+        case GmfTriangles: {
+          theMesh->AddFace( node[0], node[1], node[2]);
+          // Enforced triangles
+//          for ( int iEnfElem = nbElem; iEnfElem < nbElem+nbEnfTri; iEnfElem++ )
+//          {
+//            for ( int iRef = 0; iRef < nbRef; iRef++ )
+//            {
+//              aGMFNodeID = id[iEnfElem*tabRef[token]+iRef]; // read nbRef aGMFNodeID
+//              enfNode  [ iRef ] = GMFNode[ aGMFNodeID ];
+//              nodeAssigne[ aGMFNodeID] = 1;
+//            }
+//            theMesh->AddFace( enfNode[0], enfNode[1], enfNode[2]);
+//          }
+          break;
+        }
+        case GmfQuadrilaterals: {
+          theMesh->AddFace( node[0], node[1], node[2], node[3] );
+          // Enforced Quadrilaterals
+//          for ( int iEnfElem = nbElem+nbEnfTri; iEnfElem < nbElem+nbEnfTri+nbEnfQuad; iEnfElem++ )
+//          {
+//            for ( int iRef = 0; iRef < nbRef; iRef++ )
+//            {
+//              aGMFNodeID = id[iEnfElem*tabRef[token]+iRef]; // read nbRef aGMFNodeID
+//              enfNode  [ iRef ] = GMFNode[ aGMFNodeID ];
+//              nodeAssigne[ aGMFNodeID] = 1;
+//            }
+//            theMesh->AddFace( enfNode[0], enfNode[1], enfNode[2], enfNode[3]);
+//          }
+          break;
+        }
+        case GmfTetrahedra:
+          theHelper->AddVolume( node[0], node[1], node[2], node[3] ); break;
+        case GmfHexahedra:
+          theHelper->AddVolume( node[0], node[3], node[2], node[1],
+                                node[4], node[7], node[6], node[5] ); break;
+        default: continue;
+        }
+        if ( token == GmfTriangles || token == GmfQuadrilaterals ) // "Quadrilaterals" and "Triangles"
+          for ( int iRef = 0; iRef < nbRef; iRef++ )
+            nodeAssigne[ nodeID[ iRef ]] = 1;
+      }
+      break;
+    }
+    }
+  }
+  cout << std::endl;
+
+  shapeID = theHelper->GetSubShapeID();
+  for ( int i = 0; i < nbVertices; ++i )
+    if ( !nodeAssigne[ i+1 ])
+      theMesh->SetNodeInVolume( GMFNode[ i+1 ], shapeID );
+
+  GmfCloseMesh(InpMsh);
+  delete [] GMFNode;
+  delete [] nodeAssigne;
+  return true;
+}
+
+static bool writeGMFFile(const char*   theMeshFileName,
+                         const char*   theRequiredFileName,
+                         const char*   theSolFileName,
                          const SMESH_ProxyMesh&           theProxyMesh,
                          SMESH_Mesh *                     theMesh,
                          vector <const SMDS_MeshNode*> &  theNodeByGhs3dId,
@@ -275,7 +502,7 @@ static bool writeGMFFile(const TCollection_AsciiString&   theMeshFileName,
                          GHS3DPlugin_Hypothesis::TEnforcedVertexValues & theEnforcedVertices)
 {
   MESSAGE("writeGMFFile");
-  int idx;
+  int idx, idxRequired, idxSol;
   const int dummyint = 0;
   GHS3DPlugin_Hypothesis::TEnforcedVertexValues::const_iterator vertexIt;
   std::vector<double> enfVertexSizes;
@@ -288,10 +515,10 @@ static bool writeGMFFile(const TCollection_AsciiString&   theMeshFileName,
   auto_ptr< SMESH_ElementSearcher > pntCls ( SMESH_MeshEditor( theMesh ).GetElementSearcher());
   
   int nbEnforcedVertices = theEnforcedVertices.size();
-  int nbEnforcedNodes    = theEnforcedNodes.size();
-  int nbEnforcedEdges       = theEnforcedEdges.size();
-  int nbEnforcedTriangles   = theEnforcedTriangles.size();
-  int nbEnforcedQuadrangles = theEnforcedQuadrangles.size();
+//  int nbEnforcedNodes    = theEnforcedNodes.size();
+//  int nbEnforcedEdges       = theEnforcedEdges.size();
+//  int nbEnforcedTriangles   = theEnforcedTriangles.size();
+//  int nbEnforcedQuadrangles = theEnforcedQuadrangles.size();
   
   // count faces
   int nbFaces = theProxyMesh.NbFaces();
@@ -299,7 +526,7 @@ static bool writeGMFFile(const TCollection_AsciiString&   theMeshFileName,
   if ( nbFaces == 0 )
     return false;
   
-  idx = GmfOpenMesh(theMeshFileName.ToCString(), GmfWrite, 3, 3);
+  idx = GmfOpenMesh(theMeshFileName, GmfWrite, 3, 3);
   if (!idx)
     return false;
   
@@ -435,7 +662,7 @@ static bool writeGMFFile(const TCollection_AsciiString&   theMeshFileName,
   
   
   /* ========================== NODES ========================== */
-  vector<const SMDS_MeshNode*> theOrderedNodes;
+  vector<const SMDS_MeshNode*> theOrderedNodes, theRequiredNodes;
   std::set< std::vector<double> > nodesCoords;
   vector<const SMDS_MeshNode*>::const_iterator ghs3dNodeIt = theNodeByGhs3dId.begin();
   vector<const SMDS_MeshNode*>::const_iterator after  = theNodeByGhs3dId.end();
@@ -479,11 +706,12 @@ static bool writeGMFFile(const TCollection_AsciiString&   theMeshFileName,
     
     nodesCoords.insert(coords);
     theOrderedNodes.push_back(node);
+    theRequiredNodes.push_back(node);
   }
   // Iterate over the enforced nodes given by enforced elements
   ghs3dNodeIt = theEnforcedNodeByGhs3dId.begin();
   after  = theEnforcedNodeByGhs3dId.end();
-  std::cout << theEnforcedNodes.size() << " nodes from enforced elements ..." << std::endl;
+  std::cout << theEnforcedNodeByGhs3dId.size() << " nodes from enforced elements ..." << std::endl;
   for ( ; ghs3dNodeIt != after; ++ghs3dNodeIt )
   {
     const SMDS_MeshNode* node = *ghs3dNodeIt;
@@ -502,18 +730,134 @@ static bool writeGMFFile(const TCollection_AsciiString&   theMeshFileName,
     
     nodesCoords.insert(coords);
     theOrderedNodes.push_back(node);
+    theRequiredNodes.push_back(node);
   }
   
-  
-  GmfSetKwd(idx, GmfVertices, theOrderedNodes.size());
-//   std::set< std::vector<double> >::const_iterator coordsIt = nodesCoords.begin();
+  int requiredNodes = theRequiredNodes.size();
+  int solSize = 0;
+  std::vector<std::vector<double> > ReqVerTab;
+  if (nbEnforcedVertices) {
+//    ReqVerTab.clear();
+    std::cout << theEnforcedVertices.size() << " nodes from enforced vertices ..." << std::endl;
+    // Iterate over the enforced vertices
+    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);
+      TopAbs_State result = pntCls->GetPointState( myPoint );
+      if ( result != TopAbs_IN )
+        continue;
+      std::vector<double> coords;
+      coords.push_back(x);
+      coords.push_back(y);
+      coords.push_back(z);
+      ReqVerTab.push_back(coords);
+      enfVertexSizes.push_back(vertexIt->second);
+      solSize++;
+    }
+  }
+
+  // GmfVertices
+  std::cout << "Begin writting required nodes in GmfVertices" << std::endl;
+  GmfSetKwd(idx, GmfVertices, theOrderedNodes.size()+solSize);
   for (ghs3dNodeIt = theOrderedNodes.begin();ghs3dNodeIt != theOrderedNodes.end();++ghs3dNodeIt)
     GmfSetLin(idx, GmfVertices, (*ghs3dNodeIt)->X(), (*ghs3dNodeIt)->Y(), (*ghs3dNodeIt)->Z(), 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);
+  }
+  std::cout << "End writting required nodes in GmfVertices" << std::endl;
+
+  if (requiredNodes + solSize) {
+    GmfSetKwd(idx, GmfRequiredVertices, requiredNodes+solSize);
+    if (requiredNodes) {
+      std::cout << "Begin writting required nodes in GmfRequiredVertices" << std::endl;
+      int startId = theOrderedNodes.size()-requiredNodes+1;
+      std::cout << "startId: " << startId << std::endl;
+      for (int i=0;i<requiredNodes;i++)
+        GmfSetLin(idx, GmfRequiredVertices, startId+i);
+      std::cout << "End writting required nodes in GmfRequiredVertices" << std::endl;
+    }
+    if (solSize) {
+      std::cout << "Begin writting required vertices in GmfRequiredVertices" << std::endl;
+      int startId = theOrderedNodes.size()+1;
+      std::cout << "startId: " << startId << std::endl;
+      for (int i=0;i<solSize;i++)
+        GmfSetLin(idx, GmfRequiredVertices, startId+i);
+      std::cout << "End writting required vertices in GmfRequiredVertices" << std::endl;
+
+      std::cout << "Begin writting in sol file" << std::endl;
+      idxSol = GmfOpenMesh(theSolFileName, GmfWrite, 3, 3);
+      if (!idxSol) {
+        GmfCloseMesh(idx);
+        if (idxRequired)
+          GmfCloseMesh(idxRequired);
+        return false;
+      }
+      int TypTab[] = {GmfSca};
+      GmfSetKwd(idxSol, GmfSolAtVertices, solSize, 1, TypTab);
+      for (int i=0;i<solSize;i++) {
+        std::cout << "enfVertexSizes.at(i): " << enfVertexSizes.at(i) << std::endl;
+        double solTab[] = {enfVertexSizes.at(i)};
+        GmfSetLin(idxSol, GmfSolAtVertices, solTab);
+      }
+      std::cout << "End writting in sol file" << std::endl;
+    }
+  }
+
+//  // GmfRequiredVertices + GmfSolAtVertices
+////  std::cout << "theRequiredNodes.size() + solSize: " << theRequiredNodes.size()+ solSize << std::endl;
+////  std::cout << "theRequiredNodes.size(): " << theRequiredNodes.size() << std::endl;
+//  std::cout << "solSize: " << solSize << std::endl;
+////  if (theRequiredNodes.size()+ solSize) {
+////    GmfSetKwd(idx, GmfRequiredVertices, theRequiredNodes.size()+solSize);
+////
+////    if (theRequiredNodes.size()) {
+////      std::cout << "Begin writting required nodes in GmfRequiredVertices" << std::endl;
+////      int startId = theOrderedNodes.size()-theRequiredNodes.size();
+////      std::cout << "startId: " << startId << std::endl;
+////      for (int i=1;i<=theRequiredNodes.size();i++)
+////        GmfSetLin(idx, GmfRequiredVertices, startId+i);
+////      std::cout << "End writting required nodes in GmfRequiredVertices" << std::endl;
+////    }
+//
+//    if (solSize) {
+//      std::cout << "Begin writting in sol file" << std::endl;
+//      GmfSetKwd(idx, GmfRequiredVertices, solSize);
+//      idxSol = GmfOpenMesh(theSolFileName, GmfWrite, 3, 3);
+//      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(idx, GmfRequiredVertices, theOrderedNodes.size()+i+1);
+//        GmfSetLin(idxSol, GmfSolAtVertices, solTab);
+////      GmfSetLin(idxRequired, GmfVertices, ReqVerTab[i][0], ReqVerTab[i][1], ReqVerTab[i][2], dummyint);
+//      }
+//      std::cout << "End writting in sol file" << std::endl;
+//    }
+//
+////  }
 
   int nedge[2], ntri[3], nquad[4];
   
+  int usedEnforcedEdges = 0;
   if (anEnforcedEdgeSet.size()) {
+//    idxRequired = GmfOpenMesh(theRequiredFileName, GmfWrite, 3, 3);
+//    if (!idxRequired)
+//      return false;
     GmfSetKwd(idx, GmfEdges, anEnforcedEdgeSet.size());
+//    GmfSetKwd(idxRequired, GmfEdges, anEnforcedEdgeSet.size());
     for(elemIt = anEnforcedEdgeSet.begin() ; elemIt != anEnforcedEdgeSet.end() ; ++elemIt) {
       elem = (*elemIt);
       nodeIt = elem->nodesIterator();
@@ -528,6 +872,16 @@ static bool writeGMFFile(const TCollection_AsciiString&   theMeshFileName,
         index++;
       }
       GmfSetLin(idx, GmfEdges, nedge[0], nedge[1], dummyint);
+//      GmfSetLin(idxRequired, GmfEdges, nedge[0], nedge[1], dummyint);
+      usedEnforcedEdges++;
+    }
+//    GmfCloseMesh(idxRequired);
+  }
+
+  if (usedEnforcedEdges) {
+    GmfSetKwd(idx, GmfRequiredEdges, usedEnforcedEdges);
+    for (int enfID=1;enfID<=usedEnforcedEdges;enfID++) {
+      GmfSetLin(idx, GmfRequiredEdges, enfID);
     }
   }
 
@@ -548,24 +902,34 @@ static bool writeGMFFile(const TCollection_AsciiString&   theMeshFileName,
       }
       GmfSetLin(idx, GmfTriangles, ntri[0], ntri[1], ntri[2], dummyint);
     }
-    for(elemIt = anEnforcedTriangleSet.begin() ; elemIt != anEnforcedTriangleSet.end() ; ++elemIt) {
-      elem = (*elemIt);
-      nodeIt = elem->nodesIterator();
-      int index=0;
-      while ( nodeIt->more() ) {
-        // find GHS3D ID
-        const SMDS_MeshNode* node = castToNode( nodeIt->next() );
-        map< const SMDS_MeshNode*,int >::iterator it = anEnforcedNodeToGhs3dIdMap.find(node);
-        if (it == anEnforcedNodeToGhs3dIdMap.end())
-          throw "Node not found";
-        ntri[index] = it->second;
-        index++;
+    if (anEnforcedTriangleSet.size()) {
+      int usedEnforcedTriangles = 0;
+      for(elemIt = anEnforcedTriangleSet.begin() ; elemIt != anEnforcedTriangleSet.end() ; ++elemIt) {
+        elem = (*elemIt);
+        nodeIt = elem->nodesIterator();
+        int index=0;
+        while ( nodeIt->more() ) {
+          // find GHS3D ID
+          const SMDS_MeshNode* node = castToNode( nodeIt->next() );
+          map< const SMDS_MeshNode*,int >::iterator it = anEnforcedNodeToGhs3dIdMap.find(node);
+          if (it == anEnforcedNodeToGhs3dIdMap.end())
+            throw "Node not found";
+          ntri[index] = it->second;
+          index++;
+        }
+        GmfSetLin(idx, GmfTriangles, ntri[0], ntri[1], ntri[2], dummyint);
+        usedEnforcedTriangles++;
+      }
+      if (usedEnforcedTriangles) {
+        GmfSetKwd(idx, GmfRequiredTriangles, usedEnforcedTriangles);
+        for (int enfID=1;enfID<=usedEnforcedTriangles;enfID++)
+          GmfSetLin(idx, GmfRequiredTriangles, anElemSet.size()+enfID);
       }
-      GmfSetLin(idx, GmfTriangles, ntri[0], ntri[1], ntri[2], dummyint);
     }
   }
 
   if (anEnforcedQuadrangleSet.size()) {
+    int usedEnforcedQuadrilaterals = 0;
     GmfSetKwd(idx, GmfQuadrilaterals, anEnforcedQuadrangleSet.size());
     for(elemIt = anEnforcedQuadrangleSet.begin() ; elemIt != anEnforcedQuadrangleSet.end() ; ++elemIt) {
       elem = (*elemIt);
@@ -581,66 +945,28 @@ static bool writeGMFFile(const TCollection_AsciiString&   theMeshFileName,
         index++;
       }
       GmfSetLin(idx, GmfQuadrilaterals, nquad[0], nquad[1], nquad[2], nquad[3], dummyint);
+      usedEnforcedQuadrilaterals++;
     }
-  }
-  
-  GmfCloseMesh(idx);
-  
-  if (nbEnforcedVertices) {
-    std::vector<std::vector<double> > ReqVerTab;
-    ReqVerTab.clear();
-    std::vector<double> enfVertexSizes;
-    int solSize = 0;
-    std::cout << theEnforcedVertices.size() << " nodes from enforced vertices ..." << std::endl;
-    // Iterate over the enforced vertices
-    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);
-      TopAbs_State result = pntCls->GetPointState( myPoint );
-      if ( result != TopAbs_IN )
-        continue;
-      std::vector<double> coords;
-      coords.push_back(x);
-      coords.push_back(y);
-      coords.push_back(z);
-      ReqVerTab.push_back(coords);
-      enfVertexSizes.push_back(vertexIt->second);
-      solSize++;
-    }
-    
-    if (solSize) {
-      int idxRequired = GmfOpenMesh(theRequiredVerticesFileName.ToCString(), GmfWrite, 3, 3);
-      if (!idxRequired)
-        return false;
-      int idxSol = GmfOpenMesh(theSolFileName.ToCString(), GmfWrite, 3, 3);
-      if (!idxSol)
-        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);
+    if (usedEnforcedQuadrilaterals) {
+      GmfSetKwd(idx, GmfRequiredQuadrilaterals, usedEnforcedQuadrilaterals);
+      for (int enfID=1;enfID<=usedEnforcedQuadrilaterals;enfID++)
+        GmfSetLin(idx, GmfRequiredQuadrilaterals, enfID);
     }
   }
-  
+
+  GmfCloseMesh(idx);
+  if (idxRequired)
+    GmfCloseMesh(idxRequired);
+  if (idxSol)
+    GmfCloseMesh(idxSol);
   
   return true;
   
 }
 
-static bool writeGMFFile(const TCollection_AsciiString&   theMeshFileName,
-                         const TCollection_AsciiString&   theRequiredVerticesFileName,
-                         const TCollection_AsciiString&   theSolFileName,
+static bool writeGMFFile(const char*   theMeshFileName,
+                         const char*   theRequiredFileName,
+                         const char*   theSolFileName,
                          SMESH_MesherHelper&              theHelper,
                          const SMESH_ProxyMesh&           theProxyMesh,
                          map <int,int> &                  theSmdsToGhs3dIdMap,
@@ -660,7 +986,7 @@ static bool writeGMFFile(const TCollection_AsciiString&   theMeshFileName,
   SMDS_NodeIteratorPtr nodeIt;
   std::map<int,int> theNodeId2NodeIndexMap;
 
-  idx = GmfOpenMesh(theMeshFileName.ToCString(), GmfWrite, 3, 3);
+  idx = GmfOpenMesh(theMeshFileName, GmfWrite, 3, 3);
   if (!idx)
     return false;
   
@@ -777,10 +1103,10 @@ static bool writeGMFFile(const TCollection_AsciiString&   theMeshFileName,
     }
 
     if (solSize) {
-      int idxRequired = GmfOpenMesh(theRequiredVerticesFileName.ToCString(), GmfWrite, 3, 3);
+      int idxRequired = GmfOpenMesh(theRequiredFileName, GmfWrite, 3, 3);
       if (!idxRequired)
         return false;
-      int idxSol = GmfOpenMesh(theSolFileName.ToCString(), GmfWrite, 3, 3);
+      int idxSol = GmfOpenMesh(theSolFileName, GmfWrite, 3, 3);
       if (!idxSol)
         return false;
       
@@ -797,10 +1123,7 @@ static bool writeGMFFile(const TCollection_AsciiString&   theMeshFileName,
       GmfCloseMesh(idxSol);
     }
   }
-  
-  /* ========================== EDGES ========================== */
-  
-  
+
   
   /* ========================== FACES ========================== */
   
@@ -812,10 +1135,11 @@ static bool writeGMFFile(const TCollection_AsciiString&   theMeshFileName,
   SMDS_ElemIteratorPtr itOnSubMesh, itOnSubFace;
   const SMDS_MeshElement* aFace;
   map<int,int>::const_iterator itOnMap;
-  std::vector<std::vector<int> > tt, qt;
+  std::vector<std::vector<int> > tt, qt,et;
   tt.clear();
   qt.clear();
-  std::vector<int> att, aqt;
+  et.clear();
+  std::vector<int> att, aqt, aet;
   
   TopExp::MapShapes( theMeshDS->ShapeToMesh(), TopAbs_FACE, facesMap );
 
@@ -863,9 +1187,8 @@ static bool writeGMFFile(const TCollection_AsciiString&   theMeshFileName,
       }
     }
   }
-  
-  int nbEnforcedTriangles = theEnforcedTriangles.size();
-  if (nbEnforcedTriangles) {
+
+  if (theEnforcedTriangles.size()) {
     // Iterate over the enforced triangles
     for(elemIt = theEnforcedTriangles.begin() ; elemIt != theEnforcedTriangles.end() ; ++elemIt) {
       aFace = (*elemIt);
@@ -879,6 +1202,7 @@ static bool writeGMFFile(const TCollection_AsciiString&   theMeshFileName,
           att.push_back((*itOnMap).second);
         else {
           isOK = false;
+          theEnforcedTriangles.erase(elemIt);
           break;
         }
       }
@@ -917,9 +1241,8 @@ static bool writeGMFFile(const TCollection_AsciiString&   theMeshFileName,
       }
     }
   }
-  
-  int nbEnforcedQuadrangles = theEnforcedQuadrangles.size();
-  if (nbEnforcedQuadrangles) {
+
+  if (theEnforcedQuadrangles.size()) {
     // Iterate over the enforced triangles
     for(elemIt = theEnforcedQuadrangles.begin() ; elemIt != theEnforcedQuadrangles.end() ; ++elemIt) {
       aFace = (*elemIt);
@@ -933,11 +1256,12 @@ static bool writeGMFFile(const TCollection_AsciiString&   theMeshFileName,
           aqt.push_back((*itOnMap).second);
         else {
           isOK = false;
+          theEnforcedQuadrangles.erase(elemIt);
           break;
         }
       }
       if (isOK)
-        qt.push_back(att);
+        qt.push_back(aqt);
     }
   }
   
@@ -947,7 +1271,38 @@ static bool writeGMFFile(const TCollection_AsciiString&   theMeshFileName,
       GmfSetLin(idx, GmfQuadrilaterals, qt[i][0], qt[i][1], qt[i][2], qt[i][3], dummyint);
   }
   
-  
+
+  /* ========================== EDGES ========================== */
+
+  if (theEnforcedEdges.size()) {
+    // Iterate over the enforced edges
+    for(elemIt = theEnforcedEdges.begin() ; elemIt != theEnforcedEdges.end() ; ++elemIt) {
+      aFace = (*elemIt);
+      bool isOK = true;
+      itOnSubFace = aFace->nodesIterator();
+      aet.clear();
+      while ( itOnSubFace->more() ) {
+        int aNodeID = itOnSubFace->next()->GetID();
+        itOnMap = theNodeId2NodeIndexMap.find(aNodeID);
+        if (itOnMap != theNodeId2NodeIndexMap.end())
+          aet.push_back((*itOnMap).second);
+        else {
+          isOK = false;
+          theEnforcedEdges.erase(elemIt);
+          break;
+        }
+      }
+      if (isOK)
+        et.push_back(aet);
+    }
+  }
+
+  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);
+  }
+
   GmfCloseMesh(idx);
   return true;
 }
@@ -1651,7 +2006,7 @@ static bool writeFaces (ofstream &                      theFile,
   // Loop from 1 to NB_ELEMS
   //   NB_NODES NODE_NB_1 NODE_NB_2 ... (NB_NODES + 1) times: DUMMY_INT
 
-  int nbNodes, nbTriangles = 0;
+  int nbTriangles = 0;
   SMDS_ElemIteratorPtr nodeIt;
 
   const char* space    = "  ";
@@ -2130,14 +2485,14 @@ static bool writePoints (ofstream &                            theFile,
     nodesCoords.insert(coords);
   }
   
-  if (nbEnforcedNodes) {
-    std::cout << theEnforcedNodes.size() << " nodes from enforced nodes ..." << std::endl;
-    // Iterate over the enforced nodes
-    TIDSortedNodeSet::const_iterator enfNodeIt;
-    auto_ptr< SMESH_ElementSearcher > pntCls ( SMESH_MeshEditor( theMesh ).GetElementSearcher());
-    for(enfNodeIt = theEnforcedNodes.begin() ; enfNodeIt != theEnforcedNodes.end() ; ++enfNodeIt)
+  if (theEnforcedNodeByGhs3dId.size()) {
+    std::cout << theEnforcedNodeByGhs3dId.size() << " nodes from enforced elements ..." << std::endl;
+    // Iterate over the enforced nodes given by enforced elements
+    nodeIt = theEnforcedNodeByGhs3dId.begin();
+    after  = theEnforcedNodeByGhs3dId.end();
+    for ( ; nodeIt != after; ++nodeIt )
     {
-      node = *enfNodeIt;
+      node = *nodeIt;
       
       std::vector<double> coords;
       coords.push_back(node->X());
@@ -2148,14 +2503,9 @@ static bool writePoints (ofstream &                            theFile,
         std::cout << "Node at " << node->X()<<", " <<node->Y()<<", " <<node->Z() << " found" << std::endl;
         continue;
       }
-
+      
       if (theEnforcedVertices.find(coords) != theEnforcedVertices.end())
         continue;
-      // Test if point is inside shape to mesh
-      gp_Pnt myPoint(node->X(),node->Y(),node->Z());
-      TopAbs_State result = pntCls->GetPointState( myPoint );
-      if ( result != TopAbs_IN )
-        continue;
 
       // X Y Z DUMMY_INT
       theFile
@@ -2168,37 +2518,43 @@ static bool writePoints (ofstream &                            theFile,
       nodesCoords.insert(coords);
     }
   }
-  
-  if (theEnforcedNodeByGhs3dId.size()) {
-    std::cout << theEnforcedNodeByGhs3dId.size() << " nodes from enforced elements ..." << std::endl;
-    // Iterate over the enforced nodes given by enforced elements
-    nodeIt = theEnforcedNodeByGhs3dId.begin();
-    after  = theEnforcedNodeByGhs3dId.end();
-    for ( ; nodeIt != after; ++nodeIt )
+
+  auto_ptr< SMESH_ElementSearcher > pntCls ( SMESH_MeshEditor( theMesh ).GetElementSearcher());
+  if (nbEnforcedNodes) {
+    std::cout << theEnforcedNodes.size() << " nodes from enforced nodes ..." << std::endl;
+    // Iterate over the enforced nodes
+    TIDSortedNodeSet::const_iterator enfNodeIt;
+//    auto_ptr< SMESH_ElementSearcher > pntCls ( SMESH_MeshEditor( theMesh ).GetElementSearcher());
+    for(enfNodeIt = theEnforcedNodes.begin() ; enfNodeIt != theEnforcedNodes.end() ; ++enfNodeIt)
     {
-      node = *nodeIt;
-      
+      node = *enfNodeIt;
+
       std::vector<double> coords;
       coords.push_back(node->X());
       coords.push_back(node->Y());
       coords.push_back(node->Z());
-      
+
       if (nodesCoords.find(coords) != nodesCoords.end()) {
         std::cout << "Node at " << node->X()<<", " <<node->Y()<<", " <<node->Z() << " found" << std::endl;
         continue;
       }
-      
+
       if (theEnforcedVertices.find(coords) != theEnforcedVertices.end())
         continue;
+      // Test if point is inside shape to mesh
+      gp_Pnt myPoint(node->X(),node->Y(),node->Z());
+      TopAbs_State result = pntCls->GetPointState( myPoint );
+      if ( result != TopAbs_IN )
+        continue;
 
       // X Y Z DUMMY_INT
       theFile
-      << node->X() << space 
-      << node->Y() << space 
-      << node->Z() << space 
+      << node->X() << space
+      << node->Y() << space
+      << node->Z() << space
       << theNodeIDToSizeMap.find(node->GetID())->second << space
       << dummyint << std::endl;
-      
+
       nodesCoords.insert(coords);
     }
   }
@@ -2207,7 +2563,6 @@ static bool writePoints (ofstream &                            theFile,
     std::cout << theEnforcedVertices.size() << " nodes from enforced vertices ..." << std::endl;
     // Iterate over the enforced vertices
     GHS3DPlugin_Hypothesis::TEnforcedVertexValues::const_iterator vertexIt;
-    auto_ptr< SMESH_ElementSearcher > pntCls ( SMESH_MeshEditor( theMesh ).GetElementSearcher());
     for(vertexIt = theEnforcedVertices.begin() ; vertexIt != theEnforcedVertices.end() ; ++vertexIt) {
       double x = vertexIt->first[0];
       double y = vertexIt->first[1];
@@ -2978,7 +3333,8 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh&         theMesh,
         return false;
     }
 // #if GHS3D_VERSION >= 42
-    Ok = writeGMFFile(aGMFFileName, aRequiredVerticesFileName, aSolFileName, helper, *proxyMesh, 
+    Ok = writeGMFFile(aGMFFileName.ToCString(), aRequiredVerticesFileName.ToCString(), aSolFileName.ToCString(),
+                      helper, *proxyMesh,
                       aSmdsToGhs3dIdMap, aGhs3dIdToNodeMap,
                       enforcedNodes, enforcedEdges, enforcedTriangles, enforcedQuadrangles,
                       enforcedVertices);
@@ -3006,9 +3362,9 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh&         theMesh,
   }
   
   int nbEnforcedNodes = enforcedNodes.size();
-  int nbEnforcedEdges = enforcedEdges.size();
-  int nbEnforcedTriangles = enforcedTriangles.size();
-  int nbEnforcedQuadrangles = enforcedQuadrangles.size();
+//  int nbEnforcedEdges = enforcedEdges.size();
+//  int nbEnforcedTriangles = enforcedTriangles.size();
+//  int nbEnforcedQuadrangles = enforcedQuadrangles.size();
 
   // Write aSmdsToGhs3dIdMap to temp file
   TCollection_AsciiString aSmdsToGhs3dIdMapFileName;
@@ -3156,13 +3512,15 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh&         theMesh,
 
   TCollection_AsciiString aFacesFileName, aPointsFileName, aResultFileName;
   TCollection_AsciiString aBadResFileName, aBbResFileName, aLogFileName;
-  TCollection_AsciiString aGMFFileName, aRequiredVerticesFileName, aSolFileName;
+  TCollection_AsciiString aGMFFileName, aGMFVolFileName, aRequiredVerticesFileName, aSolFileName;
 #ifdef _DEBUG_
   aGMFFileName    = aGenericName + ".mesh"; // GMF mesh file
+  aGMFVolFileName = aGenericName + "Vol.mesh"; // GMF mesh file
   aRequiredVerticesFileName    = aGenericName + "_required.mesh"; // GMF required vertices mesh file
   aSolFileName    = aGenericName + "_required.sol"; // GMF solution file
 #else
   aGMFFileName    = aGenericName + ".meshb"; // GMF mesh file
+  aGMFVolFileName = aGenericName + "Vol.meshb"; // GMF mesh file
   aRequiredVerticesFileName    = aGenericName + "_required.meshb"; // GMF required vertices mesh file
   aSolFileName    = aGenericName + ".solb"; // GMF solution file
 #endif
@@ -3182,9 +3540,7 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh&         theMesh,
   ofstream aFacesFile  ( aFacesFileName.ToCString()  , ios::out);
   ofstream aPointsFile  ( aPointsFileName.ToCString()  , ios::out);
   bool Ok =
-    aFacesFile.rdbuf()->is_open() && aPointsFile.rdbuf()->is_open()
-                                  /*&& aGMFFile.rdbuf()->is_open()
-                                  && aSolFile.rdbuf()->is_open()*/;
+    aFacesFile.rdbuf()->is_open() && aPointsFile.rdbuf()->is_open();
 
   if (!Ok) {
     INFOS( "Can't write into " << aFacesFileName);
@@ -3200,7 +3556,6 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh&         theMesh,
   GHS3DPlugin_Hypothesis::TID2SizeMap nodeIDToSizeMap = GHS3DPlugin_Hypothesis::GetNodeIDToSizeMap(_hyp);
   int nbEnforcedVertices = enforcedVertices.size();
 
-
   vector <const SMDS_MeshNode*> aNodeByGhs3dId, anEnforcedNodeByGhs3dId;
   {
     SMESH_ProxyMesh::Ptr proxyMesh( new SMESH_ProxyMesh( theMesh ));
@@ -3212,7 +3567,8 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh&         theMesh,
     }
 
 // #if GHS3D_VERSION >= 42
-    Ok = writeGMFFile(aGMFFileName, aRequiredVerticesFileName, aSolFileName, *proxyMesh, &theMesh, 
+    Ok = writeGMFFile(aGMFFileName.ToCString(), aRequiredVerticesFileName.ToCString(), aSolFileName.ToCString(),
+                      *proxyMesh, &theMesh,
                       aNodeByGhs3dId, anEnforcedNodeByGhs3dId,
                       enforcedNodes, enforcedEdges, enforcedTriangles, enforcedQuadrangles,
                       enforcedVertices);
@@ -3226,10 +3582,18 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh&         theMesh,
 // #endif
   }  
   
+  TIDSortedNodeSet enforcedNodesFromEnforcedElem;
   int nbEnforcedNodes = enforcedNodes.size();
-  int nbEnforcedEdges = enforcedEdges.size();
-  int nbEnforcedTriangles = enforcedTriangles.size();
-  int nbEnforcedQuadrangles = enforcedQuadrangles.size();
+  for (int i=0;i<anEnforcedNodeByGhs3dId.size();i++) {
+    enforcedNodesFromEnforcedElem.insert(anEnforcedNodeByGhs3dId[i]);
+//    if  (!enforcedNodesFromEnforcedElem.insert(anEnforcedNodeByGhs3dId[i]).second)
+//      std::cout << "Node not inserted in enforcedNodesFromEnforcedElem: " << anEnforcedNodeByGhs3dId[i];
+//    else
+//      std::cout << "GHS3D ID " << i+1 << " " << anEnforcedNodeByGhs3dId[i];
+  }
+//  int nbEnforcedEdges = enforcedEdges.size();
+//  int nbEnforcedTriangles = enforcedTriangles.size();
+//  int nbEnforcedQuadrangles = enforcedQuadrangles.size();
   
 //   aGMFFile.close();
 //   aSolFile.close();
@@ -3255,9 +3619,9 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh&         theMesh,
   cmd += TCollection_AsciiString(" --required_vertices ") + aRequiredVerticesFileName;
   cmd += TCollection_AsciiString(" --out ") + aGenericName;
 #else
-  cmd += TCollection_AsciiString(" -f ") + aGenericName;  // file to read
+  cmd += TCollection_AsciiString(" -Om -f ") + aGenericName;  // file to read
 #endif
-  cmd += TCollection_AsciiString(" -Om 1>" ) + aLogFileName;  // dump into file
+  cmd += TCollection_AsciiString(" 1>" ) + aLogFileName;  // dump into file
 
   std::cout << std::endl;
   std::cout << "Ghs3d execution..." << std::endl;
@@ -3271,6 +3635,8 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh&         theMesh,
   // --------------
   // read a result
   // --------------
+  Ok = readGMFFile(aGMFFileName.ToCString(), aHelper, enforcedNodesFromEnforcedElem, enforcedTriangles, enforcedQuadrangles);
+
   int fileOpen;
   fileOpen = open( aResultFileName.ToCString(), O_RDONLY);
   if ( fileOpen < 0 ) {
@@ -3288,6 +3654,7 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh&         theMesh,
                          theMesh, theShape ,aNodeByGhs3dId, anEnforcedNodeByGhs3dId,
                          nbEnforcedVertices, nbEnforcedNodes, 
                          enforcedEdges, enforcedTriangles, enforcedQuadrangles );
+//    Ok = readGMFFile(aGMFVolFileName.ToCString(), aHelper, anEnforcedNodeByGhs3dId, enforcedTriangles, enforcedQuadrangles);
   }
   
   // ---------------------
@@ -3320,7 +3687,7 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh&         theMesh,
     removeFile( aBadResFileName );
     removeFile( aBbResFileName );
   }
-  
+
   return Ok;
 }
 
@@ -3900,3 +4267,10 @@ bool GHS3DPlugin_GHS3D::Evaluate(SMESH_Mesh& aMesh,
   return true;
 }
 
+bool GHS3DPlugin_GHS3D::importGMFMesh(const char* theGMFFileName, SMESH_Mesh& theMesh)
+{
+  SMESH_MesherHelper* helper = new SMESH_MesherHelper(theMesh );
+  TIDSortedElemSet dummyElemSet;
+  TIDSortedNodeSet dummyNodeSet;
+  return readGMFFile(theGMFFileName, helper, dummyNodeSet , dummyElemSet, dummyElemSet);
+}
index 2054a79469488f9517530e9ecac9b1e02af12469..906b6a92890a3f73e7adbc54b625f25eb66391f1 100644 (file)
@@ -27,6 +27,7 @@
 #define _GHS3DPlugin_GHS3D_HXX_
 
 #include "SMESH_3D_Algo.hxx"
+#include "SMESH_Gen.hxx"
 
 #include <map>
 #include <vector>
@@ -57,6 +58,8 @@ public:
   virtual bool Compute(SMESH_Mesh&         theMesh,
                        SMESH_MesherHelper* aHelper);
 
+  bool importGMFMesh(const char* aGMFFileName, SMESH_Mesh& aMesh);
+
 private:
 
   bool storeErrorDescription(const TCollection_AsciiString& logFile,
index c63525a0cd92e5a9ed4810172710cf04703d56a2..cee96775f74b40a058a7393391a711050edc6225 100644 (file)
 //
 #include "GHS3DPlugin_GHS3D_i.hxx"
 #include "SMESH_Gen.hxx"
+#include "SMESH_Mesh_i.hxx"
+#include "SMESH_Gen_i.hxx"
 #include "GHS3DPlugin_GHS3D.hxx"
+#include "SMESH_PythonDump.hxx"
 
 #include "utilities.h"
+#include <cstring>
 
 using namespace std;
 
@@ -80,3 +84,36 @@ GHS3DPlugin_GHS3D_i::~GHS3DPlugin_GHS3D_i()
   return ( ::GHS3DPlugin_GHS3D* )myBaseImpl;
 }
 
+//=============================================================================
+/*!
+ *  GHS3DPlugin_GHS3D_i::~GHS3DPlugin_GHS3D_i
+ *
+ *  Destructor
+ */
+//=============================================================================
+
+bool GHS3DPlugin_GHS3D_i::importGMFMesh(const char* theGMFFileName)
+{
+  MESSAGE( "GHS3DPlugin_GHS3D_i::importGMFMesh" );
+
+  SMESH::SMESH_Mesh_ptr theMesh = SMESH_Gen_i::GetSMESHGen()->CreateEmptyMesh();
+  SMESH_Gen_i::GetSMESHGen()->RemoveLastFromPythonScript(SMESH_Gen_i::GetSMESHGen()->GetCurrentStudy()->StudyId());
+  SALOMEDS::SObject_ptr theSMesh = SMESH_Gen_i::GetSMESHGen()->ObjectToSObject(SMESH_Gen_i::GetSMESHGen()->GetCurrentStudy(), theMesh);
+#ifdef WINNT
+#define SEP '\\'
+#else
+#define SEP '/'
+#endif
+  string strFileName (theGMFFileName);
+  strFileName = strFileName.substr(strFileName.rfind(SEP)+1);
+  strFileName.erase(strFileName.rfind('.'));
+  SMESH_Gen_i::GetSMESHGen()->SetName(theSMesh, strFileName.c_str());
+  SMESH_Mesh_i* meshServant = dynamic_cast<SMESH_Mesh_i*>( SMESH_Gen_i::GetSMESHGen()->GetServant( theMesh ).in() );
+  ASSERT( meshServant );
+  if ( meshServant ) {
+    bool res = GetImpl()->importGMFMesh(theGMFFileName, meshServant->GetImpl());
+    SMESH::TPythonDump() << "isDone = " << _this() << ".importGMFMesh( \"" << theGMFFileName << "\")";
+    return res;
+  }
+  return false;
+}
index e61fb45cdd7eef386e38189af9b23a355c2b9d59..9de897f9e2dffce7adfca13b4ae577c248568799 100644 (file)
@@ -49,6 +49,8 @@ public:
  
   // Get implementation
   ::GHS3DPlugin_GHS3D* GetImpl();
+
+  virtual bool importGMFMesh(const char* theGMFFileName);
 };
 
 #endif