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