1 // Copyright (C) 2007-2019 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Anthony Geay (EDF R&D)
22 %typemap(out) MEDCoupling::DataArray*
24 $result=convertDataArray($1,$owner);
27 %typemap(out) DataArray*
29 $result=convertDataArray($1,$owner);
34 %typemap(out) MEDCoupling::DataArrayChar*
36 $result=convertDataArrayChar($1,$owner);
39 %typemap(out) DataArrayChar*
41 $result=convertDataArrayChar($1,$owner);
44 %typemap(out) MCAuto<MEDCoupling::DataArrayInt>
46 $result=SWIG_NewPointerObj(SWIG_as_voidptr($1.retn()),SWIGTYPE_p_MEDCoupling__DataArrayInt,SWIG_POINTER_OWN|0);
49 %typemap(out) MCAuto<MEDCoupling::DataArrayDouble>
51 $result=SWIG_NewPointerObj(SWIG_as_voidptr($1.retn()),SWIGTYPE_p_MEDCoupling__DataArrayDouble,SWIG_POINTER_OWN|0);
54 %typemap(out) MCAuto<MEDCoupling::DataArrayFloat>
56 $result=SWIG_NewPointerObj(SWIG_as_voidptr($1.retn()),SWIGTYPE_p_MEDCoupling__DataArrayFloat,SWIG_POINTER_OWN|0);
59 %typemap(out) MCAuto<MEDCoupling::MapII>
61 $result=SWIG_NewPointerObj(SWIG_as_voidptr($1.retn()),SWIGTYPE_p_MEDCoupling__MapII,SWIG_POINTER_OWN|0);
65 %newobject MEDCoupling::DataArray::deepCopy;
66 %newobject MEDCoupling::DataArray::buildNewEmptyInstance;
67 %newobject MEDCoupling::DataArray::selectByTupleRanges;
68 %newobject MEDCoupling::DataArray::selectByTupleId;
69 %newobject MEDCoupling::DataArray::selectByTupleIdSafe;
70 %newobject MEDCoupling::DataArray::selectByTupleIdSafeSlice;
71 %newobject MEDCoupling::DataArray::Aggregate;
72 %newobject MEDCoupling::DataArrayFloat::New;
73 %newobject MEDCoupling::DataArrayFloat::iterator;
74 %newobject MEDCoupling::DataArrayFloat::__iter__;
75 %newobject MEDCoupling::DataArrayFloat::Meld;
76 %newobject MEDCoupling::DataArrayFloat::__rmul__;
77 %newobject MEDCoupling::DataArrayInt::New;
78 %newobject MEDCoupling::DataArrayInt::__iter__;
79 %newobject MEDCoupling::DataArrayInt::performCopyOrIncrRef;
80 %newobject MEDCoupling::DataArrayInt::subArray;
81 %newobject MEDCoupling::DataArrayInt::changeNbOfComponents;
82 %newobject MEDCoupling::DataArrayInt::accumulatePerChunck;
83 %newobject MEDCoupling::DataArrayInt::checkAndPreparePermutation;
84 %newobject MEDCoupling::DataArrayInt::transformWithIndArrR;
85 %newobject MEDCoupling::DataArrayInt::renumber;
86 %newobject MEDCoupling::DataArrayInt::renumberR;
87 %newobject MEDCoupling::DataArrayInt::renumberAndReduce;
88 %newobject MEDCoupling::DataArrayInt::invertArrayO2N2N2O;
89 %newobject MEDCoupling::DataArrayInt::invertArrayN2O2O2N;
90 %newobject MEDCoupling::DataArrayInt::invertArrayO2N2N2OBis;
91 %newobject MEDCoupling::DataArrayInt::findIdsEqual;
92 %newobject MEDCoupling::DataArrayInt::findIdsNotEqual;
93 %newobject MEDCoupling::DataArrayInt::findIdsEqualList;
94 %newobject MEDCoupling::DataArrayInt::findIdsNotEqualList;
95 %newobject MEDCoupling::DataArrayInt::findIdsEqualTuple;
96 %newobject MEDCoupling::DataArrayInt::findIdForEach;
97 %newobject MEDCoupling::DataArrayInt::sumPerTuple;
98 %newobject MEDCoupling::DataArrayInt::negate;
99 %newobject MEDCoupling::DataArrayInt::computeAbs;
100 %newobject MEDCoupling::DataArrayInt::findIdsInRange;
101 %newobject MEDCoupling::DataArrayInt::findIdsNotInRange;
102 %newobject MEDCoupling::DataArrayInt::findIdsStrictlyNegative;
103 %newobject MEDCoupling::DataArrayInt::Aggregate;
104 %newobject MEDCoupling::DataArrayInt::AggregateIndexes;
105 %newobject MEDCoupling::DataArrayInt::Meld;
106 %newobject MEDCoupling::DataArrayInt::Add;
107 %newobject MEDCoupling::DataArrayInt::Substract;
108 %newobject MEDCoupling::DataArrayInt::Multiply;
109 %newobject MEDCoupling::DataArrayInt::Divide;
110 %newobject MEDCoupling::DataArrayInt::Pow;
111 %newobject MEDCoupling::DataArrayInt::BuildUnion;
112 %newobject MEDCoupling::DataArrayInt::BuildIntersection;
113 %newobject MEDCoupling::DataArrayInt::Range;
114 %newobject MEDCoupling::DataArrayInt::indicesOfSubPart;
115 %newobject MEDCoupling::DataArrayInt::fromNoInterlace;
116 %newobject MEDCoupling::DataArrayInt::toNoInterlace;
117 %newobject MEDCoupling::DataArrayInt::buildComplement;
118 %newobject MEDCoupling::DataArrayInt::buildUnion;
119 %newobject MEDCoupling::DataArrayInt::buildSubstraction;
120 %newobject MEDCoupling::DataArrayInt::buildSubstractionOptimized;
121 %newobject MEDCoupling::DataArrayInt::buildIntersection;
122 %newobject MEDCoupling::DataArrayInt::buildUnique;
123 %newobject MEDCoupling::DataArrayInt::buildUniqueNotSorted;
124 %newobject MEDCoupling::DataArrayInt::deltaShiftIndex;
125 %newobject MEDCoupling::DataArrayInt::buildExplicitArrByRanges;
126 %newobject MEDCoupling::DataArrayInt::buildExplicitArrOfSliceOnScaledArr;
127 %newobject MEDCoupling::DataArrayInt::findRangeIdForEachTuple;
128 %newobject MEDCoupling::DataArrayInt::findIdInRangeForEachTuple;
129 %newobject MEDCoupling::DataArrayInt::duplicateEachTupleNTimes;
130 %newobject MEDCoupling::DataArrayInt::buildPermutationArr;
131 %newobject MEDCoupling::DataArrayInt::buildPermArrPerLevel;
132 %newobject MEDCoupling::DataArrayInt::getDifferentValues;
133 %newobject MEDCoupling::DataArrayInt::FindPermutationFromFirstToSecond;
134 %newobject MEDCoupling::DataArrayInt::CheckAndPreparePermutation;
135 %newobject MEDCoupling::DataArrayInt::__neg__;
136 %newobject MEDCoupling::DataArrayInt::__add__;
137 %newobject MEDCoupling::DataArrayInt::__radd__;
138 %newobject MEDCoupling::DataArrayInt::__sub__;
139 %newobject MEDCoupling::DataArrayInt::__rsub__;
140 %newobject MEDCoupling::DataArrayInt::__mul__;
141 %newobject MEDCoupling::DataArrayInt::__rmul__;
142 %newobject MEDCoupling::DataArrayInt::__div__;
143 %newobject MEDCoupling::DataArrayInt::__rdiv__;
144 %newobject MEDCoupling::DataArrayInt::__mod__;
145 %newobject MEDCoupling::DataArrayInt::__rmod__;
146 %newobject MEDCoupling::DataArrayInt::__pow__;
147 %newobject MEDCoupling::DataArrayInt::__rpow__;
148 %newobject MEDCoupling::DataArrayIntTuple::buildDAInt;
149 %newobject MEDCoupling::DataArrayChar::convertToIntArr;
150 %newobject MEDCoupling::DataArrayChar::renumber;
151 %newobject MEDCoupling::DataArrayChar::renumberR;
152 %newobject MEDCoupling::DataArrayChar::renumberAndReduce;
153 %newobject MEDCoupling::DataArrayChar::changeNbOfComponents;
154 %newobject MEDCoupling::DataArrayChar::findIdsEqual;
155 %newobject MEDCoupling::DataArrayChar::findIdsNotEqual;
156 %newobject MEDCoupling::DataArrayChar::Aggregate;
157 %newobject MEDCoupling::DataArrayChar::Meld;
158 %newobject MEDCoupling::DataArrayByte::New;
159 %newobject MEDCoupling::DataArrayByte::__iter__;
160 %newobject MEDCoupling::DataArrayByte::performCopyOrIncrRef;
161 %newobject MEDCoupling::DataArrayByteTuple::buildDAByte;
162 %newobject MEDCoupling::DataArrayChar::subArray;
163 %newobject MEDCoupling::DataArrayAsciiChar::New;
164 %newobject MEDCoupling::DataArrayAsciiChar::__iter__;
165 %newobject MEDCoupling::DataArrayAsciiChar::performCopyOrIncrRef;
166 %newobject MEDCoupling::DataArrayAsciiCharTuple::buildDAAsciiChar;
167 %newobject MEDCoupling::DataArrayDouble::New;
168 %newobject MEDCoupling::DataArrayDouble::__iter__;
169 %newobject MEDCoupling::DataArrayDouble::performCopyOrIncrRef;
170 %newobject MEDCoupling::DataArrayDouble::Aggregate;
171 %newobject MEDCoupling::DataArrayDouble::Meld;
172 %newobject MEDCoupling::DataArrayDouble::Dot;
173 %newobject MEDCoupling::DataArrayDouble::CrossProduct;
174 %newobject MEDCoupling::DataArrayDouble::Add;
175 %newobject MEDCoupling::DataArrayDouble::Substract;
176 %newobject MEDCoupling::DataArrayDouble::Multiply;
177 %newobject MEDCoupling::DataArrayDouble::Divide;
178 %newobject MEDCoupling::DataArrayDouble::Pow;
179 %newobject MEDCoupling::DataArrayDouble::symmetry3DPlane;
180 %newobject MEDCoupling::DataArrayDouble::subArray;
181 %newobject MEDCoupling::DataArrayDouble::changeNbOfComponents;
182 %newobject MEDCoupling::DataArrayDouble::accumulatePerChunck;
183 %newobject MEDCoupling::DataArrayDouble::findIdsInRange;
184 %newobject MEDCoupling::DataArrayDouble::findIdsNotInRange;
185 %newobject MEDCoupling::DataArrayDouble::findIdsStrictlyNegative;
186 %newobject MEDCoupling::DataArrayDouble::negate;
187 %newobject MEDCoupling::DataArrayDouble::computeAbs;
188 %newobject MEDCoupling::DataArrayDouble::applyFunc;
189 %newobject MEDCoupling::DataArrayDouble::applyFuncCompo;
190 %newobject MEDCoupling::DataArrayDouble::applyFuncNamedCompo;
191 %newobject MEDCoupling::DataArrayDouble::doublyContractedProduct;
192 %newobject MEDCoupling::DataArrayDouble::determinant;
193 %newobject MEDCoupling::DataArrayDouble::eigenValues;
194 %newobject MEDCoupling::DataArrayDouble::eigenVectors;
195 %newobject MEDCoupling::DataArrayDouble::inverse;
196 %newobject MEDCoupling::DataArrayDouble::trace;
197 %newobject MEDCoupling::DataArrayDouble::deviator;
198 %newobject MEDCoupling::DataArrayDouble::magnitude;
199 %newobject MEDCoupling::DataArrayDouble::maxPerTuple;
200 %newobject MEDCoupling::DataArrayDouble::sumPerTuple;
201 %newobject MEDCoupling::DataArrayDouble::computeBBoxPerTuple;
202 %newobject MEDCoupling::DataArrayDouble::buildEuclidianDistanceDenseMatrix;
203 %newobject MEDCoupling::DataArrayDouble::buildEuclidianDistanceDenseMatrixWith;
204 %newobject MEDCoupling::DataArrayDouble::renumber;
205 %newobject MEDCoupling::DataArrayDouble::renumberR;
206 %newobject MEDCoupling::DataArrayDouble::renumberAndReduce;
207 %newobject MEDCoupling::DataArrayDouble::fromNoInterlace;
208 %newobject MEDCoupling::DataArrayDouble::toNoInterlace;
209 %newobject MEDCoupling::DataArrayDouble::fromPolarToCart;
210 %newobject MEDCoupling::DataArrayDouble::fromCylToCart;
211 %newobject MEDCoupling::DataArrayDouble::fromSpherToCart;
212 %newobject MEDCoupling::DataArrayDouble::fromCartToPolar;
213 %newobject MEDCoupling::DataArrayDouble::fromCartToCyl;
214 %newobject MEDCoupling::DataArrayDouble::fromCartToSpher;
215 %newobject MEDCoupling::DataArrayDouble::fromCartToCylGiven;
216 %newobject MEDCoupling::DataArrayDouble::cartesianize;
217 %newobject MEDCoupling::DataArrayDouble::getDifferentValues;
218 %newobject MEDCoupling::DataArrayDouble::findClosestTupleId;
219 %newobject MEDCoupling::DataArrayDouble::computeNbOfInteractionsWith;
220 %newobject MEDCoupling::DataArrayDouble::duplicateEachTupleNTimes;
221 %newobject MEDCoupling::DataArrayDouble::__neg__;
222 %newobject MEDCoupling::DataArrayDouble::__radd__;
223 %newobject MEDCoupling::DataArrayDouble::__rsub__;
224 %newobject MEDCoupling::DataArrayDouble::__rmul__;
225 %newobject MEDCoupling::DataArrayDouble::__rdiv__;
226 %newobject MEDCoupling::DataArrayDouble::__pow__;
227 %newobject MEDCoupling::DataArrayDouble::__rpow__;
228 %newobject MEDCoupling::DataArrayDoubleTuple::buildDADouble;
230 %newobject MEDCoupling::PartDefinition::New;
231 %newobject MEDCoupling::PartDefinition::toDAI;
232 %newobject MEDCoupling::PartDefinition::__add__;
233 %newobject MEDCoupling::PartDefinition::composeWith;
234 %newobject MEDCoupling::PartDefinition::tryToSimplify;
235 %newobject MEDCoupling::DataArrayPartDefinition::New;
236 %newobject MEDCoupling::SlicePartDefinition::New;
239 %feature("unref") DataArray "$this->decrRef();"
240 %feature("unref") DataArrayDouble "$this->decrRef();"
241 %feature("unref") DataArrayInt "$this->decrRef();"
242 %feature("unref") DataArrayChar "$this->decrRef();"
243 %feature("unref") DataArrayAsciiChar "$this->decrRef();"
244 %feature("unref") DataArrayByte "$this->decrRef();"
246 %feature("unref") MapII "$this->decrRef();"
247 %feature("unref") PartDefinition "$this->decrRef();"
248 %feature("unref") DataArrayPartDefinition "$this->decrRef();"
249 %feature("unref") SlicePartDefinition "$this->decrRef();"
251 namespace MEDCoupling
258 } MEDCouplingAxisType;
262 class MapII : public RefCountObject, public TimeLabel
265 static MCAuto< MapII > New();
268 class PartDefinition : public RefCountObject, public TimeLabel
271 static PartDefinition *New(int start, int stop, int step);
272 static PartDefinition *New(DataArrayInt *listOfIds);
273 virtual DataArrayInt *toDAI() const;
274 virtual int getNumberOfElems() const;
275 virtual std::string getRepr() const;
276 virtual PartDefinition *composeWith(const PartDefinition *other) const;
277 virtual void checkConsistencyLight() const;
278 virtual PartDefinition *tryToSimplify() const;
281 virtual PartDefinition *__add__(const PartDefinition& other) const
283 return (*self)+other;
286 virtual PyObject *isEqual(const PartDefinition *other) const
289 bool ret0(self->isEqual(other,ret1));
290 PyObject *ret=PyTuple_New(2);
291 PyObject *ret0Py=ret0?Py_True:Py_False;
293 PyTuple_SetItem(ret,0,ret0Py);
294 PyTuple_SetItem(ret,1,PyString_FromString(ret1.c_str()));
298 virtual PyObject *deepCopy() const
300 return convertPartDefinition(self->deepCopy(),SWIG_POINTER_OWN | 0);
304 virtual ~PartDefinition();
307 class DataArrayPartDefinition : public PartDefinition
310 static DataArrayPartDefinition *New(DataArrayInt *listOfIds);
313 DataArrayPartDefinition(DataArrayInt *listOfIds)
315 return DataArrayPartDefinition::New(listOfIds);
318 std::string __str__() const
320 return self->getRepr();
323 std::string __repr__() const
325 std::ostringstream oss; oss << "DataArrayPartDefinition C++ instance at " << self << "." << std::endl;
326 oss << self->getRepr();
331 virtual ~DataArrayPartDefinition();
334 class SlicePartDefinition : public PartDefinition
337 static SlicePartDefinition *New(int start, int stop, int step);
338 int getEffectiveStop() const;
341 SlicePartDefinition(int start, int stop, int step)
343 return SlicePartDefinition::New(start,stop,step);
346 PyObject *getSlice() const
349 self->getSlice(a,b,c);
350 return PySlice_New(PyInt_FromLong(a),PyInt_FromLong(b),PyInt_FromLong(c));
353 std::string __str__() const
355 return self->getRepr();
358 std::string __repr__() const
360 std::ostringstream oss; oss << "SlicePartDefinition C++ instance at " << self << "." << std::endl;
361 oss << self->getRepr();
366 virtual ~SlicePartDefinition();
369 class DataArray : public RefCountObject, public TimeLabel
372 void setName(const std::string& name);
373 void copyStringInfoFrom(const DataArray& other);
374 void copyPartOfStringInfoFrom(const DataArray& other, const std::vector<int>& compoIds);
375 void copyPartOfStringInfoFrom2(const std::vector<int>& compoIds, const DataArray& other);
376 bool areInfoEqualsIfNotWhy(const DataArray& other, std::string& reason) const;
377 bool areInfoEquals(const DataArray& other) const;
378 std::string cppRepr(const std::string& varName) const;
379 std::string getName() const;
380 void setInfoOnComponents(const std::vector<std::string>& info);
381 void setInfoAndChangeNbOfCompo(const std::vector<std::string>& info);
382 std::vector<std::string> getVarsOnComponent() const;
383 std::vector<std::string> getUnitsOnComponent() const;
384 std::string getInfoOnComponent(int i) const;
385 std::string getVarOnComponent(int i) const;
386 std::string getUnitOnComponent(int i) const;
387 void setInfoOnComponent(int i, const std::string& info);
388 int getNumberOfComponents() const;
389 virtual void alloc(int nbOfTuple, int nbOfCompo=1);
390 virtual void reAlloc(int nbOfTuples);
391 virtual bool isAllocated() const;
392 virtual void checkAllocated() const;
393 virtual void desallocate();
394 virtual int getNumberOfTuples() const;
395 virtual std::size_t getNbOfElems() const;
396 virtual std::size_t getNbOfElemAllocated() const;
397 virtual DataArray *deepCopy() const;
398 virtual DataArray *buildNewEmptyInstance() const;
399 virtual DataArray *selectByTupleIdSafeSlice(int bg, int end2, int step) const;
400 virtual void rearrange(int newNbOfCompo);
401 virtual void circularPermutation(int nbOfShift=1);
402 virtual void circularPermutationPerTuple(int nbOfShift=1);
403 virtual void reversePerTuple();
404 void checkNbOfTuples(int nbOfTuples, const std::string& msg) const;
405 void checkNbOfComps(int nbOfCompo, const std::string& msg) const;
406 void checkNbOfTuplesAndComp(const DataArray& other, const std::string& msg) const;
407 void checkNbOfTuplesAndComp(int nbOfTuples, int nbOfCompo, const std::string& msg) const;
408 void checkNbOfElems(std::size_t nbOfElems, const std::string& msg) const;
409 static int GetNumberOfItemGivenBES(int begin, int end, int step, const std::string& msg);
410 static int GetNumberOfItemGivenBESRelative(int begin, int end, int step, const std::string& msg);
411 static int GetPosOfItemGivenBESRelativeNoThrow(int value, int begin, int end, int step);
412 static std::string GetVarNameFromInfo(const std::string& info);
413 static std::string GetUnitFromInfo(const std::string& info);
414 static std::string BuildInfoFromVarAndUnit(const std::string& var, const std::string& unit);
415 static std::string GetAxisTypeRepr(MEDCouplingAxisType at);
416 void updateTime() const;
419 PyObject *getInfoOnComponents() const
421 const std::vector<std::string>& comps=self->getInfoOnComponents();
422 PyObject *ret=PyList_New((int)comps.size());
423 for(int i=0;i<(int)comps.size();i++)
424 PyList_SetItem(ret,i,PyString_FromString(comps[i].c_str()));
428 void copyPartOfStringInfoFrom(const DataArray& other, PyObject *li)
430 std::vector<int> tmp;
431 convertPyToNewIntArr3(li,tmp);
432 self->copyPartOfStringInfoFrom(other,tmp);
435 void copyPartOfStringInfoFrom2(PyObject *li, const DataArray& other)
437 std::vector<int> tmp;
438 convertPyToNewIntArr3(li,tmp);
439 self->copyPartOfStringInfoFrom2(tmp,other);
442 virtual void renumberInPlace(PyObject *li)
445 int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_MEDCoupling__DataArrayInt, 0 | 0 );
446 if (!SWIG_IsOK(res1))
449 INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
450 if(size!=self->getNumberOfTuples())
452 throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
454 self->renumberInPlace(tmp);
458 DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
460 throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
461 da2->checkAllocated();
462 int size=self->getNumberOfTuples();
463 if(size!=self->getNumberOfTuples())
465 throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
467 self->renumberInPlace(da2->getConstPointer());
471 virtual void renumberInPlaceR(PyObject *li)
474 int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_MEDCoupling__DataArrayInt, 0 | 0 );
475 if (!SWIG_IsOK(res1))
478 INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
479 if(size!=self->getNumberOfTuples())
481 throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
483 self->renumberInPlaceR(tmp);
487 DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
489 throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
490 da2->checkAllocated();
491 int size=self->getNumberOfTuples();
492 if(size!=self->getNumberOfTuples())
494 throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
496 self->renumberInPlaceR(da2->getConstPointer());
500 //tuplesSelec in PyObject * because DataArrayInt is not already existing !
501 virtual void setContigPartOfSelectedValues(int tupleIdStart, PyObject *aBase, PyObject *tuplesSelec)
503 static const char msg[]="DataArray::setContigPartOfSelectedValuesSlice : 4th parameter \"tuplesSelec\" should be of type DataArrayInt";
504 DataArray *a=CheckAndRetrieveDataArrayInstance(aBase,"DataArray::setContigPartOfSelectedValuesSlice : 3rd parameter \"aBase\" should be of type DataArray");
505 DataArray *tuplesSelecPtr=CheckAndRetrieveDataArrayInstance(tuplesSelec,msg);
506 DataArrayInt *tuplesSelecPtr2=0;
509 tuplesSelecPtr2=dynamic_cast<DataArrayInt *>(tuplesSelecPtr);
511 throw INTERP_KERNEL::Exception(msg);
513 self->setContigPartOfSelectedValues(tupleIdStart,a,tuplesSelecPtr2);
516 virtual void setContigPartOfSelectedValuesSlice(int tupleIdStart, PyObject *aBase, int bg, int end2, int step)
518 DataArray *a=CheckAndRetrieveDataArrayInstance(aBase,"DataArray::setContigPartOfSelectedValuesSlice : 2nd parameter \"aBase\" should be of type DataArray");
519 self->setContigPartOfSelectedValuesSlice(tupleIdStart,a,bg,end2,step);
522 virtual DataArray *selectByTupleRanges(PyObject *li) const
524 std::vector<std::pair<int,int> > ranges;
525 convertPyToVectorPairInt(li,ranges);
526 return self->selectByTupleRanges(ranges);
529 virtual DataArray *selectByTupleId(PyObject *li) const
532 int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_MEDCoupling__DataArrayInt, 0 | 0 );
533 if (!SWIG_IsOK(res1))
536 INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
537 return self->selectByTupleId(tmp,tmp+size);
541 DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
543 throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
544 da2->checkAllocated();
545 return self->selectByTupleId(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems());
549 virtual DataArray *selectByTupleIdSafe(PyObject *li) const
552 int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_MEDCoupling__DataArrayInt, 0 | 0 );
553 if (!SWIG_IsOK(res1))
556 INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
557 return self->selectByTupleIdSafe(tmp,tmp+size);
561 DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
563 throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
564 da2->checkAllocated();
565 return self->selectByTupleIdSafe(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems());
569 virtual PyObject *keepSelectedComponents(PyObject *li) const
571 std::vector<int> tmp;
572 convertPyToNewIntArr3(li,tmp);
573 DataArray *ret=self->keepSelectedComponents(tmp);
574 return convertDataArray(ret,SWIG_POINTER_OWN | 0 );
577 static PyObject *GetSlice(PyObject *slic, int sliceId, int nbOfSlices)
579 if(!PySlice_Check(slic))
580 throw INTERP_KERNEL::Exception("DataArray::GetSlice (wrap) : expecting a pyslice as second (first) parameter !");
581 Py_ssize_t strt=2,stp=2,step=2;
582 GetIndicesOfSliceExplicitely(slic,&strt,&stp,&step,"DataArray::GetSlice (wrap) : the input slice is invalid !");
584 DataArray::GetSlice(strt,stp,step,sliceId,nbOfSlices,a,b);
585 return PySlice_New(PyInt_FromLong(a),PyInt_FromLong(b),PyInt_FromLong(step));
588 PyObject *getSlice(PyObject *slic, int sliceId, int nbOfSlices) const
590 if(!PySlice_Check(slic))
591 throw INTERP_KERNEL::Exception("DataArray::getSlice (wrap) : expecting a pyslice as second (first) parameter !");
592 Py_ssize_t strt=2,stp=2,step=2;
593 GetIndicesOfSlice(slic,self->getNumberOfTuples(),&strt,&stp,&step,"DataArray::getSlice (wrap) : the input slice is invalid !");
595 DataArray::GetSlice(strt,stp,step,sliceId,nbOfSlices,a,b);
596 return PySlice_New(PyInt_FromLong(a),PyInt_FromLong(b),PyInt_FromLong(step));
599 static int GetNumberOfItemGivenBES(PyObject *slic)
601 if(!PySlice_Check(slic))
602 throw INTERP_KERNEL::Exception("DataArray::GetNumberOfItemGivenBES (wrap) : expecting a pyslice as second (first) parameter !");
603 Py_ssize_t strt=2,stp=2,step=2;
604 GetIndicesOfSliceExplicitely(slic,&strt,&stp,&step,"DataArray::GetNumberOfItemGivenBES (wrap) : the input slice is invalid !");
605 return DataArray::GetNumberOfItemGivenBES(strt,stp,step,"");
608 static int GetNumberOfItemGivenBESRelative(PyObject *slic)
610 if(!PySlice_Check(slic))
611 throw INTERP_KERNEL::Exception("DataArray::GetNumberOfItemGivenBESRelative (wrap) : expecting a pyslice as second (first) parameter !");
612 Py_ssize_t strt=2,stp=2,step=2;
613 GetIndicesOfSliceExplicitely(slic,&strt,&stp,&step,"DataArray::GetNumberOfItemGivenBESRelative (wrap) : the input slice is invalid !");
614 return DataArray::GetNumberOfItemGivenBESRelative(strt,stp,step,"");
617 static DataArray *Aggregate(PyObject *arrs)
619 std::vector<const DataArray *> tmp;
620 convertFromPyObjVectorOfObj<const MEDCoupling::DataArray *>(arrs,SWIGTYPE_p_MEDCoupling__DataArray,"DataArray",tmp);
621 return DataArray::Aggregate(tmp);
624 int getNumberOfItemGivenBES(PyObject *slic) const
626 if(!PySlice_Check(slic))
627 throw INTERP_KERNEL::Exception("DataArray::getNumberOfItemGivenBES (wrap) : expecting a pyslice as second (first) parameter !");
628 Py_ssize_t strt=2,stp=2,step=2;
629 GetIndicesOfSlice(slic,self->getNumberOfTuples(),&strt,&stp,&step,"DataArray::getNumberOfItemGivenBES (wrap) : the input slice is invalid !");
630 return DataArray::GetNumberOfItemGivenBES(strt,stp,step,"");
633 int getNumberOfItemGivenBESRelative(PyObject *slic)
635 if(!PySlice_Check(slic))
636 throw INTERP_KERNEL::Exception("DataArray::getNumberOfItemGivenBESRelative (wrap) : expecting a pyslice as second (first) parameter !");
637 Py_ssize_t strt=2,stp=2,step=2;
638 GetIndicesOfSlice(slic,self->getNumberOfTuples(),&strt,&stp,&step,"DataArray::getNumberOfItemGivenBESRelative (wrap) : the input slice is invalid !");
639 return DataArray::GetNumberOfItemGivenBESRelative(strt,stp,step,"");
642 PyObject *__getstate__() const
644 PyObject *ret(PyTuple_New(2));
645 std::string a0(self->getName());
646 const std::vector<std::string> &a1(self->getInfoOnComponents());
647 PyTuple_SetItem(ret,0,PyString_FromString(a0.c_str()));
650 PyObject *ret1(PyList_New(sz));
651 for(int i=0;i<sz;i++)
652 PyList_SetItem(ret1,i,PyString_FromString(a1[i].c_str()));
653 PyTuple_SetItem(ret,1,ret1);
658 void __setstate__(PyObject *inp)
660 static const char MSG[]="DataArrayDouble.__setstate__ : expected input is a tuple of size 2 with string as 1st arg and list of string as 2nd arg !";
661 if(!PyTuple_Check(inp))
662 throw INTERP_KERNEL::Exception("DataArrayDouble.__setstate__ : invalid input ! Invalid overwrite of __getstate__ ?");
663 int sz(PyTuple_Size(inp));
665 throw INTERP_KERNEL::Exception("DataArrayDouble.__setstate__ : invalid tuple in input ! Should be of size 2 ! Invalid overwrite of __getstate__ ?");
666 PyObject *a0(PyTuple_GetItem(inp,0));
667 self->setName(convertPyObjectToStr(a0,MSG));
668 PyObject *a1(PyTuple_GetItem(inp,1));
669 std::vector<std::string> a1cpp;
670 if(!fillStringVector(a1,a1cpp))
671 throw INTERP_KERNEL::Exception(MSG);
672 self->setInfoOnComponents(a1cpp);
677 class DataArrayDouble;
679 class DataArrayFloat : public DataArray
682 static DataArrayFloat *New();
683 void fillWithValue(float val);
684 bool isEqual(const DataArrayFloat& other, float prec) const;
685 bool isEqualWithoutConsideringStr(const DataArrayFloat& other, float prec) const;
686 bool isUniform(float val, float eps) const;
687 void pushBackSilent(float val);
688 void iota(float init=0.);
689 DataArrayFloatIterator *iterator();
690 MCAuto<DataArrayDouble> convertToDblArr() const;
691 static DataArrayFloat *Meld(const DataArrayFloat *a1, const DataArrayFloat *a2);
696 return DataArrayFloat::New();
699 static DataArrayFloat *New(PyObject *elt0, PyObject *nbOfTuples=0, PyObject *elt2=0)
701 return DataArrayT_New<float>(elt0,nbOfTuples,elt2);
704 DataArrayFloat(PyObject *elt0, PyObject *nbOfTuples=0, PyObject *elt2=0)
706 return MEDCoupling_DataArrayFloat_New__SWIG_1(elt0,nbOfTuples,elt2);
709 DataArrayFloatIterator *__iter__()
711 return self->iterator();
714 std::string __repr__() const
716 std::ostringstream oss;
717 self->reprQuickOverview(oss);
721 std::string __str__() const
723 return self->reprNotTooLong();
728 if(self->isAllocated())
730 return self->getNumberOfTuples();
734 throw INTERP_KERNEL::Exception("DataArrayFloat::__len__ : Instance is NOT allocated !");
738 PyObject *getValues() const
740 const float *vals(self->begin());
741 return convertDblArrToPyList<float>(vals,self->getNbOfElems());
744 PyObject *getValuesAsTuple() const
746 const float *vals(self->begin());
747 int nbOfComp(self->getNumberOfComponents()),nbOfTuples(self->getNumberOfTuples());
748 return convertDblArrToPyListOfTuple<float>(vals,nbOfComp,nbOfTuples);
751 PyObject *isEqualIfNotWhy(const DataArrayFloat& other, float prec) const
754 bool ret0=self->isEqualIfNotWhy(other,prec,ret1);
755 PyObject *ret=PyTuple_New(2);
756 PyObject *ret0Py=ret0?Py_True:Py_False;
758 PyTuple_SetItem(ret,0,ret0Py);
759 PyTuple_SetItem(ret,1,PyString_FromString(ret1.c_str()));
763 PyObject *__getitem__(PyObject *obj)
765 return DataArrayT__getitem<float>(self,obj);
768 DataArrayFloat *__setitem__(PyObject *obj, PyObject *value)
770 return DataArrayT__setitem__<float>(self,obj,value);
773 PyObject *___iadd___(PyObject *trueSelf, PyObject *obj)
775 return DataArrayT_iadd<float>(trueSelf,obj,self);
778 PyObject *___isub___(PyObject *trueSelf, PyObject *obj)
780 return DataArrayT_isub<float>(trueSelf,obj,self);
783 PyObject *___imul___(PyObject *trueSelf, PyObject *obj)
785 return DataArrayT_imul<float>(trueSelf,obj,self);
788 DataArrayFloat *__rmul__(PyObject *obj)
790 return DataArrayFPT_rmul<float>(self,obj);
793 PyObject *___idiv___(PyObject *trueSelf, PyObject *obj)
795 return DataArrayT_idiv<float>(trueSelf,obj,self);
799 PyObject *toNumPyArray() // not const. It is not a bug !
801 return ToNumPyArray<DataArrayFloat,float>(self,NPY_FLOAT,"DataArrayFloat");
807 class DataArrayFloatTuple;
809 class DataArrayFloatIterator
812 DataArrayFloatIterator(DataArrayFloat *da);
813 ~DataArrayFloatIterator();
818 DataArrayFloatTuple *ret=self->nextt();
820 return SWIG_NewPointerObj(SWIG_as_voidptr(ret),SWIGTYPE_p_MEDCoupling__DataArrayFloatTuple,SWIG_POINTER_OWN|0);
823 PyErr_SetString(PyExc_StopIteration,"No more data.");
830 class DataArrayFloatTuple
833 int getNumberOfCompo() const;
834 DataArrayFloat *buildDAFloat(int nbOfTuples, int nbOfCompo) const;
837 std::string __str__() const
842 float __float__() const
844 return self->floatValue();
847 DataArrayFloat *buildDAFloat()
849 return self->buildDAFloat(1,self->getNumberOfCompo());
852 /*PyObject *___imul___(PyObject *trueSelf, PyObject *obj)
854 MCAuto<DataArrayFloat> ret=self->buildDAFloat(1,self->getNumberOfCompo());
855 MEDCoupling_DataArrayFloat____imul___(ret,0,obj);
856 Py_XINCREF(trueSelf);
862 return PyInt_FromLong(self->getNumberOfCompo());
868 class DataArrayDoubleIterator;
870 class DataArrayDouble : public DataArray
873 static DataArrayDouble *New();
874 double doubleValue() const;
876 void aggregate(const DataArrayDouble *other);
877 DataArrayDouble *performCopyOrIncrRef(bool deepCopy) const;
878 void deepCopyFrom(const DataArrayDouble& other);
879 void reserve(std::size_t nbOfElems);
880 void pushBackSilent(double val);
881 double popBackSilent();
883 void allocIfNecessary(int nbOfTuple, int nbOfCompo);
885 void fillWithValue(double val);
886 void iota(double init=0.);
887 bool isUniform(double val, double eps) const;
888 void sort(bool asc=true);
890 void checkMonotonic(bool increasing, double eps) const;
891 bool isMonotonic(bool increasing, double eps) const;
892 std::string repr() const;
893 std::string reprZip() const;
894 std::string reprNotTooLong() const;
895 bool isEqual(const DataArrayDouble& other, double prec) const;
896 bool isEqualWithoutConsideringStr(const DataArrayDouble& other, double prec) const;
897 DataArrayDouble *fromNoInterlace() const;
898 DataArrayDouble *toNoInterlace() const;
899 DataArrayDouble *subArray(int tupleIdBg, int tupleIdEnd=-1) const;
901 DataArrayDouble *changeNbOfComponents(int newNbOfComp, double dftValue) const;
902 void meldWith(const DataArrayDouble *other);
903 DataArrayDouble *duplicateEachTupleNTimes(int nbTimes) const;
904 DataArrayDouble *getDifferentValues(double prec, int limitTupleId=-1) const;
905 DataArrayInt *findClosestTupleId(const DataArrayDouble *other) const;
906 DataArrayInt *computeNbOfInteractionsWith(const DataArrayDouble *otherBBoxFrmt, double eps) const;
907 void setPartOfValues1(const DataArrayDouble *a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare=true);
908 void setPartOfValuesSimple1(double a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp);
909 void setPartOfValuesAdv(const DataArrayDouble *a, const DataArrayInt *tuplesSelec);
910 double getIJ(int tupleId, int compoId) const;
911 double front() const;
913 double getIJSafe(int tupleId, int compoId) const;
914 void setIJ(int tupleId, int compoId, double newVal);
915 void setIJSilent(int tupleId, int compoId, double newVal);
916 double *getPointer();
917 void checkNoNullValues() const;
918 DataArrayDouble *computeBBoxPerTuple(double epsilon=0.0) const;
919 void recenterForMaxPrecision(double eps);
920 double getMaxValueInArray() const;
921 double getMaxAbsValueInArray() const;
922 double getMinValueInArray() const;
923 int count(double value, double eps) const;
924 double getAverageValue() const;
925 double norm2() const;
926 double normMax() const;
927 double normMin() const;
928 double accumulate(int compId) const;
929 DataArrayDouble *fromPolarToCart() const;
930 DataArrayDouble *fromCylToCart() const;
931 DataArrayDouble *fromSpherToCart() const;
932 DataArrayDouble *fromCartToPolar() const;
933 DataArrayDouble *fromCartToCyl() const;
934 DataArrayDouble *fromCartToSpher() const;
935 DataArrayDouble *cartesianize(MEDCouplingAxisType atOfThis) const;
936 DataArrayDouble *doublyContractedProduct() const;
937 DataArrayDouble *determinant() const;
938 DataArrayDouble *eigenValues() const;
939 DataArrayDouble *eigenVectors() const;
940 DataArrayDouble *inverse() const;
941 DataArrayDouble *trace() const;
942 DataArrayDouble *deviator() const;
943 DataArrayDouble *magnitude() const;
944 DataArrayDouble *maxPerTuple() const;
945 DataArrayDouble *sumPerTuple() const;
946 DataArrayDouble *buildEuclidianDistanceDenseMatrix() const;
947 DataArrayDouble *buildEuclidianDistanceDenseMatrixWith(const DataArrayDouble *other) const;
948 void sortPerTuple(bool asc);
950 DataArrayDouble *computeAbs() const;
951 void applyLin(double a, double b, int compoId);
952 void applyLin(double a, double b);
953 void applyInv(double numerator);
954 void applyPow(double val);
955 void applyRPow(double val);
956 DataArrayDouble *negate() const;
957 DataArrayDouble *applyFunc(int nbOfComp, FunctionToEvaluate func) const;
958 DataArrayDouble *applyFunc(int nbOfComp, const std::string& func, bool isSafe=true) const;
959 DataArrayDouble *applyFunc(const std::string& func, bool isSafe=true) const;
960 void applyFuncOnThis(const std::string& func, bool isSafe=true);
961 DataArrayDouble *applyFuncCompo(int nbOfComp, const std::string& func, bool isSafe=true) const;
962 DataArrayDouble *applyFuncNamedCompo(int nbOfComp, const std::vector<std::string>& varsOrder, const std::string& func, bool isSafe=true) const;
963 void applyFuncFast32(const std::string& func);
964 void applyFuncFast64(const std::string& func);
965 DataArrayInt *findIdsInRange(double vmin, double vmax) const;
966 DataArrayInt *findIdsNotInRange(double vmin, double vmax) const;
967 DataArrayInt *findIdsStrictlyNegative() const;
968 static DataArrayDouble *Aggregate(const DataArrayDouble *a1, const DataArrayDouble *a2);
969 static DataArrayDouble *Meld(const DataArrayDouble *a1, const DataArrayDouble *a2);
970 static DataArrayDouble *Dot(const DataArrayDouble *a1, const DataArrayDouble *a2);
971 static DataArrayDouble *CrossProduct(const DataArrayDouble *a1, const DataArrayDouble *a2);
972 static DataArrayDouble *Max(const DataArrayDouble *a1, const DataArrayDouble *a2);
973 static DataArrayDouble *Min(const DataArrayDouble *a1, const DataArrayDouble *a2);
974 static DataArrayDouble *Add(const DataArrayDouble *a1, const DataArrayDouble *a2);
975 void addEqual(const DataArrayDouble *other);
976 static DataArrayDouble *Substract(const DataArrayDouble *a1, const DataArrayDouble *a2);
977 void substractEqual(const DataArrayDouble *other);
978 static DataArrayDouble *Multiply(const DataArrayDouble *a1, const DataArrayDouble *a2);
979 void multiplyEqual(const DataArrayDouble *other);
980 static DataArrayDouble *Divide(const DataArrayDouble *a1, const DataArrayDouble *a2);
981 void divideEqual(const DataArrayDouble *other);
982 static DataArrayDouble *Pow(const DataArrayDouble *a1, const DataArrayDouble *a2);
983 void powEqual(const DataArrayDouble *other);
984 MCAuto<DataArrayInt> findIdsGreaterOrEqualTo(double val) const;
985 MCAuto<DataArrayInt> findIdsGreaterThan(double val) const;
986 MCAuto<DataArrayInt> findIdsLowerOrEqualTo(double val) const;
987 MCAuto<DataArrayInt> findIdsLowerThan(double val) const;
988 MCAuto<DataArrayInt> convertToIntArr() const;
989 MCAuto<DataArrayDouble> selectPartDef(const PartDefinition* pd) const;
990 MCAuto<DataArrayDouble> cumSum() const;
991 MCAuto<DataArrayFloat> convertToFloatArr() const;
996 return DataArrayDouble::New();
999 static DataArrayDouble *New(PyObject *elt0, PyObject *nbOfTuples=0, PyObject *elt2=0)
1001 return DataArrayT_New<double>(elt0,nbOfTuples,elt2);
1004 DataArrayDouble(PyObject *elt0, PyObject *nbOfTuples=0, PyObject *elt2=0)
1006 return MEDCoupling_DataArrayDouble_New__SWIG_1(elt0,nbOfTuples,elt2);
1009 void pushBackValsSilent(PyObject *li)
1012 std::vector<double> bb;
1014 const char msg[]="Python wrap of DataArrayDouble::pushBackValsSilent : ";
1015 const double *tmp=convertObjToPossibleCpp5_SingleCompo(li,sw,val,bb,msg,true,nbTuples);
1016 self->pushBackValsSilent(tmp,tmp+nbTuples);
1019 std::string __repr__() const
1021 std::ostringstream oss;
1022 self->reprQuickOverview(oss);
1026 std::string __str__() const
1028 return self->reprNotTooLong();
1031 double __float__() const
1033 return self->doubleValue();
1038 if(self->isAllocated())
1040 return self->getNumberOfTuples();
1044 throw INTERP_KERNEL::Exception("DataArrayDouble::__len__ : Instance is NOT allocated !");
1048 PyObject *asArcOfCircle() const
1050 double center[2],radius,ang;
1051 self->asArcOfCircle(center,radius,ang);
1052 PyObject *ret(PyTuple_New(3));
1054 PyObject *ret0(PyList_New(2));
1055 PyList_SetItem(ret0,0,PyFloat_FromDouble(center[0]));
1056 PyList_SetItem(ret0,1,PyFloat_FromDouble(center[1]));
1057 PyTuple_SetItem(ret,0,ret0);
1059 PyTuple_SetItem(ret,1,PyFloat_FromDouble(radius));
1060 PyTuple_SetItem(ret,2,PyFloat_FromDouble(ang));
1064 DataArrayDoubleIterator *__iter__()
1066 return self->iterator();
1069 void setValues(PyObject *li, PyObject *nbOfTuples=0, PyObject *nbOfComp=0)
1071 const char *msg="MEDCoupling::DataArrayDouble::setValues : Available API are : \n-DataArrayDouble.setValues([1.,3.,4.])\n-DataArrayDouble.setValues([1.,3.,4.],3)\n-DataArrayDouble.setValues([1.,3.,4.,5.],2,2)\n-DataArrayDouble.setValues([(1.,1.7),(3.,3.7),(4.,4.7)])\n !";
1072 if(PyList_Check(li) || PyTuple_Check(li))
1074 if(nbOfTuples && nbOfTuples != Py_None)
1076 if(PyInt_Check(nbOfTuples))
1078 int nbOfTuples1=PyInt_AS_LONG(nbOfTuples);
1080 throw INTERP_KERNEL::Exception("DataArrayDouble::setValues : should be a positive set of allocated memory !");
1081 if(nbOfComp && nbOfComp != Py_None)
1083 if(PyInt_Check(nbOfComp))
1084 {//DataArrayDouble.setValues([1.,3.,4.,5.],2,2)
1085 int nbOfCompo=PyInt_AS_LONG(nbOfComp);
1087 throw INTERP_KERNEL::Exception("DataArrayDouble::setValues : should be a positive number of components !");
1088 std::vector<double> tmp=fillArrayWithPyListDbl2(li,nbOfTuples1,nbOfCompo);
1089 self->alloc(nbOfTuples1,nbOfCompo); std::copy(tmp.begin(),tmp.end(),self->getPointer());
1092 throw INTERP_KERNEL::Exception(msg);
1095 {//DataArrayDouble.setValues([1.,3.,4.],3)
1097 std::vector<double> tmp=fillArrayWithPyListDbl2(li,nbOfTuples1,tmpp1);
1098 self->alloc(nbOfTuples1,tmpp1); std::copy(tmp.begin(),tmp.end(),self->getPointer());
1102 throw INTERP_KERNEL::Exception(msg);
1105 {// DataArrayDouble.setValues([1.,3.,4.])
1106 int tmpp1=-1,tmpp2=-1;
1107 std::vector<double> tmp=fillArrayWithPyListDbl2(li,tmpp1,tmpp2);
1108 self->alloc(tmpp1,tmpp2); std::copy(tmp.begin(),tmp.end(),self->getPointer());
1112 throw INTERP_KERNEL::Exception(msg);
1115 PyObject *getValues() const
1117 const double *vals(self->begin());
1118 return convertDblArrToPyList<double>(vals,self->getNbOfElems());
1122 PyObject *toNumPyArray() // not const. It is not a bug !
1124 return ToNumPyArray<DataArrayDouble,double>(self,NPY_DOUBLE,"DataArrayDouble");
1128 PyObject *isEqualIfNotWhy(const DataArrayDouble& other, double prec) const
1131 bool ret0=self->isEqualIfNotWhy(other,prec,ret1);
1132 PyObject *ret=PyTuple_New(2);
1133 PyObject *ret0Py=ret0?Py_True:Py_False;
1135 PyTuple_SetItem(ret,0,ret0Py);
1136 PyTuple_SetItem(ret,1,PyString_FromString(ret1.c_str()));
1140 PyObject *getValuesAsTuple() const
1142 const double *vals(self->begin());
1143 int nbOfComp(self->getNumberOfComponents()),nbOfTuples(self->getNumberOfTuples());
1144 return convertDblArrToPyListOfTuple<double>(vals,nbOfComp,nbOfTuples);
1147 static PyObject *ComputeIntegralOfSeg2IntoTri3(PyObject *seg2, PyObject *tri3)
1149 const char msg[]="Python wrap of DataArrayDouble::ComputeIntegralOfSeg2IntoTri3 : ";
1151 DataArrayDouble *a,*a2;
1152 DataArrayDoubleTuple *aa,*aa2;
1153 std::vector<double> bb,bb2;
1155 const double *seg2Ptr(convertObjToPossibleCpp5_Safe(seg2,sw,val,a,aa,bb,msg,2,2,true));
1156 const double *tri3Ptr(convertObjToPossibleCpp5_Safe(tri3,sw,val2,a2,aa2,bb2,msg,3,2,true));
1158 double res0[3],res1;
1159 DataArrayDouble::ComputeIntegralOfSeg2IntoTri3(seg2Ptr,tri3Ptr,res0,res1);
1160 PyObject *ret(PyTuple_New(2)),*ret0(PyTuple_New(3));
1161 PyTuple_SetItem(ret0,0,PyFloat_FromDouble(res0[0]));
1162 PyTuple_SetItem(ret0,1,PyFloat_FromDouble(res0[1]));
1163 PyTuple_SetItem(ret0,2,PyFloat_FromDouble(res0[2]));
1164 PyTuple_SetItem(ret,0,ret0);
1165 PyTuple_SetItem(ret,1,PyFloat_FromDouble(res1));
1169 DataArrayDouble *symmetry3DPlane(PyObject *point, PyObject *normalVector)
1171 const char msg[]="Python wrap of DataArrayDouble::symmetry3DPlane : ";
1173 DataArrayDouble *a,*a2;
1174 DataArrayDoubleTuple *aa,*aa2;
1175 std::vector<double> bb,bb2;
1177 const double *centerPtr(convertObjToPossibleCpp5_Safe(point,sw,val,a,aa,bb,msg,1,3,true));
1178 const double *vectorPtr(convertObjToPossibleCpp5_Safe(normalVector,sw,val2,a2,aa2,bb2,msg,1,3,true));
1179 MCAuto<DataArrayDouble> ret(self->symmetry3DPlane(centerPtr,vectorPtr));
1183 static PyObject *GiveBaseForPlane(PyObject *normalVector)
1185 const char msg[]="Python wrap of DataArrayDouble::GiveBaseForPlane : ";
1187 DataArrayDouble *a,*a2;
1188 DataArrayDoubleTuple *aa,*aa2;
1189 std::vector<double> bb,bb2;
1191 const double *vectorPtr(convertObjToPossibleCpp5_Safe(normalVector,sw,val,a,aa,bb,msg,1,3,true));
1193 DataArrayDouble::GiveBaseForPlane(vectorPtr,res);
1194 return convertDblArrToPyListOfTuple<double>(res,3,3);
1197 DataArrayDouble *fromCartToCylGiven(const DataArrayDouble *coords, PyObject *center, PyObject *vector) const
1199 const char msg[]="Python wrap of DataArrayDouble::fromCartToCylGiven : ";
1201 DataArrayDouble *a,*a2;
1202 DataArrayDoubleTuple *aa,*aa2;
1203 std::vector<double> bb,bb2;
1205 const double *centerPtr=convertObjToPossibleCpp5_Safe(center,sw,val,a,aa,bb,msg,1,3,true);
1206 const double *vectorPtr=convertObjToPossibleCpp5_Safe(vector,sw,val2,a2,aa2,bb2,msg,1,3,true);
1207 return self->fromCartToCylGiven(coords,centerPtr,vectorPtr);
1210 DataArrayDouble *renumber(PyObject *li)
1213 int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_MEDCoupling__DataArrayInt, 0 | 0 );
1214 if (!SWIG_IsOK(res1))
1217 INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
1218 if(size!=self->getNumberOfTuples())
1220 throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
1222 return self->renumber(tmp);
1226 DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
1228 throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
1229 da2->checkAllocated();
1230 int size=self->getNumberOfTuples();
1231 if(size!=self->getNumberOfTuples())
1233 throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
1235 return self->renumber(da2->getConstPointer());
1239 DataArrayDouble *renumberR(PyObject *li)
1242 int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_MEDCoupling__DataArrayInt, 0 | 0 );
1243 if (!SWIG_IsOK(res1))
1246 INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
1247 if(size!=self->getNumberOfTuples())
1249 throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
1251 return self->renumberR(tmp);
1255 DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
1257 throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
1258 da2->checkAllocated();
1259 int size=self->getNumberOfTuples();
1260 if(size!=self->getNumberOfTuples())
1262 throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
1264 return self->renumberR(da2->getConstPointer());
1268 DataArrayDouble *renumberAndReduce(PyObject *li, int newNbOfTuple)
1271 int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_MEDCoupling__DataArrayInt, 0 | 0 );
1272 if (!SWIG_IsOK(res1))
1275 INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
1276 if(size!=self->getNumberOfTuples())
1278 throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
1280 return self->renumberAndReduce(tmp,newNbOfTuple);
1284 DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
1286 throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
1287 da2->checkAllocated();
1288 int size=self->getNumberOfTuples();
1289 if(size!=self->getNumberOfTuples())
1291 throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
1293 return self->renumberAndReduce(da2->getConstPointer(),newNbOfTuple);
1297 PyObject *minimalDistanceTo(const DataArrayDouble *other) const
1299 int thisTupleId,otherTupleId;
1300 double r0=self->minimalDistanceTo(other,thisTupleId,otherTupleId);
1301 PyObject *ret=PyTuple_New(3);
1302 PyTuple_SetItem(ret,0,PyFloat_FromDouble(r0));
1303 PyTuple_SetItem(ret,1,PyInt_FromLong(thisTupleId));
1304 PyTuple_SetItem(ret,2,PyInt_FromLong(otherTupleId));
1308 PyObject *getMaxValue() const
1311 double r1=self->getMaxValue(tmp);
1312 PyObject *ret=PyTuple_New(2);
1313 PyTuple_SetItem(ret,0,PyFloat_FromDouble(r1));
1314 PyTuple_SetItem(ret,1,PyInt_FromLong(tmp));
1318 PyObject *getMaxAbsValue() const
1321 double r1=self->getMaxAbsValue(tmp);
1322 PyObject *ret=PyTuple_New(2);
1323 PyTuple_SetItem(ret,0,PyFloat_FromDouble(r1));
1324 PyTuple_SetItem(ret,1,PyInt_FromLong(tmp));
1328 PyObject *getMaxValue2() const
1331 double r1=self->getMaxValue2(tmp);
1332 PyObject *ret=PyTuple_New(2);
1333 PyTuple_SetItem(ret,0,PyFloat_FromDouble(r1));
1334 PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(tmp),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ));
1338 PyObject *getMinValue() const
1341 double r1=self->getMinValue(tmp);
1342 PyObject *ret=PyTuple_New(2);
1343 PyTuple_SetItem(ret,0,PyFloat_FromDouble(r1));
1344 PyTuple_SetItem(ret,1,PyInt_FromLong(tmp));
1348 PyObject *getMinValue2() const
1351 double r1=self->getMinValue2(tmp);
1352 PyObject *ret=PyTuple_New(2);
1353 PyTuple_SetItem(ret,0,PyFloat_FromDouble(r1));
1354 PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(tmp),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ));
1358 PyObject *getMinMaxPerComponent() const
1360 int nbOfCompo(self->getNumberOfComponents());
1361 INTERP_KERNEL::AutoPtr<double> tmp(new double[2*nbOfCompo]);
1362 self->getMinMaxPerComponent(tmp);
1363 PyObject *ret=convertDblArrToPyListOfTuple<double>(tmp,2,nbOfCompo);
1367 PyObject *normMaxPerComponent() const
1369 int nbOfCompo(self->getNumberOfComponents());
1370 INTERP_KERNEL::AutoPtr<double> tmp(new double[nbOfCompo]);
1371 self->normMaxPerComponent(tmp);
1372 return convertDblArrToPyList<double>(tmp,nbOfCompo);
1375 PyObject *accumulate() const
1377 int sz=self->getNumberOfComponents();
1378 INTERP_KERNEL::AutoPtr<double> tmp=new double[sz];
1379 self->accumulate(tmp);
1380 return convertDblArrToPyList<double>(tmp,sz);
1383 DataArrayDouble *accumulatePerChunck(PyObject *indexArr) const
1386 std::vector<int> val2;
1387 const int *bg=convertIntStarLikePyObjToCppIntStar(indexArr,sw,sz,val,val2);
1388 return self->accumulatePerChunck(bg,bg+sz);
1391 PyObject *findCommonTuples(double prec, int limitNodeId=-1) const
1393 DataArrayInt *comm, *commIndex;
1394 self->findCommonTuples(prec,limitNodeId,comm,commIndex);
1395 PyObject *res = PyList_New(2);
1396 PyList_SetItem(res,0,SWIG_NewPointerObj(SWIG_as_voidptr(comm),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ));
1397 PyList_SetItem(res,1,SWIG_NewPointerObj(SWIG_as_voidptr(commIndex),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ));
1401 PyObject *distanceToTuple(PyObject *tuple) const
1405 DataArrayDoubleTuple *aa;
1406 std::vector<double> bb;
1408 int tupleId=-1,nbOfCompo=self->getNumberOfComponents();
1409 const double *pt=convertObjToPossibleCpp5_Safe(tuple,sw,val,a,aa,bb,"Python wrap of DataArrayDouble::distanceToTuple",1,nbOfCompo,true);
1411 double ret0=self->distanceToTuple(pt,pt+nbOfCompo,tupleId);
1412 PyObject *ret=PyTuple_New(2);
1413 PyTuple_SetItem(ret,0,PyFloat_FromDouble(ret0));
1414 PyTuple_SetItem(ret,1,PyInt_FromLong(tupleId));
1418 void setSelectedComponents(const DataArrayDouble *a, PyObject *li)
1420 std::vector<int> tmp;
1421 convertPyToNewIntArr3(li,tmp);
1422 self->setSelectedComponents(a,tmp);
1425 PyObject *explodeComponents() const
1427 std::vector< MCAuto<DataArrayDouble> > retCpp(self->explodeComponents());
1428 std::size_t sz(retCpp.size());
1429 PyObject *res(PyList_New(sz));
1430 for(std::size_t i=0;i<sz;i++)
1431 PyList_SetItem(res,i,SWIG_NewPointerObj(SWIG_as_voidptr(retCpp[i].retn()),SWIGTYPE_p_MEDCoupling__DataArrayDouble, SWIG_POINTER_OWN | 0 ));
1435 PyObject *getTuple(int tupleId)
1437 int sz=self->getNumberOfComponents();
1438 INTERP_KERNEL::AutoPtr<double> tmp=new double[sz];
1439 self->getTuple(tupleId,tmp);
1440 return convertDblArrToPyList<double>(tmp,sz);
1443 static DataArrayDouble *Aggregate(PyObject *li)
1445 std::vector<const DataArrayDouble *> tmp;
1446 convertFromPyObjVectorOfObj<const DataArrayDouble *>(li,SWIGTYPE_p_MEDCoupling__DataArrayDouble,"DataArrayDouble",tmp);
1447 return DataArrayDouble::Aggregate(tmp);
1450 static DataArrayDouble *Meld(PyObject *li)
1452 std::vector<const DataArrayDouble *> tmp;
1453 convertFromPyObjVectorOfObj<const DataArrayDouble *>(li,SWIGTYPE_p_MEDCoupling__DataArrayDouble,"DataArrayDouble",tmp);
1454 return DataArrayDouble::Meld(tmp);
1457 PyObject *computeTupleIdsNearTuples(PyObject *pt, double eps) const
1461 DataArrayDoubleTuple *aa;
1462 std::vector<double> bb;
1464 int nbComp=self->getNumberOfComponents(),nbTuples=-1;
1465 const char msg[]="Python wrap of DataArrayDouble::computeTupleIdsNearTuples : ";
1466 const double *pos=convertObjToPossibleCpp5_Safe2(pt,sw,val,a,aa,bb,msg,nbComp,true,nbTuples);
1467 MCAuto<DataArrayDouble> inpu=DataArrayDouble::New(); inpu->useArray(pos,false,DeallocType::CPP_DEALLOC,nbTuples,nbComp);
1468 DataArrayInt *c=0,*cI=0;
1469 self->computeTupleIdsNearTuples(inpu,eps,c,cI);
1470 PyObject *ret=PyTuple_New(2);
1471 PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(c),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ));
1472 PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(cI),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ));
1476 PyObject *areIncludedInMe(const DataArrayDouble *other, double prec) const
1478 DataArrayInt *ret1=0;
1479 bool ret0=self->areIncludedInMe(other,prec,ret1);
1480 PyObject *ret=PyTuple_New(2);
1481 PyObject *ret0Py=ret0?Py_True:Py_False;
1483 PyTuple_SetItem(ret,0,ret0Py);
1484 PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ));
1488 PyObject *__getitem__(PyObject *obj)
1490 return DataArrayT__getitem<double>(self,obj);
1493 DataArrayDouble *__setitem__(PyObject *obj, PyObject *value)
1495 return DataArrayT__setitem__<double>(self,obj,value);
1498 DataArrayDouble *__neg__() const
1500 return self->negate();
1503 PyObject *__add__(PyObject *obj)
1505 const char msg[]="Unexpected situation in DataArrayDouble.__add__ !";
1508 DataArrayDoubleTuple *aa;
1509 std::vector<double> bb;
1512 #ifndef WITHOUT_AUTOFIELD
1514 if(SWIG_IsOK(SWIG_ConvertPtr(obj,&argp,SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDouble,0|0)))
1516 MEDCouplingFieldDouble *other=reinterpret_cast< MEDCoupling::MEDCouplingFieldDouble * >(argp);
1519 PyObject *tmp=SWIG_NewPointerObj(SWIG_as_voidptr(self),SWIGTYPE_p_MEDCoupling__DataArrayDouble, 0 | 0 );
1520 MCAuto<MEDCouplingFieldDouble> ret=MEDCoupling_MEDCouplingFieldDouble___radd__Impl(other,tmp);
1522 return SWIG_NewPointerObj(SWIG_as_voidptr(ret.retn()),SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDouble, SWIG_POINTER_OWN | 0 );
1525 throw INTERP_KERNEL::Exception(msg);
1529 convertDoubleStarLikePyObjToCpp_2(obj,sw,val,a,aa,bb);
1534 MCAuto<DataArrayDouble> ret=self->deepCopy();
1535 ret->applyLin(1.,val);
1536 return SWIG_NewPointerObj(SWIG_as_voidptr(ret.retn()),SWIGTYPE_p_MEDCoupling__DataArrayDouble, SWIG_POINTER_OWN | 0 );
1540 return SWIG_NewPointerObj(SWIG_as_voidptr(DataArrayDouble::Add(self,a)),SWIGTYPE_p_MEDCoupling__DataArrayDouble, SWIG_POINTER_OWN | 0 );
1544 MCAuto<DataArrayDouble> aaa=aa->buildDADouble(1,self->getNumberOfComponents());
1545 return SWIG_NewPointerObj(SWIG_as_voidptr(DataArrayDouble::Add(self,aaa)),SWIGTYPE_p_MEDCoupling__DataArrayDouble, SWIG_POINTER_OWN | 0 );
1549 MCAuto<DataArrayDouble> aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,DeallocType::CPP_DEALLOC,1,(int)bb.size());
1550 return SWIG_NewPointerObj(SWIG_as_voidptr(DataArrayDouble::Add(self,aaa)),SWIGTYPE_p_MEDCoupling__DataArrayDouble, SWIG_POINTER_OWN | 0 );
1553 throw INTERP_KERNEL::Exception(msg);
1557 DataArrayDouble *__radd__(PyObject *obj)
1559 const char msg[]="Unexpected situation in __radd__ !";
1562 DataArrayDoubleTuple *aa;
1563 std::vector<double> bb;
1565 convertDoubleStarLikePyObjToCpp_2(obj,sw,val,a,aa,bb);
1570 MCAuto<DataArrayDouble> ret=self->deepCopy();
1571 ret->applyLin(1.,val);
1576 MCAuto<DataArrayDouble> aaa=aa->buildDADouble(1,self->getNumberOfComponents());
1577 return DataArrayDouble::Add(self,aaa);
1581 MCAuto<DataArrayDouble> aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,DeallocType::CPP_DEALLOC,1,(int)bb.size());
1582 return DataArrayDouble::Add(self,aaa);
1585 throw INTERP_KERNEL::Exception(msg);
1589 PyObject *___iadd___(PyObject *trueSelf, PyObject *obj)
1591 return DataArrayT_iadd<double>(trueSelf,obj,self);
1594 PyObject *__sub__(PyObject *obj)
1596 const char msg[]="Unexpected situation in __sub__ !";
1599 DataArrayDoubleTuple *aa;
1600 std::vector<double> bb;
1603 #ifndef WITHOUT_AUTOFIELD
1605 if(SWIG_IsOK(SWIG_ConvertPtr(obj,&argp,SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDouble,0|0)))
1607 MEDCouplingFieldDouble *other=reinterpret_cast< MEDCoupling::MEDCouplingFieldDouble * >(argp);
1610 PyObject *tmp=SWIG_NewPointerObj(SWIG_as_voidptr(self),SWIGTYPE_p_MEDCoupling__DataArrayDouble, 0 | 0 );
1611 MCAuto<MEDCouplingFieldDouble> ret=MEDCoupling_MEDCouplingFieldDouble___rsub__Impl(other,tmp);
1613 return SWIG_NewPointerObj(SWIG_as_voidptr(ret.retn()),SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDouble, SWIG_POINTER_OWN | 0 );
1616 throw INTERP_KERNEL::Exception(msg);
1620 convertDoubleStarLikePyObjToCpp_2(obj,sw,val,a,aa,bb);
1625 MCAuto<DataArrayDouble> ret=self->deepCopy();
1626 ret->applyLin(1.,-val);
1627 return SWIG_NewPointerObj(SWIG_as_voidptr(ret.retn()),SWIGTYPE_p_MEDCoupling__DataArrayDouble, SWIG_POINTER_OWN | 0 );
1631 return SWIG_NewPointerObj(SWIG_as_voidptr(DataArrayDouble::Substract(self,a)),SWIGTYPE_p_MEDCoupling__DataArrayDouble, SWIG_POINTER_OWN | 0 );
1635 MCAuto<DataArrayDouble> aaa=aa->buildDADouble(1,self->getNumberOfComponents());
1636 return SWIG_NewPointerObj(SWIG_as_voidptr(DataArrayDouble::Substract(self,aaa)),SWIGTYPE_p_MEDCoupling__DataArrayDouble, SWIG_POINTER_OWN | 0 );
1640 MCAuto<DataArrayDouble> aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,DeallocType::CPP_DEALLOC,1,(int)bb.size());
1641 return SWIG_NewPointerObj(SWIG_as_voidptr(DataArrayDouble::Substract(self,aaa)),SWIGTYPE_p_MEDCoupling__DataArrayDouble, SWIG_POINTER_OWN | 0 );
1644 throw INTERP_KERNEL::Exception(msg);
1648 DataArrayDouble *__rsub__(PyObject *obj)
1650 const char msg[]="Unexpected situation in __rsub__ !";
1653 DataArrayDoubleTuple *aa;
1654 std::vector<double> bb;
1656 convertDoubleStarLikePyObjToCpp_2(obj,sw,val,a,aa,bb);
1661 MCAuto<DataArrayDouble> ret=self->deepCopy();
1662 ret->applyLin(-1.,val);
1667 MCAuto<DataArrayDouble> aaa=aa->buildDADouble(1,self->getNumberOfComponents());
1668 return DataArrayDouble::Substract(aaa,self);
1672 MCAuto<DataArrayDouble> aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,DeallocType::CPP_DEALLOC,1,(int)bb.size());
1673 return DataArrayDouble::Substract(aaa,self);
1676 throw INTERP_KERNEL::Exception(msg);
1680 PyObject *___isub___(PyObject *trueSelf, PyObject *obj)
1682 return DataArrayT_isub<double>(trueSelf,obj,self);
1685 PyObject *__mul__(PyObject *obj)
1687 const char msg[]="Unexpected situation in __mul__ !";
1690 DataArrayDoubleTuple *aa;
1691 std::vector<double> bb;
1694 #ifndef WITHOUT_AUTOFIELD
1696 if(SWIG_IsOK(SWIG_ConvertPtr(obj,&argp,SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDouble,0|0)))
1698 MEDCouplingFieldDouble *other=reinterpret_cast< MEDCoupling::MEDCouplingFieldDouble * >(argp);
1701 PyObject *tmp=SWIG_NewPointerObj(SWIG_as_voidptr(self),SWIGTYPE_p_MEDCoupling__DataArrayDouble, 0 | 0 );
1702 MCAuto<MEDCouplingFieldDouble> ret=MEDCoupling_MEDCouplingFieldDouble___rmul__Impl(other,tmp);
1704 return SWIG_NewPointerObj(SWIG_as_voidptr(ret.retn()),SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDouble, SWIG_POINTER_OWN | 0 );
1707 throw INTERP_KERNEL::Exception(msg);
1711 convertDoubleStarLikePyObjToCpp_2(obj,sw,val,a,aa,bb);
1716 MCAuto<DataArrayDouble> ret=self->deepCopy();
1717 ret->applyLin(val,0.);
1718 return SWIG_NewPointerObj(SWIG_as_voidptr(ret.retn()),SWIGTYPE_p_MEDCoupling__DataArrayDouble, SWIG_POINTER_OWN | 0 );
1722 return SWIG_NewPointerObj(SWIG_as_voidptr(DataArrayDouble::Multiply(self,a)),SWIGTYPE_p_MEDCoupling__DataArrayDouble, SWIG_POINTER_OWN | 0 );
1726 MCAuto<DataArrayDouble> aaa=aa->buildDADouble(1,self->getNumberOfComponents());
1727 return SWIG_NewPointerObj(SWIG_as_voidptr(DataArrayDouble::Multiply(self,aaa)),SWIGTYPE_p_MEDCoupling__DataArrayDouble, SWIG_POINTER_OWN | 0 );
1731 MCAuto<DataArrayDouble> aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,DeallocType::CPP_DEALLOC,1,(int)bb.size());
1732 return SWIG_NewPointerObj(SWIG_as_voidptr(DataArrayDouble::Multiply(self,aaa)),SWIGTYPE_p_MEDCoupling__DataArrayDouble, SWIG_POINTER_OWN | 0 );
1735 throw INTERP_KERNEL::Exception(msg);
1739 DataArrayDouble *__rmul__(PyObject *obj)
1741 return DataArrayFPT_rmul<double>(self,obj);
1744 PyObject *___imul___(PyObject *trueSelf, PyObject *obj)
1746 return DataArrayT_imul<double>(trueSelf,obj,self);
1749 PyObject *__div__(PyObject *obj)
1751 const char msg[]="Unexpected situation in __div__ !";
1754 DataArrayDoubleTuple *aa;
1755 std::vector<double> bb;
1758 #ifndef WITHOUT_AUTOFIELD
1760 if(SWIG_IsOK(SWIG_ConvertPtr(obj,&argp,SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDouble,0|0)))
1762 MEDCouplingFieldDouble *other=reinterpret_cast< MEDCoupling::MEDCouplingFieldDouble * >(argp);
1765 PyObject *tmp=SWIG_NewPointerObj(SWIG_as_voidptr(self),SWIGTYPE_p_MEDCoupling__DataArrayDouble, 0 | 0 );
1766 MCAuto<MEDCouplingFieldDouble> ret=MEDCoupling_MEDCouplingFieldDouble___rdiv__Impl(other,tmp);
1768 return SWIG_NewPointerObj(SWIG_as_voidptr(ret.retn()),SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDouble, SWIG_POINTER_OWN | 0 );
1771 throw INTERP_KERNEL::Exception(msg);
1775 convertDoubleStarLikePyObjToCpp_2(obj,sw,val,a,aa,bb);
1781 throw INTERP_KERNEL::Exception("DataArrayDouble::__div__ : trying to divide by zero !");
1782 MCAuto<DataArrayDouble> ret=self->deepCopy();
1783 ret->applyLin(1/val,0.);
1784 return SWIG_NewPointerObj(SWIG_as_voidptr(ret.retn()),SWIGTYPE_p_MEDCoupling__DataArrayDouble, SWIG_POINTER_OWN | 0 );
1788 return SWIG_NewPointerObj(SWIG_as_voidptr(DataArrayDouble::Divide(self,a)),SWIGTYPE_p_MEDCoupling__DataArrayDouble, SWIG_POINTER_OWN | 0 );
1792 MCAuto<DataArrayDouble> aaa=aa->buildDADouble(1,self->getNumberOfComponents());
1793 return SWIG_NewPointerObj(SWIG_as_voidptr(DataArrayDouble::Divide(self,aaa)),SWIGTYPE_p_MEDCoupling__DataArrayDouble, SWIG_POINTER_OWN | 0 );
1797 MCAuto<DataArrayDouble> aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,DeallocType::CPP_DEALLOC,1,(int)bb.size());
1798 return SWIG_NewPointerObj(SWIG_as_voidptr(DataArrayDouble::Divide(self,aaa)),SWIGTYPE_p_MEDCoupling__DataArrayDouble, SWIG_POINTER_OWN | 0 );
1801 throw INTERP_KERNEL::Exception(msg);
1805 DataArrayDouble *__rdiv__(PyObject *obj)
1807 const char msg[]="Unexpected situation in __rdiv__ !";
1810 DataArrayDoubleTuple *aa;
1811 std::vector<double> bb;
1813 convertDoubleStarLikePyObjToCpp_2(obj,sw,val,a,aa,bb);
1818 MCAuto<DataArrayDouble> ret=self->deepCopy();
1824 MCAuto<DataArrayDouble> aaa=aa->buildDADouble(1,self->getNumberOfComponents());
1825 return DataArrayDouble::Divide(aaa,self);
1829 MCAuto<DataArrayDouble> aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,DeallocType::CPP_DEALLOC,1,(int)bb.size());
1830 return DataArrayDouble::Divide(aaa,self);
1833 throw INTERP_KERNEL::Exception(msg);
1837 PyObject *___idiv___(PyObject *trueSelf, PyObject *obj)
1839 return DataArrayT_idiv<double>(trueSelf,obj,self);
1842 DataArrayDouble *__pow__(PyObject *obj)
1844 const char msg[]="Unexpected situation in __pow__ !";
1847 DataArrayDoubleTuple *aa;
1848 std::vector<double> bb;
1850 convertDoubleStarLikePyObjToCpp_2(obj,sw,val,a,aa,bb);
1855 MCAuto<DataArrayDouble> ret=self->deepCopy();
1861 return DataArrayDouble::Pow(self,a);
1865 MCAuto<DataArrayDouble> aaa=aa->buildDADouble(1,self->getNumberOfComponents());
1866 return DataArrayDouble::Pow(self,aaa);
1870 MCAuto<DataArrayDouble> aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,DeallocType::CPP_DEALLOC,1,(int)bb.size());
1871 return DataArrayDouble::Pow(self,aaa);
1874 throw INTERP_KERNEL::Exception(msg);
1878 DataArrayDouble *__rpow__(PyObject *obj)
1880 const char msg[]="Unexpected situation in __rpow__ !";
1883 DataArrayDoubleTuple *aa;
1884 std::vector<double> bb;
1886 convertDoubleStarLikePyObjToCpp_2(obj,sw,val,a,aa,bb);
1891 MCAuto<DataArrayDouble> ret=self->deepCopy();
1892 ret->applyRPow(val);
1897 MCAuto<DataArrayDouble> aaa=aa->buildDADouble(1,self->getNumberOfComponents());
1898 return DataArrayDouble::Pow(aaa,self);
1902 MCAuto<DataArrayDouble> aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,DeallocType::CPP_DEALLOC,1,(int)bb.size());
1903 return DataArrayDouble::Pow(aaa,self);
1906 throw INTERP_KERNEL::Exception(msg);
1910 PyObject *___ipow___(PyObject *trueSelf, PyObject *obj)
1912 const char msg[]="Unexpected situation in __ipow__ !";
1915 DataArrayDoubleTuple *aa;
1916 std::vector<double> bb;
1918 convertDoubleStarLikePyObjToCpp_2(obj,sw,val,a,aa,bb);
1923 self->applyPow(val);
1924 Py_XINCREF(trueSelf);
1930 Py_XINCREF(trueSelf);
1935 MCAuto<DataArrayDouble> aaa=aa->buildDADouble(1,self->getNumberOfComponents());
1936 self->powEqual(aaa);
1937 Py_XINCREF(trueSelf);
1942 MCAuto<DataArrayDouble> aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,DeallocType::CPP_DEALLOC,1,(int)bb.size());
1943 self->powEqual(aaa);
1944 Py_XINCREF(trueSelf);
1948 throw INTERP_KERNEL::Exception(msg);
1952 PyObject *computeTupleIdsNearTuples(const DataArrayDouble *other, double eps)
1954 DataArrayInt *c=0,*cI=0;
1956 self->computeTupleIdsNearTuples(other,eps,c,cI);
1957 PyObject *ret=PyTuple_New(2);
1958 PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(c),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ));
1959 PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(cI),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ));
1963 PyObject *maxPerTupleWithCompoId() const
1965 DataArrayInt *ret1=0;
1966 DataArrayDouble *ret0=self->maxPerTupleWithCompoId(ret1);
1967 PyObject *ret=PyTuple_New(2);
1968 PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_MEDCoupling__DataArrayDouble, SWIG_POINTER_OWN | 0 ));
1969 PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ));
1975 class DataArrayDoubleTuple;
1977 class DataArrayDoubleIterator
1980 DataArrayDoubleIterator(DataArrayDouble *da);
1981 ~DataArrayDoubleIterator();
1986 DataArrayDoubleTuple *ret=self->nextt();
1988 return SWIG_NewPointerObj(SWIG_as_voidptr(ret),SWIGTYPE_p_MEDCoupling__DataArrayDoubleTuple,SWIG_POINTER_OWN|0);
1991 PyErr_SetString(PyExc_StopIteration,"No more data.");
1998 class DataArrayDoubleTuple
2001 int getNumberOfCompo() const;
2002 DataArrayDouble *buildDADouble(int nbOfTuples, int nbOfCompo) const;
2005 std::string __str__() const
2007 return self->repr();
2010 double __float__() const
2012 return self->doubleValue();
2015 DataArrayDouble *buildDADouble()
2017 return self->buildDADouble(1,self->getNumberOfCompo());
2020 PyObject *___iadd___(PyObject *trueSelf, PyObject *obj)
2022 MCAuto<DataArrayDouble> ret=self->buildDADouble(1,self->getNumberOfCompo());
2023 MEDCoupling_DataArrayDouble____iadd___(ret,0,obj);
2024 Py_XINCREF(trueSelf);
2028 PyObject *___isub___(PyObject *trueSelf, PyObject *obj)
2030 MCAuto<DataArrayDouble> ret=self->buildDADouble(1,self->getNumberOfCompo());
2031 MEDCoupling_DataArrayDouble____isub___(ret,0,obj);
2032 Py_XINCREF(trueSelf);
2036 PyObject *___imul___(PyObject *trueSelf, PyObject *obj)
2038 MCAuto<DataArrayDouble> ret=self->buildDADouble(1,self->getNumberOfCompo());
2039 MEDCoupling_DataArrayDouble____imul___(ret,0,obj);
2040 Py_XINCREF(trueSelf);
2044 PyObject *___idiv___(PyObject *trueSelf, PyObject *obj)
2046 MCAuto<DataArrayDouble> ret=self->buildDADouble(1,self->getNumberOfCompo());
2047 MEDCoupling_DataArrayDouble____idiv___(ret,0,obj);
2048 Py_XINCREF(trueSelf);
2054 return PyInt_FromLong(self->getNumberOfCompo());
2057 PyObject *__getitem__(PyObject *obj)
2059 const char msg2[]="DataArrayDoubleTuple::__getitem__ : Mismatch of slice values in 2nd parameter (components) !";
2062 std::vector<int> multiVal;
2063 std::pair<int, std::pair<int,int> > slic;
2064 MEDCoupling::DataArrayInt *daIntTyypp=0;
2065 const double *pt=self->getConstPointer();
2066 int nbc=self->getNumberOfCompo();
2067 convertIntStarOrSliceLikePyObjToCppWithNegIntInterp(obj,nbc,sw,singleVal,multiVal,slic,daIntTyypp);
2074 std::ostringstream oss;
2075 oss << "Requesting for id " << singleVal << " having only " << nbc << " components !";
2076 PyErr_SetString(PyExc_StopIteration,oss.str().c_str());
2080 return PyFloat_FromDouble(pt[singleVal]);
2084 return PyFloat_FromDouble(pt[nbc+singleVal]);
2087 std::ostringstream oss;
2088 oss << "Requesting for id " << singleVal << " having only " << nbc << " components !";
2089 throw INTERP_KERNEL::Exception(oss.str().c_str());
2095 PyObject *t=PyTuple_New(multiVal.size());
2096 for(int j=0;j<(int)multiVal.size();j++)
2098 int cid=multiVal[j];
2101 std::ostringstream oss;
2102 oss << "Requesting for id #" << cid << " having only " << nbc << " components !";
2103 throw INTERP_KERNEL::Exception(oss.str().c_str());
2105 PyTuple_SetItem(t,j,PyFloat_FromDouble(pt[cid]));
2111 int sz=DataArray::GetNumberOfItemGivenBES(slic.first,slic.second.first,slic.second.second,msg2);
2112 PyObject *t=PyTuple_New(sz);
2113 for(int j=0;j<sz;j++)
2114 PyTuple_SetItem(t,j,PyFloat_FromDouble(pt[slic.first+j*slic.second.second]));
2118 throw INTERP_KERNEL::Exception("DataArrayDoubleTuple::__getitem__ : unrecognized type entered !");
2122 DataArrayDoubleTuple *__setitem__(PyObject *obj, PyObject *value)
2124 const char msg[]="DataArrayDoubleTuple::__setitem__ : unrecognized type entered, int, slice, list<int>, tuple<int> !";
2125 const char msg2[]="DataArrayDoubleTuple::__setitem__ : Mismatch of slice values in 2nd parameter (components) !";
2128 std::vector<double> multiValV;
2129 MEDCoupling::DataArrayDoubleTuple *daIntTyyppV=0;
2130 int nbc=self->getNumberOfCompo();
2131 convertDoubleStarLikePyObjToCpp(value,sw1,singleValV,multiValV,daIntTyyppV);
2133 std::vector<int> multiVal;
2134 std::pair<int, std::pair<int,int> > slic;
2135 MEDCoupling::DataArrayInt *daIntTyypp=0;
2136 double *pt=self->getPointer();
2137 convertIntStarOrSliceLikePyObjToCppWithNegIntInterp(obj,nbc,sw2,singleVal,multiVal,slic,daIntTyypp);
2144 std::ostringstream oss;
2145 oss << "Requesting for setting id # " << singleVal << " having only " << nbc << " components !";
2146 throw INTERP_KERNEL::Exception(oss.str().c_str());
2152 pt[singleVal]=singleValV;
2157 if(multiValV.size()!=1)
2159 std::ostringstream oss;
2160 oss << "Requesting for setting id # " << singleVal << " with a list or tuple with size != 1 ! ";
2161 throw INTERP_KERNEL::Exception(oss.str().c_str());
2163 pt[singleVal]=multiValV[0];
2168 pt[singleVal]=daIntTyyppV->getConstPointer()[0];
2172 throw INTERP_KERNEL::Exception(msg);
2181 for(std::vector<int>::const_iterator it=multiVal.begin();it!=multiVal.end();it++)
2185 std::ostringstream oss;
2186 oss << "Requesting for setting id # " << *it << " having only " << nbc << " components !";
2187 throw INTERP_KERNEL::Exception(oss.str().c_str());
2195 if(multiVal.size()!=multiValV.size())
2197 std::ostringstream oss;
2198 oss << "Mismatch length of during assignment : " << multiValV.size() << " != " << multiVal.size() << " !";
2199 throw INTERP_KERNEL::Exception(oss.str().c_str());
2201 for(int i=0;i<(int)multiVal.size();i++)
2203 int pos=multiVal[i];
2206 std::ostringstream oss;
2207 oss << "Requesting for setting id # " << pos << " having only " << nbc << " components !";
2208 throw INTERP_KERNEL::Exception(oss.str().c_str());
2210 pt[multiVal[i]]=multiValV[i];
2216 const double *ptV=daIntTyyppV->getConstPointer();
2217 if(nbc>daIntTyyppV->getNumberOfCompo())
2219 std::ostringstream oss;
2220 oss << "Mismatch length of during assignment : " << nbc << " != " << daIntTyyppV->getNumberOfCompo() << " !";
2221 throw INTERP_KERNEL::Exception(oss.str().c_str());
2223 std::copy(ptV,ptV+nbc,pt);
2227 throw INTERP_KERNEL::Exception(msg);
2232 int sz=DataArray::GetNumberOfItemGivenBES(slic.first,slic.second.first,slic.second.second,msg2);
2237 for(int j=0;j<sz;j++)
2238 pt[slic.first+j*slic.second.second]=singleValV;
2243 if(sz!=(int)multiValV.size())
2245 std::ostringstream oss;
2246 oss << "Mismatch length of during assignment : " << multiValV.size() << " != " << sz << " !";
2247 throw INTERP_KERNEL::Exception(oss.str().c_str());
2249 for(int j=0;j<sz;j++)
2250 pt[slic.first+j*slic.second.second]=multiValV[j];
2255 const double *ptV=daIntTyyppV->getConstPointer();
2256 if(sz>daIntTyyppV->getNumberOfCompo())
2258 std::ostringstream oss;
2259 oss << "Mismatch length of during assignment : " << nbc << " != " << daIntTyyppV->getNumberOfCompo() << " !";
2260 throw INTERP_KERNEL::Exception(oss.str().c_str());
2262 for(int j=0;j<sz;j++)
2263 pt[slic.first+j*slic.second.second]=ptV[j];
2267 throw INTERP_KERNEL::Exception(msg);
2271 throw INTERP_KERNEL::Exception(msg);
2277 class DataArrayIntIterator;
2279 class DataArrayInt : public DataArray
2282 static DataArrayInt *New();
2283 int intValue() const;
2284 int getHashCode() const;
2286 void aggregate(const DataArrayInt *other);
2287 DataArrayInt *performCopyOrIncrRef(bool deepCopy) const;
2288 void deepCopyFrom(const DataArrayInt& other);
2289 void reserve(std::size_t nbOfElems);
2290 void pushBackSilent(int val);
2291 int popBackSilent();
2293 void allocIfNecessary(int nbOfTuple, int nbOfCompo);
2294 bool isEqual(const DataArrayInt& other) const;
2295 bool isEqualWithoutConsideringStr(const DataArrayInt& other) const;
2296 bool isEqualWithoutConsideringStrAndOrder(const DataArrayInt& other) const;
2297 DataArrayInt *buildPermutationArr(const DataArrayInt& other) const;
2298 DataArrayInt *sumPerTuple() const;
2299 void sort(bool asc=true);
2301 void checkMonotonic(bool increasing) const;
2302 bool isMonotonic(bool increasing) const;
2303 void checkStrictlyMonotonic(bool increasing) const;
2304 bool isStrictlyMonotonic(bool increasing) const;
2305 void fillWithZero();
2306 void fillWithValue(int val);
2307 void iota(int init=0);
2308 std::string repr() const;
2309 std::string reprZip() const;
2310 std::string reprNotTooLong() const;
2311 DataArrayInt *invertArrayO2N2N2O(int newNbOfElem) const;
2312 DataArrayInt *invertArrayN2O2O2N(int oldNbOfElem) const;
2313 DataArrayInt *invertArrayO2N2N2OBis(int newNbOfElem) const;
2314 MCAuto< MapII > invertArrayN2O2O2NOptimized() const;
2315 MCAuto< MapII > giveN2OOptimized() const;
2316 DataArrayInt *indicesOfSubPart(const DataArrayInt& partOfThis) const;
2317 DataArrayInt *fromNoInterlace() const;
2318 DataArrayInt *toNoInterlace() const;
2319 DataArrayInt *selectByTupleIdSafeSlice(int bg, int end, int step) const;
2320 DataArrayInt *checkAndPreparePermutation() const;
2321 DataArrayInt *buildPermArrPerLevel() const;
2322 bool isIota(int sizeExpected) const;
2323 bool isUniform(int val) const;
2324 int checkUniformAndGuess() const;
2325 bool hasUniqueValues() const;
2326 DataArrayInt *subArray(int tupleIdBg, int tupleIdEnd=-1) const;
2328 DataArrayInt *changeNbOfComponents(int newNbOfComp, int dftValue) const;
2329 void meldWith(const DataArrayInt *other);
2330 void setPartOfValues1(const DataArrayInt *a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare=true);
2331 void setPartOfValuesSimple1(int a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp);
2332 void setPartOfValuesAdv(const DataArrayInt *a, const DataArrayInt *tuplesSelec);
2333 void getTuple(int tupleId, int *res) const;
2334 int getIJ(int tupleId, int compoId) const;
2335 int getIJSafe(int tupleId, int compoId) const;
2338 void setIJ(int tupleId, int compoId, int newVal);
2339 void setIJSilent(int tupleId, int compoId, int newVal);
2341 const int *getConstPointer() const;
2342 DataArrayIntIterator *iterator();
2343 const int *begin() const;
2344 const int *end() const;
2345 DataArrayInt *findIdsEqual(int val) const;
2346 DataArrayInt *findIdsNotEqual(int val) const;
2347 int changeValue(int oldValue, int newValue);
2348 int findIdFirstEqualTuple(const std::vector<int>& tupl) const;
2349 int findIdFirstEqual(int value) const;
2350 int findIdFirstEqual(const std::vector<int>& vals) const;
2351 int findIdSequence(const std::vector<int>& vals) const;
2352 bool presenceOfTuple(const std::vector<int>& tupl) const;
2353 bool presenceOfValue(int value) const;
2354 bool presenceOfValue(const std::vector<int>& vals) const;
2355 int count(int value) const;
2356 int accumulate(int compId) const;
2357 int getMaxValueInArray() const;
2358 int getMaxAbsValueInArray() const;
2359 int getMinValueInArray() const;
2361 DataArrayInt *computeAbs() const;
2362 void applyLin(int a, int b, int compoId);
2363 void applyLin(int a, int b);
2364 void applyInv(int numerator);
2365 DataArrayInt *negate() const;
2366 void applyDivideBy(int val);
2367 void applyModulus(int val);
2368 void applyRModulus(int val);
2369 void applyPow(int val);
2370 void applyRPow(int val);
2371 DataArrayInt *findIdsInRange(int vmin, int vmax) const;
2372 DataArrayInt *findIdsNotInRange(int vmin, int vmax) const;
2373 DataArrayInt *findIdsStrictlyNegative() const;
2374 bool checkAllIdsInRange(int vmin, int vmax) const;
2375 static DataArrayInt *Aggregate(const DataArrayInt *a1, const DataArrayInt *a2, int offsetA2);
2376 static DataArrayInt *Meld(const DataArrayInt *a1, const DataArrayInt *a2);
2377 static DataArrayInt *MakePartition(const std::vector<const DataArrayInt *>& groups, int newNb, std::vector< std::vector<int> >& fidsOfGroups);
2378 static DataArrayInt *BuildUnion(const std::vector<const DataArrayInt *>& arr);
2379 static DataArrayInt *BuildIntersection(const std::vector<const DataArrayInt *>& arr);
2380 static DataArrayInt *FindPermutationFromFirstToSecond(const DataArrayInt *ids1, const DataArrayInt *ids2);
2381 DataArrayInt *buildComplement(int nbOfElement) const;
2382 DataArrayInt *buildSubstraction(const DataArrayInt *other) const;
2383 DataArrayInt *buildSubstractionOptimized(const DataArrayInt *other) const;
2384 DataArrayInt *buildUnion(const DataArrayInt *other) const;
2385 DataArrayInt *buildIntersection(const DataArrayInt *other) const;
2386 DataArrayInt *buildUnique() const;
2387 DataArrayInt *buildUniqueNotSorted() const;
2388 DataArrayInt *deltaShiftIndex() const;
2389 void computeOffsets();
2390 void computeOffsetsFull();
2391 DataArrayInt *buildExplicitArrByRanges(const DataArrayInt *offsets) const;
2392 DataArrayInt *findRangeIdForEachTuple(const DataArrayInt *ranges) const;
2393 DataArrayInt *findIdInRangeForEachTuple(const DataArrayInt *ranges) const;
2394 void sortEachPairToMakeALinkedList();
2395 DataArrayInt *duplicateEachTupleNTimes(int nbTimes) const;
2396 DataArrayInt *getDifferentValues() const;
2397 static DataArrayInt *Add(const DataArrayInt *a1, const DataArrayInt *a2);
2398 void addEqual(const DataArrayInt *other);
2399 static DataArrayInt *Substract(const DataArrayInt *a1, const DataArrayInt *a2);
2400 void substractEqual(const DataArrayInt *other);
2401 static DataArrayInt *Multiply(const DataArrayInt *a1, const DataArrayInt *a2);
2402 void multiplyEqual(const DataArrayInt *other);
2403 static DataArrayInt *Divide(const DataArrayInt *a1, const DataArrayInt *a2);
2404 void divideEqual(const DataArrayInt *other);
2405 static DataArrayInt *Modulus(const DataArrayInt *a1, const DataArrayInt *a2);
2406 void modulusEqual(const DataArrayInt *other);
2407 static DataArrayInt *Pow(const DataArrayInt *a1, const DataArrayInt *a2);
2408 void powEqual(const DataArrayInt *other);
2409 MCAuto<DataArrayInt> fromLinkedListOfPairToList() const;
2410 MCAuto<DataArrayInt> findIdsGreaterOrEqualTo(int val) const;
2411 MCAuto<DataArrayInt> findIdsGreaterThan(int val) const;
2412 MCAuto<DataArrayInt> findIdsLowerOrEqualTo(int val) const;
2413 MCAuto<DataArrayInt> findIdsLowerThan(int val) const;
2414 MCAuto<DataArrayInt> selectPartDef(const PartDefinition* pd) const;
2415 MCAuto<DataArrayDouble> convertToDblArr() const;
2416 MCAuto<DataArrayFloat> convertToFloatArr() const;
2418 static DataArrayInt *Range(int begin, int end, int step);
2423 return DataArrayInt::New();
2426 static DataArrayInt *New(PyObject *elt0, PyObject *nbOfTuples=0, PyObject *nbOfComp=0)
2428 const char *msgBase="MEDCoupling::DataArrayInt::New : Available API are : \n-DataArrayInt.New()\n-DataArrayInt.New([1,3,4])\n-DataArrayInt.New([1,3,4],3)\n-DataArrayInt.New([1,3,4,5],2,2)\n-DataArrayInt.New([1,3,4,5,7,8],3,2)\n-DataArrayInt.New([(1,3),(4,5),(7,8)])\n-DataArrayInt.New(5)\n-DataArrayInt.New(5,2)";
2429 std::string msg(msgBase);
2431 msg+="\n-DataArrayInt.New(numpy array with dtype=int32)";
2434 if(PyList_Check(elt0) || PyTuple_Check(elt0))
2438 if(PyInt_Check(nbOfTuples))
2440 int nbOfTuples1=PyInt_AS_LONG(nbOfTuples);
2442 throw INTERP_KERNEL::Exception("DataArrayInt::New : should be a positive set of allocated memory !");
2445 if(PyInt_Check(nbOfComp))
2446 {//DataArrayInt.New([1,3,4,5],2,2)
2447 int nbOfCompo=PyInt_AS_LONG(nbOfComp);
2449 throw INTERP_KERNEL::Exception("DataArrayInt::New : should be a positive number of components !");
2450 MCAuto<DataArrayInt> ret=DataArrayInt::New();
2451 std::vector<int> tmp=fillArrayWithPyListInt2(elt0,nbOfTuples1,nbOfCompo);
2452 ret->alloc(nbOfTuples1,nbOfCompo); std::copy(tmp.begin(),tmp.end(),ret->getPointer());
2456 throw INTERP_KERNEL::Exception(msg.c_str());
2459 {//DataArrayInt.New([1,3,4],3)
2460 MCAuto<DataArrayInt> ret=DataArrayInt::New();
2462 std::vector<int> tmp=fillArrayWithPyListInt2(elt0,nbOfTuples1,tmpp1);
2463 ret->alloc(nbOfTuples1,tmpp1); std::copy(tmp.begin(),tmp.end(),ret->getPointer());
2468 throw INTERP_KERNEL::Exception(msg.c_str());
2471 {// DataArrayInt.New([1,3,4])
2472 MCAuto<DataArrayInt> ret=DataArrayInt::New();
2473 int tmpp1=-1,tmpp2=-1;
2474 std::vector<int> tmp=fillArrayWithPyListInt2(elt0,tmpp1,tmpp2);
2475 ret->alloc(tmpp1,tmpp2); std::copy(tmp.begin(),tmp.end(),ret->getPointer());
2479 else if(PyInt_Check(elt0))
2481 int nbOfTuples1=PyInt_AS_LONG(elt0);
2483 throw INTERP_KERNEL::Exception("DataArrayInt::New : should be a positive set of allocated memory !");
2488 if(PyInt_Check(nbOfTuples))
2489 {//DataArrayInt.New(5,2)
2490 int nbOfCompo=PyInt_AS_LONG(nbOfTuples);
2492 throw INTERP_KERNEL::Exception("DataArrayInt::New : should be a positive number of components !");
2493 MCAuto<DataArrayInt> ret=DataArrayInt::New();
2494 ret->alloc(nbOfTuples1,nbOfCompo);
2498 throw INTERP_KERNEL::Exception(msg.c_str());
2501 throw INTERP_KERNEL::Exception(msg.c_str());
2504 {//DataArrayInt.New(5)
2505 MCAuto<DataArrayInt> ret=DataArrayInt::New();
2506 ret->alloc(nbOfTuples1,1);
2511 else if(PyArray_Check(elt0) && nbOfTuples==NULL && nbOfComp==NULL)
2512 {//DataArrayInt.New(numpyArray)
2513 return BuildNewInstance<DataArrayInt,int>(elt0,NPY_INT32,&PyCallBackDataArrayInt_RefType,"INT32");
2517 throw INTERP_KERNEL::Exception(msg.c_str());
2518 throw INTERP_KERNEL::Exception(msg.c_str());//to make g++ happy
2521 DataArrayInt(PyObject *elt0, PyObject *nbOfTuples=0, PyObject *nbOfComp=0)
2523 return MEDCoupling_DataArrayInt_New__SWIG_1(elt0,nbOfTuples,nbOfComp);
2526 std::string __str__() const
2528 return self->reprNotTooLong();
2533 if(self->isAllocated())
2535 return self->getNumberOfTuples();
2539 throw INTERP_KERNEL::Exception("DataArrayInt::__len__ : Instance is NOT allocated !");
2545 return self->intValue();
2548 DataArrayIntIterator *__iter__()
2550 return self->iterator();
2553 PyObject *accumulate() const
2555 int sz=self->getNumberOfComponents();
2556 INTERP_KERNEL::AutoPtr<int> tmp=new int[sz];
2557 self->accumulate(tmp);
2558 return convertIntArrToPyList(tmp,sz);
2561 DataArrayInt *accumulatePerChunck(PyObject *indexArr) const
2564 std::vector<int> val2;
2565 const int *bg=convertIntStarLikePyObjToCppIntStar(indexArr,sw,sz,val,val2);
2566 return self->accumulatePerChunck(bg,bg+sz);
2569 DataArrayInt *findIdsEqualTuple(PyObject *inputTuple) const
2572 std::vector<int> val2;
2573 const int *bg(convertIntStarLikePyObjToCppIntStar(inputTuple,sw,sz,val,val2));
2574 return self->findIdsEqualTuple(bg,bg+sz);
2577 DataArrayInt *findIdForEach(PyObject *vals) const
2580 std::vector<int> val2;
2581 const int *bg(convertIntStarLikePyObjToCppIntStar(vals,sw,sz,val,val2));
2582 MCAuto<DataArrayInt> ret(self->findIdForEach(bg,bg+sz));
2586 PyObject *splitInBalancedSlices(int nbOfSlices) const
2588 std::vector< std::pair<int,int> > slcs(self->splitInBalancedSlices(nbOfSlices));
2589 PyObject *ret=PyList_New(slcs.size());
2590 for(std::size_t i=0;i<slcs.size();i++)
2591 PyList_SetItem(ret,i,PySlice_New(PyInt_FromLong(slcs[i].first),PyInt_FromLong(slcs[i].second),PyInt_FromLong(1)));
2595 DataArrayInt *buildExplicitArrOfSliceOnScaledArr(PyObject *slic) const
2597 if(!PySlice_Check(slic))
2598 throw INTERP_KERNEL::Exception("DataArrayInt::buildExplicitArrOfSliceOnScaledArr (wrap) : expecting a pyslice as second (first) parameter !");
2599 Py_ssize_t strt=2,stp=2,step=2;
2600 GetIndicesOfSliceExplicitely(slic,&strt,&stp,&step,"DataArrayInt::buildExplicitArrOfSliceOnScaledArr (wrap) : the input slice is invalid !");
2601 if(strt==std::numeric_limits<int>::max() || stp==std::numeric_limits<int>::max())
2602 throw INTERP_KERNEL::Exception("DataArrayInt::buildExplicitArrOfSliceOnScaledArr (wrap) : the input slice contains some unknowns that can't be determined in static method ! Call DataArray::getSlice (non static) instead !");
2603 return self->buildExplicitArrOfSliceOnScaledArr(strt,stp,step);
2606 PyObject *getMinMaxValues() const
2609 self->getMinMaxValues(a,b);
2610 PyObject *ret=PyTuple_New(2);
2611 PyTuple_SetItem(ret,0,PyInt_FromLong(a));
2612 PyTuple_SetItem(ret,1,PyInt_FromLong(b));
2616 static PyObject *ConvertIndexArrayToO2N(int nbOfOldTuples, PyObject *arr, PyObject *arrI)
2618 int newNbOfTuples=-1;
2619 int szArr,szArrI,sw,iTypppArr,iTypppArrI;
2620 std::vector<int> stdvecTyyppArr,stdvecTyyppArrI;
2621 const int *arrPtr=convertIntStarLikePyObjToCppIntStar(arr,sw,szArr,iTypppArr,stdvecTyyppArr);
2622 const int *arrIPtr=convertIntStarLikePyObjToCppIntStar(arrI,sw,szArrI,iTypppArrI,stdvecTyyppArrI);
2623 DataArrayInt *ret0=MEDCoupling::DataArrayInt::ConvertIndexArrayToO2N(nbOfOldTuples,arrPtr,arrIPtr,arrIPtr+szArrI,newNbOfTuples);
2624 PyObject *ret=PyTuple_New(2);
2625 PyTuple_SetItem(ret,0,SWIG_NewPointerObj((void*)ret0,SWIGTYPE_p_MEDCoupling__DataArrayInt,SWIG_POINTER_OWN | 0));
2626 PyTuple_SetItem(ret,1,PyInt_FromLong(newNbOfTuples));
2630 static DataArrayInt *CheckAndPreparePermutation(PyObject *arr)
2632 MCAuto<DataArrayInt> ret(DataArrayInt::New());
2633 int szArr,sw,iTypppArr;
2634 std::vector<int> stdvecTyyppArr;
2635 const int *arrPtr(convertIntStarLikePyObjToCppIntStar(arr,sw,szArr,iTypppArr,stdvecTyyppArr));
2636 int *pt(MEDCoupling::DataArrayInt::CheckAndPreparePermutation(arrPtr,arrPtr+szArr));
2637 ret->useArray(pt,true,MEDCoupling::DeallocType::C_DEALLOC,szArr,1);
2641 void setValues(PyObject *li, PyObject *nbOfTuples=0, PyObject *nbOfComp=0)
2643 const char *msg="MEDCoupling::DataArrayInt::setValues : Available API are : \n-DataArrayInt.setValues([1,3,4])\n-DataArrayInt.setValues([1,3,4],3)\n-DataArrayInt.setValues([1,3,4,5],2,2)\n-DataArrayInt.New(5)\n !";
2644 if(PyList_Check(li) || PyTuple_Check(li))
2646 if(nbOfTuples && nbOfTuples != Py_None)
2648 if(PyInt_Check(nbOfTuples))
2650 int nbOfTuples1=PyInt_AS_LONG(nbOfTuples);
2652 throw INTERP_KERNEL::Exception("DataArrayInt::setValue : should be a positive set of allocated memory !");
2653 if(nbOfComp && nbOfComp != Py_None)
2655 if(PyInt_Check(nbOfComp))
2656 {//DataArrayInt.setValues([1,3,4,5],2,2)
2657 int nbOfCompo=PyInt_AS_LONG(nbOfComp);
2659 throw INTERP_KERNEL::Exception("DataArrayInt::setValue : should be a positive number of components !");
2660 std::vector<int> tmp=fillArrayWithPyListInt2(li,nbOfTuples1,nbOfCompo);
2661 self->alloc(nbOfTuples1,nbOfCompo); std::copy(tmp.begin(),tmp.end(),self->getPointer());
2664 throw INTERP_KERNEL::Exception(msg);
2667 {//DataArrayInt.setValues([1,3,4],3)
2669 std::vector<int> tmp=fillArrayWithPyListInt2(li,nbOfTuples1,tmpp1);
2670 self->alloc(nbOfTuples1,tmpp1); std::copy(tmp.begin(),tmp.end(),self->getPointer());
2674 throw INTERP_KERNEL::Exception(msg);
2677 {// DataArrayInt.setValues([1,3,4])
2678 int tmpp1=-1,tmpp2=-1;
2679 std::vector<int> tmp=fillArrayWithPyListInt2(li,tmpp1,tmpp2);
2680 self->alloc(tmpp1,tmpp2); std::copy(tmp.begin(),tmp.end(),self->getPointer());
2684 throw INTERP_KERNEL::Exception(msg);
2687 PyObject *getValues() const
2689 const int *vals=self->getConstPointer();
2690 return convertIntArrToPyList(vals,self->getNbOfElems());
2694 PyObject *toNumPyArray() // not const. It is not a bug !
2696 return ToNumPyArray<DataArrayInt,int>(self,NPY_INT32,"DataArrayInt");
2700 PyObject *isEqualIfNotWhy(const DataArrayInt& other) const
2703 bool ret0=self->isEqualIfNotWhy(other,ret1);
2704 PyObject *ret=PyTuple_New(2);
2705 PyObject *ret0Py=ret0?Py_True:Py_False;
2707 PyTuple_SetItem(ret,0,ret0Py);
2708 PyTuple_SetItem(ret,1,PyString_FromString(ret1.c_str()));
2712 PyObject *getValuesAsTuple() const
2714 const int *vals=self->getConstPointer();
2715 int nbOfComp=self->getNumberOfComponents();
2716 int nbOfTuples=self->getNumberOfTuples();
2717 return convertIntArrToPyListOfTuple(vals,nbOfComp,nbOfTuples);
2720 static PyObject *MakePartition(PyObject *gps, int newNb)
2722 std::vector<const DataArrayInt *> groups;
2723 std::vector< std::vector<int> > fidsOfGroups;
2724 convertFromPyObjVectorOfObj<const MEDCoupling::DataArrayInt *>(gps,SWIGTYPE_p_MEDCoupling__DataArrayInt,"DataArrayInt",groups);
2725 MEDCoupling::DataArrayInt *ret0=MEDCoupling::DataArrayInt::MakePartition(groups,newNb,fidsOfGroups);
2726 PyObject *ret = PyList_New(2);
2727 PyList_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ));
2728 int sz=fidsOfGroups.size();
2729 PyObject *ret1 = PyList_New(sz);
2730 for(int i=0;i<sz;i++)
2731 PyList_SetItem(ret1,i,convertIntArrToPyList2(fidsOfGroups[i]));
2732 PyList_SetItem(ret,1,ret1);
2736 void transformWithIndArr(PyObject *li)
2739 int res1(SWIG_ConvertPtr(li,&da,SWIGTYPE_p_MEDCoupling__DataArrayInt, 0 | 0 ));
2740 if (!SWIG_IsOK(res1))
2742 int res2(SWIG_ConvertPtr(li,&da,SWIGTYPE_p_MEDCoupling__MapII, 0 | 0 ));
2745 MapII *m=reinterpret_cast<MapII *>(da);
2746 self->transformWithIndArr(*m);
2751 INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
2752 self->transformWithIndArr(tmp,tmp+size);
2757 DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
2758 self->transformWithIndArr(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems());
2762 DataArrayInt *findIdsEqualList(PyObject *obj)
2766 std::vector<int> multiVal;
2767 std::pair<int, std::pair<int,int> > slic;
2768 MEDCoupling::DataArrayInt *daIntTyypp=0;
2769 convertIntStarOrSliceLikePyObjToCpp(obj,self->getNumberOfTuples(),sw,singleVal,multiVal,slic,daIntTyypp);
2773 return self->findIdsEqualList(&singleVal,&singleVal+1);
2775 return self->findIdsEqualList(&multiVal[0],&multiVal[0]+multiVal.size());
2777 return self->findIdsEqualList(daIntTyypp->begin(),daIntTyypp->end());
2779 throw INTERP_KERNEL::Exception("DataArrayInt::findIdsEqualList : unrecognized type entered, expected list of int, tuple of int or DataArrayInt !");
2783 DataArrayInt *findIdsNotEqualList(PyObject *obj)
2787 std::vector<int> multiVal;
2788 std::pair<int, std::pair<int,int> > slic;
2789 MEDCoupling::DataArrayInt *daIntTyypp=0;
2790 convertIntStarOrSliceLikePyObjToCpp(obj,self->getNumberOfTuples(),sw,singleVal,multiVal,slic,daIntTyypp);
2794 return self->findIdsNotEqualList(&singleVal,&singleVal+1);
2796 return self->findIdsNotEqualList(&multiVal[0],&multiVal[0]+multiVal.size());
2798 return self->findIdsNotEqualList(daIntTyypp->begin(),daIntTyypp->end());
2800 throw INTERP_KERNEL::Exception("DataArrayInt::findIdsNotEqualList : unrecognized type entered, expected list of int, tuple of int or DataArrayInt !");
2804 PyObject *splitByValueRange(PyObject *li) const
2806 DataArrayInt *ret0=0,*ret1=0,*ret2=0;
2808 int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_MEDCoupling__DataArrayInt, 0 | 0 );
2809 if (!SWIG_IsOK(res1))
2812 INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
2813 self->splitByValueRange(tmp,(int *)tmp+size,ret0,ret1,ret2);
2817 DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
2819 throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
2820 da2->checkAllocated();
2821 self->splitByValueRange(da2->begin(),da2->end(),ret0,ret1,ret2);
2823 PyObject *ret = PyList_New(3);
2824 PyList_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ));
2825 PyList_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ));
2826 PyList_SetItem(ret,2,SWIG_NewPointerObj(SWIG_as_voidptr(ret2),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ));
2830 DataArrayInt *transformWithIndArrR(PyObject *li) const
2833 int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_MEDCoupling__DataArrayInt, 0 | 0 );
2834 if (!SWIG_IsOK(res1))
2837 INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
2838 return self->transformWithIndArrR(tmp,tmp+size);
2842 DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
2843 return self->transformWithIndArrR(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems());
2847 DataArrayInt *renumberAndReduce(PyObject *li, int newNbOfTuple)
2850 int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_MEDCoupling__DataArrayInt, 0 | 0 );
2851 if (!SWIG_IsOK(res1))
2854 INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
2855 if(size!=self->getNumberOfTuples())
2857 throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
2859 return self->renumberAndReduce(tmp,newNbOfTuple);
2863 DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
2865 throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
2866 da2->checkAllocated();
2867 int size=self->getNumberOfTuples();
2868 if(size!=self->getNumberOfTuples())
2870 throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
2872 return self->renumberAndReduce(da2->getConstPointer(),newNbOfTuple);
2876 DataArrayInt *renumber(PyObject *li)
2879 int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_MEDCoupling__DataArrayInt, 0 | 0 );
2880 if (!SWIG_IsOK(res1))
2883 INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
2884 if(size!=self->getNumberOfTuples())
2886 throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
2888 return self->renumber(tmp);
2892 DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
2894 throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
2895 da2->checkAllocated();
2896 int size=self->getNumberOfTuples();
2897 if(size!=self->getNumberOfTuples())
2899 throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
2901 return self->renumber(da2->getConstPointer());
2905 DataArrayInt *renumberR(PyObject *li)
2908 int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_MEDCoupling__DataArrayInt, 0 | 0 );
2909 if (!SWIG_IsOK(res1))
2912 INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
2913 if(size!=self->getNumberOfTuples())
2915 throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
2917 return self->renumberR(tmp);
2921 DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
2923 throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
2924 da2->checkAllocated();
2925 int size=self->getNumberOfTuples();
2926 if(size!=self->getNumberOfTuples())
2928 throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
2930 return self->renumberR(da2->getConstPointer());
2934 void setSelectedComponents(const DataArrayInt *a, PyObject *li)
2936 std::vector<int> tmp;
2937 convertPyToNewIntArr3(li,tmp);
2938 self->setSelectedComponents(a,tmp);
2941 PyObject *explodeComponents() const
2943 std::vector< MCAuto<DataArrayInt> > retCpp(self->explodeComponents());
2944 std::size_t sz(retCpp.size());
2945 PyObject *res(PyList_New(sz));
2946 for(std::size_t i=0;i<sz;i++)
2947 PyList_SetItem(res,i,SWIG_NewPointerObj(SWIG_as_voidptr(retCpp[i].retn()),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ));
2951 PyObject *getTuple(int tupleId)
2953 int sz=self->getNumberOfComponents();
2954 INTERP_KERNEL::AutoPtr<int> tmp=new int[sz];
2955 self->getTuple(tupleId,tmp);
2956 return convertIntArrToPyList(tmp,sz);
2959 PyObject *changeSurjectiveFormat(int targetNb) const
2961 DataArrayInt *arr=0;
2962 DataArrayInt *arrI=0;
2963 self->changeSurjectiveFormat(targetNb,arr,arrI);
2964 PyObject *res = PyList_New(2);
2965 PyList_SetItem(res,0,SWIG_NewPointerObj((void*)arr,SWIGTYPE_p_MEDCoupling__DataArrayInt,SWIG_POINTER_OWN | 0));
2966 PyList_SetItem(res,1,SWIG_NewPointerObj((void*)arrI,SWIGTYPE_p_MEDCoupling__DataArrayInt,SWIG_POINTER_OWN | 0));
2970 static DataArrayInt *Meld(PyObject *li)
2972 std::vector<const DataArrayInt *> tmp;
2973 convertFromPyObjVectorOfObj<const MEDCoupling::DataArrayInt *>(li,SWIGTYPE_p_MEDCoupling__DataArrayInt,"DataArrayInt",tmp);
2974 return DataArrayInt::Meld(tmp);
2977 static DataArrayInt *Aggregate(PyObject *li)
2979 std::vector<const DataArrayInt *> tmp;
2980 convertFromPyObjVectorOfObj<const MEDCoupling::DataArrayInt *>(li,SWIGTYPE_p_MEDCoupling__DataArrayInt,"DataArrayInt",tmp);
2981 return DataArrayInt::Aggregate(tmp);
2984 static DataArrayInt *AggregateIndexes(PyObject *li)
2986 std::vector<const DataArrayInt *> tmp;
2987 convertFromPyObjVectorOfObj<const MEDCoupling::DataArrayInt *>(li,SWIGTYPE_p_MEDCoupling__DataArrayInt,"DataArrayInt",tmp);
2988 return DataArrayInt::AggregateIndexes(tmp);
2991 static DataArrayInt *BuildUnion(PyObject *li)
2993 std::vector<const DataArrayInt *> tmp;
2994 convertFromPyObjVectorOfObj<const MEDCoupling::DataArrayInt *>(li,SWIGTYPE_p_MEDCoupling__DataArrayInt,"DataArrayInt",tmp);
2995 return DataArrayInt::BuildUnion(tmp);
2998 static DataArrayInt *BuildIntersection(PyObject *li)
3000 std::vector<const DataArrayInt *> tmp;
3001 convertFromPyObjVectorOfObj<const MEDCoupling::DataArrayInt *>(li,SWIGTYPE_p_MEDCoupling__DataArrayInt,"DataArrayInt",tmp);
3002 return DataArrayInt::BuildIntersection(tmp);
3005 PyObject *getMaxValue() const
3008 int r1=self->getMaxValue(tmp);
3009 PyObject *ret=PyTuple_New(2);
3010 PyTuple_SetItem(ret,0,PyInt_FromLong(r1));
3011 PyTuple_SetItem(ret,1,PyInt_FromLong(tmp));
3015 PyObject *getMaxAbsValue(std::size_t& tupleId) const
3018 int r1=self->getMaxAbsValue(tmp);
3019 PyObject *ret=PyTuple_New(2);
3020 PyTuple_SetItem(ret,0,PyInt_FromLong(r1));
3021 PyTuple_SetItem(ret,1,PyInt_FromLong(tmp));
3025 PyObject *getMinValue() const
3028 int r1=self->getMinValue(tmp);
3029 PyObject *ret=PyTuple_New(2);
3030 PyTuple_SetItem(ret,0,PyInt_FromLong(r1));
3031 PyTuple_SetItem(ret,1,PyInt_FromLong(tmp));
3035 int index(PyObject *obj) const
3037 int nbOfCompo=self->getNumberOfComponents();
3042 if(PyInt_Check(obj))
3044 int val=(int)PyInt_AS_LONG(obj);
3045 return self->findIdFirstEqual(val);
3048 throw INTERP_KERNEL::Exception("DataArrayInt::index : 'this' contains one component and trying to find an element which is not an integer !");
3052 std::vector<int> arr;
3053 convertPyToNewIntArr3(obj,arr);
3054 return self->findIdFirstEqualTuple(arr);
3059 bool __contains__(PyObject *obj) const
3061 int nbOfCompo=self->getNumberOfComponents();
3068 if(PyInt_Check(obj))
3070 int val=(int)PyInt_AS_LONG(obj);
3071 return self->presenceOfValue(val);
3074 throw INTERP_KERNEL::Exception("DataArrayInt::__contains__ : 'this' contains one component and trying to find an element which is not an integer !");
3078 std::vector<int> arr;
3079 convertPyToNewIntArr3(obj,arr);
3080 return self->presenceOfTuple(arr);
3085 PyObject *__getitem__(PyObject *obj)
3087 const char msg[]="Unexpected situation in DataArrayInt::__getitem__ !";
3088 const char msg2[]="DataArrayInt::__getitem__ : Mismatch of slice values in 2nd parameter (components) !";
3089 self->checkAllocated();
3090 int nbOfTuples=self->getNumberOfTuples();
3091 int nbOfComponents=self->getNumberOfComponents();
3093 std::vector<int> vt1,vc1;
3094 std::pair<int, std::pair<int,int> > pt1,pc1;
3095 DataArrayInt *dt1=0,*dc1=0;
3097 convertObjToPossibleCpp3(obj,nbOfTuples,nbOfComponents,sw,it1,ic1,vt1,vc1,pt1,pc1,dt1,dc1);
3098 MCAuto<DataArrayInt> ret;
3103 if(nbOfComponents==1)
3104 return PyInt_FromLong(self->getIJSafe(it1,0));
3105 return SWIG_NewPointerObj(SWIG_as_voidptr(self->selectByTupleIdSafe(&it1,&it1+1)),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 );
3108 return SWIG_NewPointerObj(SWIG_as_voidptr(self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size())),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 );
3110 return SWIG_NewPointerObj(SWIG_as_voidptr(self->selectByTupleIdSafeSlice(pt1.first,pt1.second.first,pt1.second.second)),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 );
3112 return SWIG_NewPointerObj(SWIG_as_voidptr(self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems())),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 );
3114 return PyInt_FromLong(self->getIJSafe(it1,ic1));
3117 ret=self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size());
3118 std::vector<int> v2(1,ic1);
3119 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 );
3123 ret=self->selectByTupleIdSafeSlice(pt1.first,pt1.second.first,pt1.second.second);
3124 std::vector<int> v2(1,ic1);
3125 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 );
3129 ret=self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems());
3130 std::vector<int> v2(1,ic1);
3131 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 );
3135 ret=self->selectByTupleIdSafe(&it1,&it1+1);
3136 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(vc1)),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 );
3140 ret=self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size());
3141 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(vc1)),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 );
3145 ret=self->selectByTupleIdSafeSlice(pt1.first,pt1.second.first,pt1.second.second);
3146 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(vc1)),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 );
3150 ret=self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems());
3151 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(vc1)),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 );
3155 ret=self->selectByTupleIdSafe(&it1,&it1+1);
3156 int nbOfComp=DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2);
3157 std::vector<int> v2(nbOfComp);
3158 for(int i=0;i<nbOfComp;i++)
3159 v2[i]=pc1.first+i*pc1.second.second;
3160 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 );
3164 ret=self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size());
3165 int nbOfComp=DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2);
3166 std::vector<int> v2(nbOfComp);
3167 for(int i=0;i<nbOfComp;i++)
3168 v2[i]=pc1.first+i*pc1.second.second;
3169 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 );
3173 ret=self->selectByTupleIdSafeSlice(pt1.first,pt1.second.first,pt1.second.second);
3174 int nbOfComp=DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2);
3175 std::vector<int> v2(nbOfComp);
3176 for(int i=0;i<nbOfComp;i++)
3177 v2[i]=pc1.first+i*pc1.second.second;
3178 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 );
3182 ret=self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems());
3183 int nbOfComp=DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2);
3184 std::vector<int> v2(nbOfComp);
3185 for(int i=0;i<nbOfComp;i++)
3186 v2[i]=pc1.first+i*pc1.second.second;
3187 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 );
3190 throw INTERP_KERNEL::Exception(msg);
3194 DataArrayInt *__setitem__(PyObject *obj, PyObject *value)
3196 self->checkAllocated();
3197 const char msg[]="Unexpected situation in __setitem__ !";
3198 int nbOfTuples=self->getNumberOfTuples();
3199 int nbOfComponents=self->getNumberOfComponents();
3202 std::vector<int> v1;
3204 DataArrayIntTuple *dd1=0;
3205 convertIntStarLikePyObjToCpp(value,sw1,i1,v1,d1,dd1);
3207 std::vector<int> vt1,vc1;
3208 std::pair<int, std::pair<int,int> > pt1,pc1;
3209 DataArrayInt *dt1=0,*dc1=0;
3210 convertObjToPossibleCpp3(obj,nbOfTuples,nbOfComponents,sw2,it1,ic1,vt1,vc1,pt1,pc1,dt1,dc1);
3211 MCAuto<DataArrayInt> tmp;
3219 self->setPartOfValuesSimple1(i1,it1,it1+1,1,0,nbOfComponents,1);
3222 tmp=DataArrayInt::New();
3223 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
3224 self->setPartOfValues1(tmp,it1,it1+1,1,0,nbOfComponents,1,false);
3227 self->setPartOfValues1(d1,it1,it1+1,1,0,nbOfComponents,1);
3230 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
3231 self->setPartOfValues1(tmp,it1,it1+1,1,0,nbOfComponents,1);
3234 throw INTERP_KERNEL::Exception(msg);
3243 self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1);
3246 tmp=DataArrayInt::New();
3247 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
3248 self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1,false);
3251 self->setPartOfValues3(d1,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1);
3254 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
3255 self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1);
3258 throw INTERP_KERNEL::Exception(msg);
3267 self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1);
3270 tmp=DataArrayInt::New();
3271 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
3272 self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1,false);
3275 self->setPartOfValues1(d1,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1);
3278 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
3279 self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1);
3282 throw INTERP_KERNEL::Exception(msg);
3291 self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1);
3294 tmp=DataArrayInt::New();
3295 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
3296 self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1,false);
3299 self->setPartOfValues3(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1);
3302 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
3303 self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1);
3306 throw INTERP_KERNEL::Exception(msg);
3315 self->setPartOfValuesSimple1(i1,it1,it1+1,1,ic1,ic1+1,1);
3318 tmp=DataArrayInt::New();
3319 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
3320 self->setPartOfValues1(tmp,it1,it1+1,1,ic1,ic1+1,1,false);
3323 self->setPartOfValues1(d1,it1,it1+1,1,ic1,ic1+1,1);
3326 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
3327 self->setPartOfValues1(tmp,it1,it1+1,1,ic1,ic1+1,1);
3330 throw INTERP_KERNEL::Exception(msg);
3339 self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1);
3342 tmp=DataArrayInt::New();
3343 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
3344 self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1,false);
3347 self->setPartOfValues3(d1,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1);
3350 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
3351 self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1);
3354 throw INTERP_KERNEL::Exception(msg);
3363 self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1);
3366 tmp=DataArrayInt::New();
3367 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
3368 self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1,false);
3371 self->setPartOfValues1(d1,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1);
3374 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
3375 self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1);
3378 throw INTERP_KERNEL::Exception(msg);
3387 self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1);
3390 tmp=DataArrayInt::New();
3391 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
3392 self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1,false);
3395 self->setPartOfValues3(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1);
3398 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
3399 self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1);
3402 throw INTERP_KERNEL::Exception(msg);
3411 self->setPartOfValuesSimple2(i1,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size());
3414 tmp=DataArrayInt::New();
3415 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
3416 self->setPartOfValues2(tmp,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size(),false);
3419 self->setPartOfValues2(d1,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size());
3422 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
3423 self->setPartOfValues2(tmp,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size());
3426 throw INTERP_KERNEL::Exception(msg);
3435 self->setPartOfValuesSimple2(i1,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size());
3438 tmp=DataArrayInt::New();
3439 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
3440 self->setPartOfValues2(tmp,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size(),false);
3443 self->setPartOfValues2(d1,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size());
3446 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
3447 self->setPartOfValues2(tmp,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size());
3450 throw INTERP_KERNEL::Exception(msg);
3459 self->setPartOfValuesSimple4(i1,pt1.first,pt1.second.first,pt1.second.second,&vc1[0],&vc1[0]+vc1.size());
3462 tmp=DataArrayInt::New();
3463 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
3464 self->setPartOfValues4(tmp,pt1.first,pt1.second.first,pt1.second.second,&vc1[0],&vc1[0]+vc1.size(),false);
3467 self->setPartOfValues4(d1,pt1.first,pt1.second.first,pt1.second.second,&vc1[0],&vc1[0]+vc1.size());
3470 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
3471 self->setPartOfValues4(tmp,pt1.first,pt1.second.first,pt1.second.second,&vc1[0],&vc1[0]+vc1.size());
3474 throw INTERP_KERNEL::Exception(msg);
3483 self->setPartOfValuesSimple2(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size());
3486 tmp=DataArrayInt::New();
3487 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
3488 self->setPartOfValues2(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size(),false);
3491 self->setPartOfValues2(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size());
3494 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
3495 self->setPartOfValues2(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size());
3498 throw INTERP_KERNEL::Exception(msg);
3507 self->setPartOfValuesSimple1(i1,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second);
3510 tmp=DataArrayInt::New();
3511 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
3512 self->setPartOfValues1(tmp,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second,false);
3515 self->setPartOfValues1(d1,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second);
3518 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
3519 self->setPartOfValues1(tmp,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second);
3522 throw INTERP_KERNEL::Exception(msg);
3531 self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second);
3534 tmp=DataArrayInt::New();
3535 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
3536 self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second,false);
3539 self->setPartOfValues3(d1,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second);
3542 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
3543 self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second);
3546 throw INTERP_KERNEL::Exception(msg);
3555 self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second);
3558 tmp=DataArrayInt::New();
3559 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
3560 self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second,false);
3563 self->setPartOfValues1(d1,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second);
3566 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
3567 self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second);
3570 throw INTERP_KERNEL::Exception(msg);
3579 self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second);
3582 tmp=DataArrayInt::New();
3583 tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size());
3584 self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second,false);
3587 self->setPartOfValues3(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second);
3590 tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
3591 self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second);
3594 throw INTERP_KERNEL::Exception(msg);
3599 throw INTERP_KERNEL::Exception(msg);
3604 DataArrayInt *__neg__() const
3606 return self->negate();
3609 DataArrayInt *__add__(PyObject *obj)
3611 const char msg[]="Unexpected situation in __add__ !";
3614 std::vector<int> aa;
3615 DataArrayIntTuple *aaa;
3617 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
3622 MCAuto<DataArrayInt> ret=self->deepCopy();
3623 ret->applyLin(1,val);
3628 MCAuto<DataArrayInt> aaaa=DataArrayInt::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,(int)aa.size());
3629 return DataArrayInt::Add(self,aaaa);
3633 return DataArrayInt::Add(self,a);
3637 MCAuto<DataArrayInt> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
3638 return DataArrayInt::Add(self,aaaa);
3641 throw INTERP_KERNEL::Exception(msg);
3645 DataArrayInt *__radd__(PyObject *obj)
3647 const char msg[]="Unexpected situation in __radd__ !";
3650 std::vector<int> aa;
3651 DataArrayIntTuple *aaa;
3653 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
3658 MCAuto<DataArrayInt> ret=self->deepCopy();
3659 ret->applyLin(1,val);
3664 MCAuto<DataArrayInt> aaaa=DataArrayInt::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,(int)aa.size());
3665 return DataArrayInt::Add(self,aaaa);
3669 MCAuto<DataArrayInt> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
3670 return DataArrayInt::Add(self,aaaa);
3673 throw INTERP_KERNEL::Exception(msg);
3677 PyObject *___iadd___(PyObject *trueSelf, PyObject *obj)
3679 const char msg[]="Unexpected situation in __iadd__ !";
3682 std::vector<int> aa;
3683 DataArrayIntTuple *aaa;
3685 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
3690 self->applyLin(1,val);
3691 Py_XINCREF(trueSelf);
3696 MCAuto<DataArrayInt> bb=DataArrayInt::New(); bb->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,(int)aa.size());
3698 Py_XINCREF(trueSelf);
3704 Py_XINCREF(trueSelf);
3709 MCAuto<DataArrayInt> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
3710 self->addEqual(aaaa);
3711 Py_XINCREF(trueSelf);
3715 throw INTERP_KERNEL::Exception(msg);
3719 DataArrayInt *__sub__(PyObject *obj)
3721 const char msg[]="Unexpected situation in __sub__ !";
3724 std::vector<int> aa;
3725 DataArrayIntTuple *aaa;
3727 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
3732 MCAuto<DataArrayInt> ret=self->deepCopy();
3733 ret->applyLin(1,-val);
3738 MCAuto<DataArrayInt> aaaa=DataArrayInt::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,(int)aa.size());
3739 return DataArrayInt::Substract(self,aaaa);
3743 return DataArrayInt::Substract(self,a);
3747 MCAuto<DataArrayInt> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
3748 return DataArrayInt::Substract(self,aaaa);
3751 throw INTERP_KERNEL::Exception(msg);
3755 DataArrayInt *__rsub__(PyObject *obj)
3757 const char msg[]="Unexpected situation in __rsub__ !";
3760 std::vector<int> aa;
3761 DataArrayIntTuple *aaa;
3763 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
3768 MCAuto<DataArrayInt> ret=self->deepCopy();
3769 ret->applyLin(-1,val);
3774 MCAuto<DataArrayInt> aaaa=DataArrayInt::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,(int)aa.size());
3775 return DataArrayInt::Substract(aaaa,self);
3779 MCAuto<DataArrayInt> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
3780 return DataArrayInt::Substract(aaaa,self);
3783 throw INTERP_KERNEL::Exception(msg);
3787 PyObject *___isub___(PyObject *trueSelf, PyObject *obj)
3789 const char msg[]="Unexpected situation in __isub__ !";
3792 std::vector<int> aa;
3793 DataArrayIntTuple *aaa;
3795 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
3800 self->applyLin(1,-val);
3801 Py_XINCREF(trueSelf);
3806 MCAuto<DataArrayInt> bb=DataArrayInt::New(); bb->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,(int)aa.size());
3807 self->substractEqual(bb);
3808 Py_XINCREF(trueSelf);
3813 self->substractEqual(a);
3814 Py_XINCREF(trueSelf);
3819 MCAuto<DataArrayInt> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
3820 self->substractEqual(aaaa);
3821 Py_XINCREF(trueSelf);
3825 throw INTERP_KERNEL::Exception(msg);
3829 DataArrayInt *__mul__(PyObject *obj)
3831 const char msg[]="Unexpected situation in __mul__ !";
3834 std::vector<int> aa;
3835 DataArrayIntTuple *aaa;
3837 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
3842 MCAuto<DataArrayInt> ret=self->deepCopy();
3843 ret->applyLin(val,0);
3848 MCAuto<DataArrayInt> aaaa=DataArrayInt::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,(int)aa.size());
3849 return DataArrayInt::Multiply(self,aaaa);
3853 return DataArrayInt::Multiply(self,a);
3857 MCAuto<DataArrayInt> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
3858 return DataArrayInt::Multiply(self,aaaa);
3861 throw INTERP_KERNEL::Exception(msg);
3865 DataArrayInt *__rmul__(PyObject *obj)
3867 const char msg[]="Unexpected situation in __rmul__ !";
3870 std::vector<int> aa;
3871 DataArrayIntTuple *aaa;
3873 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
3878 MCAuto<DataArrayInt> ret=self->deepCopy();
3879 ret->applyLin(val,0);
3884 MCAuto<DataArrayInt> aaaa=DataArrayInt::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,(int)aa.size());
3885 return DataArrayInt::Multiply(self,aaaa);
3889 MCAuto<DataArrayInt> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
3890 return DataArrayInt::Multiply(self,aaaa);
3893 throw INTERP_KERNEL::Exception(msg);
3897 PyObject *___imul___(PyObject *trueSelf, PyObject *obj)
3899 const char msg[]="Unexpected situation in __imul__ !";
3902 std::vector<int> aa;
3903 DataArrayIntTuple *aaa;
3905 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
3910 self->applyLin(val,0);
3911 Py_XINCREF(trueSelf);
3916 MCAuto<DataArrayInt> bb=DataArrayInt::New(); bb->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,(int)aa.size());
3917 self->multiplyEqual(bb);
3918 Py_XINCREF(trueSelf);
3923 self->multiplyEqual(a);
3924 Py_XINCREF(trueSelf);
3929 MCAuto<DataArrayInt> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
3930 self->multiplyEqual(aaaa);
3931 Py_XINCREF(trueSelf);
3935 throw INTERP_KERNEL::Exception(msg);
3939 DataArrayInt *__div__(PyObject *obj)
3941 const char msg[]="Unexpected situation in __div__ !";
3944 std::vector<int> aa;
3945 DataArrayIntTuple *aaa;
3947 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
3952 MCAuto<DataArrayInt> ret=self->deepCopy();
3953 ret->applyDivideBy(val);
3958 MCAuto<DataArrayInt> aaaa=DataArrayInt::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,(int)aa.size());
3959 return DataArrayInt::Divide(self,aaaa);
3963 return DataArrayInt::Divide(self,a);
3967 MCAuto<DataArrayInt> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
3968 return DataArrayInt::Divide(self,aaaa);
3971 throw INTERP_KERNEL::Exception(msg);
3975 DataArrayInt *__rdiv__(PyObject *obj)
3977 const char msg[]="Unexpected situation in __rdiv__ !";
3980 std::vector<int> aa;
3981 DataArrayIntTuple *aaa;
3983 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
3988 MCAuto<DataArrayInt> ret=self->deepCopy();
3994 MCAuto<DataArrayInt> aaaa=DataArrayInt::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,(int)aa.size());
3995 return DataArrayInt::Divide(aaaa,self);
3999 MCAuto<DataArrayInt> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
4000 return DataArrayInt::Divide(aaaa,self);
4003 throw INTERP_KERNEL::Exception(msg);
4007 PyObject *___idiv___(PyObject *trueSelf, PyObject *obj)
4009 const char msg[]="Unexpected situation in __idiv__ !";
4012 std::vector<int> aa;
4013 DataArrayIntTuple *aaa;
4015 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
4020 self->applyDivideBy(val);
4021 Py_XINCREF(trueSelf);
4026 MCAuto<DataArrayInt> bb=DataArrayInt::New(); bb->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,(int)aa.size());
4027 self->divideEqual(bb);
4028 Py_XINCREF(trueSelf);
4033 self->divideEqual(a);
4034 Py_XINCREF(trueSelf);
4039 MCAuto<DataArrayInt> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
4040 self->divideEqual(aaaa);
4041 Py_XINCREF(trueSelf);
4045 throw INTERP_KERNEL::Exception(msg);
4049 DataArrayInt *__mod__(PyObject *obj)
4051 const char msg[]="Unexpected situation in __mod__ !";
4054 std::vector<int> aa;
4055 DataArrayIntTuple *aaa;
4057 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
4062 MCAuto<DataArrayInt> ret=self->deepCopy();
4063 ret->applyModulus(val);
4068 MCAuto<DataArrayInt> aaaa=DataArrayInt::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,(int)aa.size());
4069 return DataArrayInt::Modulus(self,aaaa);
4073 return DataArrayInt::Modulus(self,a);
4077 MCAuto<DataArrayInt> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
4078 return DataArrayInt::Modulus(self,aaaa);
4081 throw INTERP_KERNEL::Exception(msg);
4085 DataArrayInt *__rmod__(PyObject *obj)
4087 const char msg[]="Unexpected situation in __rmod__ !";
4090 std::vector<int> aa;
4091 DataArrayIntTuple *aaa;
4093 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
4098 MCAuto<DataArrayInt> ret=self->deepCopy();
4099 ret->applyRModulus(val);
4104 MCAuto<DataArrayInt> aaaa=DataArrayInt::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,(int)aa.size());
4105 return DataArrayInt::Modulus(aaaa,self);
4109 return DataArrayInt::Modulus(a,self);
4113 MCAuto<DataArrayInt> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
4114 return DataArrayInt::Modulus(aaaa,self);
4117 throw INTERP_KERNEL::Exception(msg);
4121 PyObject *___imod___(PyObject *trueSelf, PyObject *obj)
4123 const char msg[]="Unexpected situation in __imod__ !";
4126 std::vector<int> aa;
4127 DataArrayIntTuple *aaa;
4129 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
4134 self->applyModulus(val);
4135 Py_XINCREF(trueSelf);
4140 self->modulusEqual(a);
4141 Py_XINCREF(trueSelf);
4146 MCAuto<DataArrayInt> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
4147 self->modulusEqual(aaaa);
4148 Py_XINCREF(trueSelf);
4152 throw INTERP_KERNEL::Exception(msg);
4156 DataArrayInt *__pow__(PyObject *obj)
4158 const char msg[]="Unexpected situation in __pow__ !";
4161 std::vector<int> aa;
4162 DataArrayIntTuple *aaa;
4164 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
4169 MCAuto<DataArrayInt> ret=self->deepCopy();
4175 MCAuto<DataArrayInt> aaaa=DataArrayInt::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,(int)aa.size());
4176 return DataArrayInt::Pow(self,aaaa);
4180 return DataArrayInt::Pow(self,a);
4184 MCAuto<DataArrayInt> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
4185 return DataArrayInt::Pow(self,aaaa);
4188 throw INTERP_KERNEL::Exception(msg);
4192 DataArrayInt *__rpow__(PyObject *obj)
4194 const char msg[]="Unexpected situation in __rpow__ !";
4197 std::vector<int> aa;
4198 DataArrayIntTuple *aaa;
4200 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
4205 MCAuto<DataArrayInt> ret=self->deepCopy();
4206 ret->applyRPow(val);
4211 MCAuto<DataArrayInt> aaaa=DataArrayInt::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,(int)aa.size());
4212 return DataArrayInt::Pow(aaaa,self);
4216 return DataArrayInt::Pow(a,self);
4220 MCAuto<DataArrayInt> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
4221 return DataArrayInt::Pow(aaaa,self);
4224 throw INTERP_KERNEL::Exception(msg);
4228 PyObject *___ipow___(PyObject *trueSelf, PyObject *obj)
4230 const char msg[]="Unexpected situation in __ipow__ !";
4233 std::vector<int> aa;
4234 DataArrayIntTuple *aaa;
4236 convertIntStarLikePyObjToCpp(obj,sw,val,aa,a,aaa);
4241 self->applyPow(val);
4242 Py_XINCREF(trueSelf);
4248 Py_XINCREF(trueSelf);
4253 MCAuto<DataArrayInt> aaaa=aaa->buildDAInt(1,self->getNumberOfComponents());
4254 self->powEqual(aaaa);
4255 Py_XINCREF(trueSelf);
4259 throw INTERP_KERNEL::Exception(msg);
4263 std::string __repr__() const
4265 std::ostringstream oss;
4266 self->reprQuickOverview(oss);
4270 void pushBackValsSilent(PyObject *li)
4272 int szArr,sw,iTypppArr;
4273 std::vector<int> stdvecTyyppArr;
4274 const int *tmp=convertIntStarLikePyObjToCppIntStar(li,sw,szArr,iTypppArr,stdvecTyyppArr);
4275 self->pushBackValsSilent(tmp,tmp+szArr);
4278 PyObject *partitionByDifferentValues() const
4280 std::vector<int> ret1;
4281 std::vector<DataArrayInt *> ret0=self->partitionByDifferentValues(ret1);
4282 std::size_t sz=ret0.size();
4283 PyObject *pyRet=PyTuple_New(2);
4284 PyObject *pyRet0=PyList_New((int)sz);
4285 PyObject *pyRet1=PyList_New((int)sz);
4286 for(std::size_t i=0;i<sz;i++)
4288 PyList_SetItem(pyRet0,i,SWIG_NewPointerObj(SWIG_as_voidptr(ret0[i]),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ));
4289 PyList_SetItem(pyRet1,i,PyInt_FromLong(ret1[i]));
4291 PyTuple_SetItem(pyRet,0,pyRet0);
4292 PyTuple_SetItem(pyRet,1,pyRet1);
4296 PyObject *findIdsRangesInListOfIds(const DataArrayInt *listOfIds) const
4298 DataArrayInt *ret0=0,*ret1=0;
4299 self->findIdsRangesInListOfIds(listOfIds,ret0,ret1);
4300 PyObject *pyRet=PyTuple_New(2);
4301 PyTuple_SetItem(pyRet,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ));
4302 PyTuple_SetItem(pyRet,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ));
4306 PyObject *isRange() const
4309 bool ret(self->isRange(a,b,c));
4310 PyObject *pyRet=PyTuple_New(2);
4311 PyObject *ret0Py=ret?Py_True:Py_False,*ret1Py(0);
4313 PyTuple_SetItem(pyRet,0,ret0Py);
4315 ret1Py=PySlice_New(PyInt_FromLong(a),PyInt_FromLong(b),PyInt_FromLong(c));
4321 PyTuple_SetItem(pyRet,1,ret1Py);
4325 static bool RemoveIdsFromIndexedArrays(PyObject *li, DataArrayInt *arr, DataArrayInt *arrIndx, int offsetForRemoval=0) throw(INTERP_KERNEL::Exception)
4329 std::vector<int> multiVal;
4330 std::pair<int, std::pair<int,int> > slic;
4331 MEDCoupling::DataArrayInt *daIntTyypp=0;
4333 throw INTERP_KERNEL::Exception("DataArrayInt::RemoveIdsFromIndexedArrays : null pointer as arrIndex !");
4334 convertIntStarOrSliceLikePyObjToCpp(li,arrIndx->getNumberOfTuples()-1,sw,singleVal,multiVal,slic,daIntTyypp);
4338 return DataArrayInt::RemoveIdsFromIndexedArrays(&singleVal,&singleVal+1,arr,arrIndx,offsetForRemoval);
4340 return DataArrayInt::RemoveIdsFromIndexedArrays(&multiVal[0],&multiVal[0]+multiVal.size(),arr,arrIndx,offsetForRemoval);
4342 return DataArrayInt::RemoveIdsFromIndexedArrays(daIntTyypp->begin(),daIntTyypp->end(),arr,arrIndx,offsetForRemoval);
4344 throw INTERP_KERNEL::Exception("MEDCouplingUMesh::RemoveIdsFromIndexedArrays : unrecognized type entered, expected list of int, tuple of int or DataArrayInt !");
4348 static PyObject *ExtractFromIndexedArrays(PyObject *li, const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn) throw(INTERP_KERNEL::Exception)
4350 DataArrayInt *arrOut=0,*arrIndexOut=0;
4353 std::vector<int> multiVal;
4354 std::pair<int, std::pair<int,int> > slic;
4355 MEDCoupling::DataArrayInt *daIntTyypp=0;
4357 throw INTERP_KERNEL::Exception("DataArrayInt::ExtractFromIndexedArrays : null pointer as arrIndxIn !");
4358 convertIntStarOrSliceLikePyObjToCpp(li,arrIndxIn->getNumberOfTuples()-1,sw,singleVal,multiVal,slic,daIntTyypp);
4363 DataArrayInt::ExtractFromIndexedArrays(&singleVal,&singleVal+1,arrIn,arrIndxIn,arrOut,arrIndexOut);
4368 DataArrayInt::ExtractFromIndexedArrays(&multiVal[0],&multiVal[0]+multiVal.size(),arrIn,arrIndxIn,arrOut,arrIndexOut);
4373 DataArrayInt::ExtractFromIndexedArrays(daIntTyypp->begin(),daIntTyypp->end(),arrIn,arrIndxIn,arrOut,arrIndexOut);
4377 throw INTERP_KERNEL::Exception("DataArrayInt::ExtractFromIndexedArrays : unrecognized type entered, expected list of int, tuple of int or DataArrayInt !");
4379 PyObject *ret=PyTuple_New(2);
4380 PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(arrOut),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ));
4381 PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(arrIndexOut),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ));
4385 static PyObject *ExtractFromIndexedArraysSlice(int strt, int stp, int step, const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn) throw(INTERP_KERNEL::Exception)
4387 DataArrayInt *arrOut=0,*arrIndexOut=0;
4388 DataArrayInt::ExtractFromIndexedArraysSlice(strt,stp,step,arrIn,arrIndxIn,arrOut,arrIndexOut);
4389 PyObject *ret=PyTuple_New(2);
4390 PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(arrOut),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ));
4391 PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(arrIndexOut),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ));
4395 static PyObject *ExtractFromIndexedArraysSlice(PyObject *slic, const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn) throw(INTERP_KERNEL::Exception)
4397 if(!PySlice_Check(slic))
4398 throw INTERP_KERNEL::Exception("ExtractFromIndexedArraysSlice (wrap) : the first param is not a pyslice !");
4399 Py_ssize_t strt=2,stp=2,step=2;
4401 throw INTERP_KERNEL::Exception("ExtractFromIndexedArraysSlice (wrap) : last array is null !");
4402 arrIndxIn->checkAllocated();
4403 if(arrIndxIn->getNumberOfComponents()!=1)
4404 throw INTERP_KERNEL::Exception("ExtractFromIndexedArraysSlice (wrap) : number of components of last argument must be equal to one !");
4405 GetIndicesOfSlice(slic,arrIndxIn->getNumberOfTuples(),&strt,&stp,&step,"ExtractFromIndexedArraysSlice (wrap) : Invalid slice regarding nb of elements !");
4406 DataArrayInt *arrOut=0,*arrIndexOut=0;
4407 DataArrayInt::ExtractFromIndexedArraysSlice(strt,stp,step,arrIn,arrIndxIn,arrOut,arrIndexOut);
4408 PyObject *ret=PyTuple_New(2);
4409 PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(arrOut),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ));
4410 PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(arrIndexOut),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ));
4414 static PyObject *SetPartOfIndexedArrays(PyObject *li,
4415 const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn,
4416 const DataArrayInt *srcArr, const DataArrayInt *srcArrIndex) throw(INTERP_KERNEL::Exception)
4418 DataArrayInt *arrOut=0,*arrIndexOut=0;
4421 std::vector<int> multiVal;
4422 std::pair<int, std::pair<int,int> > slic;
4423 MEDCoupling::DataArrayInt *daIntTyypp=0;
4425 throw INTERP_KERNEL::Exception("DataArrayInt::SetPartOfIndexedArrays : null pointer as arrIndex !");
4426 convertIntStarOrSliceLikePyObjToCpp(li,arrIndxIn->getNumberOfTuples()-1,sw,singleVal,multiVal,slic,daIntTyypp);
4431 DataArrayInt::SetPartOfIndexedArrays(&singleVal,&singleVal+1,arrIn,arrIndxIn,srcArr,srcArrIndex,arrOut,arrIndexOut);
4436 DataArrayInt::SetPartOfIndexedArrays(&multiVal[0],&multiVal[0]+multiVal.size(),arrIn,arrIndxIn,srcArr,srcArrIndex,arrOut,arrIndexOut);
4441 DataArrayInt::SetPartOfIndexedArrays(daIntTyypp->begin(),daIntTyypp->end(),arrIn,arrIndxIn,srcArr,srcArrIndex,arrOut,arrIndexOut);
4445 throw INTERP_KERNEL::Exception("DataArrayInt::SetPartOfIndexedArrays : unrecognized type entered, expected list of int, tuple of int or DataArrayInt !");
4447 PyObject *ret=PyTuple_New(2);
4448 PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(arrOut),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ));
4449 PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(arrIndexOut),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ));
4453 static void SetPartOfIndexedArraysSameIdx(PyObject *li, DataArrayInt *arrIn, const DataArrayInt *arrIndxIn,
4454 const DataArrayInt *srcArr, const DataArrayInt *srcArrIndex) throw(INTERP_KERNEL::Exception)
4458 std::vector<int> multiVal;
4459 std::pair<int, std::pair<int,int> > slic;
4460 MEDCoupling::DataArrayInt *daIntTyypp=0;
4462 throw INTERP_KERNEL::Exception("DataArrayInt::SetPartOfIndexedArraysSameIdx : null pointer as arrIndex !");
4463 convertIntStarOrSliceLikePyObjToCpp(li,arrIndxIn->getNumberOfTuples()-1,sw,singleVal,multiVal,slic,daIntTyypp);
4468 DataArrayInt::SetPartOfIndexedArraysSameIdx(&singleVal,&singleVal+1,arrIn,arrIndxIn,srcArr,srcArrIndex);
4473 DataArrayInt::SetPartOfIndexedArraysSameIdx(&multiVal[0],&multiVal[0]+multiVal.size(),arrIn,arrIndxIn,srcArr,srcArrIndex);
4478 DataArrayInt::SetPartOfIndexedArraysSameIdx(daIntTyypp->begin(),daIntTyypp->end(),arrIn,arrIndxIn,srcArr,srcArrIndex);
4482 throw INTERP_KERNEL::Exception("DataArrayInt::SetPartOfIndexedArraysSameIdx : unrecognized type entered, expected list of int, tuple of int or DataArrayInt !");
4489 class DataArrayIntTuple;
4491 class DataArrayIntIterator
4494 DataArrayIntIterator(DataArrayInt *da);
4495 ~DataArrayIntIterator();
4500 DataArrayIntTuple *ret=self->nextt();
4502 return SWIG_NewPointerObj(SWIG_as_voidptr(ret),SWIGTYPE_p_MEDCoupling__DataArrayIntTuple,SWIG_POINTER_OWN | 0);
4505 PyErr_SetString(PyExc_StopIteration,"No more data.");
4512 class DataArrayIntTuple
4515 int getNumberOfCompo() const;
4516 DataArrayInt *buildDAInt(int nbOfTuples, int nbOfCompo) const;
4519 std::string __str__() const
4521 return self->repr();
4526 return self->intValue();
4529 DataArrayInt *buildDAInt()
4531 return self->buildDAInt(1,self->getNumberOfCompo());
4534 PyObject *___iadd___(PyObject *trueSelf, PyObject *obj)
4536 MCAuto<DataArrayInt> ret=self->buildDAInt(1,self->getNumberOfCompo());
4537 MEDCoupling_DataArrayInt____iadd___(ret,0,obj);
4538 Py_XINCREF(trueSelf);
4542 PyObject *___isub___(PyObject *trueSelf, PyObject *obj)
4544 MCAuto<DataArrayInt> ret=self->buildDAInt(1,self->getNumberOfCompo());
4545 MEDCoupling_DataArrayInt____isub___(ret,0,obj);
4546 Py_XINCREF(trueSelf);
4550 PyObject *___imul___(PyObject *trueSelf, PyObject *obj)
4552 MCAuto<DataArrayInt> ret=self->buildDAInt(1,self->getNumberOfCompo());
4553 MEDCoupling_DataArrayInt____imul___(ret,0,obj);
4554 Py_XINCREF(trueSelf);
4557 PyObject *___idiv___(PyObject *trueSelf, PyObject *obj)
4559 MCAuto<DataArrayInt> ret=self->buildDAInt(1,self->getNumberOfCompo());
4560 MEDCoupling_DataArrayInt____idiv___(ret,0,obj);
4561 Py_XINCREF(trueSelf);
4565 PyObject *___imod___(PyObject *trueSelf, PyObject *obj)
4567 MCAuto<DataArrayInt> ret=self->buildDAInt(1,self->getNumberOfCompo());
4568 MEDCoupling_DataArrayInt____imod___(ret,0,obj);
4569 Py_XINCREF(trueSelf);
4575 return PyInt_FromLong(self->getNumberOfCompo());
4578 PyObject *__getitem__(PyObject *obj)
4580 const char msg2[]="DataArrayIntTuple::__getitem__ : Mismatch of slice values in 2nd parameter (components) !";
4583 std::vector<int> multiVal;
4584 std::pair<int, std::pair<int,int> > slic;
4585 MEDCoupling::DataArrayInt *daIntTyypp=0;
4586 const int *pt=self->getConstPointer();
4587 int nbc=self->getNumberOfCompo();
4588 convertIntStarOrSliceLikePyObjToCppWithNegIntInterp(obj,nbc,sw,singleVal,multiVal,slic,daIntTyypp);
4595 std::ostringstream oss;
4596 oss << "Requesting for id " << singleVal << " having only " << nbc << " components !";
4597 PyErr_SetString(PyExc_StopIteration,oss.str().c_str());
4601 return PyInt_FromLong(pt[singleVal]);
4605 return PyInt_FromLong(pt[nbc+singleVal]);
4608 std::ostringstream oss;
4609 oss << "Requesting for id " << singleVal << " having only " << nbc << " components !";
4610 throw INTERP_KERNEL::Exception(oss.str().c_str());
4616 PyObject *t=PyTuple_New(multiVal.size());
4617 for(int j=0;j<(int)multiVal.size();j++)
4619 int cid=multiVal[j];
4622 std::ostringstream oss;
4623 oss << "Requesting for id #" << cid << " having only " << nbc << " components !";
4624 throw INTERP_KERNEL::Exception(oss.str().c_str());
4626 PyTuple_SetItem(t,j,PyInt_FromLong(pt[cid]));
4632 int sz=DataArray::GetNumberOfItemGivenBES(slic.first,slic.second.first,slic.second.second,msg2);
4633 PyObject *t=PyTuple_New(sz);
4634 for(int j=0;j<sz;j++)
4635 PyTuple_SetItem(t,j,PyInt_FromLong(pt[slic.first+j*slic.second.second]));
4639 throw INTERP_KERNEL::Exception("DataArrayIntTuple::__getitem__ : unrecognized type entered !");
4643 DataArrayIntTuple *__setitem__(PyObject *obj, PyObject *value)
4645 const char msg[]="DataArrayIntTuple::__setitem__ : unrecognized type entered, int, slice, list<int>, tuple<int> !";
4646 const char msg2[]="DataArrayIntTuple::__setitem__ : Mismatch of slice values in 2nd parameter (components) !";
4649 std::vector<int> multiValV;
4650 std::pair<int, std::pair<int,int> > slicV;
4651 MEDCoupling::DataArrayIntTuple *daIntTyyppV=0;
4652 int nbc=self->getNumberOfCompo();
4653 convertObjToPossibleCpp22(value,nbc,sw1,singleValV,multiValV,slicV,daIntTyyppV);
4655 std::vector<int> multiVal;
4656 std::pair<int, std::pair<int,int> > slic;
4657 MEDCoupling::DataArrayInt *daIntTyypp=0;
4658 int *pt=self->getPointer();
4659 convertIntStarOrSliceLikePyObjToCppWithNegIntInterp(obj,nbc,sw2,singleVal,multiVal,slic,daIntTyypp);
4666 std::ostringstream oss;
4667 oss << "Requesting for setting id # " << singleVal << " having only " << nbc << " components !";
4668 throw INTERP_KERNEL::Exception(oss.str().c_str());
4674 pt[singleVal]=singleValV;
4679 if(multiValV.size()!=1)
4681 std::ostringstream oss;
4682 oss << "Requesting for setting id # " << singleVal << " with a list or tuple with size != 1 ! ";
4683 throw INTERP_KERNEL::Exception(oss.str().c_str());
4685 pt[singleVal]=multiValV[0];
4690 pt[singleVal]=daIntTyyppV->getConstPointer()[0];
4694 throw INTERP_KERNEL::Exception(msg);
4703 for(std::vector<int>::const_iterator it=multiVal.begin();it!=multiVal.end();it++)
4707 std::ostringstream oss;
4708 oss << "Requesting for setting id # " << *it << " having only " << nbc << " components !";
4709 throw INTERP_KERNEL::Exception(oss.str().c_str());
4717 if(multiVal.size()!=multiValV.size())
4719 std::ostringstream oss;
4720 oss << "Mismatch length of during assignment : " << multiValV.size() << " != " << multiVal.size() << " !";
4721 throw INTERP_KERNEL::Exception(oss.str().c_str());
4723 for(int i=0;i<(int)multiVal.size();i++)
4725 int pos=multiVal[i];
4728 std::ostringstream oss;
4729 oss << "Requesting for setting id # " << pos << " having only " << nbc << " components !";
4730 throw INTERP_KERNEL::Exception(oss.str().c_str());
4732 pt[multiVal[i]]=multiValV[i];
4738 const int *ptV=daIntTyyppV->getConstPointer();
4739 if(nbc>daIntTyyppV->getNumberOfCompo())
4741 std::ostringstream oss;
4742 oss << "Mismatch length of during assignment : " << nbc << " != " << daIntTyyppV->getNumberOfCompo() << " !";
4743 throw INTERP_KERNEL::Exception(oss.str().c_str());
4745 std::copy(ptV,ptV+nbc,pt);
4749 throw INTERP_KERNEL::Exception(msg);
4754 int sz=DataArray::GetNumberOfItemGivenBES(slic.first,slic.second.first,slic.second.second,msg2);
4759 for(int j=0;j<sz;j++)
4760 pt[slic.first+j*slic.second.second]=singleValV;
4765 if(sz!=(int)multiValV.size())
4767 std::ostringstream oss;
4768 oss << "Mismatch length of during assignment : " << multiValV.size() << " != " << sz << " !";
4769 throw INTERP_KERNEL::Exception(oss.str().c_str());
4771 for(int j=0;j<sz;j++)
4772 pt[slic.first+j*slic.second.second]=multiValV[j];
4777 const int *ptV=daIntTyyppV->getConstPointer();
4778 if(sz>daIntTyyppV->getNumberOfCompo())
4780 std::ostringstream oss;
4781 oss << "Mismatch length of during assignment : " << nbc << " != " << daIntTyyppV->getNumberOfCompo() << " !";
4782 throw INTERP_KERNEL::Exception(oss.str().c_str());
4784 for(int j=0;j<sz;j++)
4785 pt[slic.first+j*slic.second.second]=ptV[j];
4789 throw INTERP_KERNEL::Exception(msg);
4793 throw INTERP_KERNEL::Exception(msg);
4799 class DataArrayChar : public DataArray
4802 virtual DataArrayChar *buildEmptySpecializedDAChar() const;
4803 int getHashCode() const;
4805 void deepCopyFrom(const DataArrayChar& other);
4806 void reserve(std::size_t nbOfElems);
4807 void pushBackSilent(char val);
4808 char popBackSilent();
4810 void allocIfNecessary(int nbOfTuple, int nbOfCompo);
4811 bool isEqual(const DataArrayChar& other) const;
4812 bool isEqualWithoutConsideringStr(const DataArrayChar& other) const;
4814 void fillWithZero();
4815 void fillWithValue(char val);
4816 std::string repr() const;
4817 std::string reprZip() const;
4818 DataArrayInt *convertToIntArr() const;
4819 DataArrayChar *renumber(const int *old2New) const;
4820 DataArrayChar *renumberR(const int *new2Old) const;
4821 DataArrayChar *renumberAndReduce(const int *old2NewBg, int newNbOfTuple) const;
4822 bool isUniform(char val) const;
4823 void sort(bool asc=true);
4824 DataArrayChar *subArray(int tupleIdBg, int tupleIdEnd=-1) const;
4825 DataArrayChar *changeNbOfComponents(int newNbOfComp, char dftValue) const;
4826 void meldWith(const DataArrayChar *other);
4827 void setPartOfValuesAdv(const DataArrayChar *a, const DataArrayInt *tuplesSelec);
4830 void setIJ(int tupleId, int compoId, char newVal);
4831 void setIJSilent(int tupleId, int compoId, char newVal);
4833 DataArrayInt *findIdsEqual(char val) const;
4834 DataArrayInt *findIdsNotEqual(char val) const;
4835 int findIdFirstEqualTuple(const std::vector<char>& tupl) const;
4836 bool presenceOfTuple(const std::vector<char>& tupl) const;
4837 char getMaxValue(int& tupleId) const;
4838 char getMaxValueInArray() const;
4839 char getMinValue(int& tupleId) const;
4840 char getMinValueInArray() const;
4841 DataArrayInt *findIdsInRange(char vmin, char vmax) const;
4842 static DataArrayChar *Aggregate(const DataArrayChar *a1, const DataArrayChar *a2);
4843 static DataArrayChar *Meld(const DataArrayChar *a1, const DataArrayChar *a2);
4848 if(self->isAllocated())
4850 return self->getNumberOfTuples();
4854 throw INTERP_KERNEL::Exception("DataArrayChar::__len__ : Instance is NOT allocated !");
4858 PyObject *isEqualIfNotWhy(const DataArrayChar& other) const
4861 bool ret0=self->isEqualIfNotWhy(other,ret1);
4862 PyObject *ret=PyTuple_New(2);
4863 PyObject *ret0Py=ret0?Py_True:Py_False;
4865 PyTuple_SetItem(ret,0,ret0Py);
4866 PyTuple_SetItem(ret,1,PyString_FromString(ret1.c_str()));
4870 DataArrayChar *renumber(PyObject *li)
4873 int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_MEDCoupling__DataArrayInt, 0 | 0 );
4874 if (!SWIG_IsOK(res1))
4877 INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
4878 if(size!=self->getNumberOfTuples())
4880 throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
4882 return self->renumber(tmp);
4886 DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
4888 throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
4889 da2->checkAllocated();
4890 int size=self->getNumberOfTuples();
4891 if(size!=self->getNumberOfTuples())
4893 throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
4895 return self->renumber(da2->getConstPointer());
4899 DataArrayChar *renumberR(PyObject *li)
4902 int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_MEDCoupling__DataArrayInt, 0 | 0 );
4903 if (!SWIG_IsOK(res1))
4906 INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
4907 if(size!=self->getNumberOfTuples())
4909 throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
4911 return self->renumberR(tmp);
4915 DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
4917 throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
4918 da2->checkAllocated();
4919 int size=self->getNumberOfTuples();
4920 if(size!=self->getNumberOfTuples())
4922 throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
4924 return self->renumberR(da2->getConstPointer());
4928 DataArrayChar *renumberAndReduce(PyObject *li, int newNbOfTuple)
4931 int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_MEDCoupling__DataArrayInt, 0 | 0 );
4932 if (!SWIG_IsOK(res1))
4935 INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
4936 if(size!=self->getNumberOfTuples())
4938 throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
4940 return self->renumberAndReduce(tmp,newNbOfTuple);
4944 DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
4946 throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
4947 da2->checkAllocated();
4948 int size=self->getNumberOfTuples();
4949 if(size!=self->getNumberOfTuples())
4951 throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
4953 return self->renumberAndReduce(da2->getConstPointer(),newNbOfTuple);
4957 static DataArrayChar *Aggregate(PyObject *dachs)
4959 std::vector<const MEDCoupling::DataArrayChar *> tmp;
4960 convertFromPyObjVectorOfObj<const MEDCoupling::DataArrayChar *>(dachs,SWIGTYPE_p_MEDCoupling__DataArrayChar,"DataArrayChar",tmp);
4961 return DataArrayChar::Aggregate(tmp);
4964 static DataArrayChar *Meld(PyObject *dachs)
4966 std::vector<const MEDCoupling::DataArrayChar *> tmp;
4967 convertFromPyObjVectorOfObj<const MEDCoupling::DataArrayChar *>(dachs,SWIGTYPE_p_MEDCoupling__DataArrayChar,"DataArrayChar",tmp);
4968 return DataArrayChar::Meld(tmp);
4973 class DataArrayByteIterator;
4975 class DataArrayByte : public DataArrayChar
4978 static DataArrayByte *New();
4979 DataArrayByteIterator *iterator();
4980 DataArrayByte *performCopyOrIncrRef(bool deepCopy) const;
4981 char byteValue() const;
4986 return DataArrayByte::New();
4989 static DataArrayByte *New(PyObject *elt0, PyObject *nbOfTuples=0, PyObject *nbOfComp=0)
4991 const char *msg="MEDCoupling::DataArrayByte::New : Available API are : \n-DataArrayByte.New()\n--DataArrayByte.New([1,3,4])\n-DataArrayByte.New([1,3,4],3)\n-DataArrayByte.New([1,3,4,5],2,2)\n-DataArrayByte.New(5)\n-DataArrayByte.New(5,2) !";
4992 if(PyList_Check(elt0) || PyTuple_Check(elt0))
4996 if(PyInt_Check(nbOfTuples))
4998 int nbOfTuples1=PyInt_AS_LONG(nbOfTuples);
5000 throw INTERP_KERNEL::Exception("DataArrayByte::New : should be a positive set of allocated memory !");
5003 if(PyInt_Check(nbOfComp))
5004 {//DataArrayByte.New([1,3,4,5],2,2)
5005 int nbOfCompo=PyInt_AS_LONG(nbOfComp);
5007 throw INTERP_KERNEL::Exception("DataArrayByte::New : should be a positive number of components !");
5008 MCAuto<DataArrayByte> ret=DataArrayByte::New();
5009 std::vector<int> tmp=fillArrayWithPyListInt2(elt0,nbOfTuples1,nbOfCompo);
5010 ret->alloc(nbOfTuples1,nbOfCompo); std::copy(tmp.begin(),tmp.end(),ret->getPointer());
5014 throw INTERP_KERNEL::Exception(msg);
5017 {//DataArrayByte.New([1,3,4],3)
5018 MCAuto<DataArrayByte> ret=DataArrayByte::New();
5020 std::vector<int> tmp=fillArrayWithPyListInt2(elt0,nbOfTuples1,tmpp1);
5021 ret->alloc(nbOfTuples1,tmpp1); std::copy(tmp.begin(),tmp.end(),ret->getPointer());
5026 throw INTERP_KERNEL::Exception(msg);
5029 {// DataArrayByte.New([1,3,4])
5030 MCAuto<DataArrayByte> ret=DataArrayByte::New();
5031 int tmpp1=-1,tmpp2=-1;
5032 std::vector<int> tmp=fillArrayWithPyListInt2(elt0,tmpp1,tmpp2);
5033 ret->alloc(tmpp1,tmpp2); std::copy(tmp.begin(),tmp.end(),ret->getPointer());
5037 else if(PyInt_Check(elt0))
5039 int nbOfTuples1=PyInt_AS_LONG(elt0);
5041 throw INTERP_KERNEL::Exception("DataArrayByte::New : should be a positive set of allocated memory !");
5046 if(PyInt_Check(nbOfTuples))
5047 {//DataArrayByte.New(5,2)
5048 int nbOfCompo=PyInt_AS_LONG(nbOfTuples);
5050 throw INTERP_KERNEL::Exception("DataArrayByte::New : should be a positive number of components !");
5051 MCAuto<DataArrayByte> ret=DataArrayByte::New();
5052 ret->alloc(nbOfTuples1,nbOfCompo);
5056 throw INTERP_KERNEL::Exception(msg);
5059 throw INTERP_KERNEL::Exception(msg);
5062 {//DataArrayByte.New(5)
5063 MCAuto<DataArrayByte> ret=DataArrayByte::New();
5064 ret->alloc(nbOfTuples1,1);
5069 else if(PyArray_Check(elt0) && nbOfTuples==NULL && nbOfComp==NULL)
5070 {//DataArrayDouble.New(numpyArray)
5071 return BuildNewInstance<DataArrayByte,char>(elt0,NPY_INT8,&PyCallBackDataArrayChar_RefType,"INT8");
5075 throw INTERP_KERNEL::Exception(msg);
5078 DataArrayByte(PyObject *elt0, PyObject *nbOfTuples=0, PyObject *nbOfComp=0)
5080 return MEDCoupling_DataArrayByte_New__SWIG_1(elt0,nbOfTuples,nbOfComp);
5083 std::string __repr__() const
5085 std::ostringstream oss;
5086 self->reprQuickOverview(oss);
5092 return (int) self->byteValue();
5095 DataArrayByteIterator *__iter__()
5097 return self->iterator();
5100 int getIJ(int tupleId, int compoId) const
5102 return (int)self->getIJ(tupleId,compoId);
5105 int getIJSafe(int tupleId, int compoId) const
5107 return (int)self->getIJSafe(tupleId,compoId);
5110 std::string __str__() const
5112 return self->repr();
5115 PyObject *toStrList() const
5117 const char *vals=self->getConstPointer();
5118 int nbOfComp=self->getNumberOfComponents();
5119 int nbOfTuples=self->getNumberOfTuples();
5120 return convertCharArrToPyListOfTuple(vals,nbOfComp,nbOfTuples);
5123 bool presenceOfTuple(PyObject *tupl) const
5126 int ival=-1; std::vector<int> ivval;
5127 const int *pt=convertIntStarLikePyObjToCppIntStar(tupl,sw,sz,ival,ivval);
5128 std::vector<char> vals(sz);
5129 std::copy(pt,pt+sz,vals.begin());
5130 return self->presenceOfTuple(vals);
5133 bool presenceOfValue(PyObject *vals) const
5136 int ival=-1; std::vector<int> ivval;
5137 const int *pt=convertIntStarLikePyObjToCppIntStar(vals,sw,sz,ival,ivval);
5138 std::vector<char> vals2(sz);
5139 std::copy(pt,pt+sz,vals2.begin());
5140 return self->presenceOfValue(vals2);
5143 int findIdFirstEqual(PyObject *vals) const
5146 int ival=-1; std::vector<int> ivval;
5147 const int *pt=convertIntStarLikePyObjToCppIntStar(vals,sw,sz,ival,ivval);
5148 std::vector<char> vals2(sz);
5149 std::copy(pt,pt+sz,vals2.begin());
5150 return self->findIdFirstEqual(vals2);
5153 int findIdFirstEqualTuple(PyObject *tupl) const
5156 int ival=-1; std::vector<int> ivval;
5157 const int *pt=convertIntStarLikePyObjToCppIntStar(tupl,sw,sz,ival,ivval);
5158 std::vector<char> vals(sz);
5159 std::copy(pt,pt+sz,vals.begin());
5160 return self->findIdFirstEqualTuple(vals);
5163 int findIdSequence(PyObject *strOrListOfInt) const
5166 int ival=-1; std::vector<int> ivval;
5167 const int *pt=convertIntStarLikePyObjToCppIntStar(strOrListOfInt,sw,sz,ival,ivval);
5168 std::vector<char> vals(sz);
5169 std::copy(pt,pt+sz,vals.begin());
5170 return self->findIdSequence(vals);
5173 PyObject *getTuple(int tupleId)
5175 int sz=self->getNumberOfComponents();
5176 INTERP_KERNEL::AutoPtr<char> tmp=new char[sz];
5177 self->getTuple(tupleId,tmp);
5178 PyObject *ret=PyTuple_New(sz);
5179 for(int i=0;i<sz;i++) PyTuple_SetItem(ret,i,PyInt_FromLong((int)tmp[i]));
5183 PyObject *getMaxValue() const
5186 int r1=(int)self->getMaxValue(tmp);
5187 PyObject *ret=PyTuple_New(2);
5188 PyTuple_SetItem(ret,0,PyInt_FromLong(r1));
5189 PyTuple_SetItem(ret,1,PyInt_FromLong(tmp));
5193 PyObject *getMinValue() const
5196 int r1=(int)self->getMinValue(tmp);
5197 PyObject *ret=PyTuple_New(2);
5198 PyTuple_SetItem(ret,0,PyInt_FromLong(r1));
5199 PyTuple_SetItem(ret,1,PyInt_FromLong(tmp));
5203 int index(PyObject *obj) const
5205 int nbOfCompo=self->getNumberOfComponents();
5210 if(PyInt_Check(obj))
5212 int val=(int)PyInt_AS_LONG(obj);
5213 return self->findIdFirstEqual(val);
5216 throw INTERP_KERNEL::Exception("DataArrayByte::index : 'this' contains one component and trying to find an element which is not an integer !");
5219 return MEDCoupling_DataArrayByte_findIdFirstEqualTuple(self,obj);
5223 bool __contains__(PyObject *obj) const
5225 int nbOfCompo=self->getNumberOfComponents();
5232 if(PyInt_Check(obj))
5234 int val=(int)PyInt_AS_LONG(obj);
5235 return self->presenceOfValue(val);
5238 throw INTERP_KERNEL::Exception("DataArrayByte::__contains__ : 'this' contains one component and trying to find an element which is not an integer !");
5241 return MEDCoupling_DataArrayByte_presenceOfTuple(self,obj);
5246 PyObject *toNumPyArray() // not const. It is not a bug !
5248 return ToNumPyArray<DataArrayByte,char>(self,NPY_INT8,"DataArrayByte");
5252 DataArrayByte *__setitem__(PyObject *obj, PyObject *value)
5254 self->checkAllocated();
5255 const char msg[]="Unexpected situation in __setitem__ !";
5256 int nbOfTuples(self->getNumberOfTuples()),nbOfComponents(self->getNumberOfComponents());
5259 std::vector<int> v1;
5261 DataArrayIntTuple *dd1=0;
5262 convertIntStarLikePyObjToCpp(value,sw1,i1,v1,d1,dd1);
5264 std::vector<int> vt1,vc1;
5265 std::pair<int, std::pair<int,int> > pt1,pc1;
5266 DataArrayInt *dt1=0,*dc1=0;
5267 convertObjToPossibleCpp3(obj,nbOfTuples,nbOfComponents,sw2,it1,ic1,vt1,vc1,pt1,pc1,dt1,dc1);
5268 MCAuto<DataArrayInt> tmp;
5276 self->setPartOfValuesSimple1(i1,it1,it1+1,1,0,nbOfComponents,1);
5279 throw INTERP_KERNEL::Exception(msg);
5288 self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1);
5291 throw INTERP_KERNEL::Exception(msg);
5300 self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1);
5303 throw INTERP_KERNEL::Exception(msg);
5312 self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1);
5315 throw INTERP_KERNEL::Exception(msg);
5324 self->setPartOfValuesSimple1(i1,it1,it1+1,1,ic1,ic1+1,1);
5327 throw INTERP_KERNEL::Exception(msg);
5336 self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1);
5339 throw INTERP_KERNEL::Exception(msg);
5348 self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1);
5351 throw INTERP_KERNEL::Exception(msg);
5360 self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1);
5363 throw INTERP_KERNEL::Exception(msg);
5372 self->setPartOfValuesSimple2(i1,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size());
5375 throw INTERP_KERNEL::Exception(msg);
5384 self->setPartOfValuesSimple2(i1,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size());
5387 throw INTERP_KERNEL::Exception(msg);
5396 self->setPartOfValuesSimple4(i1,pt1.first,pt1.second.first,pt1.second.second,&vc1[0],&vc1[0]+vc1.size());
5399 throw INTERP_KERNEL::Exception(msg);
5408 self->setPartOfValuesSimple2(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size());
5411 throw INTERP_KERNEL::Exception(msg);
5420 self->setPartOfValuesSimple1(i1,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second);
5423 throw INTERP_KERNEL::Exception(msg);
5432 self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second);
5435 throw INTERP_KERNEL::Exception(msg);
5444 self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second);
5447 throw INTERP_KERNEL::Exception(msg);
5456 self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second);
5459 throw INTERP_KERNEL::Exception(msg);
5464 throw INTERP_KERNEL::Exception(msg);
5471 class DataArrayByteTuple;
5473 class DataArrayByteIterator
5476 DataArrayByteIterator(DataArrayByte *da);
5477 ~DataArrayByteIterator();
5480 class DataArrayByteTuple
5483 std::string repr() const;
5484 DataArrayByte *buildDAByte(int nbOfTuples, int nbOfCompo) const;
5487 std::string __str__() const
5489 return self->repr();
5492 char __int__() const
5494 return self->byteValue();
5497 DataArrayByte *buildDAByte()
5499 return self->buildDAByte(1,self->getNumberOfCompo());
5504 class DataArrayAsciiCharIterator;
5506 class DataArrayAsciiChar : public DataArrayChar
5509 static DataArrayAsciiChar *New();
5510 DataArrayAsciiCharIterator *iterator();
5511 DataArrayAsciiChar *performCopyOrIncrRef(bool deepCopy) const;
5512 char asciiCharValue() const;
5515 DataArrayAsciiChar()
5517 return DataArrayAsciiChar::New();
5520 static DataArrayAsciiChar *New(PyObject *elt0, PyObject *nbOfTuples=0, PyObject *nbOfComp=0)
5522 const char *msg="MEDCoupling::DataArrayAsciiChar::New : Available API are : \n-DataArrayAsciiChar.New()\n-DataArrayAsciiChar.New([1,3,4])\n-DataArrayAsciiChar.New([\"abc\",\"de\",\"fghi\"])\n-DataArrayAsciiChar.New([\"abc\",\"de\",\"fghi\"],\"t\")\n-DataArrayAsciiChar.New([1,3,4],3)\n-DataArrayAsciiChar.New([1,3,4,5],2,2)\n-DataArrayAsciiChar.New(5)\n-DataArrayAsciiChar.New(5,2) !";
5523 if(PyList_Check(elt0) || PyTuple_Check(elt0))
5527 if(PyInt_Check(nbOfTuples))
5529 int nbOfTuples1=PyInt_AS_LONG(nbOfTuples);
5531 throw INTERP_KERNEL::Exception("DataArrayAsciiChar::New : should be a positive set of allocated memory !");
5534 if(PyInt_Check(nbOfComp))
5535 {//DataArrayAsciiChar.New([1,3,4,5],2,2)
5536 int nbOfCompo=PyInt_AS_LONG(nbOfComp);
5538 throw INTERP_KERNEL::Exception("DataArrayAsciiChar::New : should be a positive number of components !");
5539 MCAuto<DataArrayAsciiChar> ret=DataArrayAsciiChar::New();
5540 std::vector<int> tmp=fillArrayWithPyListInt2(elt0,nbOfTuples1,nbOfCompo);
5541 ret->alloc(nbOfTuples1,nbOfCompo); std::copy(tmp.begin(),tmp.end(),ret->getPointer());
5545 throw INTERP_KERNEL::Exception(msg);
5548 {//DataArrayAsciiChar.New([1,3,4],3)
5549 MCAuto<DataArrayAsciiChar> ret=DataArrayAsciiChar::New();
5551 std::vector<int> tmp=fillArrayWithPyListInt2(elt0,nbOfTuples1,tmpp1);
5552 ret->alloc(nbOfTuples1,tmpp1); std::copy(tmp.begin(),tmp.end(),ret->getPointer());
5556 else if(PyString_Check(nbOfTuples))
5558 if(PyString_Size(nbOfTuples)!=1)
5559 throw INTERP_KERNEL::Exception(msg);
5560 //DataArrayAsciiChar.New(["abc","de","fghi"],"t")
5561 std::vector<std::string> tmp;
5562 if(fillStringVector(elt0,tmp))
5563 return DataArrayAsciiChar::New(tmp,PyString_AsString(nbOfTuples)[0]);
5565 throw INTERP_KERNEL::Exception(msg);
5567 %#if PY_VERSION_HEX >= 0x03000000
5568 else if(PyUnicode_Check(nbOfTuples))
5570 if(PyUnicode_GET_LENGTH(nbOfTuples)!=1)
5571 throw INTERP_KERNEL::Exception(msg);
5572 //DataArrayAsciiChar.New(["abc","de","fghi"],"t")
5573 std::vector<std::string> tmp;
5574 if(fillStringVector(elt0,tmp))
5575 return DataArrayAsciiChar::New(tmp,PyUnicode_AsUTF8(nbOfTuples)[0]);
5577 throw INTERP_KERNEL::Exception(msg);
5581 throw INTERP_KERNEL::Exception(msg);
5585 std::vector<std::string> tmmp;
5586 if(fillStringVector(elt0,tmmp))
5587 //DataArrayAsciiChar.New(["abc","de","fghi"])
5588 return DataArrayAsciiChar::New(tmmp,' ');
5591 // DataArrayAsciiChar.New([1,3,4])
5592 MCAuto<DataArrayAsciiChar> ret=DataArrayAsciiChar::New();
5593 int tmpp1=-1,tmpp2=-1;
5594 std::vector<int> tmp=fillArrayWithPyListInt2(elt0,tmpp1,tmpp2);
5595 ret->alloc(tmpp1,tmpp2); std::copy(tmp.begin(),tmp.end(),ret->getPointer());
5600 else if(PyInt_Check(elt0))
5602 int nbOfTuples1=PyInt_AS_LONG(elt0);
5604 throw INTERP_KERNEL::Exception("DataArrayAsciiChar::New : should be a positive set of allocated memory !");
5609 if(PyInt_Check(nbOfTuples))
5610 {//DataArrayAsciiChar.New(5,2)
5611 int nbOfCompo=PyInt_AS_LONG(nbOfTuples);
5613 throw INTERP_KERNEL::Exception("DataArrayAsciiChar::New : should be a positive number of components !");
5614 MCAuto<DataArrayAsciiChar> ret=DataArrayAsciiChar::New();
5615 ret->alloc(nbOfTuples1,nbOfCompo);
5619 throw INTERP_KERNEL::Exception(msg);
5622 throw INTERP_KERNEL::Exception(msg);
5625 {//DataArrayAsciiChar.New(5)
5626 MCAuto<DataArrayAsciiChar> ret=DataArrayAsciiChar::New();
5627 ret->alloc(nbOfTuples1,1);
5632 throw INTERP_KERNEL::Exception(msg);
5635 DataArrayAsciiChar(PyObject *elt0, PyObject *nbOfTuples=0, PyObject *nbOfComp=0)
5637 return MEDCoupling_DataArrayAsciiChar_New__SWIG_1(elt0,nbOfTuples,nbOfComp);
5640 std::string __repr__() const
5642 std::ostringstream oss;
5643 self->reprQuickOverview(oss);
5647 DataArrayAsciiCharIterator *__iter__()
5649 return self->iterator();
5652 std::string getIJ(int tupleId, int compoId) const
5654 char tmp[2]; tmp[1]='\0';
5655 tmp[0]=self->getIJ(tupleId,compoId);
5656 return std::string(tmp);
5659 std::string getIJSafe(int tupleId, int compoId) const
5661 char tmp[2]; tmp[1]='\0';
5662 tmp[0]=self->getIJSafe(tupleId,compoId);
5663 return std::string(tmp);
5666 std::string __str__() const
5668 return self->repr();
5671 PyObject *toStrList() const
5673 const char *vals=self->getConstPointer();
5674 int nbOfComp=self->getNumberOfComponents();
5675 int nbOfTuples=self->getNumberOfTuples();
5676 return convertCharArrToPyListOfTuple(vals,nbOfComp,nbOfTuples);
5679 bool presenceOfTuple(PyObject *tupl) const
5681 if(PyString_Check(tupl))
5683 Py_ssize_t sz=PyString_Size(tupl);
5684 std::vector<char> vals(sz);
5685 std::copy(PyString_AsString(tupl),PyString_AsString(tupl)+sz,vals.begin());
5686 return self->presenceOfTuple(vals);
5688 %#if PY_VERSION_HEX >= 0x03000000
5689 else if(PyUnicode_Check(tupl))
5691 Py_ssize_t sz=PyUnicode_GET_LENGTH(tupl);
5692 std::vector<char> vals(sz);
5693 std::copy(PyUnicode_AsUTF8(tupl),PyUnicode_AsUTF8(tupl)+sz,vals.begin());
5694 return self->presenceOfTuple(vals);
5698 throw INTERP_KERNEL::Exception("DataArrayAsciiChar::presenceOfTuple : only strings in input supported !");
5701 bool presenceOfValue(PyObject *vals) const
5703 if(PyString_Check(vals))
5705 Py_ssize_t sz=PyString_Size(vals);
5706 std::vector<char> vals2(sz);
5707 std::copy(PyString_AsString(vals),PyString_AsString(vals)+sz,vals2.begin());
5708 return self->presenceOfValue(vals2);
5710 %#if PY_VERSION_HEX >= 0x03000000
5711 if(PyUnicode_Check(vals))
5713 Py_ssize_t sz=PyUnicode_GET_LENGTH(vals);
5714 std::vector<char> vals2(sz);
5715 std::copy(PyUnicode_AsUTF8(vals),PyUnicode_AsUTF8(vals)+sz,vals2.begin());
5716 return self->presenceOfValue(vals2);
5720 throw INTERP_KERNEL::Exception("DataArrayAsciiChar::presenceOfValue : only strings in input supported !");
5723 int findIdFirstEqual(PyObject *vals) const
5725 if(PyString_Check(vals))
5727 Py_ssize_t sz=PyString_Size(vals);
5728 std::vector<char> vals2(sz);
5729 std::copy(PyString_AsString(vals),PyString_AsString(vals)+sz,vals2.begin());
5730 return self->findIdFirstEqual(vals2);
5732 %#if PY_VERSION_HEX >= 0x03000000
5733 if(PyUnicode_Check(vals))
5735 Py_ssize_t sz=PyUnicode_GET_LENGTH(vals);
5736 std::vector<char> vals2(sz);
5737 std::copy(PyUnicode_AsUTF8(vals),PyUnicode_AsUTF8(vals)+sz,vals2.begin());
5738 return self->findIdFirstEqual(vals2);
5742 throw INTERP_KERNEL::Exception("DataArrayAsciiChar::findIdFirstEqual : only strings in input supported !");
5745 int findIdFirstEqualTuple(PyObject *tupl) const
5747 if(PyString_Check(tupl))
5749 Py_ssize_t sz=PyString_Size(tupl);
5750 std::vector<char> vals(sz);
5751 std::copy(PyString_AsString(tupl),PyString_AsString(tupl)+sz,vals.begin());
5752 return self->findIdFirstEqualTuple(vals);
5754 %#if PY_VERSION_HEX >= 0x03000000
5755 if(PyUnicode_Check(tupl))
5757 Py_ssize_t sz=PyUnicode_GET_LENGTH(tupl);
5758 std::vector<char> vals(sz);
5759 std::copy(PyUnicode_AsUTF8(tupl),PyUnicode_AsUTF8(tupl)+sz,vals.begin());
5760 return self->findIdFirstEqualTuple(vals);
5764 throw INTERP_KERNEL::Exception("DataArrayAsciiChar::findIdFirstEqualTuple : only strings in input supported !");
5767 int findIdSequence(PyObject *strOrListOfInt) const
5769 if(PyString_Check(strOrListOfInt))
5771 Py_ssize_t sz=PyString_Size(strOrListOfInt);
5772 std::vector<char> vals(sz);
5773 std::copy(PyString_AsString(strOrListOfInt),PyString_AsString(strOrListOfInt)+sz,vals.begin());
5774 return self->findIdSequence(vals);
5776 %#if PY_VERSION_HEX >= 0x03000000
5777 else if(PyUnicode_Check(strOrListOfInt))
5779 Py_ssize_t sz=PyUnicode_GET_LENGTH(strOrListOfInt);
5780 std::vector<char> vals(sz);
5781 std::copy(PyUnicode_AsUTF8(strOrListOfInt),PyUnicode_AsUTF8(strOrListOfInt)+sz,vals.begin());
5782 return self->findIdSequence(vals);
5786 throw INTERP_KERNEL::Exception("DataArrayAsciiChar::search : only strings in input supported !");
5789 PyObject *getTuple(int tupleId) const
5791 int sz=self->getNumberOfComponents();
5792 INTERP_KERNEL::AutoPtr<char> tmp=new char[sz+1]; tmp[sz]='\0';
5793 self->getTuple(tupleId,tmp);
5794 return PyString_FromString(tmp);
5797 PyObject *getMaxValue() const
5800 char tmp2[2]; tmp2[1]='\0';
5801 tmp2[0]=self->getMaxValue(tmp);
5802 PyObject *ret=PyTuple_New(2);
5803 PyTuple_SetItem(ret,0,PyString_FromString(tmp2));
5804 PyTuple_SetItem(ret,1,PyInt_FromLong(tmp));
5808 PyObject *getMinValue() const
5811 char tmp2[2]; tmp2[1]='\0';
5812 tmp2[0]=self->getMinValue(tmp);
5813 PyObject *ret=PyTuple_New(2);
5814 PyTuple_SetItem(ret,0,PyString_FromString(tmp2));
5815 PyTuple_SetItem(ret,1,PyInt_FromLong(tmp));
5819 int index(PyObject *obj) const
5821 int nbOfCompo=self->getNumberOfComponents();
5826 if(PyString_Check(obj))
5828 Py_ssize_t sz=PyString_Size(obj);
5829 char *pt=PyString_AsString(obj);
5831 return self->findIdFirstEqual(pt[0]);
5833 throw INTERP_KERNEL::Exception("DataArrayAsciiChar::index : 'this' contains one component and trying to find a string with size different from 1 !");
5835 %#if PY_VERSION_HEX >= 0x03000000
5836 if(PyUnicode_Check(obj))
5839 char *pt=PyUnicode_AsUTF8AndSize(obj, &sz);
5841 return self->findIdFirstEqual(pt[0]);
5843 throw INTERP_KERNEL::Exception("DataArrayAsciiChar::index : 'this' contains one component and trying to find a string with size different from 1 !");
5847 throw INTERP_KERNEL::Exception("DataArrayAsciiChar::index : 'this' contains one component and trying to find an element which is not an integer !");
5850 return MEDCoupling_DataArrayAsciiChar_findIdFirstEqualTuple(self,obj);
5854 bool __contains__(PyObject *obj) const
5856 int nbOfCompo=self->getNumberOfComponents();
5863 if(PyString_Check(obj))
5865 Py_ssize_t sz=PyString_Size(obj);
5866 char *pt=PyString_AsString(obj);
5868 return self->presenceOfValue(pt[0]);
5870 throw INTERP_KERNEL::Exception("DataArrayAsciiChar::__contains__ : 'this' contains one component and trying to find a string with size different from 1 !");
5872 %#if PY_VERSION_HEX >= 0x03000000
5873 if(PyUnicode_Check(obj))
5876 char *pt=PyUnicode_AsUTF8AndSize(obj, &sz);
5878 return self->presenceOfValue(pt[0]);
5880 throw INTERP_KERNEL::Exception("DataArrayAsciiChar::__contains__ : 'this' contains one component and trying to find a string with size different from 1 !");
5884 throw INTERP_KERNEL::Exception("DataArrayAsciiChar::__contains__ : 'this' contains one component and trying to find an element which is not an integer !");
5887 return MEDCoupling_DataArrayAsciiChar_presenceOfTuple(self,obj);
5891 PyObject *__getitem__(PyObject *obj) const
5894 std::vector<int> stdvecTyyppArr;
5895 std::pair<int, std::pair<int,int> > sTyyppArr;
5896 MEDCoupling::DataArrayInt *daIntTyypp=0;
5897 convertIntStarOrSliceLikePyObjToCppWithNegIntInterp(obj,self->getNumberOfTuples(),sw,iTypppArr,stdvecTyyppArr,sTyyppArr,daIntTyypp);
5901 return MEDCoupling_DataArrayAsciiChar_getTuple(self,iTypppArr);
5903 return convertDataArrayChar(self->selectByTupleIdSafe(&stdvecTyyppArr[0],&stdvecTyyppArr[0]+stdvecTyyppArr.size()), SWIG_POINTER_OWN | 0 );
5905 return convertDataArrayChar(self->selectByTupleIdSafeSlice(sTyyppArr.first,sTyyppArr.second.first,sTyyppArr.second.second), SWIG_POINTER_OWN | 0 );
5907 return convertDataArrayChar(self->selectByTupleIdSafe(daIntTyypp->begin(),daIntTyypp->end()), SWIG_POINTER_OWN | 0 );
5909 throw INTERP_KERNEL::Exception("DataArrayAsciiChar::__getitem__ : supporting int, list of int, tuple of int, DataArrayInt and slice in input !");
5913 DataArrayAsciiChar *__setitem__(PyObject *obj, PyObject *value)
5915 static const char msg[]="DataArrayAsciiChar::__setitem__ : supporting int, list of int, tuple of int, DataArrayInt and slice in input, and 4 types accepted in value : string, list or tuple of strings having same size, not null DataArrayChar instance.";
5917 std::vector<int> stdvecTyyppArr;
5918 std::pair<int, std::pair<int,int> > sTyyppArr;
5919 MEDCoupling::DataArrayInt *daIntTyypp=0;
5920 int nbOfCompo=self->getNumberOfComponents();
5921 int nbOfTuples=self->getNumberOfTuples();
5922 convertIntStarOrSliceLikePyObjToCppWithNegIntInterp(obj,nbOfTuples,sw1,iTypppArr,stdvecTyyppArr,sTyyppArr,daIntTyypp);
5924 char vc; std::string sc; std::vector<std::string> vsc; DataArrayChar *dacc=0;
5925 convertObjToPossibleCpp6(value,sw2,vc,sc,vsc,dacc);
5934 self->setPartOfValuesSimple3(vc,&iTypppArr,&iTypppArr+1,0,nbOfCompo,1);
5940 MCAuto<DataArrayAsciiChar> tmp=DataArrayAsciiChar::New(sc);
5941 self->setPartOfValues3(tmp,&iTypppArr,&iTypppArr+1,0,nbOfCompo,1,false);
5944 //value vector<string>
5947 MCAuto<DataArrayAsciiChar> tmp=DataArrayAsciiChar::New(vsc,' ');
5948 self->setPartOfValues3(tmp,&iTypppArr,&iTypppArr+1,0,nbOfCompo,1,false);
5951 //value DataArrayChar
5954 self->setPartOfValues3(dacc,&iTypppArr,&iTypppArr+1,0,nbOfCompo,1,false);
5958 throw INTERP_KERNEL::Exception(msg);
5962 {//obj list-tuple[int]
5968 self->setPartOfValuesSimple3(vc,&stdvecTyyppArr[0],&stdvecTyyppArr[0]+stdvecTyyppArr.size(),0,nbOfCompo,1);
5974 MCAuto<DataArrayAsciiChar> tmp=DataArrayAsciiChar::New(sc);
5975 self->setPartOfValues3(tmp,&stdvecTyyppArr[0],&stdvecTyyppArr[0]+stdvecTyyppArr.size(),0,nbOfCompo,1,false);
5978 //value vector<string>
5981 MCAuto<DataArrayAsciiChar> tmp=DataArrayAsciiChar::New(vsc,' ');
5982 self->setPartOfValues3(tmp,&stdvecTyyppArr[0],&stdvecTyyppArr[0]+stdvecTyyppArr.size(),0,nbOfCompo,1,false);
5985 //value DataArrayChar
5988 self->setPartOfValues3(dacc,&stdvecTyyppArr[0],&stdvecTyyppArr[0]+stdvecTyyppArr.size(),0,nbOfCompo,1,false);
5992 throw INTERP_KERNEL::Exception(msg);
6003 self->setPartOfValuesSimple1(vc,sTyyppArr.first,sTyyppArr.second.first,sTyyppArr.second.second,0,nbOfCompo,1);
6009 MCAuto<DataArrayAsciiChar> tmp=DataArrayAsciiChar::New(sc);
6010 self->setPartOfValues1(tmp,sTyyppArr.first,sTyyppArr.second.first,sTyyppArr.second.second,0,nbOfCompo,1,false);
6013 //value vector<string>
6016 MCAuto<DataArrayAsciiChar> tmp=DataArrayAsciiChar::New(vsc,' ');
6017 self->setPartOfValues1(tmp,sTyyppArr.first,sTyyppArr.second.first,sTyyppArr.second.second,0,nbOfCompo,1,false);
6020 //value DataArrayChar
6023 self->setPartOfValues1(dacc,sTyyppArr.first,sTyyppArr.second.first,sTyyppArr.second.second,0,nbOfCompo,1,false);
6027 throw INTERP_KERNEL::Exception(msg);
6038 self->setPartOfValuesSimple3(vc,daIntTyypp->begin(),daIntTyypp->end(),0,nbOfCompo,1);
6044 MCAuto<DataArrayAsciiChar> tmp=DataArrayAsciiChar::New(sc);
6045 self->setPartOfValues3(tmp,daIntTyypp->begin(),daIntTyypp->end(),0,nbOfCompo,1,false);
6048 //value vector<string>
6051 MCAuto<DataArrayAsciiChar> tmp=DataArrayAsciiChar::New(vsc,' ');
6052 self->setPartOfValues3(tmp,daIntTyypp->begin(),daIntTyypp->end(),0,nbOfCompo,1,false);
6055 //value DataArrayChar
6058 self->setPartOfValues3(dacc,daIntTyypp->begin(),daIntTyypp->end(),0,nbOfCompo,1,false);
6062 throw INTERP_KERNEL::Exception(msg);
6067 throw INTERP_KERNEL::Exception(msg);
6073 class DataArrayAsciiCharTuple;
6075 class DataArrayAsciiCharIterator
6078 DataArrayAsciiCharIterator(DataArrayAsciiChar *da);
6079 ~DataArrayAsciiCharIterator();
6084 DataArrayAsciiCharTuple *ret=self->nextt();
6086 return SWIG_NewPointerObj(SWIG_as_voidptr(ret),SWIGTYPE_p_MEDCoupling__DataArrayAsciiCharTuple,SWIG_POINTER_OWN | 0);
6089 PyErr_SetString(PyExc_StopIteration,"No more data.");
6096 class DataArrayAsciiCharTuple
6099 int getNumberOfCompo() const;
6100 DataArrayAsciiChar *buildDAAsciiChar(int nbOfTuples, int nbOfCompo) const;
6103 std::string __str__() const
6105 return self->repr();
6108 DataArrayAsciiChar *buildDAAsciiChar()
6110 return self->buildDAAsciiChar(1,self->getNumberOfCompo());
6117 def MEDCouplingStdReduceFunct(cls,params):
6119 ret=object.__new__(cls)
6124 def MEDCouplingDataArrayDoubleReduce(self):
6125 if not MEDCouplingHasNumPyBindings():
6126 raise InterpKernelException("PyWrap of DataArrayDouble.__reduce__ : not implemented because numpy is not active in your configuration ! No serialization/unserialization available without numpy !")
6127 return MEDCouplingStdReduceFunct,(DataArrayDouble,((self.toNumPyArray(),),(self.__getstate__()),))
6129 def MEDCouplingDataArrayIntReduce(self):
6130 if not MEDCouplingHasNumPyBindings():
6131 raise InterpKernelException("PyWrap of DataArrayInt.__reduce__ : not implemented because numpy is not active in your configuration ! No serialization/unserialization available without numpy !")
6132 return MEDCouplingStdReduceFunct,(DataArrayInt,((self.toNumPyArray(),),(self.__getstate__()),))
6134 def MEDCouplingDataArrayByteReduce(self):
6135 if not MEDCouplingHasNumPyBindings():
6136 raise InterpKernelException("PyWrap of DataArrayByte.__reduce__ : not implemented because numpy is not active in your configuration ! No serialization/unserialization available without numpy !")
6137 return MEDCouplingStdReduceFunct,(DataArrayByte,((self.toNumPyArray(),),(self.__getstate__()),))
6139 def MEDCouplingDataArrayFloatReduce(self):
6140 if not MEDCouplingHasNumPyBindings():
6141 raise InterpKernelException("PyWrap of DataArrayFloat.__reduce__ : not implemented because numpy is not active in your configuration ! No serialization/unserialization available without numpy !")
6142 return MEDCouplingStdReduceFunct,(DataArrayFloat,((self.toNumPyArray(),),(self.__getstate__()),))