Salome HOME
Merge from V6_main 12/04/2013
[tools/medcoupling.git] / src / MEDLoader / SauvWriter.cxx
index 5fb31d2b65cc50d3d5ac660cda2e852c48e35902..88d17854d50b701112c1bf957f5d4de1b3df536e 100644 (file)
@@ -404,7 +404,7 @@ void SauvWriter::fillFamilySubMeshes()
 
 //================================================================================
 /*!
- * \brief fill sub-mehses of groups
+ * \brief fill sub-meshes of groups
  */
 //================================================================================
 
@@ -418,22 +418,30 @@ void SauvWriter::fillGroupSubMeshes()
       const vector<string>& famNames = g2ff->second;
       if ( famNames.empty() ) continue;
       std::vector<SubMesh*> famSubMeshes( famNames.size() );
+      std::size_t k = 0;
       for ( size_t i = 0; i < famNames.size(); ++i )
         {
           int famID = _fileMesh->getFamilyId( famNames[i].c_str() );
           map< int, SubMesh* >::iterator i2f = _famIDs2Sub.find( famID );
-          if ( i2f == _famIDs2Sub.end() )
-            THROW_IK_EXCEPTION("SauvWriter::fillGroupSubMeshes(): unknown family ID: " << famID);
-          famSubMeshes[ i ] = i2f->second;
+          if ( i2f != _famIDs2Sub.end() )
+            {
+              famSubMeshes[ k ] = i2f->second;
+              ++k;
+            }
         }
+      // if a family exists but has no element, no submesh has been found for this family
+      // => we have to resize famSubMeshes with the number of submeshes stored
+      if (k != famNames.size())
+          famSubMeshes.resize(k);
       SubMesh* grpSubMesh = addSubMesh( groupName, famSubMeshes[0]->_dimRelExt );
       grpSubMesh->_subs.swap( famSubMeshes );
     }
 }
 
+
 //================================================================================
 /*!
- * \brief fill sub-mehses of profiles
+ * \brief fill sub-meshes of profiles
  */
 //================================================================================