From 805f6b27aae3dd3a5e683bb40ab07b5cacf37f20 Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Tue, 2 May 2017 16:00:22 +0200 Subject: [PATCH] Step1 --- src/MEDCoupling/MEDCouplingMemArray.cxx | 67 +--- src/MEDCoupling/MEDCouplingMemArray.hxx | 190 +++++----- src/MEDCoupling/MEDCouplingMemArray.txx | 45 +++ src/MEDCoupling/MEDCouplingTraits.hxx | 4 + .../MEDCouplingBasicsTest5.py | 65 ++++ src/MEDCoupling_Swig/MEDCouplingCommon.i | 180 ++++++--- .../MEDCouplingDataArrayTraits.hxx | 1 + .../MEDCouplingDataArrayTypemaps.i | 356 +++++++++--------- .../MEDCouplingFieldDiscretization.i | 18 +- src/MEDCoupling_Swig/MEDCouplingMemArray.i | 112 +++--- src/MEDCoupling_Swig/MEDCouplingTypemaps.i | 12 +- src/MEDLoader/Swig/MEDLoaderCommon.i | 4 +- 12 files changed, 604 insertions(+), 450 deletions(-) diff --git a/src/MEDCoupling/MEDCouplingMemArray.cxx b/src/MEDCoupling/MEDCouplingMemArray.cxx index 2ad3aaf63..bd33d0785 100644 --- a/src/MEDCoupling/MEDCouplingMemArray.cxx +++ b/src/MEDCoupling/MEDCouplingMemArray.cxx @@ -43,6 +43,7 @@ template class MEDCoupling::DataArrayTemplate; template class MEDCoupling::DataArrayTemplateClassic; template class MEDCoupling::DataArrayTemplateClassic; template class MEDCoupling::DataArrayTemplateFP; +template class MEDCoupling::DataArrayIterator; template void DataArrayDouble::findCommonTuplesAlg(const double *bbox, int nbNodes, int limitNodeId, double prec, DataArrayInt *c, DataArrayInt *cI) const @@ -4564,40 +4565,11 @@ void DataArrayDouble::Rotate2DAlg(const double *center, double angle, int nbNode } } -DataArrayDoubleIterator::DataArrayDoubleIterator(DataArrayDouble *da):_da(da),_tuple_id(0),_nb_comp(0),_nb_tuple(0) +DataArrayDoubleIterator::DataArrayDoubleIterator(DataArrayDouble *da):DataArrayIterator(da) { - if(_da) - { - _da->incrRef(); - if(_da->isAllocated()) - { - _nb_comp=da->getNumberOfComponents(); - _nb_tuple=da->getNumberOfTuples(); - _pt=da->getPointer(); - } - } -} - -DataArrayDoubleIterator::~DataArrayDoubleIterator() -{ - if(_da) - _da->decrRef(); -} - -DataArrayDoubleTuple *DataArrayDoubleIterator::nextt() -{ - if(_tuple_id<_nb_tuple) - { - _tuple_id++; - DataArrayDoubleTuple *ret=new DataArrayDoubleTuple(_pt,_nb_comp); - _pt+=_nb_comp; - return ret; - } - else - return 0; } -DataArrayDoubleTuple::DataArrayDoubleTuple(double *pt, int nbOfComp):_pt(pt),_nb_of_compo(nbOfComp) +DataArrayDoubleTuple::DataArrayDoubleTuple(double *pt, int nbOfComp):DataArrayTuple(pt,nbOfComp) { } @@ -9138,40 +9110,11 @@ void DataArrayInt::finishUnserialization(const std::vector& tinyInfoI, cons } } -DataArrayIntIterator::DataArrayIntIterator(DataArrayInt *da):_da(da),_pt(0),_tuple_id(0),_nb_comp(0),_nb_tuple(0) +DataArrayIntIterator::DataArrayIntIterator(DataArrayInt *da):DataArrayIterator(da) { - if(_da) - { - _da->incrRef(); - if(_da->isAllocated()) - { - _nb_comp=da->getNumberOfComponents(); - _nb_tuple=da->getNumberOfTuples(); - _pt=da->getPointer(); - } - } -} - -DataArrayIntIterator::~DataArrayIntIterator() -{ - if(_da) - _da->decrRef(); -} - -DataArrayIntTuple *DataArrayIntIterator::nextt() -{ - if(_tuple_id<_nb_tuple) - { - _tuple_id++; - DataArrayIntTuple *ret=new DataArrayIntTuple(_pt,_nb_comp); - _pt+=_nb_comp; - return ret; - } - else - return 0; } -DataArrayIntTuple::DataArrayIntTuple(int *pt, int nbOfComp):_pt(pt),_nb_of_compo(nbOfComp) +DataArrayIntTuple::DataArrayIntTuple(int *pt, int nbOfComp):DataArrayTuple(pt,nbOfComp) { } diff --git a/src/MEDCoupling/MEDCouplingMemArray.hxx b/src/MEDCoupling/MEDCouplingMemArray.hxx index 1d6acba01..a2dac270c 100644 --- a/src/MEDCoupling/MEDCouplingMemArray.hxx +++ b/src/MEDCoupling/MEDCouplingMemArray.hxx @@ -507,37 +507,6 @@ namespace MEDCoupling DataArrayDouble() { } }; - class DataArrayDoubleTuple; - - class DataArrayDoubleIterator - { - public: - MEDCOUPLING_EXPORT DataArrayDoubleIterator(DataArrayDouble *da); - MEDCOUPLING_EXPORT ~DataArrayDoubleIterator(); - MEDCOUPLING_EXPORT DataArrayDoubleTuple *nextt(); - private: - DataArrayDouble *_da; - double *_pt; - int _tuple_id; - int _nb_comp; - int _nb_tuple; - }; - - class DataArrayDoubleTuple - { - public: - MEDCOUPLING_EXPORT DataArrayDoubleTuple(double *pt, int nbOfComp); - MEDCOUPLING_EXPORT std::string repr() const; - MEDCOUPLING_EXPORT int getNumberOfCompo() const { return _nb_of_compo; } - MEDCOUPLING_EXPORT const double *getConstPointer() const { return _pt; } - MEDCOUPLING_EXPORT double *getPointer() { return _pt; } - MEDCOUPLING_EXPORT double doubleValue() const; - MEDCOUPLING_EXPORT DataArrayDouble *buildDADouble(int nbOfTuples, int nbOfCompo) const; - private: - double *_pt; - int _nb_of_compo; - }; - class DataArrayIntIterator; class DataArrayInt : public DataArrayTemplateClassic @@ -725,38 +694,6 @@ namespace MEDCoupling return ret; } - - class DataArrayIntTuple; - - class DataArrayIntIterator - { - public: - MEDCOUPLING_EXPORT DataArrayIntIterator(DataArrayInt *da); - MEDCOUPLING_EXPORT ~DataArrayIntIterator(); - MEDCOUPLING_EXPORT DataArrayIntTuple *nextt(); - private: - DataArrayInt *_da; - int *_pt; - int _tuple_id; - int _nb_comp; - int _nb_tuple; - }; - - class DataArrayIntTuple - { - public: - MEDCOUPLING_EXPORT DataArrayIntTuple(int *pt, int nbOfComp); - MEDCOUPLING_EXPORT std::string repr() const; - MEDCOUPLING_EXPORT int getNumberOfCompo() const { return _nb_of_compo; } - MEDCOUPLING_EXPORT const int *getConstPointer() const { return _pt; } - MEDCOUPLING_EXPORT int *getPointer() { return _pt; } - MEDCOUPLING_EXPORT int intValue() const; - MEDCOUPLING_EXPORT DataArrayInt *buildDAInt(int nbOfTuples, int nbOfCompo) const; - private: - int *_pt; - int _nb_of_compo; - }; - class DataArrayChar : public DataArrayTemplate { public: @@ -831,37 +768,6 @@ namespace MEDCoupling DataArrayByte() { } }; - class DataArrayByteTuple; - - class DataArrayByteIterator - { - public: - MEDCOUPLING_EXPORT DataArrayByteIterator(DataArrayByte *da); - MEDCOUPLING_EXPORT ~DataArrayByteIterator(); - MEDCOUPLING_EXPORT DataArrayByteTuple *nextt(); - private: - DataArrayByte *_da; - char *_pt; - int _tuple_id; - int _nb_comp; - int _nb_tuple; - }; - - class DataArrayByteTuple - { - public: - MEDCOUPLING_EXPORT DataArrayByteTuple(char *pt, int nbOfComp); - MEDCOUPLING_EXPORT std::string repr() const; - MEDCOUPLING_EXPORT int getNumberOfCompo() const { return _nb_of_compo; } - MEDCOUPLING_EXPORT const char *getConstPointer() const { return _pt; } - MEDCOUPLING_EXPORT char *getPointer() { return _pt; } - MEDCOUPLING_EXPORT char byteValue() const; - MEDCOUPLING_EXPORT DataArrayByte *buildDAByte(int nbOfTuples, int nbOfCompo) const; - private: - char *_pt; - int _nb_of_compo; - }; - class DataArrayAsciiCharIterator; class DataArrayAsciiChar : public DataArrayChar @@ -891,6 +797,71 @@ namespace MEDCoupling DataArrayAsciiChar(const std::vector& vst, char defaultChar); }; + template + class DataArrayIterator + { + public: + DataArrayIterator(typename Traits::ArrayType *da); + ~DataArrayIterator(); + MEDCOUPLING_EXPORT typename Traits::ArrayTuple *nextt(); + private: + typename Traits::ArrayType *_da; + T *_pt; + int _tuple_id; + int _nb_comp; + int _nb_tuple; + }; + + template + class DataArrayTuple + { + public: + MEDCOUPLING_EXPORT DataArrayTuple(T *pt, int nbOfComp); + MEDCOUPLING_EXPORT std::string repr() const; + MEDCOUPLING_EXPORT int getNumberOfCompo() const { return _nb_of_compo; } + MEDCOUPLING_EXPORT const T *getConstPointer() const { return _pt; } + MEDCOUPLING_EXPORT T *getPointer() { return _pt; } + protected: + T *_pt; + int _nb_of_compo; + }; + + class DataArrayDoubleTuple; + + class DataArrayDoubleIterator : public DataArrayIterator + { + public: + MEDCOUPLING_EXPORT DataArrayDoubleIterator(DataArrayDouble *da); + MEDCOUPLING_EXPORT ~DataArrayDoubleIterator() { } + }; + + class DataArrayDoubleTuple : public DataArrayTuple + { + public: + MEDCOUPLING_EXPORT DataArrayDoubleTuple(double *pt, int nbOfComp); + MEDCOUPLING_EXPORT std::string repr() const; + MEDCOUPLING_EXPORT double doubleValue() const; + MEDCOUPLING_EXPORT DataArrayDouble *buildDADouble(int nbOfTuples, int nbOfCompo) const; + }; + + class DataArrayIntTuple; + + class DataArrayIntIterator : public DataArrayIterator + { + public: + MEDCOUPLING_EXPORT DataArrayIntIterator(DataArrayInt *da); + MEDCOUPLING_EXPORT ~DataArrayIntIterator() { } + }; + + class DataArrayIntTuple : public DataArrayTuple + { + public: + MEDCOUPLING_EXPORT DataArrayIntTuple(int *pt, int nbOfComp); + MEDCOUPLING_EXPORT std::string repr() const; + MEDCOUPLING_EXPORT int intValue() const; + MEDCOUPLING_EXPORT DataArrayInt *buildDAInt(int nbOfTuples, int nbOfCompo) const; + }; + class DataArrayAsciiCharTuple; class DataArrayAsciiCharIterator @@ -921,6 +892,37 @@ namespace MEDCoupling char *_pt; int _nb_of_compo; }; + + class DataArrayByteTuple; + + class DataArrayByteIterator + { + public: + MEDCOUPLING_EXPORT DataArrayByteIterator(DataArrayByte *da); + MEDCOUPLING_EXPORT ~DataArrayByteIterator(); + MEDCOUPLING_EXPORT DataArrayByteTuple *nextt(); + private: + DataArrayByte *_da; + char *_pt; + int _tuple_id; + int _nb_comp; + int _nb_tuple; + }; + + class DataArrayByteTuple + { + public: + MEDCOUPLING_EXPORT DataArrayByteTuple(char *pt, int nbOfComp); + MEDCOUPLING_EXPORT std::string repr() const; + MEDCOUPLING_EXPORT int getNumberOfCompo() const { return _nb_of_compo; } + MEDCOUPLING_EXPORT const char *getConstPointer() const { return _pt; } + MEDCOUPLING_EXPORT char *getPointer() { return _pt; } + MEDCOUPLING_EXPORT char byteValue() const; + MEDCOUPLING_EXPORT DataArrayByte *buildDAByte(int nbOfTuples, int nbOfCompo) const; + private: + char *_pt; + int _nb_of_compo; + }; } namespace MEDCoupling diff --git a/src/MEDCoupling/MEDCouplingMemArray.txx b/src/MEDCoupling/MEDCouplingMemArray.txx index 425ceeaae..f5267f8de 100644 --- a/src/MEDCoupling/MEDCouplingMemArray.txx +++ b/src/MEDCoupling/MEDCouplingMemArray.txx @@ -480,6 +480,51 @@ namespace MEDCoupling ////////////////////////////////// + template + DataArrayIterator::DataArrayIterator(typename Traits::ArrayType *da):_da(da),_tuple_id(0),_nb_comp(0),_nb_tuple(0) + { + if(_da) + { + _da->incrRef(); + if(_da->isAllocated()) + { + _nb_comp=da->getNumberOfComponents(); + _nb_tuple=da->getNumberOfTuples(); + _pt=da->getPointer(); + } + } + } + + template + DataArrayIterator::~DataArrayIterator() + { + if(_da) + _da->decrRef(); + } + + template + typename Traits::ArrayTuple *DataArrayIterator::nextt() + { + if(_tuple_id<_nb_tuple) + { + _tuple_id++; + typename Traits::ArrayTuple *ret=new typename Traits::ArrayTuple(_pt,_nb_comp); + _pt+=_nb_comp; + return ret; + } + else + return 0; + } + + ////////////////////////////////// + + template + DataArrayTuple::DataArrayTuple(T *pt, int nbOfComp):_pt(pt),_nb_of_compo(nbOfComp) + { + } + + ////////////////////////////////// + template MCAuto< typename Traits::ArrayTypeCh > DataArrayTemplate::NewFromStdVector(const typename std::vector& v) { diff --git a/src/MEDCoupling/MEDCouplingTraits.hxx b/src/MEDCoupling/MEDCouplingTraits.hxx index 22f203a45..bb22dbe06 100644 --- a/src/MEDCoupling/MEDCouplingTraits.hxx +++ b/src/MEDCoupling/MEDCouplingTraits.hxx @@ -39,6 +39,8 @@ namespace MEDCoupling class MEDCouplingFieldDouble; class MEDCouplingFieldFloat; class MEDCouplingFieldInt; + class DataArrayIntTuple; + class DataArrayDoubleTuple; template<> struct MEDCOUPLING_EXPORT Traits @@ -49,6 +51,7 @@ namespace MEDCoupling typedef DataArrayDouble ArrayType; typedef DataArrayDouble ArrayTypeCh; typedef MEDCouplingFieldDouble FieldType; + typedef DataArrayDoubleTuple ArrayTuple; }; template<> @@ -70,6 +73,7 @@ namespace MEDCoupling typedef DataArrayInt ArrayType; typedef DataArrayInt ArrayTypeCh; typedef MEDCouplingFieldInt FieldType; + typedef DataArrayIntTuple ArrayTuple; }; template<> diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest5.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest5.py index 04c55fe8e..f2a7c8649 100644 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest5.py +++ b/src/MEDCoupling_Swig/MEDCouplingBasicsTest5.py @@ -4565,6 +4565,71 @@ class MEDCouplingBasicsTest5(unittest.TestCase): m_1=m[[0,2,4]] ; m_1.zipCoords() self.assertTrue(f_1.getMesh().isEqual(m_1,1e-12)) pass +class MEDCouplingBasicsTest5(unittest.TestCase): + + def testFieldFloatIsOnStage1(self): + """ My first test with field int.""" + m=MEDCouplingCMesh() + m.setName("mesh") + arrX=DataArrayDouble([0,1,2,3]) + m.setCoords(arrX,arrX) + f=MEDCouplingFieldFloat(ON_CELLS) + f.setMesh(m) + arr=DataArrayFloat(8) ; arr.iota() ;f.setArray(arr) + self.assertRaises(InterpKernelException,f.checkConsistencyLight) + arr=DataArrayFloat(9) ; arr.iota() ;f.setArray(arr) + f.checkConsistencyLight() + f.setTimeUnit("ms") + self.assertEqual(f.getTimeUnit(),"ms") + f.setTime(3.2,5,6) + a,b,c=f.getTime() + self.assertEqual(b,5) + self.assertEqual(c,6) + self.assertEqual(a,3.2,12) + pass + + def testFieldFloatIsOnStage2(self): + """ Very important test to check that isEqual of MEDCouplingFieldFloat is OK !""" + m1=MEDCouplingCMesh() ; m1.setCoords(DataArrayDouble([0,1,2,3]),DataArrayDouble([0,1,2,3,4])) + m1=m1.buildUnstructured() ; m1.setName("mesh") + f1=MEDCouplingFieldFloat(ON_CELLS) ; f1.setMesh(m1) + arr1=DataArrayFloat([(0,1),(2,3),(4,5),(6,7),(8,9),(10,11),(12,13),(14,15),(16,17),(18,19),(20,21),(22,23)]) ; arr1.setInfoOnComponents(["aa","bbb"]) + f1.setArray(arr1) ; f1.setName("f1") ; f1.setTime(2.,3,4) + # + m2=MEDCouplingCMesh() ; m2.setCoords(DataArrayDouble([0,1,2,3]),DataArrayDouble([0,1,2,3,4])) + m2=m2.buildUnstructured() ; m2.setName("mesh") + f2=MEDCouplingFieldFloat(ON_CELLS) ; f2.setMesh(m2) + arr2=DataArrayFloat([(0,1),(2,3),(4,5),(6,7),(8,9),(10,11),(12,13),(14,15),(16,17),(18,19),(20,21),(22,23)]) ; arr2.setInfoOnComponents(["aa","bbb"]) + f2.setArray(arr2) ; f2.setName("f1") ; f2.setTime(2.,3,4) + # + self.assertTrue(f1.isEqual(f2,1e-12,0.)) + f1.getArray()[:]*=2 + self.assertTrue(not f1.isEqual(f2,1e-12,0.)) + self.assertTrue(not f1.isEqualWithoutConsideringStr(f2,1e-12,0.)) + f1.getArray()[:]/=2 + self.assertTrue(f1.isEqual(f2,1e-12,0.)) + # + f1.setName("F1") + self.assertTrue(not f1.isEqual(f2,1e-12,0.)) + f1.setName("f1") + self.assertTrue(f1.isEqual(f2,1e-12,0.)) + # + f1.getArray().setInfoOnComponents(["aa","bbbb"]) + self.assertTrue(not f1.isEqual(f2,1e-12,0.)) + self.assertTrue(f1.isEqualWithoutConsideringStr(f2,1e-12,0.)) + f1.getArray().setInfoOnComponents(["aa","bbb"]) + self.assertTrue(f1.isEqual(f2,1e-12,0.)) + # + f3=f2.deepCopy() + self.assertTrue(f1.isEqual(f3,1e-12,0.)) + # + for fd,expected in ((ON_NODES,False),(ON_CELLS,True)): + f4=MEDCouplingFieldFloat(fd) ; f4.setMesh(m2) ; f4.setTime(2.,3,4) + arr4=DataArrayFloat([(0,1),(2,3),(4,5),(6,7),(8,9),(10,11),(12,13),(14,15),(16,17),(18,19),(20,21),(22,23)]) ; arr4.setInfoOnComponents(["aa","bbb"]) + f4.setArray(arr4) ; f4.setName("f1") + self.assertEqual(f1.isEqual(f4,1e-12,0.),expected) + pass + pass pass diff --git a/src/MEDCoupling_Swig/MEDCouplingCommon.i b/src/MEDCoupling_Swig/MEDCouplingCommon.i index bf0016815..04512d14d 100644 --- a/src/MEDCoupling_Swig/MEDCouplingCommon.i +++ b/src/MEDCoupling_Swig/MEDCouplingCommon.i @@ -38,6 +38,7 @@ #include "MEDCouplingField.hxx" #include "MEDCouplingFieldDouble.hxx" #include "MEDCouplingFieldInt.hxx" +#include "MEDCouplingFieldFloat.hxx" #include "MEDCouplingFieldTemplate.hxx" #include "MEDCouplingGaussLocalization.hxx" #include "MCAuto.hxx" @@ -244,6 +245,15 @@ using namespace INTERP_KERNEL; %newobject MEDCoupling::MEDCouplingFieldInt::buildSubPart; %newobject MEDCoupling::MEDCouplingFieldInt::buildSubPartRange; %newobject MEDCoupling::MEDCouplingFieldInt::__getitem__; +%newobject MEDCoupling::MEDCouplingFieldFloat::New; +%newobject MEDCoupling::MEDCouplingFieldFloat::convertToDblField; +%newobject MEDCoupling::MEDCouplingFieldFloat::getArray; +%newobject MEDCoupling::MEDCouplingFieldFloat::deepCopy; +%newobject MEDCoupling::MEDCouplingFieldFloat::clone; +%newobject MEDCoupling::MEDCouplingFieldFloat::cloneWithMesh; +%newobject MEDCoupling::MEDCouplingFieldFloat::buildSubPart; +%newobject MEDCoupling::MEDCouplingFieldFloat::buildSubPartRange; +%newobject MEDCoupling::MEDCouplingFieldFloat::__getitem__; %newobject MEDCoupling::MEDCouplingFieldTemplate::New; %newobject MEDCoupling::MEDCouplingMesh::deepCopy; %newobject MEDCoupling::MEDCouplingMesh::clone; @@ -467,6 +477,8 @@ using namespace INTERP_KERNEL; {// AGY : here initialization of C++ traits in MEDCouplingDataArrayTypemaps.i for code factorization. Awful, I know, but no other solutions. SWIGTITraits::TI=SWIGTYPE_p_MEDCoupling__DataArrayDouble; SWIGTITraits::TI=SWIGTYPE_p_MEDCoupling__DataArrayFloat; + SWIGTITraits::TI_TUPLE=SWIGTYPE_p_MEDCoupling__DataArrayDoubleTuple; + SWIGTITraits::TI_TUPLE=SWIGTYPE_p_MEDCoupling__DataArrayIntTuple; } %} @@ -752,7 +764,7 @@ namespace MEDCoupling { int sw,sz(-1); int v0; std::vector v1; - const int *ids(convertObjToPossibleCpp1_Safe(li,sw,sz,v0,v1)); + const int *ids(convertIntStarLikePyObjToCppIntStar(li,sw,sz,v0,v1)); self->renumberCells(ids,check); } @@ -854,7 +866,7 @@ namespace MEDCoupling { int szArr,sw,iTypppArr; std::vector stdvecTyyppArr; - const int *tmp=convertObjToPossibleCpp1_Safe(li,sw,szArr,iTypppArr,stdvecTyyppArr); + const int *tmp=convertIntStarLikePyObjToCppIntStar(li,sw,szArr,iTypppArr,stdvecTyyppArr); MEDCouplingMesh *ret=self->buildPart(tmp,tmp+szArr); if(sw==3)//DataArrayInt { @@ -872,7 +884,7 @@ namespace MEDCoupling int szArr,sw,iTypppArr; std::vector stdvecTyyppArr; DataArrayInt *arr=0; - const int *tmp=convertObjToPossibleCpp1_Safe(li,sw,szArr,iTypppArr,stdvecTyyppArr); + const int *tmp=convertIntStarLikePyObjToCppIntStar(li,sw,szArr,iTypppArr,stdvecTyyppArr); MEDCouplingMesh *ret=self->buildPartAndReduceNodes(tmp,tmp+szArr,arr); if(sw==3)//DataArrayInt { @@ -1365,7 +1377,7 @@ namespace MEDCoupling { int szArr,sw,iTypppArr; std::vector stdvecTyyppArr; - const int *tmp=convertObjToPossibleCpp1_Safe(li,sw,szArr,iTypppArr,stdvecTyyppArr); + const int *tmp=convertIntStarLikePyObjToCppIntStar(li,sw,szArr,iTypppArr,stdvecTyyppArr); MEDCouplingPointSet *ret=self->buildPartOfMySelf(tmp,tmp+szArr,keepCoords); if(sw==3)//DataArrayInt { @@ -1382,7 +1394,7 @@ namespace MEDCoupling { int szArr,sw,iTypppArr; std::vector stdvecTyyppArr; - const int *tmp=convertObjToPossibleCpp1_Safe(li,sw,szArr,iTypppArr,stdvecTyyppArr); + const int *tmp=convertIntStarLikePyObjToCppIntStar(li,sw,szArr,iTypppArr,stdvecTyyppArr); MEDCouplingPointSet *ret=self->buildPartOfMySelfNode(tmp,tmp+szArr,fullyIn); if(sw==3)//DataArrayInt { @@ -1399,7 +1411,7 @@ namespace MEDCoupling { int szArr,sw,iTypppArr; std::vector stdvecTyyppArr; - const int *tmp=convertObjToPossibleCpp1_Safe(li,sw,szArr,iTypppArr,stdvecTyyppArr); + const int *tmp=convertIntStarLikePyObjToCppIntStar(li,sw,szArr,iTypppArr,stdvecTyyppArr); MEDCouplingPointSet *ret=self->buildPartOfMySelfKeepCoords(tmp,tmp+szArr); if(sw==3)//DataArrayInt { @@ -1422,7 +1434,7 @@ namespace MEDCoupling { int szArr,sw,iTypppArr; std::vector stdvecTyyppArr; - const int *tmp=convertObjToPossibleCpp1_Safe(li,sw,szArr,iTypppArr,stdvecTyyppArr); + const int *tmp=convertIntStarLikePyObjToCppIntStar(li,sw,szArr,iTypppArr,stdvecTyyppArr); MEDCouplingPointSet *ret=self->buildFacePartOfMySelfNode(tmp,tmp+szArr,fullyIn); if(sw==3)//DataArrayInt { @@ -1439,7 +1451,7 @@ namespace MEDCoupling { int szArr,sw,iTypppArr; std::vector stdvecTyyppArr; - const int *tmp=convertObjToPossibleCpp1_Safe(li,sw,szArr,iTypppArr,stdvecTyyppArr); + const int *tmp=convertIntStarLikePyObjToCppIntStar(li,sw,szArr,iTypppArr,stdvecTyyppArr); self->renumberNodes(tmp,newNbOfNodes); } @@ -1447,7 +1459,7 @@ namespace MEDCoupling { int szArr,sw,iTypppArr; std::vector stdvecTyyppArr; - const int *tmp=convertObjToPossibleCpp1_Safe(li,sw,szArr,iTypppArr,stdvecTyyppArr); + const int *tmp=convertIntStarLikePyObjToCppIntStar(li,sw,szArr,iTypppArr,stdvecTyyppArr); self->renumberNodesCenter(tmp,newNbOfNodes); } @@ -1564,7 +1576,7 @@ namespace MEDCoupling std::vector multiVal; std::pair > slic; MEDCoupling::DataArrayInt *daIntTyypp=0; - convertObjToPossibleCpp2(li,self->getNumberOfNodes(),sw,singleVal,multiVal,slic,daIntTyypp); + convertIntStarOrSliceLikePyObjToCpp(li,self->getNumberOfNodes(),sw,singleVal,multiVal,slic,daIntTyypp); switch(sw) { case 1: @@ -1625,7 +1637,7 @@ namespace MEDCoupling // int szArr,sw,iTypppArr; std::vector stdvecTyyppArr; - const int *tmp=convertObjToPossibleCpp1_Safe(li,sw,szArr,iTypppArr,stdvecTyyppArr); + const int *tmp=convertIntStarLikePyObjToCppIntStar(li,sw,szArr,iTypppArr,stdvecTyyppArr); self->fillCellIdsToKeepFromNodeIds(tmp,tmp+szArr,fullyIn,ret); return ret; } @@ -1682,7 +1694,7 @@ namespace MEDCoupling std::pair > slic; MEDCoupling::DataArrayInt *daIntTyypp=0; int nbc=self->getNumberOfCells(); - convertObjToPossibleCpp2(listOrDataArrI,nbc,sw,singleVal,multiVal,slic,daIntTyypp); + convertIntStarOrSliceLikePyObjToCpp(listOrDataArrI,nbc,sw,singleVal,multiVal,slic,daIntTyypp); switch(sw) { case 1: @@ -2003,7 +2015,7 @@ namespace MEDCoupling std::pair > slic; MEDCoupling::DataArrayInt *daIntTyypp=0; int nbc=self->getNumberOfCells(); - convertObjToPossibleCpp2(li,nbc,sw,singleVal,multiVal,slic,daIntTyypp); + convertIntStarOrSliceLikePyObjToCpp(li,nbc,sw,singleVal,multiVal,slic,daIntTyypp); switch(sw) { case 1: @@ -2061,7 +2073,7 @@ namespace MEDCoupling std::pair > slic; MEDCoupling::DataArrayInt *daIntTyypp=0; int nbc=self->getNumberOfCells(); - convertObjToPossibleCpp2(li,nbc,sw,singleVal,multiVal,slic,daIntTyypp); + convertIntStarOrSliceLikePyObjToCpp(li,nbc,sw,singleVal,multiVal,slic,daIntTyypp); switch(sw) { case 1: @@ -2120,7 +2132,7 @@ namespace MEDCoupling { int szArr,sw,iTypppArr; std::vector stdvecTyyppArr; - const int *tmp=convertObjToPossibleCpp1_Safe(li,sw,szArr,iTypppArr,stdvecTyyppArr); + const int *tmp=convertIntStarLikePyObjToCppIntStar(li,sw,szArr,iTypppArr,stdvecTyyppArr); if(size>szArr) { std::ostringstream oss; oss << "Wrap of MEDCouplingUMesh::insertNextCell : request of connectivity with length " << size << " whereas the length of input is " << szArr << " !"; @@ -2133,7 +2145,7 @@ namespace MEDCoupling { int szArr,sw,iTypppArr; std::vector stdvecTyyppArr; - const int *tmp=convertObjToPossibleCpp1_Safe(li,sw,szArr,iTypppArr,stdvecTyyppArr); + const int *tmp=convertIntStarLikePyObjToCppIntStar(li,sw,szArr,iTypppArr,stdvecTyyppArr); self->insertNextCell(type,szArr,tmp); } @@ -2156,7 +2168,7 @@ namespace MEDCoupling { int szArr,sw,iTypppArr; std::vector stdvecTyyppArr; - const int *seedPtr=convertObjToPossibleCpp1_Safe(seed,sw,szArr,iTypppArr,stdvecTyyppArr); + const int *seedPtr=convertIntStarLikePyObjToCppIntStar(seed,sw,szArr,iTypppArr,stdvecTyyppArr); int nbOfDepthPeelingPerformed=0; DataArrayInt *ret0=MEDCouplingUMesh::ComputeSpreadZoneGraduallyFromSeed(seedPtr,seedPtr+szArr,arrIn,arrIndxIn,nbOfDepthPeeling,nbOfDepthPeelingPerformed); PyObject *res=PyTuple_New(2); @@ -2307,7 +2319,7 @@ namespace MEDCoupling std::vector multiVal; std::pair > slic; MEDCoupling::DataArrayInt *daIntTyypp=0; - convertObjToPossibleCpp2(li,self->getNumberOfNodes(),sw,singleVal,multiVal,slic,daIntTyypp); + convertIntStarOrSliceLikePyObjToCpp(li,self->getNumberOfNodes(),sw,singleVal,multiVal,slic,daIntTyypp); switch(sw) { case 1: @@ -2328,7 +2340,7 @@ namespace MEDCoupling std::vector multiVal; std::pair > slic; MEDCoupling::DataArrayInt *daIntTyypp=0; - convertObjToPossibleCpp2(li,self->getNumberOfNodes(),sw,singleVal,multiVal,slic,daIntTyypp); + convertIntStarOrSliceLikePyObjToCpp(li,self->getNumberOfNodes(),sw,singleVal,multiVal,slic,daIntTyypp); switch(sw) { case 1: @@ -2425,7 +2437,7 @@ namespace MEDCoupling MEDCoupling::DataArrayInt *daIntTyypp=0; if(!arrIndx) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::RemoveIdsFromIndexedArrays : null pointer as arrIndex !"); - convertObjToPossibleCpp2(li,arrIndx->getNumberOfTuples()-1,sw,singleVal,multiVal,slic,daIntTyypp); + convertIntStarOrSliceLikePyObjToCpp(li,arrIndx->getNumberOfTuples()-1,sw,singleVal,multiVal,slic,daIntTyypp); switch(sw) { case 1: @@ -2449,7 +2461,7 @@ namespace MEDCoupling MEDCoupling::DataArrayInt *daIntTyypp=0; if(!arrIndxIn) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::ExtractFromIndexedArrays : null pointer as arrIndxIn !"); - convertObjToPossibleCpp2(li,arrIndxIn->getNumberOfTuples()-1,sw,singleVal,multiVal,slic,daIntTyypp); + convertIntStarOrSliceLikePyObjToCpp(li,arrIndxIn->getNumberOfTuples()-1,sw,singleVal,multiVal,slic,daIntTyypp); switch(sw) { case 1: @@ -2518,7 +2530,7 @@ namespace MEDCoupling MEDCoupling::DataArrayInt *daIntTyypp=0; if(!arrIndxIn) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::SetPartOfIndexedArrays : null pointer as arrIndex !"); - convertObjToPossibleCpp2(li,arrIndxIn->getNumberOfTuples()-1,sw,singleVal,multiVal,slic,daIntTyypp); + convertIntStarOrSliceLikePyObjToCpp(li,arrIndxIn->getNumberOfTuples()-1,sw,singleVal,multiVal,slic,daIntTyypp); switch(sw) { case 1: @@ -2555,7 +2567,7 @@ namespace MEDCoupling MEDCoupling::DataArrayInt *daIntTyypp=0; if(!arrIndxIn) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::SetPartOfIndexedArraysSameIdx : null pointer as arrIndex !"); - convertObjToPossibleCpp2(li,arrIndxIn->getNumberOfTuples()-1,sw,singleVal,multiVal,slic,daIntTyypp); + convertIntStarOrSliceLikePyObjToCpp(li,arrIndxIn->getNumberOfTuples()-1,sw,singleVal,multiVal,slic,daIntTyypp); switch(sw) { case 1: @@ -2962,7 +2974,7 @@ namespace MEDCoupling std::vector pos2; DataArrayInt *pos3=0; DataArrayIntTuple *pos4=0; - convertObjToPossibleCpp1(li,sw,pos1,pos2,pos3,pos4); + convertIntStarLikePyObjToCpp(li,sw,pos1,pos2,pos3,pos4); switch(sw) { case 1: @@ -3080,7 +3092,7 @@ namespace MEDCoupling { int szArr,sw,iTypppArr; std::vector stdvecTyyppArr; - const int *tmp=convertObjToPossibleCpp1_Safe(li,sw,szArr,iTypppArr,stdvecTyyppArr); + const int *tmp=convertIntStarLikePyObjToCppIntStar(li,sw,szArr,iTypppArr,stdvecTyyppArr); self->insertNextCell(tmp,tmp+szArr); } @@ -3327,7 +3339,7 @@ namespace MEDCoupling // int szArr,sw,iTypppArr; std::vector stdvecTyyppArr; - const int *tmp4=convertObjToPossibleCpp1_Safe(st,sw,szArr,iTypppArr,stdvecTyyppArr); + const int *tmp4=convertIntStarLikePyObjToCppIntStar(st,sw,szArr,iTypppArr,stdvecTyyppArr); std::vector tmp5(tmp4,tmp4+szArr); // return MEDCouplingStructuredMesh::BuildExplicitIdsFrom(tmp5,inp); @@ -3385,7 +3397,7 @@ namespace MEDCoupling { int szArr,sw,iTypppArr; std::vector stdvecTyyppArr; - const int *tmp=convertObjToPossibleCpp1_Safe(li,sw,szArr,iTypppArr,stdvecTyyppArr); + const int *tmp=convertIntStarLikePyObjToCppIntStar(li,sw,szArr,iTypppArr,stdvecTyyppArr); return MEDCouplingStructuredMesh::Build1GTNodalConnectivity(tmp,tmp+szArr); } @@ -3393,7 +3405,7 @@ namespace MEDCoupling { int szArr,sw,iTypppArr; std::vector stdvecTyyppArr; - const int *tmp(convertObjToPossibleCpp1_Safe(li,sw,szArr,iTypppArr,stdvecTyyppArr)); + const int *tmp(convertIntStarLikePyObjToCppIntStar(li,sw,szArr,iTypppArr,stdvecTyyppArr)); return MEDCouplingStructuredMesh::Build1GTNodalConnectivityOfSubLevelMesh(tmp,tmp+szArr); } @@ -3447,10 +3459,10 @@ namespace MEDCoupling { int szArr,sw,iTypppArr; std::vector stdvecTyyppArr; - const int *tmp=convertObjToPossibleCpp1_Safe(li,sw,szArr,iTypppArr,stdvecTyyppArr); + const int *tmp=convertIntStarLikePyObjToCppIntStar(li,sw,szArr,iTypppArr,stdvecTyyppArr); int szArr2,sw2,iTypppArr2; std::vector stdvecTyyppArr2; - const int *tmp2=convertObjToPossibleCpp1_Safe(st,sw2,szArr2,iTypppArr2,stdvecTyyppArr2); + const int *tmp2=convertIntStarLikePyObjToCppIntStar(st,sw2,szArr2,iTypppArr2,stdvecTyyppArr2); std::vector tmp3(tmp2,tmp2+szArr2); std::vector< std::pair > partCompactFormat; bool ret0=MEDCouplingStructuredMesh::IsPartStructured(tmp,tmp+szArr,tmp3,partCompactFormat); @@ -3621,7 +3633,7 @@ namespace MEDCoupling { int szArr,sw,iTypppArr; std::vector stdvecTyyppArr; - const int *tmp=convertObjToPossibleCpp1_Safe(gridStruct,sw,szArr,iTypppArr,stdvecTyyppArr); + const int *tmp=convertIntStarLikePyObjToCppIntStar(gridStruct,sw,szArr,iTypppArr,stdvecTyyppArr); self->setNodeGridStructure(tmp,tmp+szArr); } } @@ -3661,7 +3673,7 @@ namespace MEDCoupling const double *originPtr(0),*dxyzPtr(0); int sw,sz,val0; std::vector bb0; - nodeStrctPtr=convertObjToPossibleCpp1_Safe(nodeStrct,sw,sz,val0,bb0); + nodeStrctPtr=convertIntStarLikePyObjToCppIntStar(nodeStrct,sw,sz,val0,bb0); // double val,val2; std::vector bb,bb2; @@ -3686,7 +3698,7 @@ namespace MEDCoupling { int sw,sz,val0; std::vector bb0; - const int *nodeStrctPtr(convertObjToPossibleCpp1_Safe(nodeStrct,sw,sz,val0,bb0)); + const int *nodeStrctPtr(convertIntStarLikePyObjToCppIntStar(nodeStrct,sw,sz,val0,bb0)); self->setNodeStruct(nodeStrctPtr,nodeStrctPtr+sz); } @@ -3879,7 +3891,7 @@ namespace MEDCoupling { int sw,sz(-1); int v0; std::vector v1; - const int *cellIdsBg(convertObjToPossibleCpp1_Safe(cellIds,sw,sz,v0,v1)); + const int *cellIdsBg(convertIntStarLikePyObjToCppIntStar(cellIds,sw,sz,v0,v1)); return self->computeTupleIdsToSelectFromCellIds(cellIdsBg,cellIdsBg+sz); } @@ -3929,6 +3941,7 @@ namespace MEDCoupling { public: static MEDCouplingFieldTemplate *New(const MEDCouplingFieldDouble& f) throw(INTERP_KERNEL::Exception); + static MEDCouplingFieldTemplate *New(const MEDCouplingFieldFloat& f) throw(INTERP_KERNEL::Exception); static MEDCouplingFieldTemplate *New(const MEDCouplingFieldInt& f) throw(INTERP_KERNEL::Exception); static MEDCouplingFieldTemplate *New(TypeOfField type); std::string simpleRepr() const throw(INTERP_KERNEL::Exception); @@ -3940,6 +3953,11 @@ namespace MEDCoupling return MEDCouplingFieldTemplate::New(f); } + MEDCouplingFieldTemplate(const MEDCouplingFieldFloat& f) throw(INTERP_KERNEL::Exception) + { + return MEDCouplingFieldTemplate::New(f); + } + MEDCouplingFieldTemplate(const MEDCouplingFieldInt& f) throw(INTERP_KERNEL::Exception) { return MEDCouplingFieldTemplate::New(f); @@ -4303,7 +4321,7 @@ namespace MEDCoupling { int szArr,sw,iTypppArr; std::vector stdvecTyyppArr; - const int *tmp=convertObjToPossibleCpp1_Safe(li,sw,szArr,iTypppArr,stdvecTyyppArr); + const int *tmp=convertIntStarLikePyObjToCppIntStar(li,sw,szArr,iTypppArr,stdvecTyyppArr); self->renumberCells(tmp,check); } @@ -4311,7 +4329,7 @@ namespace MEDCoupling { int szArr,sw,iTypppArr; std::vector stdvecTyyppArr; - const int *tmp=convertObjToPossibleCpp1_Safe(li,sw,szArr,iTypppArr,stdvecTyyppArr); + const int *tmp=convertIntStarLikePyObjToCppIntStar(li,sw,szArr,iTypppArr,stdvecTyyppArr); self->renumberCellsWithoutMesh(tmp,check); } @@ -4319,7 +4337,7 @@ namespace MEDCoupling { int szArr,sw,iTypppArr; std::vector stdvecTyyppArr; - const int *tmp=convertObjToPossibleCpp1_Safe(li,sw,szArr,iTypppArr,stdvecTyyppArr); + const int *tmp=convertIntStarLikePyObjToCppIntStar(li,sw,szArr,iTypppArr,stdvecTyyppArr); self->renumberNodes(tmp,eps); } @@ -4327,7 +4345,7 @@ namespace MEDCoupling { int szArr,sw,iTypppArr; std::vector stdvecTyyppArr; - const int *tmp=convertObjToPossibleCpp1_Safe(li,sw,szArr,iTypppArr,stdvecTyyppArr); + const int *tmp=convertIntStarLikePyObjToCppIntStar(li,sw,szArr,iTypppArr,stdvecTyyppArr); self->renumberNodesWithoutMesh(tmp,newNbOfNodes,eps); } @@ -4421,7 +4439,7 @@ namespace MEDCoupling DataArrayDoubleTuple *aa; std::vector bb; int sw; - convertObjToPossibleCpp5(obj,sw,val,a,aa,bb); + convertDoubleStarLikePyObjToCpp_2(obj,sw,val,a,aa,bb); switch(sw) { case 1: @@ -4503,7 +4521,7 @@ namespace MEDCoupling DataArrayDoubleTuple *aa; std::vector bb; int sw; - convertObjToPossibleCpp5(obj,sw,val,a,aa,bb); + convertDoubleStarLikePyObjToCpp_2(obj,sw,val,a,aa,bb); switch(sw) { case 1: @@ -4577,7 +4595,7 @@ namespace MEDCoupling DataArrayDoubleTuple *aa; std::vector bb; int sw; - convertObjToPossibleCpp5(obj,sw,val,a,aa,bb); + convertDoubleStarLikePyObjToCpp_2(obj,sw,val,a,aa,bb); switch(sw) { case 1: @@ -4653,7 +4671,7 @@ namespace MEDCoupling DataArrayDoubleTuple *aa; std::vector bb; int sw; - convertObjToPossibleCpp5(obj,sw,val,a,aa,bb); + convertDoubleStarLikePyObjToCpp_2(obj,sw,val,a,aa,bb); switch(sw) { case 1: @@ -4719,7 +4737,7 @@ namespace MEDCoupling DataArrayDoubleTuple *aa; std::vector bb; int sw; - convertObjToPossibleCpp5(obj,sw,val,a,aa,bb); + convertDoubleStarLikePyObjToCpp_2(obj,sw,val,a,aa,bb); switch(sw) { case 1: @@ -4785,7 +4803,7 @@ namespace MEDCoupling DataArrayDoubleTuple *aa; std::vector bb; int sw; - convertObjToPossibleCpp5(obj,sw,val,a,aa,bb); + convertDoubleStarLikePyObjToCpp_2(obj,sw,val,a,aa,bb); switch(sw) { case 1: @@ -4851,7 +4869,7 @@ namespace MEDCoupling DataArrayDoubleTuple *aa; std::vector bb; int sw; - convertObjToPossibleCpp5(obj,sw,val,a,aa,bb); + convertDoubleStarLikePyObjToCpp_2(obj,sw,val,a,aa,bb); switch(sw) { case 1: @@ -4919,7 +4937,7 @@ namespace MEDCoupling DataArrayDoubleTuple *aa; std::vector bb; int sw; - convertObjToPossibleCpp5(obj,sw,val,a,aa,bb); + convertDoubleStarLikePyObjToCpp_2(obj,sw,val,a,aa,bb); switch(sw) { case 1: @@ -5355,6 +5373,74 @@ namespace MEDCoupling } } }; + + class MEDCouplingFieldFloat : public MEDCouplingField + { + public: + static MEDCouplingFieldFloat *New(TypeOfField type, TypeOfTimeDiscretization td=ONE_TIME); + static MEDCouplingFieldFloat *New(const MEDCouplingFieldTemplate& ft, TypeOfTimeDiscretization td=ONE_TIME); + void setTimeUnit(const std::string& unit) throw(INTERP_KERNEL::Exception); + std::string getTimeUnit() const throw(INTERP_KERNEL::Exception); + void setTime(double val, int iteration, int order) throw(INTERP_KERNEL::Exception); + void setArray(DataArrayFloat *array) throw(INTERP_KERNEL::Exception); + MEDCouplingFieldFloat *deepCopy() const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldFloat *clone(bool recDeepCpy) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldFloat *cloneWithMesh(bool recDeepCpy) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *convertToDblField() const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldFloat *buildSubPartRange(int begin, int end, int step) const throw(INTERP_KERNEL::Exception); + %extend { + MEDCouplingFieldFloat(TypeOfField type, TypeOfTimeDiscretization td=ONE_TIME) + { + return MEDCouplingFieldFloat::New(type,td); + } + + MEDCouplingFieldFloat(const MEDCouplingFieldTemplate& ft, TypeOfTimeDiscretization td=ONE_TIME) + { + return MEDCouplingFieldFloat::New(ft,td); + } + + std::string __str__() const throw(INTERP_KERNEL::Exception) + { + return self->simpleRepr(); + } + + std::string __repr__() const throw(INTERP_KERNEL::Exception) + { + std::ostringstream oss; + self->reprQuickOverview(oss); + return oss.str(); + } + + MEDCouplingFieldFloat *buildSubPart(PyObject *li) const throw(INTERP_KERNEL::Exception) + { + return fieldT_buildSubPart(self,li); + } + + MEDCouplingFieldFloat *__getitem__(PyObject *li) const throw(INTERP_KERNEL::Exception) + { + return fieldT__getitem__(self,li); + } + + DataArrayFloat *getArray() throw(INTERP_KERNEL::Exception) + { + DataArrayFloat *ret=self->getArray(); + if(ret) + ret->incrRef(); + return ret; + } + + PyObject *getTime() throw(INTERP_KERNEL::Exception) + { + int tmp1,tmp2; + double tmp0=self->getTime(tmp1,tmp2); + PyObject *res = PyList_New(3); + PyList_SetItem(res,0,SWIG_From_double(tmp0)); + PyList_SetItem(res,1,SWIG_From_int(tmp1)); + PyList_SetItem(res,2,SWIG_From_int(tmp2)); + return res; + } + } + }; class MEDCouplingDefinitionTime { @@ -5724,7 +5810,7 @@ namespace MEDCoupling const double *originPtr(0),*dxyzPtr(0); int sw,sz,val0; std::vector bb0; - nodeStrctPtr=convertObjToPossibleCpp1_Safe(nodeStrct,sw,sz,val0,bb0); + nodeStrctPtr=convertIntStarLikePyObjToCppIntStar(nodeStrct,sw,sz,val0,bb0); // double val,val2; std::vector bb,bb2; diff --git a/src/MEDCoupling_Swig/MEDCouplingDataArrayTraits.hxx b/src/MEDCoupling_Swig/MEDCouplingDataArrayTraits.hxx index 10521d823..c22b758dc 100644 --- a/src/MEDCoupling_Swig/MEDCouplingDataArrayTraits.hxx +++ b/src/MEDCoupling_Swig/MEDCouplingDataArrayTraits.hxx @@ -345,6 +345,7 @@ struct NPYTraits { static const int NPYObjectType=NPY_FLOAT; static PyTypeObject *NPYFunc; + static PyObject *Array_SWIGTYPE; }; #endif diff --git a/src/MEDCoupling_Swig/MEDCouplingDataArrayTypemaps.i b/src/MEDCoupling_Swig/MEDCouplingDataArrayTypemaps.i index ef8946fbf..93c2f8cf2 100644 --- a/src/MEDCoupling_Swig/MEDCouplingDataArrayTypemaps.i +++ b/src/MEDCoupling_Swig/MEDCouplingDataArrayTypemaps.i @@ -1272,7 +1272,7 @@ static void convertFromPyObjVectorOfObj(PyObject *pyLi, swig_type_info *ty, cons * * switch between (int,vector,DataArrayInt) */ -static void convertObjToPossibleCpp1(PyObject *value, int& sw, int& iTyypp, std::vector& stdvecTyypp, MEDCoupling::DataArrayInt *& daIntTyypp, MEDCoupling::DataArrayIntTuple *&daIntTuple) throw(INTERP_KERNEL::Exception) +static void convertIntStarLikePyObjToCpp(PyObject *value, int& sw, int& iTyypp, std::vector& stdvecTyypp, MEDCoupling::DataArrayInt *& daIntTyypp, MEDCoupling::DataArrayIntTuple *&daIntTuple) throw(INTERP_KERNEL::Exception) { sw=-1; if(PyInt_Check(value)) @@ -1335,6 +1335,86 @@ static void convertObjToPossibleCpp1(PyObject *value, int& sw, int& iTyypp, std: throw INTERP_KERNEL::Exception("5 types accepted : integer, tuple of integer, list of integer, DataArrayInt, DataArrayIntTuple"); } +/*! + * if python int -> cpp int sw=1 + * if python list[int] -> cpp vector sw=2 + * if python tuple[int] -> cpp vector sw=2 + * if python DataArrayInt -> cpp DataArrayInt sw=3 + * if python DataArrayIntTuple -> cpp DataArrayIntTuple sw=4 + * + * switch between (int,vector,DataArrayInt) + */ +static const int *convertIntStarLikePyObjToCppIntStar(PyObject *value, int& sw, int& sz, int& iTyypp, std::vector& stdvecTyypp) throw(INTERP_KERNEL::Exception) +{ + sw=-1; + if(PyInt_Check(value)) + { + iTyypp=(int)PyInt_AS_LONG(value); + sw=1; sz=1; + return &iTyypp; + } + if(PyTuple_Check(value)) + { + int size=PyTuple_Size(value); + stdvecTyypp.resize(size); + for(int i=0;i(argp); + if(daIntTyypp) + { + sw=3; sz=daIntTyypp->getNbOfElems(); + return daIntTyypp->begin(); + } + else + { + sz=0; + return 0; + } + } + status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayIntTuple,0|0); + if(SWIG_IsOK(status)) + { + MEDCoupling::DataArrayIntTuple *daIntTuple=reinterpret_cast< MEDCoupling::DataArrayIntTuple * >(argp); + sw=4; sz=daIntTuple->getNumberOfCompo(); + return daIntTuple->getConstPointer(); + } + throw INTERP_KERNEL::Exception("5 types accepted : integer, tuple of integer, list of integer, DataArrayInt, DataArrayIntTuple"); +} + /*! * if python double -> cpp double sw=1 * if python int -> cpp double sw=1 @@ -1347,7 +1427,7 @@ static void convertObjToPossibleCpp1(PyObject *value, int& sw, int& iTyypp, std: * switch between (int,vector,DataArrayInt) */ template -void convertObjToPossibleCpp4(PyObject *value, int& sw, T& iTyypp, std::vector& stdvecTyypp, typename MEDCoupling::Traits::ArrayType *& daIntTyypp, swig_type_info *ti) throw(INTERP_KERNEL::Exception) +void considerPyObjAsATStarLikeObject(PyObject *value, int& sw, T& iTyypp, std::vector& stdvecTyypp, typename MEDCoupling::Traits::ArrayType *& daIntTyypp, swig_type_info *ti) throw(INTERP_KERNEL::Exception) { sw=-1; if(PyFloat_Check(value)) @@ -1421,7 +1501,7 @@ void convertObjToPossibleCpp4(PyObject *value, int& sw, T& iTyypp, std::vector,DataArrayInt) */ -static void convertObjToPossibleCpp44(PyObject *value, int& sw, double& iTyypp, std::vector& stdvecTyypp, MEDCoupling::DataArrayDoubleTuple *& daIntTyypp) throw(INTERP_KERNEL::Exception) +static void convertDoubleStarLikePyObjToCpp(PyObject *value, int& sw, double& iTyypp, std::vector& stdvecTyypp, MEDCoupling::DataArrayDoubleTuple *& daIntTyypp) throw(INTERP_KERNEL::Exception) { sw=-1; if(PyFloat_Check(value)) @@ -1484,6 +1564,87 @@ static void convertObjToPossibleCpp44(PyObject *value, int& sw, double& iTyypp, sw=3; } +/*! + * if value int -> cpp val sw=1 + * if value double -> cpp val sw=1 + * if value DataArrayDouble -> cpp DataArrayDouble sw=2 + * if value DataArrayDoubleTuple -> cpp DataArrayDoubleTuple sw=3 + * if value list[int,double] -> cpp std::vector sw=4 + * if value tuple[int,double] -> cpp std::vector sw=4 + */ +static void convertDoubleStarLikePyObjToCpp_2(PyObject *value, int& sw, double& val, MEDCoupling::DataArrayDouble *&d, MEDCoupling::DataArrayDoubleTuple *&e, std::vector& f) +{ + sw=-1; + if(PyFloat_Check(value)) + { + val=PyFloat_AS_DOUBLE(value); + sw=1; + return; + } + if(PyInt_Check(value)) + { + val=(double)PyInt_AS_LONG(value); + sw=1; + return; + } + if(PyTuple_Check(value)) + { + int size=PyTuple_Size(value); + f.resize(size); + for(int i=0;i(argp); + sw=2; + return ; + } + status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayDoubleTuple,0|0); + if(SWIG_IsOK(status)) + { + e=reinterpret_cast< MEDCoupling::DataArrayDoubleTuple * >(argp); + sw=3; + return ; + } + throw INTERP_KERNEL::Exception("4 types accepted : integer, double, DataArrayDouble, DataArrayDoubleTuple"); +} + /*! * if python int -> cpp int sw=1 * if python list[int] -> cpp vector sw=2 @@ -1493,7 +1654,7 @@ static void convertObjToPossibleCpp44(PyObject *value, int& sw, double& iTyypp, * * switch between (int,vector,DataArrayInt) */ -static void convertObjToPossibleCpp2(PyObject *value, int nbelem, int& sw, int& iTyypp, std::vector& stdvecTyypp, std::pair >& p, MEDCoupling::DataArrayInt *& daIntTyypp) throw(INTERP_KERNEL::Exception) +static void convertIntStarOrSliceLikePyObjToCpp(PyObject *value, int nbelem, int& sw, int& iTyypp, std::vector& stdvecTyypp, std::pair >& p, MEDCoupling::DataArrayInt *& daIntTyypp) throw(INTERP_KERNEL::Exception) { const char *msg="5 types accepted : integer, tuple of integer, list of integer, slice, DataArrayInt, DataArrayIntTuple"; sw=-1; @@ -1581,11 +1742,11 @@ static void convertObjToPossibleCpp2(PyObject *value, int nbelem, int& sw, int& } /*! - * Idem than convertObjToPossibleCpp2 + * Idem than convertIntStarOrSliceLikePyObjToCpp */ -static void convertObjToPossibleCpp2WithNegIntInterp(PyObject *value, int nbelem, int& sw, int& iTyypp, std::vector& stdvecTyypp, std::pair >& p, MEDCoupling::DataArrayInt *& daIntTyypp) throw(INTERP_KERNEL::Exception) +static void convertIntStarOrSliceLikePyObjToCppWithNegIntInterp(PyObject *value, int nbelem, int& sw, int& iTyypp, std::vector& stdvecTyypp, std::pair >& p, MEDCoupling::DataArrayInt *& daIntTyypp) throw(INTERP_KERNEL::Exception) { - convertObjToPossibleCpp2(value,nbelem,sw,iTyypp,stdvecTyypp,p,daIntTyypp); + convertIntStarOrSliceLikePyObjToCpp(value,nbelem,sw,iTyypp,stdvecTyypp,p,daIntTyypp); if(sw==1) { iTyypp=InterpreteNegativeInt(iTyypp,nbelem); @@ -1778,7 +1939,7 @@ static void convertObjToPossibleCpp3(PyObject *value, int nbTuple, int nbCompo, { if(!PyTuple_Check(value)) { - convertObjToPossibleCpp2WithNegIntInterp(value,nbTuple,sw,it,vt,pt,dt); + convertIntStarOrSliceLikePyObjToCppWithNegIntInterp(value,nbTuple,sw,it,vt,pt,dt); return ; } else @@ -1788,94 +1949,13 @@ static void convertObjToPossibleCpp3(PyObject *value, int nbTuple, int nbCompo, throw INTERP_KERNEL::Exception("Unexpected nb of slice element : 1 or 2 expected !\n1st is for tuple selection, 2nd for component selection !"); PyObject *ob0=PyTuple_GetItem(value,0); int sw1,sw2; - convertObjToPossibleCpp2WithNegIntInterp(ob0,nbTuple,sw1,it,vt,pt,dt); + convertIntStarOrSliceLikePyObjToCppWithNegIntInterp(ob0,nbTuple,sw1,it,vt,pt,dt); PyObject *ob1=PyTuple_GetItem(value,1); - convertObjToPossibleCpp2WithNegIntInterp(ob1,nbCompo,sw2,ic,vc,pc,dc); + convertIntStarOrSliceLikePyObjToCppWithNegIntInterp(ob1,nbCompo,sw2,ic,vc,pc,dc); sw=4*sw2+sw1; } } -/*! - * if value int -> cpp val sw=1 - * if value double -> cpp val sw=1 - * if value DataArrayDouble -> cpp DataArrayDouble sw=2 - * if value DataArrayDoubleTuple -> cpp DataArrayDoubleTuple sw=3 - * if value list[int,double] -> cpp std::vector sw=4 - * if value tuple[int,double] -> cpp std::vector sw=4 - */ -static void convertObjToPossibleCpp5(PyObject *value, int& sw, double& val, MEDCoupling::DataArrayDouble *&d, MEDCoupling::DataArrayDoubleTuple *&e, std::vector& f) -{ - sw=-1; - if(PyFloat_Check(value)) - { - val=PyFloat_AS_DOUBLE(value); - sw=1; - return; - } - if(PyInt_Check(value)) - { - val=(double)PyInt_AS_LONG(value); - sw=1; - return; - } - if(PyTuple_Check(value)) - { - int size=PyTuple_Size(value); - f.resize(size); - for(int i=0;i(argp); - sw=2; - return ; - } - status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayDoubleTuple,0|0); - if(SWIG_IsOK(status)) - { - e=reinterpret_cast< MEDCoupling::DataArrayDoubleTuple * >(argp); - sw=3; - return ; - } - throw INTERP_KERNEL::Exception("4 types accepted : integer, double, DataArrayDouble, DataArrayDoubleTuple"); -} - /*! * if value int -> cpp val sw=1 * if value double -> cpp val sw=1 @@ -2257,86 +2337,6 @@ static const double *convertObjToPossibleCpp5_SingleCompo(PyObject *value, int& throw INTERP_KERNEL::Exception("4 types accepted : integer, double, DataArrayDouble, DataArrayDoubleTuple"); } -/*! - * if python int -> cpp int sw=1 - * if python list[int] -> cpp vector sw=2 - * if python tuple[int] -> cpp vector sw=2 - * if python DataArrayInt -> cpp DataArrayInt sw=3 - * if python DataArrayIntTuple -> cpp DataArrayIntTuple sw=4 - * - * switch between (int,vector,DataArrayInt) - */ -static const int *convertObjToPossibleCpp1_Safe(PyObject *value, int& sw, int& sz, int& iTyypp, std::vector& stdvecTyypp) throw(INTERP_KERNEL::Exception) -{ - sw=-1; - if(PyInt_Check(value)) - { - iTyypp=(int)PyInt_AS_LONG(value); - sw=1; sz=1; - return &iTyypp; - } - if(PyTuple_Check(value)) - { - int size=PyTuple_Size(value); - stdvecTyypp.resize(size); - for(int i=0;i(argp); - if(daIntTyypp) - { - sw=3; sz=daIntTyypp->getNbOfElems(); - return daIntTyypp->begin(); - } - else - { - sz=0; - return 0; - } - } - status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayIntTuple,0|0); - if(SWIG_IsOK(status)) - { - MEDCoupling::DataArrayIntTuple *daIntTuple=reinterpret_cast< MEDCoupling::DataArrayIntTuple * >(argp); - sw=4; sz=daIntTuple->getNumberOfCompo(); - return daIntTuple->getConstPointer(); - } - throw INTERP_KERNEL::Exception("5 types accepted : integer, tuple of integer, list of integer, DataArrayInt, DataArrayIntTuple"); -} - static MEDCoupling::DataArray *CheckAndRetrieveDataArrayInstance(PyObject *obj, const char *msg) { void *aBasePtrVS=0; @@ -2548,7 +2548,7 @@ typename MEDCoupling::Traits::ArrayType *DataArrayT__setitem__internal(typena T i1; std::vector v1; typename MEDCoupling::Traits::ArrayType *d1=0; - convertObjToPossibleCpp4(value,sw1,i1,v1,d1,ti); + considerPyObjAsATStarLikeObject(value,sw1,i1,v1,d1,ti); int it1,ic1; std::vector vt1,vc1; std::pair > pt1,pc1; @@ -2996,14 +2996,22 @@ struct SWIGTITraits template<> struct SWIGTITraits -{ static swig_type_info *TI; }; +{ static swig_type_info *TI; static swig_type_info *TI_TUPLE; }; template<> struct SWIGTITraits -{ static swig_type_info *TI; }; +{ static swig_type_info *TI; static swig_type_info *TI_TUPLE; }; + +template<> +struct SWIGTITraits +{ static swig_type_info *TI; static swig_type_info *TI_TUPLE; }; swig_type_info *SWIGTITraits::TI=NULL;//unfortunately SWIGTYPE_p_MEDCoupling__DataArrayDouble is null when called here ! Postpone initialization at inlined initializeMe() swig_type_info *SWIGTITraits::TI=NULL;//unfortunately SWIGTYPE_p_MEDCoupling__DataArrayFloat is null when called here ! Postpone initialization at inlined initializeMe() +swig_type_info *SWIGTITraits::TI=NULL;//unfortunately SWIGTYPE_p_MEDCoupling__DataArrayFloat is null when called here ! Postpone initialization at inlined initializeMe() +swig_type_info *SWIGTITraits::TI_TUPLE=NULL;//unfortunately SWIGTYPE_p_MEDCoupling__DataArrayDouble is null when called here ! Postpone initialization at inlined initializeMe() +swig_type_info *SWIGTITraits::TI_TUPLE=NULL;//unfortunately SWIGTYPE_p_MEDCoupling__DataArrayFloat is null when called here ! Postpone initialization at inlined initializeMe() +swig_type_info *SWIGTITraits::TI_TUPLE=NULL;//unfortunately SWIGTYPE_p_MEDCoupling__DataArrayFloat is null when called here ! Postpone initialization at inlined initializeMe() PyTypeObject *NPYTraits::NPYFunc=&PyCallBackDataArrayDouble_RefType; diff --git a/src/MEDCoupling_Swig/MEDCouplingFieldDiscretization.i b/src/MEDCoupling_Swig/MEDCouplingFieldDiscretization.i index e152e6e33..8c5ca3fea 100644 --- a/src/MEDCoupling_Swig/MEDCouplingFieldDiscretization.i +++ b/src/MEDCoupling_Swig/MEDCouplingFieldDiscretization.i @@ -69,7 +69,7 @@ namespace MEDCoupling { int sz=0,sw=-1,val1=-1; std::vector val2; - const int *inp=convertObjToPossibleCpp1_Safe(li,sw,sz,val1,val2); + const int *inp=convertIntStarLikePyObjToCppIntStar(li,sw,sz,val1,val2); return self->clonePart(inp,inp+sz); } @@ -103,7 +103,7 @@ namespace MEDCoupling { std::vector vVal; int iVal=-1; int sz=-1,sw=0; - const int *tupleIdsBg=convertObjToPossibleCpp1_Safe(tupleIds,sw,sz,iVal,vVal); + const int *tupleIdsBg=convertIntStarLikePyObjToCppIntStar(tupleIds,sw,sz,iVal,vVal); if(sw==0) throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretization::computeMeshRestrictionFromTupleIds : none parameter in input !"); DataArrayInt *ret0=0,*ret1=0; @@ -225,7 +225,7 @@ namespace MEDCoupling { int sw,sz(-1); int v0; std::vector v1; - const int *ids(convertObjToPossibleCpp1_Safe(li,sw,sz,v0,v1)); + const int *ids(convertIntStarLikePyObjToCppIntStar(li,sw,sz,v0,v1)); self->renumberCells(ids,check); } @@ -237,7 +237,7 @@ namespace MEDCoupling // int sw,sz(-1); int v0; std::vector v1; - const int *old2NewBg(convertObjToPossibleCpp1_Safe(old2New,sw,sz,v0,v1)); + const int *old2NewBg(convertIntStarLikePyObjToCppIntStar(old2New,sw,sz,v0,v1)); // self->renumberArraysForCell(mesh,input1,old2NewBg,check); } @@ -246,7 +246,7 @@ namespace MEDCoupling { int sw,sz(-1); int v0; std::vector v1; - const int *cellIdsBg(convertObjToPossibleCpp1_Safe(cellIds,sw,sz,v0,v1)); + const int *cellIdsBg(convertIntStarLikePyObjToCppIntStar(cellIds,sw,sz,v0,v1)); return self->computeTupleIdsToSelectFromCellIds(mesh,cellIdsBg,cellIdsBg+sz); } @@ -254,7 +254,7 @@ namespace MEDCoupling { int sw,sz(-1); int v0; std::vector v1; - const int *idsBg(convertObjToPossibleCpp1_Safe(ids,sw,sz,v0,v1)); + const int *idsBg(convertIntStarLikePyObjToCppIntStar(ids,sw,sz,v0,v1)); DataArrayInt *di(0); MEDCouplingMesh *ret0=self->buildSubMeshData(mesh,idsBg,idsBg+sz,di); PyObject *ret=PyTuple_New(2); @@ -267,7 +267,7 @@ namespace MEDCoupling { int sw,sz(-1); int v0; std::vector v1; - const int *old2NewBg(convertObjToPossibleCpp1_Safe(old2New,sw,sz,v0,v1)); + const int *old2NewBg(convertIntStarLikePyObjToCppIntStar(old2New,sw,sz,v0,v1)); self->renumberValuesOnNodes(epsOnVals,old2NewBg,newNbOfNodes,arr); } @@ -275,7 +275,7 @@ namespace MEDCoupling { int sw,sz(-1); int v0; std::vector v1; - const int *old2NewBg(convertObjToPossibleCpp1_Safe(old2New,sw,sz,v0,v1)); + const int *old2NewBg(convertIntStarLikePyObjToCppIntStar(old2New,sw,sz,v0,v1)); self->renumberValuesOnCells(epsOnVals,mesh,old2NewBg,newSz,arr); } @@ -283,7 +283,7 @@ namespace MEDCoupling { int sw,sz(-1); int v0; std::vector v1; - const int *new2oldBg(convertObjToPossibleCpp1_Safe(new2old,sw,sz,v0,v1)); + const int *new2oldBg(convertIntStarLikePyObjToCppIntStar(new2old,sw,sz,v0,v1)); self->renumberValuesOnCellsR(mesh,new2oldBg,newSz,arr); } } diff --git a/src/MEDCoupling_Swig/MEDCouplingMemArray.i b/src/MEDCoupling_Swig/MEDCouplingMemArray.i index 0b6ca517b..5c863dccd 100644 --- a/src/MEDCoupling_Swig/MEDCouplingMemArray.i +++ b/src/MEDCoupling_Swig/MEDCouplingMemArray.i @@ -1225,7 +1225,7 @@ namespace MEDCoupling { int sw,sz,val; std::vector val2; - const int *bg=convertObjToPossibleCpp1_Safe(indexArr,sw,sz,val,val2); + const int *bg=convertIntStarLikePyObjToCppIntStar(indexArr,sw,sz,val,val2); return self->accumulatePerChunck(bg,bg+sz); } @@ -1367,7 +1367,7 @@ namespace MEDCoupling } #endif // - convertObjToPossibleCpp5(obj,sw,val,a,aa,bb); + convertDoubleStarLikePyObjToCpp_2(obj,sw,val,a,aa,bb); switch(sw) { case 1: @@ -1403,7 +1403,7 @@ namespace MEDCoupling DataArrayDoubleTuple *aa; std::vector bb; int sw; - convertObjToPossibleCpp5(obj,sw,val,a,aa,bb); + convertDoubleStarLikePyObjToCpp_2(obj,sw,val,a,aa,bb); switch(sw) { case 1: @@ -1435,7 +1435,7 @@ namespace MEDCoupling DataArrayDoubleTuple *aa; std::vector bb; int sw; - convertObjToPossibleCpp5(obj,sw,val,a,aa,bb); + convertDoubleStarLikePyObjToCpp_2(obj,sw,val,a,aa,bb); switch(sw) { case 1: @@ -1495,7 +1495,7 @@ namespace MEDCoupling } #endif // - convertObjToPossibleCpp5(obj,sw,val,a,aa,bb); + convertDoubleStarLikePyObjToCpp_2(obj,sw,val,a,aa,bb); switch(sw) { case 1: @@ -1531,7 +1531,7 @@ namespace MEDCoupling DataArrayDoubleTuple *aa; std::vector bb; int sw; - convertObjToPossibleCpp5(obj,sw,val,a,aa,bb); + convertDoubleStarLikePyObjToCpp_2(obj,sw,val,a,aa,bb); switch(sw) { case 1: @@ -1563,7 +1563,7 @@ namespace MEDCoupling DataArrayDoubleTuple *aa; std::vector bb; int sw; - convertObjToPossibleCpp5(obj,sw,val,a,aa,bb); + convertDoubleStarLikePyObjToCpp_2(obj,sw,val,a,aa,bb); switch(sw) { case 1: @@ -1623,7 +1623,7 @@ namespace MEDCoupling } #endif // - convertObjToPossibleCpp5(obj,sw,val,a,aa,bb); + convertDoubleStarLikePyObjToCpp_2(obj,sw,val,a,aa,bb); switch(sw) { case 1: @@ -1659,7 +1659,7 @@ namespace MEDCoupling DataArrayDoubleTuple *aa; std::vector bb; int sw; - convertObjToPossibleCpp5(obj,sw,val,a,aa,bb); + convertDoubleStarLikePyObjToCpp_2(obj,sw,val,a,aa,bb); switch(sw) { case 1: @@ -1691,7 +1691,7 @@ namespace MEDCoupling DataArrayDoubleTuple *aa; std::vector bb; int sw; - convertObjToPossibleCpp5(obj,sw,val,a,aa,bb); + convertDoubleStarLikePyObjToCpp_2(obj,sw,val,a,aa,bb); switch(sw) { case 1: @@ -1751,7 +1751,7 @@ namespace MEDCoupling } #endif // - convertObjToPossibleCpp5(obj,sw,val,a,aa,bb); + convertDoubleStarLikePyObjToCpp_2(obj,sw,val,a,aa,bb); switch(sw) { case 1: @@ -1789,7 +1789,7 @@ namespace MEDCoupling DataArrayDoubleTuple *aa; std::vector bb; int sw; - convertObjToPossibleCpp5(obj,sw,val,a,aa,bb); + convertDoubleStarLikePyObjToCpp_2(obj,sw,val,a,aa,bb); switch(sw) { case 1: @@ -1821,7 +1821,7 @@ namespace MEDCoupling DataArrayDoubleTuple *aa; std::vector bb; int sw; - convertObjToPossibleCpp5(obj,sw,val,a,aa,bb); + convertDoubleStarLikePyObjToCpp_2(obj,sw,val,a,aa,bb); switch(sw) { case 1: @@ -1865,7 +1865,7 @@ namespace MEDCoupling DataArrayDoubleTuple *aa; std::vector bb; int sw; - convertObjToPossibleCpp5(obj,sw,val,a,aa,bb); + convertDoubleStarLikePyObjToCpp_2(obj,sw,val,a,aa,bb); switch(sw) { case 1: @@ -1901,7 +1901,7 @@ namespace MEDCoupling DataArrayDoubleTuple *aa; std::vector bb; int sw; - convertObjToPossibleCpp5(obj,sw,val,a,aa,bb); + convertDoubleStarLikePyObjToCpp_2(obj,sw,val,a,aa,bb); switch(sw) { case 1: @@ -1933,7 +1933,7 @@ namespace MEDCoupling DataArrayDoubleTuple *aa; std::vector bb; int sw; - convertObjToPossibleCpp5(obj,sw,val,a,aa,bb); + convertDoubleStarLikePyObjToCpp_2(obj,sw,val,a,aa,bb); switch(sw) { case 1: @@ -2107,7 +2107,7 @@ namespace MEDCoupling MEDCoupling::DataArrayInt *daIntTyypp=0; const double *pt=self->getConstPointer(); int nbc=self->getNumberOfCompo(); - convertObjToPossibleCpp2WithNegIntInterp(obj,nbc,sw,singleVal,multiVal,slic,daIntTyypp); + convertIntStarOrSliceLikePyObjToCppWithNegIntInterp(obj,nbc,sw,singleVal,multiVal,slic,daIntTyypp); switch(sw) { case 1: @@ -2171,13 +2171,13 @@ namespace MEDCoupling std::vector multiValV; MEDCoupling::DataArrayDoubleTuple *daIntTyyppV=0; int nbc=self->getNumberOfCompo(); - convertObjToPossibleCpp44(value,sw1,singleValV,multiValV,daIntTyyppV); + convertDoubleStarLikePyObjToCpp(value,sw1,singleValV,multiValV,daIntTyyppV); int singleVal; std::vector multiVal; std::pair > slic; MEDCoupling::DataArrayInt *daIntTyypp=0; double *pt=self->getPointer(); - convertObjToPossibleCpp2WithNegIntInterp(obj,nbc,sw2,singleVal,multiVal,slic,daIntTyypp); + convertIntStarOrSliceLikePyObjToCppWithNegIntInterp(obj,nbc,sw2,singleVal,multiVal,slic,daIntTyypp); switch(sw2) { case 1: @@ -2643,7 +2643,7 @@ namespace MEDCoupling { int sw,sz,val; std::vector val2; - const int *bg=convertObjToPossibleCpp1_Safe(indexArr,sw,sz,val,val2); + const int *bg=convertIntStarLikePyObjToCppIntStar(indexArr,sw,sz,val,val2); return self->accumulatePerChunck(bg,bg+sz); } @@ -2651,7 +2651,7 @@ namespace MEDCoupling { int sw,sz,val; std::vector val2; - const int *bg(convertObjToPossibleCpp1_Safe(inputTuple,sw,sz,val,val2)); + const int *bg(convertIntStarLikePyObjToCppIntStar(inputTuple,sw,sz,val,val2)); return self->findIdsEqualTuple(bg,bg+sz); } @@ -2691,8 +2691,8 @@ namespace MEDCoupling int newNbOfTuples=-1; int szArr,szArrI,sw,iTypppArr,iTypppArrI; std::vector stdvecTyyppArr,stdvecTyyppArrI; - const int *arrPtr=convertObjToPossibleCpp1_Safe(arr,sw,szArr,iTypppArr,stdvecTyyppArr); - const int *arrIPtr=convertObjToPossibleCpp1_Safe(arrI,sw,szArrI,iTypppArrI,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)); @@ -2705,7 +2705,7 @@ namespace MEDCoupling MCAuto ret(DataArrayInt::New()); int szArr,sw,iTypppArr; std::vector stdvecTyyppArr; - const int *arrPtr(convertObjToPossibleCpp1_Safe(arr,sw,szArr,iTypppArr,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(); @@ -2830,7 +2830,7 @@ namespace MEDCoupling std::vector multiVal; std::pair > slic; MEDCoupling::DataArrayInt *daIntTyypp=0; - convertObjToPossibleCpp2(obj,self->getNumberOfTuples(),sw,singleVal,multiVal,slic,daIntTyypp); + convertIntStarOrSliceLikePyObjToCpp(obj,self->getNumberOfTuples(),sw,singleVal,multiVal,slic,daIntTyypp); switch(sw) { case 1: @@ -2851,7 +2851,7 @@ namespace MEDCoupling std::vector multiVal; std::pair > slic; MEDCoupling::DataArrayInt *daIntTyypp=0; - convertObjToPossibleCpp2(obj,self->getNumberOfTuples(),sw,singleVal,multiVal,slic,daIntTyypp); + convertIntStarOrSliceLikePyObjToCpp(obj,self->getNumberOfTuples(),sw,singleVal,multiVal,slic,daIntTyypp); switch(sw) { case 1: @@ -3256,7 +3256,7 @@ namespace MEDCoupling std::vector v1; DataArrayInt *d1=0; DataArrayIntTuple *dd1=0; - convertObjToPossibleCpp1(value,sw1,i1,v1,d1,dd1); + convertIntStarLikePyObjToCpp(value,sw1,i1,v1,d1,dd1); int it1,ic1; std::vector vt1,vc1; std::pair > pt1,pc1; @@ -3668,7 +3668,7 @@ namespace MEDCoupling std::vector aa; DataArrayIntTuple *aaa; int sw; - convertObjToPossibleCpp1(obj,sw,val,aa,a,aaa); + convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa); switch(sw) { case 1: @@ -3704,7 +3704,7 @@ namespace MEDCoupling std::vector aa; DataArrayIntTuple *aaa; int sw; - convertObjToPossibleCpp1(obj,sw,val,aa,a,aaa); + convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa); switch(sw) { case 1: @@ -3736,7 +3736,7 @@ namespace MEDCoupling std::vector aa; DataArrayIntTuple *aaa; int sw; - convertObjToPossibleCpp1(obj,sw,val,aa,a,aaa); + convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa); switch(sw) { case 1: @@ -3778,7 +3778,7 @@ namespace MEDCoupling std::vector aa; DataArrayIntTuple *aaa; int sw; - convertObjToPossibleCpp1(obj,sw,val,aa,a,aaa); + convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa); switch(sw) { case 1: @@ -3814,7 +3814,7 @@ namespace MEDCoupling std::vector aa; DataArrayIntTuple *aaa; int sw; - convertObjToPossibleCpp1(obj,sw,val,aa,a,aaa); + convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa); switch(sw) { case 1: @@ -3846,7 +3846,7 @@ namespace MEDCoupling std::vector aa; DataArrayIntTuple *aaa; int sw; - convertObjToPossibleCpp1(obj,sw,val,aa,a,aaa); + convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa); switch(sw) { case 1: @@ -3888,7 +3888,7 @@ namespace MEDCoupling std::vector aa; DataArrayIntTuple *aaa; int sw; - convertObjToPossibleCpp1(obj,sw,val,aa,a,aaa); + convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa); switch(sw) { case 1: @@ -3924,7 +3924,7 @@ namespace MEDCoupling std::vector aa; DataArrayIntTuple *aaa; int sw; - convertObjToPossibleCpp1(obj,sw,val,aa,a,aaa); + convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa); switch(sw) { case 1: @@ -3956,7 +3956,7 @@ namespace MEDCoupling std::vector aa; DataArrayIntTuple *aaa; int sw; - convertObjToPossibleCpp1(obj,sw,val,aa,a,aaa); + convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa); switch(sw) { case 1: @@ -3998,7 +3998,7 @@ namespace MEDCoupling std::vector aa; DataArrayIntTuple *aaa; int sw; - convertObjToPossibleCpp1(obj,sw,val,aa,a,aaa); + convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa); switch(sw) { case 1: @@ -4034,7 +4034,7 @@ namespace MEDCoupling std::vector aa; DataArrayIntTuple *aaa; int sw; - convertObjToPossibleCpp1(obj,sw,val,aa,a,aaa); + convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa); switch(sw) { case 1: @@ -4066,7 +4066,7 @@ namespace MEDCoupling std::vector aa; DataArrayIntTuple *aaa; int sw; - convertObjToPossibleCpp1(obj,sw,val,aa,a,aaa); + convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa); switch(sw) { case 1: @@ -4108,7 +4108,7 @@ namespace MEDCoupling std::vector aa; DataArrayIntTuple *aaa; int sw; - convertObjToPossibleCpp1(obj,sw,val,aa,a,aaa); + convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa); switch(sw) { case 1: @@ -4144,7 +4144,7 @@ namespace MEDCoupling std::vector aa; DataArrayIntTuple *aaa; int sw; - convertObjToPossibleCpp1(obj,sw,val,aa,a,aaa); + convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa); switch(sw) { case 1: @@ -4180,7 +4180,7 @@ namespace MEDCoupling std::vector aa; DataArrayIntTuple *aaa; int sw; - convertObjToPossibleCpp1(obj,sw,val,aa,a,aaa); + convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa); switch(sw) { case 1: @@ -4215,7 +4215,7 @@ namespace MEDCoupling std::vector aa; DataArrayIntTuple *aaa; int sw; - convertObjToPossibleCpp1(obj,sw,val,aa,a,aaa); + convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa); switch(sw) { case 1: @@ -4251,7 +4251,7 @@ namespace MEDCoupling std::vector aa; DataArrayIntTuple *aaa; int sw; - convertObjToPossibleCpp1(obj,sw,val,aa,a,aaa); + convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa); switch(sw) { case 1: @@ -4287,7 +4287,7 @@ namespace MEDCoupling std::vector aa; DataArrayIntTuple *aaa; int sw; - convertObjToPossibleCpp1(obj,sw,val,aa,a,aaa); + convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa); switch(sw) { case 1: @@ -4325,7 +4325,7 @@ namespace MEDCoupling { int szArr,sw,iTypppArr; std::vector stdvecTyyppArr; - const int *tmp=convertObjToPossibleCpp1_Safe(li,sw,szArr,iTypppArr,stdvecTyyppArr); + const int *tmp=convertIntStarLikePyObjToCppIntStar(li,sw,szArr,iTypppArr,stdvecTyyppArr); self->pushBackValsSilent(tmp,tmp+szArr); } @@ -4503,7 +4503,7 @@ namespace MEDCoupling MEDCoupling::DataArrayInt *daIntTyypp=0; const int *pt=self->getConstPointer(); int nbc=self->getNumberOfCompo(); - convertObjToPossibleCpp2WithNegIntInterp(obj,nbc,sw,singleVal,multiVal,slic,daIntTyypp); + convertIntStarOrSliceLikePyObjToCppWithNegIntInterp(obj,nbc,sw,singleVal,multiVal,slic,daIntTyypp); switch(sw) { case 1: @@ -4574,7 +4574,7 @@ namespace MEDCoupling std::pair > slic; MEDCoupling::DataArrayInt *daIntTyypp=0; int *pt=self->getPointer(); - convertObjToPossibleCpp2WithNegIntInterp(obj,nbc,sw2,singleVal,multiVal,slic,daIntTyypp); + convertIntStarOrSliceLikePyObjToCppWithNegIntInterp(obj,nbc,sw2,singleVal,multiVal,slic,daIntTyypp); switch(sw2) { case 1: @@ -5042,7 +5042,7 @@ namespace MEDCoupling { int sz=-1,sw=-1; int ival=-1; std::vector ivval; - const int *pt=convertObjToPossibleCpp1_Safe(tupl,sw,sz,ival,ivval); + const int *pt=convertIntStarLikePyObjToCppIntStar(tupl,sw,sz,ival,ivval); std::vector vals(sz); std::copy(pt,pt+sz,vals.begin()); return self->presenceOfTuple(vals); @@ -5052,7 +5052,7 @@ namespace MEDCoupling { int sz=-1,sw=-1; int ival=-1; std::vector ivval; - const int *pt=convertObjToPossibleCpp1_Safe(vals,sw,sz,ival,ivval); + const int *pt=convertIntStarLikePyObjToCppIntStar(vals,sw,sz,ival,ivval); std::vector vals2(sz); std::copy(pt,pt+sz,vals2.begin()); return self->presenceOfValue(vals2); @@ -5062,7 +5062,7 @@ namespace MEDCoupling { int sz=-1,sw=-1; int ival=-1; std::vector ivval; - const int *pt=convertObjToPossibleCpp1_Safe(vals,sw,sz,ival,ivval); + const int *pt=convertIntStarLikePyObjToCppIntStar(vals,sw,sz,ival,ivval); std::vector vals2(sz); std::copy(pt,pt+sz,vals2.begin()); return self->findIdFirstEqual(vals2); @@ -5072,7 +5072,7 @@ namespace MEDCoupling { int sz=-1,sw=-1; int ival=-1; std::vector ivval; - const int *pt=convertObjToPossibleCpp1_Safe(tupl,sw,sz,ival,ivval); + const int *pt=convertIntStarLikePyObjToCppIntStar(tupl,sw,sz,ival,ivval); std::vector vals(sz); std::copy(pt,pt+sz,vals.begin()); return self->findIdFirstEqualTuple(vals); @@ -5082,7 +5082,7 @@ namespace MEDCoupling { int sz=-1,sw=-1; int ival=-1; std::vector ivval; - const int *pt=convertObjToPossibleCpp1_Safe(strOrListOfInt,sw,sz,ival,ivval); + const int *pt=convertIntStarLikePyObjToCppIntStar(strOrListOfInt,sw,sz,ival,ivval); std::vector vals(sz); std::copy(pt,pt+sz,vals.begin()); return self->findIdSequence(vals); @@ -5202,7 +5202,7 @@ namespace MEDCoupling std::vector v1; DataArrayInt *d1=0; DataArrayIntTuple *dd1=0; - convertObjToPossibleCpp1(value,sw1,i1,v1,d1,dd1); + convertIntStarLikePyObjToCpp(value,sw1,i1,v1,d1,dd1); int it1,ic1; std::vector vt1,vc1; std::pair > pt1,pc1; @@ -5757,7 +5757,7 @@ namespace MEDCoupling std::vector stdvecTyyppArr; std::pair > sTyyppArr; MEDCoupling::DataArrayInt *daIntTyypp=0; - convertObjToPossibleCpp2WithNegIntInterp(obj,self->getNumberOfTuples(),sw,iTypppArr,stdvecTyyppArr,sTyyppArr,daIntTyypp); + convertIntStarOrSliceLikePyObjToCppWithNegIntInterp(obj,self->getNumberOfTuples(),sw,iTypppArr,stdvecTyyppArr,sTyyppArr,daIntTyypp); switch(sw) { case 1: @@ -5782,7 +5782,7 @@ namespace MEDCoupling MEDCoupling::DataArrayInt *daIntTyypp=0; int nbOfCompo=self->getNumberOfComponents(); int nbOfTuples=self->getNumberOfTuples(); - convertObjToPossibleCpp2WithNegIntInterp(obj,nbOfTuples,sw1,iTypppArr,stdvecTyyppArr,sTyyppArr,daIntTyypp); + convertIntStarOrSliceLikePyObjToCppWithNegIntInterp(obj,nbOfTuples,sw1,iTypppArr,stdvecTyyppArr,sTyyppArr,daIntTyypp); int sw2; char vc; std::string sc; std::vector vsc; DataArrayChar *dacc=0; convertObjToPossibleCpp6(value,sw2,vc,sc,vsc,dacc); diff --git a/src/MEDCoupling_Swig/MEDCouplingTypemaps.i b/src/MEDCoupling_Swig/MEDCouplingTypemaps.i index 8aec95be3..0bd84c00e 100644 --- a/src/MEDCoupling_Swig/MEDCouplingTypemaps.i +++ b/src/MEDCoupling_Swig/MEDCouplingTypemaps.i @@ -168,7 +168,7 @@ static MEDCoupling::MEDCouplingFieldDouble *MEDCoupling_MEDCouplingFieldDouble__ MEDCoupling::DataArrayDoubleTuple *aa; std::vector bb; int sw; - convertObjToPossibleCpp5(obj,sw,val,a,aa,bb); + convertDoubleStarLikePyObjToCpp_2(obj,sw,val,a,aa,bb); switch(sw) { case 1: @@ -240,7 +240,7 @@ static MEDCoupling::MEDCouplingFieldDouble *MEDCoupling_MEDCouplingFieldDouble__ MEDCoupling::DataArrayDoubleTuple *aa; std::vector bb; int sw; - convertObjToPossibleCpp5(obj,sw,val,a,aa,bb); + convertDoubleStarLikePyObjToCpp_2(obj,sw,val,a,aa,bb); switch(sw) { case 1: @@ -307,7 +307,7 @@ static MEDCoupling::MEDCouplingFieldDouble *MEDCoupling_MEDCouplingFieldDouble__ MEDCoupling::DataArrayDoubleTuple *aa; std::vector bb; int sw; - convertObjToPossibleCpp5(obj,sw,val,a,aa,bb); + convertDoubleStarLikePyObjToCpp_2(obj,sw,val,a,aa,bb); switch(sw) { case 1: @@ -379,7 +379,7 @@ MEDCoupling::MEDCouplingFieldDouble *MEDCoupling_MEDCouplingFieldDouble___rdiv__ MEDCoupling::DataArrayDoubleTuple *aa; std::vector bb; int sw; - convertObjToPossibleCpp5(obj,sw,val,a,aa,bb); + convertDoubleStarLikePyObjToCpp_2(obj,sw,val,a,aa,bb); switch(sw) { case 1: @@ -438,7 +438,7 @@ typename MEDCoupling::Traits::FieldType *fieldT_buildSubPart(const MEDCouplin if(!mesh) throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::buildSubPart : field lies on a null mesh !"); int nbc=mesh->getNumberOfCells(); - convertObjToPossibleCpp2(li,nbc,sw,singleVal,multiVal,slic,daIntTyypp); + convertIntStarOrSliceLikePyObjToCpp(li,nbc,sw,singleVal,multiVal,slic,daIntTyypp); switch(sw) { case 1: @@ -504,7 +504,7 @@ typename MEDCoupling::Traits::FieldType *fieldT__getitem__(const MEDCoupling: if(!self->getArray()) throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::__getitem__ : no array set on field to deduce number of components !"); try - { convertObjToPossibleCpp2(elt1,self->getArray()->getNumberOfComponents(),sw,singleVal,multiVal,slic,daIntTyypp); } + { convertIntStarOrSliceLikePyObjToCpp(elt1,self->getArray()->getNumberOfComponents(),sw,singleVal,multiVal,slic,daIntTyypp); } catch(INTERP_KERNEL::Exception& e) { std::ostringstream oss; oss << "MEDCouplingFieldDouble::__getitem__ : invalid type in 2nd parameter (compo) !" << e.what(); throw INTERP_KERNEL::Exception(oss.str().c_str()); } typename MEDCoupling::MCAuto< typename MEDCoupling::Traits::FieldType > ret0(fieldT_buildSubPart(self,elt0)); diff --git a/src/MEDLoader/Swig/MEDLoaderCommon.i b/src/MEDLoader/Swig/MEDLoaderCommon.i index 0bf980794..e2e61a7f8 100644 --- a/src/MEDLoader/Swig/MEDLoaderCommon.i +++ b/src/MEDLoader/Swig/MEDLoaderCommon.i @@ -2656,7 +2656,7 @@ namespace MEDCoupling std::vector pos2; DataArrayInt *pos3=0; DataArrayIntTuple *pos4=0; - convertObjToPossibleCpp1(li,sw,pos1,pos2,pos3,pos4); + convertIntStarLikePyObjToCpp(li,sw,pos1,pos2,pos3,pos4); switch(sw) { case 1: @@ -3483,7 +3483,7 @@ namespace MEDCoupling std::vector pos2; DataArrayInt *pos3=0; DataArrayIntTuple *pos4=0; - convertObjToPossibleCpp1(ids,sw,pos1,pos2,pos3,pos4); + convertIntStarLikePyObjToCpp(ids,sw,pos1,pos2,pos3,pos4); switch(sw) { case 1: -- 2.30.2