Salome HOME
Fix: getCellsContainingPoints() in case of polyhedron with a face containing colinear...
[tools/medcoupling.git] / src / MEDCoupling_Swig / DataArrayInt.i
1 // Copyright (C) 2007-2024  CEA, EDF
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 // Author : Anthony Geay (EDF R&D)
20
21 %include "MEDCouplingMemArray.i"
22
23 %define ARRAYDEF( ARRAY, INT )
24
25 // namespace MEDCoupling
26 // {
27 //   class ARRAY ## Iterator;
28
29 //   class ARRAY : public DataArray -- #ifdef doesn't work inside
30 //   {
31   public:
32     static ARRAY *New();
33     INT intValue() const;
34     INT getHashCode() const;
35     bool empty() const;
36     void aggregate(const ARRAY *other);
37     ARRAY *performCopyOrIncrRef(bool deepCopy) const;
38     void deepCopyFrom(const ARRAY& other);
39     void reserve(std::size_t nbOfElems);
40     void pushBackSilent(INT val);
41     INT popBackSilent();
42     void pack() const;
43     void allocIfNecessary(INT nbOfTuple, INT nbOfCompo);
44     bool isEqual(const ARRAY& other) const;
45     bool isEqualWithoutConsideringStr(const ARRAY& other) const;
46     bool isEqualWithoutConsideringStrAndOrder(const ARRAY& other) const;
47     DataArrayIdType *occurenceRankInThis() const;
48     DataArrayIdType *buildPermutationArr(const ARRAY& other) const;
49     ARRAY *sumPerTuple() const;
50     void sort(bool asc=true);
51     void reverse();
52     void checkMonotonic(bool increasing) const;
53     bool isMonotonic(bool increasing) const;
54     void checkStrictlyMonotonic(bool increasing) const;
55     bool isStrictlyMonotonic(bool increasing) const;
56     void fillWithZero();
57     void fillWithValue(INT val);
58     void iota(INT init=0);
59     std::string repr() const;
60     std::string reprZip() const;
61     std::string reprNotTooLong() const;
62     ARRAY *invertArrayO2N2N2O(mcIdType newNbOfElem) const;
63     ARRAY *invertArrayN2O2O2N(mcIdType oldNbOfElem) const;
64     ARRAY *invertArrayO2N2N2OBis(mcIdType newNbOfElem) const;
65     DataArrayIdType *indicesOfSubPart(const ARRAY& partOfThis) const;
66     ARRAY *fromNoInterlace() const;
67     ARRAY *toNoInterlace() const;
68     ARRAY *selectByTupleIdSafeSlice(mcIdType bg, mcIdType end, mcIdType step) const;
69     DataArrayIdType *checkAndPreparePermutation() const;
70     DataArrayIdType *buildPermArrPerLevel() const;
71     bool isIota(mcIdType sizeExpected) const;
72     bool isUniform(INT val) const;
73     INT checkUniformAndGuess() const;
74     bool hasUniqueValues() const;
75     ARRAY *subArray(mcIdType tupleIdBg, mcIdType tupleIdEnd=-1) const;
76     void transpose();
77     ARRAY *changeNbOfComponents(std::size_t newNbOfComp, INT dftValue) const;
78     void meldWith(const ARRAY *other);
79     void setPartOfValues1(const ARRAY *a, mcIdType bgTuples, mcIdType endTuples, mcIdType stepTuples, mcIdType bgComp, mcIdType endComp, mcIdType stepComp, bool strictCompoCompare=true);
80     void setPartOfValuesSimple1(INT a, mcIdType bgTuples, mcIdType endTuples, mcIdType stepTuples, mcIdType bgComp, mcIdType endComp, mcIdType stepComp);
81     void setPartOfValuesAdv(const ARRAY *a, const DataArrayIdType *tuplesSelec);
82     void getTuple(mcIdType tupleId, INT *res) const;
83     INT getIJ(std::size_t tupleId, std::size_t compoId) const;
84     INT getIJSafe(std::size_t tupleId, std::size_t compoId) const;
85     INT front() const;
86     INT back() const;
87     void setIJ(mcIdType tupleId, mcIdType compoId, INT newVal);
88     void setIJSilent(mcIdType tupleId, mcIdType compoId, INT newVal);
89     INT *getPointer();
90     const INT *getConstPointer() const;
91     ARRAY ## Iterator *iterator();
92     const INT *begin() const;
93     const INT *end() const;
94     DataArrayIdType *findIdsEqual(INT val) const;
95     DataArrayIdType *findIdsNotEqual(INT val) const;
96     mcIdType changeValue(INT oldValue, INT newValue);
97     mcIdType findIdFirstEqualTuple(const std::vector<INT>& tupl) const;
98     mcIdType findIdFirstEqual(INT value) const;
99     mcIdType findIdFirstEqual(const std::vector<INT>& vals) const;
100     mcIdType findIdSequence(const std::vector<INT>& vals) const;
101     bool presenceOfTuple(const std::vector<INT>& tupl) const;
102     bool presenceOfValue(INT value) const;
103     bool presenceOfValue(const std::vector<INT>& vals) const;
104     INT count(INT value) const;
105     INT accumulate(INT compId) const;
106     INT getMaxValueInArray() const;
107     INT getMaxAbsValueInArray() const;
108     INT getMinValueInArray() const;
109     void abs();
110     ARRAY *computeAbs() const;
111     void applyLin(INT a, INT b, INT compoId);
112     void applyLin(INT a, INT b);
113     void applyInv(INT numerator);
114     ARRAY *negate() const;
115     void applyDivideBy(INT val);
116     void applyModulus(INT val);
117     void applyRModulus(INT val);
118     void applyPow(INT val);
119     void applyRPow(INT val);
120     ARRAY *findIdsInRange(INT vmin, INT vmax) const;
121     ARRAY *findIdsNotInRange(INT vmin, INT vmax) const;
122     ARRAY *findIdsStrictlyNegative() const;
123     bool checkAllIdsInRange(INT vmin, INT vmax) const;
124     static ARRAY *Aggregate(const ARRAY *a1, const ARRAY *a2, INT offsetA2);
125     static ARRAY *Meld(const ARRAY *a1, const ARRAY *a2);
126     static DataArrayIdType *MakePartition(const std::vector<const ARRAY *>& groups, mcIdType newNb, std::vector< std::vector<mcIdType> >& fidsOfGroups);
127     static ARRAY *BuildUnion(const std::vector<const ARRAY *>& arr);
128     static ARRAY *BuildIntersection(const std::vector<const ARRAY *>& arr);
129     static DataArrayIdType *FindPermutationFromFirstToSecond(const ARRAY *ids1, const ARRAY *ids2);
130     static DataArrayIdType *FindPermutationFromFirstToSecondDuplicate(const ARRAY *ids1, const ARRAY *ids2);
131     DataArrayIdType *buildComplement(mcIdType nbOfElement) const;
132     ARRAY *buildSubstraction(const ARRAY *other) const;
133     ARRAY *buildSubstractionOptimized(const ARRAY *other) const;
134     ARRAY *buildUnion(const ARRAY *other) const;
135     ARRAY *buildIntersection(const ARRAY *other) const;
136     DataArrayIdType *indexOfSameConsecutiveValueGroups() const;
137     ARRAY *buildUnique() const;
138     ARRAY *buildUniqueNotSorted() const;
139     ARRAY *deltaShiftIndex() const;
140     void computeOffsets();
141     void computeOffsetsFull();
142     ARRAY *buildExplicitArrByRanges(const ARRAY *offsets) const;
143     DataArrayIdType *findRangeIdForEachTuple(const ARRAY *ranges) const;
144     ARRAY *findIdInRangeForEachTuple(const ARRAY *ranges) const;
145     void sortEachPairToMakeALinkedList();
146     void sortToHaveConsecutivePairs();
147     ARRAY *duplicateEachTupleNTimes(mcIdType nbTimes) const;
148     ARRAY *getDifferentValues() const;
149     static ARRAY *Add(const ARRAY *a1, const ARRAY *a2);
150     void addEqual(const ARRAY *other);
151     static ARRAY *Substract(const ARRAY *a1, const ARRAY *a2);
152     void substractEqual(const ARRAY *other);
153     static ARRAY *Multiply(const ARRAY *a1, const ARRAY *a2);
154     void multiplyEqual(const ARRAY *other);
155     static ARRAY *Divide(const ARRAY *a1, const ARRAY *a2);
156     void divideEqual(const ARRAY *other);
157     static ARRAY *Modulus(const ARRAY *a1, const ARRAY *a2);
158     void modulusEqual(const ARRAY *other);
159     static ARRAY *Pow(const ARRAY *a1, const ARRAY *a2);
160     void powEqual(const ARRAY *other);
161     MCAuto<ARRAY> fromLinkedListOfPairToList() const;
162     MCAuto<DataArrayIdType> findIdsGreaterOrEqualTo(INT val) const;
163     MCAuto<DataArrayIdType> findIdsGreaterThan(INT val) const;
164     MCAuto<DataArrayIdType> findIdsLowerOrEqualTo(INT val) const;
165     MCAuto<DataArrayIdType> findIdsLowerThan(INT val) const;
166     MCAuto<ARRAY> selectPartDef(const PartDefinition* pd) const;
167     MCAuto<DataArrayDouble> convertToDblArr() const;
168     MCAuto<DataArrayFloat> convertToFloatArr() const;
169   public:
170     static ARRAY *Range(INT begin, INT end, INT step);
171     %extend
172     {
173       ARRAY()
174         {
175           return ARRAY::New();
176         }
177
178       static ARRAY *New(PyObject *elt0, PyObject *nbOfTuples=0, PyObject *nbOfComp=0)
179       {
180         const char *msgBase="MEDCoupling::ARRAY::New : Available API are : \n-ARRAY.New()\n-ARRAY.New([1,3,4])\n-ARRAY.New([1,3,4],3)\n-ARRAY.New([1,3,4,5],2,2)\n-ARRAY.New([1,3,4,5,7,8],3,2)\n-ARRAY.New([(1,3),(4,5),(7,8)])\n-ARRAY.New(5)\n-ARRAY.New(5,2)";
181         std::string msg(msgBase);
182         if ( MEDCouplingHasNumPyBindings() )
183           msg+="\n-ARRAY.New(numpy array with dtype=int32)";
184
185         msg+=" !";
186         if(PyList_Check(elt0) || PyTuple_Check(elt0))
187           {
188             if(nbOfTuples)
189               {
190                 if(PyInt_Check(nbOfTuples))
191                   {
192                     mcIdType nbOfTuples1=ToIdType(PyInt_AS_LONG(nbOfTuples));
193                     if(nbOfTuples1<0)
194                       throw INTERP_KERNEL::Exception("ARRAY::New : should be a positive set of allocated memory !");
195                     if(nbOfComp)
196                       {
197                         if(PyInt_Check(nbOfComp))
198                           {//ARRAY.New([1,3,4,5],2,2)
199                             mcIdType nbOfCompo=ToIdType(PyInt_AS_LONG(nbOfComp));
200                             if(nbOfCompo<0)
201                               throw INTERP_KERNEL::Exception("ARRAY::New : should be a positive number of components !");
202                             MCAuto<ARRAY> ret=ARRAY::New();
203                             std::vector<INT> tmp=fillArrayWithPyListInt2<INT>(elt0,nbOfTuples1,nbOfCompo);
204                             ret->alloc(nbOfTuples1,nbOfCompo); std::copy(tmp.begin(),tmp.end(),ret->getPointer());
205                             return ret.retn();
206                           }
207                         else
208                           throw INTERP_KERNEL::Exception(msg.c_str());
209                       }
210                     else
211                       {//ARRAY.New([1,3,4],3)
212                         MCAuto<ARRAY> ret=ARRAY::New();
213                         mcIdType tmpp1=-1;
214                         std::vector<INT> tmp=fillArrayWithPyListInt2<INT>(elt0,nbOfTuples1,tmpp1);
215                         ret->alloc(nbOfTuples1,tmpp1); std::copy(tmp.begin(),tmp.end(),ret->getPointer());
216                         return ret.retn();
217                       }
218                   }
219                 else
220                   throw INTERP_KERNEL::Exception(msg.c_str());
221               }
222             else
223               {// ARRAY.New([1,3,4])
224                 MCAuto<ARRAY> ret=ARRAY::New();
225                 mcIdType tmpp1=-1,tmpp2=-1;
226                 std::vector<INT> tmp=fillArrayWithPyListInt2<INT>(elt0,tmpp1,tmpp2);
227                 ret->alloc(tmpp1,tmpp2); std::copy(tmp.begin(),tmp.end(),ret->getPointer());
228                 return ret.retn();
229               }
230           }
231         else if(PyInt_Check(elt0))
232           {
233             INT nbOfTuples1=(INT)PyInt_AS_LONG(elt0);
234             if(nbOfTuples1<0)
235               throw INTERP_KERNEL::Exception("ARRAY::New : should be a positive set of allocated memory !");
236             if(nbOfTuples)
237               {
238                 if(!nbOfComp)
239                   {
240                     if(PyInt_Check(nbOfTuples))
241                       {//ARRAY.New(5,2)
242                         INT nbOfCompo=(INT)PyInt_AS_LONG(nbOfTuples);
243                         if(nbOfCompo<0)
244                           throw INTERP_KERNEL::Exception("ARRAY::New : should be a positive number of components !");
245                         MCAuto<ARRAY> ret=ARRAY::New();
246                         ret->alloc(nbOfTuples1,nbOfCompo);
247                         return ret.retn();
248                       }
249                     else
250                       throw INTERP_KERNEL::Exception(msg.c_str());
251                   }
252                 else
253                   throw INTERP_KERNEL::Exception(msg.c_str());
254               }
255             else
256               {//ARRAY.New(5)
257                 MCAuto<ARRAY> ret=ARRAY::New();
258                 ret->alloc(nbOfTuples1,1);
259                 return ret.retn();
260               }
261           }
262 #if defined(WITH_NUMPY)
263         else if(MEDCouplingHasNumPyBindings() && PyArray_Check(elt0) && nbOfTuples==NULL && nbOfComp==NULL)
264           {//ARRAY.New(numpyArray)
265             return BuildNewInstance<ARRAY,INT>(elt0,NPYTraits<INT>::NPYObjectType,NPYTraits<INT>::NPYFunc,MEDCoupling::Traits<INT>::NPYStr);
266           }
267 #endif
268         else
269           throw INTERP_KERNEL::Exception(msg.c_str());
270         throw INTERP_KERNEL::Exception(msg.c_str());//to make g++ happy
271       }
272
273       ARRAY(PyObject *elt0, PyObject *nbOfTuples=0, PyObject *nbOfComp=0)
274         {
275           return MEDCoupling_ ## ARRAY ## _New__SWIG_1(elt0,nbOfTuples,nbOfComp);
276         }
277       
278       std::string __str__() const
279       {
280         return self->reprNotTooLong();
281       }
282
283       mcIdType __len__() const
284       {
285         if(self->isAllocated())
286           {
287             return self->getNumberOfTuples();
288           }
289         else
290           {
291             throw INTERP_KERNEL::Exception("ARRAY::__len__ : Instance is NOT allocated !");
292           }
293       }
294
295       INT __int__() const
296       {
297         return self->intValue();
298       }
299
300       ARRAY ## Iterator *__iter__()
301       {
302         return self->iterator();
303       }
304    
305       PyObject *accumulate() const
306       {
307         mcIdType sz=ToIdType(self->getNumberOfComponents());
308         INTERP_KERNEL::AutoPtr<INT> tmp=new INT[sz];
309         self->accumulate((INT *)tmp);
310         return convertIntArrToPyList((const INT *)tmp,sz);
311       }
312
313       ARRAY *accumulatePerChunck(PyObject *indexArr) const
314       {
315         mcIdType sw,sz,val;
316         std::vector<mcIdType> val2;
317         const mcIdType *bg=convertIntStarLikePyObjToCppIntStar(indexArr,sw,sz,val,val2);
318         return self->accumulatePerChunck(bg,bg+sz);
319       }
320
321       DataArrayIdType *findIdsEqualTuple(PyObject *inputTuple) const
322       {
323         mcIdType sw,sz;
324         INT val;
325         std::vector<INT> val2;
326         const INT *bg(convertIntStarLikePyObjToCppIntStar(inputTuple,sw,sz,val,val2));
327         return self->findIdsEqualTuple(bg,bg+sz);
328       }
329
330       DataArrayIdType *findIdForEach(PyObject *vals) const
331       {
332         mcIdType sw,sz;
333         INT val;
334         std::vector<INT> val2;
335         const INT *bg(convertIntStarLikePyObjToCppIntStar(vals,sw,sz,val,val2));
336         MCAuto<DataArrayIdType> ret(self->findIdForEach(bg,bg+sz));
337         return ret.retn();
338       }
339
340       PyObject *splitInBalancedSlices(mcIdType nbOfSlices) const
341       {
342         std::vector< std::pair<mcIdType,mcIdType> > slcs(self->splitInBalancedSlices(nbOfSlices));
343         PyObject *ret=PyList_New(slcs.size());
344         for(std::size_t i=0;i<slcs.size();i++)
345           PyList_SetItem(ret,i,PySlice_New(PyInt_FromLong(slcs[i].first),PyInt_FromLong(slcs[i].second),PyInt_FromLong(1)));
346         return ret;
347       }
348
349       ARRAY *buildExplicitArrOfSliceOnScaledArr(PyObject *slic) const
350       {
351         if(!PySlice_Check(slic))
352           throw INTERP_KERNEL::Exception("ARRAY::buildExplicitArrOfSliceOnScaledArr (wrap) : expecting a pyslice as second (first) parameter !");
353         Py_ssize_t strt=2,stp=2,step=2;
354         GetIndicesOfSliceExplicitely(slic,&strt,&stp,&step,"ARRAY::buildExplicitArrOfSliceOnScaledArr (wrap) : the input slice is invalid !");
355         if(strt==std::numeric_limits<INT>::max() || stp==std::numeric_limits<INT>::max())
356           throw INTERP_KERNEL::Exception("ARRAY::buildExplicitArrOfSliceOnScaledArr (wrap) : the input slice contains some unknowns that can't be determined in static method ! Call DataArray::getSlice (non static) instead !");
357         return self->buildExplicitArrOfSliceOnScaledArr((INT)strt,(INT)stp,(INT)step);
358       }
359
360       PyObject *getMinMaxValues() const
361       {
362         INT a,b;
363         self->getMinMaxValues(a,b);
364         PyObject *ret=PyTuple_New(2);
365         PyTuple_SetItem(ret,0,PyInt_FromLong(a));
366         PyTuple_SetItem(ret,1,PyInt_FromLong(b));
367         return ret;
368       }
369    
370       static PyObject *ConvertIndexArrayToO2N(mcIdType nbOfOldTuples, PyObject *arr, PyObject *arrI)
371       {
372         mcIdType newNbOfTuples=-1;
373         mcIdType szArr,szArrI,sw,iTypppArr,iTypppArrI;
374         std::vector<mcIdType> stdvecTyyppArr;
375         std::vector<mcIdType> stdvecTyyppArrI;
376         const mcIdType *arrPtr=convertIntStarLikePyObjToCppIntStar(arr,sw,szArr,iTypppArr,stdvecTyyppArr);
377         const mcIdType *arrIPtr=convertIntStarLikePyObjToCppIntStar(arrI,sw,szArrI,iTypppArrI,stdvecTyyppArrI);
378         DataArrayIdType *ret0=MEDCoupling::ARRAY::ConvertIndexArrayToO2N(nbOfOldTuples,arrPtr,arrIPtr,arrIPtr+szArrI,newNbOfTuples);
379         PyObject *ret=PyTuple_New(2);
380         PyTuple_SetItem(ret,0,SWIG_NewPointerObj((void*)ret0,SWIGTITraits<mcIdType>::TI,SWIG_POINTER_OWN | 0));
381         PyTuple_SetItem(ret,1,PyInt_FromLong(newNbOfTuples));
382         return ret;
383       }
384
385       static DataArrayIdType *CheckAndPreparePermutation(PyObject *arr)
386       {
387         MCAuto<DataArrayIdType> ret(DataArrayIdType::New());
388         mcIdType szArr,sw;
389         INT iTypppArr;
390         std::vector<INT> stdvecTyyppArr;
391         const INT *arrPtr(convertIntStarLikePyObjToCppIntStar(arr,sw,szArr,iTypppArr,stdvecTyyppArr));
392         mcIdType *pt(MEDCoupling::ARRAY::CheckAndPreparePermutation(arrPtr,arrPtr+szArr));
393         ret->useArray(pt,true,MEDCoupling::DeallocType::C_DEALLOC,szArr,1);
394         return ret.retn();
395       }
396
397       void setValues(PyObject *li, PyObject *nbOfTuples=0, PyObject *nbOfComp=0)
398       {
399         const char *msg="MEDCoupling::ARRAY::setValues : Available API are : \n-ARRAY.setValues([1,3,4])\n-ARRAY.setValues([1,3,4],3)\n-ARRAY.setValues([1,3,4,5],2,2)\n-ARRAY.New(5)\n !";
400         if(PyList_Check(li) || PyTuple_Check(li))
401           {
402             if(nbOfTuples && nbOfTuples != Py_None)
403               {
404                 if(PyInt_Check(nbOfTuples))
405                   {
406                     mcIdType nbOfTuples1=ToIdType(PyInt_AS_LONG(nbOfTuples));
407                     if(nbOfTuples1<0)
408                       throw INTERP_KERNEL::Exception("ARRAY::setValue : should be a positive set of allocated memory !");
409                     if(nbOfComp && nbOfComp != Py_None)
410                       {
411                         if(PyInt_Check(nbOfComp))
412                           {//ARRAY.setValues([1,3,4,5],2,2)
413                             mcIdType nbOfCompo=ToIdType(PyInt_AS_LONG(nbOfComp));
414                             if(nbOfCompo<0)
415                               throw INTERP_KERNEL::Exception("ARRAY::setValue : should be a positive number of components !");
416                             std::vector<INT> tmp=fillArrayWithPyListInt2<INT>(li,nbOfTuples1,nbOfCompo);
417                             self->alloc(nbOfTuples1,nbOfCompo); std::copy(tmp.begin(),tmp.end(),self->getPointer());
418                           }
419                         else
420                           throw INTERP_KERNEL::Exception(msg);
421                       }
422                     else
423                       {//ARRAY.setValues([1,3,4],3)
424                         mcIdType tmpp1=-1;
425                         std::vector<INT> tmp=fillArrayWithPyListInt2<INT>(li,nbOfTuples1,tmpp1);
426                         self->alloc(nbOfTuples1,tmpp1); std::copy(tmp.begin(),tmp.end(),self->getPointer());
427                       }
428                   }
429                 else
430                   throw INTERP_KERNEL::Exception(msg);
431               }
432             else
433               {// ARRAY.setValues([1,3,4])
434                 mcIdType tmpp1=-1,tmpp2=-1;
435                 std::vector<INT> tmp=fillArrayWithPyListInt2<INT>(li,tmpp1,tmpp2);
436                 self->alloc(tmpp1,tmpp2); std::copy(tmp.begin(),tmp.end(),self->getPointer());
437               }
438           }
439         else
440           throw INTERP_KERNEL::Exception(msg);
441       }
442
443       PyObject *getValues() const
444       {
445         const INT *vals=self->getConstPointer();
446         return convertIntArrToPyList(vals,self->getNbOfElems());
447       }
448
449       PyObject *isEqualIfNotWhy(const ARRAY& other) const
450       {
451         std::string ret1;
452         bool ret0=self->isEqualIfNotWhy(other,ret1);
453         PyObject *ret=PyTuple_New(2);
454         PyObject *ret0Py=ret0?Py_True:Py_False;
455         Py_XINCREF(ret0Py);
456         PyTuple_SetItem(ret,0,ret0Py);
457         PyTuple_SetItem(ret,1,PyString_FromString(ret1.c_str()));
458         return ret;
459       }
460
461       PyObject *getValuesAsTuple() const
462       {
463         const INT *vals=self->getConstPointer();
464         mcIdType nbOfComp=ToIdType(self->getNumberOfComponents());
465         mcIdType nbOfTuples=self->getNumberOfTuples();
466         return convertIntArrToPyListOfTuple(vals,nbOfComp,nbOfTuples);
467       }
468
469       static PyObject *MakePartition(PyObject *gps, mcIdType newNb)
470       {
471         std::vector<const ARRAY *> groups;
472         std::vector< std::vector<mcIdType> > fidsOfGroups;
473         convertFromPyObjVectorOfObj(gps,SWIGTITraits<INT>::TI,"ARRAY",groups);
474         DataArrayIdType *ret0=MEDCoupling::ARRAY::MakePartition(groups,newNb,fidsOfGroups);
475         PyObject *ret = PyList_New(2);
476         PyList_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
477         std::size_t sz=fidsOfGroups.size();
478         PyObject *ret1 = PyList_New(sz);
479         for(std::size_t i=0;i<sz;i++)
480           PyList_SetItem(ret1,i,convertIntArrToPyList2(fidsOfGroups[i]));
481         PyList_SetItem(ret,1,ret1);
482         return ret;
483       }
484
485       DataArrayIdType *findIdsEqualList(PyObject *obj)
486       {
487         mcIdType sw;
488         INT singleVal;
489         std::vector<INT> multiVal;
490         std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slic;
491         ARRAY *daIntTyypp=0;
492         convertIntStarOrSliceLikePyObjToCpp(obj,self->getNumberOfTuples(),sw,singleVal,multiVal,slic,daIntTyypp);
493         switch(sw)
494           {
495           case 1:
496             return self->findIdsEqualList(&singleVal,&singleVal+1);
497           case 2:
498             return self->findIdsEqualList(&multiVal[0],&multiVal[0]+multiVal.size());
499           case 4:
500             return self->findIdsEqualList(daIntTyypp->begin(),daIntTyypp->end());
501           default:
502             throw INTERP_KERNEL::Exception("ARRAY::findIdsEqualList : unrecognized type entered, expected list of int, tuple of int or ARRAY !");
503           }
504       }
505
506       DataArrayIdType *findIdsNotEqualList(PyObject *obj)
507       {
508         mcIdType sw;
509         INT singleVal;
510         std::vector<INT> multiVal;
511         std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slic;
512         ARRAY *daIntTyypp=0;
513         convertIntStarOrSliceLikePyObjToCpp(obj,self->getNumberOfTuples(),sw,singleVal,multiVal,slic,daIntTyypp);
514         switch(sw)
515           {
516           case 1:
517             return self->findIdsNotEqualList(&singleVal,&singleVal+1);
518           case 2:
519             return self->findIdsNotEqualList(&multiVal[0],&multiVal[0]+multiVal.size());
520           case 4:
521             return self->findIdsNotEqualList(daIntTyypp->begin(),daIntTyypp->end());
522           default:
523             throw INTERP_KERNEL::Exception("ARRAY::findIdsNotEqualList : unrecognized type entered, expected list of int, tuple of int or ARRAY !");
524           }
525       }
526
527       PyObject *splitByValueRange(PyObject *li) const
528       {
529         ARRAY *ret0=0,*ret1=0,*ret2=0;
530         void *da=0;
531         int res1=SWIG_ConvertPtr(li,&da,SWIGTITraits<INT>::TI, 0 |  0 );
532         if (!SWIG_IsOK(res1))
533           {
534             mcIdType size;
535             INTERP_KERNEL::AutoPtr<INT> tmp=convertPyToNewIntArr2<INT>(li,&size);
536             self->splitByValueRange(tmp,(INT *)tmp+size,ret0,ret1,ret2);
537           }
538         else
539           {
540             ARRAY *da2=reinterpret_cast< ARRAY * >(da);
541             if(!da2)
542               throw INTERP_KERNEL::Exception("Not null ARRAY instance expected !");
543             da2->checkAllocated();
544             self->splitByValueRange(da2->begin(),da2->end(),ret0,ret1,ret2);
545           }
546         PyObject *ret = PyList_New(3);
547         PyList_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 ));
548         PyList_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 ));
549         PyList_SetItem(ret,2,SWIG_NewPointerObj(SWIG_as_voidptr(ret2),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 ));
550         return ret;
551       }
552
553       DataArrayIdType *transformWithIndArrR(PyObject *li) const
554       {
555         void *da=0;
556         int res1=SWIG_ConvertPtr(li,&da,SWIGTITraits<INT>::TI, 0 |  0 );
557         if (!SWIG_IsOK(res1))
558           {
559             mcIdType size;
560             INTERP_KERNEL::AutoPtr<INT> tmp=convertPyToNewIntArr2<INT>(li,&size);
561             return self->transformWithIndArrR(tmp,tmp+size);
562           }
563         else
564           {
565             ARRAY *da2=reinterpret_cast< ARRAY * >(da);
566             return self->transformWithIndArrR(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems());
567           }
568       }
569
570       ARRAY *renumberAndReduce(PyObject *li, mcIdType newNbOfTuple)
571       {
572         void *da=0;
573         int res1=SWIG_ConvertPtr(li,&da,SWIGTITraits<mcIdType>::TI, 0 |  0 );
574         if (!SWIG_IsOK(res1))
575           {
576             mcIdType size;
577             INTERP_KERNEL::AutoPtr<mcIdType> tmp=convertPyToNewIntArr2(li,&size);
578             if(size!=self->getNumberOfTuples())
579               {
580                 throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
581               }
582             return self->renumberAndReduce(tmp,newNbOfTuple);
583           }
584         else
585           {
586             DataArrayIdType *da2=reinterpret_cast< DataArrayIdType * >(da);
587             if(!da2)
588               throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
589             da2->checkAllocated();
590             mcIdType size=self->getNumberOfTuples();
591             if(size!=self->getNumberOfTuples())
592               {
593                 throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
594               }
595             return self->renumberAndReduce(da2->getConstPointer(),newNbOfTuple);
596           }
597       }
598
599       ARRAY *renumber(PyObject *li)
600       {
601         void *da=0;
602         int res1=SWIG_ConvertPtr(li,&da,SWIGTITraits<mcIdType>::TI, 0 |  0 );
603         if (!SWIG_IsOK(res1))
604           {
605             mcIdType size;
606             INTERP_KERNEL::AutoPtr<mcIdType> tmp=convertPyToNewIntArr2(li,&size);
607             if(size!=self->getNumberOfTuples())
608               {
609                 throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
610               }
611             return self->renumber(tmp);
612           }
613         else
614           {
615             DataArrayIdType *da2=reinterpret_cast< DataArrayIdType * >(da);
616             if(!da2)
617               throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
618             da2->checkAllocated();
619             mcIdType size=self->getNumberOfTuples();
620             if(size!=self->getNumberOfTuples())
621               {
622                 throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
623               }
624             return self->renumber(da2->getConstPointer());
625           }
626       }
627
628       ARRAY *renumberR(PyObject *li)
629       {
630         void *da=0;
631         int res1=SWIG_ConvertPtr(li,&da,SWIGTITraits<mcIdType>::TI, 0 |  0 );
632         if (!SWIG_IsOK(res1))
633           {
634             mcIdType size;
635             INTERP_KERNEL::AutoPtr<mcIdType> tmp=convertPyToNewIntArr2(li,&size);
636             if(size!=self->getNumberOfTuples())
637               {
638                 throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
639               }
640             return self->renumberR(tmp);
641           }
642         else
643           {
644             DataArrayIdType *da2=reinterpret_cast< DataArrayIdType * >(da);
645             if(!da2)
646               throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
647             da2->checkAllocated();
648             mcIdType size=self->getNumberOfTuples();
649             if(size!=self->getNumberOfTuples())
650               {
651                 throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
652               }
653             return self->renumberR(da2->getConstPointer());
654           }
655       }
656
657       void setSelectedComponents(const ARRAY *a, PyObject *li)
658       {
659         std::vector<std::size_t> tmp;
660         convertPyToNewIntArr3(li,tmp);
661         self->setSelectedComponents(a,tmp);
662       }
663
664       PyObject *explodeComponents() const
665       {
666         std::vector< MCAuto<ARRAY> > retCpp(self->explodeComponents());
667         std::size_t sz(retCpp.size());
668         PyObject *res(PyList_New(sz));
669         for(std::size_t i=0;i<sz;i++)
670           PyList_SetItem(res,i,SWIG_NewPointerObj(SWIG_as_voidptr(retCpp[i].retn()),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
671         return res;
672       }
673
674       PyObject *getTuple(mcIdType tupleId)
675       {
676         mcIdType sz=ToIdType(self->getNumberOfComponents());
677         INTERP_KERNEL::AutoPtr<INT> tmp=new INT[sz];
678         self->getTuple(tupleId,tmp);
679         return convertIntArrToPyList((const INT*)tmp,sz);
680       }
681
682       PyObject *changeSurjectiveFormat(INT targetNb) const
683       {
684         DataArrayIdType *arr=0;
685         DataArrayIdType *arrI=0;
686         self->changeSurjectiveFormat(targetNb,arr,arrI);
687         PyObject *res = PyList_New(2);
688         PyList_SetItem(res,0,SWIG_NewPointerObj((void*)arr,SWIGTITraits<mcIdType>::TI,SWIG_POINTER_OWN | 0));
689         PyList_SetItem(res,1,SWIG_NewPointerObj((void*)arrI,SWIGTITraits<mcIdType>::TI,SWIG_POINTER_OWN | 0));
690         return res;
691       }
692
693       static ARRAY *Meld(PyObject *li)
694       {
695         std::vector<const ARRAY *> tmp;
696         convertFromPyObjVectorOfObj(li,SWIGTITraits<INT>::TI,"ARRAY",tmp);
697         return ARRAY::Meld(tmp);
698       }
699
700       static ARRAY *Aggregate(PyObject *li)
701       {
702         std::vector<const ARRAY *> tmp;
703         convertFromPyObjVectorOfObj(li,SWIGTITraits<INT>::TI,"ARRAY",tmp);
704         return ARRAY::Aggregate(tmp);
705       }
706
707       static ARRAY *AggregateIndexes(PyObject *li)
708       {
709         std::vector<const ARRAY *> tmp;
710         convertFromPyObjVectorOfObj(li,SWIGTITraits<INT>::TI,"ARRAY",tmp);
711         return ARRAY::AggregateIndexes(tmp);
712       }
713
714       static ARRAY *BuildUnion(PyObject *li)
715       {
716         std::vector<const ARRAY *> tmp;
717         convertFromPyObjVectorOfObj(li,SWIGTITraits<INT>::TI,"ARRAY",tmp);
718         return ARRAY::BuildUnion(tmp);
719       }
720
721       static ARRAY *BuildIntersection(PyObject *li)
722       {
723         std::vector<const ARRAY *> tmp;
724         convertFromPyObjVectorOfObj(li,SWIGTITraits<INT>::TI,"ARRAY",tmp);
725         return ARRAY::BuildIntersection(tmp);
726       }
727
728       PyObject *getMaxValue() const
729       {
730         mcIdType tmp;
731         INT r1=self->getMaxValue(tmp);
732         PyObject *ret=PyTuple_New(2);
733         PyTuple_SetItem(ret,0,PyInt_FromLong(r1));
734         PyTuple_SetItem(ret,1,PyInt_FromLong(tmp));
735         return ret;
736       }
737     
738       PyObject *getMaxAbsValue(std::size_t& tupleId) const
739       {
740         std::size_t tmp;
741         INT r1=self->getMaxAbsValue(tmp);
742         PyObject *ret=PyTuple_New(2);
743         PyTuple_SetItem(ret,0,PyInt_FromLong(r1));
744         PyTuple_SetItem(ret,1,PyInt_FromLong(tmp));
745         return ret;
746       }
747
748       PyObject *getMinValue() const
749       {
750         mcIdType tmp;
751         INT r1=self->getMinValue(tmp);
752         PyObject *ret=PyTuple_New(2);
753         PyTuple_SetItem(ret,0,PyInt_FromLong(r1));
754         PyTuple_SetItem(ret,1,PyInt_FromLong(tmp));
755         return ret;
756       }
757
758       mcIdType index(PyObject *obj) const
759       {
760         std::size_t nbOfCompo=self->getNumberOfComponents();
761         switch(nbOfCompo)
762           {
763           case 1:
764             {
765               if(PyInt_Check(obj))
766                 {
767                   INT val=(INT)PyInt_AS_LONG(obj);
768                   return self->findIdFirstEqual(val);
769                 }
770               else
771                 throw INTERP_KERNEL::Exception("ARRAY::index : 'this' contains one component and trying to find an element which is not an integer !");
772             }
773           default:
774             {
775               std::vector<INT> arr;
776               convertPyToNewIntArr3(obj,arr);
777               return self->findIdFirstEqualTuple(arr);
778             }
779           }
780       }
781
782       bool __contains__(PyObject *obj) const
783       {
784         std::size_t nbOfCompo=self->getNumberOfComponents();
785         switch(nbOfCompo)
786           {
787           case 0:
788             return false;
789           case 1:
790             {
791               if(PyInt_Check(obj))
792                 {
793                   INT val=(INT)PyInt_AS_LONG(obj);
794                   return self->presenceOfValue(val);
795                 }
796               else
797                 throw INTERP_KERNEL::Exception("ARRAY::__contains__ : 'this' contains one component and trying to find an element which is not an integer !");
798             }
799           default:
800             {
801               std::vector<INT> arr;
802               convertPyToNewIntArr3(obj,arr);
803               return self->presenceOfTuple(arr);
804             }
805           }
806       }
807
808       PyObject *__getitem__(PyObject *obj)
809       {
810         const char msg[]="Unexpected situation in ARRAY::__getitem__ !";
811         const char msg2[]="ARRAY::__getitem__ : Mismatch of slice values in 2nd parameter (components) !";
812         self->checkAllocated();
813         mcIdType nbOfTuples=self->getNumberOfTuples();
814         std::size_t nbOfComponents=self->getNumberOfComponents();
815         mcIdType it1;
816         std::size_t ic1;
817         std::vector<mcIdType> vt1;
818         std::vector<std::size_t> vc1;
819         std::pair<mcIdType, std::pair<mcIdType,mcIdType> > pt1,pc1;
820         DataArrayIdType *dt1=0,*dc1=0;
821         mcIdType sw;
822         convertObjToPossibleCpp3(obj,nbOfTuples,(int)nbOfComponents,sw,it1,ic1,vt1,vc1,pt1,pc1,dt1,dc1);
823         MCAuto<ARRAY> ret;
824         switch(sw)
825           {
826           case 1:
827             {
828               if(nbOfComponents==1)
829                 return PyInt_FromLong(self->getIJSafe(it1,0));
830               return SWIG_NewPointerObj(SWIG_as_voidptr(self->selectByTupleIdSafe(&it1,&it1+1)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
831             }
832           case 2:
833             return SWIG_NewPointerObj(SWIG_as_voidptr(self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size())),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
834           case 3:
835             return SWIG_NewPointerObj(SWIG_as_voidptr(self->selectByTupleIdSafeSlice(pt1.first,pt1.second.first,pt1.second.second)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
836           case 4:
837             return SWIG_NewPointerObj(SWIG_as_voidptr(self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems())),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
838           case 5:
839             return PyInt_FromLong(self->getIJSafe(it1,ic1));
840           case 6:
841             {
842               ret=self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size());
843               std::vector<std::size_t> v2(1,ic1);
844               return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
845             }
846           case 7:
847             {
848               ret=self->selectByTupleIdSafeSlice(pt1.first,pt1.second.first,pt1.second.second);
849               std::vector<std::size_t> v2(1,ic1);
850               return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
851             }
852           case 8:
853             {
854               ret=self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems());
855               std::vector<std::size_t> v2(1,ic1);
856               return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
857             }
858           case 9:
859             {
860               ret=self->selectByTupleIdSafe(&it1,&it1+1);
861               return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(vc1)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
862             }
863           case 10:
864             {
865               ret=self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size());
866               return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(vc1)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
867             }
868           case 11:
869             {
870               ret=self->selectByTupleIdSafeSlice(pt1.first,pt1.second.first,pt1.second.second);
871               return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(vc1)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
872             }
873           case 12:
874             {
875               ret=self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems());
876               return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(vc1)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
877             }
878           case 13:
879             {
880               ret=self->selectByTupleIdSafe(&it1,&it1+1);
881               mcIdType nbOfComp=DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2);
882               std::vector<std::size_t> v2(nbOfComp);
883               for(INT i=0;i<nbOfComp;i++)
884                 v2[i]=pc1.first+i*pc1.second.second;
885               return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
886             }
887           case 14:
888             {
889               ret=self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size());
890               mcIdType nbOfComp=DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2);
891               std::vector<std::size_t> v2(nbOfComp);
892               for(INT i=0;i<nbOfComp;i++)
893                 v2[i]=pc1.first+i*pc1.second.second;
894               return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
895             }
896           case 15:
897             {
898               ret=self->selectByTupleIdSafeSlice(pt1.first,pt1.second.first,pt1.second.second);
899               mcIdType nbOfComp=DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2);
900               std::vector<std::size_t> v2(nbOfComp);
901               for(mcIdType i=0;i<nbOfComp;i++)
902                 v2[i]=pc1.first+i*pc1.second.second;
903               return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
904             }
905           case 16:
906             {
907               ret=self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems());
908               mcIdType nbOfComp=DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2);
909               std::vector<std::size_t> v2(nbOfComp);
910               for(INT i=0;i<nbOfComp;i++)
911                 v2[i]=pc1.first+i*pc1.second.second;
912               return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 );
913             }
914           default:
915             throw INTERP_KERNEL::Exception(msg);
916           }
917       }
918
919       ARRAY *__setitem__(PyObject *obj, PyObject *value)
920       {
921         self->checkAllocated();
922         const char msg[]="Unexpected situation in __setitem__ !";
923         mcIdType nbOfTuples=self->getNumberOfTuples();
924         int nbOfComponents=(int)self->getNumberOfComponents();
925         mcIdType sw1,sw2;
926         INT i1;
927         std::vector<INT> v1;
928         ARRAY *d1=0;
929         ARRAY ## Tuple *dd1=0;
930         convertIntStarLikePyObjToCpp(value,sw1,i1,v1,d1,dd1);
931         mcIdType it1,ic1;
932         std::vector<mcIdType> vt1,vc1;
933         std::pair<mcIdType, std::pair<mcIdType,mcIdType> > pt1,pc1;
934         DataArrayIdType *dt1=0,*dc1=0;
935         convertObjToPossibleCpp3(obj,nbOfTuples,nbOfComponents,sw2,it1,ic1,vt1,vc1,pt1,pc1,dt1,dc1);
936         MCAuto<ARRAY> tmp;
937         switch(sw2)
938           {
939           case 1:
940             {
941               switch(sw1)
942                 {
943                 case 1:
944                   self->setPartOfValuesSimple1(i1,it1,it1+1,1,0,nbOfComponents,1);
945                   return self;
946                 case 2:
947                   tmp=ARRAY::New();
948                   tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
949                   self->setPartOfValues1(tmp,it1,it1+1,1,0,nbOfComponents,1,false);
950                   return self;
951                 case 3:
952                   self->setPartOfValues1(d1,it1,it1+1,1,0,nbOfComponents,1);
953                   return self;
954                 case 4:
955                   tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
956                   self->setPartOfValues1(tmp,it1,it1+1,1,0,nbOfComponents,1);
957                   return self;
958                 default:
959                   throw INTERP_KERNEL::Exception(msg);
960                 }
961               break;
962             }
963           case 2:
964             {
965               switch(sw1)
966                 {
967                 case 1:
968                   self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1);
969                   return self;
970                 case 2:
971                   tmp=ARRAY::New();
972                   tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
973                   self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1,false);
974                   return self;
975                 case 3:
976                   self->setPartOfValues3(d1,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1);
977                   return self;
978                 case 4:
979                   tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
980                   self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1);
981                   return self;
982                 default:
983                   throw INTERP_KERNEL::Exception(msg);
984                 }
985               break;
986             }
987           case 3:
988             {
989               switch(sw1)
990                 {
991                 case 1:
992                   self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1);
993                   return self;
994                 case 2:
995                   tmp=ARRAY::New();
996                   tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
997                   self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1,false);
998                   return self;
999                 case 3:
1000                   self->setPartOfValues1(d1,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1);
1001                   return self;
1002                 case 4:
1003                   tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1004                   self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1);
1005                   return self;
1006                 default:
1007                   throw INTERP_KERNEL::Exception(msg);
1008                 }
1009               break;
1010             }
1011           case 4:
1012             {
1013               switch(sw1)
1014                 {
1015                 case 1:
1016                   self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1);
1017                   return self;
1018                 case 2:
1019                   tmp=ARRAY::New();
1020                   tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1021                   self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1,false);
1022                   return self;
1023                 case 3:
1024                   self->setPartOfValues3(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1);
1025                   return self;
1026                 case 4:
1027                   tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1028                   self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1);
1029                   return self;
1030                 default:
1031                   throw INTERP_KERNEL::Exception(msg);
1032                 }
1033               break;
1034             }
1035           case 5:
1036             {
1037               switch(sw1)
1038                 {
1039                 case 1:
1040                   self->setPartOfValuesSimple1(i1,it1,it1+1,1,ic1,ic1+1,1);
1041                   return self;
1042                 case 2:
1043                   tmp=ARRAY::New();
1044                   tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1045                   self->setPartOfValues1(tmp,it1,it1+1,1,ic1,ic1+1,1,false);
1046                   return self;
1047                 case 3:
1048                   self->setPartOfValues1(d1,it1,it1+1,1,ic1,ic1+1,1);
1049                   return self;
1050                 case 4:
1051                   tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1052                   self->setPartOfValues1(tmp,it1,it1+1,1,ic1,ic1+1,1);
1053                   return self;
1054                 default:
1055                   throw INTERP_KERNEL::Exception(msg);
1056                 }
1057               break;
1058             }
1059           case 6:
1060             {
1061               switch(sw1)
1062                 {
1063                 case 1:
1064                   self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1);
1065                   return self;
1066                 case 2:
1067                   tmp=ARRAY::New();
1068                   tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1069                   self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1,false);
1070                   return self;
1071                 case 3:
1072                   self->setPartOfValues3(d1,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1);
1073                   return self;
1074                 case 4:
1075                   tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1076                   self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1);
1077                   return self;
1078                 default:
1079                   throw INTERP_KERNEL::Exception(msg);
1080                 }
1081               break;
1082             }
1083           case 7:
1084             {
1085               switch(sw1)
1086                 {
1087                 case 1:
1088                   self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1);
1089                   return self;
1090                 case 2:
1091                   tmp=ARRAY::New();
1092                   tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1093                   self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1,false);
1094                   return self;
1095                 case 3:
1096                   self->setPartOfValues1(d1,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1);
1097                   return self;
1098                 case 4:
1099                   tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1100                   self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1);
1101                   return self;
1102                 default:
1103                   throw INTERP_KERNEL::Exception(msg);
1104                 }
1105               break;
1106             }
1107           case 8:
1108             {
1109               switch(sw1)
1110                 {
1111                 case 1:
1112                   self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1);
1113                   return self;
1114                 case 2:
1115                   tmp=ARRAY::New();
1116                   tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1117                   self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1,false);
1118                   return self;
1119                 case 3:
1120                   self->setPartOfValues3(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1);
1121                   return self;
1122                 case 4:
1123                   tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1124                   self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1);
1125                   return self;
1126                 default:
1127                   throw INTERP_KERNEL::Exception(msg);
1128                 }
1129               break;
1130             }
1131           case 9:
1132             {
1133               switch(sw1)
1134                 {
1135                 case 1:
1136                   self->setPartOfValuesSimple2(i1,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size());
1137                   return self;
1138                 case 2:
1139                   tmp=ARRAY::New();
1140                   tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1141                   self->setPartOfValues2(tmp,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size(),false);
1142                   return self;
1143                 case 3:
1144                   self->setPartOfValues2(d1,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size());
1145                   return self;
1146                 case 4:
1147                   tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1148                   self->setPartOfValues2(tmp,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size());
1149                   return self;
1150                 default:
1151                   throw INTERP_KERNEL::Exception(msg);
1152                 }
1153               break;
1154             }
1155           case 10:
1156             {
1157               switch(sw1)
1158                 {
1159                 case 1:
1160                   self->setPartOfValuesSimple2(i1,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size());
1161                   return self;
1162                 case 2:
1163                   tmp=ARRAY::New();
1164                   tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1165                   self->setPartOfValues2(tmp,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size(),false);
1166                   return self;
1167                 case 3:
1168                   self->setPartOfValues2(d1,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size());
1169                   return self;
1170                 case 4:
1171                   tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1172                   self->setPartOfValues2(tmp,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size());
1173                   return self;
1174                 default:
1175                   throw INTERP_KERNEL::Exception(msg);
1176                 }
1177               break;
1178             }
1179           case 11:
1180             {
1181               switch(sw1)
1182                 {
1183                 case 1:
1184                   self->setPartOfValuesSimple4(i1,pt1.first,pt1.second.first,pt1.second.second,&vc1[0],&vc1[0]+vc1.size());
1185                   return self;
1186                 case 2:
1187                   tmp=ARRAY::New();
1188                   tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1189                   self->setPartOfValues4(tmp,pt1.first,pt1.second.first,pt1.second.second,&vc1[0],&vc1[0]+vc1.size(),false);
1190                   return self;
1191                 case 3:
1192                   self->setPartOfValues4(d1,pt1.first,pt1.second.first,pt1.second.second,&vc1[0],&vc1[0]+vc1.size());
1193                   return self;
1194                 case 4:
1195                   tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1196                   self->setPartOfValues4(tmp,pt1.first,pt1.second.first,pt1.second.second,&vc1[0],&vc1[0]+vc1.size());
1197                   return self;
1198                 default:
1199                   throw INTERP_KERNEL::Exception(msg);
1200                 }
1201               break;
1202             }
1203           case 12:
1204             {
1205               switch(sw1)
1206                 {
1207                 case 1:
1208                   self->setPartOfValuesSimple2(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size());
1209                   return self;
1210                 case 2:
1211                   tmp=ARRAY::New();
1212                   tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1213                   self->setPartOfValues2(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size(),false);
1214                   return self;
1215                 case 3:
1216                   self->setPartOfValues2(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size());
1217                   return self;
1218                 case 4:
1219                   tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1220                   self->setPartOfValues2(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size());
1221                   return self;
1222                 default:
1223                   throw INTERP_KERNEL::Exception(msg);
1224                 }
1225               break;
1226             }
1227           case 13:
1228             {
1229               switch(sw1)
1230                 {
1231                 case 1:
1232                   self->setPartOfValuesSimple1(i1,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second);
1233                   return self;
1234                 case 2:
1235                   tmp=ARRAY::New();
1236                   tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1237                   self->setPartOfValues1(tmp,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second,false);
1238                   return self;
1239                 case 3:
1240                   self->setPartOfValues1(d1,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second);
1241                   return self;
1242                 case 4:
1243                   tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1244                   self->setPartOfValues1(tmp,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second);
1245                   return self;
1246                 default:
1247                   throw INTERP_KERNEL::Exception(msg);
1248                 }
1249               break;
1250             }
1251           case 14:
1252             {
1253               switch(sw1)
1254                 {
1255                 case 1:
1256                   self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second);
1257                   return self;
1258                 case 2:
1259                   tmp=ARRAY::New();
1260                   tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1261                   self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second,false);
1262                   return self;
1263                 case 3:
1264                   self->setPartOfValues3(d1,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second);
1265                   return self;
1266                 case 4:
1267                   tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1268                   self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second);
1269                   return self;
1270                 default:
1271                   throw INTERP_KERNEL::Exception(msg);
1272                 }
1273               break;
1274             }
1275           case 15:
1276             {
1277               switch(sw1)
1278                 {
1279                 case 1:
1280                   self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second);
1281                   return self;
1282                 case 2:
1283                   tmp=ARRAY::New();
1284                   tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1285                   self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second,false);
1286                   return self;
1287                 case 3:
1288                   self->setPartOfValues1(d1,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second);
1289                   return self;
1290                 case 4:
1291                   tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1292                   self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second);
1293                   return self;
1294                 default:
1295                   throw INTERP_KERNEL::Exception(msg);
1296                 }
1297               break;
1298             }
1299           case 16:
1300             {
1301               switch(sw1)
1302                 {
1303                 case 1:
1304                   self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second);
1305                   return self;
1306                 case 2:
1307                   tmp=ARRAY::New();
1308                   tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
1309                   self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second,false);
1310                   return self;
1311                 case 3:
1312                   self->setPartOfValues3(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second);
1313                   return self;
1314                 case 4:
1315                   tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
1316                   self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second);
1317                   return self;
1318                 default:
1319                   throw INTERP_KERNEL::Exception(msg);
1320                 }
1321               break;
1322             }
1323           default:
1324             throw INTERP_KERNEL::Exception(msg);
1325           }
1326         return self;
1327       }
1328
1329       ARRAY *__neg__() const
1330       {
1331         return self->negate();
1332       }
1333  
1334       ARRAY *__add__(PyObject *obj)
1335       {
1336         const char msg[]="Unexpected situation in __add__ !";
1337         INT val;
1338         ARRAY *a;
1339         std::vector<INT> aa;
1340         ARRAY ## Tuple *aaa;
1341         mcIdType sw;
1342         convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1343         switch(sw)
1344           {
1345           case 1:
1346             {
1347               MCAuto<ARRAY> ret=self->deepCopy();
1348               ret->applyLin(1,val);
1349               return ret.retn();
1350             }
1351           case 2:
1352             {
1353               MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1354               return ARRAY::Add(self,aaaa);
1355             }
1356           case 3:
1357             {
1358               return ARRAY::Add(self,a);
1359             }
1360           case 4:
1361             {
1362               MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1363               return ARRAY::Add(self,aaaa);
1364             }
1365           default:
1366             throw INTERP_KERNEL::Exception(msg);
1367           }
1368       }
1369
1370       ARRAY *__radd__(PyObject *obj)
1371       {
1372         const char msg[]="Unexpected situation in __radd__ !";
1373         INT val;
1374         ARRAY *a;
1375         std::vector<INT> aa;
1376         ARRAY ## Tuple *aaa;
1377         mcIdType sw;
1378         convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1379         switch(sw)
1380           {
1381           case 1:
1382             {
1383               MCAuto<ARRAY> ret=self->deepCopy();
1384               ret->applyLin(1,val);
1385               return ret.retn();
1386             }
1387           case 2:
1388             {
1389               MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1390               return ARRAY::Add(self,aaaa);
1391             }
1392           case 4:
1393             {
1394               MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1395               return ARRAY::Add(self,aaaa);
1396             }
1397           default:
1398             throw INTERP_KERNEL::Exception(msg);
1399           }
1400       }
1401
1402       PyObject *___iadd___(PyObject *trueSelf, PyObject *obj)
1403       {
1404         const char msg[]="Unexpected situation in __iadd__ !";
1405         INT val;
1406         ARRAY *a;
1407         std::vector<INT> aa;
1408         ARRAY ## Tuple *aaa;
1409         mcIdType sw;
1410         convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1411         switch(sw)
1412           {
1413           case 1:
1414             {
1415               self->applyLin(1,val);
1416               Py_XINCREF(trueSelf);
1417               return trueSelf;
1418             }
1419           case 2:
1420             {
1421               MCAuto<ARRAY> bb=ARRAY::New(); bb->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1422               self->addEqual(bb);
1423               Py_XINCREF(trueSelf);
1424               return trueSelf;
1425             }
1426           case 3:
1427             {
1428               self->addEqual(a);
1429               Py_XINCREF(trueSelf);
1430               return trueSelf;
1431             }
1432           case 4:
1433             {
1434               MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1435               self->addEqual(aaaa);
1436               Py_XINCREF(trueSelf);
1437               return trueSelf;
1438             }
1439           default:
1440             throw INTERP_KERNEL::Exception(msg);
1441           }
1442       }
1443
1444       ARRAY *__sub__(PyObject *obj)
1445       {
1446         const char msg[]="Unexpected situation in __sub__ !";
1447         INT val;
1448         ARRAY *a;
1449         std::vector<INT> aa;
1450         ARRAY ## Tuple *aaa;
1451         mcIdType sw;
1452         convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1453         switch(sw)
1454           {
1455           case 1:
1456             {
1457               MCAuto<ARRAY> ret=self->deepCopy();
1458               ret->applyLin(1,-val);
1459               return ret.retn();
1460             }
1461           case 2:
1462             {
1463               MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1464               return ARRAY::Substract(self,aaaa);
1465             }
1466           case 3:
1467             {
1468               return ARRAY::Substract(self,a);
1469             }
1470           case 4:
1471             {
1472               MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1473               return ARRAY::Substract(self,aaaa);
1474             }
1475           default:
1476             throw INTERP_KERNEL::Exception(msg);
1477           }
1478       }
1479
1480       ARRAY *__rsub__(PyObject *obj)
1481       {
1482         const char msg[]="Unexpected situation in __rsub__ !";
1483         INT val;
1484         ARRAY *a;
1485         std::vector<INT> aa;
1486         ARRAY ## Tuple *aaa;
1487         mcIdType sw;
1488         convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1489         switch(sw)
1490           {
1491           case 1:
1492             {
1493               MCAuto<ARRAY> ret=self->deepCopy();
1494               ret->applyLin(-1,val);
1495               return ret.retn();
1496             }
1497           case 2:
1498             {
1499               MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1500               return ARRAY::Substract(aaaa,self);
1501             }
1502           case 4:
1503             {
1504               MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1505               return ARRAY::Substract(aaaa,self);
1506             }
1507           default:
1508             throw INTERP_KERNEL::Exception(msg);
1509           }
1510       }
1511
1512       PyObject *___isub___(PyObject *trueSelf, PyObject *obj)
1513       {
1514         const char msg[]="Unexpected situation in __isub__ !";
1515         INT val;
1516         ARRAY *a;
1517         std::vector<INT> aa;
1518         ARRAY ## Tuple *aaa;
1519         mcIdType sw;
1520         convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1521         switch(sw)
1522           {
1523           case 1:
1524             {
1525               self->applyLin(1,-val);
1526               Py_XINCREF(trueSelf);
1527               return trueSelf;
1528             }
1529           case 2:
1530             {
1531               MCAuto<ARRAY> bb=ARRAY::New(); bb->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1532               self->substractEqual(bb);
1533               Py_XINCREF(trueSelf);
1534               return trueSelf;
1535             }
1536           case 3:
1537             {
1538               self->substractEqual(a);
1539               Py_XINCREF(trueSelf);
1540               return trueSelf;
1541             }
1542           case 4:
1543             {
1544               MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1545               self->substractEqual(aaaa);
1546               Py_XINCREF(trueSelf);
1547               return trueSelf;
1548             }
1549           default:
1550             throw INTERP_KERNEL::Exception(msg);
1551           }
1552       }
1553
1554       ARRAY *__mul__(PyObject *obj)
1555       {
1556         const char msg[]="Unexpected situation in __mul__ !";
1557         INT val;
1558         ARRAY *a;
1559         std::vector<INT> aa;
1560         ARRAY ## Tuple *aaa;
1561         mcIdType sw;
1562         convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1563         switch(sw)
1564           {
1565           case 1:
1566             {
1567               MCAuto<ARRAY> ret=self->deepCopy();
1568               ret->applyLin(val,0);
1569               return ret.retn();
1570             }
1571           case 2:
1572             {
1573               MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1574               return ARRAY::Multiply(self,aaaa);
1575             }
1576           case 3:
1577             {
1578               return ARRAY::Multiply(self,a);
1579             }
1580           case 4:
1581             {
1582               MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1583               return ARRAY::Multiply(self,aaaa);
1584             }
1585           default:
1586             throw INTERP_KERNEL::Exception(msg);
1587           }
1588       }
1589
1590       ARRAY *__rmul__(PyObject *obj)
1591       {
1592         const char msg[]="Unexpected situation in __rmul__ !";
1593         INT val;
1594         ARRAY *a;
1595         std::vector<INT> aa;
1596         ARRAY ## Tuple *aaa;
1597         mcIdType sw;
1598         convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1599         switch(sw)
1600           {
1601           case 1:
1602             {
1603               MCAuto<ARRAY> ret=self->deepCopy();
1604               ret->applyLin(val,0);
1605               return ret.retn();
1606             }
1607           case 2:
1608             {
1609               MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1610               return ARRAY::Multiply(self,aaaa);
1611             }
1612           case 4:
1613             {
1614               MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1615               return ARRAY::Multiply(self,aaaa);
1616             }
1617           default:
1618             throw INTERP_KERNEL::Exception(msg);
1619           }
1620       }
1621
1622       PyObject *___imul___(PyObject *trueSelf, PyObject *obj)
1623       {
1624         const char msg[]="Unexpected situation in __imul__ !";
1625         INT val;
1626         ARRAY *a;
1627         std::vector<INT> aa;
1628         ARRAY ## Tuple *aaa;
1629         mcIdType sw;
1630         convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1631         switch(sw)
1632           {
1633           case 1:
1634             {
1635               self->applyLin(val,0);
1636               Py_XINCREF(trueSelf);
1637               return trueSelf;
1638             }
1639           case 2:
1640             {
1641               MCAuto<ARRAY> bb=ARRAY::New(); bb->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1642               self->multiplyEqual(bb);
1643               Py_XINCREF(trueSelf);
1644               return trueSelf;
1645             }
1646           case 3:
1647             {
1648               self->multiplyEqual(a);
1649               Py_XINCREF(trueSelf);
1650               return trueSelf;
1651             }
1652           case 4:
1653             {
1654               MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1655               self->multiplyEqual(aaaa);
1656               Py_XINCREF(trueSelf);
1657               return trueSelf;
1658             }
1659           default:
1660             throw INTERP_KERNEL::Exception(msg);
1661           }
1662       }
1663
1664       ARRAY *__div__(PyObject *obj)
1665       {
1666         const char msg[]="Unexpected situation in __div__ !";
1667         INT val;
1668         ARRAY *a;
1669         std::vector<INT> aa;
1670         ARRAY ## Tuple *aaa;
1671         mcIdType sw;
1672         convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1673         switch(sw)
1674           {
1675           case 1:
1676             {
1677               MCAuto<ARRAY> ret=self->deepCopy();
1678               ret->applyDivideBy(val);
1679               return ret.retn();
1680             }
1681           case 2:
1682             {
1683               MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1684               return ARRAY::Divide(self,aaaa);
1685             }
1686           case 3:
1687             {
1688               return ARRAY::Divide(self,a);
1689             }
1690           case 4:
1691             {
1692               MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1693               return ARRAY::Divide(self,aaaa);
1694             }
1695           default:
1696             throw INTERP_KERNEL::Exception(msg);
1697           }
1698       }
1699
1700       ARRAY *__rdiv__(PyObject *obj)
1701       {
1702         const char msg[]="Unexpected situation in __rdiv__ !";
1703         INT val;
1704         ARRAY *a;
1705         std::vector<INT> aa;
1706         ARRAY ## Tuple *aaa;
1707         mcIdType sw;
1708         convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1709         switch(sw)
1710           {
1711           case 1:
1712             {
1713               MCAuto<ARRAY> ret=self->deepCopy();
1714               ret->applyInv(val);
1715               return ret.retn();
1716             }
1717           case 2:
1718             {
1719               MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1720               return ARRAY::Divide(aaaa,self);
1721             }
1722           case 4:
1723             {
1724               MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1725               return ARRAY::Divide(aaaa,self);
1726             }
1727           default:
1728             throw INTERP_KERNEL::Exception(msg);
1729           }
1730       }
1731
1732       PyObject *___idiv___(PyObject *trueSelf, PyObject *obj)
1733       {
1734         const char msg[]="Unexpected situation in __idiv__ !";
1735         INT val;
1736         ARRAY *a;
1737         std::vector<INT> aa;
1738         ARRAY ## Tuple *aaa;
1739         mcIdType sw;
1740         convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1741         switch(sw)
1742           {
1743           case 1:
1744             {
1745               self->applyDivideBy(val);
1746               Py_XINCREF(trueSelf);
1747               return trueSelf;
1748             }
1749           case 2:
1750             {
1751               MCAuto<ARRAY> bb=ARRAY::New(); bb->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1752               self->divideEqual(bb);
1753               Py_XINCREF(trueSelf);
1754               return trueSelf;
1755             }
1756           case 3:
1757             {
1758               self->divideEqual(a);
1759               Py_XINCREF(trueSelf);
1760               return trueSelf;
1761             }
1762           case 4:
1763             {
1764               MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1765               self->divideEqual(aaaa);
1766               Py_XINCREF(trueSelf);
1767               return trueSelf;
1768             }
1769           default:
1770             throw INTERP_KERNEL::Exception(msg);
1771           }
1772       }
1773
1774       ARRAY *__mod__(PyObject *obj)
1775       {
1776         const char msg[]="Unexpected situation in __mod__ !";
1777         INT val;
1778         ARRAY *a;
1779         std::vector<INT> aa;
1780         ARRAY ## Tuple *aaa;
1781         mcIdType sw;
1782         convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1783         switch(sw)
1784           {
1785           case 1:
1786             {
1787               MCAuto<ARRAY> ret=self->deepCopy();
1788               ret->applyModulus(val);
1789               return ret.retn();
1790             }
1791           case 2:
1792             {
1793               MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1794               return ARRAY::Modulus(self,aaaa);
1795             }
1796           case 3:
1797             {
1798               return ARRAY::Modulus(self,a);
1799             }
1800           case 4:
1801             {
1802               MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1803               return ARRAY::Modulus(self,aaaa);
1804             }
1805           default:
1806             throw INTERP_KERNEL::Exception(msg);
1807           }
1808       }
1809
1810       ARRAY *__rmod__(PyObject *obj)
1811       {
1812         const char msg[]="Unexpected situation in __rmod__ !";
1813         INT val;
1814         ARRAY *a;
1815         std::vector<INT> aa;
1816         ARRAY ## Tuple *aaa;
1817         mcIdType sw;
1818         convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1819         switch(sw)
1820           {
1821           case 1:
1822             {
1823               MCAuto<ARRAY> ret=self->deepCopy();
1824               ret->applyRModulus(val);
1825               return ret.retn();
1826             }
1827           case 2:
1828             {
1829               MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1830               return ARRAY::Modulus(aaaa,self);
1831             }
1832           case 3:
1833             {
1834               return ARRAY::Modulus(a,self);
1835             }
1836           case 4:
1837             {
1838               MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1839               return ARRAY::Modulus(aaaa,self);
1840             }
1841           default:
1842             throw INTERP_KERNEL::Exception(msg);
1843           }
1844       }
1845
1846       PyObject *___imod___(PyObject *trueSelf, PyObject *obj)
1847       {
1848         const char msg[]="Unexpected situation in __imod__ !";
1849         INT val;
1850         ARRAY *a;
1851         std::vector<INT> aa;
1852         ARRAY ## Tuple *aaa;
1853         mcIdType sw;
1854         convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1855         switch(sw)
1856           {
1857           case 1:
1858             {
1859               self->applyModulus(val);
1860               Py_XINCREF(trueSelf);
1861               return trueSelf;
1862             }
1863           case 3:
1864             {
1865               self->modulusEqual(a);
1866               Py_XINCREF(trueSelf);
1867               return trueSelf;
1868             }
1869           case 4:
1870             {
1871               MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1872               self->modulusEqual(aaaa);
1873               Py_XINCREF(trueSelf);
1874               return trueSelf;
1875             }
1876           default:
1877             throw INTERP_KERNEL::Exception(msg);
1878           }
1879       }
1880
1881       ARRAY *__pow__(PyObject *obj)
1882       {
1883         const char msg[]="Unexpected situation in __pow__ !";
1884         INT val;
1885         ARRAY *a;
1886         std::vector<INT> aa;
1887         ARRAY ## Tuple *aaa;
1888         mcIdType sw;
1889         convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1890         switch(sw)
1891           {
1892           case 1:
1893             {
1894               MCAuto<ARRAY> ret=self->deepCopy();
1895               ret->applyPow(val);
1896               return ret.retn();
1897             }
1898           case 2:
1899             {
1900               MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1901               return ARRAY::Pow(self,aaaa);
1902             }
1903           case 3:
1904             {
1905               return ARRAY::Pow(self,a);
1906             }
1907           case 4:
1908             {
1909               MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1910               return ARRAY::Pow(self,aaaa);
1911             }
1912           default:
1913             throw INTERP_KERNEL::Exception(msg);
1914           }
1915       }
1916
1917       ARRAY *__rpow__(PyObject *obj)
1918       {
1919         const char msg[]="Unexpected situation in __rpow__ !";
1920         INT val;
1921         ARRAY *a;
1922         std::vector<INT> aa;
1923         ARRAY ## Tuple *aaa;
1924         mcIdType sw;
1925         convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1926         switch(sw)
1927           {
1928           case 1:
1929             {
1930               MCAuto<ARRAY> ret=self->deepCopy();
1931               ret->applyRPow(val);
1932               return ret.retn();
1933             }
1934           case 2:
1935             {
1936               MCAuto<ARRAY> aaaa=ARRAY::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,aa.size());
1937               return ARRAY::Pow(aaaa,self);
1938             }
1939           case 3:
1940             {
1941               return ARRAY::Pow(a,self);
1942             }
1943           case 4:
1944             {
1945               MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1946               return ARRAY::Pow(aaaa,self);
1947             }
1948           default:
1949             throw INTERP_KERNEL::Exception(msg);
1950           }
1951       }
1952    
1953       PyObject *___ipow___(PyObject *trueSelf, PyObject *obj)
1954       {
1955         const char msg[]="Unexpected situation in __ipow__ !";
1956         INT val;
1957         ARRAY *a;
1958         std::vector<INT> aa;
1959         ARRAY ## Tuple *aaa;
1960         mcIdType sw;
1961         convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
1962         switch(sw)
1963           {
1964           case 1:
1965             {
1966               self->applyPow(val);
1967               Py_XINCREF(trueSelf);
1968               return trueSelf;
1969             }
1970           case 3:
1971             {
1972               self->powEqual(a);
1973               Py_XINCREF(trueSelf);
1974               return trueSelf;
1975             }
1976           case 4:
1977             {
1978               MCAuto<ARRAY> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
1979               self->powEqual(aaaa);
1980               Py_XINCREF(trueSelf);
1981               return trueSelf;
1982             }
1983           default:
1984             throw INTERP_KERNEL::Exception(msg);
1985           }
1986       }
1987
1988       std::string __repr__() const
1989       {
1990         std::ostringstream oss;
1991         self->reprQuickOverview(oss);
1992         return oss.str();
1993       }
1994       
1995       void pushBackValsSilent(PyObject *li)
1996       {
1997         mcIdType szArr,sw;
1998         INT iTypppArr;
1999         std::vector<INT> stdvecTyyppArr;
2000         const INT *tmp=convertIntStarLikePyObjToCppIntStar(li,sw,szArr,iTypppArr,stdvecTyyppArr);
2001         self->pushBackValsSilent(tmp,tmp+szArr);
2002       }
2003       
2004       PyObject *partitionByDifferentValues() const
2005       {
2006         std::vector<INT> ret1;
2007         std::vector<DataArrayIdType *> ret0=self->partitionByDifferentValues(ret1);
2008         std::size_t sz=ret0.size();
2009         PyObject *pyRet=PyTuple_New(2);
2010         PyObject *pyRet0=PyList_New((INT)sz);
2011         PyObject *pyRet1=PyList_New((INT)sz);
2012         for(std::size_t i=0;i<sz;i++)
2013           {
2014             PyList_SetItem(pyRet0,i,SWIG_NewPointerObj(SWIG_as_voidptr(ret0[i]),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
2015             PyList_SetItem(pyRet1,i,PyInt_FromLong(ret1[i]));
2016           }
2017         PyTuple_SetItem(pyRet,0,pyRet0);
2018         PyTuple_SetItem(pyRet,1,pyRet1);
2019         return pyRet;
2020       }
2021       
2022       DataArrayIdType *locateComponentId(const ARRAY *valToSearchIntoTuples, const DataArrayIdType *tupleIdHint) const
2023       {
2024         return self->locateComponentId(valToSearchIntoTuples,tupleIdHint);
2025       }
2026       
2027       PyObject *findIdsRangesInListOfIds(const ARRAY *listOfIds) const
2028       {
2029         DataArrayIdType *ret0=0;
2030         ARRAY *ret1=0;
2031         self->findIdsRangesInListOfIds(listOfIds,ret0,ret1);
2032         PyObject *pyRet=PyTuple_New(2);
2033         PyTuple_SetItem(pyRet,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
2034         PyTuple_SetItem(pyRet,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTITraits<INT>::TI, SWIG_POINTER_OWN | 0 ));
2035         return pyRet;
2036       }
2037
2038       PyObject *isRange() const
2039       {
2040         INT a(0),b(0),c(0);
2041         bool ret(self->isRange(a,b,c));
2042         PyObject *pyRet=PyTuple_New(2);
2043         PyObject *ret0Py=ret?Py_True:Py_False,*ret1Py(0);
2044         Py_XINCREF(ret0Py);
2045         PyTuple_SetItem(pyRet,0,ret0Py);
2046         if(ret)
2047           ret1Py=PySlice_New(PyInt_FromLong(a),PyInt_FromLong(b),PyInt_FromLong(c));
2048         else
2049           {
2050             ret1Py=Py_None;
2051             Py_XINCREF(ret1Py);
2052           }
2053         PyTuple_SetItem(pyRet,1,ret1Py);
2054         return pyRet;
2055       }
2056
2057       static bool RemoveIdsFromIndexedArrays(PyObject *li, ARRAY *arr, DataArrayIdType *arrIndx, mcIdType offsetForRemoval=0) throw(INTERP_KERNEL::Exception)
2058       {
2059         mcIdType sw;
2060         INT singleVal;
2061         std::vector<INT> multiVal;
2062         std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slic;
2063         MEDCoupling::ARRAY *daIntTyypp=0;
2064         if(!arrIndx)
2065           throw INTERP_KERNEL::Exception("ARRAY::RemoveIdsFromIndexedArrays : null pointer as arrIndex !");
2066         convertIntStarOrSliceLikePyObjToCpp(li,arrIndx->getNumberOfTuples()-1,sw,singleVal,multiVal,slic,daIntTyypp);
2067         switch(sw)
2068           {
2069           case 1:
2070             return ARRAY::RemoveIdsFromIndexedArrays(&singleVal,&singleVal+1,arr,arrIndx,offsetForRemoval);
2071           case 2:
2072             return ARRAY::RemoveIdsFromIndexedArrays(&multiVal[0],&multiVal[0]+multiVal.size(),arr,arrIndx,offsetForRemoval);
2073           case 4:
2074             return ARRAY::RemoveIdsFromIndexedArrays(daIntTyypp->begin(),daIntTyypp->end(),arr,arrIndx,offsetForRemoval);
2075           default:
2076             throw INTERP_KERNEL::Exception("MEDCouplingUMesh::RemoveIdsFromIndexedArrays : unrecognized type entered, expected list of int, tuple of int or ARRAY !");
2077           }
2078       }
2079
2080       static PyObject *ExtractFromIndexedArrays(PyObject *li, const ARRAY *arrIn, const DataArrayIdType *arrIndxIn) throw(INTERP_KERNEL::Exception)
2081       {
2082         ARRAY *arrOut=0;
2083         DataArrayIdType *arrIndexOut=0;
2084         mcIdType sw;
2085         mcIdType singleVal;
2086         std::vector<mcIdType> multiVal;
2087         std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slic;
2088         MEDCoupling::DataArrayIdType *daIntTyypp=0;
2089         if(!arrIndxIn)
2090           throw INTERP_KERNEL::Exception("ARRAY::ExtractFromIndexedArrays : null pointer as arrIndxIn !");
2091         convertIntStarOrSliceLikePyObjToCpp(li,arrIndxIn->getNumberOfTuples()-1,sw,singleVal,multiVal,slic,daIntTyypp);
2092         switch(sw)
2093           {
2094           case 1:
2095             {
2096               ARRAY::ExtractFromIndexedArrays(&singleVal,&singleVal+1,arrIn,arrIndxIn,arrOut,arrIndexOut);
2097               break;
2098             }
2099           case 2:
2100             {
2101               ARRAY::ExtractFromIndexedArrays(&multiVal[0],&multiVal[0]+multiVal.size(),arrIn,arrIndxIn,arrOut,arrIndexOut);
2102               break;
2103             }
2104           case 4:
2105             {
2106               ARRAY::ExtractFromIndexedArrays(daIntTyypp->begin(),daIntTyypp->end(),arrIn,arrIndxIn,arrOut,arrIndexOut);
2107               break;
2108             }
2109           default:
2110             throw INTERP_KERNEL::Exception("ARRAY::ExtractFromIndexedArrays : unrecognized type entered, expected list of int, tuple of int or ARRAY !");
2111           }
2112         PyObject *ret=PyTuple_New(2);
2113         PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(arrOut),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
2114         PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(arrIndexOut),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
2115         return ret;
2116       }
2117
2118       static PyObject *ExtractFromIndexedArraysSlice(mcIdType strt, mcIdType stp, mcIdType step, const ARRAY *arrIn, const DataArrayIdType *arrIndxIn) throw(INTERP_KERNEL::Exception)
2119       {
2120         ARRAY *arrOut=0;
2121         DataArrayIdType *arrIndexOut=0;
2122         ARRAY::ExtractFromIndexedArraysSlice(strt,stp,step,arrIn,arrIndxIn,arrOut,arrIndexOut);
2123         PyObject *ret=PyTuple_New(2);
2124         PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(arrOut),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
2125         PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(arrIndexOut),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
2126         return ret;
2127       }
2128
2129       static PyObject *ExtractFromIndexedArraysSlice(PyObject *slic, const ARRAY *arrIn, const DataArrayIdType *arrIndxIn) throw(INTERP_KERNEL::Exception)
2130       {
2131         if(!PySlice_Check(slic))
2132           throw INTERP_KERNEL::Exception("ExtractFromIndexedArraysSlice (wrap) : the first param is not a pyslice !");
2133         Py_ssize_t strt=2,stp=2,step=2;
2134         if(!arrIndxIn)
2135           throw INTERP_KERNEL::Exception("ExtractFromIndexedArraysSlice (wrap) : last array is null !");
2136         arrIndxIn->checkAllocated();
2137         if(arrIndxIn->getNumberOfComponents()!=1)
2138           throw INTERP_KERNEL::Exception("ExtractFromIndexedArraysSlice (wrap) : number of components of last argument must be equal to one !");
2139         GetIndicesOfSlice(slic,arrIndxIn->getNumberOfTuples(),&strt,&stp,&step,"ExtractFromIndexedArraysSlice (wrap) : Invalid slice regarding nb of elements !");
2140         ARRAY *arrOut=0;
2141         DataArrayIdType *arrIndexOut=0;
2142         ARRAY::ExtractFromIndexedArraysSlice(ToIdType(strt),ToIdType(stp),ToIdType(step),arrIn,arrIndxIn,arrOut,arrIndexOut);
2143         PyObject *ret=PyTuple_New(2);
2144         PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(arrOut),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
2145         PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(arrIndexOut),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
2146         return ret;
2147       }
2148
2149       static PyObject *SetPartOfIndexedArrays(PyObject *li,
2150                                               const ARRAY *arrIn, const DataArrayIdType *arrIndxIn,
2151                                               const ARRAY *srcArr, const DataArrayIdType *srcArrIndex) throw(INTERP_KERNEL::Exception)
2152       {
2153         ARRAY *arrOut=0;
2154         DataArrayIdType *arrIndexOut=0;
2155         mcIdType sw;
2156         mcIdType singleVal;
2157         std::vector<mcIdType> multiVal;
2158         std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slic;
2159         MEDCoupling::DataArrayIdType *daIntTyypp=0;
2160         if(!arrIndxIn)
2161           throw INTERP_KERNEL::Exception("ARRAY::SetPartOfIndexedArrays : null pointer as arrIndex !");
2162         convertIntStarOrSliceLikePyObjToCpp(li,arrIndxIn->getNumberOfTuples()-1,sw,singleVal,multiVal,slic,daIntTyypp);
2163         switch(sw)
2164           {
2165           case 1:
2166             {
2167               ARRAY::SetPartOfIndexedArrays(&singleVal,&singleVal+1,arrIn,arrIndxIn,srcArr,srcArrIndex,arrOut,arrIndexOut);
2168               break;
2169             }
2170           case 2:
2171             {
2172               ARRAY::SetPartOfIndexedArrays(&multiVal[0],&multiVal[0]+multiVal.size(),arrIn,arrIndxIn,srcArr,srcArrIndex,arrOut,arrIndexOut);
2173               break;
2174             }
2175           case 4:
2176             {
2177               ARRAY::SetPartOfIndexedArrays(daIntTyypp->begin(),daIntTyypp->end(),arrIn,arrIndxIn,srcArr,srcArrIndex,arrOut,arrIndexOut);
2178               break;
2179             }
2180           default:
2181             throw INTERP_KERNEL::Exception("ARRAY::SetPartOfIndexedArrays : unrecognized type entered, expected list of int, tuple of int or ARRAY !");
2182           }
2183         PyObject *ret=PyTuple_New(2);
2184         PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(arrOut),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
2185         PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(arrIndexOut),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
2186         return ret;
2187       }
2188
2189       static void SetPartOfIndexedArraysSameIdx(PyObject *li, ARRAY *arrIn, const DataArrayIdType *arrIndxIn,
2190                                                 const ARRAY *srcArr, const DataArrayIdType *srcArrIndex) throw(INTERP_KERNEL::Exception)
2191       {
2192         mcIdType sw;
2193         mcIdType singleVal;
2194         std::vector<mcIdType> multiVal;
2195         std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slic;
2196         MEDCoupling::DataArrayIdType *daIntTyypp=0;
2197         if(!arrIndxIn)
2198           throw INTERP_KERNEL::Exception("ARRAY::SetPartOfIndexedArraysSameIdx : null pointer as arrIndex !");
2199         convertIntStarOrSliceLikePyObjToCpp(li,arrIndxIn->getNumberOfTuples()-1,sw,singleVal,multiVal,slic,daIntTyypp);
2200         switch(sw)
2201           {
2202           case 1:
2203             {
2204               ARRAY::SetPartOfIndexedArraysSameIdx(&singleVal,&singleVal+1,arrIn,arrIndxIn,srcArr,srcArrIndex);
2205               break;
2206             }
2207           case 2:
2208             {
2209               ARRAY::SetPartOfIndexedArraysSameIdx(&multiVal[0],&multiVal[0]+multiVal.size(),arrIn,arrIndxIn,srcArr,srcArrIndex);
2210               break;
2211             }
2212           case 4:
2213             {
2214               ARRAY::SetPartOfIndexedArraysSameIdx(daIntTyypp->begin(),daIntTyypp->end(),arrIn,arrIndxIn,srcArr,srcArrIndex);
2215               break;
2216             }
2217           default:
2218             throw INTERP_KERNEL::Exception("ARRAY::SetPartOfIndexedArraysSameIdx : unrecognized type entered, expected list of int, tuple of int or ARRAY !");
2219           }
2220       }
2221
2222     } // end extent
2223   };
2224
2225   class ARRAY ## Tuple;
2226
2227   class ARRAY ## Iterator
2228   {
2229   public:
2230     ARRAY ## Iterator(ARRAY *da);
2231     ~ARRAY ## Iterator();
2232     %extend
2233     {
2234       PyObject *next()
2235       {
2236         ARRAY ## Tuple *ret=self->nextt();
2237         if(ret)
2238           return SWIG_NewPointerObj(SWIG_as_voidptr(ret),SWIGTYPE_p_MEDCoupling__ ## ARRAY ## Tuple,SWIG_POINTER_OWN | 0);
2239         else
2240           {
2241             PyErr_SetString(PyExc_StopIteration,"No more data.");
2242             return 0;
2243           }
2244       }
2245     }
2246   };
2247
2248   class ARRAY ## Tuple
2249   {
2250   public:
2251     std::size_t getNumberOfCompo() const;
2252     ARRAY *buildDAInt(INT nbOfTuples, INT nbOfCompo) const;
2253     %extend
2254     {
2255       std::string __str__() const
2256       {
2257         return self->repr();
2258       }
2259
2260       INT __int__() const
2261       {
2262         return self->intValue();
2263       }
2264
2265       ARRAY *buildDAInt()
2266       {
2267         return self->buildDAInt(1,self->getNumberOfCompo());
2268       }
2269
2270       PyObject *___iadd___(PyObject *trueSelf, PyObject *obj)
2271       {
2272         MCAuto<ARRAY> ret=self->buildDAInt(1,self->getNumberOfCompo());
2273         MEDCoupling_ ## ARRAY ## ____iadd___(ret,0,obj);
2274         Py_XINCREF(trueSelf);
2275         return trueSelf;
2276       }
2277   
2278       PyObject *___isub___(PyObject *trueSelf, PyObject *obj)
2279       {
2280         MCAuto<ARRAY> ret=self->buildDAInt(1,self->getNumberOfCompo());
2281         MEDCoupling_ ## ARRAY ## ____isub___(ret,0,obj);
2282         Py_XINCREF(trueSelf);
2283         return trueSelf;
2284       }
2285   
2286       PyObject *___imul___(PyObject *trueSelf, PyObject *obj)
2287       {
2288         MCAuto<ARRAY> ret=self->buildDAInt(1,self->getNumberOfCompo());
2289         MEDCoupling_ ## ARRAY ## ____imul___(ret,0,obj);
2290         Py_XINCREF(trueSelf);
2291         return trueSelf;
2292       }
2293       PyObject *___idiv___(PyObject *trueSelf, PyObject *obj)
2294       {
2295         MCAuto<ARRAY> ret=self->buildDAInt(1,self->getNumberOfCompo());
2296         MEDCoupling_ ## ARRAY ## ____idiv___(ret,0,obj);
2297         Py_XINCREF(trueSelf);
2298         return trueSelf;
2299       }
2300
2301       PyObject *___imod___(PyObject *trueSelf, PyObject *obj)
2302       {
2303         MCAuto<ARRAY> ret=self->buildDAInt(1,self->getNumberOfCompo());
2304         MEDCoupling_ ## ARRAY ## ____imod___(ret,0,obj);
2305         Py_XINCREF(trueSelf);
2306         return trueSelf;
2307       }
2308
2309       PyObject *__len__()
2310       {
2311         return PyInt_FromLong(self->getNumberOfCompo());
2312       }
2313   
2314       PyObject *__getitem__(PyObject *obj)
2315       {
2316         const char msg2[]="ARRAY ## Tuple::__getitem__ : Mismatch of slice values in 2nd parameter (components) !";
2317         mcIdType sw;
2318         INT singleVal;
2319         std::vector<INT> multiVal;
2320         std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slic;
2321         MEDCoupling::DataArrayIdType *daIntTyypp=0;
2322         const INT *pt=self->getConstPointer();
2323         INT nbc=(INT)self->getNumberOfCompo();
2324         convertIntStarOrSliceLikePyObjToCppWithNegIntInterp(obj,ToIdType(nbc),sw,singleVal,multiVal,slic,daIntTyypp);
2325         switch(sw)
2326           {
2327           case 1:
2328             {
2329               if(singleVal>=(INT)nbc)
2330                 {
2331                   std::ostringstream oss;
2332                   oss << "Requesting for id " << singleVal << " having only " << nbc << " components !";
2333                   PyErr_SetString(PyExc_StopIteration,oss.str().c_str());
2334                   return 0;
2335                 }
2336               if(singleVal>=0)
2337                 return PyInt_FromLong(pt[singleVal]);
2338               else
2339                 {
2340                   if(nbc+singleVal>0)
2341                     return PyInt_FromLong(pt[nbc+singleVal]);
2342                   else
2343                     {
2344                       std::ostringstream oss;
2345                       oss << "Requesting for id " << singleVal << " having only " << nbc << " components !";
2346                       throw INTERP_KERNEL::Exception(oss.str().c_str());
2347                     }
2348                 }
2349             }
2350           case 2:
2351             {
2352               PyObject *t=PyTuple_New(multiVal.size());
2353               for(std::size_t j=0;j<multiVal.size();j++)
2354                 {
2355                   INT cid=multiVal[j];
2356                   if(cid>=(INT)nbc)
2357                     {
2358                       std::ostringstream oss;
2359                       oss << "Requesting for id #" << cid << " having only " << nbc << " components !";
2360                       throw INTERP_KERNEL::Exception(oss.str().c_str());
2361                     }
2362                   PyTuple_SetItem(t,j,PyInt_FromLong(pt[cid]));
2363                 }
2364               return t;
2365             }
2366           case 3:
2367             {
2368               mcIdType sz=DataArray::GetNumberOfItemGivenBES(slic.first,slic.second.first,slic.second.second,msg2);
2369               PyObject *t=PyTuple_New(sz);
2370               for(INT j=0;j<sz;j++)
2371                 PyTuple_SetItem(t,j,PyInt_FromLong(pt[slic.first+j*slic.second.second]));
2372               return t;
2373             }
2374           default:
2375             throw INTERP_KERNEL::Exception("ARRAY ## Tuple::__getitem__ : unrecognized type entered !");
2376           }
2377       }
2378
2379       ARRAY ## Tuple *__setitem__(PyObject *obj, PyObject *value)
2380       {
2381         const char msg[]="DataArrayIntTuple::__setitem__ : unrecognized type entered, int, slice, list<int>, tuple<int> !";
2382         const char msg2[]="DataArrayIntTuple::__setitem__ : Mismatch of slice values in 2nd parameter (components) !";
2383         mcIdType sw1,sw2;
2384         mcIdType singleValV;
2385         std::vector<mcIdType> multiValV;
2386         std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slicV;
2387         MEDCoupling::ARRAY ## Tuple *daIntTyyppV=0;
2388         mcIdType nbc=ToIdType(self->getNumberOfCompo());
2389         convertObjToPossibleCpp22<INT>(value,nbc,sw1,singleValV,multiValV,slicV,daIntTyyppV);
2390         INT singleVal;
2391         std::vector<INT> multiVal;
2392         std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slic;
2393         MEDCoupling::ARRAY *daIntTyypp=0;
2394         INT *pt=self->getPointer();
2395         convertIntStarOrSliceLikePyObjToCppWithNegIntInterp(obj,nbc,sw2,singleVal,multiVal,slic,daIntTyypp);
2396         switch(sw2)
2397           {
2398           case 1:
2399             {
2400               if(singleVal>=nbc)
2401                 {
2402                   std::ostringstream oss;
2403                   oss << "Requesting for setting id # " << singleVal << " having only " << nbc << " components !";
2404                   throw INTERP_KERNEL::Exception(oss.str().c_str());
2405                 }
2406               switch(sw1)
2407                 {
2408                 case 1:
2409                   {
2410                     pt[singleVal]=(INT)singleValV;
2411                     return self;
2412                   }
2413                 case 2:
2414                   {
2415                     if(multiValV.size()!=1)
2416                       {
2417                         std::ostringstream oss;
2418                         oss << "Requesting for setting id # " << singleVal << " with a list or tuple with size != 1 ! ";
2419                         throw INTERP_KERNEL::Exception(oss.str().c_str());
2420                       }
2421                     pt[singleVal]=(INT)multiValV[0];
2422                     return self;
2423                   }
2424                 case 4:
2425                   {
2426                     pt[singleVal]=daIntTyyppV->getConstPointer()[0];
2427                     return self;
2428                   }
2429                 default:
2430                   throw INTERP_KERNEL::Exception(msg);
2431                 }
2432             }
2433           case 2:
2434             {
2435               switch(sw1)
2436                 {
2437                 case 1:
2438                   {
2439                     for(std::vector<INT>::const_iterator it=multiVal.begin();it!=multiVal.end();it++)
2440                       {
2441                         if(*it>=nbc)
2442                           {
2443                             std::ostringstream oss;
2444                             oss << "Requesting for setting id # " << *it << " having only " << nbc << " components !";
2445                             throw INTERP_KERNEL::Exception(oss.str().c_str());
2446                           }
2447                         pt[*it]=(INT)singleValV;
2448                       }
2449                     return self;
2450                   }
2451                 case 2:
2452                   {
2453                     if(multiVal.size()!=multiValV.size())
2454                       {
2455                         std::ostringstream oss;
2456                         oss << "Mismatch length of during assignment : " << multiValV.size() << " != " << multiVal.size() << " !";
2457                         throw INTERP_KERNEL::Exception(oss.str().c_str());
2458                       }
2459                     for(INT i=0;i<(INT)multiVal.size();i++)
2460                       {
2461                         INT pos=multiVal[i];
2462                         if(pos>=nbc)
2463                           {
2464                             std::ostringstream oss;
2465                             oss << "Requesting for setting id # " << pos << " having only " << nbc << " components !";
2466                             throw INTERP_KERNEL::Exception(oss.str().c_str());
2467                           }
2468                         pt[multiVal[i]]=(INT)multiValV[i];
2469                       }
2470                     return self;
2471                   }
2472                 case 4:
2473                   {
2474                     const INT *ptV=daIntTyyppV->getConstPointer();
2475                     if(nbc>(INT)daIntTyyppV->getNumberOfCompo())
2476                       {
2477                         std::ostringstream oss;
2478                         oss << "Mismatch length of during assignment : " << nbc << " != " << daIntTyyppV->getNumberOfCompo() << " !";
2479                         throw INTERP_KERNEL::Exception(oss.str().c_str());
2480                       }
2481                     std::copy(ptV,ptV+nbc,pt);
2482                     return self;
2483                   }
2484                 default:
2485                   throw INTERP_KERNEL::Exception(msg);
2486                 }
2487             }
2488           case 3:
2489             {
2490               std::size_t sz=DataArray::GetNumberOfItemGivenBES(slic.first,slic.second.first,slic.second.second,msg2);
2491               switch(sw1)
2492                 {
2493                 case 1:
2494                   {
2495                     for(std::size_t j=0;j<sz;j++)
2496                       pt[slic.first+j*slic.second.second]=(INT)singleValV;
2497                     return self;
2498                   }
2499                 case 2:
2500                   {
2501                     if(sz!=multiValV.size())
2502                       {
2503                         std::ostringstream oss;
2504                         oss << "Mismatch length of during assignment : " << multiValV.size() << " != " << sz << " !";
2505                         throw INTERP_KERNEL::Exception(oss.str().c_str());
2506                       }
2507                     for(std::size_t j=0;j<sz;j++)
2508                       pt[slic.first+j*slic.second.second]=(INT)multiValV[j];
2509                     return self;
2510                   }
2511                 case 4:
2512                   {
2513                     const INT *ptV=daIntTyyppV->getConstPointer();
2514                     if(sz>daIntTyyppV->getNumberOfCompo())
2515                       {
2516                         std::ostringstream oss;
2517                         oss << "Mismatch length of during assignment : " << nbc << " != " << daIntTyyppV->getNumberOfCompo() << " !";
2518                         throw INTERP_KERNEL::Exception(oss.str().c_str());
2519                       }
2520                     for(std::size_t j=0;j<sz;j++)
2521                       pt[slic.first+j*slic.second.second]=ptV[j];
2522                     return self;
2523                   }
2524                 default:
2525                   throw INTERP_KERNEL::Exception(msg);
2526                 }
2527             }
2528           default:
2529             throw INTERP_KERNEL::Exception(msg);
2530           }
2531       }
2532     }
2533 //   };
2534 // }
2535 %enddef
2536
2537
2538 %define TRANSFORMWITHINDARR( ARRAY, INT )
2539 void transformWithIndArr(PyObject *li)
2540 {
2541   void *da=0;
2542   int res1(SWIG_ConvertPtr(li,&da,SWIGTITraits<INT>::TI, 0 |  0 ));
2543   if (!SWIG_IsOK(res1))
2544     {
2545       int res2(SWIG_ConvertPtr(li,&da,SWIGTYPE_p_MEDCoupling__MapII, 0 |  0 ));
2546       if(SWIG_IsOK(res2))
2547         {
2548           MapII *m=reinterpret_cast<MapII *>(da);
2549           self->transformWithIndArr(*m);
2550         }
2551       else
2552         {
2553           mcIdType size;
2554           INTERP_KERNEL::AutoPtr<INT> tmp=convertPyToNewIntArr2<INT>(li,&size);
2555           self->transformWithIndArr(tmp,tmp+size);
2556         }
2557     }
2558   else
2559     {
2560       ARRAY *da2=reinterpret_cast< ARRAY * >(da);
2561       self->transformWithIndArr(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems());
2562     }
2563 }
2564 %enddef
2565
2566 namespace MEDCoupling
2567 {
2568   typedef int      Int32;
2569 #ifdef WIN32
2570   typedef long long Int64;
2571 #else
2572   typedef long int  Int64;
2573 #endif
2574
2575   class DataArrayInt32Iterator;
2576
2577   class DataArrayInt32 : public DataArray
2578   {
2579     ARRAYDEF( DataArrayInt32, Int32 )
2580   };
2581   %extend DataArrayInt32 {
2582     DataArrayInt64 *convertToInt64Arr() const
2583     {
2584       MCAuto<DataArrayInt64> ret(self->convertToInt64Arr());
2585       return ret.retn();
2586     }
2587 #ifdef WITH_NUMPY
2588     PyObject *toNumPyArray() // not const. It is not a bug !
2589     {
2590       return ToNumPyArray<DataArrayInt32,MEDCoupling::Int32>(self,NPY_INT32,"DataArrayInt32");
2591     }
2592 #endif
2593 #ifndef MEDCOUPLING_USE_64BIT_IDS
2594     MCAuto< MapII > invertArrayN2O2O2NOptimized()
2595     {
2596       return self->invertArrayN2O2O2NOptimized();
2597     }
2598     MCAuto< MapII > giveN2OOptimized()
2599     {
2600       return self->giveN2OOptimized();
2601     }
2602     TRANSFORMWITHINDARR( DataArrayInt32, Int32 )
2603 #endif
2604   };
2605   
2606   class DataArrayInt64Iterator;
2607
2608   class DataArrayInt64 : public DataArray
2609   {
2610     ARRAYDEF( DataArrayInt64, Int64 )
2611   };
2612   %extend DataArrayInt64 {
2613     DataArrayInt32 *convertToInt32Arr() const
2614     {
2615       MCAuto<DataArrayInt32> ret(self->convertToInt32Arr());
2616       return ret.retn();
2617     }
2618 #ifdef WITH_NUMPY
2619     PyObject *toNumPyArray() // not const. It is not a bug !
2620     {
2621       return ToNumPyArray<DataArrayInt64,MEDCoupling::Int64>(self,NPY_INT64,"DataArrayInt64");
2622     }
2623 #endif
2624 #ifdef MEDCOUPLING_USE_64BIT_IDS
2625     MCAuto< MapII > invertArrayN2O2O2NOptimized()
2626     {
2627       return self->invertArrayN2O2O2NOptimized();
2628     }
2629     MCAuto< MapII > giveN2OOptimized()
2630     {
2631       return self->giveN2OOptimized();
2632     }
2633     TRANSFORMWITHINDARR( DataArrayInt64, Int64 )
2634 #endif
2635   };
2636
2637 }