X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDCoupling_Swig%2FMEDCouplingMemArray.i;h=5da9355d8e99e1938a0b2647b4926c8500460545;hb=1b746b38f3cdeae6654a9501f37fde5e56e59288;hp=767d95696f8eca5d6831f0d0348e447fd8d68a50;hpb=aeb6e025e98c5432c365cfc264d1f8405d1da1f3;p=tools%2Fmedcoupling.git diff --git a/src/MEDCoupling_Swig/MEDCouplingMemArray.i b/src/MEDCoupling_Swig/MEDCouplingMemArray.i index 767d95696..5da9355d8 100644 --- a/src/MEDCoupling_Swig/MEDCouplingMemArray.i +++ b/src/MEDCoupling_Swig/MEDCouplingMemArray.i @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2016 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 @@ -16,7 +16,7 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// Author : Anthony Geay (CEA/DEN) +// Author : Anthony Geay (EDF R&D) //////////////////// %typemap(out) MEDCoupling::DataArray* @@ -40,9 +40,40 @@ { $result=convertDataArrayChar($1,$owner); } + +%typemap(out) MCAuto +{ + $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 +{ + $result=SWIG_NewPointerObj(SWIG_as_voidptr($1.retn()),SWIGTYPE_p_MEDCoupling__DataArrayDouble,SWIG_POINTER_OWN|0); +} + +%typemap(out) MCAuto +{ + $result=SWIG_NewPointerObj(SWIG_as_voidptr($1.retn()),SWIGTYPE_p_MEDCoupling__DataArrayFloat,SWIG_POINTER_OWN|0); +} + +%typemap(out) MCAuto +{ + $result=SWIG_NewPointerObj(SWIG_as_voidptr($1.retn()),SWIGTYPE_p_MEDCoupling__MapII,SWIG_POINTER_OWN|0); +} //$$$$$$$$$$$$$$$$$$ %newobject MEDCoupling::DataArray::deepCopy; +%newobject MEDCoupling::DataArray::copySorted; %newobject MEDCoupling::DataArray::buildNewEmptyInstance; %newobject MEDCoupling::DataArray::selectByTupleRanges; %newobject MEDCoupling::DataArray::selectByTupleId; @@ -52,86 +83,162 @@ %newobject MEDCoupling::DataArrayFloat::New; %newobject MEDCoupling::DataArrayFloat::iterator; %newobject MEDCoupling::DataArrayFloat::__iter__; -%newobject MEDCoupling::DataArrayFloat::convertToDblArr; -%newobject MEDCoupling::DataArrayInt::New; -%newobject MEDCoupling::DataArrayInt::__iter__; -%newobject MEDCoupling::DataArrayInt::selectPartDef; -%newobject MEDCoupling::DataArrayInt::convertToDblArr; -%newobject MEDCoupling::DataArrayInt::convertToFloatArr; -%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::sumPerTuple; -%newobject MEDCoupling::DataArrayInt::negate; -%newobject MEDCoupling::DataArrayInt::computeAbs; -%newobject MEDCoupling::DataArrayInt::findIdsInRange; -%newobject MEDCoupling::DataArrayInt::findIdsNotInRange; -%newobject MEDCoupling::DataArrayInt::findIdsStricltyNegative; -%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::fromLinkedListOfPairToList; -%newobject MEDCoupling::DataArrayInt::findIdsGreaterOrEqualTo; -%newobject MEDCoupling::DataArrayInt::findIdsGreaterThan; -%newobject MEDCoupling::DataArrayInt::findIdsLowerOrEqualTo; -%newobject MEDCoupling::DataArrayInt::findIdsLowerThan; -%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::DataArrayFloat::Meld; +%newobject MEDCoupling::DataArrayFloat::__rmul__; +%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; @@ -152,9 +259,6 @@ %newobject MEDCoupling::DataArrayAsciiCharTuple::buildDAAsciiChar; %newobject MEDCoupling::DataArrayDouble::New; %newobject MEDCoupling::DataArrayDouble::__iter__; -%newobject MEDCoupling::DataArrayDouble::selectPartDef; -%newobject MEDCoupling::DataArrayDouble::convertToIntArr; -%newobject MEDCoupling::DataArrayDouble::convertToFloatArr; %newobject MEDCoupling::DataArrayDouble::performCopyOrIncrRef; %newobject MEDCoupling::DataArrayDouble::Aggregate; %newobject MEDCoupling::DataArrayDouble::Meld; @@ -169,9 +273,9 @@ %newobject MEDCoupling::DataArrayDouble::subArray; %newobject MEDCoupling::DataArrayDouble::changeNbOfComponents; %newobject MEDCoupling::DataArrayDouble::accumulatePerChunck; -%newobject MEDCoupling::DataArrayDouble::cumSum; %newobject MEDCoupling::DataArrayDouble::findIdsInRange; %newobject MEDCoupling::DataArrayDouble::findIdsNotInRange; +%newobject MEDCoupling::DataArrayDouble::findIdsStrictlyNegative; %newobject MEDCoupling::DataArrayDouble::negate; %newobject MEDCoupling::DataArrayDouble::computeAbs; %newobject MEDCoupling::DataArrayDouble::applyFunc; @@ -186,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; @@ -224,14 +329,18 @@ %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();" +%feature("unref") MapII "$this->decrRef();" %feature("unref") PartDefinition "$this->decrRef();" %feature("unref") DataArrayPartDefinition "$this->decrRef();" %feature("unref") SlicePartDefinition "$this->decrRef();" @@ -245,27 +354,42 @@ 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) throw(INTERP_KERNEL::Exception); - static PartDefinition *New(DataArrayInt *listOfIds) throw(INTERP_KERNEL::Exception); - virtual DataArrayInt *toDAI() const throw(INTERP_KERNEL::Exception); - virtual int getNumberOfElems() const throw(INTERP_KERNEL::Exception); - virtual std::string getRepr() const throw(INTERP_KERNEL::Exception); - virtual PartDefinition *composeWith(const PartDefinition *other) const throw(INTERP_KERNEL::Exception); - virtual void checkConsistencyLight() const throw(INTERP_KERNEL::Exception); - virtual PartDefinition *tryToSimplify() const throw(INTERP_KERNEL::Exception); + static PartDefinition *New(int start, int stop, int step); + 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; + virtual void checkConsistencyLight() const; + virtual PartDefinition *tryToSimplify() const; %extend { - virtual PartDefinition *__add__(const PartDefinition& other) const throw(INTERP_KERNEL::Exception) + virtual PartDefinition *__add__(const PartDefinition& other) const { return (*self)+other; } - virtual PyObject *isEqual(const PartDefinition *other) const throw(INTERP_KERNEL::Exception) + virtual PyObject *isEqual(const PartDefinition *other) const { std::string ret1; bool ret0(self->isEqual(other,ret1)); @@ -277,7 +401,7 @@ namespace MEDCoupling return ret; } - virtual PyObject *deepCopy() const throw(INTERP_KERNEL::Exception) + virtual PyObject *deepCopy() const { return convertPartDefinition(self->deepCopy(),SWIG_POINTER_OWN | 0); } @@ -289,20 +413,20 @@ namespace MEDCoupling class DataArrayPartDefinition : public PartDefinition { public: - static DataArrayPartDefinition *New(DataArrayInt *listOfIds) throw(INTERP_KERNEL::Exception); + static DataArrayPartDefinition *New(DataArrayIdType *listOfIds); %extend { - DataArrayPartDefinition(DataArrayInt *listOfIds) throw(INTERP_KERNEL::Exception) + DataArrayPartDefinition(DataArrayIdType *listOfIds) { return DataArrayPartDefinition::New(listOfIds); } - std::string __str__() const throw(INTERP_KERNEL::Exception) + std::string __str__() const { return self->getRepr(); } - - std::string __repr__() const throw(INTERP_KERNEL::Exception) + + std::string __repr__() const { std::ostringstream oss; oss << "DataArrayPartDefinition C++ instance at " << self << "." << std::endl; oss << self->getRepr(); @@ -316,28 +440,28 @@ namespace MEDCoupling class SlicePartDefinition : public PartDefinition { public: - static SlicePartDefinition *New(int start, int stop, int step) throw(INTERP_KERNEL::Exception); - int getEffectiveStop() const throw(INTERP_KERNEL::Exception); + static SlicePartDefinition *New(int start, int stop, int step); + int getEffectiveStop() const; %extend { - SlicePartDefinition(int start, int stop, int step) throw(INTERP_KERNEL::Exception) + SlicePartDefinition(mcIdType start, mcIdType stop, mcIdType step) { return SlicePartDefinition::New(start,stop,step); } - PyObject *getSlice() const throw(INTERP_KERNEL::Exception) + 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 throw(INTERP_KERNEL::Exception) + + std::string __str__() const { return self->getRepr(); } - - std::string __repr__() const throw(INTERP_KERNEL::Exception) + + std::string __repr__() const { std::ostringstream oss; oss << "SlicePartDefinition C++ instance at " << self << "." << std::endl; oss << self->getRepr(); @@ -347,88 +471,89 @@ namespace MEDCoupling protected: virtual ~SlicePartDefinition(); }; - + class DataArray : public RefCountObject, public TimeLabel { public: void setName(const std::string& name); - void copyStringInfoFrom(const DataArray& other) throw(INTERP_KERNEL::Exception); - void copyPartOfStringInfoFrom(const DataArray& other, const std::vector& compoIds) throw(INTERP_KERNEL::Exception); - void copyPartOfStringInfoFrom2(const std::vector& compoIds, const DataArray& other) throw(INTERP_KERNEL::Exception); - bool areInfoEqualsIfNotWhy(const DataArray& other, std::string& reason) const throw(INTERP_KERNEL::Exception); - bool areInfoEquals(const DataArray& other) const throw(INTERP_KERNEL::Exception); - std::string cppRepr(const std::string& varName) const throw(INTERP_KERNEL::Exception); + void copyStringInfoFrom(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; std::string getName() const; - void setInfoOnComponents(const std::vector& info) throw(INTERP_KERNEL::Exception); - void setInfoAndChangeNbOfCompo(const std::vector& info) throw(INTERP_KERNEL::Exception); - std::vector getVarsOnComponent() const throw(INTERP_KERNEL::Exception); - std::vector getUnitsOnComponent() const throw(INTERP_KERNEL::Exception); - std::string getInfoOnComponent(int i) const throw(INTERP_KERNEL::Exception); - std::string getVarOnComponent(int i) const throw(INTERP_KERNEL::Exception); - std::string getUnitOnComponent(int i) const throw(INTERP_KERNEL::Exception); - void setInfoOnComponent(int i, const std::string& info) throw(INTERP_KERNEL::Exception); + void setInfoOnComponents(const std::vector& info); + void setInfoAndChangeNbOfCompo(const std::vector& info); + std::vector getVarsOnComponent() const; + std::vector getUnitsOnComponent() const; + std::string getInfoOnComponent(int i) const; + std::string getVarOnComponent(int i) const; + std::string getUnitOnComponent(int i) const; + void setInfoOnComponent(int i, const std::string& info); int getNumberOfComponents() const; - virtual void alloc(int nbOfTuple, int nbOfCompo=1) throw(INTERP_KERNEL::Exception); - virtual void reAlloc(int nbOfTuples) throw(INTERP_KERNEL::Exception); - virtual bool isAllocated() const throw(INTERP_KERNEL::Exception); - virtual void checkAllocated() const throw(INTERP_KERNEL::Exception); - virtual void desallocate() throw(INTERP_KERNEL::Exception); - virtual int getNumberOfTuples() const throw(INTERP_KERNEL::Exception); - virtual std::size_t getNbOfElems() const throw(INTERP_KERNEL::Exception); - virtual std::size_t getNbOfElemAllocated() const throw(INTERP_KERNEL::Exception); - virtual DataArray *deepCopy() const throw(INTERP_KERNEL::Exception); - virtual DataArray *buildNewEmptyInstance() const throw(INTERP_KERNEL::Exception); - virtual DataArray *selectByTupleIdSafeSlice(int bg, int end2, int step) const throw(INTERP_KERNEL::Exception); - virtual void rearrange(int newNbOfCompo) throw(INTERP_KERNEL::Exception); - virtual void circularPermutation(int nbOfShift=1) throw(INTERP_KERNEL::Exception); - virtual void circularPermutationPerTuple(int nbOfShift=1) throw(INTERP_KERNEL::Exception); - virtual void reversePerTuple() throw(INTERP_KERNEL::Exception); - void checkNbOfTuples(int nbOfTuples, const std::string& msg) const throw(INTERP_KERNEL::Exception); - void checkNbOfComps(int nbOfCompo, const std::string& msg) const throw(INTERP_KERNEL::Exception); - void checkNbOfTuplesAndComp(const DataArray& other, const std::string& msg) const throw(INTERP_KERNEL::Exception); - void checkNbOfTuplesAndComp(int nbOfTuples, int nbOfCompo, const std::string& msg) const throw(INTERP_KERNEL::Exception); - void checkNbOfElems(std::size_t nbOfElems, const std::string& msg) const throw(INTERP_KERNEL::Exception); - static int GetNumberOfItemGivenBES(int begin, int end, int step, const std::string& msg) throw(INTERP_KERNEL::Exception); - static int GetNumberOfItemGivenBESRelative(int begin, int end, int step, const std::string& msg) throw(INTERP_KERNEL::Exception); - static int GetPosOfItemGivenBESRelativeNoThrow(int value, int begin, int end, int step) throw(INTERP_KERNEL::Exception); - static std::string GetVarNameFromInfo(const std::string& info) throw(INTERP_KERNEL::Exception); - static std::string GetUnitFromInfo(const std::string& info) throw(INTERP_KERNEL::Exception); - static std::string BuildInfoFromVarAndUnit(const std::string& var, const std::string& unit) throw(INTERP_KERNEL::Exception); - static std::string GetAxisTypeRepr(MEDCouplingAxisType at) throw(INTERP_KERNEL::Exception); + virtual void alloc(int nbOfTuple, int nbOfCompo=1); + virtual void reAlloc(int nbOfTuples); + virtual bool isAllocated() const; + virtual void checkAllocated() const; + virtual void desallocate(); + virtual int getNumberOfTuples() const; + 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); + virtual void circularPermutation(int nbOfShift=1); + virtual void circularPermutationPerTuple(int nbOfShift=1); + virtual void reversePerTuple(); + void checkNbOfTuples(int nbOfTuples, const std::string& msg) const; + 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(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); + static std::string GetVarNameFromInfo(const std::string& info); + static std::string GetUnitFromInfo(const std::string& info); + static std::string BuildInfoFromVarAndUnit(const std::string& var, const std::string& unit); + static std::string GetAxisTypeRepr(MEDCouplingAxisType at); void updateTime() const; %extend { - PyObject *getInfoOnComponents() const throw(INTERP_KERNEL::Exception) + 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) throw(INTERP_KERNEL::Exception) + void copyPartOfStringInfoFrom2(PyObject *li, const DataArray& other) { - std::vector tmp; + std::vector tmp; convertPyToNewIntArr3(li,tmp); self->copyPartOfStringInfoFrom2(tmp,other); } - virtual void renumberInPlace(PyObject *li) throw(INTERP_KERNEL::Exception) + 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 !"); @@ -437,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 !"); @@ -450,14 +575,14 @@ namespace MEDCoupling } } - virtual void renumberInPlaceR(PyObject *li) throw(INTERP_KERNEL::Exception) + 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 !"); @@ -466,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 !"); @@ -480,47 +605,47 @@ namespace MEDCoupling } //tuplesSelec in PyObject * because DataArrayInt is not already existing ! - virtual void setContigPartOfSelectedValues(int tupleIdStart, PyObject *aBase, PyObject *tuplesSelec) throw(INTERP_KERNEL::Exception) + 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) throw(INTERP_KERNEL::Exception) + + 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); } - virtual DataArray *selectByTupleRanges(PyObject *li) const throw(INTERP_KERNEL::Exception) + virtual DataArray *selectByTupleRanges(PyObject *li) const { - std::vector > ranges; + std::vector > ranges; convertPyToVectorPairInt(li,ranges); return self->selectByTupleRanges(ranges); } - virtual DataArray *selectByTupleId(PyObject *li) const throw(INTERP_KERNEL::Exception) + 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(); @@ -528,19 +653,19 @@ namespace MEDCoupling } } - virtual DataArray *selectByTupleIdSafe(PyObject *li) const throw(INTERP_KERNEL::Exception) + 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(); @@ -548,117 +673,111 @@ namespace MEDCoupling } } - virtual PyObject *keepSelectedComponents(PyObject *li) const throw(INTERP_KERNEL::Exception) + 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) throw(INTERP_KERNEL::Exception) + 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; - PySliceObject *sly=reinterpret_cast(slic); - GetIndicesOfSliceExplicitely(sly,&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)); + GetIndicesOfSliceExplicitely(slic,&strt,&stp,&step,"DataArray::GetSlice (wrap) : the input slice is invalid !"); + 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 throw(INTERP_KERNEL::Exception) + 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; - PySliceObject *sly=reinterpret_cast(slic); - GetIndicesOfSlice(sly,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)); + GetIndicesOfSlice(slic,self->getNumberOfTuples(),&strt,&stp,&step,"DataArray::getSlice (wrap) : the input slice is invalid !"); + 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) throw(INTERP_KERNEL::Exception) + 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; - PySliceObject *sly=reinterpret_cast(slic); - GetIndicesOfSliceExplicitely(sly,&strt,&stp,&step,"DataArray::GetNumberOfItemGivenBES (wrap) : the input slice is invalid !"); - return DataArray::GetNumberOfItemGivenBES(strt,stp,step,""); + GetIndicesOfSliceExplicitely(slic,&strt,&stp,&step,"DataArray::GetNumberOfItemGivenBES (wrap) : the input slice is invalid !"); + return DataArray::GetNumberOfItemGivenBES(ToIdType(strt),ToIdType(stp),ToIdType(step),""); } - static int GetNumberOfItemGivenBESRelative(PyObject *slic) throw(INTERP_KERNEL::Exception) + 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; - PySliceObject *sly=reinterpret_cast(slic); - GetIndicesOfSliceExplicitely(sly,&strt,&stp,&step,"DataArray::GetNumberOfItemGivenBESRelative (wrap) : the input slice is invalid !"); - return DataArray::GetNumberOfItemGivenBESRelative(strt,stp,step,""); + GetIndicesOfSliceExplicitely(slic,&strt,&stp,&step,"DataArray::GetNumberOfItemGivenBESRelative (wrap) : the input slice is invalid !"); + return DataArray::GetNumberOfItemGivenBESRelative(ToIdType(strt),ToIdType(stp),ToIdType(step),""); } - - static DataArray *Aggregate(PyObject *arrs) throw(INTERP_KERNEL::Exception) + + static DataArray *Aggregate(PyObject *arrs) { std::vector tmp; convertFromPyObjVectorOfObj(arrs,SWIGTYPE_p_MEDCoupling__DataArray,"DataArray",tmp); return DataArray::Aggregate(tmp); } - int getNumberOfItemGivenBES(PyObject *slic) const throw(INTERP_KERNEL::Exception) + 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; - PySliceObject *sly=reinterpret_cast(slic); - GetIndicesOfSlice(sly,self->getNumberOfTuples(),&strt,&stp,&step,"DataArray::getNumberOfItemGivenBES (wrap) : the input slice is invalid !"); - return DataArray::GetNumberOfItemGivenBES(strt,stp,step,""); + GetIndicesOfSlice(slic,self->getNumberOfTuples(),&strt,&stp,&step,"DataArray::getNumberOfItemGivenBES (wrap) : the input slice is invalid !"); + return DataArray::GetNumberOfItemGivenBES(ToIdType(strt),ToIdType(stp),ToIdType(step),""); } - int getNumberOfItemGivenBESRelative(PyObject *slic) throw(INTERP_KERNEL::Exception) + 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; - PySliceObject *sly=reinterpret_cast(slic); - GetIndicesOfSlice(sly,self->getNumberOfTuples(),&strt,&stp,&step,"DataArray::getNumberOfItemGivenBESRelative (wrap) : the input slice is invalid !"); - return DataArray::GetNumberOfItemGivenBESRelative(strt,stp,step,""); + GetIndicesOfSlice(slic,self->getNumberOfTuples(),&strt,&stp,&step,"DataArray::getNumberOfItemGivenBESRelative (wrap) : the input slice is invalid !"); + return DataArray::GetNumberOfItemGivenBESRelative(ToIdType(strt),ToIdType(stp),ToIdType(step),""); } - PyObject *__getstate__() const throw(INTERP_KERNEL::Exception) + PyObject *__getstate__() const { PyObject *ret(PyTuple_New(2)); std::string a0(self->getName()); 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;isetName(convertPyObjectToStr(a0,MSG)); PyObject *a1(PyTuple_GetItem(inp,1)); std::vector a1cpp; if(!fillStringVector(a1,a1cpp)) throw INTERP_KERNEL::Exception(MSG); - self->setName(PyString_AsString(a0)); self->setInfoOnComponents(a1cpp); } } @@ -670,48 +789,50 @@ namespace MEDCoupling { public: static DataArrayFloat *New(); - void fillWithValue(float val) throw(INTERP_KERNEL::Exception); - bool isEqual(const DataArrayFloat& other, float prec) const throw(INTERP_KERNEL::Exception); - bool isEqualWithoutConsideringStr(const DataArrayFloat& other, float prec) const throw(INTERP_KERNEL::Exception); - bool isUniform(float val, float eps) const throw(INTERP_KERNEL::Exception); - void pushBackSilent(float val) throw(INTERP_KERNEL::Exception); - void iota(float init=0.) throw(INTERP_KERNEL::Exception); - DataArrayFloatIterator *iterator() throw(INTERP_KERNEL::Exception); + void fillWithValue(float val); + bool isEqual(const DataArrayFloat& other, float prec) const; + bool isEqualWithoutConsideringStr(const DataArrayFloat& other, float prec) const; + bool isUniform(float val, float eps) const; + void pushBackSilent(float val); + void iota(float init=0.); + DataArrayFloatIterator *iterator(); + MCAuto convertToDblArr() const; + static DataArrayFloat *Meld(const DataArrayFloat *a1, const DataArrayFloat *a2); %extend { - DataArrayFloat() throw(INTERP_KERNEL::Exception) + DataArrayFloat() { return DataArrayFloat::New(); } - static DataArrayFloat *New(PyObject *elt0, PyObject *nbOfTuples=0, PyObject *elt2=0) throw(INTERP_KERNEL::Exception) + static DataArrayFloat *New(PyObject *elt0, PyObject *nbOfTuples=0, PyObject *elt2=0) { return DataArrayT_New(elt0,nbOfTuples,elt2); } - - DataArrayFloat(PyObject *elt0, PyObject *nbOfTuples=0, PyObject *elt2=0) throw(INTERP_KERNEL::Exception) + + DataArrayFloat(PyObject *elt0, PyObject *nbOfTuples=0, PyObject *elt2=0) { return MEDCoupling_DataArrayFloat_New__SWIG_1(elt0,nbOfTuples,elt2); } - - DataArrayFloatIterator *__iter__() throw(INTERP_KERNEL::Exception) + + DataArrayFloatIterator *__iter__() { return self->iterator(); } - std::string __repr__() const throw(INTERP_KERNEL::Exception) + std::string __repr__() const { std::ostringstream oss; self->reprQuickOverview(oss); return oss.str(); } - std::string __str__() const throw(INTERP_KERNEL::Exception) + std::string __str__() const { return self->reprNotTooLong(); } - int __len__() const throw(INTERP_KERNEL::Exception) + mcIdType __len__() const { if(self->isAllocated()) { @@ -723,62 +844,73 @@ namespace MEDCoupling } } - PyObject *getValues() const throw(INTERP_KERNEL::Exception) + PyObject *getValues() const { const float *vals(self->begin()); return convertDblArrToPyList(vals,self->getNbOfElems()); } - PyObject *getValuesAsTuple() const throw(INTERP_KERNEL::Exception) + 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); } - - DataArrayDouble *convertToDblArr() const throw(INTERP_KERNEL::Exception) + + PyObject *isEqualIfNotWhy(const DataArrayFloat& other, float prec) const { - MCAuto ret(self->convertToDblArr()); - return ret.retn(); + std::string ret1; + bool ret0=self->isEqualIfNotWhy(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,PyString_FromString(ret1.c_str())); + return ret; } - PyObject *__getitem__(PyObject *obj) throw(INTERP_KERNEL::Exception) + PyObject *__getitem__(PyObject *obj) { return DataArrayT__getitem(self,obj); } - DataArrayFloat *__setitem__(PyObject *obj, PyObject *value) throw(INTERP_KERNEL::Exception) + DataArrayFloat *__setitem__(PyObject *obj, PyObject *value) { return DataArrayT__setitem__(self,obj,value); } - - PyObject *___iadd___(PyObject *trueSelf, PyObject *obj) throw(INTERP_KERNEL::Exception) + + PyObject *___iadd___(PyObject *trueSelf, PyObject *obj) { return DataArrayT_iadd(trueSelf,obj,self); } - PyObject *___isub___(PyObject *trueSelf, PyObject *obj) throw(INTERP_KERNEL::Exception) + PyObject *___isub___(PyObject *trueSelf, PyObject *obj) { return DataArrayT_isub(trueSelf,obj,self); } - PyObject *___imul___(PyObject *trueSelf, PyObject *obj) throw(INTERP_KERNEL::Exception) + PyObject *___imul___(PyObject *trueSelf, PyObject *obj) { return DataArrayT_imul(trueSelf,obj,self); } - PyObject *___idiv___(PyObject *trueSelf, PyObject *obj) throw(INTERP_KERNEL::Exception) + DataArrayFloat *__rmul__(PyObject *obj) + { + return DataArrayFPT_rmul(self,obj); + } + + PyObject *___idiv___(PyObject *trueSelf, PyObject *obj) { return DataArrayT_idiv(trueSelf,obj,self); } - + #ifdef WITH_NUMPY - PyObject *toNumPyArray() throw(INTERP_KERNEL::Exception) // not const. It is not a bug ! + PyObject *toNumPyArray() // not const. It is not a bug ! { return ToNumPyArray(self,NPY_FLOAT,"DataArrayFloat"); } #endif - } }; @@ -808,26 +940,26 @@ namespace MEDCoupling class DataArrayFloatTuple { public: - int getNumberOfCompo() const throw(INTERP_KERNEL::Exception); - DataArrayFloat *buildDAFloat(int nbOfTuples, int nbOfCompo) const throw(INTERP_KERNEL::Exception); + std::size_t getNumberOfCompo() const; + DataArrayFloat *buildDAFloat(mcIdType nbOfTuples, mcIdType nbOfCompo) const; %extend { - std::string __str__() const throw(INTERP_KERNEL::Exception) + std::string __str__() const { return self->repr(); } - float __float__() const throw(INTERP_KERNEL::Exception) + float __float__() const { return self->floatValue(); } - DataArrayFloat *buildDAFloat() throw(INTERP_KERNEL::Exception) + DataArrayFloat *buildDAFloat() { return self->buildDAFloat(1,self->getNumberOfCompo()); } - - /*PyObject *___imul___(PyObject *trueSelf, PyObject *obj) throw(INTERP_KERNEL::Exception) + + /*PyObject *___imul___(PyObject *trueSelf, PyObject *obj) { MCAuto ret=self->buildDAFloat(1,self->getNumberOfCompo()); MEDCoupling_DataArrayFloat____imul___(ret,0,obj); @@ -835,199 +967,184 @@ namespace MEDCoupling return trueSelf; }*/ - PyObject *__len__() throw(INTERP_KERNEL::Exception) + PyObject *__len__() { return PyInt_FromLong(self->getNumberOfCompo()); } } }; - - class DataArrayInt; + class DataArrayDoubleIterator; - + class DataArrayDouble : public DataArray { public: static DataArrayDouble *New(); - double doubleValue() const throw(INTERP_KERNEL::Exception); - bool empty() const throw(INTERP_KERNEL::Exception); - void aggregate(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception); - DataArrayDouble *performCopyOrIncrRef(bool deepCopy) const throw(INTERP_KERNEL::Exception); - void deepCopyFrom(const DataArrayDouble& other) throw(INTERP_KERNEL::Exception); - void reserve(std::size_t nbOfElems) throw(INTERP_KERNEL::Exception); - void pushBackSilent(double val) throw(INTERP_KERNEL::Exception); - double popBackSilent() throw(INTERP_KERNEL::Exception); - void pack() const throw(INTERP_KERNEL::Exception); - void allocIfNecessary(int nbOfTuple, int nbOfCompo) throw(INTERP_KERNEL::Exception); - void fillWithZero() throw(INTERP_KERNEL::Exception); - void fillWithValue(double val) throw(INTERP_KERNEL::Exception); - void iota(double init=0.) throw(INTERP_KERNEL::Exception); - bool isUniform(double val, double eps) const throw(INTERP_KERNEL::Exception); - void sort(bool asc=true) throw(INTERP_KERNEL::Exception); - void reverse() throw(INTERP_KERNEL::Exception); - void checkMonotonic(bool increasing, double eps) const throw(INTERP_KERNEL::Exception); - bool isMonotonic(bool increasing, double eps) const throw(INTERP_KERNEL::Exception); - std::string repr() const throw(INTERP_KERNEL::Exception); - std::string reprZip() const throw(INTERP_KERNEL::Exception); - std::string reprNotTooLong() const throw(INTERP_KERNEL::Exception); - bool isEqual(const DataArrayDouble& other, double prec) const throw(INTERP_KERNEL::Exception); - bool isEqualWithoutConsideringStr(const DataArrayDouble& other, double prec) const throw(INTERP_KERNEL::Exception); - DataArrayDouble *fromNoInterlace() const throw(INTERP_KERNEL::Exception); - DataArrayDouble *toNoInterlace() const throw(INTERP_KERNEL::Exception); - DataArrayDouble *subArray(int tupleIdBg, int tupleIdEnd=-1) const throw(INTERP_KERNEL::Exception); - void transpose() throw(INTERP_KERNEL::Exception); - DataArrayDouble *changeNbOfComponents(int newNbOfComp, double dftValue) const throw(INTERP_KERNEL::Exception); - void meldWith(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception); - DataArrayDouble *duplicateEachTupleNTimes(int nbTimes) const throw(INTERP_KERNEL::Exception); - DataArrayDouble *getDifferentValues(double prec, int limitTupleId=-1) const throw(INTERP_KERNEL::Exception); - DataArrayInt *findClosestTupleId(const DataArrayDouble *other) const throw(INTERP_KERNEL::Exception); - DataArrayInt *computeNbOfInteractionsWith(const DataArrayDouble *otherBBoxFrmt, double eps) const throw(INTERP_KERNEL::Exception); - void setPartOfValues1(const DataArrayDouble *a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare=true) throw(INTERP_KERNEL::Exception); - void setPartOfValuesSimple1(double a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp) throw(INTERP_KERNEL::Exception); - void setPartOfValuesAdv(const DataArrayDouble *a, const DataArrayInt *tuplesSelec) throw(INTERP_KERNEL::Exception); - double getIJ(int tupleId, int compoId) const throw(INTERP_KERNEL::Exception); - double front() const throw(INTERP_KERNEL::Exception); - double back() const throw(INTERP_KERNEL::Exception); - double getIJSafe(int tupleId, int compoId) const throw(INTERP_KERNEL::Exception); - void setIJ(int tupleId, int compoId, double newVal) throw(INTERP_KERNEL::Exception); - void setIJSilent(int tupleId, int compoId, double newVal) throw(INTERP_KERNEL::Exception); - double *getPointer() throw(INTERP_KERNEL::Exception); - void checkNoNullValues() const throw(INTERP_KERNEL::Exception); - DataArrayDouble *computeBBoxPerTuple(double epsilon=0.0) const throw(INTERP_KERNEL::Exception); - void recenterForMaxPrecision(double eps) throw(INTERP_KERNEL::Exception); - double getMaxValue(int& tupleId) const throw(INTERP_KERNEL::Exception); - double getMaxValueInArray() const throw(INTERP_KERNEL::Exception); - double getMinValue(int& tupleId) const throw(INTERP_KERNEL::Exception); - double getMinValueInArray() const throw(INTERP_KERNEL::Exception); - int count(double value, double eps) const throw(INTERP_KERNEL::Exception); - double getAverageValue() const throw(INTERP_KERNEL::Exception); - double norm2() const throw(INTERP_KERNEL::Exception); - double normMax() const throw(INTERP_KERNEL::Exception); - double normMin() const throw(INTERP_KERNEL::Exception); - double accumulate(int compId) const throw(INTERP_KERNEL::Exception); - DataArrayDouble *fromPolarToCart() const throw(INTERP_KERNEL::Exception); - DataArrayDouble *fromCylToCart() const throw(INTERP_KERNEL::Exception); - DataArrayDouble *fromSpherToCart() const throw(INTERP_KERNEL::Exception); - DataArrayDouble *fromCartToPolar() const throw(INTERP_KERNEL::Exception); - DataArrayDouble *fromCartToCyl() const throw(INTERP_KERNEL::Exception); - DataArrayDouble *fromCartToSpher() const throw(INTERP_KERNEL::Exception); - DataArrayDouble *cartesianize(MEDCouplingAxisType atOfThis) const throw(INTERP_KERNEL::Exception); - DataArrayDouble *doublyContractedProduct() const throw(INTERP_KERNEL::Exception); - DataArrayDouble *determinant() const throw(INTERP_KERNEL::Exception); - DataArrayDouble *eigenValues() const throw(INTERP_KERNEL::Exception); - DataArrayDouble *eigenVectors() const throw(INTERP_KERNEL::Exception); - DataArrayDouble *inverse() const throw(INTERP_KERNEL::Exception); - DataArrayDouble *trace() const throw(INTERP_KERNEL::Exception); - DataArrayDouble *deviator() const throw(INTERP_KERNEL::Exception); - DataArrayDouble *magnitude() const throw(INTERP_KERNEL::Exception); - DataArrayDouble *maxPerTuple() const throw(INTERP_KERNEL::Exception); - DataArrayDouble *sumPerTuple() const throw(INTERP_KERNEL::Exception); - DataArrayDouble *buildEuclidianDistanceDenseMatrix() const throw(INTERP_KERNEL::Exception); - DataArrayDouble *buildEuclidianDistanceDenseMatrixWith(const DataArrayDouble *other) const throw(INTERP_KERNEL::Exception); - void sortPerTuple(bool asc) throw(INTERP_KERNEL::Exception); - void abs() throw(INTERP_KERNEL::Exception); - DataArrayDouble *computeAbs() const throw(INTERP_KERNEL::Exception); - void applyLin(double a, double b, int compoId) throw(INTERP_KERNEL::Exception); - void applyLin(double a, double b) throw(INTERP_KERNEL::Exception); - void applyInv(double numerator) throw(INTERP_KERNEL::Exception); - void applyPow(double val) throw(INTERP_KERNEL::Exception); - void applyRPow(double val) throw(INTERP_KERNEL::Exception); - DataArrayDouble *negate() const throw(INTERP_KERNEL::Exception); - DataArrayDouble *applyFunc(int nbOfComp, FunctionToEvaluate func) const throw(INTERP_KERNEL::Exception); - DataArrayDouble *applyFunc(int nbOfComp, const std::string& func, bool isSafe=true) const throw(INTERP_KERNEL::Exception); - DataArrayDouble *applyFunc(const std::string& func, bool isSafe=true) const throw(INTERP_KERNEL::Exception); - void applyFuncOnThis(const std::string& func, bool isSafe=true) throw(INTERP_KERNEL::Exception); - DataArrayDouble *applyFuncCompo(int nbOfComp, const std::string& func, bool isSafe=true) const throw(INTERP_KERNEL::Exception); - DataArrayDouble *applyFuncNamedCompo(int nbOfComp, const std::vector& varsOrder, const std::string& func, bool isSafe=true) const throw(INTERP_KERNEL::Exception); - void applyFuncFast32(const std::string& func) throw(INTERP_KERNEL::Exception); - void applyFuncFast64(const std::string& func) throw(INTERP_KERNEL::Exception); - DataArrayInt *findIdsInRange(double vmin, double vmax) const throw(INTERP_KERNEL::Exception); - DataArrayInt *findIdsNotInRange(double vmin, double vmax) const throw(INTERP_KERNEL::Exception); - static DataArrayDouble *Aggregate(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception); - static DataArrayDouble *Meld(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception); - static DataArrayDouble *Dot(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception); - static DataArrayDouble *CrossProduct(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception); - static DataArrayDouble *Max(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception); - static DataArrayDouble *Min(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception); - static DataArrayDouble *Add(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception); - void addEqual(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception); - static DataArrayDouble *Substract(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception); - void substractEqual(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception); - static DataArrayDouble *Multiply(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception); - void multiplyEqual(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception); - static DataArrayDouble *Divide(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception); - void divideEqual(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception); - static DataArrayDouble *Pow(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception); - void powEqual(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception); + double doubleValue() const; + bool empty() const; + void aggregate(const DataArrayDouble *other); + DataArrayDouble *performCopyOrIncrRef(bool deepCopy) const; + void deepCopyFrom(const DataArrayDouble& other); + void reserve(std::size_t nbOfElems); + void pushBackSilent(double val); + double popBackSilent(); + void pack() const; + void allocIfNecessary(int nbOfTuple, int nbOfCompo); + void fillWithZero(); + void fillWithValue(double val); + void iota(double init=0.); + bool isUniform(double val, double eps) const; + void sort(bool asc=true); + void reverse(); + void checkMonotonic(bool increasing, double eps) const; + bool isMonotonic(bool increasing, double eps) const; + std::string repr() const; + std::string reprZip() const; + std::string reprNotTooLong() const; + bool isEqual(const DataArrayDouble& other, double prec) const; + bool isEqualWithoutConsideringStr(const DataArrayDouble& other, double prec) const; + DataArrayDouble *fromNoInterlace() const; + DataArrayDouble *toNoInterlace() const; + DataArrayDouble *subArray(int tupleIdBg, int tupleIdEnd=-1) const; + void transpose(); + 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; + 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, 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; + double getIJSafe(int tupleId, int compoId) const; + void setIJ(int tupleId, int compoId, double newVal); + void setIJSilent(int tupleId, int compoId, double newVal); + double *getPointer(); + void checkNoNullValues() const; + DataArrayDouble *computeBBoxPerTuple(double epsilon=0.0) const; + void recenterForMaxPrecision(double eps); + double getMaxValueInArray() const; + double getMaxAbsValueInArray() const; + double getMinValueInArray() const; + int count(double value, double eps) const; + double getAverageValue() const; + double norm2() const; + double normMax() const; + double normMin() const; + double accumulate(int compId) const; + DataArrayDouble *fromPolarToCart() const; + DataArrayDouble *fromCylToCart() const; + DataArrayDouble *fromSpherToCart() const; + DataArrayDouble *fromCartToPolar() const; + DataArrayDouble *fromCartToCyl() const; + DataArrayDouble *fromCartToSpher() const; + DataArrayDouble *cartesianize(MEDCouplingAxisType atOfThis) const; + DataArrayDouble *doublyContractedProduct() const; + DataArrayDouble *determinant() const; + DataArrayDouble *eigenValues() const; + DataArrayDouble *eigenVectors() const; + DataArrayDouble *inverse() const; + DataArrayDouble *trace() const; + DataArrayDouble *deviator() const; + DataArrayDouble *magnitude() const; + DataArrayDouble *maxPerTuple() const; + DataArrayDouble *minPerTuple() const; + DataArrayDouble *sumPerTuple() const; + DataArrayDouble *buildEuclidianDistanceDenseMatrix() const; + DataArrayDouble *buildEuclidianDistanceDenseMatrixWith(const DataArrayDouble *other) const; + void sortPerTuple(bool asc); + void abs(); + DataArrayDouble *computeAbs() const; + void applyLin(double a, double b, int compoId); + void applyLin(double a, double b); + void applyInv(double numerator); + void applyPow(double val); + void applyRPow(double val); + DataArrayDouble *negate() const; + DataArrayDouble *applyFunc(int nbOfComp, FunctionToEvaluate func) const; + DataArrayDouble *applyFunc(int nbOfComp, const std::string& func, bool isSafe=true) const; + DataArrayDouble *applyFunc(const std::string& func, bool isSafe=true) const; + void applyFuncOnThis(const std::string& func, bool isSafe=true); + DataArrayDouble *applyFuncCompo(int nbOfComp, const std::string& func, bool isSafe=true) const; + 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); + 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); + static DataArrayDouble *CrossProduct(const DataArrayDouble *a1, const DataArrayDouble *a2); + static DataArrayDouble *Max(const DataArrayDouble *a1, const DataArrayDouble *a2); + static DataArrayDouble *Min(const DataArrayDouble *a1, const DataArrayDouble *a2); + static DataArrayDouble *Add(const DataArrayDouble *a1, const DataArrayDouble *a2); + void addEqual(const DataArrayDouble *other); + static DataArrayDouble *Substract(const DataArrayDouble *a1, const DataArrayDouble *a2); + void substractEqual(const DataArrayDouble *other); + static DataArrayDouble *Multiply(const DataArrayDouble *a1, const DataArrayDouble *a2); + void multiplyEqual(const DataArrayDouble *other); + static DataArrayDouble *Divide(const DataArrayDouble *a1, const DataArrayDouble *a2); + 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 convertToInt64Arr() const; + MCAuto selectPartDef(const PartDefinition* pd) const; + MCAuto cumSum() const; + MCAuto convertToFloatArr() const; %extend { - DataArrayDouble() throw(INTERP_KERNEL::Exception) + DataArrayDouble() { return DataArrayDouble::New(); } - static DataArrayDouble *New(PyObject *elt0, PyObject *nbOfTuples=0, PyObject *elt2=0) throw(INTERP_KERNEL::Exception) + static DataArrayDouble *New(PyObject *elt0, PyObject *nbOfTuples=0, PyObject *elt2=0) { return DataArrayT_New(elt0,nbOfTuples,elt2); } - - DataArrayDouble(PyObject *elt0, PyObject *nbOfTuples=0, PyObject *elt2=0) throw(INTERP_KERNEL::Exception) - { - return MEDCoupling_DataArrayDouble_New__SWIG_1(elt0,nbOfTuples,elt2); - } - - DataArrayDouble *selectPartDef(const PartDefinition* pd) const throw(INTERP_KERNEL::Exception) - { - MCAuto ret(self->selectPartDef(pd)); - return ret.retn(); - } - - DataArrayDouble *cumSum() const throw(INTERP_KERNEL::Exception) - { - MCAuto ret(self->cumSum()); - return ret.retn(); - } - DataArrayFloat *convertToFloatArr() const throw(INTERP_KERNEL::Exception) - { - MCAuto ret(self->convertToFloatArr()); - return ret.retn(); - } - - DataArrayInt *convertToIntArr() const throw(INTERP_KERNEL::Exception) + DataArrayDouble(PyObject *elt0, PyObject *nbOfTuples=0, PyObject *elt2=0) { - MCAuto ret(self->convertToIntArr()); - return ret.retn(); + return MEDCoupling_DataArrayDouble_New__SWIG_1(elt0,nbOfTuples,elt2); } - void pushBackValsSilent(PyObject *li) throw(INTERP_KERNEL::Exception) + void pushBackValsSilent(PyObject *li) { 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); } - std::string __repr__() const throw(INTERP_KERNEL::Exception) + std::string __repr__() const { std::ostringstream oss; self->reprQuickOverview(oss); return oss.str(); } - std::string __str__() const throw(INTERP_KERNEL::Exception) + std::string __str__() const { return self->reprNotTooLong(); } - double __float__() const throw(INTERP_KERNEL::Exception) + double __float__() const { return self->doubleValue(); } - int __len__() const throw(INTERP_KERNEL::Exception) + mcIdType __len__() const { if(self->isAllocated()) { @@ -1039,28 +1156,44 @@ namespace MEDCoupling } } - DataArrayDoubleIterator *__iter__() throw(INTERP_KERNEL::Exception) + PyObject *asArcOfCircle() const + { + double center[2],radius,ang; + self->asArcOfCircle(center,radius,ang); + PyObject *ret(PyTuple_New(3)); + { + PyObject *ret0(PyList_New(2)); + PyList_SetItem(ret0,0,PyFloat_FromDouble(center[0])); + PyList_SetItem(ret0,1,PyFloat_FromDouble(center[1])); + PyTuple_SetItem(ret,0,ret0); + } + PyTuple_SetItem(ret,1,PyFloat_FromDouble(radius)); + PyTuple_SetItem(ret,2,PyFloat_FromDouble(ang)); + return ret; + } + + DataArrayDoubleIterator *__iter__() { return self->iterator(); } - - void setValues(PyObject *li, PyObject *nbOfTuples=0, PyObject *nbOfComp=0) throw(INTERP_KERNEL::Exception) + + 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 !"; if(PyList_Check(li) || PyTuple_Check(li)) { - if(nbOfTuples) + if(nbOfTuples && nbOfTuples != Py_None) { 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) + 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); @@ -1071,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()); } @@ -1081,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()); } @@ -1090,20 +1223,20 @@ namespace MEDCoupling throw INTERP_KERNEL::Exception(msg); } - PyObject *getValues() const throw(INTERP_KERNEL::Exception) + PyObject *getValues() const { const double *vals(self->begin()); return convertDblArrToPyList(vals,self->getNbOfElems()); } #ifdef WITH_NUMPY - PyObject *toNumPyArray() throw(INTERP_KERNEL::Exception) // not const. It is not a bug ! + PyObject *toNumPyArray() // not const. It is not a bug ! { return ToNumPyArray(self,NPY_DOUBLE,"DataArrayDouble"); } #endif - PyObject *isEqualIfNotWhy(const DataArrayDouble& other, double prec) const throw(INTERP_KERNEL::Exception) + PyObject *isEqualIfNotWhy(const DataArrayDouble& other, double prec) const { std::string ret1; bool ret0=self->isEqualIfNotWhy(other,prec,ret1); @@ -1115,35 +1248,58 @@ namespace MEDCoupling return ret; } - PyObject *getValuesAsTuple() const throw(INTERP_KERNEL::Exception) + 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); } - DataArrayDouble *symmetry3DPlane(PyObject *point, PyObject *normalVector) throw(INTERP_KERNEL::Exception) + static PyObject *ComputeIntegralOfSeg2IntoTri3(PyObject *seg2, PyObject *tri3) + { + const char msg[]="Python wrap of DataArrayDouble::ComputeIntegralOfSeg2IntoTri3 : "; + double val,val2; + DataArrayDouble *a,*a2; + DataArrayDoubleTuple *aa,*aa2; + std::vector bb,bb2; + 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)); + // + double res0[3],res1; + DataArrayDouble::ComputeIntegralOfSeg2IntoTri3(seg2Ptr,tri3Ptr,res0,res1); + PyObject *ret(PyTuple_New(2)),*ret0(PyTuple_New(3)); + PyTuple_SetItem(ret0,0,PyFloat_FromDouble(res0[0])); + PyTuple_SetItem(ret0,1,PyFloat_FromDouble(res0[1])); + PyTuple_SetItem(ret0,2,PyFloat_FromDouble(res0[2])); + PyTuple_SetItem(ret,0,ret0); + PyTuple_SetItem(ret,1,PyFloat_FromDouble(res1)); + return ret; + } + + DataArrayDouble *symmetry3DPlane(PyObject *point, PyObject *normalVector) { const char msg[]="Python wrap of DataArrayDouble::symmetry3DPlane : "; double val,val2; 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)); return ret.retn(); } - static PyObject *GiveBaseForPlane(PyObject *normalVector) throw(INTERP_KERNEL::Exception) + 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); @@ -1157,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) throw(INTERP_KERNEL::Exception) + + 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 !"); @@ -1179,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 !"); @@ -1192,14 +1348,14 @@ namespace MEDCoupling } } - DataArrayDouble *renumberR(PyObject *li) throw(INTERP_KERNEL::Exception) + 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 !"); @@ -1208,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 !"); @@ -1221,14 +1377,14 @@ namespace MEDCoupling } } - DataArrayDouble *renumberAndReduce(PyObject *li, int newNbOfTuple) throw(INTERP_KERNEL::Exception) + 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 !"); @@ -1237,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 !"); @@ -1250,9 +1406,9 @@ namespace MEDCoupling } } - PyObject *minimalDistanceTo(const DataArrayDouble *other) const throw(INTERP_KERNEL::Exception) + 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)); @@ -1261,9 +1417,9 @@ namespace MEDCoupling return ret; } - PyObject *getMaxValue() const throw(INTERP_KERNEL::Exception) + PyObject *getMaxValue() const { - int tmp; + mcIdType tmp; double r1=self->getMaxValue(tmp); PyObject *ret=PyTuple_New(2); PyTuple_SetItem(ret,0,PyFloat_FromDouble(r1)); @@ -1271,19 +1427,29 @@ namespace MEDCoupling return ret; } - PyObject *getMaxValue2() const throw(INTERP_KERNEL::Exception) + PyObject *getMaxAbsValue() const + { + std::size_t tmp; + double r1=self->getMaxAbsValue(tmp); + PyObject *ret=PyTuple_New(2); + PyTuple_SetItem(ret,0,PyFloat_FromDouble(r1)); + PyTuple_SetItem(ret,1,PyInt_FromLong(tmp)); + return ret; + } + + 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 throw(INTERP_KERNEL::Exception) + PyObject *getMinValue() const { - int tmp; + mcIdType tmp; double r1=self->getMinValue(tmp); PyObject *ret=PyTuple_New(2); PyTuple_SetItem(ret,0,PyFloat_FromDouble(r1)); @@ -1291,60 +1457,69 @@ namespace MEDCoupling return ret; } - PyObject *getMinValue2() const throw(INTERP_KERNEL::Exception) + 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 throw(INTERP_KERNEL::Exception) + 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 *accumulate() const throw(INTERP_KERNEL::Exception) + PyObject *normMaxPerComponent() const + { + std::size_t nbOfCompo(self->getNumberOfComponents()); + INTERP_KERNEL::AutoPtr tmp(new double[nbOfCompo]); + self->normMaxPerComponent(tmp); + 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 throw(INTERP_KERNEL::Exception) + 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 throw(INTERP_KERNEL::Exception) + 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; } - PyObject *distanceToTuple(PyObject *tuple) const throw(INTERP_KERNEL::Exception) + PyObject *distanceToTuple(PyObject *tuple) const { double val; 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); @@ -1353,14 +1528,14 @@ namespace MEDCoupling return ret; } - void setSelectedComponents(const DataArrayDouble *a, PyObject *li) throw(INTERP_KERNEL::Exception) + void setSelectedComponents(const DataArrayDouble *a, PyObject *li) { - std::vector tmp; + std::vector tmp; convertPyToNewIntArr3(li,tmp); self->setSelectedComponents(a,tmp); } - PyObject *explodeComponents() const throw(INTERP_KERNEL::Exception) + PyObject *explodeComponents() const { std::vector< MCAuto > retCpp(self->explodeComponents()); std::size_t sz(retCpp.size()); @@ -1369,83 +1544,84 @@ 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) throw(INTERP_KERNEL::Exception) + + 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) throw(INTERP_KERNEL::Exception) + static DataArrayDouble *Aggregate(PyObject *li) { std::vector tmp; convertFromPyObjVectorOfObj(li,SWIGTYPE_p_MEDCoupling__DataArrayDouble,"DataArrayDouble",tmp); return DataArrayDouble::Aggregate(tmp); } - static DataArrayDouble *Meld(PyObject *li) throw(INTERP_KERNEL::Exception) + static DataArrayDouble *Meld(PyObject *li) { std::vector tmp; convertFromPyObjVectorOfObj(li,SWIGTYPE_p_MEDCoupling__DataArrayDouble,"DataArrayDouble",tmp); return DataArrayDouble::Meld(tmp); } - PyObject *computeTupleIdsNearTuples(PyObject *pt, double eps) const throw(INTERP_KERNEL::Exception) + PyObject *computeTupleIdsNearTuples(PyObject *pt, double eps) const { double val; 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); - MCAuto inpu=DataArrayDouble::New(); inpu->useArray(pos,false,CPP_DEALLOC,nbTuples,nbComp); - DataArrayInt *c=0,*cI=0; + const double *pos=convertObjToPossibleCpp5_Safe2(pt,sw,val,a,aa,bb,msg,(int)nbComp,true,nbTuples); + MCAuto inpu=DataArrayDouble::New(); inpu->useArray(pos,false,DeallocType::CPP_DEALLOC,nbTuples,nbComp); + DataArrayIdType *c=0,*cI=0; self->computeTupleIdsNearTuples(inpu,eps,c,cI); 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 throw(INTERP_KERNEL::Exception) + 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; } - PyObject *__getitem__(PyObject *obj) throw(INTERP_KERNEL::Exception) + PyObject *__getitem__(PyObject *obj) { return DataArrayT__getitem(self,obj); } - DataArrayDouble *__setitem__(PyObject *obj, PyObject *value) throw(INTERP_KERNEL::Exception) + DataArrayDouble *__setitem__(PyObject *obj, PyObject *value) { return DataArrayT__setitem__(self,obj,value); } - DataArrayDouble *__neg__() const throw(INTERP_KERNEL::Exception) + DataArrayDouble *__neg__() const { return self->negate(); } - PyObject *__add__(PyObject *obj) throw(INTERP_KERNEL::Exception) + PyObject *__add__(PyObject *obj) { const char msg[]="Unexpected situation in DataArrayDouble.__add__ !"; double val; DataArrayDouble *a; DataArrayDoubleTuple *aa; std::vector bb; - int sw; + mcIdType sw; // #ifndef WITHOUT_AUTOFIELD void *argp; @@ -1484,7 +1660,7 @@ namespace MEDCoupling } case 4: { - MCAuto aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,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: @@ -1492,14 +1668,14 @@ namespace MEDCoupling } } - DataArrayDouble *__radd__(PyObject *obj) throw(INTERP_KERNEL::Exception) + DataArrayDouble *__radd__(PyObject *obj) { const char msg[]="Unexpected situation in __radd__ !"; double val; DataArrayDouble *a; DataArrayDoubleTuple *aa; std::vector bb; - int sw; + mcIdType sw; convertDoubleStarLikePyObjToCpp_2(obj,sw,val,a,aa,bb); switch(sw) { @@ -1516,27 +1692,27 @@ namespace MEDCoupling } case 4: { - MCAuto aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,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) throw(INTERP_KERNEL::Exception) + + PyObject *___iadd___(PyObject *trueSelf, PyObject *obj) { return DataArrayT_iadd(trueSelf,obj,self); } - PyObject *__sub__(PyObject *obj) throw(INTERP_KERNEL::Exception) + PyObject *__sub__(PyObject *obj) { const char msg[]="Unexpected situation in __sub__ !"; double val; DataArrayDouble *a; DataArrayDoubleTuple *aa; std::vector bb; - int sw; + mcIdType sw; // #ifndef WITHOUT_AUTOFIELD void *argp; @@ -1575,7 +1751,7 @@ namespace MEDCoupling } case 4: { - MCAuto aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,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: @@ -1583,14 +1759,14 @@ namespace MEDCoupling } } - DataArrayDouble *__rsub__(PyObject *obj) throw(INTERP_KERNEL::Exception) + DataArrayDouble *__rsub__(PyObject *obj) { const char msg[]="Unexpected situation in __rsub__ !"; double val; DataArrayDouble *a; DataArrayDoubleTuple *aa; std::vector bb; - int sw; + mcIdType sw; convertDoubleStarLikePyObjToCpp_2(obj,sw,val,a,aa,bb); switch(sw) { @@ -1607,7 +1783,7 @@ namespace MEDCoupling } case 4: { - MCAuto aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,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: @@ -1615,19 +1791,19 @@ namespace MEDCoupling } } - PyObject *___isub___(PyObject *trueSelf, PyObject *obj) throw(INTERP_KERNEL::Exception) + PyObject *___isub___(PyObject *trueSelf, PyObject *obj) { return DataArrayT_isub(trueSelf,obj,self); } - PyObject *__mul__(PyObject *obj) throw(INTERP_KERNEL::Exception) + PyObject *__mul__(PyObject *obj) { const char msg[]="Unexpected situation in __mul__ !"; double val; DataArrayDouble *a; DataArrayDoubleTuple *aa; std::vector bb; - int sw; + mcIdType sw; // #ifndef WITHOUT_AUTOFIELD void *argp; @@ -1666,7 +1842,7 @@ namespace MEDCoupling } case 4: { - MCAuto aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,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: @@ -1674,51 +1850,24 @@ namespace MEDCoupling } } - DataArrayDouble *__rmul__(PyObject *obj) throw(INTERP_KERNEL::Exception) + DataArrayDouble *__rmul__(PyObject *obj) { - const char msg[]="Unexpected situation in __rmul__ !"; - double val; - DataArrayDouble *a; - DataArrayDoubleTuple *aa; - std::vector bb; - int sw; - convertDoubleStarLikePyObjToCpp_2(obj,sw,val,a,aa,bb); - switch(sw) - { - case 1: - { - MCAuto ret=self->deepCopy(); - ret->applyLin(val,0.); - return ret.retn(); - } - case 3: - { - MCAuto aaa=aa->buildDADouble(1,self->getNumberOfComponents()); - return DataArrayDouble::Multiply(self,aaa); - } - case 4: - { - MCAuto aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,CPP_DEALLOC,1,(int)bb.size()); - return DataArrayDouble::Multiply(self,aaa); - } - default: - throw INTERP_KERNEL::Exception(msg); - } + return DataArrayFPT_rmul(self,obj); } - PyObject *___imul___(PyObject *trueSelf, PyObject *obj) throw(INTERP_KERNEL::Exception) + PyObject *___imul___(PyObject *trueSelf, PyObject *obj) { return DataArrayT_imul(trueSelf,obj,self); } - PyObject *__div__(PyObject *obj) throw(INTERP_KERNEL::Exception) + PyObject *__div__(PyObject *obj) { const char msg[]="Unexpected situation in __div__ !"; double val; DataArrayDouble *a; DataArrayDoubleTuple *aa; std::vector bb; - int sw; + mcIdType sw; // #ifndef WITHOUT_AUTOFIELD void *argp; @@ -1759,7 +1908,7 @@ namespace MEDCoupling } case 4: { - MCAuto aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,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: @@ -1767,14 +1916,14 @@ namespace MEDCoupling } } - DataArrayDouble *__rdiv__(PyObject *obj) throw(INTERP_KERNEL::Exception) + DataArrayDouble *__rdiv__(PyObject *obj) { const char msg[]="Unexpected situation in __rdiv__ !"; double val; DataArrayDouble *a; DataArrayDoubleTuple *aa; std::vector bb; - int sw; + mcIdType sw; convertDoubleStarLikePyObjToCpp_2(obj,sw,val,a,aa,bb); switch(sw) { @@ -1791,7 +1940,7 @@ namespace MEDCoupling } case 4: { - MCAuto aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,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: @@ -1799,19 +1948,19 @@ namespace MEDCoupling } } - PyObject *___idiv___(PyObject *trueSelf, PyObject *obj) throw(INTERP_KERNEL::Exception) + PyObject *___idiv___(PyObject *trueSelf, PyObject *obj) { return DataArrayT_idiv(trueSelf,obj,self); } - - DataArrayDouble *__pow__(PyObject *obj) throw(INTERP_KERNEL::Exception) + + DataArrayDouble *__pow__(PyObject *obj) { const char msg[]="Unexpected situation in __pow__ !"; double val; DataArrayDouble *a; DataArrayDoubleTuple *aa; std::vector bb; - int sw; + mcIdType sw; convertDoubleStarLikePyObjToCpp_2(obj,sw,val,a,aa,bb); switch(sw) { @@ -1832,7 +1981,7 @@ namespace MEDCoupling } case 4: { - MCAuto aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,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: @@ -1840,14 +1989,14 @@ namespace MEDCoupling } } - DataArrayDouble *__rpow__(PyObject *obj) throw(INTERP_KERNEL::Exception) + DataArrayDouble *__rpow__(PyObject *obj) { const char msg[]="Unexpected situation in __rpow__ !"; double val; DataArrayDouble *a; DataArrayDoubleTuple *aa; std::vector bb; - int sw; + mcIdType sw; convertDoubleStarLikePyObjToCpp_2(obj,sw,val,a,aa,bb); switch(sw) { @@ -1864,7 +2013,7 @@ namespace MEDCoupling } case 4: { - MCAuto aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,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: @@ -1872,14 +2021,14 @@ namespace MEDCoupling } } - PyObject *___ipow___(PyObject *trueSelf, PyObject *obj) throw(INTERP_KERNEL::Exception) + PyObject *___ipow___(PyObject *trueSelf, PyObject *obj) { const char msg[]="Unexpected situation in __ipow__ !"; double val; DataArrayDouble *a; DataArrayDoubleTuple *aa; std::vector bb; - int sw; + mcIdType sw; convertDoubleStarLikePyObjToCpp_2(obj,sw,val,a,aa,bb); switch(sw) { @@ -1904,7 +2053,7 @@ namespace MEDCoupling } case 4: { - MCAuto aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,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; @@ -1913,51 +2062,26 @@ 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 throw(INTERP_KERNEL::Exception) + 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 )); - return ret; - } - - // serialization - static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception) - { - return NewMethWrapCallInitOnlyIfDictWithSingleEltInInput(cls,args,"DataArrayDouble"); - } - - PyObject *__getnewargs__() throw(INTERP_KERNEL::Exception) - { -#ifdef WITH_NUMPY - if(!self->isAllocated()) - throw INTERP_KERNEL::Exception("PyWrap of DataArrayDouble.__getnewargs__ : self is not allocated !"); - PyObject *ret(PyTuple_New(1)); - PyObject *ret0(PyDict_New()); - PyObject *numpyArryObj(MEDCoupling_DataArrayDouble_toNumPyArray(self)); - {// create a dict to discriminite in __new__ if __init__ should be called. Not beautiful but not idea ... - PyObject *tmp1(PyInt_FromLong(0)); - PyDict_SetItem(ret0,tmp1,numpyArryObj); Py_DECREF(tmp1); Py_DECREF(numpyArryObj); - PyTuple_SetItem(ret,0,ret0); - } + PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTITraits::TI, SWIG_POINTER_OWN | 0 )); return ret; -#else - throw INTERP_KERNEL::Exception("PyWrap of DataArrayDouble.__getnewargs__ : not implemented because numpy is not active in your configuration ! No serialization/unserialization available without numpy !"); -#endif } } }; @@ -1988,42 +2112,42 @@ namespace MEDCoupling class DataArrayDoubleTuple { public: - int getNumberOfCompo() const throw(INTERP_KERNEL::Exception); - DataArrayDouble *buildDADouble(int nbOfTuples, int nbOfCompo) const throw(INTERP_KERNEL::Exception); + std::size_t getNumberOfCompo() const; + DataArrayDouble *buildDADouble(int nbOfTuples, int nbOfCompo) const; %extend { - std::string __str__() const throw(INTERP_KERNEL::Exception) + std::string __str__() const { return self->repr(); } - double __float__() const throw(INTERP_KERNEL::Exception) + double __float__() const { return self->doubleValue(); } - DataArrayDouble *buildDADouble() throw(INTERP_KERNEL::Exception) + DataArrayDouble *buildDADouble() { return self->buildDADouble(1,self->getNumberOfCompo()); } - PyObject *___iadd___(PyObject *trueSelf, PyObject *obj) throw(INTERP_KERNEL::Exception) + PyObject *___iadd___(PyObject *trueSelf, PyObject *obj) { MCAuto ret=self->buildDADouble(1,self->getNumberOfCompo()); MEDCoupling_DataArrayDouble____iadd___(ret,0,obj); Py_XINCREF(trueSelf); return trueSelf; } - - PyObject *___isub___(PyObject *trueSelf, PyObject *obj) throw(INTERP_KERNEL::Exception) + + PyObject *___isub___(PyObject *trueSelf, PyObject *obj) { MCAuto ret=self->buildDADouble(1,self->getNumberOfCompo()); MEDCoupling_DataArrayDouble____isub___(ret,0,obj); Py_XINCREF(trueSelf); return trueSelf; } - - PyObject *___imul___(PyObject *trueSelf, PyObject *obj) throw(INTERP_KERNEL::Exception) + + PyObject *___imul___(PyObject *trueSelf, PyObject *obj) { MCAuto ret=self->buildDADouble(1,self->getNumberOfCompo()); MEDCoupling_DataArrayDouble____imul___(ret,0,obj); @@ -2031,7 +2155,7 @@ namespace MEDCoupling return trueSelf; } - PyObject *___idiv___(PyObject *trueSelf, PyObject *obj) throw(INTERP_KERNEL::Exception) + PyObject *___idiv___(PyObject *trueSelf, PyObject *obj) { MCAuto ret=self->buildDADouble(1,self->getNumberOfCompo()); MEDCoupling_DataArrayDouble____idiv___(ret,0,obj); @@ -2039,21 +2163,21 @@ namespace MEDCoupling return trueSelf; } - PyObject *__len__() throw(INTERP_KERNEL::Exception) + PyObject *__len__() { return PyInt_FromLong(self->getNumberOfCompo()); } - PyObject *__getitem__(PyObject *obj) throw(INTERP_KERNEL::Exception) + 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) { @@ -2083,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; @@ -2098,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) @@ -2168,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) { @@ -2188,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; @@ -2204,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() << " !"; @@ -2219,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& tupl) const throw(INTERP_KERNEL::Exception); - int findIdFirstEqual(int value) const throw(INTERP_KERNEL::Exception); - int findIdFirstEqual(const std::vector& vals) const throw(INTERP_KERNEL::Exception); - int findIdSequence(const std::vector& vals) const throw(INTERP_KERNEL::Exception); - bool presenceOfTuple(const std::vector& tupl) const throw(INTERP_KERNEL::Exception); - bool presenceOfValue(int value) const throw(INTERP_KERNEL::Exception); - bool presenceOfValue(const std::vector& vals) const throw(INTERP_KERNEL::Exception); - int count(int value) const throw(INTERP_KERNEL::Exception); - int accumulate(int compId) const throw(INTERP_KERNEL::Exception); - int getMaxValue(int& tupleId) const throw(INTERP_KERNEL::Exception); - int getMaxValueInArray() const throw(INTERP_KERNEL::Exception); - int getMinValue(int& tupleId) const throw(INTERP_KERNEL::Exception); - int getMinValueInArray() const throw(INTERP_KERNEL::Exception); - void abs() throw(INTERP_KERNEL::Exception); - DataArrayInt *computeAbs() const throw(INTERP_KERNEL::Exception); - void applyLin(int a, int b, int compoId) throw(INTERP_KERNEL::Exception); - void applyLin(int a, int b) throw(INTERP_KERNEL::Exception); - void applyInv(int numerator) throw(INTERP_KERNEL::Exception); - DataArrayInt *negate() const throw(INTERP_KERNEL::Exception); - void applyDivideBy(int val) throw(INTERP_KERNEL::Exception); - void applyModulus(int val) throw(INTERP_KERNEL::Exception); - void applyRModulus(int val) throw(INTERP_KERNEL::Exception); - void applyPow(int val) throw(INTERP_KERNEL::Exception); - void applyRPow(int val) throw(INTERP_KERNEL::Exception); - DataArrayInt *findIdsInRange(int vmin, int vmax) const throw(INTERP_KERNEL::Exception); - DataArrayInt *findIdsNotInRange(int vmin, int vmax) const throw(INTERP_KERNEL::Exception); - DataArrayInt *findIdsStricltyNegative() const throw(INTERP_KERNEL::Exception); - bool checkAllIdsInRange(int vmin, int vmax) const throw(INTERP_KERNEL::Exception); - static DataArrayInt *Aggregate(const DataArrayInt *a1, const DataArrayInt *a2, int offsetA2) throw(INTERP_KERNEL::Exception); - static DataArrayInt *Meld(const DataArrayInt *a1, const DataArrayInt *a2) throw(INTERP_KERNEL::Exception); - static DataArrayInt *MakePartition(const std::vector& groups, int newNb, std::vector< std::vector >& fidsOfGroups) throw(INTERP_KERNEL::Exception); - static DataArrayInt *BuildUnion(const std::vector& arr) throw(INTERP_KERNEL::Exception); - static DataArrayInt *BuildIntersection(const std::vector& arr) throw(INTERP_KERNEL::Exception); - static DataArrayInt *FindPermutationFromFirstToSecond(const DataArrayInt *ids1, const DataArrayInt *ids2) throw(INTERP_KERNEL::Exception); - DataArrayInt *buildComplement(int nbOfElement) const throw(INTERP_KERNEL::Exception); - DataArrayInt *buildSubstraction(const DataArrayInt *other) const throw(INTERP_KERNEL::Exception); - DataArrayInt *buildSubstractionOptimized(const DataArrayInt *other) const throw(INTERP_KERNEL::Exception); - DataArrayInt *buildUnion(const DataArrayInt *other) const throw(INTERP_KERNEL::Exception); - DataArrayInt *buildIntersection(const DataArrayInt *other) const throw(INTERP_KERNEL::Exception); - DataArrayInt *buildUnique() const throw(INTERP_KERNEL::Exception); - DataArrayInt *buildUniqueNotSorted() const throw(INTERP_KERNEL::Exception); - DataArrayInt *deltaShiftIndex() const throw(INTERP_KERNEL::Exception); - void computeOffsets() throw(INTERP_KERNEL::Exception); - void computeOffsetsFull() throw(INTERP_KERNEL::Exception); - DataArrayInt *buildExplicitArrByRanges(const DataArrayInt *offsets) const throw(INTERP_KERNEL::Exception); - DataArrayInt *findRangeIdForEachTuple(const DataArrayInt *ranges) const throw(INTERP_KERNEL::Exception); - DataArrayInt *findIdInRangeForEachTuple(const DataArrayInt *ranges) const throw(INTERP_KERNEL::Exception); - void sortEachPairToMakeALinkedList() throw(INTERP_KERNEL::Exception); - DataArrayInt *duplicateEachTupleNTimes(int nbTimes) const throw(INTERP_KERNEL::Exception); - DataArrayInt *getDifferentValues() const throw(INTERP_KERNEL::Exception); - static DataArrayInt *Add(const DataArrayInt *a1, const DataArrayInt *a2) throw(INTERP_KERNEL::Exception); - void addEqual(const DataArrayInt *other) throw(INTERP_KERNEL::Exception); - static DataArrayInt *Substract(const DataArrayInt *a1, const DataArrayInt *a2) throw(INTERP_KERNEL::Exception); - void substractEqual(const DataArrayInt *other) throw(INTERP_KERNEL::Exception); - static DataArrayInt *Multiply(const DataArrayInt *a1, const DataArrayInt *a2) throw(INTERP_KERNEL::Exception); - void multiplyEqual(const DataArrayInt *other) throw(INTERP_KERNEL::Exception); - static DataArrayInt *Divide(const DataArrayInt *a1, const DataArrayInt *a2) throw(INTERP_KERNEL::Exception); - void divideEqual(const DataArrayInt *other) throw(INTERP_KERNEL::Exception); - static DataArrayInt *Modulus(const DataArrayInt *a1, const DataArrayInt *a2) throw(INTERP_KERNEL::Exception); - void modulusEqual(const DataArrayInt *other) throw(INTERP_KERNEL::Exception); - static DataArrayInt *Pow(const DataArrayInt *a1, const DataArrayInt *a2) throw(INTERP_KERNEL::Exception); - void powEqual(const DataArrayInt *other) throw(INTERP_KERNEL::Exception); - public: - static DataArrayInt *Range(int begin, int end, int step) throw(INTERP_KERNEL::Exception); + virtual DataArrayChar *buildEmptySpecializedDAChar() const; + int getHashCode() const; + bool empty() const; + void deepCopyFrom(const DataArrayChar& other); + void reserve(std::size_t nbOfElems); + void pushBackSilent(char val); + char popBackSilent(); + void pack() const; + void allocIfNecessary(int nbOfTuple, int nbOfCompo); + bool isEqual(const DataArrayChar& other) const; + bool isEqualWithoutConsideringStr(const DataArrayChar& other) const; + void reverse(); + void fillWithZero(); + void fillWithValue(char val); + std::string repr() const; + std::string reprZip() 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 { - DataArrayInt() throw(INTERP_KERNEL::Exception) - { - return DataArrayInt::New(); - } - - static DataArrayInt *New(PyObject *elt0, PyObject *nbOfTuples=0, PyObject *nbOfComp=0) throw(INTERP_KERNEL::Exception) + mcIdType __len__() const { - 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+=" !"; - if(PyList_Check(elt0) || PyTuple_Check(elt0)) + if(self->isAllocated()) { - if(nbOfTuples) - { - if(PyInt_Check(nbOfTuples)) - { - int nbOfTuples1=PyInt_AS_LONG(nbOfTuples); - if(nbOfTuples1<0) - throw INTERP_KERNEL::Exception("DataArrayInt::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); - 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); - ret->alloc(nbOfTuples1,nbOfCompo); std::copy(tmp.begin(),tmp.end(),ret->getPointer()); - return ret.retn(); - } - else - throw INTERP_KERNEL::Exception(msg.c_str()); - } - else - {//DataArrayInt.New([1,3,4],3) - MCAuto ret=DataArrayInt::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.c_str()); - } - else - {// DataArrayInt.New([1,3,4]) - MCAuto ret=DataArrayInt::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(); - } + return self->getNumberOfTuples(); } - else if(PyInt_Check(elt0)) + else { - int nbOfTuples1=PyInt_AS_LONG(elt0); - if(nbOfTuples1<0) - throw INTERP_KERNEL::Exception("DataArrayInt::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); - if(nbOfCompo<0) - throw INTERP_KERNEL::Exception("DataArrayInt::New : should be a positive number of components !"); - MCAuto ret=DataArrayInt::New(); - ret->alloc(nbOfTuples1,nbOfCompo); - return ret.retn(); - } - else - throw INTERP_KERNEL::Exception(msg.c_str()); - } - else - throw INTERP_KERNEL::Exception(msg.c_str()); - } - else - {//DataArrayInt.New(5) - MCAuto ret=DataArrayInt::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"); + throw INTERP_KERNEL::Exception("DataArrayChar::__len__ : Instance is NOT allocated !"); } -#endif - else - throw INTERP_KERNEL::Exception(msg.c_str()); - throw INTERP_KERNEL::Exception(msg.c_str());//to make g++ happy - } - - DataArrayInt(PyObject *elt0, PyObject *nbOfTuples=0, PyObject *nbOfComp=0) throw(INTERP_KERNEL::Exception) - { - return MEDCoupling_DataArrayInt_New__SWIG_1(elt0,nbOfTuples,nbOfComp); - } - - DataArrayDouble *convertToDblArr() const throw(INTERP_KERNEL::Exception) - { - MCAuto ret(self->convertToDblArr()); - return ret.retn(); - } - - DataArrayFloat *convertToFloatArr() const throw(INTERP_KERNEL::Exception) - { - MCAuto ret(self->convertToFloatArr()); - return ret.retn(); } - std::string __str__() const throw(INTERP_KERNEL::Exception) + PyObject *isEqualIfNotWhy(const DataArrayChar& other) const { - return self->reprNotTooLong(); + 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; } - int __len__() const throw(INTERP_KERNEL::Exception) + DataArrayChar *renumber(PyObject *li) { - if(self->isAllocated()) + void *da=0; + int res1=SWIG_ConvertPtr(li,&da,SWIGTITraits::TI, 0 | 0 ); + if (!SWIG_IsOK(res1)) { - return self->getNumberOfTuples(); + 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 { - throw INTERP_KERNEL::Exception("DataArrayInt::__len__ : Instance is NOT allocated !"); + 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()); } } - int __int__() const throw(INTERP_KERNEL::Exception) - { - return self->intValue(); - } - - DataArrayIntIterator *__iter__() throw(INTERP_KERNEL::Exception) - { - return self->iterator(); - } - - DataArrayInt *fromLinkedListOfPairToList() const throw(INTERP_KERNEL::Exception) - { - MCAuto ret(self->fromLinkedListOfPairToList()); - return ret.retn(); - } - - DataArrayInt *findIdsGreaterOrEqualTo(int val) const throw(INTERP_KERNEL::Exception) - { - MCAuto ret(self->findIdsGreaterOrEqualTo(val)); - return ret.retn(); - } - - DataArrayInt *findIdsGreaterThan(int val) const throw(INTERP_KERNEL::Exception) - { - MCAuto ret(self->findIdsGreaterThan(val)); - return ret.retn(); - } - - DataArrayInt *findIdsLowerOrEqualTo(int val) const throw(INTERP_KERNEL::Exception) - { - MCAuto ret(self->findIdsLowerOrEqualTo(val)); - return ret.retn(); - } - - DataArrayInt *findIdsLowerThan(int val) const throw(INTERP_KERNEL::Exception) - { - MCAuto ret(self->findIdsLowerThan(val)); - return ret.retn(); - } - - DataArrayInt *selectPartDef(const PartDefinition* pd) const throw(INTERP_KERNEL::Exception) - { - MCAuto ret(self->selectPartDef(pd)); - return ret.retn(); - } - - PyObject *accumulate() const throw(INTERP_KERNEL::Exception) - { - int sz=self->getNumberOfComponents(); - INTERP_KERNEL::AutoPtr tmp=new int[sz]; - self->accumulate(tmp); - return convertIntArrToPyList(tmp,sz); - } - - DataArrayInt *accumulatePerChunck(PyObject *indexArr) const throw(INTERP_KERNEL::Exception) - { - int sw,sz,val; - std::vector val2; - const int *bg=convertIntStarLikePyObjToCppIntStar(indexArr,sw,sz,val,val2); - return self->accumulatePerChunck(bg,bg+sz); - } - - DataArrayInt *findIdsEqualTuple(PyObject *inputTuple) const throw(INTERP_KERNEL::Exception) - { - int sw,sz,val; - std::vector val2; - const int *bg(convertIntStarLikePyObjToCppIntStar(inputTuple,sw,sz,val,val2)); - return self->findIdsEqualTuple(bg,bg+sz); - } - - PyObject *splitInBalancedSlices(int nbOfSlices) const throw(INTERP_KERNEL::Exception) - { - std::vector< std::pair > slcs(self->splitInBalancedSlices(nbOfSlices)); - PyObject *ret=PyList_New(slcs.size()); - for(std::size_t i=0;i(slic); - GetIndicesOfSliceExplicitely(sly,&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); - } - - PyObject *getMinMaxValues() const throw(INTERP_KERNEL::Exception) - { - 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) throw(INTERP_KERNEL::Exception) - { - 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) throw(INTERP_KERNEL::Exception) - { - 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::C_DEALLOC,szArr,1); - return ret.retn(); - } - - void setValues(PyObject *li, PyObject *nbOfTuples=0, PyObject *nbOfComp=0) throw(INTERP_KERNEL::Exception) - { - 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(nbOfTuples<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 throw(INTERP_KERNEL::Exception) - { - const int *vals=self->getConstPointer(); - return convertIntArrToPyList(vals,self->getNbOfElems()); - } - -#ifdef WITH_NUMPY - PyObject *toNumPyArray() throw(INTERP_KERNEL::Exception) // not const. It is not a bug ! - { - return ToNumPyArray(self,NPY_INT32,"DataArrayInt"); - } -#endif - - PyObject *isEqualIfNotWhy(const DataArrayInt& other) const throw(INTERP_KERNEL::Exception) - { - 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 throw(INTERP_KERNEL::Exception) - { - 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) throw(INTERP_KERNEL::Exception) - { - 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 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) throw(INTERP_KERNEL::Exception) - { - 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) throw(INTERP_KERNEL::Exception) - { - 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 throw(INTERP_KERNEL::Exception) - { - 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 throw(INTERP_KERNEL::Exception) - { - 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) throw(INTERP_KERNEL::Exception) - { - 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) throw(INTERP_KERNEL::Exception) - { - 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) throw(INTERP_KERNEL::Exception) - { - 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) throw(INTERP_KERNEL::Exception) - { - std::vector tmp; - convertPyToNewIntArr3(li,tmp); - self->setSelectedComponents(a,tmp); - } - - PyObject *explodeComponents() const throw(INTERP_KERNEL::Exception) - { - 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 throw(INTERP_KERNEL::Exception) - { - 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) throw(INTERP_KERNEL::Exception) - { - std::vector tmp; - convertFromPyObjVectorOfObj(li,SWIGTYPE_p_MEDCoupling__DataArrayInt,"DataArrayInt",tmp); - return DataArrayInt::Meld(tmp); - } - - static DataArrayInt *Aggregate(PyObject *li) throw(INTERP_KERNEL::Exception) - { - std::vector tmp; - convertFromPyObjVectorOfObj(li,SWIGTYPE_p_MEDCoupling__DataArrayInt,"DataArrayInt",tmp); - return DataArrayInt::Aggregate(tmp); - } - - static DataArrayInt *AggregateIndexes(PyObject *li) throw(INTERP_KERNEL::Exception) - { - std::vector tmp; - convertFromPyObjVectorOfObj(li,SWIGTYPE_p_MEDCoupling__DataArrayInt,"DataArrayInt",tmp); - return DataArrayInt::AggregateIndexes(tmp); - } - - static DataArrayInt *BuildUnion(PyObject *li) throw(INTERP_KERNEL::Exception) - { - std::vector tmp; - convertFromPyObjVectorOfObj(li,SWIGTYPE_p_MEDCoupling__DataArrayInt,"DataArrayInt",tmp); - return DataArrayInt::BuildUnion(tmp); - } - - static DataArrayInt *BuildIntersection(PyObject *li) throw(INTERP_KERNEL::Exception) - { - std::vector tmp; - convertFromPyObjVectorOfObj(li,SWIGTYPE_p_MEDCoupling__DataArrayInt,"DataArrayInt",tmp); - return DataArrayInt::BuildIntersection(tmp); - } - - PyObject *getMaxValue() const throw(INTERP_KERNEL::Exception) - { - 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 *getMinValue() const throw(INTERP_KERNEL::Exception) - { - 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 throw(INTERP_KERNEL::Exception) - { - 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 throw(INTERP_KERNEL::Exception) - { - 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) throw(INTERP_KERNEL::Exception) - { - const char msg[]="Unexpected situation in DataArrayInt::__getitem__ !"; - const char msg2[]="DataArrayInt::__getitem__ : Mismatch of slice values in 2nd parameter (components) !"; - self->checkAllocated(); - int nbOfTuples=self->getNumberOfTuples(); - int nbOfComponents=self->getNumberOfComponents(); - 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) throw(INTERP_KERNEL::Exception) - { - 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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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 throw(INTERP_KERNEL::Exception) - { - return self->negate(); - } - - DataArrayInt *__add__(PyObject *obj) throw(INTERP_KERNEL::Exception) - { - 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,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) throw(INTERP_KERNEL::Exception) - { - 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,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) throw(INTERP_KERNEL::Exception) - { - 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,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) throw(INTERP_KERNEL::Exception) - { - 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,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) throw(INTERP_KERNEL::Exception) - { - 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,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) throw(INTERP_KERNEL::Exception) - { - 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,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) throw(INTERP_KERNEL::Exception) - { - 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,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) throw(INTERP_KERNEL::Exception) - { - 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,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) throw(INTERP_KERNEL::Exception) - { - 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,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) throw(INTERP_KERNEL::Exception) - { - 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,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) throw(INTERP_KERNEL::Exception) - { - 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,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) throw(INTERP_KERNEL::Exception) - { - 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,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) throw(INTERP_KERNEL::Exception) - { - 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,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) throw(INTERP_KERNEL::Exception) - { - 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,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) throw(INTERP_KERNEL::Exception) - { - 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) throw(INTERP_KERNEL::Exception) - { - 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,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) throw(INTERP_KERNEL::Exception) - { - 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,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) throw(INTERP_KERNEL::Exception) - { - 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 throw(INTERP_KERNEL::Exception) - { - std::ostringstream oss; - self->reprQuickOverview(oss); - return oss.str(); - } - - void pushBackValsSilent(PyObject *li) throw(INTERP_KERNEL::Exception) - { - int szArr,sw,iTypppArr; - std::vector stdvecTyyppArr; - const int *tmp=convertIntStarLikePyObjToCppIntStar(li,sw,szArr,iTypppArr,stdvecTyyppArr); - self->pushBackValsSilent(tmp,tmp+szArr); - } - - PyObject *partitionByDifferentValues() const throw(INTERP_KERNEL::Exception) - { - 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 throw(INTERP_KERNEL::Exception) - { - 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; - } - - // serialization - static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception) - { - return NewMethWrapCallInitOnlyIfDictWithSingleEltInInput(cls,args,"DataArrayInt"); - } - - PyObject *__getnewargs__() throw(INTERP_KERNEL::Exception) - { -#ifdef WITH_NUMPY - if(!self->isAllocated()) - throw INTERP_KERNEL::Exception("PyWrap of DataArrayInt.__getnewargs__ : self is not allocated !"); - PyObject *ret(PyTuple_New(1)); - PyObject *ret0(PyDict_New()); - PyObject *numpyArryObj(MEDCoupling_DataArrayInt_toNumPyArray(self)); - {// create a dict to discriminite in __new__ if __init__ should be called. Not beautiful but not idea ... - PyObject *tmp1(PyInt_FromLong(0)); - PyDict_SetItem(ret0,tmp1,numpyArryObj); Py_DECREF(tmp1); Py_DECREF(numpyArryObj); - PyTuple_SetItem(ret,0,ret0); - } - return ret; -#else - throw INTERP_KERNEL::Exception("PyWrap of DataArrayInt.__getnewargs__ : not implemented because numpy is not active in your configuration ! No serialization/unserialization available without numpy !"); -#endif - } - } - }; - - 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 throw(INTERP_KERNEL::Exception); - DataArrayInt *buildDAInt(int nbOfTuples, int nbOfCompo) const throw(INTERP_KERNEL::Exception); - %extend - { - std::string __str__() const throw(INTERP_KERNEL::Exception) - { - return self->repr(); - } - - int __int__() const throw(INTERP_KERNEL::Exception) - { - return self->intValue(); - } - - DataArrayInt *buildDAInt() throw(INTERP_KERNEL::Exception) - { - return self->buildDAInt(1,self->getNumberOfCompo()); - } - - PyObject *___iadd___(PyObject *trueSelf, PyObject *obj) throw(INTERP_KERNEL::Exception) - { - MCAuto ret=self->buildDAInt(1,self->getNumberOfCompo()); - MEDCoupling_DataArrayInt____iadd___(ret,0,obj); - Py_XINCREF(trueSelf); - return trueSelf; - } - - PyObject *___isub___(PyObject *trueSelf, PyObject *obj) throw(INTERP_KERNEL::Exception) - { - MCAuto ret=self->buildDAInt(1,self->getNumberOfCompo()); - MEDCoupling_DataArrayInt____isub___(ret,0,obj); - Py_XINCREF(trueSelf); - return trueSelf; - } - - PyObject *___imul___(PyObject *trueSelf, PyObject *obj) throw(INTERP_KERNEL::Exception) - { - MCAuto ret=self->buildDAInt(1,self->getNumberOfCompo()); - MEDCoupling_DataArrayInt____imul___(ret,0,obj); - Py_XINCREF(trueSelf); - return trueSelf; - } - - PyObject *___idiv___(PyObject *trueSelf, PyObject *obj) throw(INTERP_KERNEL::Exception) - { - MCAuto ret=self->buildDAInt(1,self->getNumberOfCompo()); - MEDCoupling_DataArrayInt____idiv___(ret,0,obj); - Py_XINCREF(trueSelf); - return trueSelf; - } - - PyObject *___imod___(PyObject *trueSelf, PyObject *obj) throw(INTERP_KERNEL::Exception) - { - MCAuto ret=self->buildDAInt(1,self->getNumberOfCompo()); - MEDCoupling_DataArrayInt____imod___(ret,0,obj); - Py_XINCREF(trueSelf); - return trueSelf; - } - - PyObject *__len__() throw(INTERP_KERNEL::Exception) - { - return PyInt_FromLong(self->getNumberOfCompo()); - } - - PyObject *__getitem__(PyObject *obj) throw(INTERP_KERNEL::Exception) - { - 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 throw(INTERP_KERNEL::Exception); - bool presenceOfTuple(const std::vector& tupl) const throw(INTERP_KERNEL::Exception); - char getMaxValue(int& tupleId) const throw(INTERP_KERNEL::Exception); - char getMaxValueInArray() const throw(INTERP_KERNEL::Exception); - char getMinValue(int& tupleId) const throw(INTERP_KERNEL::Exception); - char getMinValueInArray() const throw(INTERP_KERNEL::Exception); - DataArrayInt *findIdsInRange(char vmin, char vmax) const throw(INTERP_KERNEL::Exception); - static DataArrayChar *Aggregate(const DataArrayChar *a1, const DataArrayChar *a2) throw(INTERP_KERNEL::Exception); - static DataArrayChar *Meld(const DataArrayChar *a1, const DataArrayChar *a2) throw(INTERP_KERNEL::Exception); - %extend - { - int __len__() const throw(INTERP_KERNEL::Exception) - { - if(self->isAllocated()) - { - return self->getNumberOfTuples(); - } - else - { - throw INTERP_KERNEL::Exception("DataArrayChar::__len__ : Instance is NOT allocated !"); - } - } - - PyObject *isEqualIfNotWhy(const DataArrayChar& other) const throw(INTERP_KERNEL::Exception) - { - 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) throw(INTERP_KERNEL::Exception) - { - 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) throw(INTERP_KERNEL::Exception) + DataArrayChar *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 !"); @@ -4777,11 +2504,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 !"); + throw INTERP_KERNEL::Exception("Not null DataArrayIdType 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 !"); @@ -4789,15 +2516,15 @@ namespace MEDCoupling return self->renumberR(da2->getConstPointer()); } } - - DataArrayChar *renumberAndReduce(PyObject *li, int newNbOfTuple) throw(INTERP_KERNEL::Exception) + + DataArrayChar *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 !"); @@ -4806,11 +2533,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 !"); + throw INTERP_KERNEL::Exception("Not null DataArrayIdType 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 !"); @@ -4818,15 +2545,15 @@ namespace MEDCoupling return self->renumberAndReduce(da2->getConstPointer(),newNbOfTuple); } } - - static DataArrayChar *Aggregate(PyObject *dachs) throw(INTERP_KERNEL::Exception) + + 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) throw(INTERP_KERNEL::Exception) + + static DataArrayChar *Meld(PyObject *dachs) { std::vector tmp; convertFromPyObjVectorOfObj(dachs,SWIGTYPE_p_MEDCoupling__DataArrayChar,"DataArrayChar",tmp); @@ -4834,24 +2561,24 @@ namespace MEDCoupling } } }; - + class DataArrayByteIterator; class DataArrayByte : public DataArrayChar { public: static DataArrayByte *New(); - DataArrayByteIterator *iterator() throw(INTERP_KERNEL::Exception); - DataArrayByte *performCopyOrIncrRef(bool deepCopy) const throw(INTERP_KERNEL::Exception); - char byteValue() const throw(INTERP_KERNEL::Exception); + DataArrayByteIterator *iterator(); + DataArrayByte *performCopyOrIncrRef(bool deepCopy) const; + char byteValue() const; %extend { - DataArrayByte() throw(INTERP_KERNEL::Exception) + DataArrayByte() { return DataArrayByte::New(); } - static DataArrayByte *New(PyObject *elt0, PyObject *nbOfTuples=0, PyObject *nbOfComp=0) throw(INTERP_KERNEL::Exception) + 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)) @@ -4860,18 +2587,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("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); + mcIdType nbOfCompo=ToIdType(PyInt_AS_LONG(nbOfComp)); if(nbOfCompo<0) throw INTERP_KERNEL::Exception("DataArrayByte::New : should be a positive number of components !"); MCAuto ret=DataArrayByte::New(); - 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(); } @@ -4881,8 +2608,8 @@ namespace MEDCoupling else {//DataArrayByte.New([1,3,4],3) MCAuto ret=DataArrayByte::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(); } @@ -4893,15 +2620,15 @@ namespace MEDCoupling else {// DataArrayByte.New([1,3,4]) MCAuto ret=DataArrayByte::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(); } } 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("DataArrayByte::New : should be a positive set of allocated memory !"); if(nbOfTuples) @@ -4910,7 +2637,7 @@ namespace MEDCoupling { if(PyInt_Check(nbOfTuples)) {//DataArrayByte.New(5,2) - int nbOfCompo=PyInt_AS_LONG(nbOfTuples); + mcIdType nbOfCompo=ToIdType(PyInt_AS_LONG(nbOfTuples)); if(nbOfCompo<0) throw INTERP_KERNEL::Exception("DataArrayByte::New : should be a positive number of components !"); MCAuto ret=DataArrayByte::New(); @@ -4940,141 +2667,141 @@ namespace MEDCoupling throw INTERP_KERNEL::Exception(msg); } - DataArrayByte(PyObject *elt0, PyObject *nbOfTuples=0, PyObject *nbOfComp=0) throw(INTERP_KERNEL::Exception) + DataArrayByte(PyObject *elt0, PyObject *nbOfTuples=0, PyObject *nbOfComp=0) { return MEDCoupling_DataArrayByte_New__SWIG_1(elt0,nbOfTuples,nbOfComp); } - - std::string __repr__() const throw(INTERP_KERNEL::Exception) + + std::string __repr__() const { std::ostringstream oss; self->reprQuickOverview(oss); return oss.str(); } - - int __int__() const throw(INTERP_KERNEL::Exception) + + int __int__() const { return (int) self->byteValue(); } - DataArrayByteIterator *__iter__() throw(INTERP_KERNEL::Exception) + DataArrayByteIterator *__iter__() { return self->iterator(); } - int getIJ(int tupleId, int compoId) const throw(INTERP_KERNEL::Exception) + mcIdType getIJ(mcIdType tupleId, mcIdType compoId) const { - return (int)self->getIJ(tupleId,compoId); + return (mcIdType)self->getIJ(tupleId,compoId); } - - int getIJSafe(int tupleId, int compoId) const throw(INTERP_KERNEL::Exception) + + mcIdType getIJSafe(mcIdType tupleId, mcIdType compoId) const { - return (int)self->getIJSafe(tupleId,compoId); + return (mcIdType)self->getIJSafe(tupleId,compoId); } - std::string __str__() const throw(INTERP_KERNEL::Exception) + std::string __str__() const { return self->repr(); } - PyObject *toStrList() const throw(INTERP_KERNEL::Exception) + 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 throw(INTERP_KERNEL::Exception) + + 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); + 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->presenceOfTuple(vals); } - bool presenceOfValue(PyObject *vals) const throw(INTERP_KERNEL::Exception) + 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); + 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); } - int findIdFirstEqual(PyObject *vals) const throw(INTERP_KERNEL::Exception) + mcIdType 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 throw(INTERP_KERNEL::Exception) + 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 throw(INTERP_KERNEL::Exception) + 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) throw(INTERP_KERNEL::Exception) + 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)); return ret; } - PyObject *getMinValue() const throw(INTERP_KERNEL::Exception) + 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 throw(INTERP_KERNEL::Exception) + 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 @@ -5085,9 +2812,9 @@ namespace MEDCoupling } } - bool __contains__(PyObject *obj) const throw(INTERP_KERNEL::Exception) + bool __contains__(PyObject *obj) const { - int nbOfCompo=self->getNumberOfComponents(); + std::size_t nbOfCompo=self->getNumberOfComponents(); switch(nbOfCompo) { case 0: @@ -5096,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 @@ -5106,56 +2833,33 @@ namespace MEDCoupling return MEDCoupling_DataArrayByte_presenceOfTuple(self,obj); } } - + #ifdef WITH_NUMPY - PyObject *toNumPyArray() throw(INTERP_KERNEL::Exception) // not const. It is not a bug ! + PyObject *toNumPyArray() // not const. It is not a bug ! { return ToNumPyArray(self,NPY_INT8,"DataArrayByte"); } #endif - // serialization - static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception) - { - return NewMethWrapCallInitOnlyIfDictWithSingleEltInInput(cls,args,"DataArrayByte"); - } - - PyObject *__getnewargs__() throw(INTERP_KERNEL::Exception) - { -#ifdef WITH_NUMPY - if(!self->isAllocated()) - throw INTERP_KERNEL::Exception("PyWrap of DataArrayByte.__getnewargs__ : self is not allocated !"); - PyObject *ret(PyTuple_New(1)); - PyObject *ret0(PyDict_New()); - PyObject *numpyArryObj(MEDCoupling_DataArrayByte_toNumPyArray(self)); - {// create a dict to discriminite in __new__ if __init__ should be called. Not beautiful but not idea ... - PyObject *tmp1(PyInt_FromLong(0)); - PyDict_SetItem(ret0,tmp1,numpyArryObj); Py_DECREF(tmp1); Py_DECREF(numpyArryObj); - PyTuple_SetItem(ret,0,ret0); - } - return ret; -#else - throw INTERP_KERNEL::Exception("PyWrap of DataArrayByte.__getnewargs__ : not implemented because numpy is not active in your configuration ! No serialization/unserialization available without numpy !"); -#endif - } - - DataArrayByte *__setitem__(PyObject *obj, PyObject *value) throw(INTERP_KERNEL::Exception) + DataArrayByte *__setitem__(PyObject *obj, PyObject *value) { 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: @@ -5370,44 +3074,44 @@ namespace MEDCoupling class DataArrayByteTuple { public: - std::string repr() const throw(INTERP_KERNEL::Exception); - DataArrayByte *buildDAByte(int nbOfTuples, int nbOfCompo) const throw(INTERP_KERNEL::Exception); + std::string repr() const; + DataArrayByte *buildDAByte(mcIdType nbOfTuples, mcIdType nbOfCompo) const; %extend { - std::string __str__() const throw(INTERP_KERNEL::Exception) + std::string __str__() const { return self->repr(); } - - char __int__() const throw(INTERP_KERNEL::Exception) + + char __int__() const { return self->byteValue(); } - - DataArrayByte *buildDAByte() throw(INTERP_KERNEL::Exception) + + DataArrayByte *buildDAByte() { return self->buildDAByte(1,self->getNumberOfCompo()); } } }; - + class DataArrayAsciiCharIterator; - + class DataArrayAsciiChar : public DataArrayChar { public: static DataArrayAsciiChar *New(); - DataArrayAsciiCharIterator *iterator() throw(INTERP_KERNEL::Exception); - DataArrayAsciiChar *performCopyOrIncrRef(bool deepCopy) const throw(INTERP_KERNEL::Exception); - char asciiCharValue() const throw(INTERP_KERNEL::Exception); + DataArrayAsciiCharIterator *iterator(); + DataArrayAsciiChar *performCopyOrIncrRef(bool deepCopy) const; + char asciiCharValue() const; %extend { - DataArrayAsciiChar() throw(INTERP_KERNEL::Exception) + DataArrayAsciiChar() { return DataArrayAsciiChar::New(); } - static DataArrayAsciiChar *New(PyObject *elt0, PyObject *nbOfTuples=0, PyObject *nbOfComp=0) throw(INTERP_KERNEL::Exception) + static DataArrayAsciiChar *New(PyObject *elt0, PyObject *nbOfTuples=0, PyObject *nbOfComp=0) { const char *msg="MEDCoupling::DataArrayAsciiChar::New : Available API are : \n-DataArrayAsciiChar.New()\n-DataArrayAsciiChar.New([1,3,4])\n-DataArrayAsciiChar.New([\"abc\",\"de\",\"fghi\"])\n-DataArrayAsciiChar.New([\"abc\",\"de\",\"fghi\"],\"t\")\n-DataArrayAsciiChar.New([1,3,4],3)\n-DataArrayAsciiChar.New([1,3,4,5],2,2)\n-DataArrayAsciiChar.New(5)\n-DataArrayAsciiChar.New(5,2) !"; if(PyList_Check(elt0) || PyTuple_Check(elt0)) @@ -5416,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(); } @@ -5437,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(); } @@ -5454,6 +3158,19 @@ namespace MEDCoupling else throw INTERP_KERNEL::Exception(msg); } +%#if PY_VERSION_HEX >= 0x03000000 + else if(PyUnicode_Check(nbOfTuples)) + { + if(PyUnicode_GET_LENGTH(nbOfTuples)!=1) + throw INTERP_KERNEL::Exception(msg); + //DataArrayAsciiChar.New(["abc","de","fghi"],"t") + std::vector tmp; + if(fillStringVector(elt0,tmp)) + return DataArrayAsciiChar::New(tmp,PyUnicode_AsUTF8(nbOfTuples)[0]); + else + throw INTERP_KERNEL::Exception(msg); + } +%#endif else throw INTERP_KERNEL::Exception(msg); } @@ -5467,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(); } @@ -5476,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) @@ -5485,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(); @@ -5509,51 +3226,51 @@ namespace MEDCoupling throw INTERP_KERNEL::Exception(msg); } - DataArrayAsciiChar(PyObject *elt0, PyObject *nbOfTuples=0, PyObject *nbOfComp=0) throw(INTERP_KERNEL::Exception) + DataArrayAsciiChar(PyObject *elt0, PyObject *nbOfTuples=0, PyObject *nbOfComp=0) { return MEDCoupling_DataArrayAsciiChar_New__SWIG_1(elt0,nbOfTuples,nbOfComp); } - std::string __repr__() const throw(INTERP_KERNEL::Exception) + std::string __repr__() const { std::ostringstream oss; self->reprQuickOverview(oss); return oss.str(); } - DataArrayAsciiCharIterator *__iter__() throw(INTERP_KERNEL::Exception) + DataArrayAsciiCharIterator *__iter__() { return self->iterator(); } - std::string getIJ(int tupleId, int compoId) const throw(INTERP_KERNEL::Exception) + 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 throw(INTERP_KERNEL::Exception) + + std::string getIJSafe(mcIdType tupleId, mcIdType compoId) const { char tmp[2]; tmp[1]='\0'; tmp[0]=self->getIJSafe(tupleId,compoId); return std::string(tmp); } - std::string __str__() const throw(INTERP_KERNEL::Exception) + std::string __str__() const { return self->repr(); } - PyObject *toStrList() const throw(INTERP_KERNEL::Exception) + 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 throw(INTERP_KERNEL::Exception) + bool presenceOfTuple(PyObject *tupl) const { if(PyString_Check(tupl)) { @@ -5562,11 +3279,20 @@ namespace MEDCoupling std::copy(PyString_AsString(tupl),PyString_AsString(tupl)+sz,vals.begin()); return self->presenceOfTuple(vals); } +%#if PY_VERSION_HEX >= 0x03000000 + else if(PyUnicode_Check(tupl)) + { + Py_ssize_t sz=PyUnicode_GET_LENGTH(tupl); + std::vector vals(sz); + std::copy(PyUnicode_AsUTF8(tupl),PyUnicode_AsUTF8(tupl)+sz,vals.begin()); + return self->presenceOfTuple(vals); + } +%#endif else throw INTERP_KERNEL::Exception("DataArrayAsciiChar::presenceOfTuple : only strings in input supported !"); } - - bool presenceOfValue(PyObject *vals) const throw(INTERP_KERNEL::Exception) + + bool presenceOfValue(PyObject *vals) const { if(PyString_Check(vals)) { @@ -5575,11 +3301,20 @@ namespace MEDCoupling std::copy(PyString_AsString(vals),PyString_AsString(vals)+sz,vals2.begin()); return self->presenceOfValue(vals2); } +%#if PY_VERSION_HEX >= 0x03000000 + if(PyUnicode_Check(vals)) + { + Py_ssize_t sz=PyUnicode_GET_LENGTH(vals); + std::vector vals2(sz); + std::copy(PyUnicode_AsUTF8(vals),PyUnicode_AsUTF8(vals)+sz,vals2.begin()); + return self->presenceOfValue(vals2); + } +%#endif else throw INTERP_KERNEL::Exception("DataArrayAsciiChar::presenceOfValue : only strings in input supported !"); } - int findIdFirstEqual(PyObject *vals) const throw(INTERP_KERNEL::Exception) + mcIdType findIdFirstEqual(PyObject *vals) const { if(PyString_Check(vals)) { @@ -5588,11 +3323,20 @@ namespace MEDCoupling std::copy(PyString_AsString(vals),PyString_AsString(vals)+sz,vals2.begin()); return self->findIdFirstEqual(vals2); } +%#if PY_VERSION_HEX >= 0x03000000 + if(PyUnicode_Check(vals)) + { + Py_ssize_t sz=PyUnicode_GET_LENGTH(vals); + std::vector vals2(sz); + std::copy(PyUnicode_AsUTF8(vals),PyUnicode_AsUTF8(vals)+sz,vals2.begin()); + return self->findIdFirstEqual(vals2); + } +%#endif else throw INTERP_KERNEL::Exception("DataArrayAsciiChar::findIdFirstEqual : only strings in input supported !"); } - int findIdFirstEqualTuple(PyObject *tupl) const throw(INTERP_KERNEL::Exception) + mcIdType findIdFirstEqualTuple(PyObject *tupl) const { if(PyString_Check(tupl)) { @@ -5601,11 +3345,20 @@ namespace MEDCoupling std::copy(PyString_AsString(tupl),PyString_AsString(tupl)+sz,vals.begin()); return self->findIdFirstEqualTuple(vals); } +%#if PY_VERSION_HEX >= 0x03000000 + if(PyUnicode_Check(tupl)) + { + Py_ssize_t sz=PyUnicode_GET_LENGTH(tupl); + std::vector vals(sz); + std::copy(PyUnicode_AsUTF8(tupl),PyUnicode_AsUTF8(tupl)+sz,vals.begin()); + return self->findIdFirstEqualTuple(vals); + } +%#endif else throw INTERP_KERNEL::Exception("DataArrayAsciiChar::findIdFirstEqualTuple : only strings in input supported !"); } - int findIdSequence(PyObject *strOrListOfInt) const throw(INTERP_KERNEL::Exception) + mcIdType findIdSequence(PyObject *strOrListOfInt) const { if(PyString_Check(strOrListOfInt)) { @@ -5614,21 +3367,30 @@ namespace MEDCoupling std::copy(PyString_AsString(strOrListOfInt),PyString_AsString(strOrListOfInt)+sz,vals.begin()); return self->findIdSequence(vals); } +%#if PY_VERSION_HEX >= 0x03000000 + else if(PyUnicode_Check(strOrListOfInt)) + { + Py_ssize_t sz=PyUnicode_GET_LENGTH(strOrListOfInt); + std::vector vals(sz); + std::copy(PyUnicode_AsUTF8(strOrListOfInt),PyUnicode_AsUTF8(strOrListOfInt)+sz,vals.begin()); + return self->findIdSequence(vals); + } +%#endif else throw INTERP_KERNEL::Exception("DataArrayAsciiChar::search : only strings in input supported !"); } - - PyObject *getTuple(int tupleId) const throw(INTERP_KERNEL::Exception) + + 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); } - PyObject *getMaxValue() const throw(INTERP_KERNEL::Exception) + PyObject *getMaxValue() const { - int tmp; + mcIdType tmp; char tmp2[2]; tmp2[1]='\0'; tmp2[0]=self->getMaxValue(tmp); PyObject *ret=PyTuple_New(2); @@ -5637,9 +3399,9 @@ namespace MEDCoupling return ret; } - PyObject *getMinValue() const throw(INTERP_KERNEL::Exception) + PyObject *getMinValue() const { - int tmp; + mcIdType tmp; char tmp2[2]; tmp2[1]='\0'; tmp2[0]=self->getMinValue(tmp); PyObject *ret=PyTuple_New(2); @@ -5648,9 +3410,9 @@ namespace MEDCoupling return ret; } - int index(PyObject *obj) const throw(INTERP_KERNEL::Exception) + mcIdType index(PyObject *obj) const { - int nbOfCompo=self->getNumberOfComponents(); + std::size_t nbOfCompo=self->getNumberOfComponents(); switch(nbOfCompo) { case 1: @@ -5664,6 +3426,17 @@ namespace MEDCoupling else throw INTERP_KERNEL::Exception("DataArrayAsciiChar::index : 'this' contains one component and trying to find a string with size different from 1 !"); } +%#if PY_VERSION_HEX >= 0x03000000 + if(PyUnicode_Check(obj)) + { + Py_ssize_t sz; + const char *pt=PyUnicode_AsUTF8AndSize(obj, &sz); + if(sz==1) + return self->findIdFirstEqual(pt[0]); + else + throw INTERP_KERNEL::Exception("DataArrayAsciiChar::index : 'this' contains one component and trying to find a string with size different from 1 !"); + } +%#endif else throw INTERP_KERNEL::Exception("DataArrayAsciiChar::index : 'this' contains one component and trying to find an element which is not an integer !"); } @@ -5672,9 +3445,9 @@ namespace MEDCoupling } } - bool __contains__(PyObject *obj) const throw(INTERP_KERNEL::Exception) + bool __contains__(PyObject *obj) const { - int nbOfCompo=self->getNumberOfComponents(); + std::size_t nbOfCompo=self->getNumberOfComponents(); switch(nbOfCompo) { case 0: @@ -5690,6 +3463,17 @@ namespace MEDCoupling else throw INTERP_KERNEL::Exception("DataArrayAsciiChar::__contains__ : 'this' contains one component and trying to find a string with size different from 1 !"); } +%#if PY_VERSION_HEX >= 0x03000000 + if(PyUnicode_Check(obj)) + { + Py_ssize_t sz; + const char *pt=PyUnicode_AsUTF8AndSize(obj, &sz); + if(sz==1) + return self->presenceOfValue(pt[0]); + else + throw INTERP_KERNEL::Exception("DataArrayAsciiChar::__contains__ : 'this' contains one component and trying to find a string with size different from 1 !"); + } +%#endif else throw INTERP_KERNEL::Exception("DataArrayAsciiChar::__contains__ : 'this' contains one component and trying to find an element which is not an integer !"); } @@ -5698,12 +3482,12 @@ namespace MEDCoupling } } - PyObject *__getitem__(PyObject *obj) const throw(INTERP_KERNEL::Exception) + 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) { @@ -5716,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) throw(INTERP_KERNEL::Exception) + 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) @@ -5839,7 +3623,7 @@ namespace MEDCoupling } } case 4: - {//DataArrayInt + {//DataArrayIdType switch(sw2) { {//value char @@ -5906,19 +3690,73 @@ namespace MEDCoupling class DataArrayAsciiCharTuple { public: - int getNumberOfCompo() const throw(INTERP_KERNEL::Exception); - DataArrayAsciiChar *buildDAAsciiChar(int nbOfTuples, int nbOfCompo) const throw(INTERP_KERNEL::Exception); + std::size_t getNumberOfCompo() const; + DataArrayAsciiChar *buildDAAsciiChar(mcIdType nbOfTuples, mcIdType nbOfCompo) const; %extend { - std::string __str__() const throw(INTERP_KERNEL::Exception) + std::string __str__() const { return self->repr(); } - - DataArrayAsciiChar *buildDAAsciiChar() throw(INTERP_KERNEL::Exception) + + 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 + ret=object.__new__(cls) + ret.__init__(*a) + ret.__setstate__(b) + return ret + +def MEDCouplingDataArrayDoubleReduce(self): + if not MEDCouplingHasNumPyBindings(): + 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 MEDCouplingDataArrayInt32Reduce(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,(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(): + raise InterpKernelException("PyWrap of DataArrayByte.__reduce__ : not implemented because numpy is not active in your configuration ! No serialization/unserialization available without numpy !") + return MEDCouplingStdReduceFunct,(DataArrayByte,((self.toNumPyArray(),),(self.__getstate__()),)) + +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 + +%}