+/*!
+ * Removes all groups in \a this that are orphan. A group is orphan if this group lies on
+ * a set of families, themselves orphan. A family is said orphan if its id appears nowhere in
+ * family field whatever its level. This method also suppresses the orphan families.
+ *
+ * \return - The list of removed groups names.
+ *
+ * \sa MEDFileMesh::removeOrphanFamilies.
+ */
+std::vector<std::string> MEDFileMesh::removeOrphanGroups() throw(INTERP_KERNEL::Exception)
+{
+ removeOrphanFamilies();
+ return removeEmptyGroups();
+}
+
+/*!
+ * Removes all families in \a this that are orphan. A family is said orphan if its id appears nowhere in
+ * family field whatever its level. Groups are updated in consequence, that is to say all groups lying on orphan family, will see their families list modified.
+ *
+ * \return - The list of removed families names.
+ * \sa MEDFileMesh::removeOrphanGroups.
+ */
+std::vector<std::string> MEDFileMesh::removeOrphanFamilies() throw(INTERP_KERNEL::Exception)
+{
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> allFamIdsInUse=computeAllFamilyIdsInUse();
+ std::vector<std::string> ret;
+ if(!((DataArrayInt*)allFamIdsInUse))
+ {
+ ret=getFamiliesNames();
+ _families.clear(); _groups.clear();
+ return ret;
+ }
+ std::map<std::string,int> famMap;
+ std::map<std::string, std::vector<std::string> > grps(_groups);
+ for(std::map<std::string,int>::const_iterator it=_families.begin();it!=_families.end();it++)
+ {
+ if(allFamIdsInUse->presenceOfValue((*it).second))
+ famMap[(*it).first]=(*it).second;
+ else
+ {
+ ret.push_back((*it).first);
+ std::vector<std::string> grpsOnEraseFam=getGroupsOnFamily((*it).first.c_str());
+ for(std::vector<std::string>::const_iterator it2=grpsOnEraseFam.begin();it2!=grpsOnEraseFam.end();it2++)
+ {
+ std::map<std::string, std::vector<std::string> >::iterator it3=grps.find(*it2);//it3!=grps.empty() thanks to copy
+ std::vector<std::string>& famv=(*it3).second;
+ std::vector<std::string>::iterator it4=std::find(famv.begin(),famv.end(),(*it).first);//it4!=famv.end() thanks to copy
+ famv.erase(it4);
+ }
+ }
+ }
+ if(!ret.empty())
+ { _families=famMap; _groups=grps; }
+ return ret;
+}
+