* This method has no impact on groups. This method only works on families. This method firstly removes families not referred by any groups in \a this, then all unused entities
* are put as belonging to family 0 ("FAMILLE_ZERO"). Finally, all orphanFamilies are killed.
* This method raises an exception if "FAMILLE_ZERO" is already belonging to a group.
+ *
+ * This method also raises an exception if a family belonging to a group has also id 0 (which is not right in MED file format). You should never encounter this case using addGroup method.
*
* \sa MEDFileMesh::removeOrphanFamilies
*/
std::vector<int> levels(getNonEmptyLevelsExt());
std::set<int> idsRefed;
for(std::map<std::string,int>::const_iterator it=_families.begin();it!=_families.end();it++)
- idsRefed.insert((*it).second);
+ {
+ idsRefed.insert((*it).second);
+ if((*it).second==0)
+ {
+ if(!getGroupsOnFamily((*it).first).empty())
+ {
+ std::ostringstream oss; oss << "MEDFileMesh::rearrangeFamilies : Not orphan family \"" << (*it).first << "\" has id 0 ! This method may alterate groups in this for such a case !";
+ throw INTERP_KERNEL::Exception(oss.str());
+ }
+ }
+ }
for(std::vector<int>::const_iterator it=levels.begin();it!=levels.end();it++)
{
const DataArrayInt *fams(0);
mm.addGroup(0,grp2)
grp3=DataArrayInt.Range(0,m1.getNumberOfCells(),1) ; grp3.setName("grp3")
mm.addGroup(-1,grp3)
- assert(0 not in mm.getFamiliesIdsOnGroup("grp3")) # bug was here !
+ self.assertNotIn(0,mm.getFamiliesIdsOnGroup("grp3")) # bug was here !
grp4=DataArrayInt([3,5,8,10]) ; grp4.setName("grp4")
mm.addNodeGroup(grp4)
mm.rearrangeFamilies()
- assert(mm.getGrpNonEmptyLevelsExt("grp0")==(0,))
- assert(mm.getGrpNonEmptyLevelsExt("grp1")==(0,))
- assert(mm.getGrpNonEmptyLevelsExt("grp2")==(0,))
- assert(mm.getGrpNonEmptyLevelsExt("grp3")==(-1,))
- assert(mm.getGrpNonEmptyLevelsExt("grp4")==(1,))
+ self.assertEqual(mm.getGrpNonEmptyLevelsExt("grp0"),(0,))
+ self.assertEqual(mm.getGrpNonEmptyLevelsExt("grp1"),(0,))
+ self.assertEqual(mm.getGrpNonEmptyLevelsExt("grp2"),(0,))
+ self.assertEqual(mm.getGrpNonEmptyLevelsExt("grp3"),(-1,))
+ self.assertEqual(mm.getGrpNonEmptyLevelsExt("grp4"),(1,))
for grp in [grp0,grp1,grp2,grp3,grp4]:
- assert(mm.getGroupArr(mm.getGrpNonEmptyLevelsExt(grp.getName())[0],grp.getName()).isEqual(grp))
+ self.assertTrue(mm.getGroupArr(mm.getGrpNonEmptyLevelsExt(grp.getName())[0],grp.getName()).isEqual(grp))
pass
pass