Salome HOME
0020028: EDF 842 SMESH : Can't export to med a mesh with same names BR_FSH_DEV V6_0_0
authoreap <eap@opencascade.com>
Fri, 25 Dec 2009 11:22:10 +0000 (11:22 +0000)
committereap <eap@opencascade.com>
Fri, 25 Dec 2009 11:22:10 +0000 (11:22 +0000)
for one group of nodes and one group of faces

avoid duplicated group names within one type of elements only

src/SMESH/SMESH_Mesh.cxx

index 58c6a227ba0442675bcc17cb466cd75199dc0a3e..d39700ed360a2600e4a38aedbf9f059f0d65b4b4 100644 (file)
@@ -1029,12 +1029,15 @@ bool SMESH_Mesh::GetAutoColor() throw(SALOME_Exception)
 
 bool SMESH_Mesh::HasDuplicatedGroupNamesMED()
 {
 
 bool SMESH_Mesh::HasDuplicatedGroupNamesMED()
 {
-  set<string> aGroupNames;
-  for ( map<int, SMESH_Group*>::iterator it = _mapGroup.begin(); it != _mapGroup.end(); it++ ) {
+  //set<string> aGroupNames; // Corrected for Mantis issue 0020028
+  map< SMDSAbs_ElementType, set<string> > aGroupNames;
+  for ( map<int, SMESH_Group*>::iterator it = _mapGroup.begin(); it != _mapGroup.end(); it++ )
+  {
     SMESH_Group* aGroup = it->second;
     SMESH_Group* aGroup = it->second;
+    SMDSAbs_ElementType aType = aGroup->GetGroupDS()->GetType();
     string aGroupName = aGroup->GetName();
     aGroupName.resize(MAX_MED_GROUP_NAME_LENGTH);
     string aGroupName = aGroup->GetName();
     aGroupName.resize(MAX_MED_GROUP_NAME_LENGTH);
-    if (!aGroupNames.insert(aGroupName).second)
+    if (!aGroupNames[aType].insert(aGroupName).second)
       return true;
   }
 
       return true;
   }
 
@@ -1067,17 +1070,19 @@ void SMESH_Mesh::ExportMED(const char *file,
   }
 
   // Pass groups to writer. Provide unique group names.
   }
 
   // Pass groups to writer. Provide unique group names.
-  set<string> aGroupNames;
+  //set<string> aGroupNames; // Corrected for Mantis issue 0020028
+  map< SMDSAbs_ElementType, set<string> > aGroupNames;
   char aString [256];
   int maxNbIter = 10000; // to guarantee cycle finish
   for ( map<int, SMESH_Group*>::iterator it = _mapGroup.begin(); it != _mapGroup.end(); it++ ) {
     SMESH_Group*       aGroup   = it->second;
     SMESHDS_GroupBase* aGroupDS = aGroup->GetGroupDS();
     if ( aGroupDS ) {
   char aString [256];
   int maxNbIter = 10000; // to guarantee cycle finish
   for ( map<int, SMESH_Group*>::iterator it = _mapGroup.begin(); it != _mapGroup.end(); it++ ) {
     SMESH_Group*       aGroup   = it->second;
     SMESHDS_GroupBase* aGroupDS = aGroup->GetGroupDS();
     if ( aGroupDS ) {
+      SMDSAbs_ElementType aType = aGroupDS->GetType();
       string aGroupName0 = aGroup->GetName();
       aGroupName0.resize(MAX_MED_GROUP_NAME_LENGTH);
       string aGroupName = aGroupName0;
       string aGroupName0 = aGroup->GetName();
       aGroupName0.resize(MAX_MED_GROUP_NAME_LENGTH);
       string aGroupName = aGroupName0;
-      for (int i = 1; !aGroupNames.insert(aGroupName).second && i < maxNbIter; i++) {
+      for (int i = 1; !aGroupNames[aType].insert(aGroupName).second && i < maxNbIter; i++) {
         sprintf(&aString[0], "GR_%d_%s", i, aGroupName0.c_str());
         aGroupName = aString;
         aGroupName.resize(MAX_MED_GROUP_NAME_LENGTH);
         sprintf(&aString[0], "GR_%d_%s", i, aGroupName0.c_str());
         aGroupName = aString;
         aGroupName.resize(MAX_MED_GROUP_NAME_LENGTH);