From 30b589800c805a5d83170198b406fa1d9c4dcd1b Mon Sep 17 00:00:00 2001 From: eap Date: Tue, 10 Dec 2019 16:13:46 +0300 Subject: [PATCH] LOT4: fix tests. testHeapMem1 (MEDLoaderTest3.py) fails only --- src/INTERP_KERNEL/SplitterTetra.cxx | 8 +- src/MEDCoupling/MEDCouplingField.cxx | 2 +- src/MEDCoupling/MEDCouplingField.hxx | 2 +- src/MEDCoupling/MEDCouplingFieldDouble.cxx | 2 +- src/MEDCoupling/MEDCouplingFieldDouble.hxx | 2 +- src/MEDCoupling/MEDCouplingMemArray.hxx | 4 +- src/MEDCoupling/MEDCouplingMemArray.txx | 4 +- src/MEDCoupling/MEDCouplingMemArrayChar.cxx | 6 +- src/MEDCoupling/MEDCouplingTraits.hxx | 4 + src/MEDCoupling/MEDCouplingUMesh.cxx | 9 +- .../Test/MEDCouplingBasicsTest1.cxx | 2 +- .../Test/MEDCouplingBasicsTest3.cxx | 17 +- .../Test/MEDCouplingBasicsTest4.cxx | 4 +- .../Test/MEDCouplingBasicsTest5.cxx | 5 +- src/MEDCoupling_Swig/DataArrayInt.i | 104 +++---- .../MEDCouplingBasicsTest2.py | 4 +- .../MEDCouplingBasicsTest3.py | 2 +- src/MEDCoupling_Swig/MEDCouplingCommon.i | 128 ++++---- .../MEDCouplingDataArrayTypemaps.i | 289 +++++++++--------- .../MEDCouplingFieldDiscretization.i | 14 +- src/MEDCoupling_Swig/MEDCouplingMemArray.i | 116 +++---- src/MEDCoupling_Swig/MEDCouplingTypemaps.i | 10 +- 22 files changed, 378 insertions(+), 360 deletions(-) diff --git a/src/INTERP_KERNEL/SplitterTetra.cxx b/src/INTERP_KERNEL/SplitterTetra.cxx index 543ce3cbd..c906545d3 100644 --- a/src/INTERP_KERNEL/SplitterTetra.cxx +++ b/src/INTERP_KERNEL/SplitterTetra.cxx @@ -186,19 +186,19 @@ namespace INTERP_KERNEL } case NORM_POLYHED: { - std::size_t nbOfFaces(std::count(nodalConnBg,nodalConnEnd,-1)+1); - std::size_t nbOfTetra(std::distance(nodalConnBg,nodalConnEnd)-nbOfFaces+1); + mcIdType nbOfFaces(ToIdType(std::count(nodalConnBg,nodalConnEnd,-1)+1)); + mcIdType nbOfTetra(ToIdType(std::distance(nodalConnBg,nodalConnEnd)-nbOfFaces+1)); addCoords.resize((nbOfFaces+1)*3); tetrasNodalConn.resize(nbOfTetra*4); mcIdType *conn(&tetrasNodalConn[0]); const mcIdType *work(nodalConnBg); double *tmp(&addCoords[0]),*tmp2(&addCoords[3*nbOfFaces]); tmp2[0]=0.; tmp2[1]=0.; tmp2[2]=0.; - for(unsigned int i=0;i getGaussLocalizationIdsOfOneType(INTERP_KERNEL::NormalizedCellType type) const; MEDCOUPLING_EXPORT mcIdType getNbOfGaussLocalization() const; - MEDCOUPLING_EXPORT mcIdType getGaussLocalizationIdOfOneCell(int cellId) const; + MEDCOUPLING_EXPORT mcIdType getGaussLocalizationIdOfOneCell(mcIdType cellId) const; MEDCOUPLING_EXPORT void getCellIdsHavingGaussLocalization(int locId, std::vector& cellIds) const; MEDCOUPLING_EXPORT const MEDCouplingGaussLocalization& getGaussLocalization(int locId) const; MEDCOUPLING_EXPORT void updateTime() const; diff --git a/src/MEDCoupling/MEDCouplingFieldDouble.cxx b/src/MEDCoupling/MEDCouplingFieldDouble.cxx index e2113c3e3..351a7b6c5 100755 --- a/src/MEDCoupling/MEDCouplingFieldDouble.cxx +++ b/src/MEDCoupling/MEDCouplingFieldDouble.cxx @@ -945,7 +945,7 @@ void MEDCouplingFieldDouble::integral(bool isWAbs, double *res) const * \ref py_mcfielddouble_getValueOnPos "Here is a Python example". * \endif */ -void MEDCouplingFieldDouble::getValueOnPos(int i, int j, int k, double *res) const +void MEDCouplingFieldDouble::getValueOnPos(mcIdType i, mcIdType j, mcIdType k, double *res) const { const DataArrayDouble *arr=timeDiscr()->getArray(); if(!_mesh) diff --git a/src/MEDCoupling/MEDCouplingFieldDouble.hxx b/src/MEDCoupling/MEDCouplingFieldDouble.hxx index 91ced90cb..4f65fa050 100644 --- a/src/MEDCoupling/MEDCouplingFieldDouble.hxx +++ b/src/MEDCoupling/MEDCouplingFieldDouble.hxx @@ -70,7 +70,7 @@ namespace MEDCoupling MEDCOUPLING_EXPORT void normMax(double *res) const; MEDCOUPLING_EXPORT double integral(int compId, bool isWAbs) const; MEDCOUPLING_EXPORT void integral(bool isWAbs, double *res) const; - MEDCOUPLING_EXPORT void getValueOnPos(int i, int j, int k, double *res) const; + MEDCOUPLING_EXPORT void getValueOnPos(mcIdType i, mcIdType j, mcIdType k, double *res) const; MEDCOUPLING_EXPORT void getValueOn(const double *spaceLoc, double *res) const; MEDCOUPLING_EXPORT void getValueOn(const double *spaceLoc, double time, double *res) const; MEDCOUPLING_EXPORT DataArrayDouble *getValueOnMulti(const double *spaceLoc, int nbOfPoints) const; diff --git a/src/MEDCoupling/MEDCouplingMemArray.hxx b/src/MEDCoupling/MEDCouplingMemArray.hxx index 28d3ddec4..549f3ca9b 100755 --- a/src/MEDCoupling/MEDCouplingMemArray.hxx +++ b/src/MEDCoupling/MEDCouplingMemArray.hxx @@ -323,7 +323,7 @@ namespace MEDCoupling { public: MEDCOUPLING_EXPORT MCAuto convertToDblArr() const; - MEDCOUPLING_EXPORT MCAuto convertToIntArr() const; + MEDCOUPLING_EXPORT MCAuto convertToIntArr() const; MEDCOUPLING_EXPORT MCAuto convertToFloatArr() const; MEDCOUPLING_EXPORT void applyLin(T a, T b, std::size_t compoId); MEDCOUPLING_EXPORT void applyLin(T a, T b); @@ -761,7 +761,7 @@ namespace MEDCoupling MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const DataArrayChar& other) const; MEDCOUPLING_EXPORT std::string repr() const; MEDCOUPLING_EXPORT std::string reprZip() const; - MEDCOUPLING_EXPORT DataArrayIdType *convertToIntArr() const; + MEDCOUPLING_EXPORT DataArrayInt *convertToIntArr() const; MEDCOUPLING_EXPORT DataArrayChar *selectByTupleId(const mcIdType *new2OldBg, const mcIdType *new2OldEnd) const { return this->mySelectByTupleId(new2OldBg,new2OldEnd); } MEDCOUPLING_EXPORT DataArrayChar *selectByTupleId(const DataArrayIdType& di) const { return this->mySelectByTupleId(di); } MEDCOUPLING_EXPORT DataArrayChar *selectByTupleIdSafe(const mcIdType *new2OldBg, const mcIdType *new2OldEnd) const { return DataArrayTemplate::mySelectByTupleIdSafe(new2OldBg,new2OldEnd); } diff --git a/src/MEDCoupling/MEDCouplingMemArray.txx b/src/MEDCoupling/MEDCouplingMemArray.txx index 68980ddac..e054290ad 100755 --- a/src/MEDCoupling/MEDCouplingMemArray.txx +++ b/src/MEDCoupling/MEDCouplingMemArray.txx @@ -2575,9 +2575,9 @@ namespace MEDCoupling * \return DataArrayInt * - the new instance of DataArrayInt. */ template - MCAuto DataArrayTemplateClassic::convertToIntArr() const + MCAuto DataArrayTemplateClassic::convertToIntArr() const { - return convertToOtherTypeOfArr(); + return convertToOtherTypeOfArr(); } /*! diff --git a/src/MEDCoupling/MEDCouplingMemArrayChar.cxx b/src/MEDCoupling/MEDCouplingMemArrayChar.cxx index 1c083670d..965794bf8 100755 --- a/src/MEDCoupling/MEDCouplingMemArrayChar.cxx +++ b/src/MEDCoupling/MEDCouplingMemArrayChar.cxx @@ -117,14 +117,14 @@ std::string DataArrayChar::reprZip() const * array to the new one. * \return DataArrayIdType * - the new instance of DataArrayChar. */ -DataArrayIdType *DataArrayChar::convertToIntArr() const +DataArrayInt *DataArrayChar::convertToIntArr() const { checkAllocated(); - DataArrayIdType *ret=DataArrayIdType::New(); + DataArrayInt *ret=DataArrayInt::New(); ret->alloc(getNumberOfTuples(),getNumberOfComponents()); std::size_t nbOfVals=getNbOfElems(); const char *src=getConstPointer(); - mcIdType *dest=ret->getPointer(); + int *dest=ret->getPointer(); std::copy(src,src+nbOfVals,dest); ret->copyStringInfoFrom(*this); return ret; diff --git a/src/MEDCoupling/MEDCouplingTraits.hxx b/src/MEDCoupling/MEDCouplingTraits.hxx index d0d8f7446..9d10b48fa 100644 --- a/src/MEDCoupling/MEDCouplingTraits.hxx +++ b/src/MEDCoupling/MEDCouplingTraits.hxx @@ -46,8 +46,10 @@ namespace MEDCoupling class DataArrayInt64Tuple; class DataArrayFloatTuple; class DataArrayDoubleTuple; + class DataArrayByteTuple; class DataArrayInt32Iterator; class DataArrayInt64Iterator; + class DataArrayByteIterator; template<> struct MEDCOUPLING_EXPORT Traits @@ -111,6 +113,8 @@ namespace MEDCoupling static const char ArrayTypeName[]; typedef DataArrayByte ArrayTypeCh; typedef DataArrayChar ArrayType; + typedef DataArrayByteTuple ArrayTuple; + typedef DataArrayByteIterator IteratorType; }; } diff --git a/src/MEDCoupling/MEDCouplingUMesh.cxx b/src/MEDCoupling/MEDCouplingUMesh.cxx index 603f7c5f7..05eaf2661 100755 --- a/src/MEDCoupling/MEDCouplingUMesh.cxx +++ b/src/MEDCoupling/MEDCouplingUMesh.cxx @@ -7564,11 +7564,12 @@ void MEDCouplingUMesh::writeVTKLL(std::ostream& ofs, const std::string& cellData } types->transformWithIndArr(MEDCOUPLING2VTKTYPETRADUCER,MEDCOUPLING2VTKTYPETRADUCER+INTERP_KERNEL::NORM_MAXTYPE+1); types->writeVTK(ofs,8,"UInt8","types",byteData); - offsets->writeVTK(ofs,8,"Int32","offsets",byteData); + std::string vtkTypeName = Traits::VTKReprStr; + offsets->writeVTK(ofs,8,vtkTypeName,"offsets",byteData); if(szFaceOffsets!=0) {//presence of Polyhedra connectivity->reAlloc(szConn); - faceoffsets->writeVTK(ofs,8,"Int32","faceoffsets",byteData); + faceoffsets->writeVTK(ofs,8,vtkTypeName,"faceoffsets",byteData); MCAuto faces=DataArrayIdType::New(); faces->alloc(szFaceOffsets,1); w1=faces->getPointer(); for(mcIdType i=0;iwriteVTK(ofs,8,"Int32","faces",byteData); + faces->writeVTK(ofs,8,vtkTypeName,"faces",byteData); } - connectivity->writeVTK(ofs,8,"Int32","connectivity",byteData); + connectivity->writeVTK(ofs,8,vtkTypeName,"connectivity",byteData); ofs << " \n"; ofs << " \n"; ofs << " \n"; diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest1.cxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest1.cxx index 2473089de..417e6bbab 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest1.cxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest1.cxx @@ -72,7 +72,7 @@ void MEDCouplingBasicsTest1::testArray2() arr->setInfoOnComponent(1,"hhhh"); arr->setInfoOnComponent(2,"jj"); arr->setInfoOnComponent(3,"kkkkkk"); - MCAuto arr2(arr->convertToIntArr()); + MCAuto arr2(arr->convertToIntArr()); MCAuto arr3(arr2->convertToDblArr()); CPPUNIT_ASSERT(arr->isEqual(*arr3,1e-14)); arr->decrRef(); diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest3.cxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest3.cxx index 3841f4fd7..52200697a 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest3.cxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest3.cxx @@ -24,6 +24,7 @@ #include "MEDCouplingMappedExtrudedMesh.hxx" #include "MEDCouplingFieldDouble.hxx" #include "MEDCouplingMemArray.hxx" +#include "MEDCouplingMemArray.txx" #include "MEDCouplingGaussLocalization.hxx" #include @@ -681,8 +682,8 @@ void MEDCouplingBasicsTest3::testKeepSetSelectedComponent1() const double expected1[30]={2.,3.,2.,3.,1.,1., 12.,13.,12.,13.,11.,11., 22.,23.,22.,23.,21.,21., 32.,33.,32.,33.,31.,31., 42.,43.,42.,43.,41.,41.}; for(int i=0;i<30;i++) CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],a2->getIJ(0,i),1e-14); - MCAuto a3(a1->convertToIntArr()); - DataArrayIdType *a4=static_cast(a3->keepSelectedComponents(arr2V)); + MCAuto a3(a1->convertToIntArr()); + DataArrayInt *a4=static_cast(a3->keepSelectedComponents(arr2V)); CPPUNIT_ASSERT_EQUAL(6,(int)a4->getNumberOfComponents()); CPPUNIT_ASSERT_EQUAL(5,(int)a4->getNumberOfTuples()); CPPUNIT_ASSERT(std::string(a4->getInfoOnComponent(0))=="bbbb"); @@ -692,7 +693,7 @@ void MEDCouplingBasicsTest3::testKeepSetSelectedComponent1() CPPUNIT_ASSERT(std::string(a4->getInfoOnComponent(4))=="aaaa"); CPPUNIT_ASSERT(std::string(a4->getInfoOnComponent(5))=="aaaa"); for(int i=0;i<30;i++) - CPPUNIT_ASSERT_EQUAL(ToIdType(expected1[i]),a4->getIJ(0,i)); + CPPUNIT_ASSERT_EQUAL((int)expected1[i],a4->getIJ(0,i)); // setSelectedComponents const mcIdType arr3[2]={3,2}; std::vector arr3V(arr3,arr3+2); @@ -713,7 +714,7 @@ void MEDCouplingBasicsTest3::testKeepSetSelectedComponent1() const double expected2[30]={2.,4.,3.,3.,1.,1., 12.,14.,13.,13.,11.,11., 22.,24.,23.,23.,21.,21., 32.,34.,33.,33.,31.,31., 42.,44.,43.,43.,41.,41.}; for(int i=0;i<30;i++) CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],a2->getIJ(0,i),1e-14); - MCAuto a6=a5->convertToIntArr(); + MCAuto a6=a5->convertToIntArr(); a6->setInfoOnComponent(0,"eeee"); a6->setInfoOnComponent(1,"ffff"); a4->setSelectedComponents(a6,arr4V); @@ -1665,8 +1666,8 @@ void MEDCouplingBasicsTest3::testDAMeld1() for(int i=0;i<35;i++) CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],da1->getIJ(0,i),1e-10); // - MCAuto dai1=da1C->convertToIntArr(); - MCAuto dai3=da3->convertToIntArr(); + MCAuto dai1=da1C->convertToIntArr(); + MCAuto dai3=da3->convertToIntArr(); dai1->meldWith(dai3); CPPUNIT_ASSERT_EQUAL(5,(int)dai1->getNumberOfComponents()); CPPUNIT_ASSERT_EQUAL(7,(int)dai1->getNumberOfTuples()); @@ -1676,7 +1677,7 @@ void MEDCouplingBasicsTest3::testDAMeld1() CPPUNIT_ASSERT(dai1->getInfoOnComponent(3)=="c1da3"); CPPUNIT_ASSERT(dai1->getInfoOnComponent(4)=="c2da3"); for(int i=0;i<35;i++) - CPPUNIT_ASSERT_EQUAL(ToIdType(expected1[i]),dai1->getIJ(0,i)); + CPPUNIT_ASSERT_EQUAL((int)expected1[i],dai1->getIJ(0,i)); // test of static method DataArrayDouble::meld DataArrayDouble *da4=DataArrayDouble::Meld(da1C,da3); CPPUNIT_ASSERT_EQUAL(5,(int)da4->getNumberOfComponents()); @@ -1690,7 +1691,7 @@ void MEDCouplingBasicsTest3::testDAMeld1() CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],da4->getIJ(0,i),1e-10); // test of static method DataArrayIdType::meld dai1=da1C->convertToIntArr(); - DataArrayIdType *dai4=DataArrayIdType::Meld(dai1,dai3); + DataArrayInt *dai4=DataArrayInt::Meld(dai1,dai3); CPPUNIT_ASSERT_EQUAL(5,(int)dai4->getNumberOfComponents()); CPPUNIT_ASSERT_EQUAL(7,(int)dai4->getNumberOfTuples()); CPPUNIT_ASSERT(dai4->getInfoOnComponent(0)=="c0da1"); diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest4.cxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest4.cxx index 126a949e8..7eb6e1364 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest4.cxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest4.cxx @@ -998,8 +998,8 @@ void MEDCouplingBasicsTest4::testDACpyFrom1() d1->deepCopyFrom(*d); CPPUNIT_ASSERT(d->isEqual(*d1,1e-12)); // - MCAuto d2=d->convertToIntArr(); - DataArrayIdType *d4=DataArrayIdType::New(); + MCAuto d2=d->convertToIntArr(); + DataArrayInt *d4=DataArrayInt::New(); CPPUNIT_ASSERT(!d2->isEqual(*d4)); d4->deepCopyFrom(*d2); CPPUNIT_ASSERT(d2->isEqual(*d4)); diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest5.cxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest5.cxx index 935a25517..41a7cb634 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest5.cxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest5.cxx @@ -24,6 +24,7 @@ #include "MEDCouplingMappedExtrudedMesh.hxx" #include "MEDCouplingFieldDouble.hxx" #include "MEDCouplingMemArray.hxx" +#include "MEDCouplingMemArray.txx" #include "MEDCouplingGaussLocalization.hxx" #include "MEDCouplingMultiFields.hxx" #include "MEDCouplingFieldOverTime.hxx" @@ -601,7 +602,7 @@ void MEDCouplingBasicsTest5::testDataArrayAbs1() const double expected1[12]={2.,3.,5.,6.,7.,8.,9.,10.,11.,12.,13.,15.}; d1->alloc(6,2); std::copy(val1,val1+12,d1->getPointer()); - MCAuto d2=d1->convertToIntArr(); + MCAuto d2=d1->convertToIntArr(); // d1->abs(); for(int i=0;i<12;i++) @@ -610,7 +611,7 @@ void MEDCouplingBasicsTest5::testDataArrayAbs1() const mcIdType expected2[12]={2,3,5,6,7,8,9,10,11,12,13,15}; d2->abs(); for(int i=0;i<12;i++) - CPPUNIT_ASSERT_EQUAL(expected2[i],d2->getIJ(0,i)); + CPPUNIT_ASSERT_EQUAL((int)expected2[i],d2->getIJ(0,i)); // d1->decrRef(); } diff --git a/src/MEDCoupling_Swig/DataArrayInt.i b/src/MEDCoupling_Swig/DataArrayInt.i index 1f462d7a1..6017f1559 100644 --- a/src/MEDCoupling_Swig/DataArrayInt.i +++ b/src/MEDCoupling_Swig/DataArrayInt.i @@ -58,33 +58,33 @@ std::string repr() const; std::string reprZip() const; std::string reprNotTooLong() const; - ARRAY *invertArrayO2N2N2O(INT newNbOfElem) const; - ARRAY *invertArrayN2O2O2N(INT oldNbOfElem) const; - ARRAY *invertArrayO2N2N2OBis(INT newNbOfElem) const; + ARRAY *invertArrayO2N2N2O(mcIdType newNbOfElem) const; + ARRAY *invertArrayN2O2O2N(mcIdType oldNbOfElem) const; + ARRAY *invertArrayO2N2N2OBis(mcIdType newNbOfElem) const; DataArrayIdType *indicesOfSubPart(const ARRAY& partOfThis) const; ARRAY *fromNoInterlace() const; ARRAY *toNoInterlace() const; - ARRAY *selectByTupleIdSafeSlice(INT bg, INT end, INT step) const; + ARRAY *selectByTupleIdSafeSlice(mcIdType bg, mcIdType end, mcIdType step) const; DataArrayIdType *checkAndPreparePermutation() const; DataArrayIdType *buildPermArrPerLevel() const; - bool isIota(INT sizeExpected) const; + bool isIota(mcIdType sizeExpected) const; bool isUniform(INT val) const; INT checkUniformAndGuess() const; bool hasUniqueValues() const; - ARRAY *subArray(INT tupleIdBg, INT tupleIdEnd=-1) const; + ARRAY *subArray(mcIdType tupleIdBg, mcIdType tupleIdEnd=-1) const; void transpose(); ARRAY *changeNbOfComponents(std::size_t newNbOfComp, INT dftValue) const; void meldWith(const ARRAY *other); - void setPartOfValues1(const ARRAY *a, INT bgTuples, INT endTuples, INT stepTuples, INT bgComp, INT endComp, INT stepComp, bool strictCompoCompare=true); - void setPartOfValuesSimple1(INT a, INT bgTuples, INT endTuples, INT stepTuples, INT bgComp, INT endComp, INT stepComp); + void setPartOfValues1(const ARRAY *a, mcIdType bgTuples, mcIdType endTuples, mcIdType stepTuples, mcIdType bgComp, mcIdType endComp, mcIdType stepComp, bool strictCompoCompare=true); + void setPartOfValuesSimple1(INT a, mcIdType bgTuples, mcIdType endTuples, mcIdType stepTuples, mcIdType bgComp, mcIdType endComp, mcIdType stepComp); void setPartOfValuesAdv(const ARRAY *a, const DataArrayIdType *tuplesSelec); - void getTuple(INT tupleId, INT *res) const; + void getTuple(mcIdType tupleId, INT *res) const; INT getIJ(std::size_t tupleId, std::size_t compoId) const; - INT getIJSafe(INT tupleId, INT compoId) const; + INT getIJSafe(std::size_t tupleId, std::size_t compoId) const; INT front() const; INT back() const; - void setIJ(INT tupleId, INT compoId, INT newVal); - void setIJSilent(INT tupleId, INT compoId, INT newVal); + void setIJ(mcIdType tupleId, mcIdType compoId, INT newVal); + void setIJSilent(mcIdType tupleId, mcIdType compoId, INT newVal); INT *getPointer(); const INT *getConstPointer() const; ARRAY ## Iterator *iterator(); @@ -140,7 +140,7 @@ DataArrayIdType *findRangeIdForEachTuple(const ARRAY *ranges) const; ARRAY *findIdInRangeForEachTuple(const ARRAY *ranges) const; void sortEachPairToMakeALinkedList(); - ARRAY *duplicateEachTupleNTimes(INT nbTimes) const; + ARRAY *duplicateEachTupleNTimes(mcIdType nbTimes) const; ARRAY *getDifferentValues() const; static ARRAY *Add(const ARRAY *a1, const ARRAY *a2); void addEqual(const ARRAY *other); @@ -185,14 +185,14 @@ { if(PyInt_Check(nbOfTuples)) { - mcIdType nbOfTuples1=PyInt_AS_LONG(nbOfTuples); + mcIdType nbOfTuples1=ToIdType(PyInt_AS_LONG(nbOfTuples)); if(nbOfTuples1<0) throw INTERP_KERNEL::Exception("ARRAY::New : should be a positive set of allocated memory !"); if(nbOfComp) { if(PyInt_Check(nbOfComp)) {//ARRAY.New([1,3,4,5],2,2) - mcIdType nbOfCompo=PyInt_AS_LONG(nbOfComp); + mcIdType nbOfCompo=ToIdType(PyInt_AS_LONG(nbOfComp)); if(nbOfCompo<0) throw INTERP_KERNEL::Exception("ARRAY::New : should be a positive number of components !"); MCAuto ret=ARRAY::New(); @@ -226,7 +226,7 @@ } else if(PyInt_Check(elt0)) { - INT nbOfTuples1=PyInt_AS_LONG(elt0); + INT nbOfTuples1=(INT)PyInt_AS_LONG(elt0); if(nbOfTuples1<0) throw INTERP_KERNEL::Exception("ARRAY::New : should be a positive set of allocated memory !"); if(nbOfTuples) @@ -235,7 +235,7 @@ { if(PyInt_Check(nbOfTuples)) {//ARRAY.New(5,2) - INT nbOfCompo=PyInt_AS_LONG(nbOfTuples); + INT nbOfCompo=(INT)PyInt_AS_LONG(nbOfTuples); if(nbOfCompo<0) throw INTERP_KERNEL::Exception("ARRAY::New : should be a positive number of components !"); MCAuto ret=ARRAY::New(); @@ -274,7 +274,7 @@ return self->reprNotTooLong(); } - INT __len__() const + mcIdType __len__() const { if(self->isAllocated()) { @@ -298,7 +298,7 @@ PyObject *accumulate() const { - mcIdType sz=self->getNumberOfComponents(); + mcIdType sz=ToIdType(self->getNumberOfComponents()); INTERP_KERNEL::AutoPtr tmp=new INT[sz]; self->accumulate((INT *)tmp); return convertIntArrToPyList((const INT *)tmp,sz); @@ -348,7 +348,7 @@ GetIndicesOfSliceExplicitely(slic,&strt,&stp,&step,"ARRAY::buildExplicitArrOfSliceOnScaledArr (wrap) : the input slice is invalid !"); if(strt==std::numeric_limits::max() || stp==std::numeric_limits::max()) throw INTERP_KERNEL::Exception("ARRAY::buildExplicitArrOfSliceOnScaledArr (wrap) : the input slice contains some unknowns that can't be determined in static method ! Call DataArray::getSlice (non static) instead !"); - return self->buildExplicitArrOfSliceOnScaledArr(strt,stp,step); + return self->buildExplicitArrOfSliceOnScaledArr((INT)strt,(INT)stp,(INT)step); } PyObject *getMinMaxValues() const @@ -397,14 +397,14 @@ { if(PyInt_Check(nbOfTuples)) { - mcIdType nbOfTuples1=PyInt_AS_LONG(nbOfTuples); + mcIdType nbOfTuples1=ToIdType(PyInt_AS_LONG(nbOfTuples)); if(nbOfTuples1<0) throw INTERP_KERNEL::Exception("ARRAY::setValue : should be a positive set of allocated memory !"); if(nbOfComp && nbOfComp != Py_None) { if(PyInt_Check(nbOfComp)) {//ARRAY.setValues([1,3,4,5],2,2) - mcIdType nbOfCompo=PyInt_AS_LONG(nbOfComp); + mcIdType nbOfCompo=ToIdType(PyInt_AS_LONG(nbOfComp)); if(nbOfCompo<0) throw INTERP_KERNEL::Exception("ARRAY::setValue : should be a positive number of components !"); std::vector tmp=fillArrayWithPyListInt2(li,nbOfTuples1,nbOfCompo); @@ -455,7 +455,7 @@ PyObject *getValuesAsTuple() const { const INT *vals=self->getConstPointer(); - mcIdType nbOfComp=self->getNumberOfComponents(); + mcIdType nbOfComp=ToIdType(self->getNumberOfComponents()); mcIdType nbOfTuples=self->getNumberOfTuples(); return convertIntArrToPyListOfTuple(vals,nbOfComp,nbOfTuples); } @@ -468,9 +468,9 @@ DataArrayIdType *ret0=MEDCoupling::ARRAY::MakePartition(groups,newNb,fidsOfGroups); PyObject *ret = PyList_New(2); PyList_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTITraits::TI, SWIG_POINTER_OWN | 0 )); - mcIdType sz=fidsOfGroups.size(); + std::size_t sz=fidsOfGroups.size(); PyObject *ret1 = PyList_New(sz); - for(mcIdType i=0;igetNumberOfComponents(); + mcIdType sz=ToIdType(self->getNumberOfComponents()); INTERP_KERNEL::AutoPtr tmp=new INT[sz]; self->getTuple(tupleId,tmp); return convertIntArrToPyList((const INT*)tmp,sz); @@ -751,7 +751,7 @@ mcIdType index(PyObject *obj) const { - mcIdType nbOfCompo=self->getNumberOfComponents(); + std::size_t nbOfCompo=self->getNumberOfComponents(); switch(nbOfCompo) { case 1: @@ -775,7 +775,7 @@ bool __contains__(PyObject *obj) const { - mcIdType nbOfCompo=self->getNumberOfComponents(); + std::size_t nbOfCompo=self->getNumberOfComponents(); switch(nbOfCompo) { case 0: @@ -805,7 +805,7 @@ const char msg2[]="ARRAY::__getitem__ : Mismatch of slice values in 2nd parameter (components) !"; self->checkAllocated(); mcIdType nbOfTuples=self->getNumberOfTuples(); - mcIdType nbOfComponents=self->getNumberOfComponents(); + std::size_t nbOfComponents=self->getNumberOfComponents(); mcIdType it1; std::size_t ic1; std::vector vt1; @@ -813,7 +813,7 @@ std::pair > pt1,pc1; DataArrayIdType *dt1=0,*dc1=0; mcIdType sw; - convertObjToPossibleCpp3(obj,nbOfTuples,nbOfComponents,sw,it1,ic1,vt1,vc1,pt1,pc1,dt1,dc1); + convertObjToPossibleCpp3(obj,nbOfTuples,(int)nbOfComponents,sw,it1,ic1,vt1,vc1,pt1,pc1,dt1,dc1); MCAuto ret; switch(sw) { @@ -915,7 +915,7 @@ self->checkAllocated(); const char msg[]="Unexpected situation in __setitem__ !"; mcIdType nbOfTuples=self->getNumberOfTuples(); - mcIdType nbOfComponents=self->getNumberOfComponents(); + int nbOfComponents=(int)self->getNumberOfComponents(); mcIdType sw1,sw2; INT i1; std::vector v1; @@ -2304,18 +2304,18 @@ { const char msg2[]="ARRAY ## Tuple::__getitem__ : Mismatch of slice values in 2nd parameter (components) !"; mcIdType sw; - mcIdType singleVal; - std::vector multiVal; + INT singleVal; + std::vector multiVal; std::pair > slic; MEDCoupling::DataArrayIdType *daIntTyypp=0; const INT *pt=self->getConstPointer(); - INT nbc=self->getNumberOfCompo(); - convertIntStarOrSliceLikePyObjToCppWithNegIntInterp(obj,nbc,sw,singleVal,multiVal,slic,daIntTyypp); + INT nbc=(INT)self->getNumberOfCompo(); + convertIntStarOrSliceLikePyObjToCppWithNegIntInterp(obj,ToIdType(nbc),sw,singleVal,multiVal,slic,daIntTyypp); switch(sw) { case 1: { - if(singleVal>=nbc) + if(singleVal>=(INT)nbc) { std::ostringstream oss; oss << "Requesting for id " << singleVal << " having only " << nbc << " components !"; @@ -2339,10 +2339,10 @@ case 2: { PyObject *t=PyTuple_New(multiVal.size()); - for(INT j=0;j<(INT)multiVal.size();j++) + for(std::size_t j=0;j=nbc) + if(cid>=(INT)nbc) { std::ostringstream oss; oss << "Requesting for id #" << cid << " having only " << nbc << " components !"; @@ -2354,7 +2354,7 @@ } case 3: { - INT sz=DataArray::GetNumberOfItemGivenBES(slic.first,slic.second.first,slic.second.second,msg2); + mcIdType sz=DataArray::GetNumberOfItemGivenBES(slic.first,slic.second.first,slic.second.second,msg2); PyObject *t=PyTuple_New(sz); for(INT j=0;j multiValV; std::pair > slicV; MEDCoupling::ARRAY ## Tuple *daIntTyyppV=0; - INT nbc=self->getNumberOfCompo(); + mcIdType nbc=ToIdType(self->getNumberOfCompo()); convertObjToPossibleCpp22(value,nbc,sw1,singleValV,multiValV,slicV,daIntTyyppV); INT singleVal; std::vector multiVal; @@ -2396,7 +2396,7 @@ { case 1: { - pt[singleVal]=singleValV; + pt[singleVal]=(INT)singleValV; return self; } case 2: @@ -2407,7 +2407,7 @@ oss << "Requesting for setting id # " << singleVal << " with a list or tuple with size != 1 ! "; throw INTERP_KERNEL::Exception(oss.str().c_str()); } - pt[singleVal]=multiValV[0]; + pt[singleVal]=(INT)multiValV[0]; return self; } case 4: @@ -2433,7 +2433,7 @@ oss << "Requesting for setting id # " << *it << " having only " << nbc << " components !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } - pt[*it]=singleValV; + pt[*it]=(INT)singleValV; } return self; } @@ -2454,7 +2454,7 @@ oss << "Requesting for setting id # " << pos << " having only " << nbc << " components !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } - pt[multiVal[i]]=multiValV[i]; + pt[multiVal[i]]=(INT)multiValV[i]; } return self; } @@ -2476,37 +2476,37 @@ } case 3: { - INT sz=DataArray::GetNumberOfItemGivenBES(slic.first,slic.second.first,slic.second.second,msg2); + std::size_t sz=DataArray::GetNumberOfItemGivenBES(slic.first,slic.second.first,slic.second.second,msg2); switch(sw1) { case 1: { - for(INT j=0;jgetConstPointer(); - if(sz>(INT)daIntTyyppV->getNumberOfCompo()) + if(sz>daIntTyyppV->getNumberOfCompo()) { std::ostringstream oss; oss << "Mismatch length of during assignment : " << nbc << " != " << daIntTyyppV->getNumberOfCompo() << " !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } - for(INT j=0;j; +%template(i64vec) std::vector; #else //typedef std::int64_t mcIdType; typedef long int mcIdType; typedef DataArrayInt64 DataArrayIdType; %template(ivec) std::vector; +%template(i32vec) std::vector; #endif @@ -541,7 +543,7 @@ typedef DataArrayInt64 DataArrayIdType; Py_ssize_t sz(sizeof(MEDCouplingUMesh::MEDCOUPLING2VTKTYPETRADUCER)/sizeof(decltype(MEDCouplingUMesh::MEDCOUPLING2VTKTYPETRADUCER[0]))); auto maxElt(*std::max_element(MEDCouplingUMesh::MEDCOUPLING2VTKTYPETRADUCER,MEDCouplingUMesh::MEDCOUPLING2VTKTYPETRADUCER+sz)); auto szOut(maxElt+1); - std::vector< int > retCpp(szOut,-1); + std::vector< mcIdType > retCpp(szOut,-1); mcIdType id(0); for(const mcIdType *it=MEDCouplingUMesh::MEDCOUPLING2VTKTYPETRADUCER;it!=MEDCouplingUMesh::MEDCOUPLING2VTKTYPETRADUCER+sz;it++,id++) { @@ -739,7 +741,7 @@ namespace MEDCoupling return ret2; } - int getCellContainingPoint(PyObject *p, double eps) const + mcIdType getCellContainingPoint(PyObject *p, double eps) const { double val; DataArrayDouble *a; @@ -998,9 +1000,9 @@ namespace MEDCoupling for(std::size_t j=0;jbuildNewNumberingFromCommonNodesFormat(comm,commIndex,newNbOfNodes); PyObject *res = PyList_New(2); PyList_SetItem(res,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTITraits::TI, SWIG_POINTER_OWN | 0 )); - PyList_SetItem(res,1,SWIG_From_int(newNbOfNodes)); + PyList_SetItem(res,1,PyInt_FromLong(newNbOfNodes)); return res; } @@ -1751,7 +1753,7 @@ namespace MEDCoupling PyObject *res = PyList_New(3); PyList_SetItem(res,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTITraits::TI, SWIG_POINTER_OWN | 0 )); PyList_SetItem(res,1,SWIG_From_bool(ret1)); - PyList_SetItem(res,2,SWIG_From_int(ret2)); + PyList_SetItem(res,2,PyInt_FromLong(ret2)); return res; } @@ -1763,7 +1765,7 @@ namespace MEDCoupling PyObject *res = PyList_New(3); PyList_SetItem(res,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTITraits::TI, SWIG_POINTER_OWN | 0 )); PyList_SetItem(res,1,SWIG_From_bool(ret1)); - PyList_SetItem(res,2,SWIG_From_int(ret2)); + PyList_SetItem(res,2,PyInt_FromLong(ret2)); return res; } @@ -2506,14 +2508,14 @@ namespace MEDCoupling static PyObject *FuseUMeshesOnSameCoords(PyObject *ms, int compType) { - mcIdType sz; + std::size_t sz; std::vector meshes; convertFromPyObjVectorOfObj(ms,SWIGTYPE_p_MEDCoupling__MEDCouplingUMesh,"MEDCouplingUMesh",meshes); std::vector corr; MEDCouplingUMesh *um=MEDCouplingUMesh::FuseUMeshesOnSameCoords(meshes,compType,corr); sz=corr.size(); PyObject *ret1=PyList_New(sz); - for(int i=0;i::TI, SWIG_POINTER_OWN | 0 )); PyObject *ret=PyList_New(2); PyList_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(um),SWIGTYPE_p_MEDCoupling__MEDCouplingUMesh, SWIG_POINTER_OWN | 0 )); @@ -3586,7 +3588,7 @@ namespace MEDCoupling { return MEDCouplingIMesh::New(); } - static MEDCouplingIMesh *New(const std::string& meshName, mcIdType spaceDim, PyObject *nodeStrct, PyObject *origin, PyObject *dxyz) + static MEDCouplingIMesh *New(const std::string& meshName, int spaceDim, PyObject *nodeStrct, PyObject *origin, PyObject *dxyz) { static const char msg0[]="MEDCouplingIMesh::New : error on 'origin' parameter !"; static const char msg1[]="MEDCouplingIMesh::New : error on 'dxyz' parameter !"; @@ -3605,7 +3607,7 @@ namespace MEDCoupling return MEDCouplingIMesh::New(meshName,spaceDim,nodeStrctPtr,nodeStrctPtr+sz,originPtr,originPtr+sz1,dxyzPtr,dxyzPtr+sz2); } - MEDCouplingIMesh(const std::string& meshName, mcIdType spaceDim, PyObject *nodeStrct, PyObject *origin, PyObject *dxyz) + MEDCouplingIMesh(const std::string& meshName, int spaceDim, PyObject *nodeStrct, PyObject *origin, PyObject *dxyz) { return MEDCoupling_MEDCouplingIMesh_New__SWIG_1(meshName,spaceDim,nodeStrct,origin,dxyz); } @@ -3713,10 +3715,10 @@ namespace MEDCoupling void setGaussLocalizationOnType(INTERP_KERNEL::NormalizedCellType type, const std::vector& refCoo, const std::vector& gsCoo, const std::vector& wg); void clearGaussLocalizations(); - MEDCouplingGaussLocalization& getGaussLocalization(mcIdType locId); + MEDCouplingGaussLocalization& getGaussLocalization(int locId); mcIdType getNbOfGaussLocalization() const; mcIdType getGaussLocalizationIdOfOneCell(mcIdType cellId) const; - const MEDCouplingGaussLocalization& getGaussLocalization(mcIdType locId) const; + const MEDCouplingGaussLocalization& getGaussLocalization(int locId) const; mcIdType getGaussLocalizationIdOfOneType(INTERP_KERNEL::NormalizedCellType type) const; void setDiscretization(MEDCouplingFieldDiscretization *newDisc); %extend { @@ -3814,7 +3816,7 @@ namespace MEDCoupling } } - PyObject *getCellIdsHavingGaussLocalization(mcIdType locId) const + PyObject *getCellIdsHavingGaussLocalization(int locId) const { std::vector tmp; self->getCellIdsHavingGaussLocalization(locId,tmp); @@ -4086,9 +4088,9 @@ namespace MEDCoupling for(std::vector::iterator it=arrs.begin();it!=arrs.end();it++) if(*it) (*it)->incrRef(); - int sz=arrs.size(); + std::size_t sz=arrs.size(); PyObject *ret=PyTuple_New(sz); - for(int i=0;igetNumberOfComponents(); + mcIdType sz=ToIdType(self->getNumberOfComponents()); INTERP_KERNEL::AutoPtr res=new double[sz]; self->getValueOn(spaceLoc,res); return convertDblArrToPyList(res,sz); @@ -4139,7 +4141,7 @@ namespace MEDCoupling PyObject *getValueOnPos(mcIdType i, mcIdType j, mcIdType k) const { - int sz=self->getNumberOfComponents(); + mcIdType sz=ToIdType(self->getNumberOfComponents()); INTERP_KERNEL::AutoPtr res=new double[sz]; self->getValueOnPos(i,j,k,res); return convertDblArrToPyList(res,sz); @@ -4155,7 +4157,7 @@ namespace MEDCoupling double v0; MEDCoupling::DataArrayDouble *v1(0); MEDCoupling::DataArrayDoubleTuple *v2(0); std::vector v3; const double *inp=convertObjToPossibleCpp5_Safe2(locs,sw,v0,v1,v2,v3,"wrap of MEDCouplingFieldDouble::getValueOnMulti", mesh->getSpaceDimension(),true,nbPts); - return self->getValueOnMulti(inp,nbPts); + return self->getValueOnMulti(inp,(int)nbPts); } PyObject *getValueOn(PyObject *sl, double time) const @@ -4173,7 +4175,7 @@ namespace MEDCoupling const double *spaceLoc=convertObjToPossibleCpp5_Safe(sl,sw,val,a,aa,bb,msg,1,spaceDim,true); // // - int sz=self->getNumberOfComponents(); + mcIdType sz=ToIdType(self->getNumberOfComponents()); INTERP_KERNEL::AutoPtr res=new double[sz]; self->getValueOn(spaceLoc,time,res); return convertDblArrToPyList(res,sz); @@ -4225,42 +4227,42 @@ namespace MEDCoupling } PyObject *accumulate() const { - int sz=self->getNumberOfComponents(); + mcIdType sz=ToIdType(self->getNumberOfComponents()); INTERP_KERNEL::AutoPtr tmp=new double[sz]; self->accumulate(tmp); return convertDblArrToPyList(tmp,sz); } PyObject *integral(bool isWAbs) const { - int sz=self->getNumberOfComponents(); + mcIdType sz=ToIdType(self->getNumberOfComponents()); INTERP_KERNEL::AutoPtr tmp=new double[sz]; self->integral(isWAbs,tmp); return convertDblArrToPyList(tmp,sz); } PyObject *getWeightedAverageValue(bool isWAbs=true) const { - int sz=self->getNumberOfComponents(); + mcIdType sz=ToIdType(self->getNumberOfComponents()); INTERP_KERNEL::AutoPtr tmp=new double[sz]; self->getWeightedAverageValue(tmp,isWAbs); return convertDblArrToPyList(tmp,sz); } PyObject *normL1() const { - int sz=self->getNumberOfComponents(); + mcIdType sz=ToIdType(self->getNumberOfComponents()); INTERP_KERNEL::AutoPtr tmp=new double[sz]; self->normL1(tmp); return convertDblArrToPyList(tmp,sz); } PyObject *normL2() const { - int sz=self->getNumberOfComponents(); + mcIdType sz=ToIdType(self->getNumberOfComponents()); INTERP_KERNEL::AutoPtr tmp=new double[sz]; self->normL2(tmp); return convertDblArrToPyList(tmp,sz); } PyObject *normMax() const { - int sz=self->getNumberOfComponents(); + mcIdType sz=ToIdType(self->getNumberOfComponents()); INTERP_KERNEL::AutoPtr tmp=new double[sz]; self->normMax(tmp); return convertDblArrToPyList(tmp,sz); @@ -4348,7 +4350,7 @@ namespace MEDCoupling DataArrayDoubleTuple *aa,*aa2; std::vector bb,bb2; mcIdType sw; - mcIdType spaceDim=3; + int spaceDim=3; const char msg[]="Python wrap of MEDCouplingFieldDouble::extractSlice3D : 1st parameter for origin."; const char msg2[]="Python wrap of MEDCouplingFieldDouble::extractSlice3D : 2nd parameter for vector."; const double *orig=convertObjToPossibleCpp5_Safe(origin,sw,val,a,aa,bb,msg,1,spaceDim,true); @@ -4983,9 +4985,9 @@ namespace MEDCoupling { std::vector tmp; convertFromPyObjVectorOfObj(li,SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDouble,"MEDCouplingFieldDouble",tmp); - int sz=tmp.size(); + std::size_t sz=tmp.size(); std::vector fs(sz); - for(int i=0;i(tmp[i]); return MEDCouplingMultiFields::New(fs); } @@ -4993,18 +4995,18 @@ namespace MEDCoupling { std::vector tmp; convertFromPyObjVectorOfObj(li,SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDouble,"MEDCouplingFieldDouble",tmp); - int sz=tmp.size(); + std::size_t sz=tmp.size(); std::vector fs(sz); - for(int i=0;i(tmp[i]); return MEDCouplingMultiFields::New(fs); } PyObject *getFields() const { std::vector fields=self->getFields(); - int sz=fields.size(); + std::size_t sz=fields.size(); PyObject *res = PyList_New(sz); - for(int i=0;i ms=self->getMeshes(); - int sz=ms.size(); + std::size_t sz=ms.size(); PyObject *res = PyList_New(sz); - for(int i=0;i refs; std::vector ms=self->getDifferentMeshes(refs); - int sz=ms.size(); + std::size_t sz=ms.size(); PyObject *res = PyList_New(sz); - for(int i=0;i ms=self->getArrays(); - int sz=ms.size(); + std::size_t sz=ms.size(); PyObject *res = PyList_New(sz); - for(int i=0;i > refs; std::vector ms=self->getDifferentArrays(refs); - int sz=ms.size(); + std::size_t sz=ms.size(); PyObject *res = PyList_New(sz); PyObject *res2 = PyList_New(sz); - for(int i=0;i tmp; convertFromPyObjVectorOfObj(li,SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDouble,"MEDCouplingFieldDouble",tmp); - int sz=tmp.size(); + std::size_t sz=tmp.size(); std::vector fs(sz); - for(int i=0;i(tmp[i]); return MEDCouplingFieldOverTime::New(fs); } @@ -5390,15 +5392,15 @@ namespace MEDCoupling return self->simpleRepr(); } static MEDCouplingFieldOverTime *New(PyObject *li) - { - std::vector tmp; - convertFromPyObjVectorOfObj(li,SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDouble,"MEDCouplingFieldDouble",tmp); - int sz=tmp.size(); - std::vector fs(sz); - for(int i=0;i(tmp[i]); - return MEDCouplingFieldOverTime::New(fs); - } + { + std::vector tmp; + convertFromPyObjVectorOfObj(li,SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDouble,"MEDCouplingFieldDouble",tmp); + std::size_t sz=tmp.size(); + std::vector fs(sz); + for(std::size_t i=0;i(tmp[i]); + return MEDCouplingFieldOverTime::New(fs); + } } }; @@ -5538,9 +5540,9 @@ namespace MEDCoupling PyObject *getPatches() const { std::vector< const MEDCouplingCartesianAMRPatch *> ps(self->getPatches()); - mcIdType sz(ps.size()); + std::size_t sz(ps.size()); PyObject *ret = PyList_New(sz); - for(mcIdType i=0;i(ps[i])); if(elt) @@ -5587,9 +5589,9 @@ namespace MEDCoupling virtual PyObject *retrieveGridsAt(mcIdType absoluteLev) const { std::vector ps(self->retrieveGridsAt(absoluteLev)); - mcIdType sz(ps.size()); + std::size_t sz(ps.size()); PyObject *ret = PyList_New(sz); - for(mcIdType i=0;i -PyObject *ToNumPyArrayUnderground(MCData *self, int npyObjectType, const char *MCDataStr, int nbTuples, int nbComp) +PyObject *ToNumPyArrayUnderground(MCData *self, int npyObjectType, const char *MCDataStr, mcIdType nbTuples, std::size_t nbComp) { if(!self->isAllocated()) { @@ -341,7 +341,7 @@ PyObject *ToNumPyArrayUnderground(MCData *self, int npyObjectType, const char *M } int nbDims=nbComp==1?1:2; npy_intp dim[2]; - dim[0]=(npy_intp)nbTuples; dim[1]=nbComp; + dim[0]=(npy_intp)nbTuples; dim[1]=(npy_intp)nbComp; const T *bg=self->getConstPointer(); PyObject *ret(PyArray_SimpleNewFromData(nbDims,dim,npyObjectType,const_cast(bg))); if(mem.isDeallocatorCalled()) @@ -492,9 +492,9 @@ static PyObject *convertIntArrToPyList(const T *ptr, mcIdType size) template static PyObject *convertIntArrToPyList2(const std::vector& v) { - T size=v.size(); + std::size_t size=v.size(); PyObject *ret=PyList_New(size); - for(T i=0;i& v) template static PyObject *convertIntArrToPyList3(const std::set& v) { - T size=v.size(); + std::size_t size=v.size(); PyObject *ret=PyList_New(size); typename std::set::const_iterator it=v.begin(); - for(T i=0;i fillArrayWithPyListInt2(PyObject *pyLi, mcIdType& nbOfTupl mcIdType size1=-1,size2=-1; if(PyList_Check(pyLi)) { - size1=PyList_Size(pyLi); + size1=ToIdType(PyList_Size(pyLi)); for(mcIdType i=0;i fillArrayWithPyListInt2(PyObject *pyLi, mcIdType& nbOfTupl } else if(PyTuple_Check(pyLi)) { - size1=PyTuple_Size(pyLi); + size1=ToIdType(PyTuple_Size(pyLi)); for(mcIdType i=0;i& vec) { PyObject *o=PyList_GetItem(pyLi,i); if(PyInt_Check(o)) - vec[i]=PyInt_AS_LONG(o); + vec[i]=ToIdType(PyInt_AS_LONG(o)); else return false; } @@ -1044,7 +1044,7 @@ static bool fillIntVector(PyObject *pyLi, std::vector& vec) { PyObject *o=PyTuple_GetItem(pyLi,i); if(PyInt_Check(o)) - vec[i]=PyInt_AS_LONG(o); + vec[i]=ToIdType(PyInt_AS_LONG(o)); else return false; } @@ -1095,7 +1095,7 @@ static void convertPyToVectorPairStringVecString(PyObject *pyLi, std::vector< st PyObject *o=PyList_GetItem(pyLi,i); if(PyTuple_Check(o)) { - mcIdType sz2=PyTuple_Size(o); + std::size_t sz2=PyTuple_Size(o); if(sz2!=2) throw INTERP_KERNEL::Exception(msg); std::pair > item; @@ -1114,12 +1114,12 @@ static void convertPyToVectorPairStringVecString(PyObject *pyLi, std::vector< st { Py_ssize_t sz=PyTuple_Size(pyLi); arr.resize(sz); - for(mcIdType i=0;i > item; @@ -1139,31 +1139,31 @@ static void convertPyToVectorPairStringVecString(PyObject *pyLi, std::vector< st } template -PyObject *convertDblArrToPyList(const T *ptr, mcIdType size) +PyObject *convertDblArrToPyList(const T *ptr, std::size_t size) { PyObject *ret(PyList_New(size)); - for(mcIdType i=0;i& v) { - mcIdType size(v.size()); + std::size_t size(v.size()); PyObject *ret(PyList_New(size)); - for(mcIdType i=0;i -PyObject *convertDblArrToPyListOfTuple(const T *vals, int nbOfComp, mcIdType nbOfTuples) +PyObject *convertDblArrToPyListOfTuple(const T *vals, std::size_t nbOfComp, mcIdType nbOfTuples) { PyObject *ret(PyList_New(nbOfTuples)); for(mcIdType i=0;i fillArrayWithPyListDbl2(PyObject *pyLi, mcIdType& nbOfTuples, mcIdType& nbOfComp) { std::vector ret; - mcIdType size1=-1,size2=-1; + std::size_t size1=-1; + mcIdType size2=-1; if(PyList_Check(pyLi)) { size1=PyList_Size(pyLi); - for(mcIdType i=0;i fillArrayWithPyListDbl2(PyObject *pyLi, mcIdType& nbO else if(PyTuple_Check(pyLi)) { size1=PyTuple_Size(pyLi); - for(mcIdType i=0;i fillArrayWithPyListDbl2(PyObject *pyLi, mcIdType& nbO else throw INTERP_KERNEL::Exception("fillArrayWithPyListDbl2 : Unrecognized type ! Should be a tuple or a list !"); // - checkFillArrayWithPyList(size1,size2,nbOfTuples,nbOfComp); + checkFillArrayWithPyList(ToIdType(size1),ToIdType(size2),nbOfTuples,nbOfComp); return ret; } @@ -1346,9 +1347,9 @@ static void convertFromPyObjVectorOfObj(PyObject *pyLi, swig_type_info *ty, cons void *argp=0; if(PyList_Check(pyLi)) { - mcIdType size=PyList_Size(pyLi); + std::size_t size=PyList_Size(pyLi); ret.resize(size); - for(mcIdType i=0;i::ArrayTuple ARRAYTUPLE; ARRAYTUPLE *daIntTuple=reinterpret_cast< ARRAYTUPLE * >(argp); - sw=4; sz=daIntTuple->getNumberOfCompo(); + sw=4; sz=ToIdType(daIntTuple->getNumberOfCompo()); return daIntTuple->getConstPointer(); } throw INTERP_KERNEL::Exception("5 types accepted : integer, tuple of integer, list of integer, DataArrayIdType, DataArrayIdTypeTuple"); @@ -1573,9 +1574,9 @@ void considerPyObjAsATStarLikeObject(PyObject *value, mcIdType& sw, T& iTyypp, s } if(PyTuple_Check(value)) { - mcIdType size=PyTuple_Size(value); + std::size_t size=PyTuple_Size(value); stdvecTyypp.resize(size); - for(mcIdType i=0;igetNumberOfCompo(); + nbTuples=ToIdType(e->getNumberOfCompo()); return e->getConstPointer(); } else @@ -2570,14 +2571,14 @@ static typename MEDCoupling::Traits::ArrayType *DataArrayT_New(PyObject *elt0 { if(PyInt_Check(nbOfTuples)) { - mcIdType nbOfTuples1=PyInt_AS_LONG(nbOfTuples); + mcIdType nbOfTuples1=ToIdType(PyInt_AS_LONG(nbOfTuples)); if(nbOfTuples1<0) throw INTERP_KERNEL::Exception("DataArrayDouble::New : should be a positive set of allocated memory !"); if(elt2) { if(PyInt_Check(elt2)) {//DataArrayDouble.New([1.,3.,4.,5.],2,2) - mcIdType nbOfCompo=PyInt_AS_LONG(elt2); + mcIdType nbOfCompo=ToIdType(PyInt_AS_LONG(elt2)); if(nbOfCompo<0) throw INTERP_KERNEL::Exception("DataArrayDouble::New : should be a positive number of components !"); MEDCoupling::MCAuto< typename MEDCoupling::Traits::ArrayType > ret(MEDCoupling::Traits::ArrayType::New()); @@ -2611,7 +2612,7 @@ static typename MEDCoupling::Traits::ArrayType *DataArrayT_New(PyObject *elt0 } else if(PyInt_Check(elt0)) { - mcIdType nbOfTuples1(PyInt_AS_LONG(elt0)); + mcIdType nbOfTuples1(ToIdType(PyInt_AS_LONG(elt0))); if(nbOfTuples1<0) throw INTERP_KERNEL::Exception("DataArrayDouble::New : should be a positive set of allocated memory !"); if(nbOfTuples) @@ -2620,7 +2621,7 @@ static typename MEDCoupling::Traits::ArrayType *DataArrayT_New(PyObject *elt0 { if(PyInt_Check(nbOfTuples)) {//DataArrayDouble.New(5,2) - mcIdType nbOfCompo=PyInt_AS_LONG(nbOfTuples); + mcIdType nbOfCompo=ToIdType(PyInt_AS_LONG(nbOfTuples)); if(nbOfCompo<0) throw INTERP_KERNEL::Exception("DataArrayDouble::New : should be a positive number of components !"); MEDCoupling::MCAuto< typename MEDCoupling::Traits::ArrayType > ret(MEDCoupling::Traits::ArrayType::New()); @@ -2656,7 +2657,8 @@ typename MEDCoupling::Traits::ArrayType *DataArrayT__setitem__internal(typena { self->checkAllocated(); const char msg[]="Unexpected situation in DataArrayDouble::__setitem__ !"; - mcIdType nbOfTuples(self->getNumberOfTuples()),nbOfComponents(self->getNumberOfComponents()); + mcIdType nbOfTuples(self->getNumberOfTuples()); + int nbOfComponents((int)(self->getNumberOfComponents())); mcIdType sw1,sw2; T i1; std::vector v1; @@ -3003,7 +3005,8 @@ PyObject *DataArrayT__getitem__internal(const typename MEDCoupling::Traits::A const char msg[]="Unexpected situation in DataArrayDouble::__getitem__ !"; const char msg2[]="DataArrayDouble::__getitem__ : Mismatch of slice values in 2nd parameter (components) !"; self->checkAllocated(); - mcIdType nbOfTuples(self->getNumberOfTuples()),nbOfComponents(self->getNumberOfComponents()); + mcIdType nbOfTuples(self->getNumberOfTuples()); + int nbOfComponents((int)(self->getNumberOfComponents())); mcIdType it1; std::size_t ic1; std::vector vt1; @@ -3068,7 +3071,7 @@ PyObject *DataArrayT__getitem__internal(const typename MEDCoupling::Traits::A case 13: { ret=self->selectByTupleIdSafe(&it1,&it1+1); - int nbOfComp(MEDCoupling::DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2)); + mcIdType nbOfComp(MEDCoupling::DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2)); std::vector v2(nbOfComp); for(mcIdType i=0;i::A case 14: { ret=self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size()); - int nbOfComp(MEDCoupling::DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2)); + mcIdType nbOfComp(MEDCoupling::DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2)); std::vector v2(nbOfComp); for(int i=0;i::A case 15: { ret=self->selectByTupleIdSafeSlice(pt1.first,pt1.second.first,pt1.second.second); - int nbOfComp(MEDCoupling::DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2)); + mcIdType nbOfComp(MEDCoupling::DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2)); std::vector v2(nbOfComp); for(int i=0;i::A case 16: { ret=self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems()); - int nbOfComp(MEDCoupling::DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2)); + mcIdType nbOfComp(MEDCoupling::DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2)); std::vector v2(nbOfComp); for(int i=0;iapplyLin(1./val,0.); + self->applyLin((T)(1./val),(T)0.); Py_XINCREF(trueSelf); return trueSelf; } diff --git a/src/MEDCoupling_Swig/MEDCouplingFieldDiscretization.i b/src/MEDCoupling_Swig/MEDCouplingFieldDiscretization.i index 124206120..c70d046f7 100644 --- a/src/MEDCoupling_Swig/MEDCouplingFieldDiscretization.i +++ b/src/MEDCoupling_Swig/MEDCouplingFieldDiscretization.i @@ -118,7 +118,7 @@ namespace MEDCoupling { if(!arr) throw INTERP_KERNEL::Exception("wrap of MEDCouplingFieldDiscretization::normL1 : input array is null !"); - int sz(arr->getNumberOfComponents()); + std::size_t sz(arr->getNumberOfComponents()); INTERP_KERNEL::AutoPtr tmp=new double[sz]; self->normL1(mesh,arr,tmp); return convertDblArrToPyList(tmp,sz); @@ -128,7 +128,7 @@ namespace MEDCoupling { if(!arr) throw INTERP_KERNEL::Exception("wrap of MEDCouplingFieldDiscretization::normL2 : input array is null !"); - int sz(arr->getNumberOfComponents()); + std::size_t sz(arr->getNumberOfComponents()); INTERP_KERNEL::AutoPtr tmp=new double[sz]; self->normL2(mesh,arr,tmp); return convertDblArrToPyList(tmp,sz); @@ -138,7 +138,7 @@ namespace MEDCoupling { if(!arr) throw INTERP_KERNEL::Exception("wrap of MEDCouplingFieldDiscretization::integral : input array is null !"); - int sz(arr->getNumberOfComponents()); + std::size_t sz(arr->getNumberOfComponents()); INTERP_KERNEL::AutoPtr tmp=new double[sz]; self->integral(mesh,arr,isWAbs,tmp); return convertDblArrToPyList(tmp,sz); @@ -203,7 +203,7 @@ namespace MEDCoupling { if(!arr) throw INTERP_KERNEL::Exception("wrap of MEDCouplingFieldDiscretization::getValueOnPos : input array is null !"); - int sz(arr->getNumberOfComponents()); + std::size_t sz(arr->getNumberOfComponents()); INTERP_KERNEL::AutoPtr res=new double[sz]; self->getValueOnPos(arr,mesh,i,j,k,res); return convertDblArrToPyList(res,sz); @@ -353,21 +353,21 @@ namespace MEDCoupling { std::size_t sz(0); const double *ret(MEDCouplingFieldDiscretizationGaussNE::GetWeightArrayFromGeometricType(geoType,sz)); - return convertDblArrToPyList(ret,sz); + return convertDblArrToPyList(ret,ToIdType(sz)); } static PyObject *GetRefCoordsFromGeometricType(INTERP_KERNEL::NormalizedCellType geoType) { std::size_t sz(0); const double *ret(MEDCouplingFieldDiscretizationGaussNE::GetRefCoordsFromGeometricType(geoType,sz)); - return convertDblArrToPyList(ret,sz); + return convertDblArrToPyList(ret,ToIdType(sz)); } static PyObject *GetLocsFromGeometricType(INTERP_KERNEL::NormalizedCellType geoType) { std::size_t sz(0); const double *ret(MEDCouplingFieldDiscretizationGaussNE::GetLocsFromGeometricType(geoType,sz)); - return convertDblArrToPyList(ret,sz); + return convertDblArrToPyList(ret,ToIdType(sz)); } } }; diff --git a/src/MEDCoupling_Swig/MEDCouplingMemArray.i b/src/MEDCoupling_Swig/MEDCouplingMemArray.i index d999ded1a..4c988d334 100644 --- a/src/MEDCoupling_Swig/MEDCouplingMemArray.i +++ b/src/MEDCoupling_Swig/MEDCouplingMemArray.i @@ -497,7 +497,7 @@ typedef DataArrayInt64 DataArrayIdType; void checkNbOfComps(int nbOfCompo, const std::string& msg) const; void checkNbOfTuplesAndComp(const DataArray& other, const std::string& msg) const; void checkNbOfTuplesAndComp(int nbOfTuples, int nbOfCompo, const std::string& msg) const; - void checkNbOfElems(std::size_t nbOfElems, const std::string& msg) const; + void checkNbOfElems(mcIdType nbOfElems, const std::string& msg) const; static int GetNumberOfItemGivenBES(int begin, int end, int step, const std::string& msg); static int GetNumberOfItemGivenBESRelative(int begin, int end, int step, const std::string& msg); static int GetPosOfItemGivenBESRelativeNoThrow(int value, int begin, int end, int step); @@ -673,7 +673,7 @@ typedef DataArrayInt64 DataArrayIdType; Py_ssize_t strt=2,stp=2,step=2; GetIndicesOfSliceExplicitely(slic,&strt,&stp,&step,"DataArray::GetSlice (wrap) : the input slice is invalid !"); mcIdType a,b; - DataArray::GetSlice(strt,stp,step,sliceId,nbOfSlices,a,b); + DataArray::GetSlice(ToIdType(strt),ToIdType(stp),ToIdType(step),sliceId,nbOfSlices,a,b); return PySlice_New(PyInt_FromLong(a),PyInt_FromLong(b),PyInt_FromLong(step)); } @@ -684,7 +684,7 @@ typedef DataArrayInt64 DataArrayIdType; Py_ssize_t strt=2,stp=2,step=2; GetIndicesOfSlice(slic,self->getNumberOfTuples(),&strt,&stp,&step,"DataArray::getSlice (wrap) : the input slice is invalid !"); mcIdType a,b; - DataArray::GetSlice(strt,stp,step,sliceId,nbOfSlices,a,b); + DataArray::GetSlice(ToIdType(strt),ToIdType(stp),ToIdType(step),sliceId,nbOfSlices,a,b); return PySlice_New(PyInt_FromLong(a),PyInt_FromLong(b),PyInt_FromLong(step)); } @@ -694,7 +694,7 @@ typedef DataArrayInt64 DataArrayIdType; throw INTERP_KERNEL::Exception("DataArray::GetNumberOfItemGivenBES (wrap) : expecting a pyslice as second (first) parameter !"); Py_ssize_t strt=2,stp=2,step=2; GetIndicesOfSliceExplicitely(slic,&strt,&stp,&step,"DataArray::GetNumberOfItemGivenBES (wrap) : the input slice is invalid !"); - return DataArray::GetNumberOfItemGivenBES(strt,stp,step,""); + return DataArray::GetNumberOfItemGivenBES(ToIdType(strt),ToIdType(stp),ToIdType(step),""); } static mcIdType GetNumberOfItemGivenBESRelative(PyObject *slic) @@ -703,7 +703,7 @@ typedef DataArrayInt64 DataArrayIdType; throw INTERP_KERNEL::Exception("DataArray::GetNumberOfItemGivenBESRelative (wrap) : expecting a pyslice as second (first) parameter !"); Py_ssize_t strt=2,stp=2,step=2; GetIndicesOfSliceExplicitely(slic,&strt,&stp,&step,"DataArray::GetNumberOfItemGivenBESRelative (wrap) : the input slice is invalid !"); - return DataArray::GetNumberOfItemGivenBESRelative(strt,stp,step,""); + return DataArray::GetNumberOfItemGivenBESRelative(ToIdType(strt),ToIdType(stp),ToIdType(step),""); } static DataArray *Aggregate(PyObject *arrs) @@ -719,7 +719,7 @@ typedef DataArrayInt64 DataArrayIdType; throw INTERP_KERNEL::Exception("DataArray::getNumberOfItemGivenBES (wrap) : expecting a pyslice as second (first) parameter !"); Py_ssize_t strt=2,stp=2,step=2; GetIndicesOfSlice(slic,self->getNumberOfTuples(),&strt,&stp,&step,"DataArray::getNumberOfItemGivenBES (wrap) : the input slice is invalid !"); - return DataArray::GetNumberOfItemGivenBES(strt,stp,step,""); + return DataArray::GetNumberOfItemGivenBES(ToIdType(strt),ToIdType(stp),ToIdType(step),""); } mcIdType getNumberOfItemGivenBESRelative(PyObject *slic) @@ -728,7 +728,7 @@ typedef DataArrayInt64 DataArrayIdType; throw INTERP_KERNEL::Exception("DataArray::getNumberOfItemGivenBESRelative (wrap) : expecting a pyslice as second (first) parameter !"); Py_ssize_t strt=2,stp=2,step=2; GetIndicesOfSlice(slic,self->getNumberOfTuples(),&strt,&stp,&step,"DataArray::getNumberOfItemGivenBESRelative (wrap) : the input slice is invalid !"); - return DataArray::GetNumberOfItemGivenBESRelative(strt,stp,step,""); + return DataArray::GetNumberOfItemGivenBESRelative(ToIdType(strt),ToIdType(stp),ToIdType(step),""); } PyObject *__getstate__() const @@ -738,9 +738,9 @@ typedef DataArrayInt64 DataArrayIdType; const std::vector &a1(self->getInfoOnComponents()); PyTuple_SetItem(ret,0,PyString_FromString(a0.c_str())); // - mcIdType sz(a1.size()); + std::size_t sz(a1.size()); PyObject *ret1(PyList_New(sz)); - for(mcIdType i=0;ibegin()); - mcIdType nbOfComp(self->getNumberOfComponents()),nbOfTuples(self->getNumberOfTuples()); + std::size_t nbOfComp(self->getNumberOfComponents()); + mcIdType nbOfTuples(self->getNumberOfTuples()); return convertDblArrToPyListOfTuple(vals,nbOfComp,nbOfTuples); } @@ -996,7 +997,7 @@ typedef DataArrayInt64 DataArrayIdType; DataArrayIdType *findClosestTupleId(const DataArrayDouble *other) const; DataArrayIdType *computeNbOfInteractionsWith(const DataArrayDouble *otherBBoxFrmt, double eps) const; void setPartOfValues1(const DataArrayDouble *a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare=true); - void setPartOfValuesSimple1(double a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp); + void setPartOfValuesSimple1(double a, mcIdType bgTuples, mcIdType endTuples, mcIdType stepTuples, mcIdType bgComp, mcIdType endComp, mcIdType stepComp); void setPartOfValuesAdv(const DataArrayDouble *a, const DataArrayIdType *tuplesSelec); double getIJ(int tupleId, int compoId) const; double front() const; @@ -1076,7 +1077,7 @@ typedef DataArrayInt64 DataArrayIdType; MCAuto findIdsGreaterThan(double val) const; MCAuto findIdsLowerOrEqualTo(double val) const; MCAuto findIdsLowerThan(double val) const; - MCAuto convertToIntArr() const; + MCAuto convertToIntArr() const; MCAuto selectPartDef(const PartDefinition* pd) const; MCAuto cumSum() const; MCAuto convertToFloatArr() const; @@ -1124,7 +1125,7 @@ typedef DataArrayInt64 DataArrayIdType; return self->doubleValue(); } - int __len__() const + mcIdType __len__() const { if(self->isAllocated()) { @@ -1166,14 +1167,14 @@ typedef DataArrayInt64 DataArrayIdType; { if(PyInt_Check(nbOfTuples)) { - mcIdType nbOfTuples1=PyInt_AS_LONG(nbOfTuples); + mcIdType nbOfTuples1=ToIdType(PyInt_AS_LONG(nbOfTuples)); if(nbOfTuples1<0) throw INTERP_KERNEL::Exception("DataArrayDouble::setValues : should be a positive set of allocated memory !"); if(nbOfComp && nbOfComp != Py_None) { if(PyInt_Check(nbOfComp)) {//DataArrayDouble.setValues([1.,3.,4.,5.],2,2) - mcIdType nbOfCompo=PyInt_AS_LONG(nbOfComp); + mcIdType nbOfCompo=ToIdType(PyInt_AS_LONG(nbOfComp)); if(nbOfCompo<0) throw INTERP_KERNEL::Exception("DataArrayDouble::setValues : should be a positive number of components !"); std::vector tmp=fillArrayWithPyListDbl2(li,nbOfTuples1,nbOfCompo); @@ -1231,7 +1232,8 @@ typedef DataArrayInt64 DataArrayIdType; PyObject *getValuesAsTuple() const { const double *vals(self->begin()); - mcIdType nbOfComp(self->getNumberOfComponents()),nbOfTuples(self->getNumberOfTuples()); + std::size_t nbOfComp(self->getNumberOfComponents()); + mcIdType nbOfTuples(self->getNumberOfTuples()); return convertDblArrToPyListOfTuple(vals,nbOfComp,nbOfTuples); } @@ -1451,7 +1453,7 @@ typedef DataArrayInt64 DataArrayIdType; std::size_t nbOfCompo(self->getNumberOfComponents()); INTERP_KERNEL::AutoPtr tmp(new double[2*nbOfCompo]); self->getMinMaxPerComponent(tmp); - PyObject *ret=convertDblArrToPyListOfTuple(tmp,2,nbOfCompo); + PyObject *ret=convertDblArrToPyListOfTuple(tmp,2,ToIdType(nbOfCompo)); return ret; } @@ -1460,7 +1462,7 @@ typedef DataArrayInt64 DataArrayIdType; std::size_t nbOfCompo(self->getNumberOfComponents()); INTERP_KERNEL::AutoPtr tmp(new double[nbOfCompo]); self->normMaxPerComponent(tmp); - return convertDblArrToPyList(tmp,nbOfCompo); + return convertDblArrToPyList(tmp,ToIdType(nbOfCompo)); } PyObject *accumulate() const @@ -1468,7 +1470,7 @@ typedef DataArrayInt64 DataArrayIdType; std::size_t sz=self->getNumberOfComponents(); INTERP_KERNEL::AutoPtr tmp=new double[sz]; self->accumulate(tmp); - return convertDblArrToPyList(tmp,sz); + return convertDblArrToPyList(tmp,ToIdType(sz)); } DataArrayDouble *accumulatePerChunck(PyObject *indexArr) const @@ -1496,8 +1498,9 @@ typedef DataArrayInt64 DataArrayIdType; DataArrayDoubleTuple *aa; std::vector bb; mcIdType sw; - mcIdType tupleId=-1,nbOfCompo=self->getNumberOfComponents(); - const double *pt=convertObjToPossibleCpp5_Safe(tuple,sw,val,a,aa,bb,"Python wrap of DataArrayDouble::distanceToTuple",1,nbOfCompo,true); + mcIdType tupleId=-1; + std::size_t nbOfCompo=self->getNumberOfComponents(); + const double *pt=convertObjToPossibleCpp5_Safe(tuple,sw,val,a,aa,bb,"Python wrap of DataArrayDouble::distanceToTuple",1,(int)nbOfCompo,true); // double ret0=self->distanceToTuple(pt,pt+nbOfCompo,tupleId); PyObject *ret=PyTuple_New(2); @@ -1528,7 +1531,7 @@ typedef DataArrayInt64 DataArrayIdType; std::size_t sz=self->getNumberOfComponents(); INTERP_KERNEL::AutoPtr tmp=new double[sz]; self->getTuple(tupleId,tmp); - return convertDblArrToPyList(tmp,sz); + return convertDblArrToPyList(tmp,ToIdType(sz)); } static DataArrayDouble *Aggregate(PyObject *li) @@ -1552,9 +1555,10 @@ typedef DataArrayInt64 DataArrayIdType; DataArrayDoubleTuple *aa; std::vector bb; mcIdType sw; - mcIdType nbComp=self->getNumberOfComponents(),nbTuples=-1; + std::size_t nbComp=self->getNumberOfComponents(); + mcIdType nbTuples=-1; const char msg[]="Python wrap of DataArrayDouble::computeTupleIdsNearTuples : "; - const double *pos=convertObjToPossibleCpp5_Safe2(pt,sw,val,a,aa,bb,msg,nbComp,true,nbTuples); + const double *pos=convertObjToPossibleCpp5_Safe2(pt,sw,val,a,aa,bb,msg,(int)nbComp,true,nbTuples); MCAuto inpu=DataArrayDouble::New(); inpu->useArray(pos,false,DeallocType::CPP_DEALLOC,nbTuples,nbComp); DataArrayIdType *c=0,*cI=0; self->computeTupleIdsNearTuples(inpu,eps,c,cI); @@ -2154,7 +2158,7 @@ typedef DataArrayInt64 DataArrayIdType; std::pair > slic; MEDCoupling::DataArrayIdType *daIntTyypp=0; const double *pt=self->getConstPointer(); - mcIdType nbc=self->getNumberOfCompo(); + mcIdType nbc=ToIdType(self->getNumberOfCompo()); convertIntStarOrSliceLikePyObjToCppWithNegIntInterp(obj,nbc,sw,singleVal,multiVal,slic,daIntTyypp); switch(sw) { @@ -2218,7 +2222,7 @@ typedef DataArrayInt64 DataArrayIdType; double singleValV; std::vector multiValV; MEDCoupling::DataArrayDoubleTuple *daIntTyyppV=0; - mcIdType nbc=self->getNumberOfCompo(); + mcIdType nbc=ToIdType(self->getNumberOfCompo()); convertDoubleStarLikePyObjToCpp(value,sw1,singleValV,multiValV,daIntTyyppV); mcIdType singleVal; std::vector multiVal; @@ -2384,7 +2388,7 @@ typedef DataArrayInt64 DataArrayIdType; void fillWithValue(char val); std::string repr() const; std::string reprZip() const; - DataArrayIdType *convertToIntArr() const; + DataArrayInt *convertToIntArr() const; DataArrayChar *renumber(const mcIdType *old2New) const; DataArrayChar *renumberR(const mcIdType *new2Old) const; DataArrayChar *renumberAndReduce(const mcIdType *old2NewBg, mcIdType newNbOfTuple) const; @@ -2564,14 +2568,14 @@ typedef DataArrayInt64 DataArrayIdType; { if(PyInt_Check(nbOfTuples)) { - mcIdType nbOfTuples1=PyInt_AS_LONG(nbOfTuples); + mcIdType nbOfTuples1=ToIdType(PyInt_AS_LONG(nbOfTuples)); if(nbOfTuples1<0) throw INTERP_KERNEL::Exception("DataArrayByte::New : should be a positive set of allocated memory !"); if(nbOfComp) { if(PyInt_Check(nbOfComp)) {//DataArrayByte.New([1,3,4,5],2,2) - mcIdType nbOfCompo=PyInt_AS_LONG(nbOfComp); + mcIdType nbOfCompo=ToIdType(PyInt_AS_LONG(nbOfComp)); if(nbOfCompo<0) throw INTERP_KERNEL::Exception("DataArrayByte::New : should be a positive number of components !"); MCAuto ret=DataArrayByte::New(); @@ -2605,7 +2609,7 @@ typedef DataArrayInt64 DataArrayIdType; } else if(PyInt_Check(elt0)) { - mcIdType nbOfTuples1=PyInt_AS_LONG(elt0); + mcIdType nbOfTuples1=ToIdType(PyInt_AS_LONG(elt0)); if(nbOfTuples1<0) throw INTERP_KERNEL::Exception("DataArrayByte::New : should be a positive set of allocated memory !"); if(nbOfTuples) @@ -2614,7 +2618,7 @@ typedef DataArrayInt64 DataArrayIdType; { if(PyInt_Check(nbOfTuples)) {//DataArrayByte.New(5,2) - mcIdType nbOfCompo=PyInt_AS_LONG(nbOfTuples); + mcIdType nbOfCompo=ToIdType(PyInt_AS_LONG(nbOfTuples)); if(nbOfCompo<0) throw INTERP_KERNEL::Exception("DataArrayByte::New : should be a positive number of components !"); MCAuto ret=DataArrayByte::New(); @@ -2684,9 +2688,9 @@ typedef DataArrayInt64 DataArrayIdType; PyObject *toStrList() const { const char *vals=self->getConstPointer(); - mcIdType nbOfComp=self->getNumberOfComponents(); + std::size_t nbOfComp=self->getNumberOfComponents(); mcIdType nbOfTuples=self->getNumberOfTuples(); - return convertCharArrToPyListOfTuple(vals,nbOfComp,nbOfTuples); + return convertCharArrToPyListOfTuple(vals,(int)nbOfComp,nbOfTuples); } bool presenceOfTuple(PyObject *tupl) const @@ -2741,11 +2745,11 @@ typedef DataArrayInt64 DataArrayIdType; PyObject *getTuple(mcIdType tupleId) { - mcIdType sz=self->getNumberOfComponents(); + std::size_t sz=self->getNumberOfComponents(); INTERP_KERNEL::AutoPtr tmp=new char[sz]; self->getTuple(tupleId,tmp); PyObject *ret=PyTuple_New(sz); - for(mcIdType i=0;igetNumberOfComponents(); + std::size_t nbOfCompo=self->getNumberOfComponents(); switch(nbOfCompo) { case 1: { if(PyInt_Check(obj)) { - mcIdType val=(mcIdType)PyInt_AS_LONG(obj); + char val=(char)PyInt_AS_LONG(obj); return self->findIdFirstEqual(val); } else @@ -2791,7 +2795,7 @@ typedef DataArrayInt64 DataArrayIdType; bool __contains__(PyObject *obj) const { - mcIdType nbOfCompo=self->getNumberOfComponents(); + std::size_t nbOfCompo=self->getNumberOfComponents(); switch(nbOfCompo) { case 0: @@ -2800,7 +2804,7 @@ typedef DataArrayInt64 DataArrayIdType; { if(PyInt_Check(obj)) { - mcIdType val=(mcIdType)PyInt_AS_LONG(obj); + char val=(char)PyInt_AS_LONG(obj); return self->presenceOfValue(val); } else @@ -2822,19 +2826,21 @@ typedef DataArrayInt64 DataArrayIdType; { self->checkAllocated(); const char msg[]="Unexpected situation in __setitem__ !"; - mcIdType nbOfTuples(self->getNumberOfTuples()),nbOfComponents(self->getNumberOfComponents()); + mcIdType nbOfTuples(self->getNumberOfTuples()); + int nbOfComponents((int)self->getNumberOfComponents()); mcIdType sw1,sw2; - mcIdType i1; - std::vector v1; + int int1; + std::vector v1; DataArrayIdType *d1=0; - DataArrayIdTypeTuple *dd1=0; - convertIntStarLikePyObjToCpp(value,sw1,i1,v1,d1,dd1); + DataArrayIntTuple *dd1=0; + convertIntStarLikePyObjToCpp(value,sw1,int1,v1,d1,dd1); mcIdType it1,ic1; std::vector vt1,vc1; std::pair > pt1,pc1; DataArrayIdType *dt1=0,*dc1=0; convertObjToPossibleCpp3(obj,nbOfTuples,nbOfComponents,sw2,it1,ic1,vt1,vc1,pt1,pc1,dt1,dc1); MCAuto tmp; + char i1 = (char)int1; switch(sw2) { case 1: @@ -3095,14 +3101,14 @@ typedef DataArrayInt64 DataArrayIdType; { if(PyInt_Check(nbOfTuples)) { - mcIdType nbOfTuples1=PyInt_AS_LONG(nbOfTuples); + mcIdType nbOfTuples1=ToIdType(PyInt_AS_LONG(nbOfTuples)); if(nbOfTuples1<0) throw INTERP_KERNEL::Exception("DataArrayAsciiChar::New : should be a positive set of allocated memory !"); if(nbOfComp) { if(PyInt_Check(nbOfComp)) {//DataArrayAsciiChar.New([1,3,4,5],2,2) - mcIdType nbOfCompo=PyInt_AS_LONG(nbOfComp); + mcIdType nbOfCompo=ToIdType(PyInt_AS_LONG(nbOfComp)); if(nbOfCompo<0) throw INTERP_KERNEL::Exception("DataArrayAsciiChar::New : should be a positive number of components !"); MCAuto ret=DataArrayAsciiChar::New(); @@ -3168,7 +3174,7 @@ typedef DataArrayInt64 DataArrayIdType; } else if(PyInt_Check(elt0)) { - mcIdType nbOfTuples1=PyInt_AS_LONG(elt0); + mcIdType nbOfTuples1=ToIdType(PyInt_AS_LONG(elt0)); if(nbOfTuples1<0) throw INTERP_KERNEL::Exception("DataArrayAsciiChar::New : should be a positive set of allocated memory !"); if(nbOfTuples) @@ -3177,7 +3183,7 @@ typedef DataArrayInt64 DataArrayIdType; { if(PyInt_Check(nbOfTuples)) {//DataArrayAsciiChar.New(5,2) - mcIdType nbOfCompo=PyInt_AS_LONG(nbOfTuples); + mcIdType nbOfCompo=ToIdType(PyInt_AS_LONG(nbOfTuples)); if(nbOfCompo<0) throw INTERP_KERNEL::Exception("DataArrayAsciiChar::New : should be a positive number of components !"); MCAuto ret=DataArrayAsciiChar::New(); @@ -3240,9 +3246,9 @@ typedef DataArrayInt64 DataArrayIdType; PyObject *toStrList() const { const char *vals=self->getConstPointer(); - mcIdType nbOfComp=self->getNumberOfComponents(); + std::size_t nbOfComp=self->getNumberOfComponents(); mcIdType nbOfTuples=self->getNumberOfTuples(); - return convertCharArrToPyListOfTuple(vals,nbOfComp,nbOfTuples); + return convertCharArrToPyListOfTuple(vals,(int)nbOfComp,nbOfTuples); } bool presenceOfTuple(PyObject *tupl) const @@ -3357,7 +3363,7 @@ typedef DataArrayInt64 DataArrayIdType; PyObject *getTuple(mcIdType tupleId) const { - mcIdType sz=self->getNumberOfComponents(); + std::size_t sz=self->getNumberOfComponents(); INTERP_KERNEL::AutoPtr tmp=new char[sz+1]; tmp[sz]='\0'; self->getTuple(tupleId,tmp); return PyString_FromString(tmp); @@ -3387,7 +3393,7 @@ typedef DataArrayInt64 DataArrayIdType; mcIdType index(PyObject *obj) const { - mcIdType nbOfCompo=self->getNumberOfComponents(); + std::size_t nbOfCompo=self->getNumberOfComponents(); switch(nbOfCompo) { case 1: @@ -3422,7 +3428,7 @@ typedef DataArrayInt64 DataArrayIdType; bool __contains__(PyObject *obj) const { - mcIdType nbOfCompo=self->getNumberOfComponents(); + std::size_t nbOfCompo=self->getNumberOfComponents(); switch(nbOfCompo) { case 0: @@ -3486,7 +3492,7 @@ typedef DataArrayInt64 DataArrayIdType; std::vector stdvecTyyppArr; std::pair > sTyyppArr; MEDCoupling::DataArrayIdType *daIntTyypp=0; - mcIdType nbOfCompo=self->getNumberOfComponents(); + mcIdType nbOfCompo=ToIdType(self->getNumberOfComponents()); mcIdType nbOfTuples=self->getNumberOfTuples(); convertIntStarOrSliceLikePyObjToCppWithNegIntInterp(obj,nbOfTuples,sw1,iTypppArr,stdvecTyyppArr,sTyyppArr,daIntTyypp); mcIdType sw2; diff --git a/src/MEDCoupling_Swig/MEDCouplingTypemaps.i b/src/MEDCoupling_Swig/MEDCouplingTypemaps.i index e38e5c7ff..080def392 100644 --- a/src/MEDCoupling_Swig/MEDCouplingTypemaps.i +++ b/src/MEDCoupling_Swig/MEDCouplingTypemaps.i @@ -523,7 +523,7 @@ typename MEDCoupling::Traits::FieldType *fieldT__getitem__(const MEDCoupling: if(!self->getArray()) throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::__getitem__ : no array set on field to deduce number of components !"); try - { convertIntStarOrSliceLikePyObjToCpp(elt1,self->getArray()->getNumberOfComponents(),sw,singleVal,multiVal,slic,daIntTyypp); } + { convertIntStarOrSliceLikePyObjToCpp(elt1,ToIdType(self->getArray()->getNumberOfComponents()),sw,singleVal,multiVal,slic,daIntTyypp); } catch(INTERP_KERNEL::Exception& e) { std::ostringstream oss; oss << "MEDCouplingFieldDouble::__getitem__ : invalid type in 2nd parameter (compo) !" << e.what(); throw INTERP_KERNEL::Exception(oss.str().c_str()); } typename MEDCoupling::MCAuto< typename MEDCoupling::Traits::FieldType > ret0(fieldT_buildSubPart(self,elt0)); @@ -576,10 +576,10 @@ PyObject *field_getTinySerializationInformation(const FIELDT *self) PyObject *ret(PyTuple_New(3)); PyTuple_SetItem(ret,0,convertDblArrToPyList2(a0)); PyTuple_SetItem(ret,1,convertIntArrToPyList2(a1)); - mcIdType sz(a2.size()); + std::size_t sz(a2.size()); PyObject *ret2(PyList_New(sz)); { - for(mcIdType i=0;i::FieldType *self, PyObjec static const char MSG[]="MEDCouplingFieldDouble.__setstate__ : expected input is a tuple of size 3 !"; if(!PyTuple_Check(inp)) throw INTERP_KERNEL::Exception(MSG); - mcIdType sz(PyTuple_Size(inp)); + std::size_t sz(PyTuple_Size(inp)); if(sz!=3) throw INTERP_KERNEL::Exception(MSG); // mesh @@ -713,7 +713,7 @@ PyObject *Mesh_getCellsContainingPointsLike(PyObject *p, double eps, const MEDCo throw INTERP_KERNEL::Exception("MEDCouplingMesh::getCellsContainingPoints : Not null DataArrayDouble instance expected !"); da2->checkAllocated(); mcIdType size=da2->getNumberOfTuples(); - mcIdType nbOfCompo=da2->getNumberOfComponents(); + mcIdType nbOfCompo=ToIdType(da2->getNumberOfComponents()); if(nbOfCompo!=spaceDim) { throw INTERP_KERNEL::Exception("MEDCouplingMesh::getCellsContainingPoints : Invalid DataArrayDouble nb of components ! Expected same as self.getSpaceDimension() !"); -- 2.39.2