]> SALOME platform Git repositories - tools/medcoupling.git/blob - src/MEDCoupling/MEDCouplingMemArray.hxx
Salome HOME
aea13c23df3e652f97ecae4291da51ec35758c9f
[tools/medcoupling.git] / src / MEDCoupling / MEDCouplingMemArray.hxx
1 // Copyright (C) 2007-2016  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 // Author : Anthony Geay (CEA/DEN)
20
21 #ifndef __MEDCOUPLING_MEDCOUPLINGMEMARRAY_HXX__
22 #define __MEDCOUPLING_MEDCOUPLINGMEMARRAY_HXX__
23
24 #include "MEDCoupling.hxx"
25 #include "MCAuto.hxx"
26 #include "MEDCouplingTimeLabel.hxx"
27 #include "MEDCouplingRefCountObject.hxx"
28 #include "InterpKernelException.hxx"
29 #include "MEDCouplingTraits.hxx"
30 #include "BBTreePts.txx"
31
32 #include <string>
33 #include <vector>
34 #include <iterator>
35
36 namespace MEDCoupling
37 {
38   typedef enum
39     {
40       AX_CART = 3,
41       AX_CYL = 4,
42       AX_SPHER = 5
43     } MEDCouplingAxisType;
44   // -- WARNING this enum must be synchronized with MEDCouplingCommon.i file ! --
45
46   template<class T>
47   class MEDCouplingPointer
48   {
49   public:
50     MEDCouplingPointer():_internal(0),_external(0) { }
51     void null() { _internal=0; _external=0; }
52     bool isNull() const { return _internal==0 && _external==0; }
53     void setInternal(T *pointer);
54     void setExternal(const T *pointer);
55     const T *getConstPointer() const { if(_internal) return _internal; else return _external; }
56     const T *getConstPointerLoc(std::size_t offset) const { if(_internal) return _internal+offset; else return _external+offset; }
57     T *getPointer() { if(_internal) return _internal; if(_external) throw INTERP_KERNEL::Exception("Trying to write on an external pointer."); else return 0; }
58   private:
59     T *_internal;
60     const T *_external;
61   };
62
63   template<class T>
64   class MemArray
65   {
66   public:
67     typedef void (*Deallocator)(void *,void *);
68   public:
69     MemArray():_nb_of_elem(0),_nb_of_elem_alloc(0),_ownership(false),_dealloc(0),_param_for_deallocator(0) { }
70     MemArray(const MemArray<T>& other);
71     bool isNull() const { return _pointer.isNull(); }
72     const T *getConstPointerLoc(std::size_t offset) const { return _pointer.getConstPointerLoc(offset); }
73     const T *getConstPointer() const { return _pointer.getConstPointer(); }
74     std::size_t getNbOfElem() const { return _nb_of_elem; }
75     std::size_t getNbOfElemAllocated() const { return _nb_of_elem_alloc; }
76     T *getPointer() { return _pointer.getPointer(); }
77     MemArray<T> &operator=(const MemArray<T>& other);
78     T operator[](std::size_t id) const { return _pointer.getConstPointer()[id]; }
79     T& operator[](std::size_t id) { return _pointer.getPointer()[id]; }
80     bool isEqual(const MemArray<T>& other, T prec, std::string& reason) const;
81     void repr(int sl, std::ostream& stream) const;
82     bool reprHeader(int sl, std::ostream& stream) const;
83     void reprZip(int sl, std::ostream& stream) const;
84     void reprNotTooLong(int sl, std::ostream& stream) const;
85     void fillWithValue(const T& val);
86     T *fromNoInterlace(int nbOfComp) const;
87     T *toNoInterlace(int nbOfComp) const;
88     void sort(bool asc);
89     void reverse(int nbOfComp);
90     void alloc(std::size_t nbOfElements);
91     void reserve(std::size_t newNbOfElements);
92     void reAlloc(std::size_t newNbOfElements);
93     void useArray(const T *array, bool ownership, DeallocType type, std::size_t nbOfElem);
94     void useExternalArrayWithRWAccess(const T *array, std::size_t nbOfElem);
95     void writeOnPlace(std::size_t id, T element0, const T *others, std::size_t sizeOfOthers);
96     template<class InputIterator>
97     void insertAtTheEnd(InputIterator first, InputIterator last);
98     void pushBack(T elem);
99     T popBack();
100     void pack() const;
101     bool isDeallocatorCalled() const { return _ownership; }
102     Deallocator getDeallocator() const { return _dealloc; }
103     void setSpecificDeallocator(Deallocator dealloc) { _dealloc=dealloc; }
104     void setParameterForDeallocator(void *param) { _param_for_deallocator=param; }
105     void *getParameterForDeallocator() const { return _param_for_deallocator; }
106     void destroy();
107     ~MemArray() { destroy(); }
108   public:
109     static void CPPDeallocator(void *pt, void *param);
110     static void CDeallocator(void *pt, void *param);
111   private:
112     static void DestroyPointer(T *pt, Deallocator dealloc, void *param);
113     static Deallocator BuildFromType(DeallocType type);
114   private:
115     std::size_t _nb_of_elem;
116     std::size_t _nb_of_elem_alloc;
117     bool _ownership;
118     MEDCouplingPointer<T> _pointer;
119     Deallocator _dealloc;
120     void *_param_for_deallocator;
121   };
122
123   class DataArrayInt;
124   class DataArrayByte;
125
126   class DataArray : public RefCountObject, public TimeLabel
127   {
128   public:
129     MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
130     MEDCOUPLING_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
131     MEDCOUPLING_EXPORT void setName(const std::string& name);
132     MEDCOUPLING_EXPORT void copyStringInfoFrom(const DataArray& other);
133     MEDCOUPLING_EXPORT void copyPartOfStringInfoFrom(const DataArray& other, const std::vector<int>& compoIds);
134     MEDCOUPLING_EXPORT void copyPartOfStringInfoFrom2(const std::vector<int>& compoIds, const DataArray& other);
135     MEDCOUPLING_EXPORT bool areInfoEqualsIfNotWhy(const DataArray& other, std::string& reason) const;
136     MEDCOUPLING_EXPORT bool areInfoEquals(const DataArray& other) const;
137     MEDCOUPLING_EXPORT std::string cppRepr(const std::string& varName) const;
138     MEDCOUPLING_EXPORT std::string getName() const { return _name; }
139     MEDCOUPLING_EXPORT const std::vector<std::string> &getInfoOnComponents() const { return _info_on_compo; }
140     MEDCOUPLING_EXPORT std::vector<std::string> &getInfoOnComponents() { return _info_on_compo; }
141     MEDCOUPLING_EXPORT void setInfoOnComponents(const std::vector<std::string>& info);
142     MEDCOUPLING_EXPORT void setInfoAndChangeNbOfCompo(const std::vector<std::string>& info);
143     MEDCOUPLING_EXPORT std::vector<std::string> getVarsOnComponent() const;
144     MEDCOUPLING_EXPORT std::vector<std::string> getUnitsOnComponent() const;
145     MEDCOUPLING_EXPORT std::string getInfoOnComponent(int i) const;
146     MEDCOUPLING_EXPORT std::string getVarOnComponent(int i) const;
147     MEDCOUPLING_EXPORT std::string getUnitOnComponent(int i) const;
148     MEDCOUPLING_EXPORT void setInfoOnComponent(int i, const std::string& info);
149     MEDCOUPLING_EXPORT std::size_t getNumberOfComponents() const { return _info_on_compo.size(); }
150     MEDCOUPLING_EXPORT void setPartOfValuesBase3(const DataArray *aBase, const int *bgTuples, const int *endTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare=true);
151     MEDCOUPLING_EXPORT virtual void *getVoidStarPointer() = 0;
152     MEDCOUPLING_EXPORT virtual DataArray *deepCopy() const = 0;
153     MEDCOUPLING_EXPORT virtual DataArray *buildNewEmptyInstance() const = 0;
154     MEDCOUPLING_EXPORT virtual bool isAllocated() const = 0;
155     MEDCOUPLING_EXPORT virtual void checkAllocated() const = 0;
156     MEDCOUPLING_EXPORT virtual void desallocate() = 0;
157     MEDCOUPLING_EXPORT virtual int getNumberOfTuples() const = 0;
158     MEDCOUPLING_EXPORT virtual std::size_t getNbOfElems() const = 0;
159     MEDCOUPLING_EXPORT virtual std::size_t getNbOfElemAllocated() const = 0;
160     MEDCOUPLING_EXPORT virtual void alloc(std::size_t nbOfTuple, std::size_t nbOfCompo=1) = 0;
161     MEDCOUPLING_EXPORT virtual void reAlloc(std::size_t newNbOfTuple) = 0;
162     MEDCOUPLING_EXPORT virtual void renumberInPlace(const int *old2New) = 0;
163     MEDCOUPLING_EXPORT virtual void renumberInPlaceR(const int *new2Old) = 0;
164     MEDCOUPLING_EXPORT virtual void setContigPartOfSelectedValues(int tupleIdStart, const DataArray *aBase, const DataArrayInt *tuplesSelec) = 0;
165     MEDCOUPLING_EXPORT virtual void setContigPartOfSelectedValuesSlice(int tupleIdStart, const DataArray *aBase, int bg, int end2, int step) = 0;
166     MEDCOUPLING_EXPORT virtual DataArray *selectByTupleRanges(const std::vector<std::pair<int,int> >& ranges) const = 0;
167     MEDCOUPLING_EXPORT virtual DataArray *keepSelectedComponents(const std::vector<int>& compoIds) const = 0;
168     MEDCOUPLING_EXPORT virtual DataArray *selectByTupleId(const int *new2OldBg, const int *new2OldEnd) const = 0;
169     MEDCOUPLING_EXPORT virtual DataArray *selectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const = 0;
170     MEDCOUPLING_EXPORT virtual DataArray *selectByTupleIdSafeSlice(int bg, int end2, int step) const = 0;
171     MEDCOUPLING_EXPORT virtual void rearrange(int newNbOfCompo) = 0;
172     MEDCOUPLING_EXPORT virtual void circularPermutation(int nbOfShift=1) = 0;
173     MEDCOUPLING_EXPORT virtual void circularPermutationPerTuple(int nbOfShift=1) = 0;
174     MEDCOUPLING_EXPORT virtual void reversePerTuple() = 0;
175     MEDCOUPLING_EXPORT void checkNbOfTuples(int nbOfTuples, const std::string& msg) const;
176     MEDCOUPLING_EXPORT void checkNbOfComps(int nbOfCompo, const std::string& msg) const;
177     MEDCOUPLING_EXPORT void checkNbOfTuplesAndComp(const DataArray& other, const std::string& msg) const;
178     MEDCOUPLING_EXPORT void checkNbOfTuplesAndComp(int nbOfTuples, int nbOfCompo, const std::string& msg) const;
179     MEDCOUPLING_EXPORT void checkNbOfElems(std::size_t nbOfElems, const std::string& msg) const;
180     MEDCOUPLING_EXPORT static void GetSlice(int start, int stop, int step, int sliceId, int nbOfSlices, int& startSlice, int& stopSlice);
181     MEDCOUPLING_EXPORT static int GetNumberOfItemGivenBES(int begin, int end, int step, const std::string& msg);
182     MEDCOUPLING_EXPORT static int GetNumberOfItemGivenBESRelative(int begin, int end, int step, const std::string& msg);
183     MEDCOUPLING_EXPORT static int GetPosOfItemGivenBESRelativeNoThrow(int value, int begin, int end, int step);
184     MEDCOUPLING_EXPORT static std::string GetVarNameFromInfo(const std::string& info);
185     MEDCOUPLING_EXPORT static std::string GetUnitFromInfo(const std::string& info);
186     MEDCOUPLING_EXPORT static std::string BuildInfoFromVarAndUnit(const std::string& var, const std::string& unit);
187     MEDCOUPLING_EXPORT static std::string GetAxisTypeRepr(MEDCouplingAxisType at);
188     MEDCOUPLING_EXPORT static DataArray *Aggregate(const std::vector<const DataArray *>& arrs);
189     MEDCOUPLING_EXPORT virtual void reprStream(std::ostream& stream) const = 0;
190     MEDCOUPLING_EXPORT virtual void reprZipStream(std::ostream& stream) const = 0;
191     MEDCOUPLING_EXPORT virtual void reprWithoutNameStream(std::ostream& stream) const;
192     MEDCOUPLING_EXPORT virtual void reprZipWithoutNameStream(std::ostream& stream) const = 0;
193     MEDCOUPLING_EXPORT virtual void reprCppStream(const std::string& varName, std::ostream& stream) const = 0;
194     MEDCOUPLING_EXPORT virtual void reprQuickOverview(std::ostream& stream) const = 0;
195     MEDCOUPLING_EXPORT virtual void reprQuickOverviewData(std::ostream& stream, std::size_t maxNbOfByteInRepr) const = 0;
196   protected:
197     DataArray() { }
198     ~DataArray() { }
199   protected:
200     MEDCOUPLING_EXPORT static void CheckValueInRange(int ref, int value, const std::string& msg);
201     MEDCOUPLING_EXPORT static void CheckValueInRangeEx(int value, int start, int end, const std::string& msg);
202     MEDCOUPLING_EXPORT static void CheckClosingParInRange(int ref, int value, const std::string& msg);
203     MEDCOUPLING_EXPORT static int EffectiveCircPerm(int nbOfShift, int nbOfTuples);
204   protected:
205     std::string _name;
206     std::vector<std::string> _info_on_compo;
207   };
208 }
209
210 namespace MEDCoupling
211 {
212   class DataArrayInt;
213
214   template<class T>
215   class DataArrayTemplate : public DataArray
216   {
217   public:
218     MEDCOUPLING_EXPORT static MCAuto< typename Traits<T>::ArrayTypeCh > NewFromStdVector(const typename std::vector<T>& v);
219     MEDCOUPLING_EXPORT std::vector< MCAuto< typename Traits<T>::ArrayTypeCh > > explodeComponents() const;
220     //
221     std::size_t getHeapMemorySizeWithoutChildren() const;
222     //
223     MEDCOUPLING_EXPORT int getNumberOfTuples() const { return _info_on_compo.empty()?0:_mem.getNbOfElem()/getNumberOfComponents(); }
224     MEDCOUPLING_EXPORT std::size_t getNbOfElems() const { return _mem.getNbOfElem(); }
225     bool empty() const;
226     MEDCOUPLING_EXPORT void *getVoidStarPointer() { return getPointer(); }
227     MEDCOUPLING_EXPORT const T *getConstPointer() const { return _mem.getConstPointer(); }
228     MEDCOUPLING_EXPORT const T *begin() const { return getConstPointer(); }
229     MEDCOUPLING_EXPORT const T *end() const { return getConstPointer()+getNbOfElems(); }
230     void alloc(std::size_t nbOfTuple, std::size_t nbOfCompo=1);
231     void useArray(const T *array, bool ownership, DeallocType type, int nbOfTuple, int nbOfCompo);
232     void useExternalArrayWithRWAccess(const T *array, int nbOfTuple, int nbOfCompo);
233     T getIJSafe(int tupleId, int compoId) const;
234     MEDCOUPLING_EXPORT T getIJ(int tupleId, int compoId) const { return _mem[tupleId*_info_on_compo.size()+compoId]; }
235     MEDCOUPLING_EXPORT void setIJ(int tupleId, int compoId, T newVal) { _mem[tupleId*_info_on_compo.size()+compoId]=newVal; declareAsNew(); }
236     MEDCOUPLING_EXPORT void setIJSilent(int tupleId, int compoId, T newVal) { _mem[tupleId*_info_on_compo.size()+compoId]=newVal; }
237     MEDCOUPLING_EXPORT T *getPointer() { return _mem.getPointer(); declareAsNew(); }
238     void pack() const;
239     bool isAllocated() const;
240     void checkAllocated() const;
241     void desallocate();
242     void reserve(std::size_t nbOfElems);
243     void rearrange(int newNbOfCompo);
244     void transpose();
245     void pushBackSilent(T val);
246     void pushBackValsSilent(const T *valsBg, const T *valsEnd);
247     T popBackSilent();
248     T front() const;
249     T back() const;
250     std::size_t getNbOfElemAllocated() const { return _mem.getNbOfElemAllocated(); }
251     void allocIfNecessary(int nbOfTuple, int nbOfCompo);
252     void deepCopyFrom(const DataArrayTemplate<T>& other);
253     void reverse();
254     void fillWithValue(T val);
255     void reAlloc(std::size_t newNbOfTuple);
256     void renumberInPlace(const int *old2New);
257     void renumberInPlaceR(const int *new2Old);
258     void sort(bool asc=true);
259     typename Traits<T>::ArrayType *renumber(const int *old2New) const;
260     typename Traits<T>::ArrayType *renumberR(const int *new2Old) const;
261     typename Traits<T>::ArrayType *renumberAndReduce(const int *old2New, int newNbOfTuple) const;
262     typename Traits<T>::ArrayType *changeNbOfComponents(int newNbOfComp, T dftValue) const;
263     typename Traits<T>::ArrayType *subArray(int tupleIdBg, int tupleIdEnd=-1) const;
264     void circularPermutation(int nbOfShift=1);
265     void circularPermutationPerTuple(int nbOfShift=1);
266     void reversePerTuple();
267     void setPartOfValues1(const typename Traits<T>::ArrayType *a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare=true);
268     void setPartOfValuesSimple1(T a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp);
269     void setPartOfValues2(const typename Traits<T>::ArrayType *a, const int *bgTuples, const int *endTuples, const int *bgComp, const int *endComp, bool strictCompoCompare=true);
270     void setPartOfValuesSimple2(T a, const int *bgTuples, const int *endTuples, const int *bgComp, const int *endComp);
271     void setPartOfValues3(const typename Traits<T>::ArrayType *a, const int *bgTuples, const int *endTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare=true);
272     void setPartOfValuesSimple3(T a, const int *bgTuples, const int *endTuples, int bgComp, int endComp, int stepComp);
273     void setPartOfValues4(const typename Traits<T>::ArrayType *a, int bgTuples, int endTuples, int stepTuples, const int *bgComp, const int *endComp, bool strictCompoCompare=true);
274     void setPartOfValuesSimple4(T a, int bgTuples, int endTuples, int stepTuples, const int *bgComp, const int *endComp);
275     void setPartOfValuesAdv(const typename Traits<T>::ArrayType *a, const DataArrayInt *tuplesSelec);
276     void setContigPartOfSelectedValues(int tupleIdStart, const DataArray *aBase, const DataArrayInt *tuplesSelec);
277     void setContigPartOfSelectedValuesSlice(int tupleIdStart, const DataArray *aBase, int bg, int end2, int step);
278     T getMaxValue(int& tupleId) const;
279     T getMaxValueInArray() const;
280     T getMinValue(int& tupleId) const;
281     T getMinValueInArray() const;
282   protected:
283     typename Traits<T>::ArrayType *mySelectByTupleId(const int *new2OldBg, const int *new2OldEnd) const;
284     typename Traits<T>::ArrayType *mySelectByTupleId(const DataArrayInt& di) const;
285     typename Traits<T>::ArrayType *mySelectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const;
286     typename Traits<T>::ArrayType *myKeepSelectedComponents(const std::vector<int>& compoIds) const;
287     typename Traits<T>::ArrayType *mySelectByTupleIdSafeSlice(int bg, int end2, int step) const;
288     typename Traits<T>::ArrayType *mySelectByTupleRanges(const std::vector<std::pair<int,int> >& ranges) const;
289   protected:
290     MemArray<T> _mem;
291   };
292 }
293
294 namespace MEDCoupling
295 {
296   class DataArrayDoubleIterator;
297   class DataArrayDouble : public DataArrayTemplate<double>
298   {
299   public:
300     MEDCOUPLING_EXPORT static DataArrayDouble *New();
301     MEDCOUPLING_EXPORT double doubleValue() const;
302     MEDCOUPLING_EXPORT DataArrayDouble *deepCopy() const;
303     MEDCOUPLING_EXPORT DataArrayDouble *buildNewEmptyInstance() const { return DataArrayDouble::New(); }
304     MEDCOUPLING_EXPORT DataArrayDouble *performCopyOrIncrRef(bool deepCopy) const;
305     MEDCOUPLING_EXPORT void fillWithZero();
306     MEDCOUPLING_EXPORT void iota(double init=0.);
307     MEDCOUPLING_EXPORT bool isUniform(double val, double eps) const;
308     MEDCOUPLING_EXPORT void checkMonotonic(bool increasing, double eps) const;
309     MEDCOUPLING_EXPORT bool isMonotonic(bool increasing, double eps) const;
310     MEDCOUPLING_EXPORT std::string repr() const;
311     MEDCOUPLING_EXPORT std::string reprZip() const;
312     MEDCOUPLING_EXPORT std::string reprNotTooLong() const;
313     MEDCOUPLING_EXPORT void writeVTK(std::ostream& ofs, int indent, const std::string& nameInFile, DataArrayByte *byteArr) const;
314     MEDCOUPLING_EXPORT void reprStream(std::ostream& stream) const;
315     MEDCOUPLING_EXPORT void reprZipStream(std::ostream& stream) const;
316     MEDCOUPLING_EXPORT void reprNotTooLongStream(std::ostream& stream) const;
317     MEDCOUPLING_EXPORT void reprWithoutNameStream(std::ostream& stream) const;
318     MEDCOUPLING_EXPORT void reprZipWithoutNameStream(std::ostream& stream) const;
319     MEDCOUPLING_EXPORT void reprNotTooLongWithoutNameStream(std::ostream& stream) const;
320     MEDCOUPLING_EXPORT void reprCppStream(const std::string& varName, std::ostream& stream) const;
321     MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const;
322     MEDCOUPLING_EXPORT void reprQuickOverviewData(std::ostream& stream, std::size_t maxNbOfByteInRepr) const;
323     MEDCOUPLING_EXPORT bool isEqual(const DataArrayDouble& other, double prec) const;
324     MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const DataArrayDouble& other, double prec, std::string& reason) const;
325     MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const DataArrayDouble& other, double prec) const;
326     MEDCOUPLING_EXPORT DataArrayInt *convertToIntArr() const;
327     MEDCOUPLING_EXPORT DataArrayDouble *fromNoInterlace() const;
328     MEDCOUPLING_EXPORT DataArrayDouble *toNoInterlace() const;
329     MEDCOUPLING_EXPORT DataArrayDouble *selectByTupleId(const int *new2OldBg, const int *new2OldEnd) const { return DataArrayTemplate<double>::mySelectByTupleId(new2OldBg,new2OldEnd); }
330     MEDCOUPLING_EXPORT DataArrayDouble *selectByTupleId(const DataArrayInt& di) const { return DataArrayTemplate<double>::mySelectByTupleId(di); }
331     MEDCOUPLING_EXPORT DataArrayDouble *selectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const { return DataArrayTemplate<double>::mySelectByTupleIdSafe(new2OldBg,new2OldEnd); }
332     MEDCOUPLING_EXPORT DataArrayDouble *keepSelectedComponents(const std::vector<int>& compoIds) const { return DataArrayTemplate<double>::myKeepSelectedComponents(compoIds); }
333     MEDCOUPLING_EXPORT DataArrayDouble *selectByTupleIdSafeSlice(int bg, int end2, int step) const { return DataArrayTemplate<double>::mySelectByTupleIdSafeSlice(bg,end2,step); }
334     MEDCOUPLING_EXPORT DataArray *selectByTupleRanges(const std::vector<std::pair<int,int> >& ranges) const { return DataArrayTemplate<double>::mySelectByTupleRanges(ranges); }
335     MEDCOUPLING_EXPORT void meldWith(const DataArrayDouble *other);
336     MEDCOUPLING_EXPORT bool areIncludedInMe(const DataArrayDouble *other, double prec, DataArrayInt *&tupleIds) const;
337     MEDCOUPLING_EXPORT void findCommonTuples(double prec, int limitTupleId, DataArrayInt *&comm, DataArrayInt *&commIndex) const;
338     MEDCOUPLING_EXPORT double minimalDistanceTo(const DataArrayDouble *other, int& thisTupleId, int& otherTupleId) const;
339     MEDCOUPLING_EXPORT DataArrayDouble *duplicateEachTupleNTimes(int nbTimes) const;
340     MEDCOUPLING_EXPORT DataArrayDouble *getDifferentValues(double prec, int limitTupleId=-1) const;
341     MEDCOUPLING_EXPORT DataArrayInt *findClosestTupleId(const DataArrayDouble *other) const;
342     MEDCOUPLING_EXPORT DataArrayInt *computeNbOfInteractionsWith(const DataArrayDouble *otherBBoxFrmt, double eps) const;
343     MEDCOUPLING_EXPORT void setSelectedComponents(const DataArrayDouble *a, const std::vector<int>& compoIds);
344     MEDCOUPLING_EXPORT void getTuple(int tupleId, double *res) const { std::copy(_mem.getConstPointerLoc(tupleId*_info_on_compo.size()),_mem.getConstPointerLoc((tupleId+1)*_info_on_compo.size()),res); }
345     MEDCOUPLING_EXPORT static void SetArrayIn(DataArrayDouble *newArray, DataArrayDouble* &arrayToSet);
346     MEDCOUPLING_EXPORT DataArrayDoubleIterator *iterator();
347     template<class InputIterator>
348     void insertAtTheEnd(InputIterator first, InputIterator last);
349     MEDCOUPLING_EXPORT void aggregate(const DataArrayDouble *other);
350     MEDCOUPLING_EXPORT void writeOnPlace(std::size_t id, double element0, const double *others, int sizeOfOthers) { _mem.writeOnPlace(id,element0,others,sizeOfOthers); }
351     MEDCOUPLING_EXPORT void checkNoNullValues() const;
352     MEDCOUPLING_EXPORT void getMinMaxPerComponent(double *bounds) const;
353     MEDCOUPLING_EXPORT DataArrayDouble *computeBBoxPerTuple(double epsilon=0.0) const;
354     MEDCOUPLING_EXPORT void computeTupleIdsNearTuples(const DataArrayDouble *other, double eps, DataArrayInt *& c, DataArrayInt *& cI) const;
355     MEDCOUPLING_EXPORT void recenterForMaxPrecision(double eps);
356     MEDCOUPLING_EXPORT double getMaxValue2(DataArrayInt*& tupleIds) const;
357     MEDCOUPLING_EXPORT double getMinValue2(DataArrayInt*& tupleIds) const;
358     MEDCOUPLING_EXPORT int count(double value, double eps) const;
359     MEDCOUPLING_EXPORT double getAverageValue() const;
360     MEDCOUPLING_EXPORT double norm2() const;
361     MEDCOUPLING_EXPORT double normMax() const;
362     MEDCOUPLING_EXPORT double normMin() const;
363     MEDCOUPLING_EXPORT void accumulate(double *res) const;
364     MEDCOUPLING_EXPORT double accumulate(int compId) const;
365     MEDCOUPLING_EXPORT DataArrayDouble *accumulatePerChunck(const int *bgOfIndex, const int *endOfIndex) const;
366     MEDCOUPLING_EXPORT double distanceToTuple(const double *tupleBg, const double *tupleEnd, int& tupleId) const;
367     MEDCOUPLING_EXPORT DataArrayDouble *fromPolarToCart() const;
368     MEDCOUPLING_EXPORT DataArrayDouble *fromCylToCart() const;
369     MEDCOUPLING_EXPORT DataArrayDouble *fromSpherToCart() const;
370     MEDCOUPLING_EXPORT DataArrayDouble *cartesianize(MEDCouplingAxisType atOfThis) const;
371     MEDCOUPLING_EXPORT DataArrayDouble *fromCartToPolar() const;
372     MEDCOUPLING_EXPORT DataArrayDouble *fromCartToCyl() const;
373     MEDCOUPLING_EXPORT DataArrayDouble *fromCartToSpher() const;
374     MEDCOUPLING_EXPORT DataArrayDouble *fromCartToCylGiven(const DataArrayDouble *coords, const double center[3], const double vect[3]) const;
375     MEDCOUPLING_EXPORT DataArrayDouble *doublyContractedProduct() const;
376     MEDCOUPLING_EXPORT DataArrayDouble *determinant() const;
377     MEDCOUPLING_EXPORT DataArrayDouble *eigenValues() const;
378     MEDCOUPLING_EXPORT DataArrayDouble *eigenVectors() const;
379     MEDCOUPLING_EXPORT DataArrayDouble *inverse() const;
380     MEDCOUPLING_EXPORT DataArrayDouble *trace() const;
381     MEDCOUPLING_EXPORT DataArrayDouble *deviator() const;
382     MEDCOUPLING_EXPORT DataArrayDouble *magnitude() const;
383     MEDCOUPLING_EXPORT DataArrayDouble *sumPerTuple() const;
384     MEDCOUPLING_EXPORT DataArrayDouble *maxPerTuple() const;
385     MEDCOUPLING_EXPORT DataArrayDouble *maxPerTupleWithCompoId(DataArrayInt* &compoIdOfMaxPerTuple) const;
386     MEDCOUPLING_EXPORT DataArrayDouble *buildEuclidianDistanceDenseMatrix() const;
387     MEDCOUPLING_EXPORT DataArrayDouble *buildEuclidianDistanceDenseMatrixWith(const DataArrayDouble *other) const;
388     MEDCOUPLING_EXPORT void sortPerTuple(bool asc);
389     MEDCOUPLING_EXPORT void abs();
390     MEDCOUPLING_EXPORT DataArrayDouble *computeAbs() const;
391     MEDCOUPLING_EXPORT void applyLin(double a, double b, int compoId);
392     MEDCOUPLING_EXPORT void applyLin(double a, double b);
393     MEDCOUPLING_EXPORT void applyInv(double numerator);
394     MEDCOUPLING_EXPORT void applyPow(double val);
395     MEDCOUPLING_EXPORT void applyRPow(double val);
396     MEDCOUPLING_EXPORT DataArrayDouble *negate() const;
397     MEDCOUPLING_EXPORT DataArrayDouble *applyFunc(int nbOfComp, FunctionToEvaluate func) const;
398     MEDCOUPLING_EXPORT DataArrayDouble *applyFunc(int nbOfComp, const std::string& func, bool isSafe=true) const;
399     MEDCOUPLING_EXPORT DataArrayDouble *applyFunc(const std::string& func, bool isSafe=true) const;
400     MEDCOUPLING_EXPORT void applyFuncOnThis(const std::string& func, bool isSafe=true);
401     MEDCOUPLING_EXPORT DataArrayDouble *applyFuncCompo(int nbOfComp, const std::string& func, bool isSafe=true) const;
402     MEDCOUPLING_EXPORT DataArrayDouble *applyFuncNamedCompo(int nbOfComp, const std::vector<std::string>& varsOrder, const std::string& func, bool isSafe=true) const;
403     MEDCOUPLING_EXPORT void applyFuncFast32(const std::string& func);
404     MEDCOUPLING_EXPORT void applyFuncFast64(const std::string& func);
405     MEDCOUPLING_EXPORT MCAuto<DataArrayDouble> symmetry3DPlane(const double point[3], const double normalVector[3]) const;
406     MEDCOUPLING_EXPORT DataArrayInt *findIdsInRange(double vmin, double vmax) const;
407     MEDCOUPLING_EXPORT DataArrayInt *findIdsNotInRange(double vmin, double vmax) const;
408     MEDCOUPLING_EXPORT static DataArrayDouble *Aggregate(const DataArrayDouble *a1, const DataArrayDouble *a2);
409     MEDCOUPLING_EXPORT static DataArrayDouble *Aggregate(const std::vector<const DataArrayDouble *>& arr);
410     MEDCOUPLING_EXPORT static DataArrayDouble *Meld(const DataArrayDouble *a1, const DataArrayDouble *a2);
411     MEDCOUPLING_EXPORT static DataArrayDouble *Meld(const std::vector<const DataArrayDouble *>& arr);
412     MEDCOUPLING_EXPORT static DataArrayDouble *Dot(const DataArrayDouble *a1, const DataArrayDouble *a2);
413     MEDCOUPLING_EXPORT static DataArrayDouble *CrossProduct(const DataArrayDouble *a1, const DataArrayDouble *a2);
414     MEDCOUPLING_EXPORT static DataArrayDouble *Max(const DataArrayDouble *a1, const DataArrayDouble *a2);
415     MEDCOUPLING_EXPORT static DataArrayDouble *Min(const DataArrayDouble *a1, const DataArrayDouble *a2);
416     MEDCOUPLING_EXPORT static DataArrayDouble *Add(const DataArrayDouble *a1, const DataArrayDouble *a2);
417     MEDCOUPLING_EXPORT void addEqual(const DataArrayDouble *other);
418     MEDCOUPLING_EXPORT static DataArrayDouble *Substract(const DataArrayDouble *a1, const DataArrayDouble *a2);
419     MEDCOUPLING_EXPORT void substractEqual(const DataArrayDouble *other);
420     MEDCOUPLING_EXPORT static DataArrayDouble *Multiply(const DataArrayDouble *a1, const DataArrayDouble *a2);
421     MEDCOUPLING_EXPORT void multiplyEqual(const DataArrayDouble *other);
422     MEDCOUPLING_EXPORT static DataArrayDouble *Divide(const DataArrayDouble *a1, const DataArrayDouble *a2);
423     MEDCOUPLING_EXPORT void divideEqual(const DataArrayDouble *other);
424     MEDCOUPLING_EXPORT static DataArrayDouble *Pow(const DataArrayDouble *a1, const DataArrayDouble *a2);
425     MEDCOUPLING_EXPORT void powEqual(const DataArrayDouble *other);
426     MEDCOUPLING_EXPORT void updateTime() const { }
427     MEDCOUPLING_EXPORT MemArray<double>& accessToMemArray() { return _mem; }
428     MEDCOUPLING_EXPORT const MemArray<double>& accessToMemArray() const { return _mem; }
429     MEDCOUPLING_EXPORT std::vector<bool> toVectorOfBool(double eps) const;
430     MEDCOUPLING_EXPORT static void Rotate2DAlg(const double *center, double angle, int nbNodes, const double *coordsIn, double *coordsOut);
431     MEDCOUPLING_EXPORT static void Rotate3DAlg(const double *center, const double *vect, double angle, int nbNodes, const double *coordsIn, double *coordsOut);
432     MEDCOUPLING_EXPORT static void Symmetry3DPlane(const double point[3], const double normalVector[3], int nbNodes, const double *coordsIn, double *coordsOut);
433     MEDCOUPLING_EXPORT static void GiveBaseForPlane(const double normalVector[3], double baseOfPlane[9]);
434   public:
435     MEDCOUPLING_EXPORT void getTinySerializationIntInformation(std::vector<int>& tinyInfo) const;
436     MEDCOUPLING_EXPORT void getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const;
437     MEDCOUPLING_EXPORT bool resizeForUnserialization(const std::vector<int>& tinyInfoI);
438     MEDCOUPLING_EXPORT void finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<std::string>& tinyInfoS);
439   public:
440     template<int SPACEDIM>
441     void findCommonTuplesAlg(const double *bbox, int nbNodes, int limitNodeId, double prec, DataArrayInt *c, DataArrayInt *cI) const;
442     template<int SPACEDIM>
443     static void FindClosestTupleIdAlg(const BBTreePts<SPACEDIM,int>& myTree, double dist, const double *pos, int nbOfTuples, const double *thisPt, int thisNbOfTuples, int *res);
444     template<int SPACEDIM>
445     static void FindTupleIdsNearTuplesAlg(const BBTreePts<SPACEDIM,int>& myTree, const double *pos, int nbOfTuples, double eps,
446                                           DataArrayInt *c, DataArrayInt *cI);
447   private:
448     ~DataArrayDouble() { }
449     DataArrayDouble() { }
450   };
451
452   class DataArrayDoubleTuple;
453
454   class DataArrayDoubleIterator
455   {
456   public:
457     MEDCOUPLING_EXPORT DataArrayDoubleIterator(DataArrayDouble *da);
458     MEDCOUPLING_EXPORT ~DataArrayDoubleIterator();
459     MEDCOUPLING_EXPORT DataArrayDoubleTuple *nextt();
460   private:
461     DataArrayDouble *_da;
462     double *_pt;
463     int _tuple_id;
464     int _nb_comp;
465     int _nb_tuple;
466   };
467
468   class DataArrayDoubleTuple
469   {
470   public:
471     MEDCOUPLING_EXPORT DataArrayDoubleTuple(double *pt, int nbOfComp);
472     MEDCOUPLING_EXPORT std::string repr() const;
473     MEDCOUPLING_EXPORT int getNumberOfCompo() const { return _nb_of_compo; }
474     MEDCOUPLING_EXPORT const double *getConstPointer() const { return  _pt; }
475     MEDCOUPLING_EXPORT double *getPointer() { return _pt; }
476     MEDCOUPLING_EXPORT double doubleValue() const;
477     MEDCOUPLING_EXPORT DataArrayDouble *buildDADouble(int nbOfTuples, int nbOfCompo) const;
478   private:
479     double *_pt;
480     int _nb_of_compo;
481   };
482
483   class DataArrayIntIterator;
484
485   class DataArrayInt : public DataArrayTemplate<int>
486   {
487   public:
488     MEDCOUPLING_EXPORT static DataArrayInt *New();
489     MEDCOUPLING_EXPORT int intValue() const;
490     MEDCOUPLING_EXPORT int getHashCode() const;
491     MEDCOUPLING_EXPORT DataArrayInt *deepCopy() const;
492     MEDCOUPLING_EXPORT DataArrayInt *performCopyOrIncrRef(bool deepCopy) const;
493     MEDCOUPLING_EXPORT DataArrayInt *buildNewEmptyInstance() const { return DataArrayInt::New(); }
494     MEDCOUPLING_EXPORT bool isEqual(const DataArrayInt& other) const;
495     MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const DataArrayInt& other, std::string& reason) const;
496     MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const DataArrayInt& other) const;
497     MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStrAndOrder(const DataArrayInt& other) const;
498     MEDCOUPLING_EXPORT bool isFittingWith(const std::vector<bool>& v) const;
499     MEDCOUPLING_EXPORT void switchOnTupleEqualTo(int val, std::vector<bool>& vec) const;
500     MEDCOUPLING_EXPORT void switchOnTupleNotEqualTo(int val, std::vector<bool>& vec) const;
501     MEDCOUPLING_EXPORT DataArrayInt *buildPermutationArr(const DataArrayInt& other) const;
502     MEDCOUPLING_EXPORT DataArrayInt *indicesOfSubPart(const DataArrayInt& partOfThis) const;
503     MEDCOUPLING_EXPORT DataArrayInt *sumPerTuple() const;
504     MEDCOUPLING_EXPORT void checkMonotonic(bool increasing) const;
505     MEDCOUPLING_EXPORT bool isMonotonic(bool increasing) const;
506     MEDCOUPLING_EXPORT void checkStrictlyMonotonic(bool increasing) const;
507     MEDCOUPLING_EXPORT bool isStrictlyMonotonic(bool increasing) const;
508     MEDCOUPLING_EXPORT void fillWithZero();
509     MEDCOUPLING_EXPORT void iota(int init=0);
510     MEDCOUPLING_EXPORT std::string repr() const;
511     MEDCOUPLING_EXPORT std::string reprZip() const;
512     MEDCOUPLING_EXPORT std::string reprNotTooLong() const;
513     MEDCOUPLING_EXPORT void writeVTK(std::ostream& ofs, int indent, const std::string& type, const std::string& nameInFile, DataArrayByte *byteArr) const;
514     MEDCOUPLING_EXPORT void reprStream(std::ostream& stream) const;
515     MEDCOUPLING_EXPORT void reprZipStream(std::ostream& stream) const;
516     MEDCOUPLING_EXPORT void reprNotTooLongStream(std::ostream& stream) const;
517     MEDCOUPLING_EXPORT void reprWithoutNameStream(std::ostream& stream) const;
518     MEDCOUPLING_EXPORT void reprZipWithoutNameStream(std::ostream& stream) const;
519     MEDCOUPLING_EXPORT void reprNotTooLongWithoutNameStream(std::ostream& stream) const;
520     MEDCOUPLING_EXPORT void reprCppStream(const std::string& varName, std::ostream& stream) const;
521     MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const;
522     MEDCOUPLING_EXPORT void reprQuickOverviewData(std::ostream& stream, std::size_t maxNbOfByteInRepr) const;
523     MEDCOUPLING_EXPORT void transformWithIndArr(const int *indArrBg, const int *indArrEnd);
524     MEDCOUPLING_EXPORT DataArrayInt *transformWithIndArrR(const int *indArrBg, const int *indArrEnd) const;
525     MEDCOUPLING_EXPORT void splitByValueRange(const int *arrBg, const int *arrEnd,
526                                               DataArrayInt *& castArr, DataArrayInt *& rankInsideCast, DataArrayInt *& castsPresent) const;
527     MEDCOUPLING_EXPORT bool isRange(int& strt, int& sttoopp, int& stteepp) const;
528     MEDCOUPLING_EXPORT DataArrayInt *invertArrayO2N2N2O(int newNbOfElem) const;
529     MEDCOUPLING_EXPORT DataArrayInt *invertArrayN2O2O2N(int oldNbOfElem) const;
530     MEDCOUPLING_EXPORT DataArrayInt *invertArrayO2N2N2OBis(int newNbOfElem) const;
531     MEDCOUPLING_EXPORT DataArrayDouble *convertToDblArr() const;
532     MEDCOUPLING_EXPORT DataArrayInt *fromNoInterlace() const;
533     MEDCOUPLING_EXPORT DataArrayInt *toNoInterlace() const;
534     MEDCOUPLING_EXPORT DataArrayInt *selectByTupleId(const int *new2OldBg, const int *new2OldEnd) const { return DataArrayTemplate<int>::mySelectByTupleId(new2OldBg,new2OldEnd); }
535     MEDCOUPLING_EXPORT DataArrayInt *selectByTupleId(const DataArrayInt& di) const { return DataArrayTemplate<int>::mySelectByTupleId(di); }
536     MEDCOUPLING_EXPORT DataArrayInt *selectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const { return DataArrayTemplate<int>::mySelectByTupleIdSafe(new2OldBg,new2OldEnd); }
537     MEDCOUPLING_EXPORT DataArrayInt *keepSelectedComponents(const std::vector<int>& compoIds) const { return DataArrayTemplate<int>::myKeepSelectedComponents(compoIds); }
538     MEDCOUPLING_EXPORT DataArrayInt *selectByTupleIdSafeSlice(int bg, int end, int step) const { return DataArrayTemplate<int>::mySelectByTupleIdSafeSlice(bg,end,step); }
539     MEDCOUPLING_EXPORT DataArray *selectByTupleRanges(const std::vector<std::pair<int,int> >& ranges) const { return DataArrayTemplate<int>::mySelectByTupleRanges(ranges); }
540     MEDCOUPLING_EXPORT DataArrayInt *checkAndPreparePermutation() const;
541     MEDCOUPLING_EXPORT static DataArrayInt *FindPermutationFromFirstToSecond(const DataArrayInt *ids1, const DataArrayInt *ids2);
542     MEDCOUPLING_EXPORT void changeSurjectiveFormat(int targetNb, DataArrayInt *&arr, DataArrayInt *&arrI) const;
543     MEDCOUPLING_EXPORT static DataArrayInt *ConvertIndexArrayToO2N(int nbOfOldTuples, const int *arr, const int *arrIBg, const int *arrIEnd, int &newNbOfTuples);
544     MEDCOUPLING_EXPORT DataArrayInt *buildPermArrPerLevel() const;
545     MEDCOUPLING_EXPORT bool isIota(int sizeExpected) const;
546     MEDCOUPLING_EXPORT bool isUniform(int val) const;
547     MEDCOUPLING_EXPORT bool hasUniqueValues() const;
548     MEDCOUPLING_EXPORT void meldWith(const DataArrayInt *other);
549     MEDCOUPLING_EXPORT void setSelectedComponents(const DataArrayInt *a, const std::vector<int>& compoIds);
550     MEDCOUPLING_EXPORT void getTuple(int tupleId, int *res) const { std::copy(_mem.getConstPointerLoc(tupleId*_info_on_compo.size()),_mem.getConstPointerLoc((tupleId+1)*_info_on_compo.size()),res); }
551     MEDCOUPLING_EXPORT static void SetArrayIn(DataArrayInt *newArray, DataArrayInt* &arrayToSet);
552     MEDCOUPLING_EXPORT DataArrayIntIterator *iterator();
553     MEDCOUPLING_EXPORT DataArrayInt *findIdsEqual(int val) const;
554     MEDCOUPLING_EXPORT DataArrayInt *findIdsNotEqual(int val) const;
555     MEDCOUPLING_EXPORT DataArrayInt *findIdsEqualList(const int *valsBg, const int *valsEnd) const;
556     MEDCOUPLING_EXPORT DataArrayInt *findIdsNotEqualList(const int *valsBg, const int *valsEnd) const;
557     MEDCOUPLING_EXPORT DataArrayInt *findIdsEqualTuple(const int *tupleBg, const int *tupleEnd) const;
558     MEDCOUPLING_EXPORT int changeValue(int oldValue, int newValue);
559     MEDCOUPLING_EXPORT int findIdFirstEqualTuple(const std::vector<int>& tupl) const;
560     MEDCOUPLING_EXPORT int findIdFirstEqual(int value) const;
561     MEDCOUPLING_EXPORT int findIdFirstEqual(const std::vector<int>& vals) const;
562     MEDCOUPLING_EXPORT int findIdSequence(const std::vector<int>& vals) const;
563     MEDCOUPLING_EXPORT bool presenceOfTuple(const std::vector<int>& tupl) const;
564     MEDCOUPLING_EXPORT bool presenceOfValue(int value) const;
565     MEDCOUPLING_EXPORT bool presenceOfValue(const std::vector<int>& vals) const;
566     MEDCOUPLING_EXPORT int count(int value) const;
567     MEDCOUPLING_EXPORT void accumulate(int *res) const;
568     MEDCOUPLING_EXPORT int accumulate(int compId) const;
569     MEDCOUPLING_EXPORT DataArrayInt *accumulatePerChunck(const int *bgOfIndex, const int *endOfIndex) const;
570     MEDCOUPLING_EXPORT void getMinMaxValues(int& minValue, int& maxValue) const;
571     MEDCOUPLING_EXPORT void abs();
572     MEDCOUPLING_EXPORT DataArrayInt *computeAbs() const;
573     MEDCOUPLING_EXPORT void applyLin(int a, int b, int compoId);
574     MEDCOUPLING_EXPORT void applyLin(int a, int b);
575     MEDCOUPLING_EXPORT void applyInv(int numerator);
576     MEDCOUPLING_EXPORT DataArrayInt *negate() const;
577     MEDCOUPLING_EXPORT void applyDivideBy(int val);
578     MEDCOUPLING_EXPORT void applyModulus(int val);
579     MEDCOUPLING_EXPORT void applyRModulus(int val);
580     MEDCOUPLING_EXPORT void applyPow(int val);
581     MEDCOUPLING_EXPORT void applyRPow(int val);
582     MEDCOUPLING_EXPORT DataArrayInt *findIdsInRange(int vmin, int vmax) const;
583     MEDCOUPLING_EXPORT DataArrayInt *findIdsNotInRange(int vmin, int vmax) const;
584     MEDCOUPLING_EXPORT DataArrayInt *findIdsStricltyNegative() const;
585     MEDCOUPLING_EXPORT bool checkAllIdsInRange(int vmin, int vmax) const;
586     MEDCOUPLING_EXPORT static DataArrayInt *Aggregate(const DataArrayInt *a1, const DataArrayInt *a2, int offsetA2);
587     MEDCOUPLING_EXPORT static DataArrayInt *Aggregate(const std::vector<const DataArrayInt *>& arr);
588     MEDCOUPLING_EXPORT static DataArrayInt *AggregateIndexes(const std::vector<const DataArrayInt *>& arrs);
589     MEDCOUPLING_EXPORT static DataArrayInt *Meld(const DataArrayInt *a1, const DataArrayInt *a2);
590     MEDCOUPLING_EXPORT static DataArrayInt *Meld(const std::vector<const DataArrayInt *>& arr);
591     MEDCOUPLING_EXPORT static DataArrayInt *MakePartition(const std::vector<const DataArrayInt *>& groups, int newNb, std::vector< std::vector<int> >& fidsOfGroups);
592     MEDCOUPLING_EXPORT static DataArrayInt *BuildUnion(const std::vector<const DataArrayInt *>& arr);
593     MEDCOUPLING_EXPORT static DataArrayInt *BuildIntersection(const std::vector<const DataArrayInt *>& arr);
594     MEDCOUPLING_EXPORT static DataArrayInt *BuildListOfSwitchedOn(const std::vector<bool>& v);
595     MEDCOUPLING_EXPORT static DataArrayInt *BuildListOfSwitchedOff(const std::vector<bool>& v);
596     MEDCOUPLING_EXPORT static void PutIntoToSkylineFrmt(const std::vector< std::vector<int> >& v, DataArrayInt *& data, DataArrayInt *& dataIndex);
597     MEDCOUPLING_EXPORT DataArrayInt *buildComplement(int nbOfElement) const;
598     MEDCOUPLING_EXPORT DataArrayInt *buildSubstraction(const DataArrayInt *other) const;
599     MEDCOUPLING_EXPORT DataArrayInt *buildSubstractionOptimized(const DataArrayInt *other) const;
600     MEDCOUPLING_EXPORT DataArrayInt *buildUnion(const DataArrayInt *other) const;
601     MEDCOUPLING_EXPORT DataArrayInt *buildIntersection(const DataArrayInt *other) const;
602     MEDCOUPLING_EXPORT DataArrayInt *buildUnique() const;
603     MEDCOUPLING_EXPORT DataArrayInt *buildUniqueNotSorted() const;
604     MEDCOUPLING_EXPORT DataArrayInt *deltaShiftIndex() const;
605     MEDCOUPLING_EXPORT void computeOffsets();
606     MEDCOUPLING_EXPORT void computeOffsetsFull();
607     MEDCOUPLING_EXPORT void findIdsRangesInListOfIds(const DataArrayInt *listOfIds, DataArrayInt *& rangeIdsFetched, DataArrayInt *& idsInInputListThatFetch) const;
608     MEDCOUPLING_EXPORT DataArrayInt *buildExplicitArrByRanges(const DataArrayInt *offsets) const;
609     MEDCOUPLING_EXPORT DataArrayInt *buildExplicitArrOfSliceOnScaledArr(int begin, int stop, int step) const;
610     MEDCOUPLING_EXPORT DataArrayInt *findRangeIdForEachTuple(const DataArrayInt *ranges) const;
611     MEDCOUPLING_EXPORT DataArrayInt *findIdInRangeForEachTuple(const DataArrayInt *ranges) const;
612     MEDCOUPLING_EXPORT void sortEachPairToMakeALinkedList();
613     MEDCOUPLING_EXPORT DataArrayInt *duplicateEachTupleNTimes(int nbTimes) const;
614     MEDCOUPLING_EXPORT DataArrayInt *getDifferentValues() const;
615     MEDCOUPLING_EXPORT std::vector<DataArrayInt *> partitionByDifferentValues(std::vector<int>& differentIds) const;
616     MEDCOUPLING_EXPORT std::vector< std::pair<int,int> > splitInBalancedSlices(int nbOfSlices) const;
617     template<class InputIterator>
618     void insertAtTheEnd(InputIterator first, InputIterator last);
619     MEDCOUPLING_EXPORT void aggregate(const DataArrayInt *other);
620     MEDCOUPLING_EXPORT void writeOnPlace(std::size_t id, int element0, const int *others, int sizeOfOthers) { _mem.writeOnPlace(id,element0,others,sizeOfOthers); }
621     MEDCOUPLING_EXPORT static DataArrayInt *Add(const DataArrayInt *a1, const DataArrayInt *a2);
622     MEDCOUPLING_EXPORT void addEqual(const DataArrayInt *other);
623     MEDCOUPLING_EXPORT static DataArrayInt *Substract(const DataArrayInt *a1, const DataArrayInt *a2);
624     MEDCOUPLING_EXPORT void substractEqual(const DataArrayInt *other);
625     MEDCOUPLING_EXPORT static DataArrayInt *Multiply(const DataArrayInt *a1, const DataArrayInt *a2);
626     MEDCOUPLING_EXPORT void multiplyEqual(const DataArrayInt *other);
627     MEDCOUPLING_EXPORT static DataArrayInt *Divide(const DataArrayInt *a1, const DataArrayInt *a2);
628     MEDCOUPLING_EXPORT void divideEqual(const DataArrayInt *other);
629     MEDCOUPLING_EXPORT static DataArrayInt *Modulus(const DataArrayInt *a1, const DataArrayInt *a2);
630     MEDCOUPLING_EXPORT void modulusEqual(const DataArrayInt *other);
631     MEDCOUPLING_EXPORT static DataArrayInt *Pow(const DataArrayInt *a1, const DataArrayInt *a2);
632     MEDCOUPLING_EXPORT void powEqual(const DataArrayInt *other);
633     MEDCOUPLING_EXPORT void updateTime() const { }
634     MEDCOUPLING_EXPORT MemArray<int>& accessToMemArray() { return _mem; }
635     MEDCOUPLING_EXPORT const MemArray<int>& accessToMemArray() const { return _mem; }
636   public:
637     MEDCOUPLING_EXPORT static int *CheckAndPreparePermutation(const int *start, const int *end);
638     MEDCOUPLING_EXPORT static DataArrayInt *Range(int begin, int end, int step);
639   public:
640     MEDCOUPLING_EXPORT void getTinySerializationIntInformation(std::vector<int>& tinyInfo) const;
641     MEDCOUPLING_EXPORT void getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const;
642     MEDCOUPLING_EXPORT bool resizeForUnserialization(const std::vector<int>& tinyInfoI);
643     MEDCOUPLING_EXPORT void finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<std::string>& tinyInfoS);
644   private:
645     ~DataArrayInt() { }
646     DataArrayInt() { }
647   };
648
649   class DataArrayIntTuple;
650
651   class DataArrayIntIterator
652   {
653   public:
654     MEDCOUPLING_EXPORT DataArrayIntIterator(DataArrayInt *da);
655     MEDCOUPLING_EXPORT ~DataArrayIntIterator();
656     MEDCOUPLING_EXPORT DataArrayIntTuple *nextt();
657   private:
658     DataArrayInt *_da;
659     int *_pt;
660     int _tuple_id;
661     int _nb_comp;
662     int _nb_tuple;
663   };
664
665   class DataArrayIntTuple
666   {
667   public:
668     MEDCOUPLING_EXPORT DataArrayIntTuple(int *pt, int nbOfComp);
669     MEDCOUPLING_EXPORT std::string repr() const;
670     MEDCOUPLING_EXPORT int getNumberOfCompo() const { return _nb_of_compo; }
671     MEDCOUPLING_EXPORT const int *getConstPointer() const { return  _pt; }
672     MEDCOUPLING_EXPORT int *getPointer() { return _pt; }
673     MEDCOUPLING_EXPORT int intValue() const;
674     MEDCOUPLING_EXPORT DataArrayInt *buildDAInt(int nbOfTuples, int nbOfCompo) const;
675   private:
676     int *_pt;
677     int _nb_of_compo;
678   };
679
680   class DataArrayChar : public DataArrayTemplate<char>
681   {
682   public:
683     MEDCOUPLING_EXPORT virtual DataArrayChar *buildEmptySpecializedDAChar() const = 0;
684     MEDCOUPLING_EXPORT int getHashCode() const;
685     MEDCOUPLING_EXPORT bool isEqual(const DataArrayChar& other) const;
686     MEDCOUPLING_EXPORT virtual bool isEqualIfNotWhy(const DataArrayChar& other, std::string& reason) const;
687     MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const DataArrayChar& other) const;
688     MEDCOUPLING_EXPORT void fillWithZero();
689     MEDCOUPLING_EXPORT std::string repr() const;
690     MEDCOUPLING_EXPORT std::string reprZip() const;
691     MEDCOUPLING_EXPORT DataArrayInt *convertToIntArr() const;
692     MEDCOUPLING_EXPORT DataArrayChar *selectByTupleId(const int *new2OldBg, const int *new2OldEnd) const { return DataArrayTemplate<char>::mySelectByTupleId(new2OldBg,new2OldEnd); }
693     MEDCOUPLING_EXPORT DataArrayChar *selectByTupleId(const DataArrayInt& di) const { return DataArrayTemplate<char>::mySelectByTupleId(di); }
694     MEDCOUPLING_EXPORT DataArrayChar *selectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const { return DataArrayTemplate<char>::mySelectByTupleIdSafe(new2OldBg,new2OldEnd); }
695     MEDCOUPLING_EXPORT DataArrayChar *keepSelectedComponents(const std::vector<int>& compoIds) const { return DataArrayTemplate<char>::myKeepSelectedComponents(compoIds); }
696     MEDCOUPLING_EXPORT DataArrayChar *selectByTupleIdSafeSlice(int bg, int end, int step) const { return DataArrayTemplate<char>::mySelectByTupleIdSafeSlice(bg,end,step); }
697     MEDCOUPLING_EXPORT bool isUniform(char val) const;
698     MEDCOUPLING_EXPORT void meldWith(const DataArrayChar *other);
699     MEDCOUPLING_EXPORT DataArray *selectByTupleRanges(const std::vector<std::pair<int,int> >& ranges) const { return DataArrayTemplate<char>::mySelectByTupleRanges(ranges); }
700     MEDCOUPLING_EXPORT void getTuple(int tupleId, char *res) const { std::copy(_mem.getConstPointerLoc(tupleId*_info_on_compo.size()),_mem.getConstPointerLoc((tupleId+1)*_info_on_compo.size()),res); }
701     MEDCOUPLING_EXPORT DataArrayInt *findIdsEqual(char val) const;
702     MEDCOUPLING_EXPORT DataArrayInt *findIdsNotEqual(char val) const;
703     MEDCOUPLING_EXPORT int findIdSequence(const std::vector<char>& vals) const;
704     MEDCOUPLING_EXPORT int findIdFirstEqualTuple(const std::vector<char>& tupl) const;
705     MEDCOUPLING_EXPORT int findIdFirstEqual(char value) const;
706     MEDCOUPLING_EXPORT int findIdFirstEqual(const std::vector<char>& vals) const;
707     MEDCOUPLING_EXPORT bool presenceOfTuple(const std::vector<char>& tupl) const;
708     MEDCOUPLING_EXPORT bool presenceOfValue(char value) const;
709     MEDCOUPLING_EXPORT bool presenceOfValue(const std::vector<char>& vals) const;
710     MEDCOUPLING_EXPORT DataArrayInt *findIdsInRange(char vmin, char vmax) const;
711     MEDCOUPLING_EXPORT static DataArrayChar *Aggregate(const DataArrayChar *a1, const DataArrayChar *a2);
712     MEDCOUPLING_EXPORT static DataArrayChar *Aggregate(const std::vector<const DataArrayChar *>& arr);
713     MEDCOUPLING_EXPORT static DataArrayChar *Meld(const DataArrayChar *a1, const DataArrayChar *a2);
714     MEDCOUPLING_EXPORT static DataArrayChar *Meld(const std::vector<const DataArrayChar *>& arr);
715     template<class InputIterator>
716     void insertAtTheEnd(InputIterator first, InputIterator last);
717     MEDCOUPLING_EXPORT void updateTime() const { }
718     MEDCOUPLING_EXPORT MemArray<char>& accessToMemArray() { return _mem; }
719     MEDCOUPLING_EXPORT const MemArray<char>& accessToMemArray() const { return _mem; }
720   public:
721     //MEDCOUPLING_EXPORT void getTinySerializationIntInformation(std::vector<int>& tinyInfo) const;
722     //MEDCOUPLING_EXPORT void getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const;
723     //MEDCOUPLING_EXPORT bool resizeForUnserialization(const std::vector<int>& tinyInfoI);
724     //MEDCOUPLING_EXPORT void finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<std::string>& tinyInfoS);
725   protected:
726     DataArrayChar() { }
727   };
728
729   class DataArrayByteIterator;
730
731   class DataArrayByte : public DataArrayChar
732   {
733   public:
734     MEDCOUPLING_EXPORT static DataArrayByte *New();
735     MEDCOUPLING_EXPORT DataArrayChar *buildEmptySpecializedDAChar() const;
736     MEDCOUPLING_EXPORT DataArrayByteIterator *iterator();
737     MEDCOUPLING_EXPORT DataArrayByte *deepCopy() const;
738     MEDCOUPLING_EXPORT DataArrayByte *performCopyOrIncrRef(bool deepCopy) const;
739     MEDCOUPLING_EXPORT DataArrayByte *buildNewEmptyInstance() const { return DataArrayByte::New(); }
740     MEDCOUPLING_EXPORT char byteValue() const;
741     MEDCOUPLING_EXPORT void reprStream(std::ostream& stream) const;
742     MEDCOUPLING_EXPORT void reprZipStream(std::ostream& stream) const;
743     MEDCOUPLING_EXPORT void reprWithoutNameStream(std::ostream& stream) const;
744     MEDCOUPLING_EXPORT void reprZipWithoutNameStream(std::ostream& stream) const;
745     MEDCOUPLING_EXPORT void reprCppStream(const std::string& varName, std::ostream& stream) const;
746     MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const;
747     MEDCOUPLING_EXPORT void reprQuickOverviewData(std::ostream& stream, std::size_t maxNbOfByteInRepr) const;
748     MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const DataArrayChar& other, std::string& reason) const;
749     MEDCOUPLING_EXPORT std::vector<bool> toVectorOfBool() const;
750   private:
751     ~DataArrayByte() { }
752     DataArrayByte() { }
753   };
754
755   class DataArrayByteTuple;
756
757   class DataArrayByteIterator
758   {
759   public:
760     MEDCOUPLING_EXPORT DataArrayByteIterator(DataArrayByte *da);
761     MEDCOUPLING_EXPORT ~DataArrayByteIterator();
762     MEDCOUPLING_EXPORT DataArrayByteTuple *nextt();
763   private:
764     DataArrayByte *_da;
765     char *_pt;
766     int _tuple_id;
767     int _nb_comp;
768     int _nb_tuple;
769   };
770
771   class DataArrayByteTuple
772   {
773   public:
774     MEDCOUPLING_EXPORT DataArrayByteTuple(char *pt, int nbOfComp);
775     MEDCOUPLING_EXPORT std::string repr() const;
776     MEDCOUPLING_EXPORT int getNumberOfCompo() const { return _nb_of_compo; }
777     MEDCOUPLING_EXPORT const char *getConstPointer() const { return  _pt; }
778     MEDCOUPLING_EXPORT char *getPointer() { return _pt; }
779     MEDCOUPLING_EXPORT char byteValue() const;
780     MEDCOUPLING_EXPORT DataArrayByte *buildDAByte(int nbOfTuples, int nbOfCompo) const;
781   private:
782     char *_pt;
783     int _nb_of_compo;
784   };
785
786   class DataArrayAsciiCharIterator;
787
788   class DataArrayAsciiChar : public DataArrayChar
789   {
790   public:
791     MEDCOUPLING_EXPORT static DataArrayAsciiChar *New();
792     MEDCOUPLING_EXPORT static DataArrayAsciiChar *New(const std::string& st);
793     MEDCOUPLING_EXPORT static DataArrayAsciiChar *New(const std::vector<std::string>& vst, char defaultChar);
794     MEDCOUPLING_EXPORT DataArrayChar *buildEmptySpecializedDAChar() const;
795     MEDCOUPLING_EXPORT DataArrayAsciiCharIterator *iterator();
796     MEDCOUPLING_EXPORT DataArrayAsciiChar *deepCopy() const;
797     MEDCOUPLING_EXPORT DataArrayAsciiChar *performCopyOrIncrRef(bool deepCopy) const;
798     MEDCOUPLING_EXPORT DataArrayAsciiChar *buildNewEmptyInstance() const { return DataArrayAsciiChar::New(); }
799     MEDCOUPLING_EXPORT char asciiCharValue() const;
800     MEDCOUPLING_EXPORT void reprStream(std::ostream& stream) const;
801     MEDCOUPLING_EXPORT void reprZipStream(std::ostream& stream) const;
802     MEDCOUPLING_EXPORT void reprWithoutNameStream(std::ostream& stream) const;
803     MEDCOUPLING_EXPORT void reprZipWithoutNameStream(std::ostream& stream) const;
804     MEDCOUPLING_EXPORT void reprCppStream(const std::string& varName, std::ostream& stream) const;
805     MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const;
806     MEDCOUPLING_EXPORT void reprQuickOverviewData(std::ostream& stream, std::size_t maxNbOfByteInRepr) const;
807     MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const DataArrayChar& other, std::string& reason) const;
808   private:
809     ~DataArrayAsciiChar() { }
810     DataArrayAsciiChar() { }
811     DataArrayAsciiChar(const std::string& st);
812     DataArrayAsciiChar(const std::vector<std::string>& vst, char defaultChar);
813   };
814
815   class DataArrayAsciiCharTuple;
816
817   class DataArrayAsciiCharIterator
818   {
819   public:
820     MEDCOUPLING_EXPORT DataArrayAsciiCharIterator(DataArrayAsciiChar *da);
821     MEDCOUPLING_EXPORT ~DataArrayAsciiCharIterator();
822     MEDCOUPLING_EXPORT DataArrayAsciiCharTuple *nextt();
823   private:
824     DataArrayAsciiChar *_da;
825     char *_pt;
826     int _tuple_id;
827     int _nb_comp;
828     int _nb_tuple;
829   };
830
831   class DataArrayAsciiCharTuple
832   {
833   public:
834     MEDCOUPLING_EXPORT DataArrayAsciiCharTuple(char *pt, int nbOfComp);
835     MEDCOUPLING_EXPORT std::string repr() const;
836     MEDCOUPLING_EXPORT int getNumberOfCompo() const { return _nb_of_compo; }
837     MEDCOUPLING_EXPORT const char *getConstPointer() const { return  _pt; }
838     MEDCOUPLING_EXPORT char *getPointer() { return _pt; }
839     MEDCOUPLING_EXPORT char asciiCharValue() const;
840     MEDCOUPLING_EXPORT DataArrayAsciiChar *buildDAAsciiChar(int nbOfTuples, int nbOfCompo) const;
841   private:
842     char *_pt;
843     int _nb_of_compo;
844   };
845 }
846
847 namespace MEDCoupling
848 {
849   template<class T>
850   template<class InputIterator>
851   void MemArray<T>::insertAtTheEnd(InputIterator first, InputIterator last)
852   {
853     T *pointer=_pointer.getPointer();
854     while(first!=last)
855       {
856         if(_nb_of_elem>=_nb_of_elem_alloc)
857           {
858             reserve(_nb_of_elem_alloc>0?2*_nb_of_elem_alloc:1);
859             pointer=_pointer.getPointer();
860           }
861         pointer[_nb_of_elem++]=*first++;
862       }
863   }
864   
865   template<class InputIterator>
866   void DataArrayDouble::insertAtTheEnd(InputIterator first, InputIterator last)
867   {
868     int nbCompo(getNumberOfComponents());
869     if(nbCompo==1)
870       _mem.insertAtTheEnd(first,last);
871     else if(nbCompo==0)
872       {
873         _info_on_compo.resize(1);
874         _mem.insertAtTheEnd(first,last);
875       }
876     else
877       throw INTERP_KERNEL::Exception("DataArrayDouble::insertAtTheEnd : not available for DataArrayDouble with number of components different than 1 !");
878   }
879
880   template<class InputIterator>
881   void DataArrayInt::insertAtTheEnd(InputIterator first, InputIterator last)
882   {
883     int nbCompo(getNumberOfComponents());
884     if(nbCompo==1)
885       _mem.insertAtTheEnd(first,last);
886     else if(nbCompo==0)
887       {
888         _info_on_compo.resize(1);
889         _mem.insertAtTheEnd(first,last);
890       }
891     else
892       throw INTERP_KERNEL::Exception("DataArrayInt::insertAtTheEnd : not available for DataArrayInt with number of components different than 1 !");
893   }
894
895   template<class InputIterator>
896   void DataArrayChar::insertAtTheEnd(InputIterator first, InputIterator last)
897   {
898     int nbCompo(getNumberOfComponents());
899     if(nbCompo==1)
900       _mem.insertAtTheEnd(first,last);
901     else if(nbCompo==0)
902       {
903         _info_on_compo.resize(1);
904         _mem.insertAtTheEnd(first,last);
905       }
906     else
907       throw INTERP_KERNEL::Exception("DataArrayChar::insertAtTheEnd : not available for DataArrayChar with number of components different than 1 !");
908   }
909 }
910
911 #endif