From 1619930c00ad9aa9ea3f7ace9c7346b239c82025 Mon Sep 17 00:00:00 2001 From: ageay Date: Wed, 10 Apr 2013 12:23:13 +0000 Subject: [PATCH] Extension of slice managements when delta<0 --- src/MEDCoupling_Swig/MEDCouplingMemArray.i | 30 +++++++++++++--------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/MEDCoupling_Swig/MEDCouplingMemArray.i b/src/MEDCoupling_Swig/MEDCouplingMemArray.i index e2b5417ea..9b057fb97 100644 --- a/src/MEDCoupling_Swig/MEDCouplingMemArray.i +++ b/src/MEDCoupling_Swig/MEDCouplingMemArray.i @@ -756,6 +756,7 @@ namespace ParaMEDMEM PyObject *__getitem__(PyObject *obj) throw(INTERP_KERNEL::Exception) { const char msg[]="Unexpected situation in DataArrayDouble::__getitem__ !"; + const char msg2[]="DataArrayDouble::__getitem__ : Mismatch of slice values in 2nd parameter (components) !"; self->checkAllocated(); int nbOfTuples=self->getNumberOfTuples(); int nbOfComponents=self->getNumberOfComponents(); @@ -821,7 +822,7 @@ namespace ParaMEDMEM case 13: { ret=self->selectByTupleIdSafe(&it1,&it1+1); - int nbOfComp=(pc1.second.first-1-pc1.first)/pc1.second.second+1; + int nbOfComp=DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2); std::vector v2(nbOfComp); for(int i=0;iselectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size()); - int nbOfComp=(pc1.second.first-1-pc1.first)/pc1.second.second+1; + int nbOfComp=DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2); std::vector v2(nbOfComp); for(int i=0;iselectByTupleId2(pt1.first,pt1.second.first,pt1.second.second); - int nbOfComp=(pc1.second.first-1-pc1.first)/pc1.second.second+1; + int nbOfComp=DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2); std::vector v2(nbOfComp); for(int i=0;iselectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems()); - int nbOfComp=(pc1.second.first-1-pc1.first)/pc1.second.second+1; + int nbOfComp=DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2); std::vector v2(nbOfComp); for(int i=0;i multiVal; @@ -1905,7 +1907,7 @@ namespace ParaMEDMEM } case 3: { - int sz=DataArray::GetNumberOfItemGivenBES(slic.first,slic.second.first,slic.second.second,""); + int sz=DataArray::GetNumberOfItemGivenBES(slic.first,slic.second.first,slic.second.second,msg2); PyObject *t=PyTuple_New(sz); for(int j=0;j multiValV; @@ -2025,7 +2028,7 @@ namespace ParaMEDMEM } case 3: { - int sz=DataArray::GetNumberOfItemGivenBES(slic.first,slic.second.first,slic.second.second,""); + int sz=DataArray::GetNumberOfItemGivenBES(slic.first,slic.second.first,slic.second.second,msg2); switch(sw1) { case 1: @@ -2863,6 +2866,7 @@ namespace ParaMEDMEM PyObject *__getitem__(PyObject *obj) throw(INTERP_KERNEL::Exception) { const char msg[]="Unexpected situation in DataArrayInt::__getitem__ !"; + const char msg2[]="DataArrayInt::__getitem__ : Mismatch of slice values in 2nd parameter (components) !"; self->checkAllocated(); int nbOfTuples=self->getNumberOfTuples(); int nbOfComponents=self->getNumberOfComponents(); @@ -2930,7 +2934,7 @@ namespace ParaMEDMEM case 13: { ret=self->selectByTupleIdSafe(&it1,&it1+1); - int nbOfComp=(pc1.second.first-1-pc1.first)/pc1.second.second+1; + int nbOfComp=DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2); std::vector v2(nbOfComp); for(int i=0;iselectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size()); - int nbOfComp=(pc1.second.first-1-pc1.first)/pc1.second.second+1; + int nbOfComp=DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2); std::vector v2(nbOfComp); for(int i=0;iselectByTupleId2(pt1.first,pt1.second.first,pt1.second.second); - int nbOfComp=(pc1.second.first-1-pc1.first)/pc1.second.second+1; + int nbOfComp=DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2); std::vector v2(nbOfComp); for(int i=0;iselectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems()); - int nbOfComp=(pc1.second.first-1-pc1.first)/pc1.second.second+1; + int nbOfComp=DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2); std::vector v2(nbOfComp); for(int i=0;i multiVal; @@ -4219,7 +4224,7 @@ namespace ParaMEDMEM } case 3: { - int sz=DataArray::GetNumberOfItemGivenBES(slic.first,slic.second.first,slic.second.second,""); + int sz=DataArray::GetNumberOfItemGivenBES(slic.first,slic.second.first,slic.second.second,msg2); PyObject *t=PyTuple_New(sz); for(int j=0;j multiValV; @@ -4340,7 +4346,7 @@ namespace ParaMEDMEM } case 3: { - int sz=DataArray::GetNumberOfItemGivenBES(slic.first,slic.second.first,slic.second.second,""); + int sz=DataArray::GetNumberOfItemGivenBES(slic.first,slic.second.first,slic.second.second,msg2); switch(sw1) { case 1: -- 2.39.2