X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDCoupling_Swig%2FMEDCouplingMemArray.i;h=5da9355d8e99e1938a0b2647b4926c8500460545;hb=1b746b38f3cdeae6654a9501f37fde5e56e59288;hp=0c1d416d25174f8dff7d14a3e293872e2230d76b;hpb=d15bb34554367bc3a38631ce76a8560702822aad;p=tools%2Fmedcoupling.git diff --git a/src/MEDCoupling_Swig/MEDCouplingMemArray.i b/src/MEDCoupling_Swig/MEDCouplingMemArray.i index 0c1d416d2..5da9355d8 100644 --- a/src/MEDCoupling_Swig/MEDCouplingMemArray.i +++ b/src/MEDCoupling_Swig/MEDCouplingMemArray.i @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2019 CEA/DEN, EDF R&D +// Copyright (C) 2007-2024 CEA, EDF // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -41,9 +41,19 @@ $result=convertDataArrayChar($1,$owner); } -%typemap(out) MCAuto +%typemap(out) MCAuto { - $result=SWIG_NewPointerObj(SWIG_as_voidptr($1.retn()),SWIGTYPE_p_MEDCoupling__DataArrayInt,SWIG_POINTER_OWN|0); + $result=SWIG_NewPointerObj(SWIG_as_voidptr($1.retn()),SWIGTYPE_p_MEDCoupling__DataArrayInt32,SWIG_POINTER_OWN|0); +} + +%typemap(out) MCAuto +{ + $result=SWIG_NewPointerObj(SWIG_as_voidptr($1.retn()),SWIGTYPE_p_MEDCoupling__DataArrayInt64,SWIG_POINTER_OWN|0); +} + +%typemap(out) MCAuto +{ + $result=SWIG_NewPointerObj(SWIG_as_voidptr($1.retn()),SWIGTITraits::TI,SWIG_POINTER_OWN|0); } %typemap(out) MCAuto @@ -63,6 +73,7 @@ //$$$$$$$$$$$$$$$$$$ %newobject MEDCoupling::DataArray::deepCopy; +%newobject MEDCoupling::DataArray::copySorted; %newobject MEDCoupling::DataArray::buildNewEmptyInstance; %newobject MEDCoupling::DataArray::selectByTupleRanges; %newobject MEDCoupling::DataArray::selectByTupleId; @@ -74,78 +85,160 @@ %newobject MEDCoupling::DataArrayFloat::__iter__; %newobject MEDCoupling::DataArrayFloat::Meld; %newobject MEDCoupling::DataArrayFloat::__rmul__; -%newobject MEDCoupling::DataArrayInt::New; -%newobject MEDCoupling::DataArrayInt::__iter__; -%newobject MEDCoupling::DataArrayInt::performCopyOrIncrRef; -%newobject MEDCoupling::DataArrayInt::subArray; -%newobject MEDCoupling::DataArrayInt::changeNbOfComponents; -%newobject MEDCoupling::DataArrayInt::accumulatePerChunck; -%newobject MEDCoupling::DataArrayInt::checkAndPreparePermutation; -%newobject MEDCoupling::DataArrayInt::transformWithIndArrR; -%newobject MEDCoupling::DataArrayInt::renumber; -%newobject MEDCoupling::DataArrayInt::renumberR; -%newobject MEDCoupling::DataArrayInt::renumberAndReduce; -%newobject MEDCoupling::DataArrayInt::invertArrayO2N2N2O; -%newobject MEDCoupling::DataArrayInt::invertArrayN2O2O2N; -%newobject MEDCoupling::DataArrayInt::invertArrayO2N2N2OBis; -%newobject MEDCoupling::DataArrayInt::findIdsEqual; -%newobject MEDCoupling::DataArrayInt::findIdsNotEqual; -%newobject MEDCoupling::DataArrayInt::findIdsEqualList; -%newobject MEDCoupling::DataArrayInt::findIdsNotEqualList; -%newobject MEDCoupling::DataArrayInt::findIdsEqualTuple; -%newobject MEDCoupling::DataArrayInt::findIdForEach; -%newobject MEDCoupling::DataArrayInt::sumPerTuple; -%newobject MEDCoupling::DataArrayInt::negate; -%newobject MEDCoupling::DataArrayInt::computeAbs; -%newobject MEDCoupling::DataArrayInt::findIdsInRange; -%newobject MEDCoupling::DataArrayInt::findIdsNotInRange; -%newobject MEDCoupling::DataArrayInt::findIdsStrictlyNegative; -%newobject MEDCoupling::DataArrayInt::Aggregate; -%newobject MEDCoupling::DataArrayInt::AggregateIndexes; -%newobject MEDCoupling::DataArrayInt::Meld; -%newobject MEDCoupling::DataArrayInt::Add; -%newobject MEDCoupling::DataArrayInt::Substract; -%newobject MEDCoupling::DataArrayInt::Multiply; -%newobject MEDCoupling::DataArrayInt::Divide; -%newobject MEDCoupling::DataArrayInt::Pow; -%newobject MEDCoupling::DataArrayInt::BuildUnion; -%newobject MEDCoupling::DataArrayInt::BuildIntersection; -%newobject MEDCoupling::DataArrayInt::Range; -%newobject MEDCoupling::DataArrayInt::indicesOfSubPart; -%newobject MEDCoupling::DataArrayInt::fromNoInterlace; -%newobject MEDCoupling::DataArrayInt::toNoInterlace; -%newobject MEDCoupling::DataArrayInt::buildComplement; -%newobject MEDCoupling::DataArrayInt::buildUnion; -%newobject MEDCoupling::DataArrayInt::buildSubstraction; -%newobject MEDCoupling::DataArrayInt::buildSubstractionOptimized; -%newobject MEDCoupling::DataArrayInt::buildIntersection; -%newobject MEDCoupling::DataArrayInt::buildUnique; -%newobject MEDCoupling::DataArrayInt::buildUniqueNotSorted; -%newobject MEDCoupling::DataArrayInt::deltaShiftIndex; -%newobject MEDCoupling::DataArrayInt::buildExplicitArrByRanges; -%newobject MEDCoupling::DataArrayInt::buildExplicitArrOfSliceOnScaledArr; -%newobject MEDCoupling::DataArrayInt::findRangeIdForEachTuple; -%newobject MEDCoupling::DataArrayInt::findIdInRangeForEachTuple; -%newobject MEDCoupling::DataArrayInt::duplicateEachTupleNTimes; -%newobject MEDCoupling::DataArrayInt::buildPermutationArr; -%newobject MEDCoupling::DataArrayInt::buildPermArrPerLevel; -%newobject MEDCoupling::DataArrayInt::getDifferentValues; -%newobject MEDCoupling::DataArrayInt::FindPermutationFromFirstToSecond; -%newobject MEDCoupling::DataArrayInt::CheckAndPreparePermutation; -%newobject MEDCoupling::DataArrayInt::__neg__; -%newobject MEDCoupling::DataArrayInt::__add__; -%newobject MEDCoupling::DataArrayInt::__radd__; -%newobject MEDCoupling::DataArrayInt::__sub__; -%newobject MEDCoupling::DataArrayInt::__rsub__; -%newobject MEDCoupling::DataArrayInt::__mul__; -%newobject MEDCoupling::DataArrayInt::__rmul__; -%newobject MEDCoupling::DataArrayInt::__div__; -%newobject MEDCoupling::DataArrayInt::__rdiv__; -%newobject MEDCoupling::DataArrayInt::__mod__; -%newobject MEDCoupling::DataArrayInt::__rmod__; -%newobject MEDCoupling::DataArrayInt::__pow__; -%newobject MEDCoupling::DataArrayInt::__rpow__; -%newobject MEDCoupling::DataArrayIntTuple::buildDAInt; +%newobject MEDCoupling::DataArrayInt32::New; +%newobject MEDCoupling::DataArrayInt32::__iter__; +%newobject MEDCoupling::DataArrayInt32::performCopyOrIncrRef; +%newobject MEDCoupling::DataArrayInt32::subArray; +%newobject MEDCoupling::DataArrayInt32::changeNbOfComponents; +%newobject MEDCoupling::DataArrayInt32::accumulatePerChunck; +%newobject MEDCoupling::DataArrayInt32::checkAndPreparePermutation; +%newobject MEDCoupling::DataArrayInt32::transformWithIndArrR; +%newobject MEDCoupling::DataArrayInt32::renumber; +%newobject MEDCoupling::DataArrayInt32::renumberR; +%newobject MEDCoupling::DataArrayInt32::renumberAndReduce; +%newobject MEDCoupling::DataArrayInt32::invertArrayO2N2N2O; +%newobject MEDCoupling::DataArrayInt32::invertArrayN2O2O2N; +%newobject MEDCoupling::DataArrayInt32::invertArrayO2N2N2OBis; +%newobject MEDCoupling::DataArrayInt32::findIdsEqual; +%newobject MEDCoupling::DataArrayInt32::findIdsNotEqual; +%newobject MEDCoupling::DataArrayInt32::findIdsEqualList; +%newobject MEDCoupling::DataArrayInt32::findIdsNotEqualList; +%newobject MEDCoupling::DataArrayInt32::findIdsEqualTuple; +%newobject MEDCoupling::DataArrayInt32::findIdForEach; +%newobject MEDCoupling::DataArrayInt32::sumPerTuple; +%newobject MEDCoupling::DataArrayInt32::negate; +%newobject MEDCoupling::DataArrayInt32::computeAbs; +%newobject MEDCoupling::DataArrayInt32::findIdsInRange; +%newobject MEDCoupling::DataArrayInt32::findIdsNotInRange; +%newobject MEDCoupling::DataArrayInt32::findIdsStrictlyNegative; +%newobject MEDCoupling::DataArrayInt32::Aggregate; +%newobject MEDCoupling::DataArrayInt32::AggregateIndexes; +%newobject MEDCoupling::DataArrayInt32::Meld; +%newobject MEDCoupling::DataArrayInt32::Add; +%newobject MEDCoupling::DataArrayInt32::Substract; +%newobject MEDCoupling::DataArrayInt32::Multiply; +%newobject MEDCoupling::DataArrayInt32::Divide; +%newobject MEDCoupling::DataArrayInt32::Pow; +%newobject MEDCoupling::DataArrayInt32::BuildUnion; +%newobject MEDCoupling::DataArrayInt32::BuildIntersection; +%newobject MEDCoupling::DataArrayInt32::Range; +%newobject MEDCoupling::DataArrayInt32::indicesOfSubPart; +%newobject MEDCoupling::DataArrayInt32::fromNoInterlace; +%newobject MEDCoupling::DataArrayInt32::toNoInterlace; +%newobject MEDCoupling::DataArrayInt32::buildComplement; +%newobject MEDCoupling::DataArrayInt32::buildUnion; +%newobject MEDCoupling::DataArrayInt32::buildSubstraction; +%newobject MEDCoupling::DataArrayInt32::buildSubstractionOptimized; +%newobject MEDCoupling::DataArrayInt32::buildIntersection; +%newobject MEDCoupling::DataArrayInt32::indexOfSameConsecutiveValueGroups; +%newobject MEDCoupling::DataArrayInt32::buildUnique; +%newobject MEDCoupling::DataArrayInt32::buildUniqueNotSorted; +%newobject MEDCoupling::DataArrayInt32::deltaShiftIndex; +%newobject MEDCoupling::DataArrayInt32::buildExplicitArrByRanges; +%newobject MEDCoupling::DataArrayInt32::buildExplicitArrOfSliceOnScaledArr; +%newobject MEDCoupling::DataArrayInt32::findRangeIdForEachTuple; +%newobject MEDCoupling::DataArrayInt32::findIdInRangeForEachTuple; +%newobject MEDCoupling::DataArrayInt32::duplicateEachTupleNTimes; +%newobject MEDCoupling::DataArrayInt32::occurenceRankInThis; +%newobject MEDCoupling::DataArrayInt32::buildPermutationArr; +%newobject MEDCoupling::DataArrayInt32::buildPermArrPerLevel; +%newobject MEDCoupling::DataArrayInt32::locateComponentId; +%newobject MEDCoupling::DataArrayInt32::getDifferentValues; +%newobject MEDCoupling::DataArrayInt32::FindPermutationFromFirstToSecond; +%newobject MEDCoupling::DataArrayInt32::FindPermutationFromFirstToSecondDuplicate; +%newobject MEDCoupling::DataArrayInt32::CheckAndPreparePermutation; +%newobject MEDCoupling::DataArrayInt32::__neg__; +%newobject MEDCoupling::DataArrayInt32::__add__; +%newobject MEDCoupling::DataArrayInt32::__radd__; +%newobject MEDCoupling::DataArrayInt32::__sub__; +%newobject MEDCoupling::DataArrayInt32::__rsub__; +%newobject MEDCoupling::DataArrayInt32::__mul__; +%newobject MEDCoupling::DataArrayInt32::__rmul__; +%newobject MEDCoupling::DataArrayInt32::__div__; +%newobject MEDCoupling::DataArrayInt32::__rdiv__; +%newobject MEDCoupling::DataArrayInt32::__mod__; +%newobject MEDCoupling::DataArrayInt32::__rmod__; +%newobject MEDCoupling::DataArrayInt32::__pow__; +%newobject MEDCoupling::DataArrayInt32::__rpow__; +%newobject MEDCoupling::DataArrayInt32::convertToInt64Arr; +%newobject MEDCoupling::DataArrayInt32Tuple::buildDAInt; +%newobject MEDCoupling::DataArrayInt64::New; +%newobject MEDCoupling::DataArrayInt64::__iter__; +%newobject MEDCoupling::DataArrayInt64::performCopyOrIncrRef; +%newobject MEDCoupling::DataArrayInt64::subArray; +%newobject MEDCoupling::DataArrayInt64::changeNbOfComponents; +%newobject MEDCoupling::DataArrayInt64::accumulatePerChunck; +%newobject MEDCoupling::DataArrayInt64::checkAndPreparePermutation; +%newobject MEDCoupling::DataArrayInt64::transformWithIndArrR; +%newobject MEDCoupling::DataArrayInt64::renumber; +%newobject MEDCoupling::DataArrayInt64::renumberR; +%newobject MEDCoupling::DataArrayInt64::renumberAndReduce; +%newobject MEDCoupling::DataArrayInt64::invertArrayO2N2N2O; +%newobject MEDCoupling::DataArrayInt64::invertArrayN2O2O2N; +%newobject MEDCoupling::DataArrayInt64::invertArrayO2N2N2OBis; +%newobject MEDCoupling::DataArrayInt64::findIdsEqual; +%newobject MEDCoupling::DataArrayInt64::findIdsNotEqual; +%newobject MEDCoupling::DataArrayInt64::findIdsEqualList; +%newobject MEDCoupling::DataArrayInt64::findIdsNotEqualList; +%newobject MEDCoupling::DataArrayInt64::findIdsEqualTuple; +%newobject MEDCoupling::DataArrayInt64::findIdForEach; +%newobject MEDCoupling::DataArrayInt64::sumPerTuple; +%newobject MEDCoupling::DataArrayInt64::negate; +%newobject MEDCoupling::DataArrayInt64::computeAbs; +%newobject MEDCoupling::DataArrayInt64::findIdsInRange; +%newobject MEDCoupling::DataArrayInt64::findIdsNotInRange; +%newobject MEDCoupling::DataArrayInt64::findIdsStrictlyNegative; +%newobject MEDCoupling::DataArrayInt64::Aggregate; +%newobject MEDCoupling::DataArrayInt64::AggregateIndexes; +%newobject MEDCoupling::DataArrayInt64::Meld; +%newobject MEDCoupling::DataArrayInt64::Add; +%newobject MEDCoupling::DataArrayInt64::Substract; +%newobject MEDCoupling::DataArrayInt64::Multiply; +%newobject MEDCoupling::DataArrayInt64::Divide; +%newobject MEDCoupling::DataArrayInt64::Pow; +%newobject MEDCoupling::DataArrayInt64::BuildUnion; +%newobject MEDCoupling::DataArrayInt64::BuildIntersection; +%newobject MEDCoupling::DataArrayInt64::Range; +%newobject MEDCoupling::DataArrayInt64::indicesOfSubPart; +%newobject MEDCoupling::DataArrayInt64::fromNoInterlace; +%newobject MEDCoupling::DataArrayInt64::toNoInterlace; +%newobject MEDCoupling::DataArrayInt64::buildComplement; +%newobject MEDCoupling::DataArrayInt64::buildUnion; +%newobject MEDCoupling::DataArrayInt64::buildSubstraction; +%newobject MEDCoupling::DataArrayInt64::buildSubstractionOptimized; +%newobject MEDCoupling::DataArrayInt64::buildIntersection; +%newobject MEDCoupling::DataArrayInt64::indexOfSameConsecutiveValueGroups; +%newobject MEDCoupling::DataArrayInt64::buildUnique; +%newobject MEDCoupling::DataArrayInt64::buildUniqueNotSorted; +%newobject MEDCoupling::DataArrayInt64::deltaShiftIndex; +%newobject MEDCoupling::DataArrayInt64::buildExplicitArrByRanges; +%newobject MEDCoupling::DataArrayInt64::buildExplicitArrOfSliceOnScaledArr; +%newobject MEDCoupling::DataArrayInt64::findRangeIdForEachTuple; +%newobject MEDCoupling::DataArrayInt64::findIdInRangeForEachTuple; +%newobject MEDCoupling::DataArrayInt64::duplicateEachTupleNTimes; +%newobject MEDCoupling::DataArrayInt64::occurenceRankInThis; +%newobject MEDCoupling::DataArrayInt64::buildPermutationArr; +%newobject MEDCoupling::DataArrayInt64::buildPermArrPerLevel; +%newobject MEDCoupling::DataArrayInt64::locateComponentId; +%newobject MEDCoupling::DataArrayInt64::getDifferentValues; +%newobject MEDCoupling::DataArrayInt64::FindPermutationFromFirstToSecond; +%newobject MEDCoupling::DataArrayInt64::FindPermutationFromFirstToSecondDuplicate; +%newobject MEDCoupling::DataArrayInt64::CheckAndPreparePermutation; +%newobject MEDCoupling::DataArrayInt64::__neg__; +%newobject MEDCoupling::DataArrayInt64::__add__; +%newobject MEDCoupling::DataArrayInt64::__radd__; +%newobject MEDCoupling::DataArrayInt64::__sub__; +%newobject MEDCoupling::DataArrayInt64::__rsub__; +%newobject MEDCoupling::DataArrayInt64::__mul__; +%newobject MEDCoupling::DataArrayInt64::__rmul__; +%newobject MEDCoupling::DataArrayInt64::__div__; +%newobject MEDCoupling::DataArrayInt64::__rdiv__; +%newobject MEDCoupling::DataArrayInt64::__mod__; +%newobject MEDCoupling::DataArrayInt64::__rmod__; +%newobject MEDCoupling::DataArrayInt64::__pow__; +%newobject MEDCoupling::DataArrayInt64::__rpow__; +%newobject MEDCoupling::DataArrayInt64::convertToInt32Arr; +%newobject MEDCoupling::DataArrayInt64Tuple::buildDAInt; %newobject MEDCoupling::DataArrayChar::convertToIntArr; %newobject MEDCoupling::DataArrayChar::renumber; %newobject MEDCoupling::DataArrayChar::renumberR; @@ -197,6 +290,7 @@ %newobject MEDCoupling::DataArrayDouble::deviator; %newobject MEDCoupling::DataArrayDouble::magnitude; %newobject MEDCoupling::DataArrayDouble::maxPerTuple; +%newobject MEDCoupling::DataArrayDouble::minPerTuple; %newobject MEDCoupling::DataArrayDouble::sumPerTuple; %newobject MEDCoupling::DataArrayDouble::computeBBoxPerTuple; %newobject MEDCoupling::DataArrayDouble::buildEuclidianDistanceDenseMatrix; @@ -235,10 +329,13 @@ %newobject MEDCoupling::DataArrayPartDefinition::New; %newobject MEDCoupling::SlicePartDefinition::New; +%newobject FromPyIntPtrToDataArrayByte; + %feature("unref") DataArray "$this->decrRef();" %feature("unref") DataArrayDouble "$this->decrRef();" -%feature("unref") DataArrayInt "$this->decrRef();" +%feature("unref") DataArrayInt32 "$this->decrRef();" +%feature("unref") DataArrayInt64 "$this->decrRef();" %feature("unref") DataArrayChar "$this->decrRef();" %feature("unref") DataArrayAsciiChar "$this->decrRef();" %feature("unref") DataArrayByte "$this->decrRef();" @@ -257,20 +354,29 @@ namespace MEDCoupling AX_SPHER = 5 } MEDCouplingAxisType; - class DataArrayInt; + class DataArrayInt32; + class DataArrayInt64; + +#ifndef MEDCOUPLING_USE_64BIT_IDS +typedef DataArrayInt32 DataArrayIdType; +#define DataArrayIdType DataArrayInt32 +#else +typedef DataArrayInt64 DataArrayIdType; +#define DataArrayIdType DataArrayInt64 +#endif class MapII : public RefCountObject, public TimeLabel { public: static MCAuto< MapII > New(); }; - + class PartDefinition : public RefCountObject, public TimeLabel { public: static PartDefinition *New(int start, int stop, int step); - static PartDefinition *New(DataArrayInt *listOfIds); - virtual DataArrayInt *toDAI() const; + static PartDefinition *New(DataArrayIdType *listOfIds); + virtual DataArrayIdType *toDAI() const; virtual int getNumberOfElems() const; virtual std::string getRepr() const; virtual PartDefinition *composeWith(const PartDefinition *other) const; @@ -307,10 +413,10 @@ namespace MEDCoupling class DataArrayPartDefinition : public PartDefinition { public: - static DataArrayPartDefinition *New(DataArrayInt *listOfIds); + static DataArrayPartDefinition *New(DataArrayIdType *listOfIds); %extend { - DataArrayPartDefinition(DataArrayInt *listOfIds) + DataArrayPartDefinition(DataArrayIdType *listOfIds) { return DataArrayPartDefinition::New(listOfIds); } @@ -319,7 +425,7 @@ namespace MEDCoupling { return self->getRepr(); } - + std::string __repr__() const { std::ostringstream oss; oss << "DataArrayPartDefinition C++ instance at " << self << "." << std::endl; @@ -338,23 +444,23 @@ namespace MEDCoupling int getEffectiveStop() const; %extend { - SlicePartDefinition(int start, int stop, int step) + SlicePartDefinition(mcIdType start, mcIdType stop, mcIdType step) { return SlicePartDefinition::New(start,stop,step); } PyObject *getSlice() const { - int a,b,c; + mcIdType a,b,c; self->getSlice(a,b,c); return PySlice_New(PyInt_FromLong(a),PyInt_FromLong(b),PyInt_FromLong(c)); } - + std::string __str__() const { return self->getRepr(); } - + std::string __repr__() const { std::ostringstream oss; oss << "SlicePartDefinition C++ instance at " << self << "." << std::endl; @@ -365,14 +471,14 @@ namespace MEDCoupling protected: virtual ~SlicePartDefinition(); }; - + class DataArray : public RefCountObject, public TimeLabel { public: void setName(const std::string& name); void copyStringInfoFrom(const DataArray& other); - void copyPartOfStringInfoFrom(const DataArray& other, const std::vector& compoIds); - void copyPartOfStringInfoFrom2(const std::vector& compoIds, const DataArray& other); + void copyPartOfStringInfoFrom(const DataArray& other, const std::vector& compoIds); + void copyPartOfStringInfoFrom2(const std::vector& compoIds, const DataArray& other); bool areInfoEqualsIfNotWhy(const DataArray& other, std::string& reason) const; bool areInfoEquals(const DataArray& other) const; std::string cppRepr(const std::string& varName) const; @@ -395,6 +501,7 @@ namespace MEDCoupling virtual std::size_t getNbOfElems() const; virtual std::size_t getNbOfElemAllocated() const; virtual DataArray *deepCopy() const; + virtual DataArray *copySorted() const; virtual DataArray *buildNewEmptyInstance() const; virtual DataArray *selectByTupleIdSafeSlice(int bg, int end2, int step) const; virtual void rearrange(int newNbOfCompo); @@ -405,7 +512,7 @@ namespace MEDCoupling 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); @@ -419,22 +526,22 @@ namespace MEDCoupling PyObject *getInfoOnComponents() const { const std::vector& comps=self->getInfoOnComponents(); - PyObject *ret=PyList_New((int)comps.size()); - for(int i=0;i<(int)comps.size();i++) + PyObject *ret=PyList_New((mcIdType)comps.size()); + for(std::size_t i=0;i tmp; + std::vector tmp; convertPyToNewIntArr3(li,tmp); self->copyPartOfStringInfoFrom(other,tmp); } void copyPartOfStringInfoFrom2(PyObject *li, const DataArray& other) { - std::vector tmp; + std::vector tmp; convertPyToNewIntArr3(li,tmp); self->copyPartOfStringInfoFrom2(tmp,other); } @@ -442,11 +549,11 @@ namespace MEDCoupling virtual void renumberInPlace(PyObject *li) { void *da=0; - int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_MEDCoupling__DataArrayInt, 0 | 0 ); + int res1=SWIG_ConvertPtr(li,&da,SWIGTITraits::TI, 0 | 0 ); if (!SWIG_IsOK(res1)) { - int size; - INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); + mcIdType size; + INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); if(size!=self->getNumberOfTuples()) { throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !"); @@ -455,11 +562,11 @@ namespace MEDCoupling } else { - DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da); + DataArrayIdType *da2=reinterpret_cast< DataArrayIdType * >(da); if(!da2) throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !"); da2->checkAllocated(); - int size=self->getNumberOfTuples(); + mcIdType size=self->getNumberOfTuples(); if(size!=self->getNumberOfTuples()) { throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !"); @@ -471,11 +578,11 @@ namespace MEDCoupling virtual void renumberInPlaceR(PyObject *li) { void *da=0; - int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_MEDCoupling__DataArrayInt, 0 | 0 ); + int res1=SWIG_ConvertPtr(li,&da,SWIGTITraits::TI, 0 | 0 ); if (!SWIG_IsOK(res1)) { - int size; - INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); + mcIdType size; + INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); if(size!=self->getNumberOfTuples()) { throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !"); @@ -484,11 +591,11 @@ namespace MEDCoupling } else { - DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da); + DataArrayIdType *da2=reinterpret_cast< DataArrayIdType * >(da); if(!da2) throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !"); da2->checkAllocated(); - int size=self->getNumberOfTuples(); + mcIdType size=self->getNumberOfTuples(); if(size!=self->getNumberOfTuples()) { throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !"); @@ -498,22 +605,22 @@ namespace MEDCoupling } //tuplesSelec in PyObject * because DataArrayInt is not already existing ! - virtual void setContigPartOfSelectedValues(int tupleIdStart, PyObject *aBase, PyObject *tuplesSelec) + virtual void setContigPartOfSelectedValues(mcIdType tupleIdStart, PyObject *aBase, PyObject *tuplesSelec) { static const char msg[]="DataArray::setContigPartOfSelectedValuesSlice : 4th parameter \"tuplesSelec\" should be of type DataArrayInt"; DataArray *a=CheckAndRetrieveDataArrayInstance(aBase,"DataArray::setContigPartOfSelectedValuesSlice : 3rd parameter \"aBase\" should be of type DataArray"); DataArray *tuplesSelecPtr=CheckAndRetrieveDataArrayInstance(tuplesSelec,msg); - DataArrayInt *tuplesSelecPtr2=0; + DataArrayIdType *tuplesSelecPtr2=0; if(tuplesSelecPtr) { - tuplesSelecPtr2=dynamic_cast(tuplesSelecPtr); + tuplesSelecPtr2=dynamic_cast(tuplesSelecPtr); if(!tuplesSelecPtr2) throw INTERP_KERNEL::Exception(msg); } self->setContigPartOfSelectedValues(tupleIdStart,a,tuplesSelecPtr2); } - - virtual void setContigPartOfSelectedValuesSlice(int tupleIdStart, PyObject *aBase, int bg, int end2, int step) + + virtual void setContigPartOfSelectedValuesSlice(mcIdType tupleIdStart, PyObject *aBase, mcIdType bg, mcIdType end2, mcIdType step) { DataArray *a=CheckAndRetrieveDataArrayInstance(aBase,"DataArray::setContigPartOfSelectedValuesSlice : 2nd parameter \"aBase\" should be of type DataArray"); self->setContigPartOfSelectedValuesSlice(tupleIdStart,a,bg,end2,step); @@ -521,7 +628,7 @@ namespace MEDCoupling virtual DataArray *selectByTupleRanges(PyObject *li) const { - std::vector > ranges; + std::vector > ranges; convertPyToVectorPairInt(li,ranges); return self->selectByTupleRanges(ranges); } @@ -529,16 +636,16 @@ namespace MEDCoupling virtual DataArray *selectByTupleId(PyObject *li) const { void *da=0; - int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_MEDCoupling__DataArrayInt, 0 | 0 ); + int res1=SWIG_ConvertPtr(li,&da,SWIGTITraits::TI, 0 | 0 ); if (!SWIG_IsOK(res1)) { - int size; - INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); + mcIdType size; + INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); return self->selectByTupleId(tmp,tmp+size); } else { - DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da); + DataArrayIdType *da2=reinterpret_cast< DataArrayIdType * >(da); if(!da2) throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !"); da2->checkAllocated(); @@ -549,16 +656,16 @@ namespace MEDCoupling virtual DataArray *selectByTupleIdSafe(PyObject *li) const { void *da=0; - int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_MEDCoupling__DataArrayInt, 0 | 0 ); + int res1=SWIG_ConvertPtr(li,&da,SWIGTITraits::TI, 0 | 0 ); if (!SWIG_IsOK(res1)) { - int size; - INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); + mcIdType size; + INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); return self->selectByTupleIdSafe(tmp,tmp+size); } else { - DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da); + DataArrayIdType *da2=reinterpret_cast< DataArrayIdType * >(da); if(!da2) throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !"); da2->checkAllocated(); @@ -568,52 +675,54 @@ namespace MEDCoupling virtual PyObject *keepSelectedComponents(PyObject *li) const { - std::vector tmp; + std::vector tmp; convertPyToNewIntArr3(li,tmp); DataArray *ret=self->keepSelectedComponents(tmp); return convertDataArray(ret,SWIG_POINTER_OWN | 0 ); } - static PyObject *GetSlice(PyObject *slic, int sliceId, int nbOfSlices) + static PyObject *GetSlice(PyObject *slic, mcIdType sliceId, mcIdType nbOfSlices) { if(!PySlice_Check(slic)) throw INTERP_KERNEL::Exception("DataArray::GetSlice (wrap) : expecting a pyslice as second (first) parameter !"); Py_ssize_t strt=2,stp=2,step=2; GetIndicesOfSliceExplicitely(slic,&strt,&stp,&step,"DataArray::GetSlice (wrap) : the input slice is invalid !"); - int a,b; - DataArray::GetSlice(strt,stp,step,sliceId,nbOfSlices,a,b); - return PySlice_New(PyInt_FromLong(a),PyInt_FromLong(b),PyInt_FromLong(step)); + mcIdType a,b; + DataArray::GetSlice(ToIdType(strt),ToIdType(stp),ToIdType(step),sliceId,nbOfSlices,a,b); + AutoPyPtr ap(PyInt_FromLong(a)),bp(PyInt_FromLong(b)),stepp(PyInt_FromLong(step)); + return PySlice_New(ap,bp,stepp); } - PyObject *getSlice(PyObject *slic, int sliceId, int nbOfSlices) const + PyObject *getSlice(PyObject *slic, mcIdType sliceId, mcIdType nbOfSlices) const { if(!PySlice_Check(slic)) throw INTERP_KERNEL::Exception("DataArray::getSlice (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::getSlice (wrap) : the input slice is invalid !"); - int a,b; - DataArray::GetSlice(strt,stp,step,sliceId,nbOfSlices,a,b); - return PySlice_New(PyInt_FromLong(a),PyInt_FromLong(b),PyInt_FromLong(step)); + mcIdType a,b; + DataArray::GetSlice(ToIdType(strt),ToIdType(stp),ToIdType(step),sliceId,nbOfSlices,a,b); + AutoPyPtr ap(PyInt_FromLong(a)),bp(PyInt_FromLong(b)),stepp(PyInt_FromLong(step)); + return PySlice_New(ap,bp,stepp); } - static int GetNumberOfItemGivenBES(PyObject *slic) + static mcIdType GetNumberOfItemGivenBES(PyObject *slic) { if(!PySlice_Check(slic)) 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 int GetNumberOfItemGivenBESRelative(PyObject *slic) + static mcIdType GetNumberOfItemGivenBESRelative(PyObject *slic) { if(!PySlice_Check(slic)) 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) { std::vector tmp; @@ -621,22 +730,22 @@ namespace MEDCoupling return DataArray::Aggregate(tmp); } - int getNumberOfItemGivenBES(PyObject *slic) const + mcIdType getNumberOfItemGivenBES(PyObject *slic) const { if(!PySlice_Check(slic)) 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),""); } - int getNumberOfItemGivenBESRelative(PyObject *slic) + mcIdType getNumberOfItemGivenBESRelative(PyObject *slic) { if(!PySlice_Check(slic)) 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 @@ -646,9 +755,9 @@ namespace MEDCoupling const std::vector &a1(self->getInfoOnComponents()); PyTuple_SetItem(ret,0,PyString_FromString(a0.c_str())); // - int sz(a1.size()); + std::size_t sz(a1.size()); PyObject *ret1(PyList_New(sz)); - for(int i=0;i(elt0,nbOfTuples,elt2); } - + DataArrayFloat(PyObject *elt0, PyObject *nbOfTuples=0, PyObject *elt2=0) { return MEDCoupling_DataArrayFloat_New__SWIG_1(elt0,nbOfTuples,elt2); @@ -723,7 +832,7 @@ namespace MEDCoupling return self->reprNotTooLong(); } - int __len__() const + mcIdType __len__() const { if(self->isAllocated()) { @@ -744,7 +853,8 @@ namespace MEDCoupling PyObject *getValuesAsTuple() const { const float *vals(self->begin()); - int nbOfComp(self->getNumberOfComponents()),nbOfTuples(self->getNumberOfTuples()); + std::size_t nbOfComp(self->getNumberOfComponents()); + mcIdType nbOfTuples(self->getNumberOfTuples()); return convertDblArrToPyListOfTuple(vals,nbOfComp,nbOfTuples); } @@ -759,7 +869,7 @@ namespace MEDCoupling PyTuple_SetItem(ret,1,PyString_FromString(ret1.c_str())); return ret; } - + PyObject *__getitem__(PyObject *obj) { return DataArrayT__getitem(self,obj); @@ -769,7 +879,7 @@ namespace MEDCoupling { return DataArrayT__setitem__(self,obj,value); } - + PyObject *___iadd___(PyObject *trueSelf, PyObject *obj) { return DataArrayT_iadd(trueSelf,obj,self); @@ -794,7 +904,7 @@ namespace MEDCoupling { return DataArrayT_idiv(trueSelf,obj,self); } - + #ifdef WITH_NUMPY PyObject *toNumPyArray() // not const. It is not a bug ! { @@ -830,8 +940,8 @@ namespace MEDCoupling class DataArrayFloatTuple { public: - int getNumberOfCompo() const; - DataArrayFloat *buildDAFloat(int nbOfTuples, int nbOfCompo) const; + std::size_t getNumberOfCompo() const; + DataArrayFloat *buildDAFloat(mcIdType nbOfTuples, mcIdType nbOfCompo) const; %extend { std::string __str__() const @@ -848,7 +958,7 @@ namespace MEDCoupling { return self->buildDAFloat(1,self->getNumberOfCompo()); } - + /*PyObject *___imul___(PyObject *trueSelf, PyObject *obj) { MCAuto ret=self->buildDAFloat(1,self->getNumberOfCompo()); @@ -863,10 +973,9 @@ namespace MEDCoupling } } }; - - class DataArrayInt; + class DataArrayDoubleIterator; - + class DataArrayDouble : public DataArray { public: @@ -898,15 +1007,15 @@ namespace MEDCoupling DataArrayDouble *toNoInterlace() const; DataArrayDouble *subArray(int tupleIdBg, int tupleIdEnd=-1) const; void transpose(); - DataArrayDouble *changeNbOfComponents(int newNbOfComp, double dftValue) const; + DataArrayDouble *changeNbOfComponents(std::size_t newNbOfComp, double dftValue) const; void meldWith(const DataArrayDouble *other); DataArrayDouble *duplicateEachTupleNTimes(int nbTimes) const; DataArrayDouble *getDifferentValues(double prec, int limitTupleId=-1) const; - DataArrayInt *findClosestTupleId(const DataArrayDouble *other) const; - DataArrayInt *computeNbOfInteractionsWith(const DataArrayDouble *otherBBoxFrmt, double eps) const; + 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 setPartOfValuesAdv(const DataArrayDouble *a, const DataArrayInt *tuplesSelec); + 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; double back() const; @@ -942,6 +1051,7 @@ namespace MEDCoupling DataArrayDouble *deviator() const; DataArrayDouble *magnitude() const; DataArrayDouble *maxPerTuple() const; + DataArrayDouble *minPerTuple() const; DataArrayDouble *sumPerTuple() const; DataArrayDouble *buildEuclidianDistanceDenseMatrix() const; DataArrayDouble *buildEuclidianDistanceDenseMatrixWith(const DataArrayDouble *other) const; @@ -962,9 +1072,9 @@ namespace MEDCoupling DataArrayDouble *applyFuncNamedCompo(int nbOfComp, const std::vector& varsOrder, const std::string& func, bool isSafe=true) const; void applyFuncFast32(const std::string& func); void applyFuncFast64(const std::string& func); - DataArrayInt *findIdsInRange(double vmin, double vmax) const; - DataArrayInt *findIdsNotInRange(double vmin, double vmax) const; - DataArrayInt *findIdsStrictlyNegative() const; + DataArrayIdType *findIdsInRange(double vmin, double vmax) const; + DataArrayIdType *findIdsNotInRange(double vmin, double vmax) const; + DataArrayIdType *findIdsStrictlyNegative() const; static DataArrayDouble *Aggregate(const DataArrayDouble *a1, const DataArrayDouble *a2); static DataArrayDouble *Meld(const DataArrayDouble *a1, const DataArrayDouble *a2); static DataArrayDouble *Dot(const DataArrayDouble *a1, const DataArrayDouble *a2); @@ -981,11 +1091,12 @@ namespace MEDCoupling void divideEqual(const DataArrayDouble *other); static DataArrayDouble *Pow(const DataArrayDouble *a1, const DataArrayDouble *a2); void powEqual(const DataArrayDouble *other); - MCAuto findIdsGreaterOrEqualTo(double val) const; - MCAuto findIdsGreaterThan(double val) const; - MCAuto findIdsLowerOrEqualTo(double val) const; - MCAuto findIdsLowerThan(double val) const; - MCAuto convertToIntArr() const; + MCAuto findIdsGreaterOrEqualTo(double val) const; + MCAuto findIdsGreaterThan(double val) const; + MCAuto findIdsLowerOrEqualTo(double val) const; + MCAuto findIdsLowerThan(double val) const; + MCAuto convertToIntArr() const; + MCAuto convertToInt64Arr() const; MCAuto selectPartDef(const PartDefinition* pd) const; MCAuto cumSum() const; MCAuto convertToFloatArr() const; @@ -1000,7 +1111,7 @@ namespace MEDCoupling { return DataArrayT_New(elt0,nbOfTuples,elt2); } - + DataArrayDouble(PyObject *elt0, PyObject *nbOfTuples=0, PyObject *elt2=0) { return MEDCoupling_DataArrayDouble_New__SWIG_1(elt0,nbOfTuples,elt2); @@ -1010,7 +1121,7 @@ namespace MEDCoupling { double val; std::vector bb; - int sw,nbTuples=-1; + mcIdType sw; mcIdType nbTuples=-1; const char msg[]="Python wrap of DataArrayDouble::pushBackValsSilent : "; const double *tmp=convertObjToPossibleCpp5_SingleCompo(li,sw,val,bb,msg,true,nbTuples); self->pushBackValsSilent(tmp,tmp+nbTuples); @@ -1033,7 +1144,7 @@ namespace MEDCoupling return self->doubleValue(); } - int __len__() const + mcIdType __len__() const { if(self->isAllocated()) { @@ -1057,7 +1168,7 @@ namespace MEDCoupling PyTuple_SetItem(ret,0,ret0); } PyTuple_SetItem(ret,1,PyFloat_FromDouble(radius)); - PyTuple_SetItem(ret,2,PyFloat_FromDouble(ang)); + PyTuple_SetItem(ret,2,PyFloat_FromDouble(ang)); return ret; } @@ -1065,7 +1176,7 @@ namespace MEDCoupling { return self->iterator(); } - + void setValues(PyObject *li, PyObject *nbOfTuples=0, PyObject *nbOfComp=0) { const char *msg="MEDCoupling::DataArrayDouble::setValues : Available API are : \n-DataArrayDouble.setValues([1.,3.,4.])\n-DataArrayDouble.setValues([1.,3.,4.],3)\n-DataArrayDouble.setValues([1.,3.,4.,5.],2,2)\n-DataArrayDouble.setValues([(1.,1.7),(3.,3.7),(4.,4.7)])\n !"; @@ -1075,14 +1186,14 @@ namespace MEDCoupling { if(PyInt_Check(nbOfTuples)) { - int 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) - int 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); @@ -1093,7 +1204,7 @@ namespace MEDCoupling } else {//DataArrayDouble.setValues([1.,3.,4.],3) - int tmpp1=-1; + mcIdType tmpp1=-1; std::vector tmp=fillArrayWithPyListDbl2(li,nbOfTuples1,tmpp1); self->alloc(nbOfTuples1,tmpp1); std::copy(tmp.begin(),tmp.end(),self->getPointer()); } @@ -1103,7 +1214,7 @@ namespace MEDCoupling } else {// DataArrayDouble.setValues([1.,3.,4.]) - int tmpp1=-1,tmpp2=-1; + mcIdType tmpp1=-1,tmpp2=-1; std::vector tmp=fillArrayWithPyListDbl2(li,tmpp1,tmpp2); self->alloc(tmpp1,tmpp2); std::copy(tmp.begin(),tmp.end(),self->getPointer()); } @@ -1140,7 +1251,8 @@ namespace MEDCoupling PyObject *getValuesAsTuple() const { const double *vals(self->begin()); - int nbOfComp(self->getNumberOfComponents()),nbOfTuples(self->getNumberOfTuples()); + std::size_t nbOfComp(self->getNumberOfComponents()); + mcIdType nbOfTuples(self->getNumberOfTuples()); return convertDblArrToPyListOfTuple(vals,nbOfComp,nbOfTuples); } @@ -1151,7 +1263,7 @@ namespace MEDCoupling DataArrayDouble *a,*a2; DataArrayDoubleTuple *aa,*aa2; std::vector bb,bb2; - int sw; + mcIdType sw; const double *seg2Ptr(convertObjToPossibleCpp5_Safe(seg2,sw,val,a,aa,bb,msg,2,2,true)); const double *tri3Ptr(convertObjToPossibleCpp5_Safe(tri3,sw,val2,a2,aa2,bb2,msg,3,2,true)); // @@ -1165,7 +1277,7 @@ namespace MEDCoupling PyTuple_SetItem(ret,1,PyFloat_FromDouble(res1)); return ret; } - + DataArrayDouble *symmetry3DPlane(PyObject *point, PyObject *normalVector) { const char msg[]="Python wrap of DataArrayDouble::symmetry3DPlane : "; @@ -1173,7 +1285,7 @@ namespace MEDCoupling DataArrayDouble *a,*a2; DataArrayDoubleTuple *aa,*aa2; std::vector bb,bb2; - int sw; + mcIdType sw; const double *centerPtr(convertObjToPossibleCpp5_Safe(point,sw,val,a,aa,bb,msg,1,3,true)); const double *vectorPtr(convertObjToPossibleCpp5_Safe(normalVector,sw,val2,a2,aa2,bb2,msg,1,3,true)); MCAuto ret(self->symmetry3DPlane(centerPtr,vectorPtr)); @@ -1183,11 +1295,11 @@ namespace MEDCoupling static PyObject *GiveBaseForPlane(PyObject *normalVector) { const char msg[]="Python wrap of DataArrayDouble::GiveBaseForPlane : "; - double val,val2; - DataArrayDouble *a,*a2; - DataArrayDoubleTuple *aa,*aa2; + double val; + DataArrayDouble *a; + DataArrayDoubleTuple *aa; std::vector bb,bb2; - int sw; + mcIdType sw; const double *vectorPtr(convertObjToPossibleCpp5_Safe(normalVector,sw,val,a,aa,bb,msg,1,3,true)); double res[9]; DataArrayDouble::GiveBaseForPlane(vectorPtr,res); @@ -1201,20 +1313,20 @@ namespace MEDCoupling DataArrayDouble *a,*a2; DataArrayDoubleTuple *aa,*aa2; std::vector bb,bb2; - int sw; + mcIdType sw; const double *centerPtr=convertObjToPossibleCpp5_Safe(center,sw,val,a,aa,bb,msg,1,3,true); const double *vectorPtr=convertObjToPossibleCpp5_Safe(vector,sw,val2,a2,aa2,bb2,msg,1,3,true); return self->fromCartToCylGiven(coords,centerPtr,vectorPtr); } - + DataArrayDouble *renumber(PyObject *li) { void *da=0; - int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_MEDCoupling__DataArrayInt, 0 | 0 ); + int res1=SWIG_ConvertPtr(li,&da,SWIGTITraits::TI, 0 | 0 ); if (!SWIG_IsOK(res1)) { - int size; - INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); + mcIdType size; + INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); if(size!=self->getNumberOfTuples()) { throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !"); @@ -1223,11 +1335,11 @@ namespace MEDCoupling } else { - DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da); + DataArrayIdType *da2=reinterpret_cast< DataArrayIdType * >(da); if(!da2) throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !"); da2->checkAllocated(); - int size=self->getNumberOfTuples(); + mcIdType size=self->getNumberOfTuples(); if(size!=self->getNumberOfTuples()) { throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !"); @@ -1239,11 +1351,11 @@ namespace MEDCoupling DataArrayDouble *renumberR(PyObject *li) { void *da=0; - int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_MEDCoupling__DataArrayInt, 0 | 0 ); + int res1=SWIG_ConvertPtr(li,&da,SWIGTITraits::TI, 0 | 0 ); if (!SWIG_IsOK(res1)) { - int size; - INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); + mcIdType size; + INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); if(size!=self->getNumberOfTuples()) { throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !"); @@ -1252,11 +1364,11 @@ namespace MEDCoupling } else { - DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da); + DataArrayIdType *da2=reinterpret_cast< DataArrayIdType * >(da); if(!da2) throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !"); da2->checkAllocated(); - int size=self->getNumberOfTuples(); + mcIdType size=self->getNumberOfTuples(); if(size!=self->getNumberOfTuples()) { throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !"); @@ -1265,14 +1377,14 @@ namespace MEDCoupling } } - DataArrayDouble *renumberAndReduce(PyObject *li, int newNbOfTuple) + DataArrayDouble *renumberAndReduce(PyObject *li, mcIdType newNbOfTuple) { void *da=0; - int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_MEDCoupling__DataArrayInt, 0 | 0 ); + int res1=SWIG_ConvertPtr(li,&da,SWIGTITraits::TI, 0 | 0 ); if (!SWIG_IsOK(res1)) { - int size; - INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); + mcIdType size; + INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); if(size!=self->getNumberOfTuples()) { throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !"); @@ -1281,11 +1393,11 @@ namespace MEDCoupling } else { - DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da); + DataArrayIdType *da2=reinterpret_cast< DataArrayIdType * >(da); if(!da2) throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !"); da2->checkAllocated(); - int size=self->getNumberOfTuples(); + mcIdType size=self->getNumberOfTuples(); if(size!=self->getNumberOfTuples()) { throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !"); @@ -1296,7 +1408,7 @@ namespace MEDCoupling PyObject *minimalDistanceTo(const DataArrayDouble *other) const { - int thisTupleId,otherTupleId; + mcIdType thisTupleId,otherTupleId; double r0=self->minimalDistanceTo(other,thisTupleId,otherTupleId); PyObject *ret=PyTuple_New(3); PyTuple_SetItem(ret,0,PyFloat_FromDouble(r0)); @@ -1307,7 +1419,7 @@ namespace MEDCoupling PyObject *getMaxValue() const { - int tmp; + mcIdType tmp; double r1=self->getMaxValue(tmp); PyObject *ret=PyTuple_New(2); PyTuple_SetItem(ret,0,PyFloat_FromDouble(r1)); @@ -1327,17 +1439,17 @@ namespace MEDCoupling PyObject *getMaxValue2() const { - DataArrayInt *tmp; + DataArrayIdType *tmp; double r1=self->getMaxValue2(tmp); PyObject *ret=PyTuple_New(2); PyTuple_SetItem(ret,0,PyFloat_FromDouble(r1)); - PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(tmp),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(tmp),SWIGTITraits::TI, SWIG_POINTER_OWN | 0 )); return ret; } PyObject *getMinValue() const { - int tmp; + mcIdType tmp; double r1=self->getMinValue(tmp); PyObject *ret=PyTuple_New(2); PyTuple_SetItem(ret,0,PyFloat_FromDouble(r1)); @@ -1347,54 +1459,54 @@ namespace MEDCoupling PyObject *getMinValue2() const { - DataArrayInt *tmp; + DataArrayIdType *tmp; double r1=self->getMinValue2(tmp); PyObject *ret=PyTuple_New(2); PyTuple_SetItem(ret,0,PyFloat_FromDouble(r1)); - PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(tmp),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(tmp),SWIGTITraits::TI, SWIG_POINTER_OWN | 0 )); return ret; } PyObject *getMinMaxPerComponent() const { - int nbOfCompo(self->getNumberOfComponents()); + 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; } - + PyObject *normMaxPerComponent() const { - int nbOfCompo(self->getNumberOfComponents()); + 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 { - int sz=self->getNumberOfComponents(); + 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 { - int sw,sz,val; - std::vector val2; - const int *bg=convertIntStarLikePyObjToCppIntStar(indexArr,sw,sz,val,val2); + mcIdType sw, sz,val; + std::vector val2; + const mcIdType *bg=convertIntStarLikePyObjToCppIntStar(indexArr,sw,sz,val,val2); return self->accumulatePerChunck(bg,bg+sz); } - PyObject *findCommonTuples(double prec, int limitNodeId=-1) const + PyObject *findCommonTuples(double prec, mcIdType limitNodeId=-1) const { - DataArrayInt *comm, *commIndex; + DataArrayIdType *comm, *commIndex; self->findCommonTuples(prec,limitNodeId,comm,commIndex); PyObject *res = PyList_New(2); - PyList_SetItem(res,0,SWIG_NewPointerObj(SWIG_as_voidptr(comm),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 )); - PyList_SetItem(res,1,SWIG_NewPointerObj(SWIG_as_voidptr(commIndex),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 )); + PyList_SetItem(res,0,SWIG_NewPointerObj(SWIG_as_voidptr(comm),SWIGTITraits::TI, SWIG_POINTER_OWN | 0 )); + PyList_SetItem(res,1,SWIG_NewPointerObj(SWIG_as_voidptr(commIndex),SWIGTITraits::TI, SWIG_POINTER_OWN | 0 )); return res; } @@ -1404,9 +1516,10 @@ namespace MEDCoupling DataArrayDouble *a; DataArrayDoubleTuple *aa; std::vector bb; - int sw; - int 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 sw; + 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); @@ -1417,7 +1530,7 @@ namespace MEDCoupling void setSelectedComponents(const DataArrayDouble *a, PyObject *li) { - std::vector tmp; + std::vector tmp; convertPyToNewIntArr3(li,tmp); self->setSelectedComponents(a,tmp); } @@ -1431,13 +1544,13 @@ namespace MEDCoupling PyList_SetItem(res,i,SWIG_NewPointerObj(SWIG_as_voidptr(retCpp[i].retn()),SWIGTYPE_p_MEDCoupling__DataArrayDouble, SWIG_POINTER_OWN | 0 )); return res; } - - PyObject *getTuple(int tupleId) + + PyObject *getTuple(mcIdType tupleId) { - int sz=self->getNumberOfComponents(); + 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) @@ -1460,28 +1573,29 @@ namespace MEDCoupling DataArrayDouble *a; DataArrayDoubleTuple *aa; std::vector bb; - int sw; - int nbComp=self->getNumberOfComponents(),nbTuples=-1; + mcIdType sw; + 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); - DataArrayInt *c=0,*cI=0; + DataArrayIdType *c=0,*cI=0; self->computeTupleIdsNearTuples(inpu,eps,c,cI); PyObject *ret=PyTuple_New(2); - PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(c),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 )); - PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(cI),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(c),SWIGTITraits::TI, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(cI),SWIGTITraits::TI, SWIG_POINTER_OWN | 0 )); return ret; } PyObject *areIncludedInMe(const DataArrayDouble *other, double prec) const { - DataArrayInt *ret1=0; + DataArrayIdType *ret1=0; bool ret0=self->areIncludedInMe(other,prec,ret1); PyObject *ret=PyTuple_New(2); PyObject *ret0Py=ret0?Py_True:Py_False; Py_XINCREF(ret0Py); PyTuple_SetItem(ret,0,ret0Py); - PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTITraits::TI, SWIG_POINTER_OWN | 0 )); return ret; } @@ -1507,7 +1621,7 @@ namespace MEDCoupling DataArrayDouble *a; DataArrayDoubleTuple *aa; std::vector bb; - int sw; + mcIdType sw; // #ifndef WITHOUT_AUTOFIELD void *argp; @@ -1546,7 +1660,7 @@ namespace MEDCoupling } case 4: { - MCAuto aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,DeallocType::CPP_DEALLOC,1,(int)bb.size()); + MCAuto aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,DeallocType::CPP_DEALLOC,1,bb.size()); return SWIG_NewPointerObj(SWIG_as_voidptr(DataArrayDouble::Add(self,aaa)),SWIGTYPE_p_MEDCoupling__DataArrayDouble, SWIG_POINTER_OWN | 0 ); } default: @@ -1561,7 +1675,7 @@ namespace MEDCoupling DataArrayDouble *a; DataArrayDoubleTuple *aa; std::vector bb; - int sw; + mcIdType sw; convertDoubleStarLikePyObjToCpp_2(obj,sw,val,a,aa,bb); switch(sw) { @@ -1578,14 +1692,14 @@ namespace MEDCoupling } case 4: { - MCAuto aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,DeallocType::CPP_DEALLOC,1,(int)bb.size()); + MCAuto aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,DeallocType::CPP_DEALLOC,1,bb.size()); return DataArrayDouble::Add(self,aaa); } default: throw INTERP_KERNEL::Exception(msg); } } - + PyObject *___iadd___(PyObject *trueSelf, PyObject *obj) { return DataArrayT_iadd(trueSelf,obj,self); @@ -1598,7 +1712,7 @@ namespace MEDCoupling DataArrayDouble *a; DataArrayDoubleTuple *aa; std::vector bb; - int sw; + mcIdType sw; // #ifndef WITHOUT_AUTOFIELD void *argp; @@ -1637,7 +1751,7 @@ namespace MEDCoupling } case 4: { - MCAuto aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,DeallocType::CPP_DEALLOC,1,(int)bb.size()); + MCAuto aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,DeallocType::CPP_DEALLOC,1,bb.size()); return SWIG_NewPointerObj(SWIG_as_voidptr(DataArrayDouble::Substract(self,aaa)),SWIGTYPE_p_MEDCoupling__DataArrayDouble, SWIG_POINTER_OWN | 0 ); } default: @@ -1652,7 +1766,7 @@ namespace MEDCoupling DataArrayDouble *a; DataArrayDoubleTuple *aa; std::vector bb; - int sw; + mcIdType sw; convertDoubleStarLikePyObjToCpp_2(obj,sw,val,a,aa,bb); switch(sw) { @@ -1669,7 +1783,7 @@ namespace MEDCoupling } case 4: { - MCAuto aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,DeallocType::CPP_DEALLOC,1,(int)bb.size()); + MCAuto aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,DeallocType::CPP_DEALLOC,1,bb.size()); return DataArrayDouble::Substract(aaa,self); } default: @@ -1689,7 +1803,7 @@ namespace MEDCoupling DataArrayDouble *a; DataArrayDoubleTuple *aa; std::vector bb; - int sw; + mcIdType sw; // #ifndef WITHOUT_AUTOFIELD void *argp; @@ -1728,7 +1842,7 @@ namespace MEDCoupling } case 4: { - MCAuto aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,DeallocType::CPP_DEALLOC,1,(int)bb.size()); + MCAuto aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,DeallocType::CPP_DEALLOC,1,bb.size()); return SWIG_NewPointerObj(SWIG_as_voidptr(DataArrayDouble::Multiply(self,aaa)),SWIGTYPE_p_MEDCoupling__DataArrayDouble, SWIG_POINTER_OWN | 0 ); } default: @@ -1753,7 +1867,7 @@ namespace MEDCoupling DataArrayDouble *a; DataArrayDoubleTuple *aa; std::vector bb; - int sw; + mcIdType sw; // #ifndef WITHOUT_AUTOFIELD void *argp; @@ -1794,7 +1908,7 @@ namespace MEDCoupling } case 4: { - MCAuto aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,DeallocType::CPP_DEALLOC,1,(int)bb.size()); + MCAuto aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,DeallocType::CPP_DEALLOC,1,bb.size()); return SWIG_NewPointerObj(SWIG_as_voidptr(DataArrayDouble::Divide(self,aaa)),SWIGTYPE_p_MEDCoupling__DataArrayDouble, SWIG_POINTER_OWN | 0 ); } default: @@ -1809,7 +1923,7 @@ namespace MEDCoupling DataArrayDouble *a; DataArrayDoubleTuple *aa; std::vector bb; - int sw; + mcIdType sw; convertDoubleStarLikePyObjToCpp_2(obj,sw,val,a,aa,bb); switch(sw) { @@ -1826,7 +1940,7 @@ namespace MEDCoupling } case 4: { - MCAuto aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,DeallocType::CPP_DEALLOC,1,(int)bb.size()); + MCAuto aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,DeallocType::CPP_DEALLOC,1,bb.size()); return DataArrayDouble::Divide(aaa,self); } default: @@ -1838,7 +1952,7 @@ namespace MEDCoupling { return DataArrayT_idiv(trueSelf,obj,self); } - + DataArrayDouble *__pow__(PyObject *obj) { const char msg[]="Unexpected situation in __pow__ !"; @@ -1846,7 +1960,7 @@ namespace MEDCoupling DataArrayDouble *a; DataArrayDoubleTuple *aa; std::vector bb; - int sw; + mcIdType sw; convertDoubleStarLikePyObjToCpp_2(obj,sw,val,a,aa,bb); switch(sw) { @@ -1867,7 +1981,7 @@ namespace MEDCoupling } case 4: { - MCAuto aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,DeallocType::CPP_DEALLOC,1,(int)bb.size()); + MCAuto aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,DeallocType::CPP_DEALLOC,1,bb.size()); return DataArrayDouble::Pow(self,aaa); } default: @@ -1882,7 +1996,7 @@ namespace MEDCoupling DataArrayDouble *a; DataArrayDoubleTuple *aa; std::vector bb; - int sw; + mcIdType sw; convertDoubleStarLikePyObjToCpp_2(obj,sw,val,a,aa,bb); switch(sw) { @@ -1899,7 +2013,7 @@ namespace MEDCoupling } case 4: { - MCAuto aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,DeallocType::CPP_DEALLOC,1,(int)bb.size()); + MCAuto aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,DeallocType::CPP_DEALLOC,1,bb.size()); return DataArrayDouble::Pow(aaa,self); } default: @@ -1914,7 +2028,7 @@ namespace MEDCoupling DataArrayDouble *a; DataArrayDoubleTuple *aa; std::vector bb; - int sw; + mcIdType sw; convertDoubleStarLikePyObjToCpp_2(obj,sw,val,a,aa,bb); switch(sw) { @@ -1939,7 +2053,7 @@ namespace MEDCoupling } case 4: { - MCAuto aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,DeallocType::CPP_DEALLOC,1,(int)bb.size()); + MCAuto aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,DeallocType::CPP_DEALLOC,1,bb.size()); self->powEqual(aaa); Py_XINCREF(trueSelf); return trueSelf; @@ -1948,25 +2062,25 @@ namespace MEDCoupling throw INTERP_KERNEL::Exception(msg); } } - + PyObject *computeTupleIdsNearTuples(const DataArrayDouble *other, double eps) { - DataArrayInt *c=0,*cI=0; + DataArrayIdType *c=0,*cI=0; // self->computeTupleIdsNearTuples(other,eps,c,cI); PyObject *ret=PyTuple_New(2); - PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(c),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 )); - PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(cI),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(c),SWIGTITraits::TI, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(cI),SWIGTITraits::TI, SWIG_POINTER_OWN | 0 )); return ret; } PyObject *maxPerTupleWithCompoId() const { - DataArrayInt *ret1=0; + DataArrayIdType *ret1=0; DataArrayDouble *ret0=self->maxPerTupleWithCompoId(ret1); PyObject *ret=PyTuple_New(2); PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_MEDCoupling__DataArrayDouble, SWIG_POINTER_OWN | 0 )); - PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTITraits::TI, SWIG_POINTER_OWN | 0 )); return ret; } } @@ -1998,7 +2112,7 @@ namespace MEDCoupling class DataArrayDoubleTuple { public: - int getNumberOfCompo() const; + std::size_t getNumberOfCompo() const; DataArrayDouble *buildDADouble(int nbOfTuples, int nbOfCompo) const; %extend { @@ -2024,7 +2138,7 @@ namespace MEDCoupling Py_XINCREF(trueSelf); return trueSelf; } - + PyObject *___isub___(PyObject *trueSelf, PyObject *obj) { MCAuto ret=self->buildDADouble(1,self->getNumberOfCompo()); @@ -2032,7 +2146,7 @@ namespace MEDCoupling Py_XINCREF(trueSelf); return trueSelf; } - + PyObject *___imul___(PyObject *trueSelf, PyObject *obj) { MCAuto ret=self->buildDADouble(1,self->getNumberOfCompo()); @@ -2057,13 +2171,13 @@ namespace MEDCoupling PyObject *__getitem__(PyObject *obj) { const char msg2[]="DataArrayDoubleTuple::__getitem__ : Mismatch of slice values in 2nd parameter (components) !"; - int sw; - int singleVal; - std::vector multiVal; - std::pair > slic; - MEDCoupling::DataArrayInt *daIntTyypp=0; + mcIdType sw; + mcIdType singleVal; + std::vector multiVal; + std::pair > slic; + MEDCoupling::DataArrayIdType *daIntTyypp=0; const double *pt=self->getConstPointer(); - int nbc=self->getNumberOfCompo(); + mcIdType nbc=ToIdType(self->getNumberOfCompo()); convertIntStarOrSliceLikePyObjToCppWithNegIntInterp(obj,nbc,sw,singleVal,multiVal,slic,daIntTyypp); switch(sw) { @@ -2093,9 +2207,9 @@ namespace MEDCoupling 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) { std::ostringstream oss; @@ -2108,9 +2222,9 @@ namespace MEDCoupling } 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; MEDCoupling::DataArrayDoubleTuple *daIntTyyppV=0; - int nbc=self->getNumberOfCompo(); + mcIdType nbc=ToIdType(self->getNumberOfCompo()); convertDoubleStarLikePyObjToCpp(value,sw1,singleValV,multiValV,daIntTyyppV); - int singleVal; - std::vector multiVal; - std::pair > slic; - MEDCoupling::DataArrayInt *daIntTyypp=0; + mcIdType singleVal; + std::vector multiVal; + std::pair > slic; + MEDCoupling::DataArrayIdType *daIntTyypp=0; double *pt=self->getPointer(); convertIntStarOrSliceLikePyObjToCppWithNegIntInterp(obj,nbc,sw2,singleVal,multiVal,slic,daIntTyypp); switch(sw2) @@ -2178,7 +2292,7 @@ namespace MEDCoupling { case 1: { - for(std::vector::const_iterator it=multiVal.begin();it!=multiVal.end();it++) + for(std::vector::const_iterator it=multiVal.begin();it!=multiVal.end();it++) { if(*it>=nbc) { @@ -2198,9 +2312,9 @@ namespace MEDCoupling oss << "Mismatch length of during assignment : " << multiValV.size() << " != " << multiVal.size() << " !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } - for(int i=0;i<(int)multiVal.size();i++) + for(std::size_t i=0;i=nbc) { std::ostringstream oss; @@ -2214,7 +2328,7 @@ namespace MEDCoupling case 3: { const double *ptV=daIntTyyppV->getConstPointer(); - if(nbc>daIntTyyppV->getNumberOfCompo()) + if(nbc>(mcIdType)daIntTyyppV->getNumberOfCompo()) { std::ostringstream oss; oss << "Mismatch length of during assignment : " << nbc << " != " << daIntTyyppV->getNumberOfCompo() << " !"; @@ -2229,37 +2343,37 @@ namespace MEDCoupling } 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); switch(sw1) { case 1: { - for(int j=0;jgetConstPointer(); - if(sz>daIntTyyppV->getNumberOfCompo()) + if(sz>(mcIdType)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 invertArrayN2O2O2NOptimized() const; - MCAuto< MapII > giveN2OOptimized() const; - DataArrayInt *indicesOfSubPart(const DataArrayInt& partOfThis) const; - DataArrayInt *fromNoInterlace() const; - DataArrayInt *toNoInterlace() const; - DataArrayInt *selectByTupleIdSafeSlice(int bg, int end, int step) const; - DataArrayInt *checkAndPreparePermutation() const; - DataArrayInt *buildPermArrPerLevel() const; - bool isIota(int sizeExpected) const; - bool isUniform(int val) const; - int checkUniformAndGuess() const; - bool hasUniqueValues() const; - DataArrayInt *subArray(int tupleIdBg, int tupleIdEnd=-1) const; - void transpose(); - DataArrayInt *changeNbOfComponents(int newNbOfComp, int dftValue) const; - void meldWith(const DataArrayInt *other); - void setPartOfValues1(const DataArrayInt *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 setPartOfValuesAdv(const DataArrayInt *a, const DataArrayInt *tuplesSelec); - void getTuple(int tupleId, int *res) const; - int getIJ(int tupleId, int compoId) const; - int getIJSafe(int tupleId, int compoId) const; - int front() const; - int back() const; - void setIJ(int tupleId, int compoId, int newVal); - void setIJSilent(int tupleId, int compoId, int newVal); - int *getPointer(); - const int *getConstPointer() const; - DataArrayIntIterator *iterator(); - const int *begin() const; - const int *end() const; - DataArrayInt *findIdsEqual(int val) const; - DataArrayInt *findIdsNotEqual(int val) const; - int changeValue(int oldValue, int newValue); - int findIdFirstEqualTuple(const std::vector& tupl) const; - int findIdFirstEqual(int value) const; - int findIdFirstEqual(const std::vector& vals) const; - int findIdSequence(const std::vector& vals) const; - bool presenceOfTuple(const std::vector& tupl) const; - bool presenceOfValue(int value) const; - bool presenceOfValue(const std::vector& vals) const; - int count(int value) const; - int accumulate(int compId) const; - int getMaxValueInArray() const; - int getMaxAbsValueInArray() const; - int getMinValueInArray() const; - void abs(); - DataArrayInt *computeAbs() const; - void applyLin(int a, int b, int compoId); - void applyLin(int a, int b); - void applyInv(int numerator); - DataArrayInt *negate() const; - void applyDivideBy(int val); - void applyModulus(int val); - void applyRModulus(int val); - void applyPow(int val); - void applyRPow(int val); - DataArrayInt *findIdsInRange(int vmin, int vmax) const; - DataArrayInt *findIdsNotInRange(int vmin, int vmax) const; - DataArrayInt *findIdsStrictlyNegative() const; - bool checkAllIdsInRange(int vmin, int vmax) const; - static DataArrayInt *Aggregate(const DataArrayInt *a1, const DataArrayInt *a2, int offsetA2); - static DataArrayInt *Meld(const DataArrayInt *a1, const DataArrayInt *a2); - static DataArrayInt *MakePartition(const std::vector& groups, int newNb, std::vector< std::vector >& fidsOfGroups); - static DataArrayInt *BuildUnion(const std::vector& arr); - static DataArrayInt *BuildIntersection(const std::vector& arr); - static DataArrayInt *FindPermutationFromFirstToSecond(const DataArrayInt *ids1, const DataArrayInt *ids2); - DataArrayInt *buildComplement(int nbOfElement) const; - DataArrayInt *buildSubstraction(const DataArrayInt *other) const; - DataArrayInt *buildSubstractionOptimized(const DataArrayInt *other) const; - DataArrayInt *buildUnion(const DataArrayInt *other) const; - DataArrayInt *buildIntersection(const DataArrayInt *other) const; - DataArrayInt *buildUnique() const; - DataArrayInt *buildUniqueNotSorted() const; - DataArrayInt *deltaShiftIndex() const; - void computeOffsets(); - void computeOffsetsFull(); - DataArrayInt *buildExplicitArrByRanges(const DataArrayInt *offsets) const; - DataArrayInt *findRangeIdForEachTuple(const DataArrayInt *ranges) const; - DataArrayInt *findIdInRangeForEachTuple(const DataArrayInt *ranges) const; - void sortEachPairToMakeALinkedList(); - DataArrayInt *duplicateEachTupleNTimes(int nbTimes) const; - DataArrayInt *getDifferentValues() const; - static DataArrayInt *Add(const DataArrayInt *a1, const DataArrayInt *a2); - void addEqual(const DataArrayInt *other); - static DataArrayInt *Substract(const DataArrayInt *a1, const DataArrayInt *a2); - void substractEqual(const DataArrayInt *other); - static DataArrayInt *Multiply(const DataArrayInt *a1, const DataArrayInt *a2); - void multiplyEqual(const DataArrayInt *other); - static DataArrayInt *Divide(const DataArrayInt *a1, const DataArrayInt *a2); - void divideEqual(const DataArrayInt *other); - static DataArrayInt *Modulus(const DataArrayInt *a1, const DataArrayInt *a2); - void modulusEqual(const DataArrayInt *other); - static DataArrayInt *Pow(const DataArrayInt *a1, const DataArrayInt *a2); - void powEqual(const DataArrayInt *other); - MCAuto fromLinkedListOfPairToList() const; - MCAuto findIdsGreaterOrEqualTo(int val) const; - MCAuto findIdsGreaterThan(int val) const; - MCAuto findIdsLowerOrEqualTo(int val) const; - MCAuto findIdsLowerThan(int val) const; - MCAuto selectPartDef(const PartDefinition* pd) const; - MCAuto convertToDblArr() const; - MCAuto convertToFloatArr() const; + DataArrayInt *convertToIntArr() const; + DataArrayChar *renumber(const mcIdType *old2New) const; + DataArrayChar *renumberR(const mcIdType *new2Old) const; + DataArrayChar *renumberAndReduce(const mcIdType *old2NewBg, mcIdType newNbOfTuple) const; + bool isUniform(char val) const; + void sort(bool asc=true); + DataArrayChar *subArray(mcIdType tupleIdBg, mcIdType tupleIdEnd=-1) const; + DataArrayChar *changeNbOfComponents(std::size_t newNbOfComp, char dftValue) const; + void meldWith(const DataArrayChar *other); + void setPartOfValuesAdv(const DataArrayChar *a, const DataArrayIdType *tuplesSelec); + char front() const; + char back() const; + void setIJ(mcIdType tupleId, int compoId, char newVal); + void setIJSilent(mcIdType tupleId, int compoId, char newVal); + char *getPointer(); + DataArrayIdType *findIdsEqual(char val) const; + DataArrayIdType *findIdsNotEqual(char val) const; + int findIdFirstEqualTuple(const std::vector& tupl) const; + bool presenceOfTuple(const std::vector& tupl) const; + char getMaxValue(mcIdType& tupleId) const; + char getMaxValueInArray() const; + char getMinValue(mcIdType& tupleId) const; + char getMinValueInArray() const; + DataArrayIdType *findIdsInRange(char vmin, char vmax) const; + static DataArrayChar *Aggregate(const DataArrayChar *a1, const DataArrayChar *a2); + static DataArrayChar *Meld(const DataArrayChar *a1, const DataArrayChar *a2); + %extend + { + mcIdType __len__() const + { + if(self->isAllocated()) + { + return self->getNumberOfTuples(); + } + else + { + throw INTERP_KERNEL::Exception("DataArrayChar::__len__ : Instance is NOT allocated !"); + } + } + + PyObject *isEqualIfNotWhy(const DataArrayChar& other) const + { + std::string ret1; + bool ret0=self->isEqualIfNotWhy(other,ret1); + PyObject *ret=PyTuple_New(2); + PyObject *ret0Py=ret0?Py_True:Py_False; + Py_XINCREF(ret0Py); + PyTuple_SetItem(ret,0,ret0Py); + PyTuple_SetItem(ret,1,PyString_FromString(ret1.c_str())); + return ret; + } + + DataArrayChar *renumber(PyObject *li) + { + void *da=0; + int res1=SWIG_ConvertPtr(li,&da,SWIGTITraits::TI, 0 | 0 ); + if (!SWIG_IsOK(res1)) + { + mcIdType size; + INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); + if(size!=self->getNumberOfTuples()) + { + throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !"); + } + return self->renumber(tmp); + } + else + { + DataArrayIdType *da2=reinterpret_cast< DataArrayIdType * >(da); + if(!da2) + throw INTERP_KERNEL::Exception("Not null DataArrayIdType instance expected !"); + da2->checkAllocated(); + mcIdType size=self->getNumberOfTuples(); + if(size!=self->getNumberOfTuples()) + { + throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !"); + } + return self->renumber(da2->getConstPointer()); + } + } + + DataArrayChar *renumberR(PyObject *li) + { + void *da=0; + int res1=SWIG_ConvertPtr(li,&da,SWIGTITraits::TI, 0 | 0 ); + if (!SWIG_IsOK(res1)) + { + mcIdType size; + INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); + if(size!=self->getNumberOfTuples()) + { + throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !"); + } + return self->renumberR(tmp); + } + else + { + DataArrayIdType *da2=reinterpret_cast< DataArrayIdType * >(da); + if(!da2) + throw INTERP_KERNEL::Exception("Not null DataArrayIdType instance expected !"); + da2->checkAllocated(); + mcIdType size=self->getNumberOfTuples(); + if(size!=self->getNumberOfTuples()) + { + throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !"); + } + return self->renumberR(da2->getConstPointer()); + } + } + + DataArrayChar *renumberAndReduce(PyObject *li, mcIdType newNbOfTuple) + { + void *da=0; + int res1=SWIG_ConvertPtr(li,&da,SWIGTITraits::TI, 0 | 0 ); + if (!SWIG_IsOK(res1)) + { + mcIdType size; + INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); + if(size!=self->getNumberOfTuples()) + { + throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !"); + } + return self->renumberAndReduce(tmp,newNbOfTuple); + } + else + { + DataArrayIdType *da2=reinterpret_cast< DataArrayIdType * >(da); + if(!da2) + throw INTERP_KERNEL::Exception("Not null DataArrayIdType instance expected !"); + da2->checkAllocated(); + mcIdType size=self->getNumberOfTuples(); + if(size!=self->getNumberOfTuples()) + { + throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !"); + } + return self->renumberAndReduce(da2->getConstPointer(),newNbOfTuple); + } + } + + static DataArrayChar *Aggregate(PyObject *dachs) + { + std::vector tmp; + convertFromPyObjVectorOfObj(dachs,SWIGTYPE_p_MEDCoupling__DataArrayChar,"DataArrayChar",tmp); + return DataArrayChar::Aggregate(tmp); + } + + static DataArrayChar *Meld(PyObject *dachs) + { + std::vector tmp; + convertFromPyObjVectorOfObj(dachs,SWIGTYPE_p_MEDCoupling__DataArrayChar,"DataArrayChar",tmp); + return DataArrayChar::Meld(tmp); + } + } + }; + + class DataArrayByteIterator; + + class DataArrayByte : public DataArrayChar + { public: - static DataArrayInt *Range(int begin, int end, int step); + static DataArrayByte *New(); + DataArrayByteIterator *iterator(); + DataArrayByte *performCopyOrIncrRef(bool deepCopy) const; + char byteValue() const; %extend { - DataArrayInt() + DataArrayByte() { - return DataArrayInt::New(); + return DataArrayByte::New(); } - static DataArrayInt *New(PyObject *elt0, PyObject *nbOfTuples=0, PyObject *nbOfComp=0) + static DataArrayByte *New(PyObject *elt0, PyObject *nbOfTuples=0, PyObject *nbOfComp=0) { - const char *msgBase="MEDCoupling::DataArrayInt::New : Available API are : \n-DataArrayInt.New()\n-DataArrayInt.New([1,3,4])\n-DataArrayInt.New([1,3,4],3)\n-DataArrayInt.New([1,3,4,5],2,2)\n-DataArrayInt.New([1,3,4,5,7,8],3,2)\n-DataArrayInt.New([(1,3),(4,5),(7,8)])\n-DataArrayInt.New(5)\n-DataArrayInt.New(5,2)"; - std::string msg(msgBase); -#ifdef WITH_NUMPY - msg+="\n-DataArrayInt.New(numpy array with dtype=int32)"; -#endif - msg+=" !"; + const char *msg="MEDCoupling::DataArrayByte::New : Available API are : \n-DataArrayByte.New()\n--DataArrayByte.New([1,3,4])\n-DataArrayByte.New([1,3,4],3)\n-DataArrayByte.New([1,3,4,5],2,2)\n-DataArrayByte.New(5)\n-DataArrayByte.New(5,2) !"; if(PyList_Check(elt0) || PyTuple_Check(elt0)) { if(nbOfTuples) { if(PyInt_Check(nbOfTuples)) { - int nbOfTuples1=PyInt_AS_LONG(nbOfTuples); + mcIdType nbOfTuples1=ToIdType(PyInt_AS_LONG(nbOfTuples)); if(nbOfTuples1<0) - throw INTERP_KERNEL::Exception("DataArrayInt::New : should be a positive set of allocated memory !"); + throw INTERP_KERNEL::Exception("DataArrayByte::New : should be a positive set of allocated memory !"); if(nbOfComp) { if(PyInt_Check(nbOfComp)) - {//DataArrayInt.New([1,3,4,5],2,2) - int nbOfCompo=PyInt_AS_LONG(nbOfComp); + {//DataArrayByte.New([1,3,4,5],2,2) + mcIdType nbOfCompo=ToIdType(PyInt_AS_LONG(nbOfComp)); if(nbOfCompo<0) - throw INTERP_KERNEL::Exception("DataArrayInt::New : should be a positive number of components !"); - MCAuto ret=DataArrayInt::New(); - std::vector tmp=fillArrayWithPyListInt2(elt0,nbOfTuples1,nbOfCompo); + throw INTERP_KERNEL::Exception("DataArrayByte::New : should be a positive number of components !"); + MCAuto ret=DataArrayByte::New(); + std::vector tmp=fillArrayWithPyListInt2(elt0,nbOfTuples1,nbOfCompo); ret->alloc(nbOfTuples1,nbOfCompo); std::copy(tmp.begin(),tmp.end(),ret->getPointer()); return ret.retn(); } else - throw INTERP_KERNEL::Exception(msg.c_str()); + throw INTERP_KERNEL::Exception(msg); } else - {//DataArrayInt.New([1,3,4],3) - MCAuto ret=DataArrayInt::New(); - int tmpp1=-1; - std::vector tmp=fillArrayWithPyListInt2(elt0,nbOfTuples1,tmpp1); + {//DataArrayByte.New([1,3,4],3) + MCAuto ret=DataArrayByte::New(); + mcIdType tmpp1=-1; + std::vector tmp=fillArrayWithPyListInt2(elt0,nbOfTuples1,tmpp1); ret->alloc(nbOfTuples1,tmpp1); std::copy(tmp.begin(),tmp.end(),ret->getPointer()); return ret.retn(); } } else - throw INTERP_KERNEL::Exception(msg.c_str()); + throw INTERP_KERNEL::Exception(msg); } else - {// DataArrayInt.New([1,3,4]) - MCAuto ret=DataArrayInt::New(); - int tmpp1=-1,tmpp2=-1; - std::vector tmp=fillArrayWithPyListInt2(elt0,tmpp1,tmpp2); + {// DataArrayByte.New([1,3,4]) + MCAuto ret=DataArrayByte::New(); + mcIdType tmpp1=-1,tmpp2=-1; + std::vector tmp=fillArrayWithPyListInt2(elt0,tmpp1,tmpp2); ret->alloc(tmpp1,tmpp2); std::copy(tmp.begin(),tmp.end(),ret->getPointer()); return ret.retn(); } } else if(PyInt_Check(elt0)) { - int nbOfTuples1=PyInt_AS_LONG(elt0); + mcIdType nbOfTuples1=ToIdType(PyInt_AS_LONG(elt0)); if(nbOfTuples1<0) - throw INTERP_KERNEL::Exception("DataArrayInt::New : should be a positive set of allocated memory !"); + throw INTERP_KERNEL::Exception("DataArrayByte::New : should be a positive set of allocated memory !"); if(nbOfTuples) { if(!nbOfComp) { if(PyInt_Check(nbOfTuples)) - {//DataArrayInt.New(5,2) - int nbOfCompo=PyInt_AS_LONG(nbOfTuples); + {//DataArrayByte.New(5,2) + mcIdType nbOfCompo=ToIdType(PyInt_AS_LONG(nbOfTuples)); if(nbOfCompo<0) - throw INTERP_KERNEL::Exception("DataArrayInt::New : should be a positive number of components !"); - MCAuto ret=DataArrayInt::New(); + throw INTERP_KERNEL::Exception("DataArrayByte::New : should be a positive number of components !"); + MCAuto ret=DataArrayByte::New(); ret->alloc(nbOfTuples1,nbOfCompo); return ret.retn(); } else - throw INTERP_KERNEL::Exception(msg.c_str()); + throw INTERP_KERNEL::Exception(msg); } else - throw INTERP_KERNEL::Exception(msg.c_str()); + throw INTERP_KERNEL::Exception(msg); } else - {//DataArrayInt.New(5) - MCAuto ret=DataArrayInt::New(); + {//DataArrayByte.New(5) + MCAuto ret=DataArrayByte::New(); ret->alloc(nbOfTuples1,1); return ret.retn(); } } #ifdef WITH_NUMPY else if(PyArray_Check(elt0) && nbOfTuples==NULL && nbOfComp==NULL) - {//DataArrayInt.New(numpyArray) - return BuildNewInstance(elt0,NPY_INT32,&PyCallBackDataArrayInt_RefType,"INT32"); + {//DataArrayDouble.New(numpyArray) + return BuildNewInstance(elt0,NPY_INT8,&PyCallBackDataArrayChar_RefType,"INT8"); } #endif else - throw INTERP_KERNEL::Exception(msg.c_str()); - throw INTERP_KERNEL::Exception(msg.c_str());//to make g++ happy + throw INTERP_KERNEL::Exception(msg); } - DataArrayInt(PyObject *elt0, PyObject *nbOfTuples=0, PyObject *nbOfComp=0) + DataArrayByte(PyObject *elt0, PyObject *nbOfTuples=0, PyObject *nbOfComp=0) { - return MEDCoupling_DataArrayInt_New__SWIG_1(elt0,nbOfTuples,nbOfComp); + return MEDCoupling_DataArrayByte_New__SWIG_1(elt0,nbOfTuples,nbOfComp); } - - std::string __str__() const - { - return self->reprNotTooLong(); - } - int __len__() const + std::string __repr__() const { - if(self->isAllocated()) - { - return self->getNumberOfTuples(); - } - else - { - throw INTERP_KERNEL::Exception("DataArrayInt::__len__ : Instance is NOT allocated !"); - } + std::ostringstream oss; + self->reprQuickOverview(oss); + return oss.str(); } int __int__() const { - return self->intValue(); + return (int) self->byteValue(); } - DataArrayIntIterator *__iter__() + DataArrayByteIterator *__iter__() { return self->iterator(); } - - PyObject *accumulate() const + + mcIdType getIJ(mcIdType tupleId, mcIdType compoId) const { - int sz=self->getNumberOfComponents(); - INTERP_KERNEL::AutoPtr tmp=new int[sz]; - self->accumulate(tmp); - return convertIntArrToPyList(tmp,sz); + return (mcIdType)self->getIJ(tupleId,compoId); } - DataArrayInt *accumulatePerChunck(PyObject *indexArr) const + mcIdType getIJSafe(mcIdType tupleId, mcIdType compoId) const { - int sw,sz,val; - std::vector val2; - const int *bg=convertIntStarLikePyObjToCppIntStar(indexArr,sw,sz,val,val2); - return self->accumulatePerChunck(bg,bg+sz); + return (mcIdType)self->getIJSafe(tupleId,compoId); } - DataArrayInt *findIdsEqualTuple(PyObject *inputTuple) const + std::string __str__() const { - int sw,sz,val; - std::vector val2; - const int *bg(convertIntStarLikePyObjToCppIntStar(inputTuple,sw,sz,val,val2)); - return self->findIdsEqualTuple(bg,bg+sz); + return self->repr(); } - DataArrayInt *findIdForEach(PyObject *vals) const + PyObject *toStrList() const { - int sw,sz,val; - std::vector val2; - const int *bg(convertIntStarLikePyObjToCppIntStar(vals,sw,sz,val,val2)); - MCAuto ret(self->findIdForEach(bg,bg+sz)); - return ret.retn(); + const char *vals=self->getConstPointer(); + std::size_t nbOfComp=self->getNumberOfComponents(); + mcIdType nbOfTuples=self->getNumberOfTuples(); + return convertCharArrToPyListOfTuple(vals,(int)nbOfComp,nbOfTuples); } - PyObject *splitInBalancedSlices(int nbOfSlices) const + bool presenceOfTuple(PyObject *tupl) const { - std::vector< std::pair > slcs(self->splitInBalancedSlices(nbOfSlices)); - PyObject *ret=PyList_New(slcs.size()); - for(std::size_t i=0;i ivval; + const mcIdType *pt=convertIntStarLikePyObjToCppIntStar(tupl,sw,sz,ival,ivval); + std::vector vals(sz); + std::copy(pt,pt+sz,vals.begin()); + return self->presenceOfTuple(vals); } - DataArrayInt *buildExplicitArrOfSliceOnScaledArr(PyObject *slic) const + bool presenceOfValue(PyObject *vals) const { - if(!PySlice_Check(slic)) - throw INTERP_KERNEL::Exception("DataArrayInt::buildExplicitArrOfSliceOnScaledArr (wrap) : expecting a pyslice as second (first) parameter !"); - Py_ssize_t strt=2,stp=2,step=2; - GetIndicesOfSliceExplicitely(slic,&strt,&stp,&step,"DataArrayInt::buildExplicitArrOfSliceOnScaledArr (wrap) : the input slice is invalid !"); - if(strt==std::numeric_limits::max() || stp==std::numeric_limits::max()) - throw INTERP_KERNEL::Exception("DataArrayInt::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); + mcIdType sz=-1,sw=-1; + mcIdType ival=-1; std::vector ivval; + const mcIdType *pt=convertIntStarLikePyObjToCppIntStar(vals,sw,sz,ival,ivval); + std::vector vals2(sz); + std::copy(pt,pt+sz,vals2.begin()); + return self->presenceOfValue(vals2); } - PyObject *getMinMaxValues() const + mcIdType findIdFirstEqual(PyObject *vals) const { - int a,b; - self->getMinMaxValues(a,b); - PyObject *ret=PyTuple_New(2); - PyTuple_SetItem(ret,0,PyInt_FromLong(a)); - PyTuple_SetItem(ret,1,PyInt_FromLong(b)); - return ret; - } - - static PyObject *ConvertIndexArrayToO2N(int nbOfOldTuples, PyObject *arr, PyObject *arrI) - { - int newNbOfTuples=-1; - int szArr,szArrI,sw,iTypppArr,iTypppArrI; - std::vector stdvecTyyppArr,stdvecTyyppArrI; - const int *arrPtr=convertIntStarLikePyObjToCppIntStar(arr,sw,szArr,iTypppArr,stdvecTyyppArr); - const int *arrIPtr=convertIntStarLikePyObjToCppIntStar(arrI,sw,szArrI,iTypppArrI,stdvecTyyppArrI); - DataArrayInt *ret0=MEDCoupling::DataArrayInt::ConvertIndexArrayToO2N(nbOfOldTuples,arrPtr,arrIPtr,arrIPtr+szArrI,newNbOfTuples); - PyObject *ret=PyTuple_New(2); - PyTuple_SetItem(ret,0,SWIG_NewPointerObj((void*)ret0,SWIGTYPE_p_MEDCoupling__DataArrayInt,SWIG_POINTER_OWN | 0)); - PyTuple_SetItem(ret,1,PyInt_FromLong(newNbOfTuples)); - return ret; - } - - static DataArrayInt *CheckAndPreparePermutation(PyObject *arr) - { - MCAuto ret(DataArrayInt::New()); - int szArr,sw,iTypppArr; - std::vector stdvecTyyppArr; - const int *arrPtr(convertIntStarLikePyObjToCppIntStar(arr,sw,szArr,iTypppArr,stdvecTyyppArr)); - int *pt(MEDCoupling::DataArrayInt::CheckAndPreparePermutation(arrPtr,arrPtr+szArr)); - ret->useArray(pt,true,MEDCoupling::DeallocType::C_DEALLOC,szArr,1); - return ret.retn(); - } - - void setValues(PyObject *li, PyObject *nbOfTuples=0, PyObject *nbOfComp=0) - { - const char *msg="MEDCoupling::DataArrayInt::setValues : Available API are : \n-DataArrayInt.setValues([1,3,4])\n-DataArrayInt.setValues([1,3,4],3)\n-DataArrayInt.setValues([1,3,4,5],2,2)\n-DataArrayInt.New(5)\n !"; - if(PyList_Check(li) || PyTuple_Check(li)) - { - if(nbOfTuples && nbOfTuples != Py_None) - { - if(PyInt_Check(nbOfTuples)) - { - int nbOfTuples1=PyInt_AS_LONG(nbOfTuples); - if(nbOfTuples1<0) - throw INTERP_KERNEL::Exception("DataArrayInt::setValue : should be a positive set of allocated memory !"); - if(nbOfComp && nbOfComp != Py_None) - { - if(PyInt_Check(nbOfComp)) - {//DataArrayInt.setValues([1,3,4,5],2,2) - int nbOfCompo=PyInt_AS_LONG(nbOfComp); - if(nbOfCompo<0) - throw INTERP_KERNEL::Exception("DataArrayInt::setValue : should be a positive number of components !"); - std::vector tmp=fillArrayWithPyListInt2(li,nbOfTuples1,nbOfCompo); - self->alloc(nbOfTuples1,nbOfCompo); std::copy(tmp.begin(),tmp.end(),self->getPointer()); - } - else - throw INTERP_KERNEL::Exception(msg); - } - else - {//DataArrayInt.setValues([1,3,4],3) - int tmpp1=-1; - std::vector tmp=fillArrayWithPyListInt2(li,nbOfTuples1,tmpp1); - self->alloc(nbOfTuples1,tmpp1); std::copy(tmp.begin(),tmp.end(),self->getPointer()); - } - } - else - throw INTERP_KERNEL::Exception(msg); - } - else - {// DataArrayInt.setValues([1,3,4]) - int tmpp1=-1,tmpp2=-1; - std::vector tmp=fillArrayWithPyListInt2(li,tmpp1,tmpp2); - self->alloc(tmpp1,tmpp2); std::copy(tmp.begin(),tmp.end(),self->getPointer()); - } - } - else - throw INTERP_KERNEL::Exception(msg); - } - - PyObject *getValues() const - { - const int *vals=self->getConstPointer(); - return convertIntArrToPyList(vals,self->getNbOfElems()); - } - -#ifdef WITH_NUMPY - PyObject *toNumPyArray() // not const. It is not a bug ! - { - return ToNumPyArray(self,NPY_INT32,"DataArrayInt"); - } -#endif - - PyObject *isEqualIfNotWhy(const DataArrayInt& other) const - { - std::string ret1; - bool ret0=self->isEqualIfNotWhy(other,ret1); - PyObject *ret=PyTuple_New(2); - PyObject *ret0Py=ret0?Py_True:Py_False; - Py_XINCREF(ret0Py); - PyTuple_SetItem(ret,0,ret0Py); - PyTuple_SetItem(ret,1,PyString_FromString(ret1.c_str())); - return ret; - } - - PyObject *getValuesAsTuple() const - { - const int *vals=self->getConstPointer(); - int nbOfComp=self->getNumberOfComponents(); - int nbOfTuples=self->getNumberOfTuples(); - return convertIntArrToPyListOfTuple(vals,nbOfComp,nbOfTuples); - } - - static PyObject *MakePartition(PyObject *gps, int newNb) - { - std::vector groups; - std::vector< std::vector > fidsOfGroups; - convertFromPyObjVectorOfObj(gps,SWIGTYPE_p_MEDCoupling__DataArrayInt,"DataArrayInt",groups); - MEDCoupling::DataArrayInt *ret0=MEDCoupling::DataArrayInt::MakePartition(groups,newNb,fidsOfGroups); - PyObject *ret = PyList_New(2); - PyList_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 )); - int sz=fidsOfGroups.size(); - PyObject *ret1 = PyList_New(sz); - for(int i=0;i(da); - self->transformWithIndArr(*m); - } - else - { - int size; - INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); - self->transformWithIndArr(tmp,tmp+size); - } - } - else - { - DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da); - self->transformWithIndArr(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems()); - } - } - - DataArrayInt *findIdsEqualList(PyObject *obj) - { - int sw; - int singleVal; - std::vector multiVal; - std::pair > slic; - MEDCoupling::DataArrayInt *daIntTyypp=0; - convertIntStarOrSliceLikePyObjToCpp(obj,self->getNumberOfTuples(),sw,singleVal,multiVal,slic,daIntTyypp); - switch(sw) - { - case 1: - return self->findIdsEqualList(&singleVal,&singleVal+1); - case 2: - return self->findIdsEqualList(&multiVal[0],&multiVal[0]+multiVal.size()); - case 4: - return self->findIdsEqualList(daIntTyypp->begin(),daIntTyypp->end()); - default: - throw INTERP_KERNEL::Exception("DataArrayInt::findIdsEqualList : unrecognized type entered, expected list of int, tuple of int or DataArrayInt !"); - } - } - - DataArrayInt *findIdsNotEqualList(PyObject *obj) - { - int sw; - int singleVal; - std::vector multiVal; - std::pair > slic; - MEDCoupling::DataArrayInt *daIntTyypp=0; - convertIntStarOrSliceLikePyObjToCpp(obj,self->getNumberOfTuples(),sw,singleVal,multiVal,slic,daIntTyypp); - switch(sw) - { - case 1: - return self->findIdsNotEqualList(&singleVal,&singleVal+1); - case 2: - return self->findIdsNotEqualList(&multiVal[0],&multiVal[0]+multiVal.size()); - case 4: - return self->findIdsNotEqualList(daIntTyypp->begin(),daIntTyypp->end()); - default: - throw INTERP_KERNEL::Exception("DataArrayInt::findIdsNotEqualList : unrecognized type entered, expected list of int, tuple of int or DataArrayInt !"); - } - } - - PyObject *splitByValueRange(PyObject *li) const - { - DataArrayInt *ret0=0,*ret1=0,*ret2=0; - void *da=0; - int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_MEDCoupling__DataArrayInt, 0 | 0 ); - if (!SWIG_IsOK(res1)) - { - int size; - INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); - self->splitByValueRange(tmp,(int *)tmp+size,ret0,ret1,ret2); - } - else - { - DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da); - if(!da2) - throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !"); - da2->checkAllocated(); - self->splitByValueRange(da2->begin(),da2->end(),ret0,ret1,ret2); - } - PyObject *ret = PyList_New(3); - PyList_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 )); - PyList_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 )); - PyList_SetItem(ret,2,SWIG_NewPointerObj(SWIG_as_voidptr(ret2),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 )); - return ret; - } - - DataArrayInt *transformWithIndArrR(PyObject *li) const - { - void *da=0; - int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_MEDCoupling__DataArrayInt, 0 | 0 ); - if (!SWIG_IsOK(res1)) - { - int size; - INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); - return self->transformWithIndArrR(tmp,tmp+size); - } - else - { - DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da); - return self->transformWithIndArrR(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems()); - } - } - - DataArrayInt *renumberAndReduce(PyObject *li, int newNbOfTuple) - { - void *da=0; - int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_MEDCoupling__DataArrayInt, 0 | 0 ); - if (!SWIG_IsOK(res1)) - { - int size; - INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); - if(size!=self->getNumberOfTuples()) - { - throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !"); - } - return self->renumberAndReduce(tmp,newNbOfTuple); - } - else - { - DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da); - if(!da2) - throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !"); - da2->checkAllocated(); - int size=self->getNumberOfTuples(); - if(size!=self->getNumberOfTuples()) - { - throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !"); - } - return self->renumberAndReduce(da2->getConstPointer(),newNbOfTuple); - } - } - - DataArrayInt *renumber(PyObject *li) - { - void *da=0; - int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_MEDCoupling__DataArrayInt, 0 | 0 ); - if (!SWIG_IsOK(res1)) - { - int size; - INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); - if(size!=self->getNumberOfTuples()) - { - throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !"); - } - return self->renumber(tmp); - } - else - { - DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da); - if(!da2) - throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !"); - da2->checkAllocated(); - int size=self->getNumberOfTuples(); - if(size!=self->getNumberOfTuples()) - { - throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !"); - } - return self->renumber(da2->getConstPointer()); - } - } - - DataArrayInt *renumberR(PyObject *li) - { - void *da=0; - int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_MEDCoupling__DataArrayInt, 0 | 0 ); - if (!SWIG_IsOK(res1)) - { - int size; - INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); - if(size!=self->getNumberOfTuples()) - { - throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !"); - } - return self->renumberR(tmp); - } - else - { - DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da); - if(!da2) - throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !"); - da2->checkAllocated(); - int size=self->getNumberOfTuples(); - if(size!=self->getNumberOfTuples()) - { - throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !"); - } - return self->renumberR(da2->getConstPointer()); - } - } - - void setSelectedComponents(const DataArrayInt *a, PyObject *li) - { - std::vector tmp; - convertPyToNewIntArr3(li,tmp); - self->setSelectedComponents(a,tmp); - } - - PyObject *explodeComponents() const - { - std::vector< MCAuto > retCpp(self->explodeComponents()); - std::size_t sz(retCpp.size()); - PyObject *res(PyList_New(sz)); - for(std::size_t i=0;igetNumberOfComponents(); - INTERP_KERNEL::AutoPtr tmp=new int[sz]; - self->getTuple(tupleId,tmp); - return convertIntArrToPyList(tmp,sz); - } - - PyObject *changeSurjectiveFormat(int targetNb) const - { - DataArrayInt *arr=0; - DataArrayInt *arrI=0; - self->changeSurjectiveFormat(targetNb,arr,arrI); - PyObject *res = PyList_New(2); - PyList_SetItem(res,0,SWIG_NewPointerObj((void*)arr,SWIGTYPE_p_MEDCoupling__DataArrayInt,SWIG_POINTER_OWN | 0)); - PyList_SetItem(res,1,SWIG_NewPointerObj((void*)arrI,SWIGTYPE_p_MEDCoupling__DataArrayInt,SWIG_POINTER_OWN | 0)); - return res; - } - - static DataArrayInt *Meld(PyObject *li) - { - std::vector tmp; - convertFromPyObjVectorOfObj(li,SWIGTYPE_p_MEDCoupling__DataArrayInt,"DataArrayInt",tmp); - return DataArrayInt::Meld(tmp); - } - - static DataArrayInt *Aggregate(PyObject *li) - { - std::vector tmp; - convertFromPyObjVectorOfObj(li,SWIGTYPE_p_MEDCoupling__DataArrayInt,"DataArrayInt",tmp); - return DataArrayInt::Aggregate(tmp); - } - - static DataArrayInt *AggregateIndexes(PyObject *li) - { - std::vector tmp; - convertFromPyObjVectorOfObj(li,SWIGTYPE_p_MEDCoupling__DataArrayInt,"DataArrayInt",tmp); - return DataArrayInt::AggregateIndexes(tmp); - } - - static DataArrayInt *BuildUnion(PyObject *li) - { - std::vector tmp; - convertFromPyObjVectorOfObj(li,SWIGTYPE_p_MEDCoupling__DataArrayInt,"DataArrayInt",tmp); - return DataArrayInt::BuildUnion(tmp); - } - - static DataArrayInt *BuildIntersection(PyObject *li) - { - std::vector tmp; - convertFromPyObjVectorOfObj(li,SWIGTYPE_p_MEDCoupling__DataArrayInt,"DataArrayInt",tmp); - return DataArrayInt::BuildIntersection(tmp); - } - - PyObject *getMaxValue() const - { - int tmp; - int r1=self->getMaxValue(tmp); - PyObject *ret=PyTuple_New(2); - PyTuple_SetItem(ret,0,PyInt_FromLong(r1)); - PyTuple_SetItem(ret,1,PyInt_FromLong(tmp)); - return ret; - } - - PyObject *getMaxAbsValue(std::size_t& tupleId) const - { - std::size_t tmp; - int r1=self->getMaxAbsValue(tmp); - PyObject *ret=PyTuple_New(2); - PyTuple_SetItem(ret,0,PyInt_FromLong(r1)); - PyTuple_SetItem(ret,1,PyInt_FromLong(tmp)); - return ret; - } - - PyObject *getMinValue() const - { - int tmp; - int r1=self->getMinValue(tmp); - PyObject *ret=PyTuple_New(2); - PyTuple_SetItem(ret,0,PyInt_FromLong(r1)); - PyTuple_SetItem(ret,1,PyInt_FromLong(tmp)); - return ret; - } - - int index(PyObject *obj) const - { - int nbOfCompo=self->getNumberOfComponents(); - switch(nbOfCompo) - { - case 1: - { - if(PyInt_Check(obj)) - { - int val=(int)PyInt_AS_LONG(obj); - return self->findIdFirstEqual(val); - } - else - throw INTERP_KERNEL::Exception("DataArrayInt::index : 'this' contains one component and trying to find an element which is not an integer !"); - } - default: - { - std::vector arr; - convertPyToNewIntArr3(obj,arr); - return self->findIdFirstEqualTuple(arr); - } - } - } - - bool __contains__(PyObject *obj) const - { - int nbOfCompo=self->getNumberOfComponents(); - switch(nbOfCompo) - { - case 0: - return false; - case 1: - { - if(PyInt_Check(obj)) - { - int val=(int)PyInt_AS_LONG(obj); - return self->presenceOfValue(val); - } - else - throw INTERP_KERNEL::Exception("DataArrayInt::__contains__ : 'this' contains one component and trying to find an element which is not an integer !"); - } - default: - { - std::vector arr; - convertPyToNewIntArr3(obj,arr); - return self->presenceOfTuple(arr); - } - } - } - - PyObject *__getitem__(PyObject *obj) - { - 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(); - int it1,ic1; - std::vector vt1,vc1; - std::pair > pt1,pc1; - DataArrayInt *dt1=0,*dc1=0; - int sw; - convertObjToPossibleCpp3(obj,nbOfTuples,nbOfComponents,sw,it1,ic1,vt1,vc1,pt1,pc1,dt1,dc1); - MCAuto ret; - switch(sw) - { - case 1: - { - if(nbOfComponents==1) - return PyInt_FromLong(self->getIJSafe(it1,0)); - return SWIG_NewPointerObj(SWIG_as_voidptr(self->selectByTupleIdSafe(&it1,&it1+1)),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ); - } - case 2: - return SWIG_NewPointerObj(SWIG_as_voidptr(self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size())),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ); - case 3: - return SWIG_NewPointerObj(SWIG_as_voidptr(self->selectByTupleIdSafeSlice(pt1.first,pt1.second.first,pt1.second.second)),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ); - case 4: - return SWIG_NewPointerObj(SWIG_as_voidptr(self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems())),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ); - case 5: - return PyInt_FromLong(self->getIJSafe(it1,ic1)); - case 6: - { - ret=self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size()); - std::vector v2(1,ic1); - return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ); - } - case 7: - { - ret=self->selectByTupleIdSafeSlice(pt1.first,pt1.second.first,pt1.second.second); - std::vector v2(1,ic1); - return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ); - } - case 8: - { - ret=self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems()); - std::vector v2(1,ic1); - return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ); - } - case 9: - { - ret=self->selectByTupleIdSafe(&it1,&it1+1); - return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(vc1)),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ); - } - case 10: - { - ret=self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size()); - return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(vc1)),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ); - } - case 11: - { - ret=self->selectByTupleIdSafeSlice(pt1.first,pt1.second.first,pt1.second.second); - return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(vc1)),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ); - } - case 12: - { - ret=self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems()); - return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(vc1)),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ); - } - case 13: - { - ret=self->selectByTupleIdSafe(&it1,&it1+1); - int nbOfComp=DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2); - std::vector v2(nbOfComp); - for(int i=0;ikeepSelectedComponents(v2)),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ); - } - case 14: - { - ret=self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size()); - int nbOfComp=DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2); - std::vector v2(nbOfComp); - for(int i=0;ikeepSelectedComponents(v2)),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ); - } - case 15: - { - ret=self->selectByTupleIdSafeSlice(pt1.first,pt1.second.first,pt1.second.second); - int nbOfComp=DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2); - std::vector v2(nbOfComp); - for(int i=0;ikeepSelectedComponents(v2)),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ); - } - case 16: - { - ret=self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems()); - int nbOfComp=DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2); - std::vector v2(nbOfComp); - for(int i=0;ikeepSelectedComponents(v2)),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ); - } - default: - throw INTERP_KERNEL::Exception(msg); - } - } - - DataArrayInt *__setitem__(PyObject *obj, PyObject *value) - { - self->checkAllocated(); - const char msg[]="Unexpected situation in __setitem__ !"; - int nbOfTuples=self->getNumberOfTuples(); - int nbOfComponents=self->getNumberOfComponents(); - int sw1,sw2; - int i1; - std::vector v1; - DataArrayInt *d1=0; - DataArrayIntTuple *dd1=0; - convertIntStarLikePyObjToCpp(value,sw1,i1,v1,d1,dd1); - int it1,ic1; - std::vector vt1,vc1; - std::pair > pt1,pc1; - DataArrayInt *dt1=0,*dc1=0; - convertObjToPossibleCpp3(obj,nbOfTuples,nbOfComponents,sw2,it1,ic1,vt1,vc1,pt1,pc1,dt1,dc1); - MCAuto tmp; - switch(sw2) - { - case 1: - { - switch(sw1) - { - case 1: - self->setPartOfValuesSimple1(i1,it1,it1+1,1,0,nbOfComponents,1); - return self; - case 2: - tmp=DataArrayInt::New(); - tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size()); - self->setPartOfValues1(tmp,it1,it1+1,1,0,nbOfComponents,1,false); - return self; - case 3: - self->setPartOfValues1(d1,it1,it1+1,1,0,nbOfComponents,1); - return self; - case 4: - tmp=dd1->buildDAInt(1,self->getNumberOfComponents()); - self->setPartOfValues1(tmp,it1,it1+1,1,0,nbOfComponents,1); - return self; - default: - throw INTERP_KERNEL::Exception(msg); - } - break; - } - case 2: - { - switch(sw1) - { - case 1: - self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1); - return self; - case 2: - tmp=DataArrayInt::New(); - tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size()); - self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1,false); - return self; - case 3: - self->setPartOfValues3(d1,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1); - return self; - case 4: - tmp=dd1->buildDAInt(1,self->getNumberOfComponents()); - self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1); - return self; - default: - throw INTERP_KERNEL::Exception(msg); - } - break; - } - case 3: - { - switch(sw1) - { - case 1: - self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1); - return self; - case 2: - tmp=DataArrayInt::New(); - tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size()); - self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1,false); - return self; - case 3: - self->setPartOfValues1(d1,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1); - return self; - case 4: - tmp=dd1->buildDAInt(1,self->getNumberOfComponents()); - self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1); - return self; - default: - throw INTERP_KERNEL::Exception(msg); - } - break; - } - case 4: - { - switch(sw1) - { - case 1: - self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1); - return self; - case 2: - tmp=DataArrayInt::New(); - tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size()); - self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1,false); - return self; - case 3: - self->setPartOfValues3(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1); - return self; - case 4: - tmp=dd1->buildDAInt(1,self->getNumberOfComponents()); - self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1); - return self; - default: - throw INTERP_KERNEL::Exception(msg); - } - break; - } - case 5: - { - switch(sw1) - { - case 1: - self->setPartOfValuesSimple1(i1,it1,it1+1,1,ic1,ic1+1,1); - return self; - case 2: - tmp=DataArrayInt::New(); - tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size()); - self->setPartOfValues1(tmp,it1,it1+1,1,ic1,ic1+1,1,false); - return self; - case 3: - self->setPartOfValues1(d1,it1,it1+1,1,ic1,ic1+1,1); - return self; - case 4: - tmp=dd1->buildDAInt(1,self->getNumberOfComponents()); - self->setPartOfValues1(tmp,it1,it1+1,1,ic1,ic1+1,1); - return self; - default: - throw INTERP_KERNEL::Exception(msg); - } - break; - } - case 6: - { - switch(sw1) - { - case 1: - self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1); - return self; - case 2: - tmp=DataArrayInt::New(); - tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size()); - self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1,false); - return self; - case 3: - self->setPartOfValues3(d1,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1); - return self; - case 4: - tmp=dd1->buildDAInt(1,self->getNumberOfComponents()); - self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1); - return self; - default: - throw INTERP_KERNEL::Exception(msg); - } - break; - } - case 7: - { - switch(sw1) - { - case 1: - self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1); - return self; - case 2: - tmp=DataArrayInt::New(); - tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size()); - self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1,false); - return self; - case 3: - self->setPartOfValues1(d1,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1); - return self; - case 4: - tmp=dd1->buildDAInt(1,self->getNumberOfComponents()); - self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1); - return self; - default: - throw INTERP_KERNEL::Exception(msg); - } - break; - } - case 8: - { - switch(sw1) - { - case 1: - self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1); - return self; - case 2: - tmp=DataArrayInt::New(); - tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size()); - self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1,false); - return self; - case 3: - self->setPartOfValues3(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1); - return self; - case 4: - tmp=dd1->buildDAInt(1,self->getNumberOfComponents()); - self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1); - return self; - default: - throw INTERP_KERNEL::Exception(msg); - } - break; - } - case 9: - { - switch(sw1) - { - case 1: - self->setPartOfValuesSimple2(i1,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size()); - return self; - case 2: - tmp=DataArrayInt::New(); - tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size()); - self->setPartOfValues2(tmp,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size(),false); - return self; - case 3: - self->setPartOfValues2(d1,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size()); - return self; - case 4: - tmp=dd1->buildDAInt(1,self->getNumberOfComponents()); - self->setPartOfValues2(tmp,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size()); - return self; - default: - throw INTERP_KERNEL::Exception(msg); - } - break; - } - case 10: - { - switch(sw1) - { - case 1: - self->setPartOfValuesSimple2(i1,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size()); - return self; - case 2: - tmp=DataArrayInt::New(); - tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size()); - self->setPartOfValues2(tmp,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size(),false); - return self; - case 3: - self->setPartOfValues2(d1,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size()); - return self; - case 4: - tmp=dd1->buildDAInt(1,self->getNumberOfComponents()); - self->setPartOfValues2(tmp,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size()); - return self; - default: - throw INTERP_KERNEL::Exception(msg); - } - break; - } - case 11: - { - switch(sw1) - { - case 1: - self->setPartOfValuesSimple4(i1,pt1.first,pt1.second.first,pt1.second.second,&vc1[0],&vc1[0]+vc1.size()); - return self; - case 2: - tmp=DataArrayInt::New(); - tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size()); - self->setPartOfValues4(tmp,pt1.first,pt1.second.first,pt1.second.second,&vc1[0],&vc1[0]+vc1.size(),false); - return self; - case 3: - self->setPartOfValues4(d1,pt1.first,pt1.second.first,pt1.second.second,&vc1[0],&vc1[0]+vc1.size()); - return self; - case 4: - tmp=dd1->buildDAInt(1,self->getNumberOfComponents()); - self->setPartOfValues4(tmp,pt1.first,pt1.second.first,pt1.second.second,&vc1[0],&vc1[0]+vc1.size()); - return self; - default: - throw INTERP_KERNEL::Exception(msg); - } - break; - } - case 12: - { - switch(sw1) - { - case 1: - self->setPartOfValuesSimple2(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size()); - return self; - case 2: - tmp=DataArrayInt::New(); - tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size()); - self->setPartOfValues2(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size(),false); - return self; - case 3: - self->setPartOfValues2(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size()); - return self; - case 4: - tmp=dd1->buildDAInt(1,self->getNumberOfComponents()); - self->setPartOfValues2(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size()); - return self; - default: - throw INTERP_KERNEL::Exception(msg); - } - break; - } - case 13: - { - switch(sw1) - { - case 1: - self->setPartOfValuesSimple1(i1,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second); - return self; - case 2: - tmp=DataArrayInt::New(); - tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size()); - self->setPartOfValues1(tmp,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second,false); - return self; - case 3: - self->setPartOfValues1(d1,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second); - return self; - case 4: - tmp=dd1->buildDAInt(1,self->getNumberOfComponents()); - self->setPartOfValues1(tmp,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second); - return self; - default: - throw INTERP_KERNEL::Exception(msg); - } - break; - } - case 14: - { - switch(sw1) - { - case 1: - self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second); - return self; - case 2: - tmp=DataArrayInt::New(); - tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size()); - self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second,false); - return self; - case 3: - self->setPartOfValues3(d1,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second); - return self; - case 4: - tmp=dd1->buildDAInt(1,self->getNumberOfComponents()); - self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second); - return self; - default: - throw INTERP_KERNEL::Exception(msg); - } - break; - } - case 15: - { - switch(sw1) - { - case 1: - self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second); - return self; - case 2: - tmp=DataArrayInt::New(); - tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size()); - self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second,false); - return self; - case 3: - self->setPartOfValues1(d1,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second); - return self; - case 4: - tmp=dd1->buildDAInt(1,self->getNumberOfComponents()); - self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second); - return self; - default: - throw INTERP_KERNEL::Exception(msg); - } - break; - } - case 16: - { - switch(sw1) - { - case 1: - self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second); - return self; - case 2: - tmp=DataArrayInt::New(); - tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size()); - self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second,false); - return self; - case 3: - self->setPartOfValues3(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second); - return self; - case 4: - tmp=dd1->buildDAInt(1,self->getNumberOfComponents()); - self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second); - return self; - default: - throw INTERP_KERNEL::Exception(msg); - } - break; - } - default: - throw INTERP_KERNEL::Exception(msg); - } - return self; - } - - DataArrayInt *__neg__() const - { - return self->negate(); - } - - DataArrayInt *__add__(PyObject *obj) - { - const char msg[]="Unexpected situation in __add__ !"; - int val; - DataArrayInt *a; - std::vector aa; - DataArrayIntTuple *aaa; - int sw; - convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa); - switch(sw) - { - case 1: - { - MCAuto ret=self->deepCopy(); - ret->applyLin(1,val); - return ret.retn(); - } - case 2: - { - MCAuto aaaa=DataArrayInt::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,(int)aa.size()); - return DataArrayInt::Add(self,aaaa); - } - case 3: - { - return DataArrayInt::Add(self,a); - } - case 4: - { - MCAuto aaaa=aaa->buildDAInt(1,self->getNumberOfComponents()); - return DataArrayInt::Add(self,aaaa); - } - default: - throw INTERP_KERNEL::Exception(msg); - } - } - - DataArrayInt *__radd__(PyObject *obj) - { - const char msg[]="Unexpected situation in __radd__ !"; - int val; - DataArrayInt *a; - std::vector aa; - DataArrayIntTuple *aaa; - int sw; - convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa); - switch(sw) - { - case 1: - { - MCAuto ret=self->deepCopy(); - ret->applyLin(1,val); - return ret.retn(); - } - case 2: - { - MCAuto aaaa=DataArrayInt::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,(int)aa.size()); - return DataArrayInt::Add(self,aaaa); - } - case 4: - { - MCAuto aaaa=aaa->buildDAInt(1,self->getNumberOfComponents()); - return DataArrayInt::Add(self,aaaa); - } - default: - throw INTERP_KERNEL::Exception(msg); - } - } - - PyObject *___iadd___(PyObject *trueSelf, PyObject *obj) - { - const char msg[]="Unexpected situation in __iadd__ !"; - int val; - DataArrayInt *a; - std::vector aa; - DataArrayIntTuple *aaa; - int sw; - convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa); - switch(sw) - { - case 1: - { - self->applyLin(1,val); - Py_XINCREF(trueSelf); - return trueSelf; - } - case 2: - { - MCAuto bb=DataArrayInt::New(); bb->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,(int)aa.size()); - self->addEqual(bb); - Py_XINCREF(trueSelf); - return trueSelf; - } - case 3: - { - self->addEqual(a); - Py_XINCREF(trueSelf); - return trueSelf; - } - case 4: - { - MCAuto aaaa=aaa->buildDAInt(1,self->getNumberOfComponents()); - self->addEqual(aaaa); - Py_XINCREF(trueSelf); - return trueSelf; - } - default: - throw INTERP_KERNEL::Exception(msg); - } - } - - DataArrayInt *__sub__(PyObject *obj) - { - const char msg[]="Unexpected situation in __sub__ !"; - int val; - DataArrayInt *a; - std::vector aa; - DataArrayIntTuple *aaa; - int sw; - convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa); - switch(sw) - { - case 1: - { - MCAuto ret=self->deepCopy(); - ret->applyLin(1,-val); - return ret.retn(); - } - case 2: - { - MCAuto aaaa=DataArrayInt::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,(int)aa.size()); - return DataArrayInt::Substract(self,aaaa); - } - case 3: - { - return DataArrayInt::Substract(self,a); - } - case 4: - { - MCAuto aaaa=aaa->buildDAInt(1,self->getNumberOfComponents()); - return DataArrayInt::Substract(self,aaaa); - } - default: - throw INTERP_KERNEL::Exception(msg); - } - } - - DataArrayInt *__rsub__(PyObject *obj) - { - const char msg[]="Unexpected situation in __rsub__ !"; - int val; - DataArrayInt *a; - std::vector aa; - DataArrayIntTuple *aaa; - int sw; - convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa); - switch(sw) - { - case 1: - { - MCAuto ret=self->deepCopy(); - ret->applyLin(-1,val); - return ret.retn(); - } - case 2: - { - MCAuto aaaa=DataArrayInt::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,(int)aa.size()); - return DataArrayInt::Substract(aaaa,self); - } - case 4: - { - MCAuto aaaa=aaa->buildDAInt(1,self->getNumberOfComponents()); - return DataArrayInt::Substract(aaaa,self); - } - default: - throw INTERP_KERNEL::Exception(msg); - } - } - - PyObject *___isub___(PyObject *trueSelf, PyObject *obj) - { - const char msg[]="Unexpected situation in __isub__ !"; - int val; - DataArrayInt *a; - std::vector aa; - DataArrayIntTuple *aaa; - int sw; - convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa); - switch(sw) - { - case 1: - { - self->applyLin(1,-val); - Py_XINCREF(trueSelf); - return trueSelf; - } - case 2: - { - MCAuto bb=DataArrayInt::New(); bb->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,(int)aa.size()); - self->substractEqual(bb); - Py_XINCREF(trueSelf); - return trueSelf; - } - case 3: - { - self->substractEqual(a); - Py_XINCREF(trueSelf); - return trueSelf; - } - case 4: - { - MCAuto aaaa=aaa->buildDAInt(1,self->getNumberOfComponents()); - self->substractEqual(aaaa); - Py_XINCREF(trueSelf); - return trueSelf; - } - default: - throw INTERP_KERNEL::Exception(msg); - } - } - - DataArrayInt *__mul__(PyObject *obj) - { - const char msg[]="Unexpected situation in __mul__ !"; - int val; - DataArrayInt *a; - std::vector aa; - DataArrayIntTuple *aaa; - int sw; - convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa); - switch(sw) - { - case 1: - { - MCAuto ret=self->deepCopy(); - ret->applyLin(val,0); - return ret.retn(); - } - case 2: - { - MCAuto aaaa=DataArrayInt::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,(int)aa.size()); - return DataArrayInt::Multiply(self,aaaa); - } - case 3: - { - return DataArrayInt::Multiply(self,a); - } - case 4: - { - MCAuto aaaa=aaa->buildDAInt(1,self->getNumberOfComponents()); - return DataArrayInt::Multiply(self,aaaa); - } - default: - throw INTERP_KERNEL::Exception(msg); - } - } - - DataArrayInt *__rmul__(PyObject *obj) - { - const char msg[]="Unexpected situation in __rmul__ !"; - int val; - DataArrayInt *a; - std::vector aa; - DataArrayIntTuple *aaa; - int sw; - convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa); - switch(sw) - { - case 1: - { - MCAuto ret=self->deepCopy(); - ret->applyLin(val,0); - return ret.retn(); - } - case 2: - { - MCAuto aaaa=DataArrayInt::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,(int)aa.size()); - return DataArrayInt::Multiply(self,aaaa); - } - case 4: - { - MCAuto aaaa=aaa->buildDAInt(1,self->getNumberOfComponents()); - return DataArrayInt::Multiply(self,aaaa); - } - default: - throw INTERP_KERNEL::Exception(msg); - } - } - - PyObject *___imul___(PyObject *trueSelf, PyObject *obj) - { - const char msg[]="Unexpected situation in __imul__ !"; - int val; - DataArrayInt *a; - std::vector aa; - DataArrayIntTuple *aaa; - int sw; - convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa); - switch(sw) - { - case 1: - { - self->applyLin(val,0); - Py_XINCREF(trueSelf); - return trueSelf; - } - case 2: - { - MCAuto bb=DataArrayInt::New(); bb->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,(int)aa.size()); - self->multiplyEqual(bb); - Py_XINCREF(trueSelf); - return trueSelf; - } - case 3: - { - self->multiplyEqual(a); - Py_XINCREF(trueSelf); - return trueSelf; - } - case 4: - { - MCAuto aaaa=aaa->buildDAInt(1,self->getNumberOfComponents()); - self->multiplyEqual(aaaa); - Py_XINCREF(trueSelf); - return trueSelf; - } - default: - throw INTERP_KERNEL::Exception(msg); - } - } - - DataArrayInt *__div__(PyObject *obj) - { - const char msg[]="Unexpected situation in __div__ !"; - int val; - DataArrayInt *a; - std::vector aa; - DataArrayIntTuple *aaa; - int sw; - convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa); - switch(sw) - { - case 1: - { - MCAuto ret=self->deepCopy(); - ret->applyDivideBy(val); - return ret.retn(); - } - case 2: - { - MCAuto aaaa=DataArrayInt::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,(int)aa.size()); - return DataArrayInt::Divide(self,aaaa); - } - case 3: - { - return DataArrayInt::Divide(self,a); - } - case 4: - { - MCAuto aaaa=aaa->buildDAInt(1,self->getNumberOfComponents()); - return DataArrayInt::Divide(self,aaaa); - } - default: - throw INTERP_KERNEL::Exception(msg); - } - } - - DataArrayInt *__rdiv__(PyObject *obj) - { - const char msg[]="Unexpected situation in __rdiv__ !"; - int val; - DataArrayInt *a; - std::vector aa; - DataArrayIntTuple *aaa; - int sw; - convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa); - switch(sw) - { - case 1: - { - MCAuto ret=self->deepCopy(); - ret->applyInv(val); - return ret.retn(); - } - case 2: - { - MCAuto aaaa=DataArrayInt::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,(int)aa.size()); - return DataArrayInt::Divide(aaaa,self); - } - case 4: - { - MCAuto aaaa=aaa->buildDAInt(1,self->getNumberOfComponents()); - return DataArrayInt::Divide(aaaa,self); - } - default: - throw INTERP_KERNEL::Exception(msg); - } - } - - PyObject *___idiv___(PyObject *trueSelf, PyObject *obj) - { - const char msg[]="Unexpected situation in __idiv__ !"; - int val; - DataArrayInt *a; - std::vector aa; - DataArrayIntTuple *aaa; - int sw; - convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa); - switch(sw) - { - case 1: - { - self->applyDivideBy(val); - Py_XINCREF(trueSelf); - return trueSelf; - } - case 2: - { - MCAuto bb=DataArrayInt::New(); bb->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,(int)aa.size()); - self->divideEqual(bb); - Py_XINCREF(trueSelf); - return trueSelf; - } - case 3: - { - self->divideEqual(a); - Py_XINCREF(trueSelf); - return trueSelf; - } - case 4: - { - MCAuto aaaa=aaa->buildDAInt(1,self->getNumberOfComponents()); - self->divideEqual(aaaa); - Py_XINCREF(trueSelf); - return trueSelf; - } - default: - throw INTERP_KERNEL::Exception(msg); - } - } - - DataArrayInt *__mod__(PyObject *obj) - { - const char msg[]="Unexpected situation in __mod__ !"; - int val; - DataArrayInt *a; - std::vector aa; - DataArrayIntTuple *aaa; - int sw; - convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa); - switch(sw) - { - case 1: - { - MCAuto ret=self->deepCopy(); - ret->applyModulus(val); - return ret.retn(); - } - case 2: - { - MCAuto aaaa=DataArrayInt::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,(int)aa.size()); - return DataArrayInt::Modulus(self,aaaa); - } - case 3: - { - return DataArrayInt::Modulus(self,a); - } - case 4: - { - MCAuto aaaa=aaa->buildDAInt(1,self->getNumberOfComponents()); - return DataArrayInt::Modulus(self,aaaa); - } - default: - throw INTERP_KERNEL::Exception(msg); - } - } - - DataArrayInt *__rmod__(PyObject *obj) - { - const char msg[]="Unexpected situation in __rmod__ !"; - int val; - DataArrayInt *a; - std::vector aa; - DataArrayIntTuple *aaa; - int sw; - convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa); - switch(sw) - { - case 1: - { - MCAuto ret=self->deepCopy(); - ret->applyRModulus(val); - return ret.retn(); - } - case 2: - { - MCAuto aaaa=DataArrayInt::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,(int)aa.size()); - return DataArrayInt::Modulus(aaaa,self); - } - case 3: - { - return DataArrayInt::Modulus(a,self); - } - case 4: - { - MCAuto aaaa=aaa->buildDAInt(1,self->getNumberOfComponents()); - return DataArrayInt::Modulus(aaaa,self); - } - default: - throw INTERP_KERNEL::Exception(msg); - } - } - - PyObject *___imod___(PyObject *trueSelf, PyObject *obj) - { - const char msg[]="Unexpected situation in __imod__ !"; - int val; - DataArrayInt *a; - std::vector aa; - DataArrayIntTuple *aaa; - int sw; - convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa); - switch(sw) - { - case 1: - { - self->applyModulus(val); - Py_XINCREF(trueSelf); - return trueSelf; - } - case 3: - { - self->modulusEqual(a); - Py_XINCREF(trueSelf); - return trueSelf; - } - case 4: - { - MCAuto aaaa=aaa->buildDAInt(1,self->getNumberOfComponents()); - self->modulusEqual(aaaa); - Py_XINCREF(trueSelf); - return trueSelf; - } - default: - throw INTERP_KERNEL::Exception(msg); - } - } - - DataArrayInt *__pow__(PyObject *obj) - { - const char msg[]="Unexpected situation in __pow__ !"; - int val; - DataArrayInt *a; - std::vector aa; - DataArrayIntTuple *aaa; - int sw; - convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa); - switch(sw) - { - case 1: - { - MCAuto ret=self->deepCopy(); - ret->applyPow(val); - return ret.retn(); - } - case 2: - { - MCAuto aaaa=DataArrayInt::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,(int)aa.size()); - return DataArrayInt::Pow(self,aaaa); - } - case 3: - { - return DataArrayInt::Pow(self,a); - } - case 4: - { - MCAuto aaaa=aaa->buildDAInt(1,self->getNumberOfComponents()); - return DataArrayInt::Pow(self,aaaa); - } - default: - throw INTERP_KERNEL::Exception(msg); - } - } - - DataArrayInt *__rpow__(PyObject *obj) - { - const char msg[]="Unexpected situation in __rpow__ !"; - int val; - DataArrayInt *a; - std::vector aa; - DataArrayIntTuple *aaa; - int sw; - convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa); - switch(sw) - { - case 1: - { - MCAuto ret=self->deepCopy(); - ret->applyRPow(val); - return ret.retn(); - } - case 2: - { - MCAuto aaaa=DataArrayInt::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,(int)aa.size()); - return DataArrayInt::Pow(aaaa,self); - } - case 3: - { - return DataArrayInt::Pow(a,self); - } - case 4: - { - MCAuto aaaa=aaa->buildDAInt(1,self->getNumberOfComponents()); - return DataArrayInt::Pow(aaaa,self); - } - default: - throw INTERP_KERNEL::Exception(msg); - } - } - - PyObject *___ipow___(PyObject *trueSelf, PyObject *obj) - { - const char msg[]="Unexpected situation in __ipow__ !"; - int val; - DataArrayInt *a; - std::vector aa; - DataArrayIntTuple *aaa; - int sw; - convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa); - switch(sw) - { - case 1: - { - self->applyPow(val); - Py_XINCREF(trueSelf); - return trueSelf; - } - case 3: - { - self->powEqual(a); - Py_XINCREF(trueSelf); - return trueSelf; - } - case 4: - { - MCAuto aaaa=aaa->buildDAInt(1,self->getNumberOfComponents()); - self->powEqual(aaaa); - Py_XINCREF(trueSelf); - return trueSelf; - } - default: - throw INTERP_KERNEL::Exception(msg); - } - } - - std::string __repr__() const - { - std::ostringstream oss; - self->reprQuickOverview(oss); - return oss.str(); - } - - void pushBackValsSilent(PyObject *li) - { - int szArr,sw,iTypppArr; - std::vector stdvecTyyppArr; - const int *tmp=convertIntStarLikePyObjToCppIntStar(li,sw,szArr,iTypppArr,stdvecTyyppArr); - self->pushBackValsSilent(tmp,tmp+szArr); - } - - PyObject *partitionByDifferentValues() const - { - std::vector ret1; - std::vector ret0=self->partitionByDifferentValues(ret1); - std::size_t sz=ret0.size(); - PyObject *pyRet=PyTuple_New(2); - PyObject *pyRet0=PyList_New((int)sz); - PyObject *pyRet1=PyList_New((int)sz); - for(std::size_t i=0;ifindIdsRangesInListOfIds(listOfIds,ret0,ret1); - PyObject *pyRet=PyTuple_New(2); - PyTuple_SetItem(pyRet,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 )); - PyTuple_SetItem(pyRet,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 )); - return pyRet; - } - - PyObject *isRange() const - { - int a(0),b(0),c(0); - bool ret(self->isRange(a,b,c)); - PyObject *pyRet=PyTuple_New(2); - PyObject *ret0Py=ret?Py_True:Py_False,*ret1Py(0); - Py_XINCREF(ret0Py); - PyTuple_SetItem(pyRet,0,ret0Py); - if(ret) - ret1Py=PySlice_New(PyInt_FromLong(a),PyInt_FromLong(b),PyInt_FromLong(c)); - else - { - ret1Py=Py_None; - Py_XINCREF(ret1Py); - } - PyTuple_SetItem(pyRet,1,ret1Py); - return pyRet; - } - - static bool RemoveIdsFromIndexedArrays(PyObject *li, DataArrayInt *arr, DataArrayInt *arrIndx, int offsetForRemoval=0) throw(INTERP_KERNEL::Exception) - { - int sw; - int singleVal; - std::vector multiVal; - std::pair > slic; - MEDCoupling::DataArrayInt *daIntTyypp=0; - if(!arrIndx) - throw INTERP_KERNEL::Exception("DataArrayInt::RemoveIdsFromIndexedArrays : null pointer as arrIndex !"); - convertIntStarOrSliceLikePyObjToCpp(li,arrIndx->getNumberOfTuples()-1,sw,singleVal,multiVal,slic,daIntTyypp); - switch(sw) - { - case 1: - return DataArrayInt::RemoveIdsFromIndexedArrays(&singleVal,&singleVal+1,arr,arrIndx,offsetForRemoval); - case 2: - return DataArrayInt::RemoveIdsFromIndexedArrays(&multiVal[0],&multiVal[0]+multiVal.size(),arr,arrIndx,offsetForRemoval); - case 4: - return DataArrayInt::RemoveIdsFromIndexedArrays(daIntTyypp->begin(),daIntTyypp->end(),arr,arrIndx,offsetForRemoval); - default: - throw INTERP_KERNEL::Exception("MEDCouplingUMesh::RemoveIdsFromIndexedArrays : unrecognized type entered, expected list of int, tuple of int or DataArrayInt !"); - } - } - - static PyObject *ExtractFromIndexedArrays(PyObject *li, const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn) throw(INTERP_KERNEL::Exception) - { - DataArrayInt *arrOut=0,*arrIndexOut=0; - int sw; - int singleVal; - std::vector multiVal; - std::pair > slic; - MEDCoupling::DataArrayInt *daIntTyypp=0; - if(!arrIndxIn) - throw INTERP_KERNEL::Exception("DataArrayInt::ExtractFromIndexedArrays : null pointer as arrIndxIn !"); - convertIntStarOrSliceLikePyObjToCpp(li,arrIndxIn->getNumberOfTuples()-1,sw,singleVal,multiVal,slic,daIntTyypp); - switch(sw) - { - case 1: - { - DataArrayInt::ExtractFromIndexedArrays(&singleVal,&singleVal+1,arrIn,arrIndxIn,arrOut,arrIndexOut); - break; - } - case 2: - { - DataArrayInt::ExtractFromIndexedArrays(&multiVal[0],&multiVal[0]+multiVal.size(),arrIn,arrIndxIn,arrOut,arrIndexOut); - break; - } - case 4: - { - DataArrayInt::ExtractFromIndexedArrays(daIntTyypp->begin(),daIntTyypp->end(),arrIn,arrIndxIn,arrOut,arrIndexOut); - break; - } - default: - throw INTERP_KERNEL::Exception("DataArrayInt::ExtractFromIndexedArrays : unrecognized type entered, expected list of int, tuple of int or DataArrayInt !"); - } - PyObject *ret=PyTuple_New(2); - PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(arrOut),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 )); - PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(arrIndexOut),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 )); - return ret; - } - - static PyObject *ExtractFromIndexedArraysSlice(int strt, int stp, int step, const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn) throw(INTERP_KERNEL::Exception) - { - DataArrayInt *arrOut=0,*arrIndexOut=0; - DataArrayInt::ExtractFromIndexedArraysSlice(strt,stp,step,arrIn,arrIndxIn,arrOut,arrIndexOut); - PyObject *ret=PyTuple_New(2); - PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(arrOut),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 )); - PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(arrIndexOut),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 )); - return ret; - } - - static PyObject *ExtractFromIndexedArraysSlice(PyObject *slic, const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn) throw(INTERP_KERNEL::Exception) - { - if(!PySlice_Check(slic)) - throw INTERP_KERNEL::Exception("ExtractFromIndexedArraysSlice (wrap) : the first param is not a pyslice !"); - Py_ssize_t strt=2,stp=2,step=2; - if(!arrIndxIn) - throw INTERP_KERNEL::Exception("ExtractFromIndexedArraysSlice (wrap) : last array is null !"); - arrIndxIn->checkAllocated(); - if(arrIndxIn->getNumberOfComponents()!=1) - throw INTERP_KERNEL::Exception("ExtractFromIndexedArraysSlice (wrap) : number of components of last argument must be equal to one !"); - GetIndicesOfSlice(slic,arrIndxIn->getNumberOfTuples(),&strt,&stp,&step,"ExtractFromIndexedArraysSlice (wrap) : Invalid slice regarding nb of elements !"); - DataArrayInt *arrOut=0,*arrIndexOut=0; - DataArrayInt::ExtractFromIndexedArraysSlice(strt,stp,step,arrIn,arrIndxIn,arrOut,arrIndexOut); - PyObject *ret=PyTuple_New(2); - PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(arrOut),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 )); - PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(arrIndexOut),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 )); - return ret; - } - - static PyObject *SetPartOfIndexedArrays(PyObject *li, - const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn, - const DataArrayInt *srcArr, const DataArrayInt *srcArrIndex) throw(INTERP_KERNEL::Exception) - { - DataArrayInt *arrOut=0,*arrIndexOut=0; - int sw; - int singleVal; - std::vector multiVal; - std::pair > slic; - MEDCoupling::DataArrayInt *daIntTyypp=0; - if(!arrIndxIn) - throw INTERP_KERNEL::Exception("DataArrayInt::SetPartOfIndexedArrays : null pointer as arrIndex !"); - convertIntStarOrSliceLikePyObjToCpp(li,arrIndxIn->getNumberOfTuples()-1,sw,singleVal,multiVal,slic,daIntTyypp); - switch(sw) - { - case 1: - { - DataArrayInt::SetPartOfIndexedArrays(&singleVal,&singleVal+1,arrIn,arrIndxIn,srcArr,srcArrIndex,arrOut,arrIndexOut); - break; - } - case 2: - { - DataArrayInt::SetPartOfIndexedArrays(&multiVal[0],&multiVal[0]+multiVal.size(),arrIn,arrIndxIn,srcArr,srcArrIndex,arrOut,arrIndexOut); - break; - } - case 4: - { - DataArrayInt::SetPartOfIndexedArrays(daIntTyypp->begin(),daIntTyypp->end(),arrIn,arrIndxIn,srcArr,srcArrIndex,arrOut,arrIndexOut); - break; - } - default: - throw INTERP_KERNEL::Exception("DataArrayInt::SetPartOfIndexedArrays : unrecognized type entered, expected list of int, tuple of int or DataArrayInt !"); - } - PyObject *ret=PyTuple_New(2); - PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(arrOut),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 )); - PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(arrIndexOut),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 )); - return ret; - } - - static void SetPartOfIndexedArraysSameIdx(PyObject *li, DataArrayInt *arrIn, const DataArrayInt *arrIndxIn, - const DataArrayInt *srcArr, const DataArrayInt *srcArrIndex) throw(INTERP_KERNEL::Exception) - { - int sw; - int singleVal; - std::vector multiVal; - std::pair > slic; - MEDCoupling::DataArrayInt *daIntTyypp=0; - if(!arrIndxIn) - throw INTERP_KERNEL::Exception("DataArrayInt::SetPartOfIndexedArraysSameIdx : null pointer as arrIndex !"); - convertIntStarOrSliceLikePyObjToCpp(li,arrIndxIn->getNumberOfTuples()-1,sw,singleVal,multiVal,slic,daIntTyypp); - switch(sw) - { - case 1: - { - DataArrayInt::SetPartOfIndexedArraysSameIdx(&singleVal,&singleVal+1,arrIn,arrIndxIn,srcArr,srcArrIndex); - break; - } - case 2: - { - DataArrayInt::SetPartOfIndexedArraysSameIdx(&multiVal[0],&multiVal[0]+multiVal.size(),arrIn,arrIndxIn,srcArr,srcArrIndex); - break; - } - case 4: - { - DataArrayInt::SetPartOfIndexedArraysSameIdx(daIntTyypp->begin(),daIntTyypp->end(),arrIn,arrIndxIn,srcArr,srcArrIndex); - break; - } - default: - throw INTERP_KERNEL::Exception("DataArrayInt::SetPartOfIndexedArraysSameIdx : unrecognized type entered, expected list of int, tuple of int or DataArrayInt !"); - } - } - - } // end extent - }; - - class DataArrayIntTuple; - - class DataArrayIntIterator - { - public: - DataArrayIntIterator(DataArrayInt *da); - ~DataArrayIntIterator(); - %extend - { - PyObject *next() - { - DataArrayIntTuple *ret=self->nextt(); - if(ret) - return SWIG_NewPointerObj(SWIG_as_voidptr(ret),SWIGTYPE_p_MEDCoupling__DataArrayIntTuple,SWIG_POINTER_OWN | 0); - else - { - PyErr_SetString(PyExc_StopIteration,"No more data."); - return 0; - } - } - } - }; - - class DataArrayIntTuple - { - public: - int getNumberOfCompo() const; - DataArrayInt *buildDAInt(int nbOfTuples, int nbOfCompo) const; - %extend - { - std::string __str__() const - { - return self->repr(); - } - - int __int__() const - { - return self->intValue(); - } - - DataArrayInt *buildDAInt() - { - return self->buildDAInt(1,self->getNumberOfCompo()); - } - - PyObject *___iadd___(PyObject *trueSelf, PyObject *obj) - { - MCAuto ret=self->buildDAInt(1,self->getNumberOfCompo()); - MEDCoupling_DataArrayInt____iadd___(ret,0,obj); - Py_XINCREF(trueSelf); - return trueSelf; - } - - PyObject *___isub___(PyObject *trueSelf, PyObject *obj) - { - MCAuto ret=self->buildDAInt(1,self->getNumberOfCompo()); - MEDCoupling_DataArrayInt____isub___(ret,0,obj); - Py_XINCREF(trueSelf); - return trueSelf; - } - - PyObject *___imul___(PyObject *trueSelf, PyObject *obj) - { - MCAuto ret=self->buildDAInt(1,self->getNumberOfCompo()); - MEDCoupling_DataArrayInt____imul___(ret,0,obj); - Py_XINCREF(trueSelf); - return trueSelf; - } - PyObject *___idiv___(PyObject *trueSelf, PyObject *obj) - { - MCAuto ret=self->buildDAInt(1,self->getNumberOfCompo()); - MEDCoupling_DataArrayInt____idiv___(ret,0,obj); - Py_XINCREF(trueSelf); - return trueSelf; - } - - PyObject *___imod___(PyObject *trueSelf, PyObject *obj) - { - MCAuto ret=self->buildDAInt(1,self->getNumberOfCompo()); - MEDCoupling_DataArrayInt____imod___(ret,0,obj); - Py_XINCREF(trueSelf); - return trueSelf; - } - - PyObject *__len__() - { - return PyInt_FromLong(self->getNumberOfCompo()); - } - - PyObject *__getitem__(PyObject *obj) - { - const char msg2[]="DataArrayIntTuple::__getitem__ : Mismatch of slice values in 2nd parameter (components) !"; - int sw; - int singleVal; - std::vector multiVal; - std::pair > slic; - MEDCoupling::DataArrayInt *daIntTyypp=0; - const int *pt=self->getConstPointer(); - int nbc=self->getNumberOfCompo(); - convertIntStarOrSliceLikePyObjToCppWithNegIntInterp(obj,nbc,sw,singleVal,multiVal,slic,daIntTyypp); - switch(sw) - { - case 1: - { - if(singleVal>=nbc) - { - std::ostringstream oss; - oss << "Requesting for id " << singleVal << " having only " << nbc << " components !"; - PyErr_SetString(PyExc_StopIteration,oss.str().c_str()); - return 0; - } - if(singleVal>=0) - return PyInt_FromLong(pt[singleVal]); - else - { - if(nbc+singleVal>0) - return PyInt_FromLong(pt[nbc+singleVal]); - else - { - std::ostringstream oss; - oss << "Requesting for id " << singleVal << " having only " << nbc << " components !"; - throw INTERP_KERNEL::Exception(oss.str().c_str()); - } - } - } - case 2: - { - PyObject *t=PyTuple_New(multiVal.size()); - for(int j=0;j<(int)multiVal.size();j++) - { - int cid=multiVal[j]; - if(cid>=nbc) - { - std::ostringstream oss; - oss << "Requesting for id #" << cid << " having only " << nbc << " components !"; - throw INTERP_KERNEL::Exception(oss.str().c_str()); - } - PyTuple_SetItem(t,j,PyInt_FromLong(pt[cid])); - } - return t; - } - case 3: - { - int 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::DataArrayIntTuple *daIntTyyppV=0; - int nbc=self->getNumberOfCompo(); - convertObjToPossibleCpp22(value,nbc,sw1,singleValV,multiValV,slicV,daIntTyyppV); - int singleVal; - std::vector multiVal; - std::pair > slic; - MEDCoupling::DataArrayInt *daIntTyypp=0; - int *pt=self->getPointer(); - convertIntStarOrSliceLikePyObjToCppWithNegIntInterp(obj,nbc,sw2,singleVal,multiVal,slic,daIntTyypp); - switch(sw2) - { - case 1: - { - if(singleVal>=nbc) - { - std::ostringstream oss; - oss << "Requesting for setting id # " << singleVal << " having only " << nbc << " components !"; - throw INTERP_KERNEL::Exception(oss.str().c_str()); - } - switch(sw1) - { - case 1: - { - pt[singleVal]=singleValV; - return self; - } - case 2: - { - if(multiValV.size()!=1) - { - std::ostringstream oss; - 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]; - return self; - } - case 4: - { - pt[singleVal]=daIntTyyppV->getConstPointer()[0]; - return self; - } - default: - throw INTERP_KERNEL::Exception(msg); - } - } - case 2: - { - switch(sw1) - { - case 1: - { - for(std::vector::const_iterator it=multiVal.begin();it!=multiVal.end();it++) - { - if(*it>=nbc) - { - std::ostringstream oss; - oss << "Requesting for setting id # " << *it << " having only " << nbc << " components !"; - throw INTERP_KERNEL::Exception(oss.str().c_str()); - } - pt[*it]=singleValV; - } - return self; - } - case 2: - { - if(multiVal.size()!=multiValV.size()) - { - std::ostringstream oss; - oss << "Mismatch length of during assignment : " << multiValV.size() << " != " << multiVal.size() << " !"; - throw INTERP_KERNEL::Exception(oss.str().c_str()); - } - for(int i=0;i<(int)multiVal.size();i++) - { - int pos=multiVal[i]; - if(pos>=nbc) - { - std::ostringstream oss; - oss << "Requesting for setting id # " << pos << " having only " << nbc << " components !"; - throw INTERP_KERNEL::Exception(oss.str().c_str()); - } - pt[multiVal[i]]=multiValV[i]; - } - return self; - } - case 4: - { - const int *ptV=daIntTyyppV->getConstPointer(); - if(nbc>daIntTyyppV->getNumberOfCompo()) - { - std::ostringstream oss; - oss << "Mismatch length of during assignment : " << nbc << " != " << daIntTyyppV->getNumberOfCompo() << " !"; - throw INTERP_KERNEL::Exception(oss.str().c_str()); - } - std::copy(ptV,ptV+nbc,pt); - return self; - } - default: - throw INTERP_KERNEL::Exception(msg); - } - } - case 3: - { - int sz=DataArray::GetNumberOfItemGivenBES(slic.first,slic.second.first,slic.second.second,msg2); - switch(sw1) - { - case 1: - { - for(int j=0;jgetConstPointer(); - 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& tupl) const; - bool presenceOfTuple(const std::vector& tupl) const; - char getMaxValue(int& tupleId) const; - char getMaxValueInArray() const; - char getMinValue(int& tupleId) const; - char getMinValueInArray() const; - DataArrayInt *findIdsInRange(char vmin, char vmax) const; - static DataArrayChar *Aggregate(const DataArrayChar *a1, const DataArrayChar *a2); - static DataArrayChar *Meld(const DataArrayChar *a1, const DataArrayChar *a2); - %extend - { - int __len__() const - { - if(self->isAllocated()) - { - return self->getNumberOfTuples(); - } - else - { - throw INTERP_KERNEL::Exception("DataArrayChar::__len__ : Instance is NOT allocated !"); - } - } - - PyObject *isEqualIfNotWhy(const DataArrayChar& other) const - { - std::string ret1; - bool ret0=self->isEqualIfNotWhy(other,ret1); - PyObject *ret=PyTuple_New(2); - PyObject *ret0Py=ret0?Py_True:Py_False; - Py_XINCREF(ret0Py); - PyTuple_SetItem(ret,0,ret0Py); - PyTuple_SetItem(ret,1,PyString_FromString(ret1.c_str())); - return ret; - } - - DataArrayChar *renumber(PyObject *li) - { - void *da=0; - int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_MEDCoupling__DataArrayInt, 0 | 0 ); - if (!SWIG_IsOK(res1)) - { - int size; - INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); - if(size!=self->getNumberOfTuples()) - { - throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !"); - } - return self->renumber(tmp); - } - else - { - DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da); - if(!da2) - throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !"); - da2->checkAllocated(); - int size=self->getNumberOfTuples(); - if(size!=self->getNumberOfTuples()) - { - throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !"); - } - return self->renumber(da2->getConstPointer()); - } - } - - DataArrayChar *renumberR(PyObject *li) - { - void *da=0; - int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_MEDCoupling__DataArrayInt, 0 | 0 ); - if (!SWIG_IsOK(res1)) - { - int size; - INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); - if(size!=self->getNumberOfTuples()) - { - throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !"); - } - return self->renumberR(tmp); - } - else - { - DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da); - if(!da2) - throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !"); - da2->checkAllocated(); - int size=self->getNumberOfTuples(); - if(size!=self->getNumberOfTuples()) - { - throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !"); - } - return self->renumberR(da2->getConstPointer()); - } - } - - DataArrayChar *renumberAndReduce(PyObject *li, int newNbOfTuple) - { - void *da=0; - int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_MEDCoupling__DataArrayInt, 0 | 0 ); - if (!SWIG_IsOK(res1)) - { - int size; - INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); - if(size!=self->getNumberOfTuples()) - { - throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !"); - } - return self->renumberAndReduce(tmp,newNbOfTuple); - } - else - { - DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da); - if(!da2) - throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !"); - da2->checkAllocated(); - int size=self->getNumberOfTuples(); - if(size!=self->getNumberOfTuples()) - { - throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !"); - } - return self->renumberAndReduce(da2->getConstPointer(),newNbOfTuple); - } - } - - static DataArrayChar *Aggregate(PyObject *dachs) - { - std::vector tmp; - convertFromPyObjVectorOfObj(dachs,SWIGTYPE_p_MEDCoupling__DataArrayChar,"DataArrayChar",tmp); - return DataArrayChar::Aggregate(tmp); - } - - static DataArrayChar *Meld(PyObject *dachs) - { - std::vector tmp; - convertFromPyObjVectorOfObj(dachs,SWIGTYPE_p_MEDCoupling__DataArrayChar,"DataArrayChar",tmp); - return DataArrayChar::Meld(tmp); - } - } - }; - - class DataArrayByteIterator; - - class DataArrayByte : public DataArrayChar - { - public: - static DataArrayByte *New(); - DataArrayByteIterator *iterator(); - DataArrayByte *performCopyOrIncrRef(bool deepCopy) const; - char byteValue() const; - %extend - { - DataArrayByte() - { - return DataArrayByte::New(); - } - - static DataArrayByte *New(PyObject *elt0, PyObject *nbOfTuples=0, PyObject *nbOfComp=0) - { - const char *msg="MEDCoupling::DataArrayByte::New : Available API are : \n-DataArrayByte.New()\n--DataArrayByte.New([1,3,4])\n-DataArrayByte.New([1,3,4],3)\n-DataArrayByte.New([1,3,4,5],2,2)\n-DataArrayByte.New(5)\n-DataArrayByte.New(5,2) !"; - if(PyList_Check(elt0) || PyTuple_Check(elt0)) - { - if(nbOfTuples) - { - if(PyInt_Check(nbOfTuples)) - { - int nbOfTuples1=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) - int nbOfCompo=PyInt_AS_LONG(nbOfComp); - if(nbOfCompo<0) - throw INTERP_KERNEL::Exception("DataArrayByte::New : should be a positive number of components !"); - MCAuto ret=DataArrayByte::New(); - std::vector tmp=fillArrayWithPyListInt2(elt0,nbOfTuples1,nbOfCompo); - ret->alloc(nbOfTuples1,nbOfCompo); std::copy(tmp.begin(),tmp.end(),ret->getPointer()); - return ret.retn(); - } - else - throw INTERP_KERNEL::Exception(msg); - } - else - {//DataArrayByte.New([1,3,4],3) - MCAuto ret=DataArrayByte::New(); - int tmpp1=-1; - std::vector tmp=fillArrayWithPyListInt2(elt0,nbOfTuples1,tmpp1); - ret->alloc(nbOfTuples1,tmpp1); std::copy(tmp.begin(),tmp.end(),ret->getPointer()); - return ret.retn(); - } - } - else - throw INTERP_KERNEL::Exception(msg); - } - else - {// DataArrayByte.New([1,3,4]) - MCAuto ret=DataArrayByte::New(); - int tmpp1=-1,tmpp2=-1; - std::vector tmp=fillArrayWithPyListInt2(elt0,tmpp1,tmpp2); - ret->alloc(tmpp1,tmpp2); std::copy(tmp.begin(),tmp.end(),ret->getPointer()); - return ret.retn(); - } - } - else if(PyInt_Check(elt0)) - { - int nbOfTuples1=PyInt_AS_LONG(elt0); - if(nbOfTuples1<0) - throw INTERP_KERNEL::Exception("DataArrayByte::New : should be a positive set of allocated memory !"); - if(nbOfTuples) - { - if(!nbOfComp) - { - if(PyInt_Check(nbOfTuples)) - {//DataArrayByte.New(5,2) - int nbOfCompo=PyInt_AS_LONG(nbOfTuples); - if(nbOfCompo<0) - throw INTERP_KERNEL::Exception("DataArrayByte::New : should be a positive number of components !"); - MCAuto ret=DataArrayByte::New(); - ret->alloc(nbOfTuples1,nbOfCompo); - return ret.retn(); - } - else - throw INTERP_KERNEL::Exception(msg); - } - else - throw INTERP_KERNEL::Exception(msg); - } - else - {//DataArrayByte.New(5) - MCAuto ret=DataArrayByte::New(); - ret->alloc(nbOfTuples1,1); - return ret.retn(); - } - } -#ifdef WITH_NUMPY - else if(PyArray_Check(elt0) && nbOfTuples==NULL && nbOfComp==NULL) - {//DataArrayDouble.New(numpyArray) - return BuildNewInstance(elt0,NPY_INT8,&PyCallBackDataArrayChar_RefType,"INT8"); - } -#endif - else - throw INTERP_KERNEL::Exception(msg); - } - - DataArrayByte(PyObject *elt0, PyObject *nbOfTuples=0, PyObject *nbOfComp=0) - { - return MEDCoupling_DataArrayByte_New__SWIG_1(elt0,nbOfTuples,nbOfComp); - } - - std::string __repr__() const - { - std::ostringstream oss; - self->reprQuickOverview(oss); - return oss.str(); - } - - int __int__() const - { - return (int) self->byteValue(); - } - - DataArrayByteIterator *__iter__() - { - return self->iterator(); - } - - int getIJ(int tupleId, int compoId) const - { - return (int)self->getIJ(tupleId,compoId); - } - - int getIJSafe(int tupleId, int compoId) const - { - return (int)self->getIJSafe(tupleId,compoId); - } - - std::string __str__() const - { - return self->repr(); - } - - PyObject *toStrList() const - { - const char *vals=self->getConstPointer(); - int nbOfComp=self->getNumberOfComponents(); - int nbOfTuples=self->getNumberOfTuples(); - return convertCharArrToPyListOfTuple(vals,nbOfComp,nbOfTuples); - } - - bool presenceOfTuple(PyObject *tupl) const - { - int sz=-1,sw=-1; - int ival=-1; std::vector ivval; - const int *pt=convertIntStarLikePyObjToCppIntStar(tupl,sw,sz,ival,ivval); - std::vector vals(sz); - std::copy(pt,pt+sz,vals.begin()); - return self->presenceOfTuple(vals); - } - - bool presenceOfValue(PyObject *vals) const - { - int sz=-1,sw=-1; - int ival=-1; std::vector ivval; - const int *pt=convertIntStarLikePyObjToCppIntStar(vals,sw,sz,ival,ivval); - std::vector vals2(sz); - std::copy(pt,pt+sz,vals2.begin()); - return self->presenceOfValue(vals2); - } - - int findIdFirstEqual(PyObject *vals) const - { - int sz=-1,sw=-1; - int ival=-1; std::vector ivval; - const int *pt=convertIntStarLikePyObjToCppIntStar(vals,sw,sz,ival,ivval); + mcIdType sz=-1,sw=-1; + mcIdType ival=-1; std::vector ivval; + const mcIdType *pt=convertIntStarLikePyObjToCppIntStar(vals,sw,sz,ival,ivval); std::vector vals2(sz); std::copy(pt,pt+sz,vals2.begin()); return self->findIdFirstEqual(vals2); } - int findIdFirstEqualTuple(PyObject *tupl) const + mcIdType findIdFirstEqualTuple(PyObject *tupl) const { - int sz=-1,sw=-1; - int ival=-1; std::vector ivval; - const int *pt=convertIntStarLikePyObjToCppIntStar(tupl,sw,sz,ival,ivval); + mcIdType sz=-1,sw=-1; + mcIdType ival=-1; std::vector ivval; + const mcIdType *pt=convertIntStarLikePyObjToCppIntStar(tupl,sw,sz,ival,ivval); std::vector vals(sz); std::copy(pt,pt+sz,vals.begin()); return self->findIdFirstEqualTuple(vals); } - int findIdSequence(PyObject *strOrListOfInt) const + mcIdType findIdSequence(PyObject *strOrListOfInt) const { - int sz=-1,sw=-1; - int ival=-1; std::vector ivval; - const int *pt=convertIntStarLikePyObjToCppIntStar(strOrListOfInt,sw,sz,ival,ivval); + mcIdType sz=-1,sw=-1; + mcIdType ival=-1; std::vector ivval; + const mcIdType *pt=convertIntStarLikePyObjToCppIntStar(strOrListOfInt,sw,sz,ival,ivval); std::vector vals(sz); std::copy(pt,pt+sz,vals.begin()); return self->findIdSequence(vals); } - PyObject *getTuple(int tupleId) + PyObject *getTuple(mcIdType tupleId) { - int 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(int i=0;igetMaxValue(tmp); + mcIdType tmp; + mcIdType r1=(mcIdType)self->getMaxValue(tmp); PyObject *ret=PyTuple_New(2); PyTuple_SetItem(ret,0,PyInt_FromLong(r1)); PyTuple_SetItem(ret,1,PyInt_FromLong(tmp)); @@ -5192,24 +2784,24 @@ namespace MEDCoupling PyObject *getMinValue() const { - int tmp; - int r1=(int)self->getMinValue(tmp); + mcIdType tmp; + mcIdType r1=(mcIdType)self->getMinValue(tmp); PyObject *ret=PyTuple_New(2); PyTuple_SetItem(ret,0,PyInt_FromLong(r1)); PyTuple_SetItem(ret,1,PyInt_FromLong(tmp)); return ret; } - int index(PyObject *obj) const + mcIdType index(PyObject *obj) const { - int nbOfCompo=self->getNumberOfComponents(); + std::size_t nbOfCompo=self->getNumberOfComponents(); switch(nbOfCompo) { case 1: { if(PyInt_Check(obj)) { - int val=(int)PyInt_AS_LONG(obj); + char val=(char)PyInt_AS_LONG(obj); return self->findIdFirstEqual(val); } else @@ -5222,7 +2814,7 @@ namespace MEDCoupling bool __contains__(PyObject *obj) const { - int nbOfCompo=self->getNumberOfComponents(); + std::size_t nbOfCompo=self->getNumberOfComponents(); switch(nbOfCompo) { case 0: @@ -5231,7 +2823,7 @@ namespace MEDCoupling { if(PyInt_Check(obj)) { - int val=(int)PyInt_AS_LONG(obj); + char val=(char)PyInt_AS_LONG(obj); return self->presenceOfValue(val); } else @@ -5241,7 +2833,7 @@ namespace MEDCoupling return MEDCoupling_DataArrayByte_presenceOfTuple(self,obj); } } - + #ifdef WITH_NUMPY PyObject *toNumPyArray() // not const. It is not a bug ! { @@ -5253,19 +2845,21 @@ namespace MEDCoupling { self->checkAllocated(); const char msg[]="Unexpected situation in __setitem__ !"; - int nbOfTuples(self->getNumberOfTuples()),nbOfComponents(self->getNumberOfComponents()); - int sw1,sw2; - int i1; + mcIdType nbOfTuples(self->getNumberOfTuples()); + int nbOfComponents((int)self->getNumberOfComponents()); + mcIdType sw1,sw2; + int int1; std::vector v1; - DataArrayInt *d1=0; + DataArrayIdType *d1=0; DataArrayIntTuple *dd1=0; - convertIntStarLikePyObjToCpp(value,sw1,i1,v1,d1,dd1); - int it1,ic1; - std::vector vt1,vc1; - std::pair > pt1,pc1; - DataArrayInt *dt1=0,*dc1=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; + MCAuto tmp; + char i1 = (char)int1; switch(sw2) { case 1: @@ -5481,28 +3075,28 @@ namespace MEDCoupling { public: std::string repr() const; - DataArrayByte *buildDAByte(int nbOfTuples, int nbOfCompo) const; + DataArrayByte *buildDAByte(mcIdType nbOfTuples, mcIdType nbOfCompo) const; %extend { std::string __str__() const { return self->repr(); } - + char __int__() const { return self->byteValue(); } - + DataArrayByte *buildDAByte() { return self->buildDAByte(1,self->getNumberOfCompo()); } } }; - + class DataArrayAsciiCharIterator; - + class DataArrayAsciiChar : public DataArrayChar { public: @@ -5526,18 +3120,18 @@ namespace MEDCoupling { if(PyInt_Check(nbOfTuples)) { - int 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) - int 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(); - std::vector tmp=fillArrayWithPyListInt2(elt0,nbOfTuples1,nbOfCompo); + std::vector tmp=fillArrayWithPyListInt2(elt0,nbOfTuples1,nbOfCompo); ret->alloc(nbOfTuples1,nbOfCompo); std::copy(tmp.begin(),tmp.end(),ret->getPointer()); return ret.retn(); } @@ -5547,8 +3141,8 @@ namespace MEDCoupling else {//DataArrayAsciiChar.New([1,3,4],3) MCAuto ret=DataArrayAsciiChar::New(); - int tmpp1=-1; - std::vector tmp=fillArrayWithPyListInt2(elt0,nbOfTuples1,tmpp1); + mcIdType tmpp1=-1; + std::vector tmp=fillArrayWithPyListInt2(elt0,nbOfTuples1,tmpp1); ret->alloc(nbOfTuples1,tmpp1); std::copy(tmp.begin(),tmp.end(),ret->getPointer()); return ret.retn(); } @@ -5590,8 +3184,8 @@ namespace MEDCoupling { // DataArrayAsciiChar.New([1,3,4]) MCAuto ret=DataArrayAsciiChar::New(); - int tmpp1=-1,tmpp2=-1; - std::vector tmp=fillArrayWithPyListInt2(elt0,tmpp1,tmpp2); + mcIdType tmpp1=-1,tmpp2=-1; + std::vector tmp=fillArrayWithPyListInt2(elt0,tmpp1,tmpp2); ret->alloc(tmpp1,tmpp2); std::copy(tmp.begin(),tmp.end(),ret->getPointer()); return ret.retn(); } @@ -5599,7 +3193,7 @@ namespace MEDCoupling } else if(PyInt_Check(elt0)) { - int 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) @@ -5608,7 +3202,7 @@ namespace MEDCoupling { if(PyInt_Check(nbOfTuples)) {//DataArrayAsciiChar.New(5,2) - int 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(); @@ -5649,14 +3243,14 @@ namespace MEDCoupling return self->iterator(); } - std::string getIJ(int tupleId, int compoId) const + std::string getIJ(mcIdType tupleId, mcIdType compoId) const { char tmp[2]; tmp[1]='\0'; tmp[0]=self->getIJ(tupleId,compoId); return std::string(tmp); } - - std::string getIJSafe(int tupleId, int compoId) const + + std::string getIJSafe(mcIdType tupleId, mcIdType compoId) const { char tmp[2]; tmp[1]='\0'; tmp[0]=self->getIJSafe(tupleId,compoId); @@ -5671,9 +3265,9 @@ namespace MEDCoupling PyObject *toStrList() const { const char *vals=self->getConstPointer(); - int nbOfComp=self->getNumberOfComponents(); - int nbOfTuples=self->getNumberOfTuples(); - return convertCharArrToPyListOfTuple(vals,nbOfComp,nbOfTuples); + std::size_t nbOfComp=self->getNumberOfComponents(); + mcIdType nbOfTuples=self->getNumberOfTuples(); + return convertCharArrToPyListOfTuple(vals,(int)nbOfComp,nbOfTuples); } bool presenceOfTuple(PyObject *tupl) const @@ -5697,7 +3291,7 @@ namespace MEDCoupling else throw INTERP_KERNEL::Exception("DataArrayAsciiChar::presenceOfTuple : only strings in input supported !"); } - + bool presenceOfValue(PyObject *vals) const { if(PyString_Check(vals)) @@ -5720,7 +3314,7 @@ namespace MEDCoupling throw INTERP_KERNEL::Exception("DataArrayAsciiChar::presenceOfValue : only strings in input supported !"); } - int findIdFirstEqual(PyObject *vals) const + mcIdType findIdFirstEqual(PyObject *vals) const { if(PyString_Check(vals)) { @@ -5742,7 +3336,7 @@ namespace MEDCoupling throw INTERP_KERNEL::Exception("DataArrayAsciiChar::findIdFirstEqual : only strings in input supported !"); } - int findIdFirstEqualTuple(PyObject *tupl) const + mcIdType findIdFirstEqualTuple(PyObject *tupl) const { if(PyString_Check(tupl)) { @@ -5764,7 +3358,7 @@ namespace MEDCoupling throw INTERP_KERNEL::Exception("DataArrayAsciiChar::findIdFirstEqualTuple : only strings in input supported !"); } - int findIdSequence(PyObject *strOrListOfInt) const + mcIdType findIdSequence(PyObject *strOrListOfInt) const { if(PyString_Check(strOrListOfInt)) { @@ -5785,10 +3379,10 @@ namespace MEDCoupling else throw INTERP_KERNEL::Exception("DataArrayAsciiChar::search : only strings in input supported !"); } - - PyObject *getTuple(int tupleId) const + + PyObject *getTuple(mcIdType tupleId) const { - int 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); @@ -5796,7 +3390,7 @@ namespace MEDCoupling PyObject *getMaxValue() const { - int tmp; + mcIdType tmp; char tmp2[2]; tmp2[1]='\0'; tmp2[0]=self->getMaxValue(tmp); PyObject *ret=PyTuple_New(2); @@ -5807,7 +3401,7 @@ namespace MEDCoupling PyObject *getMinValue() const { - int tmp; + mcIdType tmp; char tmp2[2]; tmp2[1]='\0'; tmp2[0]=self->getMinValue(tmp); PyObject *ret=PyTuple_New(2); @@ -5816,9 +3410,9 @@ namespace MEDCoupling return ret; } - int index(PyObject *obj) const + mcIdType index(PyObject *obj) const { - int nbOfCompo=self->getNumberOfComponents(); + std::size_t nbOfCompo=self->getNumberOfComponents(); switch(nbOfCompo) { case 1: @@ -5836,7 +3430,7 @@ namespace MEDCoupling if(PyUnicode_Check(obj)) { Py_ssize_t sz; - char *pt=PyUnicode_AsUTF8AndSize(obj, &sz); + const char *pt=PyUnicode_AsUTF8AndSize(obj, &sz); if(sz==1) return self->findIdFirstEqual(pt[0]); else @@ -5853,7 +3447,7 @@ namespace MEDCoupling bool __contains__(PyObject *obj) const { - int nbOfCompo=self->getNumberOfComponents(); + std::size_t nbOfCompo=self->getNumberOfComponents(); switch(nbOfCompo) { case 0: @@ -5873,7 +3467,7 @@ namespace MEDCoupling if(PyUnicode_Check(obj)) { Py_ssize_t sz; - char *pt=PyUnicode_AsUTF8AndSize(obj, &sz); + const char *pt=PyUnicode_AsUTF8AndSize(obj, &sz); if(sz==1) return self->presenceOfValue(pt[0]); else @@ -5890,10 +3484,10 @@ namespace MEDCoupling PyObject *__getitem__(PyObject *obj) const { - int sw,iTypppArr; - std::vector stdvecTyyppArr; - std::pair > sTyyppArr; - MEDCoupling::DataArrayInt *daIntTyypp=0; + mcIdType sw,iTypppArr; + std::vector stdvecTyyppArr; + std::pair > sTyyppArr; + MEDCoupling::DataArrayIdType *daIntTyypp=0; convertIntStarOrSliceLikePyObjToCppWithNegIntInterp(obj,self->getNumberOfTuples(),sw,iTypppArr,stdvecTyyppArr,sTyyppArr,daIntTyypp); switch(sw) { @@ -5906,21 +3500,21 @@ namespace MEDCoupling case 4: return convertDataArrayChar(self->selectByTupleIdSafe(daIntTyypp->begin(),daIntTyypp->end()), SWIG_POINTER_OWN | 0 ); default: - throw INTERP_KERNEL::Exception("DataArrayAsciiChar::__getitem__ : supporting int, list of int, tuple of int, DataArrayInt and slice in input !"); + throw INTERP_KERNEL::Exception("DataArrayAsciiChar::__getitem__ : supporting int, list of int, tuple of int, DataArrayIdType and slice in input !"); } } DataArrayAsciiChar *__setitem__(PyObject *obj, PyObject *value) { - static const char msg[]="DataArrayAsciiChar::__setitem__ : supporting int, list of int, tuple of int, DataArrayInt and slice in input, and 4 types accepted in value : string, list or tuple of strings having same size, not null DataArrayChar instance."; - int sw1,iTypppArr; - std::vector stdvecTyyppArr; - std::pair > sTyyppArr; - MEDCoupling::DataArrayInt *daIntTyypp=0; - int nbOfCompo=self->getNumberOfComponents(); - int nbOfTuples=self->getNumberOfTuples(); + static const char msg[]="DataArrayAsciiChar::__setitem__ : supporting int, list of int, tuple of int, DataArrayIdType and slice in input, and 4 types accepted in value : string, list or tuple of strings having same size, not null DataArrayChar instance."; + mcIdType sw1,iTypppArr; + std::vector stdvecTyyppArr; + std::pair > sTyyppArr; + MEDCoupling::DataArrayIdType *daIntTyypp=0; + mcIdType nbOfCompo=ToIdType(self->getNumberOfComponents()); + mcIdType nbOfTuples=self->getNumberOfTuples(); convertIntStarOrSliceLikePyObjToCppWithNegIntInterp(obj,nbOfTuples,sw1,iTypppArr,stdvecTyyppArr,sTyyppArr,daIntTyypp); - int sw2; + mcIdType sw2; char vc; std::string sc; std::vector vsc; DataArrayChar *dacc=0; convertObjToPossibleCpp6(value,sw2,vc,sc,vsc,dacc); switch(sw1) @@ -6029,7 +3623,7 @@ namespace MEDCoupling } } case 4: - {//DataArrayInt + {//DataArrayIdType switch(sw2) { {//value char @@ -6096,23 +3690,36 @@ namespace MEDCoupling class DataArrayAsciiCharTuple { public: - int getNumberOfCompo() const; - DataArrayAsciiChar *buildDAAsciiChar(int nbOfTuples, int nbOfCompo) const; + std::size_t getNumberOfCompo() const; + DataArrayAsciiChar *buildDAAsciiChar(mcIdType nbOfTuples, mcIdType nbOfCompo) const; %extend { std::string __str__() const { return self->repr(); } - + DataArrayAsciiChar *buildDAAsciiChar() { return self->buildDAAsciiChar(1,self->getNumberOfCompo()); } } }; + +} + +%inline +{ + MEDCoupling::DataArrayByte *FromPyIntPtrToDataArrayByte(mcPyPtrType intPtr) + { + MEDCoupling::DataArrayByte *ret(reinterpret_cast(intPtr)); + return ret; + } } +%include "DataArrayInt.i" + + %pythoncode %{ def MEDCouplingStdReduceFunct(cls,params): a,b=params @@ -6126,10 +3733,15 @@ def MEDCouplingDataArrayDoubleReduce(self): raise InterpKernelException("PyWrap of DataArrayDouble.__reduce__ : not implemented because numpy is not active in your configuration ! No serialization/unserialization available without numpy !") return MEDCouplingStdReduceFunct,(DataArrayDouble,((self.toNumPyArray(),),(self.__getstate__()),)) -def MEDCouplingDataArrayIntReduce(self): +def MEDCouplingDataArrayInt32Reduce(self): if not MEDCouplingHasNumPyBindings(): - raise InterpKernelException("PyWrap of DataArrayInt.__reduce__ : not implemented because numpy is not active in your configuration ! No serialization/unserialization available without numpy !") - return MEDCouplingStdReduceFunct,(DataArrayInt,((self.toNumPyArray(),),(self.__getstate__()),)) + raise InterpKernelException("PyWrap of DataArrayIdType.__reduce__ : not implemented because numpy is not active in your configuration ! No serialization/unserialization available without numpy !") + return MEDCouplingStdReduceFunct,(DataArrayInt32,((self.toNumPyArray(),),(self.__getstate__()),)) + +def MEDCouplingDataArrayInt64Reduce(self): + if not MEDCouplingHasNumPyBindings(): + raise InterpKernelException("PyWrap of DataArrayIdType.__reduce__ : not implemented because numpy is not active in your configuration ! No serialization/unserialization available without numpy !") + return MEDCouplingStdReduceFunct,(DataArrayInt64,((self.toNumPyArray(),),(self.__getstate__()),)) def MEDCouplingDataArrayByteReduce(self): if not MEDCouplingHasNumPyBindings(): @@ -6140,4 +3752,11 @@ def MEDCouplingDataArrayFloatReduce(self): if not MEDCouplingHasNumPyBindings(): raise InterpKernelException("PyWrap of DataArrayFloat.__reduce__ : not implemented because numpy is not active in your configuration ! No serialization/unserialization available without numpy !") return MEDCouplingStdReduceFunct,(DataArrayFloat,((self.toNumPyArray(),),(self.__getstate__()),)) + +if MEDCouplingUse64BitIDs(): + DataArrayInt=DataArrayInt64 +else: + DataArrayInt=DataArrayInt32 +pass + %}