1 // Copyright (C) 2007-2019 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Anthony Geay (EDF R&D)
21 #ifndef __MEDCOUPLING_MEDCOUPLINGMEMARRAY_HXX__
22 #define __MEDCOUPLING_MEDCOUPLINGMEMARRAY_HXX__
24 #include "MEDCoupling.hxx"
27 #include "MEDCouplingTimeLabel.hxx"
28 #include "MEDCouplingRefCountObject.hxx"
29 #include "InterpKernelException.hxx"
30 #include "MEDCouplingTraits.hxx"
31 #include "MEDCouplingMap.hxx"
32 #include "BBTreePts.txx"
45 } MEDCouplingAxisType;
46 // -- WARNING this enum must be synchronized with MEDCouplingCommon.i file ! --
51 class MEDCouplingPointer
54 MEDCOUPLING_EXPORT MEDCouplingPointer():_internal(0),_external(0) { }
55 MEDCOUPLING_EXPORT void null() { _internal=0; _external=0; }
56 MEDCOUPLING_EXPORT bool isNull() const { return _internal==0 && _external==0; }
57 MEDCOUPLING_EXPORT void setInternal(T *pointer);
58 MEDCOUPLING_EXPORT void setExternal(const T *pointer);
59 MEDCOUPLING_EXPORT const T *getConstPointer() const { if(_internal) return _internal; else return _external; }
60 MEDCOUPLING_EXPORT const T *getConstPointerLoc(std::size_t offset) const { if(_internal) return _internal+offset; else return _external+offset; }
61 MEDCOUPLING_EXPORT T *getPointer() { if(_internal) return _internal; if(_external) throw INTERP_KERNEL::Exception("Trying to write on an external pointer."); else return 0; }
71 typedef void (*Deallocator)(void *,void *);
73 MEDCOUPLING_EXPORT MemArray():_nb_of_elem(0),_nb_of_elem_alloc(0),_ownership(false),_dealloc(0),_param_for_deallocator(0) { }
74 MEDCOUPLING_EXPORT MemArray(const MemArray<T>& other);
75 MEDCOUPLING_EXPORT bool isNull() const { return _pointer.isNull(); }
76 MEDCOUPLING_EXPORT const T *getConstPointerLoc(std::size_t offset) const { return _pointer.getConstPointerLoc(offset); }
77 MEDCOUPLING_EXPORT const T *getConstPointer() const { return _pointer.getConstPointer(); }
78 MEDCOUPLING_EXPORT std::size_t getNbOfElem() const { return _nb_of_elem; }
79 MEDCOUPLING_EXPORT std::size_t getNbOfElemAllocated() const { return _nb_of_elem_alloc; }
80 MEDCOUPLING_EXPORT T *getPointer() { return _pointer.getPointer(); }
81 MEDCOUPLING_EXPORT MemArray<T> &operator=(const MemArray<T>& other);
82 MEDCOUPLING_EXPORT T operator[](std::size_t id) const { return _pointer.getConstPointer()[id]; }
83 MEDCOUPLING_EXPORT T& operator[](std::size_t id) { return _pointer.getPointer()[id]; }
84 MEDCOUPLING_EXPORT bool isEqual(const MemArray<T>& other, T prec, std::string& reason) const;
85 MEDCOUPLING_EXPORT void repr(int sl, std::ostream& stream) const;
86 MEDCOUPLING_EXPORT bool reprHeader(int sl, std::ostream& stream) const;
87 MEDCOUPLING_EXPORT void reprZip(int sl, std::ostream& stream) const;
88 MEDCOUPLING_EXPORT void reprNotTooLong(int sl, std::ostream& stream) const;
89 MEDCOUPLING_EXPORT void fillWithValue(const T& val);
90 MEDCOUPLING_EXPORT T *fromNoInterlace(int nbOfComp) const;
91 MEDCOUPLING_EXPORT T *toNoInterlace(int nbOfComp) const;
92 MEDCOUPLING_EXPORT void sort(bool asc);
93 MEDCOUPLING_EXPORT void reverse(int nbOfComp);
94 MEDCOUPLING_EXPORT void alloc(std::size_t nbOfElements);
95 MEDCOUPLING_EXPORT void reserve(std::size_t newNbOfElements);
96 MEDCOUPLING_EXPORT void reAlloc(std::size_t newNbOfElements);
97 MEDCOUPLING_EXPORT void useArray(const T *array, bool ownership, DeallocType type, std::size_t nbOfElem);
98 MEDCOUPLING_EXPORT void useExternalArrayWithRWAccess(const T *array, std::size_t nbOfElem);
99 MEDCOUPLING_EXPORT void writeOnPlace(std::size_t id, T element0, const T *others, std::size_t sizeOfOthers);
100 template<class InputIterator>
101 void insertAtTheEnd(InputIterator first, InputIterator last);
102 MEDCOUPLING_EXPORT void pushBack(T elem);
103 MEDCOUPLING_EXPORT T popBack();
104 MEDCOUPLING_EXPORT void pack() const;
105 MEDCOUPLING_EXPORT bool isDeallocatorCalled() const { return _ownership; }
106 MEDCOUPLING_EXPORT Deallocator getDeallocator() const { return _dealloc; }
107 MEDCOUPLING_EXPORT void setSpecificDeallocator(Deallocator dealloc) { _dealloc=dealloc; }
108 MEDCOUPLING_EXPORT void setParameterForDeallocator(void *param) { _param_for_deallocator=param; }
109 MEDCOUPLING_EXPORT void *getParameterForDeallocator() const { return _param_for_deallocator; }
110 MEDCOUPLING_EXPORT void destroy();
111 MEDCOUPLING_EXPORT ~MemArray() { destroy(); }
113 static void CPPDeallocator(void *pt, void *param);
114 static void CDeallocator(void *pt, void *param);
115 static void COffsetDeallocator(void *pt, void *param);
117 static void DestroyPointer(T *pt, Deallocator dealloc, void *param);
118 static Deallocator BuildFromType(DeallocType type);
120 std::size_t _nb_of_elem;
121 std::size_t _nb_of_elem_alloc;
123 MEDCouplingPointer<T> _pointer;
124 Deallocator _dealloc;
125 void *_param_for_deallocator;
128 class DataArrayInt32;
131 class DataArray : public RefCountObject, public TimeLabel
134 MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
135 MEDCOUPLING_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
136 MEDCOUPLING_EXPORT void setName(const std::string& name);
137 MEDCOUPLING_EXPORT void copyStringInfoFrom(const DataArray& other);
138 MEDCOUPLING_EXPORT void copyPartOfStringInfoFrom(const DataArray& other, const std::vector<int>& compoIds);
139 MEDCOUPLING_EXPORT void copyPartOfStringInfoFrom2(const std::vector<int>& compoIds, const DataArray& other);
140 MEDCOUPLING_EXPORT bool areInfoEqualsIfNotWhy(const DataArray& other, std::string& reason) const;
141 MEDCOUPLING_EXPORT bool areInfoEquals(const DataArray& other) const;
142 MEDCOUPLING_EXPORT std::string cppRepr(const std::string& varName) const;
143 MEDCOUPLING_EXPORT std::string getName() const { return _name; }
144 MEDCOUPLING_EXPORT const std::vector<std::string> &getInfoOnComponents() const { return _info_on_compo; }
145 MEDCOUPLING_EXPORT std::vector<std::string> &getInfoOnComponents() { return _info_on_compo; }
146 MEDCOUPLING_EXPORT void setInfoOnComponents(const std::vector<std::string>& info);
147 MEDCOUPLING_EXPORT void setInfoAndChangeNbOfCompo(const std::vector<std::string>& info);
148 MEDCOUPLING_EXPORT std::vector<std::string> getVarsOnComponent() const;
149 MEDCOUPLING_EXPORT std::vector<std::string> getUnitsOnComponent() const;
150 MEDCOUPLING_EXPORT std::string getInfoOnComponent(int i) const;
151 MEDCOUPLING_EXPORT std::string getVarOnComponent(int i) const;
152 MEDCOUPLING_EXPORT std::string getUnitOnComponent(int i) const;
153 MEDCOUPLING_EXPORT void setInfoOnComponent(int i, const std::string& info);
154 MEDCOUPLING_EXPORT std::size_t getNumberOfComponents() const { return _info_on_compo.size(); }
155 MEDCOUPLING_EXPORT void setPartOfValuesBase3(const DataArray *aBase, const int *bgTuples, const int *endTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare=true);
156 MEDCOUPLING_EXPORT virtual void *getVoidStarPointer() = 0;
157 MEDCOUPLING_EXPORT virtual DataArray *deepCopy() const = 0;
158 MEDCOUPLING_EXPORT virtual DataArray *buildNewEmptyInstance() const = 0;
159 MEDCOUPLING_EXPORT virtual bool isAllocated() const = 0;
160 MEDCOUPLING_EXPORT virtual void checkAllocated() const = 0;
161 MEDCOUPLING_EXPORT virtual void desallocate() = 0;
162 MEDCOUPLING_EXPORT virtual std::size_t getNumberOfTuples() const = 0;
163 MEDCOUPLING_EXPORT virtual std::size_t getNbOfElems() const = 0;
164 MEDCOUPLING_EXPORT virtual std::size_t getNbOfElemAllocated() const = 0;
165 MEDCOUPLING_EXPORT virtual void alloc(std::size_t nbOfTuple, std::size_t nbOfCompo=1) = 0;
166 MEDCOUPLING_EXPORT virtual void reAlloc(std::size_t newNbOfTuple) = 0;
167 MEDCOUPLING_EXPORT virtual void renumberInPlace(const int *old2New) = 0;
168 MEDCOUPLING_EXPORT virtual void renumberInPlaceR(const int *new2Old) = 0;
169 MEDCOUPLING_EXPORT virtual void setContigPartOfSelectedValues(int tupleIdStart, const DataArray *aBase, const DataArrayInt32 *tuplesSelec) = 0;
170 MEDCOUPLING_EXPORT virtual void setContigPartOfSelectedValuesSlice(int tupleIdStart, const DataArray *aBase, int bg, int end2, int step) = 0;
171 MEDCOUPLING_EXPORT virtual DataArray *selectByTupleRanges(const std::vector<std::pair<int,int> >& ranges) const = 0;
172 MEDCOUPLING_EXPORT virtual DataArray *keepSelectedComponents(const std::vector<int>& compoIds) const = 0;
173 MEDCOUPLING_EXPORT virtual DataArray *selectByTupleId(const int *new2OldBg, const int *new2OldEnd) const = 0;
174 MEDCOUPLING_EXPORT virtual DataArray *selectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const = 0;
175 MEDCOUPLING_EXPORT virtual DataArray *selectByTupleIdSafeSlice(int bg, int end2, int step) const = 0;
176 MEDCOUPLING_EXPORT virtual void rearrange(int newNbOfCompo) = 0;
177 MEDCOUPLING_EXPORT virtual void circularPermutation(int nbOfShift=1) = 0;
178 MEDCOUPLING_EXPORT virtual void circularPermutationPerTuple(int nbOfShift=1) = 0;
179 MEDCOUPLING_EXPORT virtual void reversePerTuple() = 0;
180 MEDCOUPLING_EXPORT void checkNbOfTuples(int nbOfTuples, const std::string& msg) const;
181 MEDCOUPLING_EXPORT void checkNbOfComps(int nbOfCompo, const std::string& msg) const;
182 MEDCOUPLING_EXPORT void checkNbOfTuplesAndComp(const DataArray& other, const std::string& msg) const;
183 MEDCOUPLING_EXPORT void checkNbOfTuplesAndComp(int nbOfTuples, int nbOfCompo, const std::string& msg) const;
184 MEDCOUPLING_EXPORT void checkNbOfElems(std::size_t nbOfElems, const std::string& msg) const;
185 MEDCOUPLING_EXPORT static void GetSlice(int start, int stop, int step, int sliceId, int nbOfSlices, int& startSlice, int& stopSlice);
186 MEDCOUPLING_EXPORT static int GetNumberOfItemGivenBES(int begin, int end, int step, const std::string& msg);
187 MEDCOUPLING_EXPORT static int GetNumberOfItemGivenBESRelative(int begin, int end, int step, const std::string& msg);
188 MEDCOUPLING_EXPORT static int GetPosOfItemGivenBESRelativeNoThrow(int value, int begin, int end, int step);
189 MEDCOUPLING_EXPORT static std::string GetVarNameFromInfo(const std::string& info);
190 MEDCOUPLING_EXPORT static std::string GetUnitFromInfo(const std::string& info);
191 MEDCOUPLING_EXPORT static std::string BuildInfoFromVarAndUnit(const std::string& var, const std::string& unit);
192 MEDCOUPLING_EXPORT static std::string GetAxisTypeRepr(MEDCouplingAxisType at);
193 MEDCOUPLING_EXPORT static DataArray *Aggregate(const std::vector<const DataArray *>& arrs);
194 MEDCOUPLING_EXPORT virtual void reprStream(std::ostream& stream) const = 0;
195 MEDCOUPLING_EXPORT virtual void reprZipStream(std::ostream& stream) const = 0;
196 MEDCOUPLING_EXPORT virtual void reprWithoutNameStream(std::ostream& stream) const;
197 MEDCOUPLING_EXPORT virtual void reprZipWithoutNameStream(std::ostream& stream) const = 0;
198 MEDCOUPLING_EXPORT virtual void reprCppStream(const std::string& varName, std::ostream& stream) const = 0;
199 MEDCOUPLING_EXPORT virtual void reprQuickOverview(std::ostream& stream) const = 0;
200 MEDCOUPLING_EXPORT virtual void reprQuickOverviewData(std::ostream& stream, std::size_t maxNbOfByteInRepr) const = 0;
205 MEDCOUPLING_EXPORT static void CheckValueInRange(int ref, int value, const std::string& msg);
206 MEDCOUPLING_EXPORT static void CheckValueInRangeEx(int value, int start, int end, const std::string& msg);
207 MEDCOUPLING_EXPORT static void CheckClosingParInRange(int ref, int value, const std::string& msg);
208 MEDCOUPLING_EXPORT static int EffectiveCircPerm(int nbOfShift, int nbOfTuples);
211 std::vector<std::string> _info_on_compo;
215 namespace MEDCoupling
217 class DataArrayInt32;
220 class DataArrayTemplate : public DataArray
225 MEDCOUPLING_EXPORT static MCAuto< typename Traits<T>::ArrayTypeCh > NewFromStdVector(const typename std::vector<T>& v);
226 MEDCOUPLING_EXPORT std::vector< MCAuto< typename Traits<T>::ArrayTypeCh > > explodeComponents() const;
228 std::size_t getHeapMemorySizeWithoutChildren() const;
229 MEDCOUPLING_EXPORT void updateTime() const { }
231 MEDCOUPLING_EXPORT std::size_t getNumberOfTuples() const { return _info_on_compo.empty()?0:_mem.getNbOfElem()/getNumberOfComponents(); }
232 MEDCOUPLING_EXPORT std::size_t getNbOfElems() const { return _mem.getNbOfElem(); }
233 MEDCOUPLING_EXPORT bool empty() const;
234 MEDCOUPLING_EXPORT void *getVoidStarPointer() { return getPointer(); }
235 MEDCOUPLING_EXPORT const T *getConstPointer() const { return _mem.getConstPointer(); }
236 MEDCOUPLING_EXPORT const T *begin() const { return getConstPointer(); }
237 MEDCOUPLING_EXPORT const T *end() const { return getConstPointer()+getNbOfElems(); }
238 MEDCOUPLING_EXPORT T *rwBegin() { return getPointer(); }
239 MEDCOUPLING_EXPORT T *rwEnd() { return getPointer()+getNbOfElems(); }
240 MEDCOUPLING_EXPORT void alloc(std::size_t nbOfTuple, std::size_t nbOfCompo=1);
241 MEDCOUPLING_EXPORT void useArray(const T *array, bool ownership, DeallocType type, int nbOfTuple, int nbOfCompo);
242 MEDCOUPLING_EXPORT void useExternalArrayWithRWAccess(const T *array, int nbOfTuple, int nbOfCompo);
243 MEDCOUPLING_EXPORT T getIJSafe(int tupleId, int compoId) const;
244 MEDCOUPLING_EXPORT T getIJ(int tupleId, int compoId) const { return _mem[tupleId*_info_on_compo.size()+compoId]; }
245 MEDCOUPLING_EXPORT void setIJ(int tupleId, int compoId, T newVal) { _mem[tupleId*_info_on_compo.size()+compoId]=newVal; declareAsNew(); }
246 MEDCOUPLING_EXPORT void setIJSilent(int tupleId, int compoId, T newVal) { _mem[tupleId*_info_on_compo.size()+compoId]=newVal; }
247 MEDCOUPLING_EXPORT T *getPointer() { return _mem.getPointer(); declareAsNew(); }
248 MEDCOUPLING_EXPORT void pack() const;
249 MEDCOUPLING_EXPORT bool isAllocated() const override;
250 MEDCOUPLING_EXPORT void checkAllocated() const;
251 MEDCOUPLING_EXPORT void desallocate();
252 MEDCOUPLING_EXPORT void reserve(std::size_t nbOfElems);
253 MEDCOUPLING_EXPORT void rearrange(int newNbOfCompo);
254 MEDCOUPLING_EXPORT void transpose();
255 MEDCOUPLING_EXPORT void pushBackSilent(T val);
256 MEDCOUPLING_EXPORT void pushBackValsSilent(const T *valsBg, const T *valsEnd);
257 MEDCOUPLING_EXPORT T popBackSilent();
258 MEDCOUPLING_EXPORT T front() const;
259 MEDCOUPLING_EXPORT T back() const;
260 MEDCOUPLING_EXPORT std::size_t getNbOfElemAllocated() const { return _mem.getNbOfElemAllocated(); }
261 MEDCOUPLING_EXPORT void allocIfNecessary(int nbOfTuple, int nbOfCompo);
262 MEDCOUPLING_EXPORT void deepCopyFrom(const DataArrayTemplate<T>& other);
263 MEDCOUPLING_EXPORT void reverse();
264 MEDCOUPLING_EXPORT void fillWithValue(T val);
265 MEDCOUPLING_EXPORT void reAlloc(std::size_t newNbOfTuple);
266 MEDCOUPLING_EXPORT void renumberInPlace(const int *old2New);
267 MEDCOUPLING_EXPORT void renumberInPlaceR(const int *new2Old);
268 MEDCOUPLING_EXPORT void sort(bool asc=true);
269 MEDCOUPLING_EXPORT typename Traits<T>::ArrayType *renumber(const int *old2New) const;
270 MEDCOUPLING_EXPORT typename Traits<T>::ArrayType *renumberR(const int *new2Old) const;
271 MEDCOUPLING_EXPORT typename Traits<T>::ArrayType *renumberAndReduce(const int *old2New, int newNbOfTuple) const;
272 MEDCOUPLING_EXPORT typename Traits<T>::ArrayType *changeNbOfComponents(int newNbOfComp, T dftValue) const;
273 MEDCOUPLING_EXPORT typename Traits<T>::ArrayType *subArray(int tupleIdBg, int tupleIdEnd=-1) const;
274 MEDCOUPLING_EXPORT MCAuto<typename Traits<T>::ArrayTypeCh> selectPartDef(const PartDefinition* pd) const;
275 MEDCOUPLING_EXPORT void circularPermutation(int nbOfShift=1);
276 MEDCOUPLING_EXPORT void circularPermutationPerTuple(int nbOfShift=1);
277 MEDCOUPLING_EXPORT void reversePerTuple();
278 MEDCOUPLING_EXPORT void setPartOfValues1(const typename Traits<T>::ArrayType *a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare=true);
279 MEDCOUPLING_EXPORT void setPartOfValuesSimple1(T a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp);
280 MEDCOUPLING_EXPORT void setPartOfValues2(const typename Traits<T>::ArrayType *a, const int *bgTuples, const int *endTuples, const int *bgComp, const int *endComp, bool strictCompoCompare=true);
281 MEDCOUPLING_EXPORT void setPartOfValuesSimple2(T a, const int *bgTuples, const int *endTuples, const int *bgComp, const int *endComp);
282 MEDCOUPLING_EXPORT void setPartOfValues3(const typename Traits<T>::ArrayType *a, const int *bgTuples, const int *endTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare=true);
283 MEDCOUPLING_EXPORT void setPartOfValuesSimple3(T a, const int *bgTuples, const int *endTuples, int bgComp, int endComp, int stepComp);
284 MEDCOUPLING_EXPORT void setPartOfValues4(const typename Traits<T>::ArrayType *a, int bgTuples, int endTuples, int stepTuples, const int *bgComp, const int *endComp, bool strictCompoCompare=true);
285 MEDCOUPLING_EXPORT void setPartOfValuesSimple4(T a, int bgTuples, int endTuples, int stepTuples, const int *bgComp, const int *endComp);
286 MEDCOUPLING_EXPORT void setPartOfValuesAdv(const typename Traits<T>::ArrayType *a, const DataArrayInt32 *tuplesSelec);
287 MEDCOUPLING_EXPORT void setContigPartOfSelectedValues(int tupleIdStart, const DataArray *aBase, const DataArrayInt32 *tuplesSelec);
288 MEDCOUPLING_EXPORT void setContigPartOfSelectedValuesSlice(int tupleIdStart, const DataArray *aBase, int bg, int end2, int step);
289 MEDCOUPLING_EXPORT T getMaxValue(int& tupleId) const;
290 MEDCOUPLING_EXPORT T getMaxValueInArray() const;
291 MEDCOUPLING_EXPORT T getMaxAbsValue(std::size_t& tupleId) const;
292 MEDCOUPLING_EXPORT T getMaxAbsValueInArray() const;
293 MEDCOUPLING_EXPORT T getMinValue(int& tupleId) const;
294 MEDCOUPLING_EXPORT T getMinValueInArray() const;
295 MEDCOUPLING_EXPORT void getTuple(int tupleId, T *res) const { std::copy(_mem.getConstPointerLoc(tupleId*_info_on_compo.size()),_mem.getConstPointerLoc((tupleId+1)*_info_on_compo.size()),res); }
296 template<class InputIterator>
297 void insertAtTheEnd(InputIterator first, InputIterator last);
298 MEDCOUPLING_EXPORT static void SetArrayIn(typename Traits<T>::ArrayType *newArray, typename Traits<T>::ArrayType* &arrayToSet);
299 MEDCOUPLING_EXPORT void writeOnPlace(std::size_t id, T element0, const T *others, int sizeOfOthers) { _mem.writeOnPlace(id,element0,others,sizeOfOthers); }
300 MEDCOUPLING_EXPORT void fillWithZero();
302 MEDCOUPLING_EXPORT MemArray<T>& accessToMemArray() { return _mem; }
303 MEDCOUPLING_EXPORT const MemArray<T>& accessToMemArray() const { return _mem; }
305 typename Traits<T>::ArrayType *mySelectByTupleId(const mcIdType *new2OldBg, const mcIdType *new2OldEnd) const;
306 typename Traits<T>::ArrayType *mySelectByTupleId(const DataArrayIdType& di) const;
307 typename Traits<T>::ArrayType *mySelectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const;
308 typename Traits<T>::ArrayType *myKeepSelectedComponents(const std::vector<int>& compoIds) const;
309 typename Traits<T>::ArrayType *mySelectByTupleIdSafeSlice(int bg, int end2, int step) const;
310 typename Traits<T>::ArrayType *mySelectByTupleRanges(const std::vector<std::pair<int,int> >& ranges) const;
316 class DataArrayTemplateClassic : public DataArrayTemplate<T>
319 MEDCOUPLING_EXPORT MCAuto<DataArrayDouble> convertToDblArr() const;
320 MEDCOUPLING_EXPORT MCAuto<DataArrayInt32> convertToIntArr() const;
321 MEDCOUPLING_EXPORT MCAuto<DataArrayFloat> convertToFloatArr() const;
322 MEDCOUPLING_EXPORT void applyLin(T a, T b, int compoId);
323 MEDCOUPLING_EXPORT void applyLin(T a, T b);
324 MEDCOUPLING_EXPORT typename Traits<T>::ArrayType *negate() const;
325 MEDCOUPLING_EXPORT void addEqual(const typename Traits<T>::ArrayType *other);
326 MEDCOUPLING_EXPORT void substractEqual(const typename Traits<T>::ArrayType *other);
327 MEDCOUPLING_EXPORT void multiplyEqual(const typename Traits<T>::ArrayType *other);
328 MEDCOUPLING_EXPORT void divideEqual(const typename Traits<T>::ArrayType *other);
329 MEDCOUPLING_EXPORT static typename Traits<T>::ArrayType *Substract(const typename Traits<T>::ArrayType *a1, const typename Traits<T>::ArrayType *a2);
330 MEDCOUPLING_EXPORT static typename Traits<T>::ArrayType *Divide(const typename Traits<T>::ArrayType *a1, const typename Traits<T>::ArrayType *a2);
331 MEDCOUPLING_EXPORT static typename Traits<T>::ArrayType *Add(const typename Traits<T>::ArrayType *a1, const typename Traits<T>::ArrayType *a2);
332 MEDCOUPLING_EXPORT static typename Traits<T>::ArrayType *Multiply(const typename Traits<T>::ArrayType *a1, const typename Traits<T>::ArrayType *a2);
333 MEDCOUPLING_EXPORT static typename Traits<T>::ArrayType *Meld(const typename Traits<T>::ArrayType *a1, const typename Traits<T>::ArrayType *a2);
334 MEDCOUPLING_EXPORT static typename Traits<T>::ArrayType *Meld(const std::vector<const typename Traits<T>::ArrayType *>& arr);
335 MEDCOUPLING_EXPORT MCAuto<DataArrayInt32> findIdsGreaterOrEqualTo(T val) const;
336 MEDCOUPLING_EXPORT MCAuto<DataArrayInt32> findIdsGreaterThan(T val) const;
337 MEDCOUPLING_EXPORT MCAuto<DataArrayInt32> findIdsLowerOrEqualTo(T val) const;
338 MEDCOUPLING_EXPORT MCAuto<DataArrayInt32> findIdsLowerThan(T val) const;
339 MEDCOUPLING_EXPORT DataArrayInt32 *findIdsStrictlyNegative() const;
340 MEDCOUPLING_EXPORT typename Traits<T>::ArrayType *fromNoInterlace() const;
341 MEDCOUPLING_EXPORT typename Traits<T>::ArrayType *toNoInterlace() const;
342 MEDCOUPLING_EXPORT void meldWith(const typename Traits<T>::ArrayType *other);
343 MEDCOUPLING_EXPORT typename Traits<T>::ArrayType *duplicateEachTupleNTimes(int nbTimes) const;
344 MEDCOUPLING_EXPORT void aggregate(const typename Traits<T>::ArrayType *other);
345 MEDCOUPLING_EXPORT void abs();
346 MEDCOUPLING_EXPORT typename Traits<T>::ArrayType *computeAbs() const;
347 MEDCOUPLING_EXPORT typename Traits<T>::ArrayType *performCopyOrIncrRef(bool dCpy) const;
348 MEDCOUPLING_EXPORT typename Traits<T>::ArrayType *sumPerTuple() const;
349 MEDCOUPLING_EXPORT void iota(T init=(T)0);
350 MEDCOUPLING_EXPORT void reprStream(std::ostream& stream) const;
351 MEDCOUPLING_EXPORT void reprZipStream(std::ostream& stream) const;
352 MEDCOUPLING_EXPORT void reprNotTooLongStream(std::ostream& stream) const;
353 MEDCOUPLING_EXPORT void reprWithoutNameStream(std::ostream& stream) const;
354 MEDCOUPLING_EXPORT void reprZipWithoutNameStream(std::ostream& stream) const;
355 MEDCOUPLING_EXPORT void reprNotTooLongWithoutNameStream(std::ostream& stream) const;
356 MEDCOUPLING_EXPORT std::string repr() const;
357 MEDCOUPLING_EXPORT std::string reprZip() const;
358 MEDCOUPLING_EXPORT std::string reprNotTooLong() const;
360 MCAuto< typename Traits<U>::ArrayType > convertToOtherTypeOfArr() const;
362 static typename Traits<T>::ArrayType *PerformCopyOrIncrRef(bool dCpy, const typename Traits<T>::ArrayType& self);
364 MCAuto<DataArrayInt32> findIdsAdv(const OP& op) const;
367 void somethingEqual(const typename Traits<T>::ArrayType *other);
371 class DataArrayTemplateFP : public DataArrayTemplateClassic<T>
374 MEDCOUPLING_EXPORT bool isUniform(T val, T eps) const;
378 namespace MEDCoupling
380 class DataArrayFloatIterator;
381 class DataArrayFloat : public DataArrayTemplateFP<float>
384 MEDCOUPLING_EXPORT static DataArrayFloat *New();
385 public:// abstract method overload
386 MEDCOUPLING_EXPORT DataArrayFloat *deepCopy() const;
387 MEDCOUPLING_EXPORT DataArrayFloat *buildNewEmptyInstance() const { return DataArrayFloat::New(); }
388 MEDCOUPLING_EXPORT DataArrayFloat *selectByTupleRanges(const std::vector<std::pair<int,int> >& ranges) const { return DataArrayTemplateFP<float>::mySelectByTupleRanges(ranges); }
389 MEDCOUPLING_EXPORT DataArrayFloat *keepSelectedComponents(const std::vector<int>& compoIds) const { return DataArrayTemplateFP<float>::myKeepSelectedComponents(compoIds); }
390 MEDCOUPLING_EXPORT DataArrayFloat *selectByTupleId(const mcIdType *new2OldBg, const mcIdType *new2OldEnd) const { return this->mySelectByTupleId(new2OldBg,new2OldEnd); }
391 MEDCOUPLING_EXPORT DataArrayFloat *selectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const { return DataArrayTemplateFP<float>::mySelectByTupleIdSafe(new2OldBg,new2OldEnd); }
392 MEDCOUPLING_EXPORT DataArrayFloat *selectByTupleIdSafeSlice(int bg, int end2, int step) const { return DataArrayTemplateFP<float>::mySelectByTupleIdSafeSlice(bg,end2,step); }
393 MEDCOUPLING_EXPORT void reprCppStream(const std::string& varName, std::ostream& stream) const;
394 MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const;
395 MEDCOUPLING_EXPORT void reprQuickOverviewData(std::ostream& stream, std::size_t maxNbOfByteInRepr) const;
396 public:// non abstract but essential
397 MEDCOUPLING_EXPORT bool isEqual(const DataArrayFloat& other, float prec) const;
398 MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const DataArrayFloat& other, float prec, std::string& reason) const;
399 MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const DataArrayFloat& other, float prec) const;
401 MEDCOUPLING_EXPORT DataArrayFloatIterator *iterator();
403 ~DataArrayFloat() { }
408 namespace MEDCoupling
410 class DataArrayDoubleIterator;
411 class DataArrayDouble : public DataArrayTemplateFP<double>
414 MEDCOUPLING_EXPORT static DataArrayDouble *New();
415 MEDCOUPLING_EXPORT double doubleValue() const;
416 MEDCOUPLING_EXPORT DataArrayDouble *deepCopy() const;
417 MEDCOUPLING_EXPORT DataArrayDouble *buildNewEmptyInstance() const { return DataArrayDouble::New(); }
418 MEDCOUPLING_EXPORT void checkMonotonic(bool increasing, double eps) const;
419 MEDCOUPLING_EXPORT bool isMonotonic(bool increasing, double eps) const;
420 MEDCOUPLING_EXPORT void writeVTK(std::ostream& ofs, int indent, const std::string& nameInFile, DataArrayByte *byteArr) const;
421 MEDCOUPLING_EXPORT void reprCppStream(const std::string& varName, std::ostream& stream) const;
422 MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const;
423 MEDCOUPLING_EXPORT void reprQuickOverviewData(std::ostream& stream, std::size_t maxNbOfByteInRepr) const;
424 MEDCOUPLING_EXPORT bool isEqual(const DataArrayDouble& other, double prec) const;
425 MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const DataArrayDouble& other, double prec, std::string& reason) const;
426 MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const DataArrayDouble& other, double prec) const;
427 MEDCOUPLING_EXPORT DataArrayDouble *selectByTupleId(const mcIdType *new2OldBg, const mcIdType *new2OldEnd) const { return this->mySelectByTupleId(new2OldBg,new2OldEnd); }
428 MEDCOUPLING_EXPORT DataArrayDouble *selectByTupleId(const DataArrayIdType& di) const { return this->mySelectByTupleId(di); }
429 MEDCOUPLING_EXPORT DataArrayDouble *selectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const { return DataArrayTemplateFP<double>::mySelectByTupleIdSafe(new2OldBg,new2OldEnd); }
430 MEDCOUPLING_EXPORT DataArrayDouble *keepSelectedComponents(const std::vector<int>& compoIds) const { return DataArrayTemplateFP<double>::myKeepSelectedComponents(compoIds); }
431 MEDCOUPLING_EXPORT DataArrayDouble *selectByTupleIdSafeSlice(int bg, int end2, int step) const { return DataArrayTemplateFP<double>::mySelectByTupleIdSafeSlice(bg,end2,step); }
432 MEDCOUPLING_EXPORT DataArrayDouble *selectByTupleRanges(const std::vector<std::pair<int,int> >& ranges) const { return DataArrayTemplateFP<double>::mySelectByTupleRanges(ranges); }
433 MEDCOUPLING_EXPORT bool areIncludedInMe(const DataArrayDouble *other, double prec, DataArrayInt32 *&tupleIds) const;
434 MEDCOUPLING_EXPORT void findCommonTuples(double prec, int limitTupleId, DataArrayInt32 *&comm, DataArrayInt32 *&commIndex) const;
435 MEDCOUPLING_EXPORT double minimalDistanceTo(const DataArrayDouble *other, int& thisTupleId, int& otherTupleId) const;
436 MEDCOUPLING_EXPORT DataArrayDouble *getDifferentValues(double prec, int limitTupleId=-1) const;
437 MEDCOUPLING_EXPORT DataArrayInt32 *findClosestTupleId(const DataArrayDouble *other) const;
438 MEDCOUPLING_EXPORT DataArrayInt32 *computeNbOfInteractionsWith(const DataArrayDouble *otherBBoxFrmt, double eps) const;
439 MEDCOUPLING_EXPORT void setSelectedComponents(const DataArrayDouble *a, const std::vector<int>& compoIds);
440 MEDCOUPLING_EXPORT DataArrayDoubleIterator *iterator();
441 MEDCOUPLING_EXPORT void checkNoNullValues() const;
442 MEDCOUPLING_EXPORT void getMinMaxPerComponent(double *bounds) const;
443 MEDCOUPLING_EXPORT DataArrayDouble *computeBBoxPerTuple(double epsilon=0.0) const;
444 MEDCOUPLING_EXPORT void computeTupleIdsNearTuples(const DataArrayDouble *other, double eps, DataArrayInt32 *& c, DataArrayInt32 *& cI) const;
445 MEDCOUPLING_EXPORT void recenterForMaxPrecision(double eps);
446 MEDCOUPLING_EXPORT double getMaxValue2(DataArrayInt32*& tupleIds) const;
447 MEDCOUPLING_EXPORT double getMinValue2(DataArrayInt32*& tupleIds) const;
448 MEDCOUPLING_EXPORT int count(double value, double eps) const;
449 MEDCOUPLING_EXPORT double getAverageValue() const;
450 MEDCOUPLING_EXPORT double norm2() const;
451 MEDCOUPLING_EXPORT double normMax() const;
452 MEDCOUPLING_EXPORT void normMaxPerComponent(double * res) const;
453 MEDCOUPLING_EXPORT double normMin() const;
454 MEDCOUPLING_EXPORT void accumulate(double *res) const;
455 MEDCOUPLING_EXPORT double accumulate(int compId) const;
456 MEDCOUPLING_EXPORT DataArrayDouble *accumulatePerChunck(const int *bgOfIndex, const int *endOfIndex) const;
457 MEDCOUPLING_EXPORT MCAuto<DataArrayDouble> cumSum() const;
458 MEDCOUPLING_EXPORT double distanceToTuple(const double *tupleBg, const double *tupleEnd, int& tupleId) const;
459 MEDCOUPLING_EXPORT DataArrayDouble *fromPolarToCart() const;
460 MEDCOUPLING_EXPORT DataArrayDouble *fromCylToCart() const;
461 MEDCOUPLING_EXPORT DataArrayDouble *fromSpherToCart() const;
462 MEDCOUPLING_EXPORT DataArrayDouble *cartesianize(MEDCouplingAxisType atOfThis) const;
463 MEDCOUPLING_EXPORT DataArrayDouble *fromCartToPolar() const;
464 MEDCOUPLING_EXPORT DataArrayDouble *fromCartToCyl() const;
465 MEDCOUPLING_EXPORT DataArrayDouble *fromCartToSpher() const;
466 MEDCOUPLING_EXPORT DataArrayDouble *fromCartToCylGiven(const DataArrayDouble *coords, const double center[3], const double vect[3]) const;
467 MEDCOUPLING_EXPORT DataArrayDouble *doublyContractedProduct() const;
468 MEDCOUPLING_EXPORT DataArrayDouble *determinant() const;
469 MEDCOUPLING_EXPORT DataArrayDouble *eigenValues() const;
470 MEDCOUPLING_EXPORT DataArrayDouble *eigenVectors() const;
471 MEDCOUPLING_EXPORT DataArrayDouble *inverse() const;
472 MEDCOUPLING_EXPORT DataArrayDouble *trace() const;
473 MEDCOUPLING_EXPORT DataArrayDouble *deviator() const;
474 MEDCOUPLING_EXPORT DataArrayDouble *magnitude() const;
475 MEDCOUPLING_EXPORT DataArrayDouble *maxPerTuple() const;
476 MEDCOUPLING_EXPORT DataArrayDouble *maxPerTupleWithCompoId(DataArrayInt32* &compoIdOfMaxPerTuple) const;
477 MEDCOUPLING_EXPORT DataArrayDouble *buildEuclidianDistanceDenseMatrix() const;
478 MEDCOUPLING_EXPORT DataArrayDouble *buildEuclidianDistanceDenseMatrixWith(const DataArrayDouble *other) const;
479 MEDCOUPLING_EXPORT void asArcOfCircle(double center[2], double& radius, double& ang) const;
480 MEDCOUPLING_EXPORT void sortPerTuple(bool asc);
481 MEDCOUPLING_EXPORT void applyInv(double numerator);
482 MEDCOUPLING_EXPORT void applyPow(double val);
483 MEDCOUPLING_EXPORT void applyRPow(double val);
484 MEDCOUPLING_EXPORT DataArrayDouble *applyFunc(int nbOfComp, FunctionToEvaluate func) const;
485 MEDCOUPLING_EXPORT DataArrayDouble *applyFunc(int nbOfComp, const std::string& func, bool isSafe=true) const;
486 MEDCOUPLING_EXPORT DataArrayDouble *applyFunc(const std::string& func, bool isSafe=true) const;
487 MEDCOUPLING_EXPORT void applyFuncOnThis(const std::string& func, bool isSafe=true);
488 MEDCOUPLING_EXPORT DataArrayDouble *applyFuncCompo(int nbOfComp, const std::string& func, bool isSafe=true) const;
489 MEDCOUPLING_EXPORT DataArrayDouble *applyFuncNamedCompo(int nbOfComp, const std::vector<std::string>& varsOrder, const std::string& func, bool isSafe=true) const;
490 MEDCOUPLING_EXPORT void applyFuncFast32(const std::string& func);
491 MEDCOUPLING_EXPORT void applyFuncFast64(const std::string& func);
492 MEDCOUPLING_EXPORT MCAuto<DataArrayDouble> symmetry3DPlane(const double point[3], const double normalVector[3]) const;
493 MEDCOUPLING_EXPORT DataArrayInt32 *findIdsInRange(double vmin, double vmax) const;
494 MEDCOUPLING_EXPORT DataArrayInt32 *findIdsNotInRange(double vmin, double vmax) const;
495 MEDCOUPLING_EXPORT static DataArrayDouble *Aggregate(const DataArrayDouble *a1, const DataArrayDouble *a2);
496 MEDCOUPLING_EXPORT static DataArrayDouble *Aggregate(const std::vector<const DataArrayDouble *>& arr);
497 MEDCOUPLING_EXPORT static DataArrayDouble *Dot(const DataArrayDouble *a1, const DataArrayDouble *a2);
498 MEDCOUPLING_EXPORT static DataArrayDouble *CrossProduct(const DataArrayDouble *a1, const DataArrayDouble *a2);
499 MEDCOUPLING_EXPORT static DataArrayDouble *Max(const DataArrayDouble *a1, const DataArrayDouble *a2);
500 MEDCOUPLING_EXPORT static DataArrayDouble *Min(const DataArrayDouble *a1, const DataArrayDouble *a2);
501 MEDCOUPLING_EXPORT static DataArrayDouble *Pow(const DataArrayDouble *a1, const DataArrayDouble *a2);
502 MEDCOUPLING_EXPORT void powEqual(const DataArrayDouble *other);
503 MEDCOUPLING_EXPORT std::vector<bool> toVectorOfBool(double eps) const;
504 MEDCOUPLING_EXPORT static void Rotate2DAlg(const double *center, double angle, int nbNodes, const double *coordsIn, double *coordsOut);
505 MEDCOUPLING_EXPORT static void Rotate3DAlg(const double *center, const double *vect, double angle, int nbNodes, const double *coordsIn, double *coordsOut);
506 MEDCOUPLING_EXPORT static void Symmetry3DPlane(const double point[3], const double normalVector[3], int nbNodes, const double *coordsIn, double *coordsOut);
507 MEDCOUPLING_EXPORT static void GiveBaseForPlane(const double normalVector[3], double baseOfPlane[9]);
508 MEDCOUPLING_EXPORT static void ComputeIntegralOfSeg2IntoTri3(const double seg2[4], const double tri3[6], double coeffs[3], double& length);
510 MEDCOUPLING_EXPORT void getTinySerializationIntInformation(std::vector<int>& tinyInfo) const;
511 MEDCOUPLING_EXPORT void getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const;
512 MEDCOUPLING_EXPORT bool resizeForUnserialization(const std::vector<int>& tinyInfoI);
513 MEDCOUPLING_EXPORT void finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<std::string>& tinyInfoS);
515 template<int SPACEDIM>
516 void findCommonTuplesAlg(const double *bbox, int nbNodes, int limitNodeId, double prec, DataArrayInt32 *c, DataArrayInt32 *cI) const;
517 template<int SPACEDIM>
518 static void FindClosestTupleIdAlg(const BBTreePts<SPACEDIM,int>& myTree, double dist, const double *pos, int nbOfTuples, const double *thisPt, int thisNbOfTuples, int *res);
519 template<int SPACEDIM>
520 static void FindTupleIdsNearTuplesAlg(const BBTreePts<SPACEDIM,int>& myTree, const double *pos, int nbOfTuples, double eps,
521 DataArrayInt32 *c, DataArrayInt32 *cI);
523 ~DataArrayDouble() { }
524 DataArrayDouble() { }
528 class DataArrayDiscrete : public DataArrayTemplateClassic<T>
531 MEDCOUPLING_EXPORT static typename Traits<T>::ArrayType *New();
532 MEDCOUPLING_EXPORT bool isEqual(const DataArrayDiscrete<T>& other) const;
533 MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const DataArrayDiscrete<T>& other, std::string& reason) const;
534 MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const DataArrayDiscrete<T>& other) const;
535 MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStrAndOrder(const typename Traits<T>::ArrayType& other) const;
536 MEDCOUPLING_EXPORT void switchOnTupleEqualTo(T val, std::vector<bool>& vec) const;
537 MEDCOUPLING_EXPORT void switchOnTupleNotEqualTo(T val, std::vector<bool>& vec) const;
538 MEDCOUPLING_EXPORT DataArrayIdType *buildPermutationArr(const DataArrayDiscrete<T>& other) const;
539 MEDCOUPLING_EXPORT DataArrayIdType *indicesOfSubPart(const DataArrayDiscrete<T>& partOfThis) const;
540 MEDCOUPLING_EXPORT void checkMonotonic(bool increasing) const;
541 MEDCOUPLING_EXPORT bool isMonotonic(bool increasing) const;
542 MEDCOUPLING_EXPORT void checkStrictlyMonotonic(bool increasing) const;
543 MEDCOUPLING_EXPORT bool isStrictlyMonotonic(bool increasing) const;
544 MEDCOUPLING_EXPORT int getHashCode() const;
545 MEDCOUPLING_EXPORT void reprCppStream(const std::string& varName, std::ostream& stream) const;
546 MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const;
547 MEDCOUPLING_EXPORT void reprQuickOverviewData(std::ostream& stream, std::size_t maxNbOfByteInRepr) const;
548 MEDCOUPLING_EXPORT void writeVTK(std::ostream& ofs, int indent, const std::string& type, const std::string& nameInFile, DataArrayByte *byteArr) const;
549 MEDCOUPLING_EXPORT void transformWithIndArr(const T *indArrBg, const T *indArrEnd);
550 MEDCOUPLING_EXPORT void transformWithIndArr(const MapKeyVal<T>& m);
551 MEDCOUPLING_EXPORT DataArrayIdType *findIdsEqual(T val) const;
554 void switchOnTupleAlg(T val, std::vector<bool>& vec, ALG algo) const;
556 ~DataArrayDiscrete() { }
560 class DataArrayDiscreteSigned : public DataArrayDiscrete<T>
563 MEDCOUPLING_EXPORT bool isFittingWith(const std::vector<bool>& v) const;
565 ~DataArrayDiscreteSigned() { }
568 class DataArrayInt32Iterator;
570 class DataArrayInt32 : public DataArrayDiscreteSigned<Int32>
572 friend class DataArrayDiscrete<Int32>;
574 MEDCOUPLING_EXPORT int intValue() const;
575 MEDCOUPLING_EXPORT DataArrayInt32 *deepCopy() const;//ok
576 MEDCOUPLING_EXPORT DataArrayInt32 *buildNewEmptyInstance() const { return DataArrayInt32::New(); }//ok
577 MEDCOUPLING_EXPORT DataArrayInt32 *transformWithIndArrR(const int *indArr2Bg, const int *indArrEnd) const;
578 MEDCOUPLING_EXPORT void splitByValueRange(const int *arrBg, const int *arrEnd,
579 DataArrayInt32 *& castArr, DataArrayInt32 *& rankInsideCast, DataArrayInt32 *& castsPresent) const;
580 MEDCOUPLING_EXPORT bool isRange(int& strt, int& sttoopp, int& stteepp) const;
581 MEDCOUPLING_EXPORT DataArrayInt32 *invertArrayO2N2N2O(int newNbOfElem) const;
582 MEDCOUPLING_EXPORT DataArrayInt32 *invertArrayN2O2O2N(int oldNbOfElem) const;
583 MEDCOUPLING_EXPORT MCAuto< MapKeyVal<int> > invertArrayN2O2O2NOptimized() const;
584 MEDCOUPLING_EXPORT MCAuto< MapKeyVal<int> > giveN2OOptimized() const;
585 MEDCOUPLING_EXPORT DataArrayInt32 *invertArrayO2N2N2OBis(int newNbOfElem) const;
586 MEDCOUPLING_EXPORT DataArrayInt32 *selectByTupleId(const mcIdType *new2OldBg, const mcIdType *new2OldEnd) const { return this->mySelectByTupleId(new2OldBg,new2OldEnd); }
587 MEDCOUPLING_EXPORT DataArrayInt32 *selectByTupleId(const DataArrayIdType& di) const { return this->mySelectByTupleId(di); }
588 MEDCOUPLING_EXPORT DataArrayInt32 *selectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const { return DataArrayTemplate<int>::mySelectByTupleIdSafe(new2OldBg,new2OldEnd); }
589 MEDCOUPLING_EXPORT DataArrayInt32 *keepSelectedComponents(const std::vector<int>& compoIds) const { return DataArrayTemplate<int>::myKeepSelectedComponents(compoIds); }
590 MEDCOUPLING_EXPORT DataArrayInt32 *selectByTupleIdSafeSlice(int bg, int end2, int step) const { return DataArrayTemplate<int>::mySelectByTupleIdSafeSlice(bg,end2,step); }
591 MEDCOUPLING_EXPORT DataArrayInt32 *selectByTupleRanges(const std::vector<std::pair<int,int> >& ranges) const { return DataArrayTemplate<int>::mySelectByTupleRanges(ranges); }
592 MEDCOUPLING_EXPORT DataArrayInt32 *checkAndPreparePermutation() const;
593 MEDCOUPLING_EXPORT static DataArrayInt32 *FindPermutationFromFirstToSecond(const DataArrayInt32 *ids1, const DataArrayInt32 *ids2);
594 MEDCOUPLING_EXPORT void changeSurjectiveFormat(int targetNb, DataArrayInt32 *&arr, DataArrayInt32 *&arrI) const;
595 MEDCOUPLING_EXPORT static DataArrayInt32 *ConvertIndexArrayToO2N(int nbOfOldTuples, const int *arr, const int *arrIBg, const int *arrIEnd, int &newNbOfTuples);
596 MEDCOUPLING_EXPORT DataArrayInt32 *buildPermArrPerLevel() const;
597 MEDCOUPLING_EXPORT bool isIota(int sizeExpected) const;
598 MEDCOUPLING_EXPORT bool isUniform(int val) const;
599 MEDCOUPLING_EXPORT int checkUniformAndGuess() const;
600 MEDCOUPLING_EXPORT bool hasUniqueValues() const;
601 MEDCOUPLING_EXPORT void setSelectedComponents(const DataArrayInt32 *a, const std::vector<int>& compoIds);
602 MEDCOUPLING_EXPORT DataArrayInt32Iterator *iterator();
603 MEDCOUPLING_EXPORT DataArrayInt32 *findIdsNotEqual(int val) const;
604 MEDCOUPLING_EXPORT DataArrayInt32 *findIdsEqualList(const int *valsBg, const int *valsEnd) const;
605 MEDCOUPLING_EXPORT DataArrayInt32 *findIdsNotEqualList(const int *valsBg, const int *valsEnd) const;
606 MEDCOUPLING_EXPORT DataArrayInt32 *findIdsEqualTuple(const int *tupleBg, const int *tupleEnd) const;
607 MEDCOUPLING_EXPORT MCAuto<DataArrayInt32> findIdForEach(const int *valsBg, const int *valsEnd) const;
608 MEDCOUPLING_EXPORT int changeValue(int oldValue, int newValue);
609 MEDCOUPLING_EXPORT int findIdFirstEqualTuple(const std::vector<int>& tupl) const;
610 MEDCOUPLING_EXPORT int findIdFirstEqual(int value) const;
611 MEDCOUPLING_EXPORT int findIdFirstEqual(const std::vector<int>& vals) const;
612 MEDCOUPLING_EXPORT int findIdSequence(const std::vector<int>& vals) const;
613 MEDCOUPLING_EXPORT bool presenceOfTuple(const std::vector<int>& tupl) const;
614 MEDCOUPLING_EXPORT bool presenceOfValue(int value) const;
615 MEDCOUPLING_EXPORT bool presenceOfValue(const std::vector<int>& vals) const;
616 MEDCOUPLING_EXPORT int count(int value) const;
617 MEDCOUPLING_EXPORT void accumulate(int *res) const;
618 MEDCOUPLING_EXPORT int accumulate(int compId) const;
619 MEDCOUPLING_EXPORT DataArrayInt32 *accumulatePerChunck(const int *bgOfIndex, const int *endOfIndex) const;
620 MEDCOUPLING_EXPORT void getMinMaxValues(int& minValue, int& maxValue) const;
621 MEDCOUPLING_EXPORT void applyInv(int numerator);
622 MEDCOUPLING_EXPORT void applyDivideBy(int val);
623 MEDCOUPLING_EXPORT void applyModulus(int val);
624 MEDCOUPLING_EXPORT void applyRModulus(int val);
625 MEDCOUPLING_EXPORT void applyPow(int val);
626 MEDCOUPLING_EXPORT void applyRPow(int val);
627 MEDCOUPLING_EXPORT DataArrayInt32 *findIdsInRange(int vmin, int vmax) const;
628 MEDCOUPLING_EXPORT DataArrayInt32 *findIdsNotInRange(int vmin, int vmax) const;
629 MEDCOUPLING_EXPORT bool checkAllIdsInRange(int vmin, int vmax) const;
630 MEDCOUPLING_EXPORT static DataArrayInt32 *Aggregate(const DataArrayInt32 *a1, const DataArrayInt32 *a2, int offsetA2);
631 MEDCOUPLING_EXPORT static DataArrayInt32 *Aggregate(const std::vector<const DataArrayInt32 *>& arr);
632 MEDCOUPLING_EXPORT static DataArrayInt32 *AggregateIndexes(const std::vector<const DataArrayInt32 *>& arrs);
633 MEDCOUPLING_EXPORT static DataArrayInt32 *MakePartition(const std::vector<const DataArrayInt32 *>& groups, int newNb, std::vector< std::vector<int> >& fidsOfGroups);
634 MEDCOUPLING_EXPORT static DataArrayInt32 *BuildUnion(const std::vector<const DataArrayInt32 *>& arr);
635 MEDCOUPLING_EXPORT static DataArrayInt32 *BuildIntersection(const std::vector<const DataArrayInt32 *>& arr);
636 MEDCOUPLING_EXPORT static DataArrayInt32 *BuildListOfSwitchedOn(const std::vector<bool>& v);
637 MEDCOUPLING_EXPORT static DataArrayInt32 *BuildListOfSwitchedOff(const std::vector<bool>& v);
638 MEDCOUPLING_EXPORT static void PutIntoToSkylineFrmt(const std::vector< std::vector<int> >& v, DataArrayInt32 *& data, DataArrayInt32 *& dataIndex);
639 MEDCOUPLING_EXPORT DataArrayInt32 *buildComplement(int nbOfElement) const;
640 MEDCOUPLING_EXPORT DataArrayInt32 *buildSubstraction(const DataArrayInt32 *other) const;
641 MEDCOUPLING_EXPORT DataArrayInt32 *buildSubstractionOptimized(const DataArrayInt32 *other) const;
642 MEDCOUPLING_EXPORT DataArrayInt32 *buildUnion(const DataArrayInt32 *other) const;
643 MEDCOUPLING_EXPORT DataArrayInt32 *buildIntersection(const DataArrayInt32 *other) const;
644 MEDCOUPLING_EXPORT DataArrayInt32 *buildUnique() const;
645 MEDCOUPLING_EXPORT DataArrayInt32 *buildUniqueNotSorted() const;
646 MEDCOUPLING_EXPORT DataArrayInt32 *deltaShiftIndex() const;
647 MEDCOUPLING_EXPORT void computeOffsets();
648 MEDCOUPLING_EXPORT void computeOffsetsFull();
649 MEDCOUPLING_EXPORT void findIdsRangesInListOfIds(const DataArrayInt32 *listOfIds, DataArrayInt32 *& rangeIdsFetched, DataArrayInt32 *& idsInInputListThatFetch) const;
650 MEDCOUPLING_EXPORT DataArrayInt32 *buildExplicitArrByRanges(const DataArrayInt32 *offsets) const;
651 MEDCOUPLING_EXPORT DataArrayInt32 *buildExplicitArrOfSliceOnScaledArr(int begin, int stop, int step) const;
652 MEDCOUPLING_EXPORT DataArrayInt32 *findRangeIdForEachTuple(const DataArrayInt32 *ranges) const;
653 MEDCOUPLING_EXPORT DataArrayInt32 *findIdInRangeForEachTuple(const DataArrayInt32 *ranges) const;
654 MEDCOUPLING_EXPORT void sortEachPairToMakeALinkedList();
655 MEDCOUPLING_EXPORT MCAuto<DataArrayInt32> fromLinkedListOfPairToList() const;
656 MEDCOUPLING_EXPORT DataArrayInt32 *getDifferentValues() const;
657 MEDCOUPLING_EXPORT std::vector<DataArrayInt32 *> partitionByDifferentValues(std::vector<int>& differentIds) const;
658 MEDCOUPLING_EXPORT std::vector< std::pair<int,int> > splitInBalancedSlices(int nbOfSlices) const;
659 MEDCOUPLING_EXPORT static DataArrayInt32 *Modulus(const DataArrayInt32 *a1, const DataArrayInt32 *a2);
660 MEDCOUPLING_EXPORT void modulusEqual(const DataArrayInt32 *other);
661 MEDCOUPLING_EXPORT static DataArrayInt32 *Pow(const DataArrayInt32 *a1, const DataArrayInt32 *a2);
662 MEDCOUPLING_EXPORT void powEqual(const DataArrayInt32 *other);
663 MEDCOUPLING_EXPORT MemArray<int>& accessToMemArray() { return _mem; }
664 MEDCOUPLING_EXPORT const MemArray<int>& accessToMemArray() const { return _mem; }
666 MEDCOUPLING_EXPORT static void ExtractFromIndexedArrays(const int *idsOfSelectBg, const int *idsOfSelectEnd, const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn,
667 DataArrayInt* &arrOut, DataArrayInt* &arrIndexOut);
668 MEDCOUPLING_EXPORT static void ExtractFromIndexedArraysSlice(int idsOfSelectStart, int idsOfSelectStop, int idsOfSelectStep, const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn,
669 DataArrayInt* &arrOut, DataArrayInt* &arrIndexOut);
670 MEDCOUPLING_EXPORT static void SetPartOfIndexedArrays(const int *idsOfSelectBg, const int *idsOfSelectEnd, const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn,
671 const DataArrayInt *srcArr, const DataArrayInt *srcArrIndex,
672 DataArrayInt* &arrOut, DataArrayInt* &arrIndexOut);
673 MEDCOUPLING_EXPORT static void SetPartOfIndexedArraysSlice(int start, int end, int step, const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn,
674 const DataArrayInt *srcArr, const DataArrayInt *srcArrIndex,
675 DataArrayInt* &arrOut, DataArrayInt* &arrIndexOut);
676 MEDCOUPLING_EXPORT static void SetPartOfIndexedArraysSameIdx(const int *idsOfSelectBg, const int *idsOfSelectEnd, DataArrayInt *arrInOut, const DataArrayInt *arrIndxIn,
677 const DataArrayInt *srcArr, const DataArrayInt *srcArrIndex);
678 MEDCOUPLING_EXPORT static void SetPartOfIndexedArraysSameIdxSlice(int start, int end, int step, DataArrayInt *arrInOut, const DataArrayInt *arrIndxIn,
679 const DataArrayInt *srcArr, const DataArrayInt *srcArrIndex);
680 MEDCOUPLING_EXPORT static bool RemoveIdsFromIndexedArrays(const int *idsToRemoveBg, const int *idsToRemoveEnd, DataArrayInt *arr, DataArrayInt *arrIndx, int offsetForRemoval=0);
681 MEDCOUPLING_EXPORT static int *CheckAndPreparePermutation(const int *start, const int *end);
682 MEDCOUPLING_EXPORT static DataArrayInt32 *Range(int begin, int end, int step);
684 MEDCOUPLING_EXPORT void getTinySerializationIntInformation(std::vector<int>& tinyInfo) const;
685 MEDCOUPLING_EXPORT void getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const;
686 MEDCOUPLING_EXPORT bool resizeForUnserialization(const std::vector<int>& tinyInfoI);
687 MEDCOUPLING_EXPORT void finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<std::string>& tinyInfoS);
689 ~DataArrayInt32() { }
693 class DataArrayInt64 : public DataArrayDiscrete<Int64>
695 friend class DataArrayDiscrete<Int64>;
697 MEDCOUPLING_EXPORT DataArrayInt64 *deepCopy() const;
698 MEDCOUPLING_EXPORT DataArrayInt64 *buildNewEmptyInstance() const { return DataArrayInt64::New(); }//ok
699 MEDCOUPLING_EXPORT DataArrayInt64 *selectByTupleId(const mcIdType *new2OldBg, const mcIdType *new2OldEnd) const { return this->mySelectByTupleId(new2OldBg,new2OldEnd); }
700 MEDCOUPLING_EXPORT DataArrayInt64 *selectByTupleId(const DataArrayIdType& di) const { return this->mySelectByTupleId(di); }
701 MEDCOUPLING_EXPORT DataArrayInt64 *selectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const { return DataArrayTemplate<Int64>::mySelectByTupleIdSafe(new2OldBg,new2OldEnd); }
702 MEDCOUPLING_EXPORT DataArrayInt64 *keepSelectedComponents(const std::vector<int>& compoIds) const { return DataArrayTemplate<Int64>::myKeepSelectedComponents(compoIds); }
703 MEDCOUPLING_EXPORT DataArrayInt64 *selectByTupleIdSafeSlice(int bg, int end2, int step) const { return DataArrayTemplate<Int64>::mySelectByTupleIdSafeSlice(bg,end2,step); }
704 MEDCOUPLING_EXPORT DataArrayInt64 *selectByTupleRanges(const std::vector<std::pair<int,int> >& ranges) const { return DataArrayTemplate<Int64>::mySelectByTupleRanges(ranges); }
706 ~DataArrayInt64() { }
712 MCAuto<DataArrayInt> DataArrayTemplateClassic<T>::findIdsAdv(const OP& op) const
714 this->checkAllocated();
715 if(this->getNumberOfComponents()!=1)
716 throw INTERP_KERNEL::Exception("DataArrayInt::findIdsAdv : this must have exactly one component !");
717 const T *cptr(this->begin());
718 MCAuto<DataArrayInt> ret(DataArrayInt::New()); ret->alloc(0,1);
719 int nbOfTuples(this->getNumberOfTuples());
720 for(int i=0;i<nbOfTuples;i++,cptr++)
722 ret->pushBackSilent(i);
726 class DataArrayChar : public DataArrayTemplate<char>
729 MEDCOUPLING_EXPORT virtual DataArrayChar *buildEmptySpecializedDAChar() const = 0;
730 MEDCOUPLING_EXPORT int getHashCode() const;
731 MEDCOUPLING_EXPORT bool isEqual(const DataArrayChar& other) const;
732 MEDCOUPLING_EXPORT virtual bool isEqualIfNotWhy(const DataArrayChar& other, std::string& reason) const;
733 MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const DataArrayChar& other) const;
734 MEDCOUPLING_EXPORT std::string repr() const;
735 MEDCOUPLING_EXPORT std::string reprZip() const;
736 MEDCOUPLING_EXPORT DataArrayInt *convertToIntArr() const;
737 MEDCOUPLING_EXPORT DataArrayChar *selectByTupleId(const mcIdType *new2OldBg, const mcIdType *new2OldEnd) const { return this->mySelectByTupleId(new2OldBg,new2OldEnd); }
738 MEDCOUPLING_EXPORT DataArrayChar *selectByTupleId(const DataArrayIdType& di) const { return this->mySelectByTupleId(di); }
739 MEDCOUPLING_EXPORT DataArrayChar *selectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const { return DataArrayTemplate<char>::mySelectByTupleIdSafe(new2OldBg,new2OldEnd); }
740 MEDCOUPLING_EXPORT DataArrayChar *keepSelectedComponents(const std::vector<int>& compoIds) const { return DataArrayTemplate<char>::myKeepSelectedComponents(compoIds); }
741 MEDCOUPLING_EXPORT DataArrayChar *selectByTupleIdSafeSlice(int bg, int end2, int step) const { return DataArrayTemplate<char>::mySelectByTupleIdSafeSlice(bg,end2,step); }
742 MEDCOUPLING_EXPORT bool isUniform(char val) const;
743 MEDCOUPLING_EXPORT void meldWith(const DataArrayChar *other);
744 MEDCOUPLING_EXPORT DataArray *selectByTupleRanges(const std::vector<std::pair<int,int> >& ranges) const { return DataArrayTemplate<char>::mySelectByTupleRanges(ranges); }
745 MEDCOUPLING_EXPORT DataArrayInt *findIdsEqual(char val) const;
746 MEDCOUPLING_EXPORT DataArrayInt *findIdsNotEqual(char val) const;
747 MEDCOUPLING_EXPORT int findIdSequence(const std::vector<char>& vals) const;
748 MEDCOUPLING_EXPORT int findIdFirstEqualTuple(const std::vector<char>& tupl) const;
749 MEDCOUPLING_EXPORT int findIdFirstEqual(char value) const;
750 MEDCOUPLING_EXPORT int findIdFirstEqual(const std::vector<char>& vals) const;
751 MEDCOUPLING_EXPORT bool presenceOfTuple(const std::vector<char>& tupl) const;
752 MEDCOUPLING_EXPORT bool presenceOfValue(char value) const;
753 MEDCOUPLING_EXPORT bool presenceOfValue(const std::vector<char>& vals) const;
754 MEDCOUPLING_EXPORT DataArrayInt *findIdsInRange(char vmin, char vmax) const;
755 MEDCOUPLING_EXPORT static DataArrayChar *Aggregate(const DataArrayChar *a1, const DataArrayChar *a2);
756 MEDCOUPLING_EXPORT static DataArrayChar *Aggregate(const std::vector<const DataArrayChar *>& arr);
757 MEDCOUPLING_EXPORT static DataArrayChar *Meld(const DataArrayChar *a1, const DataArrayChar *a2);
758 MEDCOUPLING_EXPORT static DataArrayChar *Meld(const std::vector<const DataArrayChar *>& arr);
759 MEDCOUPLING_EXPORT MemArray<char>& accessToMemArray() { return _mem; }
760 MEDCOUPLING_EXPORT const MemArray<char>& accessToMemArray() const { return _mem; }
762 //MEDCOUPLING_EXPORT void getTinySerializationIntInformation(std::vector<int>& tinyInfo) const;
763 //MEDCOUPLING_EXPORT void getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const;
764 //MEDCOUPLING_EXPORT bool resizeForUnserialization(const std::vector<int>& tinyInfoI);
765 //MEDCOUPLING_EXPORT void finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<std::string>& tinyInfoS);
770 class DataArrayByteIterator;
772 class DataArrayByte : public DataArrayChar
775 MEDCOUPLING_EXPORT static DataArrayByte *New();
776 MEDCOUPLING_EXPORT DataArrayChar *buildEmptySpecializedDAChar() const;
777 MEDCOUPLING_EXPORT DataArrayByteIterator *iterator();
778 MEDCOUPLING_EXPORT DataArrayByte *deepCopy() const;
779 MEDCOUPLING_EXPORT DataArrayByte *performCopyOrIncrRef(bool deepCopy) const;
780 MEDCOUPLING_EXPORT DataArrayByte *buildNewEmptyInstance() const { return DataArrayByte::New(); }
781 MEDCOUPLING_EXPORT char byteValue() const;
782 MEDCOUPLING_EXPORT void reprStream(std::ostream& stream) const;
783 MEDCOUPLING_EXPORT void reprZipStream(std::ostream& stream) const;
784 MEDCOUPLING_EXPORT void reprWithoutNameStream(std::ostream& stream) const;
785 MEDCOUPLING_EXPORT void reprZipWithoutNameStream(std::ostream& stream) const;
786 MEDCOUPLING_EXPORT void reprCppStream(const std::string& varName, std::ostream& stream) const;
787 MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const;
788 MEDCOUPLING_EXPORT void reprQuickOverviewData(std::ostream& stream, std::size_t maxNbOfByteInRepr) const;
789 MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const DataArrayChar& other, std::string& reason) const;
790 MEDCOUPLING_EXPORT std::vector<bool> toVectorOfBool() const;
796 class DataArrayAsciiCharIterator;
798 class DataArrayAsciiChar : public DataArrayChar
801 MEDCOUPLING_EXPORT static DataArrayAsciiChar *New();
802 MEDCOUPLING_EXPORT static DataArrayAsciiChar *New(const std::string& st);
803 MEDCOUPLING_EXPORT static DataArrayAsciiChar *New(const std::vector<std::string>& vst, char defaultChar);
804 MEDCOUPLING_EXPORT DataArrayChar *buildEmptySpecializedDAChar() const;
805 MEDCOUPLING_EXPORT DataArrayAsciiCharIterator *iterator();
806 MEDCOUPLING_EXPORT DataArrayAsciiChar *deepCopy() const;
807 MEDCOUPLING_EXPORT DataArrayAsciiChar *performCopyOrIncrRef(bool deepCopy) const;
808 MEDCOUPLING_EXPORT DataArrayAsciiChar *buildNewEmptyInstance() const { return DataArrayAsciiChar::New(); }
809 MEDCOUPLING_EXPORT char asciiCharValue() const;
810 MEDCOUPLING_EXPORT void reprStream(std::ostream& stream) const;
811 MEDCOUPLING_EXPORT void reprZipStream(std::ostream& stream) const;
812 MEDCOUPLING_EXPORT void reprWithoutNameStream(std::ostream& stream) const;
813 MEDCOUPLING_EXPORT void reprZipWithoutNameStream(std::ostream& stream) const;
814 MEDCOUPLING_EXPORT void reprCppStream(const std::string& varName, std::ostream& stream) const;
815 MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const;
816 MEDCOUPLING_EXPORT void reprQuickOverviewData(std::ostream& stream, std::size_t maxNbOfByteInRepr) const;
817 MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const DataArrayChar& other, std::string& reason) const;
819 ~DataArrayAsciiChar() { }
820 DataArrayAsciiChar() { }
821 DataArrayAsciiChar(const std::string& st);
822 DataArrayAsciiChar(const std::vector<std::string>& vst, char defaultChar);
826 class DataArrayIterator
829 DataArrayIterator(typename Traits<T>::ArrayType *da);
830 ~DataArrayIterator();
831 MEDCOUPLING_EXPORT typename Traits<T>::ArrayTuple *nextt();
833 typename Traits<T>::ArrayType *_da;
844 MEDCOUPLING_EXPORT DataArrayTuple(T *pt, int nbOfComp);
845 MEDCOUPLING_EXPORT std::string repr() const;
846 MEDCOUPLING_EXPORT int getNumberOfCompo() const { return _nb_of_compo; }
847 MEDCOUPLING_EXPORT const T *getConstPointer() const { return _pt; }
848 MEDCOUPLING_EXPORT T *getPointer() { return _pt; }
849 MEDCOUPLING_EXPORT typename Traits<T>::ArrayType *buildDA(int nbOfTuples, int nbOfCompo) const;
857 class DataArrayDoubleTuple;
859 class DataArrayDoubleIterator : public DataArrayIterator<double>
862 MEDCOUPLING_EXPORT DataArrayDoubleIterator(DataArrayDouble *da);
863 MEDCOUPLING_EXPORT ~DataArrayDoubleIterator() { }
866 class DataArrayDoubleTuple : public DataArrayTuple<double>
869 MEDCOUPLING_EXPORT DataArrayDoubleTuple(double *pt, int nbOfComp);
870 MEDCOUPLING_EXPORT std::string repr() const;
871 MEDCOUPLING_EXPORT double doubleValue() const;
872 MEDCOUPLING_EXPORT DataArrayDouble *buildDADouble(int nbOfTuples, int nbOfCompo) const;
875 class DataArrayFloatTuple;
877 class DataArrayFloatIterator : public DataArrayIterator<float>
880 MEDCOUPLING_EXPORT DataArrayFloatIterator(DataArrayFloat *da);
881 MEDCOUPLING_EXPORT ~DataArrayFloatIterator() { }
884 class DataArrayFloatTuple : public DataArrayTuple<float>
887 MEDCOUPLING_EXPORT DataArrayFloatTuple(float *pt, int nbOfComp);
888 MEDCOUPLING_EXPORT std::string repr() const;
889 MEDCOUPLING_EXPORT float floatValue() const;
890 MEDCOUPLING_EXPORT DataArrayFloat *buildDAFloat(int nbOfTuples, int nbOfCompo) const;
893 class DataArrayIntIterator : public DataArrayIterator<int>
896 MEDCOUPLING_EXPORT DataArrayIntIterator(DataArrayInt *da);
897 MEDCOUPLING_EXPORT ~DataArrayIntIterator() { }
900 class DataArrayInt32Tuple : public DataArrayTuple<Int32>
903 MEDCOUPLING_EXPORT DataArrayInt32Tuple(int *pt, int nbOfComp);
904 MEDCOUPLING_EXPORT std::string repr() const;
905 MEDCOUPLING_EXPORT int intValue() const;
906 MEDCOUPLING_EXPORT DataArrayInt32 *buildDAInt(int nbOfTuples, int nbOfCompo) const;
909 typedef DataArrayInt32Tuple DataArrayIntTuple;
911 class DataArrayAsciiCharTuple;
913 class DataArrayAsciiCharIterator
916 MEDCOUPLING_EXPORT DataArrayAsciiCharIterator(DataArrayAsciiChar *da);
917 MEDCOUPLING_EXPORT ~DataArrayAsciiCharIterator();
918 MEDCOUPLING_EXPORT DataArrayAsciiCharTuple *nextt();
920 DataArrayAsciiChar *_da;
927 class DataArrayAsciiCharTuple
930 MEDCOUPLING_EXPORT DataArrayAsciiCharTuple(char *pt, int nbOfComp);
931 MEDCOUPLING_EXPORT std::string repr() const;
932 MEDCOUPLING_EXPORT int getNumberOfCompo() const { return _nb_of_compo; }
933 MEDCOUPLING_EXPORT const char *getConstPointer() const { return _pt; }
934 MEDCOUPLING_EXPORT char *getPointer() { return _pt; }
935 MEDCOUPLING_EXPORT char asciiCharValue() const;
936 MEDCOUPLING_EXPORT DataArrayAsciiChar *buildDAAsciiChar(int nbOfTuples, int nbOfCompo) const;
942 class DataArrayByteTuple;
944 class DataArrayByteIterator
947 MEDCOUPLING_EXPORT DataArrayByteIterator(DataArrayByte *da);
948 MEDCOUPLING_EXPORT ~DataArrayByteIterator();
949 MEDCOUPLING_EXPORT DataArrayByteTuple *nextt();
958 class DataArrayByteTuple
961 MEDCOUPLING_EXPORT DataArrayByteTuple(char *pt, int nbOfComp);
962 MEDCOUPLING_EXPORT std::string repr() const;
963 MEDCOUPLING_EXPORT int getNumberOfCompo() const { return _nb_of_compo; }
964 MEDCOUPLING_EXPORT const char *getConstPointer() const { return _pt; }
965 MEDCOUPLING_EXPORT char *getPointer() { return _pt; }
966 MEDCOUPLING_EXPORT char byteValue() const;
967 MEDCOUPLING_EXPORT DataArrayByte *buildDAByte(int nbOfTuples, int nbOfCompo) const;
974 namespace MEDCoupling
977 template<class InputIterator>
978 void MemArray<T>::insertAtTheEnd(InputIterator first, InputIterator last)
980 T *pointer=_pointer.getPointer();
983 if(_nb_of_elem>=_nb_of_elem_alloc)
985 reserve(_nb_of_elem_alloc>0?2*_nb_of_elem_alloc:1);
986 pointer=_pointer.getPointer();
988 pointer[_nb_of_elem++]=*first++;
993 template<class InputIterator>
994 void DataArrayTemplate<T>::insertAtTheEnd(InputIterator first, InputIterator last)
996 int nbCompo(this->getNumberOfComponents());
998 this->_mem.insertAtTheEnd(first,last);
1001 this->_info_on_compo.resize(1);
1002 this->_mem.insertAtTheEnd(first,last);
1005 throw INTERP_KERNEL::Exception("DataArrayDouble::insertAtTheEnd : not available for DataArrayDouble with number of components different than 1 !");