*/
DataArrayIdType *MEDCouplingPointSet::zipConnectivityTraducer(int compType, mcIdType startCellId)
{
- DataArrayIdType *commonCells=0,*commonCellsI=0;
+ DataArrayIdType *commonCells(nullptr),*commonCellsI(nullptr);
findCommonCells(compType,startCellId,commonCells,commonCellsI);
MCAuto<DataArrayIdType> commonCellsTmp(commonCells),commonCellsITmp(commonCellsI);
mcIdType newNbOfCells=-1;
- MCAuto<DataArrayIdType> ret=DataArrayIdType::ConvertIndexArrayToO2N(ToIdType(getNumberOfCells()),commonCells->begin(),commonCellsI->begin(),
- commonCellsI->end(),newNbOfCells);
+ MCAuto<DataArrayIdType> ret=DataArrayIdType::ConvertIndexArrayToO2N(ToIdType(getNumberOfCells()),commonCells->begin(),commonCellsI->begin(),commonCellsI->end(),newNbOfCells);
MCAuto<DataArrayIdType> ret2=ret->invertArrayO2N2N2O(newNbOfCells);
MCAuto<MEDCouplingPointSet> self=buildPartOfMySelf(ret2->begin(),ret2->end(),true);
shallowCopyConnectivityFrom(self);
oss << " !";
throw INTERP_KERNEL::Exception(oss.str());
}
- MCAuto<DataArrayIdType> o2n=mesh->zipConnectivityTraducer(compType,nbOfCells);
- arr=o2n->subArray(nbOfCells);
- arr->setName(other->getName());
- mcIdType tmp;
+ //
if(other->getNumberOfCells()==0)
+ {
+ MCAuto<DataArrayIdType> dftRet(DataArrayIdType::New()); dftRet->alloc(0,1); arr=dftRet.retn(); arr->setName(other->getName());
return true;
- return arr->getMaxValue(tmp)<nbOfCells;
+ }
+ DataArrayIdType *commonCells(nullptr),*commonCellsI(nullptr);
+ mesh->findCommonCells(compType,nbOfCells,commonCells,commonCellsI);
+ MCAuto<DataArrayIdType> commonCellsTmp(commonCells),commonCellsITmp(commonCellsI);
+ mcIdType newNbOfCells=-1;
+ MCAuto<DataArrayIdType> o2n = DataArrayIdType::ConvertIndexArrayToO2N(ToIdType(mesh->getNumberOfCells()),commonCells->begin(),commonCellsI->begin(),commonCellsI->end(),newNbOfCells);
+ MCAuto<DataArrayIdType> p0(o2n->selectByTupleIdSafeSlice(0,nbOfCells,1));
+ mcIdType maxPart(p0->getMaxValueInArray());
+ bool ret(maxPart==newNbOfCells-1);
+ MCAuto<DataArrayIdType> p1(p0->invertArrayO2N2N2O(newNbOfCells));
+ // fill p1 array in case of presence of cells in other not in this
+ mcIdType *pt(p1->getPointer());
+ for(mcIdType i = maxPart ; i < newNbOfCells-1 ; ++i )
+ pt[i+1] = i+1;
+ //
+ MCAuto<DataArrayIdType> p2(o2n->subArray(nbOfCells));
+ p2->transformWithIndArr(p1->begin(),p1->end()); p2->setName(other->getName());
+ arr = p2.retn();
+ return ret;
}
/*!
self.assertTrue(m.deepCopy().zipConnectivityTraducer(1).isIota(3))
self.assertTrue(m.deepCopy().zipConnectivityTraducer(2).isEqual(DataArrayInt([0,1,1])))
+ def testBugAreCellsIncludedIn1(self):
+ """
+ Non regression test: a.areCellsIncludedIn(b) was buggy when some cells in b were duplicated into a following specified policy.
+ """
+ coo = DataArrayDouble([0,1,2,3,4],5,1)
+ m = MEDCouplingUMesh("",1)
+ m.setCoords(coo)
+ m.allocateCells()
+ # m contains several duplicated cells - some of those duplicated cells will be in m1
+ for i in range(3):
+ m.insertNextCell(NORM_SEG2,[0,1])
+ for i in range(4):
+ m.insertNextCell(NORM_SEG2,[1,2])
+ for i in range(2):
+ m.insertNextCell(NORM_SEG2,[2,3])
+ for i in range(2):
+ m.insertNextCell(NORM_SEG2,[3,4])
+ #
+ bexp = DataArrayInt([0,1,2, 3,4,5,6, 9,10])
+ m1 = m[bexp]
+ #
+ a,b = m.areCellsIncludedIn(m1,0)
+ self.assertTrue(a)
+ self.assertTrue(b.isEqual(DataArrayInt([2,2,2, 6,6,6,6, 10,10])))
+ #
+ bexp2 = DataArrayInt([0,1,2, 3,4,0, 6, 9,10])
+ m2 = m[bexp2]
+ a,b = m.areCellsIncludedIn(m2,0)
+ self.assertTrue(a)
+ self.assertTrue(b.isEqual(DataArrayInt([2,2,2,6,6,2,6,10,10])))
+
pass
if __name__ == '__main__':