]> SALOME platform Git repositories - plugins/hybridplugin.git/commitdiff
Salome HOME
Fix SetEnforcedMesh to work correctly with groups and groups on geom.
authorgdd <gdd>
Wed, 11 May 2011 18:06:56 +0000 (18:06 +0000)
committergdd <gdd>
Wed, 11 May 2011 18:06:56 +0000 (18:06 +0000)
src/GHS3DPlugin/GHS3DPlugin_GHS3D.cxx
src/GHS3DPlugin/GHS3DPlugin_Hypothesis.cxx
src/GHS3DPlugin/GHS3DPlugin_Hypothesis.hxx
src/GHS3DPlugin/GHS3DPlugin_Hypothesis_i.cxx

index e22d8acf18a9f0aa24fb6ac13f71674a7c812d00..6a7df364cac2503829f6a5d0c5bd6f609e0109d7 100644 (file)
@@ -1009,16 +1009,11 @@ static void updateMeshGroups(SMESH_Mesh* theMesh,
   while (grIt->more()) {
     SMESH_Group * group = grIt->next();
     if ( !group ) continue;
-    MESSAGE("Group: " << group->GetName());
     SMESHDS_GroupBase* groupDS = group->GetGroupDS();
     if ( !groupDS ) continue;
-    MESSAGE("group->SMDSGroup().GetType(): " << (groupDS->GetType()));
-    MESSAGE("group->SMDSGroup().GetType()==anElem->GetType(): " << (groupDS->GetType()==anElem->GetType()));
-    MESSAGE("currentEnfVertex->grpName.compare(group->GetStoreName())==0: " << (groupName.compare(group->GetName())==0));
     if ( groupDS->GetType()==anElem->GetType() && groupName.compare(group->GetName())==0) {
       SMESHDS_Group* aGroupDS = static_cast<SMESHDS_Group*>( groupDS );
       aGroupDS->SMDSGroup().Add(anElem);
-      MESSAGE("Elem ID added in group: " << anElem->GetID());
       groupDone = true;
       MESSAGE("Successfully added enforced element to existing group " << groupName);
       break;
@@ -1051,7 +1046,7 @@ static bool readGMFFile(const char*                     theFile,
                         TopoDS_Shape                    theSolid,
                         vector <const SMDS_MeshNode*> & theNodeByGhs3dId,
                         map<const SMDS_MeshNode*,int> & theNodeToGhs3dIdMap,
-                        std::map<std::vector<double>, std::string> & enfVerticesWithGroup,
+                        std::vector<std::string> &      aNodeGroupByGhs3dId,
                         std::vector<std::string> &      anEdgeGroupByGhs3dId,
                         std::vector<std::string> &      aFaceGroupByGhs3dId)
 {
@@ -1194,8 +1189,8 @@ static bool readGMFFile(const char*                     theFile,
           coords.push_back(x);
           coords.push_back(y);
           coords.push_back(z);
-          if (enfVerticesWithGroup.find(coords) != enfVerticesWithGroup.end())
-            updateMeshGroups(theHelper->GetMesh(), aGMFNode, enfVerticesWithGroup[coords]);
+          if (aGMFID-1 < aNodeGroupByGhs3dId.size() && !aNodeGroupByGhs3dId.at(aGMFID-1).empty())
+            updateMeshGroups(theHelper->GetMesh(), aGMFNode, aNodeGroupByGhs3dId.at(aGMFID-1));
         }
       }
     }
@@ -1285,7 +1280,8 @@ static bool readGMFFile(const char*                     theFile,
         case GmfEdges:
           if (fullyCreatedElement) {
             aCreatedElem = theHelper->AddEdge( node[0], node[1], /*id =*/0, /*force3d =*/false );
-            updateMeshGroups(theHelper->GetMesh(), aCreatedElem, anEdgeGroupByGhs3dId[iElem]);
+            if (!anEdgeGroupByGhs3dId[iElem].empty())
+              updateMeshGroups(theHelper->GetMesh(), aCreatedElem, anEdgeGroupByGhs3dId[iElem]);
           }
           break;
         case GmfTriangles:
@@ -1293,7 +1289,8 @@ static bool readGMFFile(const char*                     theFile,
             aCreatedElem = theHelper->AddFace( node[0], node[1], node[2], /*id =*/0, /*force3d =*/false );
             for ( int iRef = 0; iRef < nbRef; iRef++ )
               nodeAssigne[ nodeID[ iRef ]] = 1;
-            updateMeshGroups(theHelper->GetMesh(), aCreatedElem, aFaceGroupByGhs3dId[iElem]);
+            if (!aFaceGroupByGhs3dId[iElem].empty())
+              updateMeshGroups(theHelper->GetMesh(), aCreatedElem, aFaceGroupByGhs3dId[iElem]);
           }
           break;
         case GmfQuadrilaterals:
@@ -1366,11 +1363,13 @@ static bool writeGMFFile(const char*                                     theMesh
                          std::vector <const SMDS_MeshNode*> &            theNodeByGhs3dId,
                          std::vector <const SMDS_MeshNode*> &            theEnforcedNodeByGhs3dId,
                          std::map<const SMDS_MeshNode*,int> &            aNodeToGhs3dIdMap,
+                         std::vector<std::string> &                      aNodeGroupByGhs3dId,
                          std::vector<std::string> &                      anEdgeGroupByGhs3dId,
                          std::vector<std::string> &                      aFaceGroupByGhs3dId,
                          GHS3DPlugin_Hypothesis::TIDSortedNodeGroupMap & theEnforcedNodes,
                          GHS3DPlugin_Hypothesis::TIDSortedElemGroupMap & theEnforcedEdges,
                          GHS3DPlugin_Hypothesis::TIDSortedElemGroupMap & theEnforcedTriangles,
+                         std::map<std::vector<double>, std::string> &    enfVerticesWithGroup,
                          GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertexCoordsValues & theEnforcedVertices)
 {
   MESSAGE("writeGMFFile w/o geometry");
@@ -1379,11 +1378,9 @@ static bool writeGMFFile(const char*                                     theMesh
   GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertexCoordsValues::const_iterator vertexIt;
   std::vector<double> enfVertexSizes;
   const SMDS_MeshElement* elem;
-  TIDSortedElemSet anElemSet, theKeptEnforcedEdges, theKeptEnforcedTriangles/*, theKeptEnforcedQuadrangles*/;
-  // GHS3D does not accept EdgesP2 in input mesh file (Ghs3d 4.2)
-//   TIDSortedElemSet aQuadElemSet, aQuadEnforcedEdgeSet, aQuadEnforcedTriangleSet, aQuadEnforcedQuadrangleSet;
+  TIDSortedElemSet anElemSet, theKeptEnforcedEdges, theKeptEnforcedTriangles;
   SMDS_ElemIteratorPtr nodeIt;
-  map<const SMDS_MeshNode*,int> /*aNodeToGhs3dIdMap,*/ anEnforcedNodeToGhs3dIdMap;
+  map<const SMDS_MeshNode*,int> anEnforcedNodeToGhs3dIdMap;
   GHS3DPlugin_Hypothesis::TIDSortedElemGroupMap::iterator elemIt;
   TIDSortedElemSet::iterator elemSetIt;
   bool isOK;
@@ -1408,10 +1405,6 @@ static bool writeGMFFile(const char*                                     theMesh
   while ( eIt->more() )
   {
     elem = eIt->next();
-    // GHS3D does not accept EdgesP2 in input mesh file (Ghs3d 4.2)
-//     if (elem->IsQuadratic())
-//       aQuadElemSet.insert(elem);
-//     else
     anElemSet.insert(elem);
     nodeIt = elem->nodesIterator();
     nbNodes = elem->NbCornerNodes();
@@ -1452,10 +1445,6 @@ static bool writeGMFFile(const char*                                     theMesh
         int newId = aNodeToGhs3dIdMap.size() + anEnforcedNodeToGhs3dIdMap.size() + 1; // ghs3d ids count from 1
         anEnforcedNodeToGhs3dIdMap.insert( make_pair( node, newId ));
       }
-      // GHS3D does not accept EdgesP2 in input mesh file (Ghs3d 4.2)
-//       if (elem->IsQuadratic())
-//         aQuadEnforcedEdgeSet.insert(elem);
-//       else
       theKeptEnforcedEdges.insert(elem);
     }
   }
@@ -1488,10 +1477,6 @@ static bool writeGMFFile(const char*                                     theMesh
         int newId = aNodeToGhs3dIdMap.size() + anEnforcedNodeToGhs3dIdMap.size() + 1; // ghs3d ids count from 1
         anEnforcedNodeToGhs3dIdMap.insert( make_pair( node, newId ));
       }
-      // GHS3D does not accept TrianglesP2 in input mesh file (Ghs3d 4.2)
-//       if (elem->IsQuadratic())
-//         aQuadEnforcedTriangleSet.insert(elem);
-//       else
       theKeptEnforcedTriangles.insert(elem);
     }
   }
@@ -1535,12 +1520,13 @@ static bool writeGMFFile(const char*                                     theMesh
     theOrderedNodes.push_back(node);
   }
   
-  // Iterate over the enforced nodes
-  GHS3DPlugin_Hypothesis::TIDSortedNodeGroupMap::const_iterator enfNodeIt;
-  std::cout << theEnforcedNodes.size() << " nodes from enforced nodes ..." << std::endl;
-  for(enfNodeIt = theEnforcedNodes.begin() ; enfNodeIt != theEnforcedNodes.end() ; ++enfNodeIt)
+  // Iterate over the enforced nodes given by enforced elements
+  ghs3dNodeIt = theEnforcedNodeByGhs3dId.begin();
+  after  = theEnforcedNodeByGhs3dId.end();
+  std::cout << theEnforcedNodeByGhs3dId.size() << " nodes from enforced elements ..." << std::endl;
+  for ( ; ghs3dNodeIt != after; ++ghs3dNodeIt )
   {
-    const SMDS_MeshNode* node = enfNodeIt->first;
+    const SMDS_MeshNode* node = *ghs3dNodeIt;
     std::vector<double> coords;
     coords.push_back(node->X());
     coords.push_back(node->Y());
@@ -1550,27 +1536,22 @@ static bool writeGMFFile(const char*                                     theMesh
       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 )
+    if (theEnforcedVertices.find(coords) != theEnforcedVertices.end())
       continue;
     
     nodesCoords.insert(coords);
     theOrderedNodes.push_back(node);
-    theRequiredNodes.push_back(node);
+//     theRequiredNodes.push_back(node);
   }
-  // Iterate over the enforced nodes given by enforced elements
-  ghs3dNodeIt = theEnforcedNodeByGhs3dId.begin();
-  after  = theEnforcedNodeByGhs3dId.end();
-  std::cout << theEnforcedNodeByGhs3dId.size() << " nodes from enforced elements ..." << std::endl;
-  for ( ; ghs3dNodeIt != after; ++ghs3dNodeIt )
+  
+  
+  // Iterate over the enforced nodes
+  GHS3DPlugin_Hypothesis::TIDSortedNodeGroupMap::const_iterator enfNodeIt;
+  std::cout << theEnforcedNodes.size() << " nodes from enforced nodes ..." << std::endl;
+  for(enfNodeIt = theEnforcedNodes.begin() ; enfNodeIt != theEnforcedNodes.end() ; ++enfNodeIt)
   {
-    const SMDS_MeshNode* node = *ghs3dNodeIt;
+    const SMDS_MeshNode* node = enfNodeIt->first;
     std::vector<double> coords;
     coords.push_back(node->X());
     coords.push_back(node->Y());
@@ -1580,16 +1561,22 @@ static bool writeGMFFile(const char*                                     theMesh
       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;
+    
     nodesCoords.insert(coords);
-    theOrderedNodes.push_back(node);
+//     theOrderedNodes.push_back(node);
     theRequiredNodes.push_back(node);
   }
+  int requiredNodes = theRequiredNodes.size();
   
-//   int requiredNodes = theRequiredNodes.size();
   int solSize = 0;
   std::vector<std::vector<double> > ReqVerTab;
   if (nbEnforcedVertices) {
@@ -1620,32 +1607,12 @@ static bool writeGMFFile(const char*                                     theMesh
   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;
+  if (requiredNodes + solSize) {
+    std::cout << "Begin writting in req and sol file" << std::endl;
+    aNodeGroupByGhs3dId.resize( requiredNodes + solSize );
     idxRequired = GmfOpenMesh(theRequiredFileName, GmfWrite, GMFVERSION, GMFDIMENSION);
     if (!idxRequired) {
       GmfCloseMesh(idx);
@@ -1659,65 +1626,31 @@ static bool writeGMFFile(const char*                                     theMesh
       return false;
     }
     int TypTab[] = {GmfSca};
-    GmfSetKwd(idxRequired, GmfVertices, solSize);
-    GmfSetKwd(idxSol, GmfSolAtVertices, solSize, 1, TypTab);
+    GmfSetKwd(idxRequired, GmfVertices, requiredNodes + solSize);
+    GmfSetKwd(idxSol, GmfSolAtVertices, requiredNodes + solSize, 1, TypTab);
+    int usedEnforcedNodes = 0;
+    for (ghs3dNodeIt = theRequiredNodes.begin();ghs3dNodeIt != theRequiredNodes.end();++ghs3dNodeIt) {
+      GmfSetLin(idxRequired, GmfVertices, (*ghs3dNodeIt)->X(), (*ghs3dNodeIt)->Y(), (*ghs3dNodeIt)->Z(), dummyint);
+      GmfSetLin(idxSol, GmfSolAtVertices, 0.0);
+      aNodeGroupByGhs3dId[usedEnforcedNodes] = theEnforcedNodes.find((*ghs3dNodeIt))->second;
+      usedEnforcedNodes++;
+    }
+
     for (int i=0;i<solSize;i++) {
       std::cout << ReqVerTab[i][0] <<" "<< ReqVerTab[i][1] << " "<< ReqVerTab[i][2] << std::endl;
       std::cout << "enfVertexSizes.at("<<i<<"): " << enfVertexSizes.at(i) << std::endl;
       double solTab[] = {enfVertexSizes.at(i)};
       GmfSetLin(idxRequired, GmfVertices, ReqVerTab[i][0], ReqVerTab[i][1], ReqVerTab[i][2], dummyint);
       GmfSetLin(idxSol, GmfSolAtVertices, solTab);
+      aNodeGroupByGhs3dId[usedEnforcedNodes] = enfVerticesWithGroup.find(ReqVerTab[i])->second;
+      std::cout << "aNodeGroupByGhs3dId["<<usedEnforcedNodes<<"] = \""<<enfVerticesWithGroup.find(ReqVerTab[i])->second<<"\""<<std::endl;
+      usedEnforcedNodes++;
     }
-    std::cout << "End writting in sol file" << std::endl;
+    std::cout << "End writting in req and 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, 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(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;
-//    }
-//
-////  }
 
-  // GHS3D does not accept quadratic elements in input mesh file (Ghs3d 4.2)
-  int nedge[2], ntri[3]/*, nquad[4]*/ /*, nedgeP2[3], ntriP2[6], nquadQ2[9]*/;
-  
-  
+  int nedge[2], ntri[3];
+    
   // GmfEdges
   int usedEnforcedEdges = 0;
   if (theKeptEnforcedEdges.size()) {
@@ -1747,39 +1680,11 @@ static bool writeGMFFile(const char*                                     theMesh
     }
 //    GmfCloseMesh(idxRequired);
   }
-  
-  // GHS3D does not accept EdgesP2 in input mesh file (Ghs3d 4.2)
-//   // GmfEdgesP2
-//   int usedEnforcedEdgesP2 = 0;
-//   if (aQuadEnforcedEdgeSet.size()) {
-// //    idxRequired = GmfOpenMesh(theRequiredFileName, GmfWrite, GMFVERSION, GMFDIMENSION);
-// //    if (!idxRequired)
-// //      return false;
-//     GmfSetKwd(idx, GmfEdgesP2, aQuadEnforcedEdgeSet.size());
-// //    GmfSetKwd(idxRequired, GmfEdges, theKeptEnforcedEdges.size());
-//     for(elemIt = aQuadEnforcedEdgeSet.begin() ; elemIt != aQuadEnforcedEdgeSet.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";
-//         nedgeP2[index] = it->second;
-//         index++;
-//       }
-//       GmfSetLin(idx, GmfEdgesP2, nedgeP2[0], nedgeP2[1], nedgeP2[2], dummyint);
-// //      GmfSetLin(idxRequired, GmfEdges, nedge[0], nedge[1], dummyint);
-//       usedEnforcedEdgesP2++;
-//     }
-// //    GmfCloseMesh(idxRequired);
-//   }
 
-  if (usedEnforcedEdges/*+usedEnforcedEdgesP2*/) {
-    GmfSetKwd(idx, GmfRequiredEdges, usedEnforcedEdges/*+usedEnforcedEdgesP2*/);
-    for (int enfID=1;enfID<=usedEnforcedEdges/*+usedEnforcedEdgesP2*/;enfID++) {
+
+  if (usedEnforcedEdges) {
+    GmfSetKwd(idx, GmfRequiredEdges, usedEnforcedEdges);
+    for (int enfID=1;enfID<=usedEnforcedEdges;enfID++) {
       GmfSetLin(idx, GmfRequiredEdges, enfID);
     }
   }
@@ -1826,108 +1731,14 @@ static bool writeGMFFile(const char*                                     theMesh
       }
     }
   }
+
   
-  // GHS3D does not accept EdgesP2 in input mesh file (Ghs3d 4.2)
-//   // GmfTrianglesP2
-//   int usedEnforcedTrianglesP2 = 0;
-//   if (aQuadElemSet.size()+aQuadEnforcedTriangleSet.size()) {
-//     GmfSetKwd(idx, GmfTrianglesP2, aQuadElemSet.size()+aQuadEnforcedTriangleSet.size());
-//     for(elemIt = aQuadElemSet.begin() ; elemIt != aQuadElemSet.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 = aNodeToGhs3dIdMap.find(node);
-//         if (it == aNodeToGhs3dIdMap.end())
-//           throw "Node not found";
-//         ntriP2[index] = it->second;
-//         index++;
-//       }
-//       GmfSetLin(idx, GmfTrianglesP2, ntriP2[0], ntriP2[1], ntriP2[2], ntriP2[3], ntriP2[4], ntriP2[5], dummyint);
-//     }
-//     if (aQuadEnforcedTriangleSet.size()) {
-//       for(elemIt = aQuadEnforcedTriangleSet.begin() ; elemIt != aQuadEnforcedTriangleSet.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";
-//           ntriP2[index] = it->second;
-//           index++;
-//         }
-//         GmfSetLin(idx, GmfTrianglesP2, ntriP2[0], ntriP2[1], ntriP2[2], ntriP2[3], ntriP2[4], ntriP2[5], dummyint);
-//         usedEnforcedTrianglesP2++;
-//       }
-//     }
-//   }
-  
-  if (usedEnforcedTriangles/*+usedEnforcedTrianglesP2*/) {
-    GmfSetKwd(idx, GmfRequiredTriangles, usedEnforcedTriangles/*+usedEnforcedTrianglesP2*/);
-    for (int enfID=1;enfID<=usedEnforcedTriangles/*+usedEnforcedTrianglesP2*/;enfID++)
-      GmfSetLin(idx, GmfRequiredTriangles, anElemSet.size()/*+aQuadElemSet.size()*/+enfID);
+  if (usedEnforcedTriangles) {
+    GmfSetKwd(idx, GmfRequiredTriangles, usedEnforcedTriangles);
+    for (int enfID=1;enfID<=usedEnforcedTriangles;enfID++)
+      GmfSetLin(idx, GmfRequiredTriangles, anElemSet.size()+enfID);
   }
 
-  // TODO
-//   // GmfQuadrangles
-//   int usedEnforcedQuadrilaterals = 0;
-//   if (anEnforcedQuadrangleSet.size()) {
-//     GmfSetKwd(idx, GmfQuadrilaterals, anEnforcedQuadrangleSet.size());
-//     for(elemIt = anEnforcedQuadrangleSet.begin() ; elemIt != anEnforcedQuadrangleSet.end() ; ++elemIt) {
-//       elem = (*elemIt);
-//       nodeIt = elem->nodesIterator();
-//       int index=0;
-//       for ( int j = 0; j < 4; ++j ) {
-//         // 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";
-//         nquad[index] = it->second;
-//         index++;
-//       }
-//       GmfSetLin(idx, GmfQuadrilaterals, nquad[0], nquad[1], nquad[2], nquad[3], dummyint);
-//       usedEnforcedQuadrilaterals++;
-//     }
-//   }
-//   
-//   // GHS3D does not accept EdgesP2 in input mesh file (Ghs3d 4.2)
-//   // GmfQuadranglesQ2
-//   int usedEnforcedQuadrilateralsQ2 = 0;
-//   if (aQuadEnforcedQuadrangleSet.size()) {
-//     GmfSetKwd(idx, GmfQuadrilateralsQ2, aQuadEnforcedQuadrangleSet.size());
-//     for(elemIt = aQuadEnforcedQuadrangleSet.begin() ; elemIt != aQuadEnforcedQuadrangleSet.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";
-//         nquadQ2[index] = it->second;
-//         index++;
-//       }
-//       //
-//       // !!! The last value in nquadQ2 is missing because in Salome the quadratic quadrilaterals have only 8 points !!!
-//       //
-//       GmfSetLin(idx, GmfQuadrilateralsQ2, nquadQ2[0], nquadQ2[1], nquadQ2[2], nquadQ2[3], nquadQ2[4], nquadQ2[5], nquadQ2[6], nquadQ2[7], nquadQ2[8], dummyint);
-//       usedEnforcedQuadrilateralsQ2++;
-//     }
-//   }
-//   
-//   if (usedEnforcedQuadrilaterals+usedEnforcedQuadrilateralsQ2) {
-//     GmfSetKwd(idx, GmfRequiredQuadrilaterals, usedEnforcedQuadrilaterals+usedEnforcedQuadrilateralsQ2);
-//     for (int enfID=1;enfID<=usedEnforcedQuadrilaterals+usedEnforcedQuadrilateralsQ2;enfID++)
-//       GmfSetLin(idx, GmfRequiredQuadrilaterals, enfID);
-//   }
-
   GmfCloseMesh(idx);
   if (idxRequired)
     GmfCloseMesh(idxRequired);
@@ -3506,19 +3317,19 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh&         theMesh,
     }
   }
   
-  const SMDS_MeshNode* enfNode;
+//   const SMDS_MeshNode* enfNode;
   GHS3DPlugin_Hypothesis::TIDSortedNodeGroupMap enforcedNodes = GHS3DPlugin_Hypothesis::GetEnforcedNodes(_hyp);
-  GHS3DPlugin_Hypothesis::TIDSortedNodeGroupMap::const_iterator enfNodeIt = enforcedNodes.begin();
-  for ( ; enfNodeIt != enforcedNodes.end() ; ++enfNodeIt)
-  {
-    enfNode = enfNodeIt->first;
-    coords.clear();
-    coords.push_back(enfNode->X());
-    coords.push_back(enfNode->Y());
-    coords.push_back(enfNode->Z());
-    if (enfVerticesWithGroup.find(coords) == enfVerticesWithGroup.end())
-      enfVerticesWithGroup.insert(make_pair(coords,enfNodeIt->second));
-  }
+//   GHS3DPlugin_Hypothesis::TIDSortedNodeGroupMap::const_iterator enfNodeIt = enforcedNodes.begin();
+//   for ( ; enfNodeIt != enforcedNodes.end() ; ++enfNodeIt)
+//   {
+//     enfNode = enfNodeIt->first;
+//     coords.clear();
+//     coords.push_back(enfNode->X());
+//     coords.push_back(enfNode->Y());
+//     coords.push_back(enfNode->Z());
+//     if (enfVerticesWithGro
+//       enfVerticesWithGroup.insert(make_pair(coords,enfNodeIt->second));
+//   }
   
   
   GHS3DPlugin_Hypothesis::TIDSortedElemGroupMap enforcedEdges = GHS3DPlugin_Hypothesis::GetEnforcedEdges(_hyp);
@@ -3533,7 +3344,7 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh&         theMesh,
   
   std::vector <const SMDS_MeshNode*> aNodeByGhs3dId, anEnforcedNodeByGhs3dId;
   std::map<const SMDS_MeshNode*,int> aNodeToGhs3dIdMap;
-  std::vector<std::string> anEdgeGroupByGhs3dId, aFaceGroupByGhs3dId;
+  std::vector<std::string> aNodeGroupByGhs3dId, anEdgeGroupByGhs3dId, aFaceGroupByGhs3dId;
   {
     SMESH_ProxyMesh::Ptr proxyMesh( new SMESH_ProxyMesh( theMesh ));
     if ( theMesh.NbQuadrangles() > 0 )
@@ -3545,9 +3356,10 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh&         theMesh,
 
     Ok = writeGMFFile(aGMFFileName.ToCString(), aRequiredVerticesFileName.ToCString(), aSolFileName.ToCString(),
                       *proxyMesh, &theMesh,
-                      aNodeByGhs3dId, anEnforcedNodeByGhs3dId, aNodeToGhs3dIdMap, anEdgeGroupByGhs3dId, aFaceGroupByGhs3dId,
-                      enforcedNodes, enforcedEdges, enforcedTriangles, /*enforcedQuadrangles,*/
-                      coordsSizeMap);
+                      aNodeByGhs3dId, anEnforcedNodeByGhs3dId, aNodeToGhs3dIdMap, 
+                      aNodeGroupByGhs3dId, anEdgeGroupByGhs3dId, aFaceGroupByGhs3dId,
+                      enforcedNodes, enforcedEdges, enforcedTriangles,
+                      enfVerticesWithGroup, coordsSizeMap);
   }
 
   // -----------------
@@ -3557,7 +3369,7 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh&         theMesh,
   TCollection_AsciiString cmd = TCollection_AsciiString((char*)GHS3DPlugin_Hypothesis::CommandToRun( _hyp, false ).c_str());
 
   cmd += TCollection_AsciiString(" --in ") + aGenericName;
-  if ( nbEnforcedVertices + nbEnforcedVertices)
+  if ( nbEnforcedVertices + nbEnforcedNodes)
     cmd += TCollection_AsciiString(" --required_vertices ") + aGenericNameRequired;
   cmd += TCollection_AsciiString(" --out ") + aResultFileName;
   cmd += TCollection_AsciiString(" 1>" ) + aLogFileName;  // dump into file
@@ -3584,7 +3396,7 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh&         theMesh,
                    this,
 #endif
                    theHelper, theShape, aNodeByGhs3dId, aNodeToGhs3dIdMap,
-                   enfVerticesWithGroup, anEdgeGroupByGhs3dId, aFaceGroupByGhs3dId);
+                   aNodeGroupByGhs3dId, anEdgeGroupByGhs3dId, aFaceGroupByGhs3dId);
   
   // ---------------------
   // remove working files
@@ -4222,13 +4034,13 @@ bool GHS3DPlugin_GHS3D::importGMFMesh(const char* theGMFFileName, SMESH_Mesh& th
   std::vector <const SMDS_MeshNode*> dummyNodeVector;
   std::map<const SMDS_MeshNode*,int> dummyNodeMap;
   std::map<std::vector<double>, std::string> dummyEnfVertGroup;
-  std::vector<std::string> dummyElemGroup1, dummyElemGroup2;
+  std::vector<std::string> dummyElemGroup;
   
   bool ok = readGMFFile(theGMFFileName, 
 #ifdef WITH_SMESH_CANCEL_COMPUTE
                         this,
 #endif
-                        helper, theMesh.GetShapeToMesh(), dummyNodeVector, dummyNodeMap, dummyEnfVertGroup, dummyElemGroup1, dummyElemGroup2);
+                        helper, theMesh.GetShapeToMesh(), dummyNodeVector, dummyNodeMap, dummyElemGroup, dummyElemGroup, dummyElemGroup);
   theMesh.GetMeshDS()->Modified();
   return ok;
 }
index b518b34045331a7cc255dbb4ed3452c559ef3d9c..8f336464afde45f5744df7d83004ccdfe580170c 100644 (file)
@@ -25,6 +25,7 @@
 //
 #include "GHS3DPlugin_Hypothesis.hxx"
 #include <SMESH_ProxyMesh.hxx>
+#include <SMESH_Group.hxx>
 #include <StdMeshers_QuadToTriaAdaptor.hxx>
 
 #include <TCollection_AsciiString.hxx>
@@ -417,14 +418,45 @@ bool GHS3DPlugin_Hypothesis::SetEnforcedVertex(std::string theName, std::string
 bool GHS3DPlugin_Hypothesis::SetEnforcedMesh(SMESH_Mesh& theMesh, SMESH::ElementType elementType, double size, std::string groupName)
 {
   TIDSortedElemSet theElemSet;
-  SMDS_ElemIteratorPtr eIt;
-  eIt = theMesh.GetMeshDS()->elementsIterator(SMDSAbs_ElementType(elementType));
+  SMDS_ElemIteratorPtr eIt = theMesh.GetMeshDS()->elementsIterator(SMDSAbs_ElementType(elementType));
   while ( eIt->more() )
     theElemSet.insert( eIt->next() );
   MESSAGE("Add "<<theElemSet.size()<<" types["<<elementType<<"] from source mesh");
   return SetEnforcedElements( theElemSet, elementType, size, groupName);
 }
 
+//=======================================================================
+//function : SetEnforcedGroup
+//=======================================================================
+bool GHS3DPlugin_Hypothesis::SetEnforcedGroup(const SMESHDS_Mesh* theMeshDS, SMESH::long_array_var theIDs, SMESH::ElementType elementType, double size, std::string groupName)
+{
+  MESSAGE("GHS3DPlugin_Hypothesis::SetEnforcedGroup");
+  TIDSortedElemSet theElemSet;
+    if ( theIDs->length() == 0 ){MESSAGE("The source group is empty");}
+    for (int i=0; i < theIDs->length(); i++) {
+      CORBA::Long ind = theIDs[i];
+      if (elementType == SMESH::NODE)
+      {
+        const SMDS_MeshNode * node = theMeshDS->FindNode(ind);
+        if (node)
+          theElemSet.insert( node );
+      }
+      else
+      {
+        const SMDS_MeshElement * elem = theMeshDS->FindElement(ind);
+        if (elem)
+          theElemSet.insert( elem );
+      }
+    }
+
+//   SMDS_ElemIteratorPtr it = theGroup->GetGroupDS()->GetElements();
+//   while ( it->more() ) 
+//     theElemSet.insert( it->next() );
+
+  MESSAGE("Add "<<theElemSet.size()<<" types["<<elementType<<"] from source group ");
+  return SetEnforcedElements( theElemSet, elementType, size, groupName);
+}
+
 //=======================================================================
 //function : SetEnforcedElements
 //=======================================================================
@@ -447,7 +479,6 @@ bool GHS3DPlugin_Hypothesis::SetEnforcedElements(TIDSortedElemSet theElemSet, SM
           added = true;
         }
         else {
-//           _enfNodes.insert(elem->begin_nodes(),elem->end_nodes());
           SMDS_ElemIteratorPtr nodeIt = elem->nodesIterator();
           for (;nodeIt->more();) {
             node = dynamic_cast<const SMDS_MeshNode*>(nodeIt->next());
index 8532002a58d2b857bf7310fde8cfd8be40411126..2063e6eaf0d37da77e852e412cae2338f01bd01d 100644 (file)
@@ -193,6 +193,7 @@ public:
    * To set enforced elements
    */
   bool SetEnforcedMesh(SMESH_Mesh& theMesh, SMESH::ElementType elementType, double size, std::string groupName = "");
+  bool SetEnforcedGroup(const SMESHDS_Mesh* theMeshDS, SMESH::long_array_var theIDs, SMESH::ElementType elementType, double size, std::string groupName = "");
   bool SetEnforcedElements(TIDSortedElemSet theElemSet, SMESH::ElementType elementType, double size, std::string groupName = "");
   void ClearEnforcedMeshes();
   const TIDSortedNodeGroupMap _GetEnforcedNodes() const { return _enfNodes; }
@@ -278,6 +279,7 @@ private:
   TIDSortedElemGroupMap _enfTriangles;
   TID2SizeMap _nodeIDToSizeMap;
   TID2SizeMap _elementIDToSizeMap;
+  std::map<std::string, TIDSortedElemSet > _entryToElemsMap;
 };
 
 
index f62b5dd44cffa66f46f7dedced60590fc6e874e5..e7a2d4c53b26bf1c2588fcef3115876e7f489a34 100644 (file)
@@ -35,6 +35,7 @@
 #include "SMESH_Group_i.hxx"
 #include "SMESH_Gen_i.hxx"
 #include "SMESH_TypeDefs.hxx"
+#include "SMESHDS_GroupBase.hxx"
 
 #ifndef GHS3D_VERSION
 #define GHS3D_VERSION 41
@@ -521,8 +522,8 @@ CORBA::Double GHS3DPlugin_Hypothesis_i::GetEnforcedVertex(CORBA::Double x, CORBA
     SALOME::ExceptionStruct ExDescription;
     ExDescription.text = ex.what();
     ExDescription.type = SALOME::BAD_PARAM;
-    ExDescription.sourceFile = "GHS3DPlugin_Hypothesis::GetEnforcedVertex(x,y,z)";
-    ExDescription.lineNumber = 0;
+    ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
+    ExDescription.lineNumber = 513;
     throw SALOME::SALOME_Exception(ExDescription);
   }
   catch (SALOME_Exception& ex) {
@@ -571,8 +572,8 @@ CORBA::Double GHS3DPlugin_Hypothesis_i::GetEnforcedVertexGeom(GEOM::GEOM_Object_
     SALOME::ExceptionStruct ExDescription;
     ExDescription.text = ex.what();
     ExDescription.type = SALOME::BAD_PARAM;
-    ExDescription.sourceFile = "GHS3DPlugin_Hypothesis::GetEnforcedVertexGeom(theVertex)";
-    ExDescription.lineNumber = 0;
+    ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
+    ExDescription.lineNumber = 538;
     throw SALOME::SALOME_Exception(ExDescription);
   }
   catch (SALOME_Exception& ex) {
@@ -635,8 +636,8 @@ bool GHS3DPlugin_Hypothesis_i::RemoveEnforcedVertex(CORBA::Double x, CORBA::Doub
     SALOME::ExceptionStruct ExDescription;
     ExDescription.text = ex.what();
     ExDescription.type = SALOME::BAD_PARAM;
-    ExDescription.sourceFile = "GHS3DPlugin_Hypothesis::RemoveEnforcedVertex(x,y,z)";
-    ExDescription.lineNumber = 408;
+    ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
+    ExDescription.lineNumber = 625;
     throw SALOME::SALOME_Exception(ExDescription);
   }
   catch (SALOME_Exception& ex) {
@@ -681,8 +682,8 @@ bool GHS3DPlugin_Hypothesis_i::RemoveEnforcedVertexGeom(GEOM::GEOM_Object_ptr th
     SALOME::ExceptionStruct ExDescription;
     ExDescription.text = ex.what();
     ExDescription.type = SALOME::BAD_PARAM;
-    ExDescription.sourceFile = "GHS3DPlugin_Hypothesis::RemoveEnforcedVertex(x,y,z)";
-    ExDescription.lineNumber = 408;
+    ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
+    ExDescription.lineNumber = 648;
     throw SALOME::SALOME_Exception(ExDescription);
   }
   catch (SALOME_Exception& ex) {
@@ -723,7 +724,8 @@ bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshWithGroup(SMESH::SMESH_IDSource_pt
   bool res = _SetEnforcedMesh(theSource, theType, -1.0, theGroupName);
   SMESH_Mesh_i* theMesh_i = SMESH::DownCast<SMESH_Mesh_i*>( theSource);
   SMESH_Group_i* theGroup_i = SMESH::DownCast<SMESH_Group_i*>( theSource);
-  if (theGroup_i)
+  SMESH_GroupOnGeom_i* theGroupOnGeom_i = SMESH::DownCast<SMESH_GroupOnGeom_i*>( theSource);
+  if (theGroup_i or theGroupOnGeom_i)
   {
     SMESH::TPythonDump () << _this() << ".SetEnforcedMeshWithGroup( " 
                           << theSource << ", " << theType << ", \"" << theGroupName << "\" )";
@@ -738,8 +740,8 @@ bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshWithGroup(SMESH::SMESH_IDSource_pt
   SALOME::ExceptionStruct ExDescription;
   ExDescription.text = "Bad version of GHS3D. It must >= 4.2.";
   ExDescription.type = SALOME::BAD_PARAM;
-  ExDescription.sourceFile = "GHS3DPlugin_Hypothesis::SetEnforcedMesh(theSource, theType)";
-  ExDescription.lineNumber = 463;
+  ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
+  ExDescription.lineNumber = 719;
   throw SALOME::SALOME_Exception(ExDescription);
 #endif
 }
@@ -750,11 +752,13 @@ bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshWithGroup(SMESH::SMESH_IDSource_pt
 bool GHS3DPlugin_Hypothesis_i::SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType)
   throw (SALOME::SALOME_Exception)
 {
+  MESSAGE("GHS3DPlugin_Hypothesis_i::SetEnforcedMesh");
 #if GHS3D_VERSION >= 42
   bool res = _SetEnforcedMesh(theSource, theType, -1.0);
   SMESH_Mesh_i* theMesh_i = SMESH::DownCast<SMESH_Mesh_i*>( theSource);
   SMESH_Group_i* theGroup_i = SMESH::DownCast<SMESH_Group_i*>( theSource);
-  if (theGroup_i)
+  SMESH_GroupOnGeom_i* theGroupOnGeom_i = SMESH::DownCast<SMESH_GroupOnGeom_i*>( theSource);
+  if (theGroup_i or theGroupOnGeom_i)
   {
     SMESH::TPythonDump () << _this() << ".SetEnforcedMesh( " 
                           << theSource << ", " << theType << " )";
@@ -769,8 +773,8 @@ bool GHS3DPlugin_Hypothesis_i::SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSour
   SALOME::ExceptionStruct ExDescription;
   ExDescription.text = "Bad version of GHS3D. It must >= 4.2.";
   ExDescription.type = SALOME::BAD_PARAM;
-  ExDescription.sourceFile = "GHS3DPlugin_Hypothesis::SetEnforcedMesh(theSource, theType)";
-  ExDescription.lineNumber = 463;
+  ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
+  ExDescription.lineNumber = 750;
   throw SALOME::SALOME_Exception(ExDescription);
 #endif
 }
@@ -785,15 +789,16 @@ bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshSizeWithGroup(SMESH::SMESH_IDSourc
     SALOME::ExceptionStruct ExDescription;
     ExDescription.text = "Size cannot be negative";
     ExDescription.type = SALOME::BAD_PARAM;
-    ExDescription.sourceFile = "GHS3DPlugin_Hypothesis::SetEnforcedMeshSize(theSource, theType)";
-    ExDescription.lineNumber = 475;
+    ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
+    ExDescription.lineNumber = 781;
     throw SALOME::SALOME_Exception(ExDescription);
   }
   
   bool res = _SetEnforcedMesh(theSource, theType, theSize,theGroupName);
   SMESH_Mesh_i* theMesh_i = SMESH::DownCast<SMESH_Mesh_i*>( theSource);
   SMESH_Group_i* theGroup_i = SMESH::DownCast<SMESH_Group_i*>( theSource);
-  if (theGroup_i)
+  SMESH_GroupOnGeom_i* theGroupOnGeom_i = SMESH::DownCast<SMESH_GroupOnGeom_i*>( theSource);
+  if (theGroup_i or theGroupOnGeom_i)
   {
     SMESH::TPythonDump () << _this() << ".SetEnforcedMeshSizeWithGroup( " 
                           << theSource << ", " << theType << ", " << theSize << ", \"" << theGroupName << "\" )";
@@ -816,15 +821,16 @@ bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshSize(SMESH::SMESH_IDSource_ptr the
     SALOME::ExceptionStruct ExDescription;
     ExDescription.text = "Size cannot be negative";
     ExDescription.type = SALOME::BAD_PARAM;
-    ExDescription.sourceFile = "GHS3DPlugin_Hypothesis::SetEnforcedMeshSize(theSource, theType)";
-    ExDescription.lineNumber = 475;
+    ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
+    ExDescription.lineNumber = 812;
     throw SALOME::SALOME_Exception(ExDescription);
   }
   
   bool res = _SetEnforcedMesh(theSource, theType, theSize);
   SMESH_Mesh_i* theMesh_i = SMESH::DownCast<SMESH_Mesh_i*>( theSource);
   SMESH_Group_i* theGroup_i = SMESH::DownCast<SMESH_Group_i*>( theSource);
-  if (theGroup_i)
+  SMESH_GroupOnGeom_i* theGroupOnGeom_i = SMESH::DownCast<SMESH_GroupOnGeom_i*>( theSource);
+  if (theGroup_i or theGroupOnGeom_i)
   {
     SMESH::TPythonDump () << _this() << ".SetEnforcedMeshSize( " 
                           << theSource << ", " << theType << ", " << theSize << " )";
@@ -840,6 +846,7 @@ bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshSize(SMESH::SMESH_IDSource_ptr the
 bool GHS3DPlugin_Hypothesis_i::_SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, double theSize, const char* theGroupName)
   throw (SALOME::SALOME_Exception)
 {
+  MESSAGE("GHS3DPlugin_Hypothesis_i::_SetEnforcedMesh");
   ASSERT(myBaseImpl);
   
   if (CORBA::is_nil( theSource ))
@@ -847,103 +854,88 @@ bool GHS3DPlugin_Hypothesis_i::_SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSou
     SALOME::ExceptionStruct ExDescription;
     ExDescription.text = "The source mesh CORBA object is NULL";
     ExDescription.type = SALOME::BAD_PARAM;
-    ExDescription.sourceFile = "GHS3DPlugin_Hypothesis::_SetEnforcedMesh(theSource, theType, theSize, theGroupName)";
+    ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
     ExDescription.lineNumber = 840;
     throw SALOME::SALOME_Exception(ExDescription);
   }
   
   if ((theType != SMESH::NODE) && (theType != SMESH::EDGE) && (theType != SMESH::FACE))
   {
-    SALOME::ExceptionStruct ExDescription;
-    ExDescription.text = "Bad elementType";
-    ExDescription.type = SALOME::BAD_PARAM;
-    ExDescription.sourceFile = "GHS3DPlugin_Hypothesis::_SetEnforcedMesh(theSource, theType, theSize, theGroupName)";
-    ExDescription.lineNumber = 840;
-    throw SALOME::SALOME_Exception(ExDescription);
+    return 0;
+//     SALOME::ExceptionStruct ExDescription;
+//     ExDescription.text = "Bad elementType";
+//     ExDescription.type = SALOME::BAD_PARAM;
+//     ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
+//     ExDescription.lineNumber = 840;
+//     throw SALOME::SALOME_Exception(ExDescription);
   }
   
   SMESH::array_of_ElementType_var types = theSource->GetTypes();
-//   MESSAGE("Required type is "<<theType);
-//   MESSAGE("Available types:");
-//   for (int i=0;i<types->length();i++){MESSAGE(types[i]);}
+  MESSAGE("Required type is "<<theType);
+  MESSAGE("Available types:");
+  for (int i=0;i<types->length();i++){MESSAGE(types[i]);}
   if ( types->length() >= 1 && types[types->length()-1] <  theType)
   {
-    SALOME::ExceptionStruct ExDescription;
-    ExDescription.text = "The source mesh has bad type";
-    ExDescription.type = SALOME::BAD_PARAM;
-    ExDescription.sourceFile = "GHS3DPlugin_Hypothesis::_SetEnforcedMesh(theSource, theType, theSize, theGroupName)";
-    ExDescription.lineNumber = 840;
-    throw SALOME::SALOME_Exception(ExDescription);
+    return 0;
+//     SALOME::ExceptionStruct ExDescription;
+//     ExDescription.text = "The source mesh has bad type";
+//     ExDescription.type = SALOME::BAD_PARAM;
+//     ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
+//     ExDescription.lineNumber = 840;
+//     throw SALOME::SALOME_Exception(ExDescription);
   }
   
-  SMESHDS_Mesh* theMeshDS;
-  SMESH_Mesh_i* anImplPtr = SMESH::DownCast<SMESH_Mesh_i*>(theSource->GetMesh());
-  if (anImplPtr)
-    theMeshDS = anImplPtr->GetImpl().GetMeshDS();
-  else
-    return false;
-  
   SMESH_Mesh_i* theMesh_i = SMESH::DownCast<SMESH_Mesh_i*>( theSource);
   SMESH_Group_i* theGroup_i = SMESH::DownCast<SMESH_Group_i*>( theSource);
+  SMESH_GroupOnGeom_i* theGroupOnGeom_i = SMESH::DownCast<SMESH_GroupOnGeom_i*>( theSource);
   TIDSortedElemSet theElemSet;
 
   if (theMesh_i)
   {
     try {
-      return this->GetImpl()->SetEnforcedMesh(anImplPtr->GetImpl(), theType, theSize, theGroupName);
+      return this->GetImpl()->SetEnforcedMesh(theMesh_i->GetImpl(), theType, theSize, theGroupName);
     }
     catch (const std::invalid_argument& ex) {
       SALOME::ExceptionStruct ExDescription;
       ExDescription.text = ex.what();
       ExDescription.type = SALOME::BAD_PARAM;
-      ExDescription.sourceFile = "GHS3DPlugin_Hypothesis::_SetEnforcedMesh(theSource, theType, theSize, theGroupName)";
+      ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
       ExDescription.lineNumber = 840;
       throw SALOME::SALOME_Exception(ExDescription);
     }
     catch (SALOME_Exception& ex) {
       THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
     }
-//
-//      SMESH::long_array_var anIDs = theMesh_i->GetElementsByType(theType);
-//      if ( anIDs->length() == 0 ){MESSAGE("The source mesh is empty");}
-//      for (int i=0; i<anIDs->length(); i++) {
-//        CORBA::Long ind = anIDs[i];
-//        const SMDS_MeshElement * elem = theMeshDS->FindElement(ind);
-//        if (elem)
-//          theElemSet.insert( elem );
-//      }
-////    }
-//    MESSAGE("Add "<<theElemSet.size()<<" types["<<theType<<"] from source mesh");
   }
   else if (theGroup_i && types->length() == 1 && types[0] == theType)
   {
-    SMESH::long_array_var anIDs = theGroup_i->GetListOfID();
-    if ( anIDs->length() == 0 ){MESSAGE("The source group is empty");}
-    for (int i=0; i<anIDs->length(); i++) {
-      CORBA::Long ind = anIDs[i];
-      if (theType == SMESH::NODE)
-      {
-        const SMDS_MeshNode * node = theMeshDS->FindNode(ind);
-        if (node)
-          theElemSet.insert( node );
-      }
-      else
-      {
-        const SMDS_MeshElement * elem = theMeshDS->FindElement(ind);
-        if (elem)
-          theElemSet.insert( elem );
-      }
+    MESSAGE("The source is a group")
+    try {
+      return this->GetImpl()->SetEnforcedGroup(theGroup_i->GetGroupDS()->GetMesh(),theGroup_i->GetListOfID(), theType, theSize, theGroupName);
     }
-    MESSAGE("Add "<<theElemSet.size()<<" types["<<theType<<"] from source group "<< theGroup_i->GetName());
-
+    catch (const std::invalid_argument& ex) {
+      SALOME::ExceptionStruct ExDescription;
+      ExDescription.text = ex.what();
+      ExDescription.type = SALOME::BAD_PARAM;
+      ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
+      ExDescription.lineNumber = 840;
+      throw SALOME::SALOME_Exception(ExDescription);
+    }
+    catch (SALOME_Exception& ex) {
+      THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
+    }
+  }
+  else if (theGroupOnGeom_i && types->length() == 1 && types[0] == theType)
+  {
+    MESSAGE("The source is a group on geom")
     try {
-      return this->GetImpl()->SetEnforcedElements(theElemSet, theType, theSize, theGroupName);
+      return this->GetImpl()->SetEnforcedGroup(theGroupOnGeom_i->GetGroupDS()->GetMesh(),theGroupOnGeom_i->GetListOfID(), theType, theSize, theGroupName);
     }
     catch (const std::invalid_argument& ex) {
       SALOME::ExceptionStruct ExDescription;
       ExDescription.text = ex.what();
       ExDescription.type = SALOME::BAD_PARAM;
-      ExDescription.sourceFile = "GHS3DPlugin_Hypothesis::_SetEnforcedMesh(theSource, theType, theSize, theGroupName)";
+      ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
       ExDescription.lineNumber = 840;
       throw SALOME::SALOME_Exception(ExDescription);
     }