- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cellIds=DataArrayInt::Range(beginCellIds,endCellIds,stepCellIds);
- return buildPart(cellIds->begin(),cellIds->end());
+ if(beginCellIds==0 && endCellIds==getNumberOfCells() && stepCellIds==1)
+ {
+ MEDCouplingMesh *ret(const_cast<MEDCouplingMesh *>(this));
+ ret->incrRef();
+ return ret;
+ }
+ else
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cellIds=DataArrayInt::Range(beginCellIds,endCellIds,stepCellIds);
+ return buildPart(cellIds->begin(),cellIds->end());
+ }