Back to index

salome-med  6.5.0
MEDCouplingMemArray.hxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 #ifndef __PARAMEDMEM_MEDCOUPLINGMEMARRAY_HXX__
00021 #define __PARAMEDMEM_MEDCOUPLINGMEMARRAY_HXX__
00022 
00023 #include "MEDCoupling.hxx"
00024 #include "MEDCouplingTimeLabel.hxx"
00025 #include "MEDCouplingRefCountObject.hxx"
00026 #include "InterpKernelException.hxx"
00027 
00028 #include <set>
00029 #include <string>
00030 #include <vector>
00031 #include <iterator>
00032 
00033 namespace ParaMEDMEM
00034 {
00035   template<class T>
00036   class MEDCouplingPointer
00037   {
00038   public:
00039     MEDCouplingPointer():_internal(0),_external(0) { }
00040     void null() { _internal=0; _external=0; }
00041     bool isNull() const { return _internal==0 && _external==0; }
00042     void setInternal(T *pointer);
00043     void setExternal(const T *pointer);
00044     const T *getConstPointer() const { if(_internal) return _internal; else return _external; }
00045     const T *getConstPointerLoc(int offset) const { if(_internal) return _internal+offset; else return _external+offset; }
00046     T *getPointer() { if(_internal) return _internal; if(_external) throw INTERP_KERNEL::Exception("Trying to write on an external pointer."); else return 0; }
00047   private:
00048     T *_internal;
00049     const T *_external;
00050   };
00051 
00052   template<class T>
00053   class MemArray
00054   {
00055   public:
00056     MemArray():_nb_of_elem(-1),_ownership(false),_dealloc(CPP_DEALLOC) { }
00057     MemArray(const MemArray<T>& other);
00058     bool isNull() const { return _pointer.isNull(); }
00059     const T *getConstPointerLoc(int offset) const { return _pointer.getConstPointerLoc(offset); }
00060     const T *getConstPointer() const { return _pointer.getConstPointer(); }
00061     T *getPointer() { return _pointer.getPointer(); }
00062     MemArray<T> &operator=(const MemArray<T>& other);
00063     T operator[](int id) const { return _pointer.getConstPointer()[id]; }
00064     T& operator[](int id) { return _pointer.getPointer()[id]; }
00065     bool isEqual(const MemArray<T>& other, T prec) const;
00066     void repr(int sl, std::ostream& stream) const;
00067     void reprZip(int sl, std::ostream& stream) const;
00068     void fillWithValue(const T& val);
00069     T *fromNoInterlace(int nbOfComp) const;
00070     T *toNoInterlace(int nbOfComp) const;
00071     void sort();
00072     void reverse();
00073     void alloc(int nbOfElements) throw(INTERP_KERNEL::Exception);
00074     void reAlloc(int newNbOfElements) throw(INTERP_KERNEL::Exception);
00075     void useArray(const T *array, bool ownership, DeallocType type, int nbOfElem);
00076     void writeOnPlace(int id, T element0, const T *others, int sizeOfOthers);
00077     ~MemArray() { destroy(); }
00078   private:
00079     void destroy();
00080     static void destroyPointer(T *pt, DeallocType type);
00081   private:
00082     int _nb_of_elem;
00083     bool _ownership;
00084     MEDCouplingPointer<T> _pointer;
00085     DeallocType _dealloc;
00086   };
00087 
00088   class DataArray : public RefCountObject, public TimeLabel
00089   {
00090   public:
00091     MEDCOUPLING_EXPORT void setName(const char *name);
00092     MEDCOUPLING_EXPORT void copyStringInfoFrom(const DataArray& other) throw(INTERP_KERNEL::Exception);
00093     MEDCOUPLING_EXPORT void copyPartOfStringInfoFrom(const DataArray& other, const std::vector<int>& compoIds) throw(INTERP_KERNEL::Exception);
00094     MEDCOUPLING_EXPORT void copyPartOfStringInfoFrom2(const std::vector<int>& compoIds, const DataArray& other) throw(INTERP_KERNEL::Exception);
00095     MEDCOUPLING_EXPORT bool areInfoEquals(const DataArray& other) const;
00096     MEDCOUPLING_EXPORT void reprWithoutNameStream(std::ostream& stream) const;
00097     MEDCOUPLING_EXPORT std::string getName() const { return _name; }
00098     MEDCOUPLING_EXPORT const std::vector<std::string> &getInfoOnComponents() const { return _info_on_compo; }
00099     MEDCOUPLING_EXPORT std::vector<std::string> &getInfoOnComponents() { return _info_on_compo; }
00100     MEDCOUPLING_EXPORT void setInfoOnComponents(const std::vector<std::string>& info) throw(INTERP_KERNEL::Exception);
00101     MEDCOUPLING_EXPORT std::vector<std::string> getVarsOnComponent() const;
00102     MEDCOUPLING_EXPORT std::vector<std::string> getUnitsOnComponent() const;
00103     MEDCOUPLING_EXPORT std::string getInfoOnComponent(int i) const throw(INTERP_KERNEL::Exception);
00104     MEDCOUPLING_EXPORT std::string getVarOnComponent(int i) const throw(INTERP_KERNEL::Exception);
00105     MEDCOUPLING_EXPORT std::string getUnitOnComponent(int i) const throw(INTERP_KERNEL::Exception);
00106     MEDCOUPLING_EXPORT void setInfoOnComponent(int i, const char *info) throw(INTERP_KERNEL::Exception);
00107     MEDCOUPLING_EXPORT int getNumberOfComponents() const { return (int)_info_on_compo.size(); }
00108     MEDCOUPLING_EXPORT int getNumberOfTuples() const { return _nb_of_tuples; }
00109     MEDCOUPLING_EXPORT int getNbOfElems() const { return ((int)_info_on_compo.size())*_nb_of_tuples; }
00110     MEDCOUPLING_EXPORT void checkNbOfTuplesAndComp(const DataArray& other, const char *msg) const throw(INTERP_KERNEL::Exception);
00111     MEDCOUPLING_EXPORT void checkNbOfTuplesAndComp(int nbOfTuples, int nbOfCompo, const char *msg) const throw(INTERP_KERNEL::Exception);
00112     MEDCOUPLING_EXPORT void checkNbOfElems(int nbOfElems, const char *msg) const throw(INTERP_KERNEL::Exception);
00113     MEDCOUPLING_EXPORT static int GetNumberOfItemGivenBES(int begin, int end, int step, const char *msg) throw(INTERP_KERNEL::Exception);
00114     MEDCOUPLING_EXPORT static int GetNumberOfItemGivenBESRelative(int begin, int end, int step, const char *msg) throw(INTERP_KERNEL::Exception);
00115     MEDCOUPLING_EXPORT static std::string GetVarNameFromInfo(const std::string& info) throw(INTERP_KERNEL::Exception);
00116     MEDCOUPLING_EXPORT static std::string GetUnitFromInfo(const std::string& info) throw(INTERP_KERNEL::Exception);
00117   protected:
00118     DataArray():_nb_of_tuples(-1) { }
00119   protected:
00120     static void CheckValueInRange(int ref, int value, const char *msg) throw(INTERP_KERNEL::Exception);
00121     static void CheckClosingParInRange(int ref, int value, const char *msg) throw(INTERP_KERNEL::Exception);
00122   protected:
00123     int _nb_of_tuples;
00124     std::string _name;
00125     std::vector<std::string> _info_on_compo;
00126   };
00127 }
00128 
00129 #include "MEDCouplingMemArray.txx"
00130 
00131 namespace ParaMEDMEM
00132 {
00133   class DataArrayInt;
00134   class DataArrayDoubleIterator;
00135   class DataArrayDouble : public DataArray
00136   {
00137   public:
00138     MEDCOUPLING_EXPORT static DataArrayDouble *New();
00139     MEDCOUPLING_EXPORT bool isAllocated() const;
00140     MEDCOUPLING_EXPORT void checkAllocated() const throw(INTERP_KERNEL::Exception);
00141     MEDCOUPLING_EXPORT void setInfoAndChangeNbOfCompo(const std::vector<std::string>& info) throw(INTERP_KERNEL::Exception);
00142     MEDCOUPLING_EXPORT double doubleValue() const throw(INTERP_KERNEL::Exception);
00143     MEDCOUPLING_EXPORT bool empty() const throw(INTERP_KERNEL::Exception);
00144     MEDCOUPLING_EXPORT DataArrayDouble *deepCpy() const;
00145     MEDCOUPLING_EXPORT DataArrayDouble *performCpy(bool deepCpy) const;
00146     MEDCOUPLING_EXPORT void cpyFrom(const DataArrayDouble& other) throw(INTERP_KERNEL::Exception);
00147     MEDCOUPLING_EXPORT void alloc(int nbOfTuple, int nbOfCompo) throw(INTERP_KERNEL::Exception);
00148     MEDCOUPLING_EXPORT void allocIfNecessary(int nbOfTuple, int nbOfCompo);
00149     MEDCOUPLING_EXPORT void fillWithZero() throw(INTERP_KERNEL::Exception);
00150     MEDCOUPLING_EXPORT void fillWithValue(double val) throw(INTERP_KERNEL::Exception);
00151     MEDCOUPLING_EXPORT void iota(double init=0.) throw(INTERP_KERNEL::Exception);
00152     MEDCOUPLING_EXPORT bool isUniform(double val, double eps) const throw(INTERP_KERNEL::Exception);
00153     MEDCOUPLING_EXPORT void sort() throw(INTERP_KERNEL::Exception);
00154     MEDCOUPLING_EXPORT void reverse() throw(INTERP_KERNEL::Exception);
00155     MEDCOUPLING_EXPORT void checkMonotonic(bool increasing, double eps) const throw(INTERP_KERNEL::Exception);
00156     MEDCOUPLING_EXPORT bool isMonotonic(bool increasing, double eps) const throw(INTERP_KERNEL::Exception);
00157     MEDCOUPLING_EXPORT std::string repr() const;
00158     MEDCOUPLING_EXPORT std::string reprZip() const;
00159     MEDCOUPLING_EXPORT void writeVTK(std::ostream& ofs, int indent, const char *nameInFile) const throw(INTERP_KERNEL::Exception);
00160     MEDCOUPLING_EXPORT void reprStream(std::ostream& stream) const;
00161     MEDCOUPLING_EXPORT void reprZipStream(std::ostream& stream) const;
00162     MEDCOUPLING_EXPORT void reprWithoutNameStream(std::ostream& stream) const;
00163     MEDCOUPLING_EXPORT void reprZipWithoutNameStream(std::ostream& stream) const;
00164     MEDCOUPLING_EXPORT bool isEqual(const DataArrayDouble& other, double prec) const;
00165     MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const DataArrayDouble& other, double prec) const;
00167     MEDCOUPLING_EXPORT void reAlloc(int nbOfTuples) throw(INTERP_KERNEL::Exception);
00168     MEDCOUPLING_EXPORT DataArrayInt *convertToIntArr() const;
00169     MEDCOUPLING_EXPORT DataArrayDouble *fromNoInterlace() const throw(INTERP_KERNEL::Exception);
00170     MEDCOUPLING_EXPORT DataArrayDouble *toNoInterlace() const throw(INTERP_KERNEL::Exception);
00171     MEDCOUPLING_EXPORT void renumberInPlace(const int *old2New);
00172     MEDCOUPLING_EXPORT void renumberInPlaceR(const int *new2Old);
00173     MEDCOUPLING_EXPORT DataArrayDouble *renumber(const int *old2New) const;
00174     MEDCOUPLING_EXPORT DataArrayDouble *renumberR(const int *new2Old) const;
00175     MEDCOUPLING_EXPORT DataArrayDouble *renumberAndReduce(const int *old2New, int newNbOfTuple) const;
00176     MEDCOUPLING_EXPORT DataArrayDouble *selectByTupleId(const int *new2OldBg, const int *new2OldEnd) const;
00177     MEDCOUPLING_EXPORT DataArrayDouble *selectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const throw(INTERP_KERNEL::Exception);
00178     MEDCOUPLING_EXPORT DataArrayDouble *selectByTupleId2(int bg, int end2, int step) const throw(INTERP_KERNEL::Exception);
00179     MEDCOUPLING_EXPORT DataArrayDouble *selectByTupleRanges(const std::vector<std::pair<int,int> >& ranges) const throw(INTERP_KERNEL::Exception);
00180     MEDCOUPLING_EXPORT DataArrayDouble *substr(int tupleIdBg, int tupleIdEnd=-1) const throw(INTERP_KERNEL::Exception);
00181     MEDCOUPLING_EXPORT void rearrange(int newNbOfCompo) throw(INTERP_KERNEL::Exception);
00182     MEDCOUPLING_EXPORT void transpose() throw(INTERP_KERNEL::Exception);
00183     MEDCOUPLING_EXPORT DataArrayDouble *changeNbOfComponents(int newNbOfComp, double dftValue) const throw(INTERP_KERNEL::Exception);
00184     MEDCOUPLING_EXPORT DataArrayDouble *keepSelectedComponents(const std::vector<int>& compoIds) const throw(INTERP_KERNEL::Exception);
00185     MEDCOUPLING_EXPORT void meldWith(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception);
00186     MEDCOUPLING_EXPORT void findCommonTuples(double prec, int limitTupleId, DataArrayInt *&comm, DataArrayInt *&commIndex) const throw(INTERP_KERNEL::Exception);
00187     MEDCOUPLING_EXPORT DataArrayDouble *getDifferentValues(double prec, int limitTupleId=-1) const throw(INTERP_KERNEL::Exception);
00188     MEDCOUPLING_EXPORT void setSelectedComponents(const DataArrayDouble *a, const std::vector<int>& compoIds) throw(INTERP_KERNEL::Exception);
00189     MEDCOUPLING_EXPORT void setPartOfValues1(const DataArrayDouble *a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare=true) throw(INTERP_KERNEL::Exception);
00190     MEDCOUPLING_EXPORT void setPartOfValuesSimple1(double a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp) throw(INTERP_KERNEL::Exception);
00191     MEDCOUPLING_EXPORT void setPartOfValues2(const DataArrayDouble *a, const int *bgTuples, const int *endTuples, const int *bgComp, const int *endComp, bool strictCompoCompare=true) throw(INTERP_KERNEL::Exception);
00192     MEDCOUPLING_EXPORT void setPartOfValuesSimple2(double a, const int *bgTuples, const int *endTuples, const int *bgComp, const int *endComp) throw(INTERP_KERNEL::Exception);
00193     MEDCOUPLING_EXPORT void setPartOfValues3(const DataArrayDouble *a, const int *bgTuples, const int *endTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare=true) throw(INTERP_KERNEL::Exception);
00194     MEDCOUPLING_EXPORT void setPartOfValuesSimple3(double a, const int *bgTuples, const int *endTuples, int bgComp, int endComp, int stepComp) throw(INTERP_KERNEL::Exception);
00195     MEDCOUPLING_EXPORT void setPartOfValuesAdv(const DataArrayDouble *a, const DataArrayInt *tuplesSelec) throw(INTERP_KERNEL::Exception);
00196     MEDCOUPLING_EXPORT void setContigPartOfSelectedValues(int tupleIdStart, const DataArrayDouble *a, const DataArrayInt *tuplesSelec) throw(INTERP_KERNEL::Exception);
00197     MEDCOUPLING_EXPORT void setContigPartOfSelectedValues2(int tupleIdStart, const DataArrayDouble *a, int bg, int end2, int step) throw(INTERP_KERNEL::Exception);
00198     MEDCOUPLING_EXPORT void getTuple(int tupleId, double *res) const { std::copy(_mem.getConstPointerLoc(tupleId*((int)_info_on_compo.size())),_mem.getConstPointerLoc((tupleId+1)*((int)_info_on_compo.size())),res); }
00199     MEDCOUPLING_EXPORT double getIJ(int tupleId, int compoId) const { return _mem[tupleId*((int)_info_on_compo.size())+compoId]; }
00200     MEDCOUPLING_EXPORT double back() const throw(INTERP_KERNEL::Exception);
00201     MEDCOUPLING_EXPORT double getIJSafe(int tupleId, int compoId) const throw(INTERP_KERNEL::Exception);
00202     MEDCOUPLING_EXPORT void setIJ(int tupleId, int compoId, double newVal) { _mem[tupleId*((int)_info_on_compo.size())+compoId]=newVal; declareAsNew(); }
00203     MEDCOUPLING_EXPORT void setIJSilent(int tupleId, int compoId, double newVal) { _mem[tupleId*((int)_info_on_compo.size())+compoId]=newVal; }
00204     MEDCOUPLING_EXPORT double *getPointer() { return _mem.getPointer(); }
00205     MEDCOUPLING_EXPORT static void SetArrayIn(DataArrayDouble *newArray, DataArrayDouble* &arrayToSet);
00206     MEDCOUPLING_EXPORT const double *getConstPointer() const { return _mem.getConstPointer(); }
00207     MEDCOUPLING_EXPORT DataArrayDoubleIterator *iterator();
00208     MEDCOUPLING_EXPORT const double *begin() const { return getConstPointer(); }
00209     MEDCOUPLING_EXPORT const double *end() const { return getConstPointer()+getNbOfElems(); }
00210     MEDCOUPLING_EXPORT void useArray(const double *array, bool ownership, DeallocType type, int nbOfTuple, int nbOfCompo);
00211     MEDCOUPLING_EXPORT void writeOnPlace(int id, double element0, const double *others, int sizeOfOthers) { _mem.writeOnPlace(id,element0,others,sizeOfOthers); }
00212     MEDCOUPLING_EXPORT void checkNoNullValues() const throw(INTERP_KERNEL::Exception);
00213     MEDCOUPLING_EXPORT void getMinMaxPerComponent(double *bounds) const throw(INTERP_KERNEL::Exception);
00214     MEDCOUPLING_EXPORT double getMaxValue(int& tupleId) const throw(INTERP_KERNEL::Exception);
00215     MEDCOUPLING_EXPORT double getMaxValueInArray() const throw(INTERP_KERNEL::Exception);
00216     MEDCOUPLING_EXPORT double getMinValue(int& tupleId) const throw(INTERP_KERNEL::Exception);
00217     MEDCOUPLING_EXPORT double getMinValueInArray() const throw(INTERP_KERNEL::Exception);
00218     MEDCOUPLING_EXPORT double getMaxValue2(DataArrayInt*& tupleIds) const throw(INTERP_KERNEL::Exception);
00219     MEDCOUPLING_EXPORT double getMinValue2(DataArrayInt*& tupleIds) const throw(INTERP_KERNEL::Exception);
00220     MEDCOUPLING_EXPORT double getAverageValue() const throw(INTERP_KERNEL::Exception);
00221     MEDCOUPLING_EXPORT double norm2() const throw(INTERP_KERNEL::Exception);
00222     MEDCOUPLING_EXPORT double normMax() const throw(INTERP_KERNEL::Exception);
00223     MEDCOUPLING_EXPORT void accumulate(double *res) const throw(INTERP_KERNEL::Exception);
00224     MEDCOUPLING_EXPORT double accumulate(int compId) const throw(INTERP_KERNEL::Exception);
00225     MEDCOUPLING_EXPORT DataArrayDouble *fromPolarToCart() const throw(INTERP_KERNEL::Exception);
00226     MEDCOUPLING_EXPORT DataArrayDouble *fromCylToCart() const throw(INTERP_KERNEL::Exception);
00227     MEDCOUPLING_EXPORT DataArrayDouble *fromSpherToCart() const throw(INTERP_KERNEL::Exception);
00228     MEDCOUPLING_EXPORT DataArrayDouble *doublyContractedProduct() const throw(INTERP_KERNEL::Exception);
00229     MEDCOUPLING_EXPORT DataArrayDouble *determinant() const throw(INTERP_KERNEL::Exception);
00230     MEDCOUPLING_EXPORT DataArrayDouble *eigenValues() const throw(INTERP_KERNEL::Exception);
00231     MEDCOUPLING_EXPORT DataArrayDouble *eigenVectors() const throw(INTERP_KERNEL::Exception);
00232     MEDCOUPLING_EXPORT DataArrayDouble *inverse() const throw(INTERP_KERNEL::Exception);
00233     MEDCOUPLING_EXPORT DataArrayDouble *trace() const throw(INTERP_KERNEL::Exception);
00234     MEDCOUPLING_EXPORT DataArrayDouble *deviator() const throw(INTERP_KERNEL::Exception);
00235     MEDCOUPLING_EXPORT DataArrayDouble *magnitude() const throw(INTERP_KERNEL::Exception);
00236     MEDCOUPLING_EXPORT DataArrayDouble *maxPerTuple() const throw(INTERP_KERNEL::Exception);
00237     MEDCOUPLING_EXPORT void sortPerTuple(bool asc) throw(INTERP_KERNEL::Exception);
00238     MEDCOUPLING_EXPORT void abs() throw(INTERP_KERNEL::Exception);
00239     MEDCOUPLING_EXPORT void applyLin(double a, double b, int compoId) throw(INTERP_KERNEL::Exception);
00240     MEDCOUPLING_EXPORT void applyLin(double a, double b) throw(INTERP_KERNEL::Exception);
00241     MEDCOUPLING_EXPORT void applyInv(double numerator) throw(INTERP_KERNEL::Exception);
00242     MEDCOUPLING_EXPORT DataArrayDouble *negate() const throw(INTERP_KERNEL::Exception);
00243     MEDCOUPLING_EXPORT DataArrayDouble *applyFunc(int nbOfComp, FunctionToEvaluate func) const throw(INTERP_KERNEL::Exception);
00244     MEDCOUPLING_EXPORT DataArrayDouble *applyFunc(int nbOfComp, const char *func) const throw(INTERP_KERNEL::Exception);
00245     MEDCOUPLING_EXPORT DataArrayDouble *applyFunc(const char *func) const throw(INTERP_KERNEL::Exception);
00246     MEDCOUPLING_EXPORT DataArrayDouble *applyFunc2(int nbOfComp, const char *func) const throw(INTERP_KERNEL::Exception);
00247     MEDCOUPLING_EXPORT DataArrayDouble *applyFunc3(int nbOfComp, const std::vector<std::string>& varsOrder, const char *func) const throw(INTERP_KERNEL::Exception);
00248     MEDCOUPLING_EXPORT void applyFuncFast32(const char *func) throw(INTERP_KERNEL::Exception);
00249     MEDCOUPLING_EXPORT void applyFuncFast64(const char *func) throw(INTERP_KERNEL::Exception);
00250     MEDCOUPLING_EXPORT DataArrayInt *getIdsInRange(double vmin, double vmax) const throw(INTERP_KERNEL::Exception);
00251     MEDCOUPLING_EXPORT static DataArrayDouble *Aggregate(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception);
00252     MEDCOUPLING_EXPORT static DataArrayDouble *Aggregate(const std::vector<const DataArrayDouble *>& a) throw(INTERP_KERNEL::Exception);
00253     MEDCOUPLING_EXPORT static DataArrayDouble *Meld(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception);
00254     MEDCOUPLING_EXPORT static DataArrayDouble *Meld(const std::vector<const DataArrayDouble *>& a) throw(INTERP_KERNEL::Exception);
00255     MEDCOUPLING_EXPORT static DataArrayDouble *Dot(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception);
00256     MEDCOUPLING_EXPORT static DataArrayDouble *CrossProduct(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception);
00257     MEDCOUPLING_EXPORT static DataArrayDouble *Max(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception);
00258     MEDCOUPLING_EXPORT static DataArrayDouble *Min(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception);
00259     MEDCOUPLING_EXPORT static DataArrayDouble *Add(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception);
00260     MEDCOUPLING_EXPORT void addEqual(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception);
00261     MEDCOUPLING_EXPORT static DataArrayDouble *Substract(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception);
00262     MEDCOUPLING_EXPORT void substractEqual(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception);
00263     MEDCOUPLING_EXPORT static DataArrayDouble *Multiply(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception);
00264     MEDCOUPLING_EXPORT void multiplyEqual(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception);
00265     MEDCOUPLING_EXPORT static DataArrayDouble *Divide(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception);
00266     MEDCOUPLING_EXPORT void divideEqual(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception);
00268     MEDCOUPLING_EXPORT void updateTime() const { }
00269   public:
00270     MEDCOUPLING_EXPORT void getTinySerializationIntInformation(std::vector<int>& tinyInfo) const;
00271     MEDCOUPLING_EXPORT void getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const;
00272     MEDCOUPLING_EXPORT bool resizeForUnserialization(const std::vector<int>& tinyInfoI);
00273     MEDCOUPLING_EXPORT void finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<std::string>& tinyInfoS);
00274   protected:
00275     template<int SPACEDIM>
00276     void findCommonTuplesAlg(std::vector<double>& bbox,
00277                              int nbNodes, int limitNodeId, double prec, std::vector<int>& c, std::vector<int>& cI) const;
00278   private:
00279     DataArrayDouble() { }
00280   private:
00281     MemArray<double> _mem;
00282   };
00283 
00284   class DataArrayDoubleTuple;
00285 
00286   class MEDCOUPLING_EXPORT DataArrayDoubleIterator
00287   {
00288   public:
00289     DataArrayDoubleIterator(DataArrayDouble *da);
00290     ~DataArrayDoubleIterator();
00291      DataArrayDoubleTuple *nextt();
00292   private:
00293     DataArrayDouble *_da;
00294     double *_pt;
00295     int _tuple_id;
00296     int _nb_comp;
00297     int _nb_tuple;
00298   };
00299 
00300   class MEDCOUPLING_EXPORT DataArrayDoubleTuple
00301   {
00302   public:
00303     DataArrayDoubleTuple(double *pt, int nbOfComp);
00304     std::string repr() const;
00305     int getNumberOfCompo() const { return _nb_of_compo; }
00306     const double *getConstPointer() const { return  _pt; }
00307     double *getPointer() { return _pt; }
00308     double doubleValue() const throw(INTERP_KERNEL::Exception);
00309     DataArrayDouble *buildDADouble(int nbOfTuples, int nbOfCompo) const throw(INTERP_KERNEL::Exception);
00310   private:
00311     double *_pt;
00312     int _nb_of_compo;
00313   };
00314 
00315   class DataArrayIntIterator;
00316 
00317   class DataArrayInt : public DataArray
00318   {
00319   public:
00320     MEDCOUPLING_EXPORT static DataArrayInt *New();
00321     MEDCOUPLING_EXPORT bool isAllocated() const;
00322     MEDCOUPLING_EXPORT void checkAllocated() const throw(INTERP_KERNEL::Exception);
00323     MEDCOUPLING_EXPORT void setInfoAndChangeNbOfCompo(const std::vector<std::string>& info) throw(INTERP_KERNEL::Exception);
00324     MEDCOUPLING_EXPORT int intValue() const throw(INTERP_KERNEL::Exception);
00325     MEDCOUPLING_EXPORT int getHashCode() const throw(INTERP_KERNEL::Exception);
00326     MEDCOUPLING_EXPORT bool empty() const throw(INTERP_KERNEL::Exception);
00327     MEDCOUPLING_EXPORT DataArrayInt *deepCpy() const;
00328     MEDCOUPLING_EXPORT DataArrayInt *performCpy(bool deepCpy) const;
00329     MEDCOUPLING_EXPORT void cpyFrom(const DataArrayInt& other) throw(INTERP_KERNEL::Exception);
00330     MEDCOUPLING_EXPORT void alloc(int nbOfTuple, int nbOfCompo) throw(INTERP_KERNEL::Exception);
00331     MEDCOUPLING_EXPORT void allocIfNecessary(int nbOfTuple, int nbOfCompo);
00332     MEDCOUPLING_EXPORT bool isEqual(const DataArrayInt& other) const;
00333     MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const DataArrayInt& other) const;
00334     MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStrAndOrder(const DataArrayInt& other) const throw(INTERP_KERNEL::Exception);
00335     MEDCOUPLING_EXPORT DataArrayInt *buildPermutationArr(const DataArrayInt& other) const throw(INTERP_KERNEL::Exception);
00336     MEDCOUPLING_EXPORT void sort() throw(INTERP_KERNEL::Exception);
00337     MEDCOUPLING_EXPORT void reverse() throw(INTERP_KERNEL::Exception);
00338     MEDCOUPLING_EXPORT void fillWithZero() throw(INTERP_KERNEL::Exception);
00339     MEDCOUPLING_EXPORT void fillWithValue(int val) throw(INTERP_KERNEL::Exception);
00340     MEDCOUPLING_EXPORT void iota(int init=0) throw(INTERP_KERNEL::Exception);
00341     MEDCOUPLING_EXPORT std::string repr() const;
00342     MEDCOUPLING_EXPORT std::string reprZip() const;
00343     MEDCOUPLING_EXPORT void writeVTK(std::ostream& ofs, int indent, const char *type, const char *nameInFile) const throw(INTERP_KERNEL::Exception);
00344     MEDCOUPLING_EXPORT void reprStream(std::ostream& stream) const;
00345     MEDCOUPLING_EXPORT void reprZipStream(std::ostream& stream) const;
00346     MEDCOUPLING_EXPORT void reprWithoutNameStream(std::ostream& stream) const;
00347     MEDCOUPLING_EXPORT void reprZipWithoutNameStream(std::ostream& stream) const;
00348     MEDCOUPLING_EXPORT void transformWithIndArr(const int *indArrBg, const int *indArrEnd) throw(INTERP_KERNEL::Exception);
00349     MEDCOUPLING_EXPORT DataArrayInt *transformWithIndArrR(const int *indArrBg, const int *indArrEnd) const throw(INTERP_KERNEL::Exception);
00350     MEDCOUPLING_EXPORT void splitByValueRange(const int *arrBg, const int *arrEnd,
00351                                               DataArrayInt *& castArr, DataArrayInt *& rankInsideCast, DataArrayInt *& castsPresent) const throw(INTERP_KERNEL::Exception);
00352     MEDCOUPLING_EXPORT DataArrayInt *invertArrayO2N2N2O(int newNbOfElem) const;
00353     MEDCOUPLING_EXPORT DataArrayInt *invertArrayN2O2O2N(int oldNbOfElem) const;
00355     MEDCOUPLING_EXPORT void reAlloc(int nbOfTuples) throw(INTERP_KERNEL::Exception);
00356     MEDCOUPLING_EXPORT DataArrayDouble *convertToDblArr() const;
00357     MEDCOUPLING_EXPORT DataArrayInt *fromNoInterlace() const throw(INTERP_KERNEL::Exception);
00358     MEDCOUPLING_EXPORT DataArrayInt *toNoInterlace() const throw(INTERP_KERNEL::Exception);
00359     MEDCOUPLING_EXPORT void renumberInPlace(const int *old2New);
00360     MEDCOUPLING_EXPORT void renumberInPlaceR(const int *new2Old);
00361     MEDCOUPLING_EXPORT DataArrayInt *renumber(const int *old2New) const;
00362     MEDCOUPLING_EXPORT DataArrayInt *renumberR(const int *new2Old) const;
00363     MEDCOUPLING_EXPORT DataArrayInt *renumberAndReduce(const int *old2NewBg, int newNbOfTuple) const;
00364     MEDCOUPLING_EXPORT DataArrayInt *selectByTupleId(const int *new2OldBg, const int *new2OldEnd) const;
00365     MEDCOUPLING_EXPORT DataArrayInt *selectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const throw(INTERP_KERNEL::Exception);
00366     MEDCOUPLING_EXPORT DataArrayInt *selectByTupleId2(int bg, int end, int step) const throw(INTERP_KERNEL::Exception);
00367     MEDCOUPLING_EXPORT DataArrayInt *selectByTupleRanges(const std::vector<std::pair<int,int> >& ranges) const throw(INTERP_KERNEL::Exception);
00368     MEDCOUPLING_EXPORT DataArrayInt *checkAndPreparePermutation() const throw(INTERP_KERNEL::Exception);
00369     MEDCOUPLING_EXPORT void changeSurjectiveFormat(int targetNb, DataArrayInt *&arr, DataArrayInt *&arrI) const throw(INTERP_KERNEL::Exception);
00370     MEDCOUPLING_EXPORT static DataArrayInt *BuildOld2NewArrayFromSurjectiveFormat2(int nbOfOldTuples, const DataArrayInt *arr, const DataArrayInt *arrI, int &newNbOfTuples) throw(INTERP_KERNEL::Exception);
00371     MEDCOUPLING_EXPORT DataArrayInt *buildPermArrPerLevel() const throw(INTERP_KERNEL::Exception);
00372     MEDCOUPLING_EXPORT bool isIdentity() const throw(INTERP_KERNEL::Exception);
00373     MEDCOUPLING_EXPORT bool isUniform(int val) const throw(INTERP_KERNEL::Exception);
00374     MEDCOUPLING_EXPORT DataArrayInt *substr(int tupleIdBg, int tupleIdEnd=-1) const throw(INTERP_KERNEL::Exception);
00375     MEDCOUPLING_EXPORT void rearrange(int newNbOfCompo) throw(INTERP_KERNEL::Exception);
00376     MEDCOUPLING_EXPORT void transpose() throw(INTERP_KERNEL::Exception);
00377     MEDCOUPLING_EXPORT DataArrayInt *changeNbOfComponents(int newNbOfComp, int dftValue) const throw(INTERP_KERNEL::Exception);
00378     MEDCOUPLING_EXPORT DataArrayInt *keepSelectedComponents(const std::vector<int>& compoIds) const throw(INTERP_KERNEL::Exception);
00379     MEDCOUPLING_EXPORT void meldWith(const DataArrayInt *other) throw(INTERP_KERNEL::Exception);
00380     MEDCOUPLING_EXPORT void setSelectedComponents(const DataArrayInt *a, const std::vector<int>& compoIds) throw(INTERP_KERNEL::Exception);
00381     MEDCOUPLING_EXPORT void setPartOfValues1(const DataArrayInt *a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare=true) throw(INTERP_KERNEL::Exception);
00382     MEDCOUPLING_EXPORT void setPartOfValuesSimple1(int a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp) throw(INTERP_KERNEL::Exception);
00383     MEDCOUPLING_EXPORT void setPartOfValues2(const DataArrayInt *a, const int *bgTuples, const int *endTuples, const int *bgComp, const int *endComp, bool strictCompoCompare=true) throw(INTERP_KERNEL::Exception);
00384     MEDCOUPLING_EXPORT void setPartOfValuesSimple2(int a, const int *bgTuples, const int *endTuples, const int *bgComp, const int *endComp) throw(INTERP_KERNEL::Exception);
00385     MEDCOUPLING_EXPORT void setPartOfValues3(const DataArrayInt *a, const int *bgTuples, const int *endTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare=true) throw(INTERP_KERNEL::Exception);
00386     MEDCOUPLING_EXPORT void setPartOfValuesSimple3(int a, const int *bgTuples, const int *endTuples, int bgComp, int endComp, int stepComp) throw(INTERP_KERNEL::Exception);
00387     MEDCOUPLING_EXPORT void setPartOfValuesAdv(const DataArrayInt *a, const DataArrayInt *tuplesSelec) throw(INTERP_KERNEL::Exception);
00388     MEDCOUPLING_EXPORT void setContigPartOfSelectedValues(int tupleIdStart, const DataArrayInt*a, const DataArrayInt *tuplesSelec) throw(INTERP_KERNEL::Exception);
00389     MEDCOUPLING_EXPORT void setContigPartOfSelectedValues2(int tupleIdStart, const DataArrayInt *a, int bg, int end2, int step) throw(INTERP_KERNEL::Exception);
00390     MEDCOUPLING_EXPORT void getTuple(int tupleId, int *res) const { std::copy(_mem.getConstPointerLoc(tupleId*((int)_info_on_compo.size())),_mem.getConstPointerLoc((tupleId+1)*((int)_info_on_compo.size())),res); }
00391     MEDCOUPLING_EXPORT int getIJ(int tupleId, int compoId) const { return _mem[tupleId*((int)_info_on_compo.size())+compoId]; }
00392     MEDCOUPLING_EXPORT int getIJSafe(int tupleId, int compoId) const throw(INTERP_KERNEL::Exception);
00393     MEDCOUPLING_EXPORT int back() const throw(INTERP_KERNEL::Exception);
00394     MEDCOUPLING_EXPORT void setIJ(int tupleId, int compoId, int newVal) { _mem[tupleId*((int)_info_on_compo.size())+compoId]=newVal; declareAsNew(); }
00395     MEDCOUPLING_EXPORT void setIJSilent(int tupleId, int compoId, int newVal) { _mem[tupleId*((int)_info_on_compo.size())+compoId]=newVal; }
00396     MEDCOUPLING_EXPORT int *getPointer() { return _mem.getPointer(); }
00397     MEDCOUPLING_EXPORT static void SetArrayIn(DataArrayInt *newArray, DataArrayInt* &arrayToSet);
00398     MEDCOUPLING_EXPORT const int *getConstPointer() const { return _mem.getConstPointer(); }
00399     MEDCOUPLING_EXPORT DataArrayIntIterator *iterator();
00400     MEDCOUPLING_EXPORT const int *begin() const { return getConstPointer(); }
00401     MEDCOUPLING_EXPORT const int *end() const { return getConstPointer()+getNbOfElems(); }
00402     MEDCOUPLING_EXPORT DataArrayInt *getIdsEqual(int val) const throw(INTERP_KERNEL::Exception);
00403     MEDCOUPLING_EXPORT DataArrayInt *getIdsNotEqual(int val) const throw(INTERP_KERNEL::Exception);
00404     MEDCOUPLING_EXPORT DataArrayInt *getIdsEqualList(const std::vector<int>& vals) const throw(INTERP_KERNEL::Exception);
00405     MEDCOUPLING_EXPORT DataArrayInt *getIdsNotEqualList(const std::vector<int>& vals) const throw(INTERP_KERNEL::Exception);
00406     MEDCOUPLING_EXPORT int changeValue(int oldValue, int newValue) throw(INTERP_KERNEL::Exception);
00407     MEDCOUPLING_EXPORT bool presenceOfValue(const std::vector<int>& vals) const throw(INTERP_KERNEL::Exception);
00408     MEDCOUPLING_EXPORT int getMaxValue(int& tupleId) const throw(INTERP_KERNEL::Exception);
00409     MEDCOUPLING_EXPORT int getMaxValueInArray() const throw(INTERP_KERNEL::Exception);
00410     MEDCOUPLING_EXPORT int getMinValue(int& tupleId) const throw(INTERP_KERNEL::Exception);
00411     MEDCOUPLING_EXPORT int getMinValueInArray() const throw(INTERP_KERNEL::Exception);
00412     MEDCOUPLING_EXPORT void abs() throw(INTERP_KERNEL::Exception);
00413     MEDCOUPLING_EXPORT void applyLin(int a, int b, int compoId) throw(INTERP_KERNEL::Exception);
00414     MEDCOUPLING_EXPORT void applyLin(int a, int b) throw(INTERP_KERNEL::Exception);
00415     MEDCOUPLING_EXPORT void applyInv(int numerator) throw(INTERP_KERNEL::Exception);
00416     MEDCOUPLING_EXPORT DataArrayInt *negate() const throw(INTERP_KERNEL::Exception);
00417     MEDCOUPLING_EXPORT void applyDivideBy(int val) throw(INTERP_KERNEL::Exception);
00418     MEDCOUPLING_EXPORT void applyModulus(int val) throw(INTERP_KERNEL::Exception);
00419     MEDCOUPLING_EXPORT void applyRModulus(int val) throw(INTERP_KERNEL::Exception);
00420     MEDCOUPLING_EXPORT static DataArrayInt *Aggregate(const DataArrayInt *a1, const DataArrayInt *a2, int offsetA2);
00421     MEDCOUPLING_EXPORT static DataArrayInt *Aggregate(const std::vector<const DataArrayInt *>& a) throw(INTERP_KERNEL::Exception);
00422     MEDCOUPLING_EXPORT static DataArrayInt *Meld(const DataArrayInt *a1, const DataArrayInt *a2) throw(INTERP_KERNEL::Exception);
00423     MEDCOUPLING_EXPORT static DataArrayInt *Meld(const std::vector<const DataArrayInt *>& a) throw(INTERP_KERNEL::Exception);
00424     MEDCOUPLING_EXPORT static DataArrayInt *MakePartition(const std::vector<const DataArrayInt *>& groups, int newNb, std::vector< std::vector<int> >& fidsOfGroups);
00425     MEDCOUPLING_EXPORT static DataArrayInt *BuildUnion(const std::vector<const DataArrayInt *>& a) throw(INTERP_KERNEL::Exception);
00426     MEDCOUPLING_EXPORT static DataArrayInt *BuildIntersection(const std::vector<const DataArrayInt *>& a) throw(INTERP_KERNEL::Exception);
00427     MEDCOUPLING_EXPORT DataArrayInt *buildComplement(int nbOfElement) const throw(INTERP_KERNEL::Exception);
00428     MEDCOUPLING_EXPORT DataArrayInt *buildSubstraction(const DataArrayInt *other) const throw(INTERP_KERNEL::Exception);
00429     MEDCOUPLING_EXPORT DataArrayInt *buildUnion(const DataArrayInt *other) const throw(INTERP_KERNEL::Exception);
00430     MEDCOUPLING_EXPORT DataArrayInt *buildIntersection(const DataArrayInt *other) const throw(INTERP_KERNEL::Exception);
00431     MEDCOUPLING_EXPORT DataArrayInt *deltaShiftIndex() const throw(INTERP_KERNEL::Exception);
00432     MEDCOUPLING_EXPORT void computeOffsets() throw(INTERP_KERNEL::Exception);
00433     MEDCOUPLING_EXPORT void computeOffsets2() throw(INTERP_KERNEL::Exception);
00434     MEDCOUPLING_EXPORT DataArrayInt *buildExplicitArrByRanges(const DataArrayInt *offsets) const throw(INTERP_KERNEL::Exception);
00435     MEDCOUPLING_EXPORT std::set<int> getDifferentValues() const throw(INTERP_KERNEL::Exception);
00436     MEDCOUPLING_EXPORT void useArray(const int *array, bool ownership, DeallocType type, int nbOfTuple, int nbOfCompo);
00437     MEDCOUPLING_EXPORT void writeOnPlace(int id, int element0, const int *others, int sizeOfOthers) { _mem.writeOnPlace(id,element0,others,sizeOfOthers); }
00438     MEDCOUPLING_EXPORT static DataArrayInt *Add(const DataArrayInt *a1, const DataArrayInt *a2) throw(INTERP_KERNEL::Exception);
00439     MEDCOUPLING_EXPORT void addEqual(const DataArrayInt *other) throw(INTERP_KERNEL::Exception);
00440     MEDCOUPLING_EXPORT static DataArrayInt *Substract(const DataArrayInt *a1, const DataArrayInt *a2) throw(INTERP_KERNEL::Exception);
00441     MEDCOUPLING_EXPORT void substractEqual(const DataArrayInt *other) throw(INTERP_KERNEL::Exception);
00442     MEDCOUPLING_EXPORT static DataArrayInt *Multiply(const DataArrayInt *a1, const DataArrayInt *a2) throw(INTERP_KERNEL::Exception);
00443     MEDCOUPLING_EXPORT void multiplyEqual(const DataArrayInt *other) throw(INTERP_KERNEL::Exception);
00444     MEDCOUPLING_EXPORT static DataArrayInt *Divide(const DataArrayInt *a1, const DataArrayInt *a2) throw(INTERP_KERNEL::Exception);
00445     MEDCOUPLING_EXPORT void divideEqual(const DataArrayInt *other) throw(INTERP_KERNEL::Exception);
00446     MEDCOUPLING_EXPORT static DataArrayInt *Modulus(const DataArrayInt *a1, const DataArrayInt *a2) throw(INTERP_KERNEL::Exception);
00447     MEDCOUPLING_EXPORT void modulusEqual(const DataArrayInt *other) throw(INTERP_KERNEL::Exception);
00449     MEDCOUPLING_EXPORT void updateTime() const { }
00450   public:
00451     MEDCOUPLING_EXPORT static int *CheckAndPreparePermutation(const int *start, const int *end);
00452     MEDCOUPLING_EXPORT static DataArrayInt *Range(int begin, int end, int step) throw(INTERP_KERNEL::Exception);
00453   public:
00454     MEDCOUPLING_EXPORT void getTinySerializationIntInformation(std::vector<int>& tinyInfo) const;
00455     MEDCOUPLING_EXPORT void getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const;
00456     MEDCOUPLING_EXPORT bool resizeForUnserialization(const std::vector<int>& tinyInfoI);
00457     MEDCOUPLING_EXPORT void finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<std::string>& tinyInfoS);
00458   private:
00459     DataArrayInt() { }
00460   private:
00461     MemArray<int> _mem;
00462   };
00463 
00464   class DataArrayIntTuple;
00465 
00466   class MEDCOUPLING_EXPORT DataArrayIntIterator
00467   {
00468   public:
00469     DataArrayIntIterator(DataArrayInt *da);
00470     ~DataArrayIntIterator();
00471      DataArrayIntTuple *nextt();
00472   private:
00473     DataArrayInt *_da;
00474     int *_pt;
00475     int _tuple_id;
00476     int _nb_comp;
00477     int _nb_tuple;
00478   };
00479 
00480   class MEDCOUPLING_EXPORT DataArrayIntTuple
00481   {
00482   public:
00483     DataArrayIntTuple(int *pt, int nbOfComp);
00484     std::string repr() const;
00485     int getNumberOfCompo() const { return _nb_of_compo; }
00486     const int *getConstPointer() const { return  _pt; }
00487     int *getPointer() { return _pt; }
00488     int intValue() const throw(INTERP_KERNEL::Exception);
00489     DataArrayInt *buildDAInt(int nbOfTuples, int nbOfCompo) const throw(INTERP_KERNEL::Exception);
00490   private:
00491     int *_pt;
00492     int _nb_of_compo;
00493   };
00494 }
00495 
00496 #endif