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