X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDCoupling%2FMEDCouplingMemArray.hxx;h=6e74370e405bc464b9081d6495d0030c566662bc;hb=e7835cba1eb17f50ef4e130c2cb8d0f54bc25083;hp=59fd39043247e8caa53a7cce34dd70ac4ae603c7;hpb=4ad5cbc849666c76b440b3541e1a7684466b8955;p=tools%2Fmedcoupling.git diff --git a/src/MEDCoupling/MEDCouplingMemArray.hxx b/src/MEDCoupling/MEDCouplingMemArray.hxx index 59fd39043..6e74370e4 100644 --- a/src/MEDCoupling/MEDCouplingMemArray.hxx +++ b/src/MEDCoupling/MEDCouplingMemArray.hxx @@ -16,17 +16,19 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// Author : Anthony Geay (CEA/DEN) +// Author : Anthony Geay (EDF R&D) #ifndef __MEDCOUPLING_MEDCOUPLINGMEMARRAY_HXX__ #define __MEDCOUPLING_MEDCOUPLINGMEMARRAY_HXX__ #include "MEDCoupling.hxx" +#include "MCType.hxx" #include "MCAuto.hxx" #include "MEDCouplingTimeLabel.hxx" #include "MEDCouplingRefCountObject.hxx" #include "InterpKernelException.hxx" #include "MEDCouplingTraits.hxx" +#include "MEDCouplingMap.hxx" #include "BBTreePts.txx" #include @@ -122,7 +124,7 @@ namespace MEDCoupling void *_param_for_deallocator; }; - class DataArrayInt; + class DataArrayInt32; class DataArrayByte; class DataArray : public RefCountObject, public TimeLabel @@ -156,14 +158,14 @@ namespace MEDCoupling MEDCOUPLING_EXPORT virtual bool isAllocated() const = 0; MEDCOUPLING_EXPORT virtual void checkAllocated() const = 0; MEDCOUPLING_EXPORT virtual void desallocate() = 0; - MEDCOUPLING_EXPORT virtual int getNumberOfTuples() const = 0; + MEDCOUPLING_EXPORT virtual std::size_t getNumberOfTuples() const = 0; MEDCOUPLING_EXPORT virtual std::size_t getNbOfElems() const = 0; MEDCOUPLING_EXPORT virtual std::size_t getNbOfElemAllocated() const = 0; MEDCOUPLING_EXPORT virtual void alloc(std::size_t nbOfTuple, std::size_t nbOfCompo=1) = 0; MEDCOUPLING_EXPORT virtual void reAlloc(std::size_t newNbOfTuple) = 0; MEDCOUPLING_EXPORT virtual void renumberInPlace(const int *old2New) = 0; MEDCOUPLING_EXPORT virtual void renumberInPlaceR(const int *new2Old) = 0; - MEDCOUPLING_EXPORT virtual void setContigPartOfSelectedValues(int tupleIdStart, const DataArray *aBase, const DataArrayInt *tuplesSelec) = 0; + MEDCOUPLING_EXPORT virtual void setContigPartOfSelectedValues(int tupleIdStart, const DataArray *aBase, const DataArrayInt32 *tuplesSelec) = 0; MEDCOUPLING_EXPORT virtual void setContigPartOfSelectedValuesSlice(int tupleIdStart, const DataArray *aBase, int bg, int end2, int step) = 0; MEDCOUPLING_EXPORT virtual DataArray *selectByTupleRanges(const std::vector >& ranges) const = 0; MEDCOUPLING_EXPORT virtual DataArray *keepSelectedComponents(const std::vector& compoIds) const = 0; @@ -211,11 +213,13 @@ namespace MEDCoupling namespace MEDCoupling { - class DataArrayInt; + class DataArrayInt32; template class DataArrayTemplate : public DataArray { + public: + typedef T Type; public: MEDCOUPLING_EXPORT static MCAuto< typename Traits::ArrayTypeCh > NewFromStdVector(const typename std::vector& v); MEDCOUPLING_EXPORT std::vector< MCAuto< typename Traits::ArrayTypeCh > > explodeComponents() const; @@ -223,7 +227,7 @@ namespace MEDCoupling std::size_t getHeapMemorySizeWithoutChildren() const; MEDCOUPLING_EXPORT void updateTime() const { } // - MEDCOUPLING_EXPORT int getNumberOfTuples() const { return _info_on_compo.empty()?0:_mem.getNbOfElem()/getNumberOfComponents(); } + MEDCOUPLING_EXPORT std::size_t getNumberOfTuples() const { return _info_on_compo.empty()?0:_mem.getNbOfElem()/getNumberOfComponents(); } MEDCOUPLING_EXPORT std::size_t getNbOfElems() const { return _mem.getNbOfElem(); } bool empty() const; MEDCOUPLING_EXPORT void *getVoidStarPointer() { return getPointer(); } @@ -276,19 +280,27 @@ namespace MEDCoupling void setPartOfValuesSimple3(T a, const int *bgTuples, const int *endTuples, int bgComp, int endComp, int stepComp); void setPartOfValues4(const typename Traits::ArrayType *a, int bgTuples, int endTuples, int stepTuples, const int *bgComp, const int *endComp, bool strictCompoCompare=true); void setPartOfValuesSimple4(T a, int bgTuples, int endTuples, int stepTuples, const int *bgComp, const int *endComp); - void setPartOfValuesAdv(const typename Traits::ArrayType *a, const DataArrayInt *tuplesSelec); - void setContigPartOfSelectedValues(int tupleIdStart, const DataArray *aBase, const DataArrayInt *tuplesSelec); + void setPartOfValuesAdv(const typename Traits::ArrayType *a, const DataArrayInt32 *tuplesSelec); + void setContigPartOfSelectedValues(int tupleIdStart, const DataArray *aBase, const DataArrayInt32 *tuplesSelec); void setContigPartOfSelectedValuesSlice(int tupleIdStart, const DataArray *aBase, int bg, int end2, int step); T getMaxValue(int& tupleId) const; T getMaxValueInArray() const; + T getMaxAbsValue(std::size_t& tupleId) const; + T getMaxAbsValueInArray() const; T getMinValue(int& tupleId) const; T getMinValueInArray() const; + 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); } + template + void insertAtTheEnd(InputIterator first, InputIterator last); + MEDCOUPLING_EXPORT static void SetArrayIn(typename Traits::ArrayType *newArray, typename Traits::ArrayType* &arrayToSet); + MEDCOUPLING_EXPORT void writeOnPlace(std::size_t id, T element0, const T *others, int sizeOfOthers) { _mem.writeOnPlace(id,element0,others,sizeOfOthers); } + MEDCOUPLING_EXPORT void fillWithZero(); public: MEDCOUPLING_EXPORT MemArray& accessToMemArray() { return _mem; } MEDCOUPLING_EXPORT const MemArray& accessToMemArray() const { return _mem; } protected: typename Traits::ArrayType *mySelectByTupleId(const int *new2OldBg, const int *new2OldEnd) const; - typename Traits::ArrayType *mySelectByTupleId(const DataArrayInt& di) const; + typename Traits::ArrayType *mySelectByTupleId(const DataArrayInt32& di) const; typename Traits::ArrayType *mySelectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const; typename Traits::ArrayType *myKeepSelectedComponents(const std::vector& compoIds) const; typename Traits::ArrayType *mySelectByTupleIdSafeSlice(int bg, int end2, int step) const; @@ -302,7 +314,7 @@ namespace MEDCoupling { public: MEDCOUPLING_EXPORT MCAuto convertToDblArr() const; - MEDCOUPLING_EXPORT MCAuto convertToIntArr() const; + MEDCOUPLING_EXPORT MCAuto convertToIntArr() const; MEDCOUPLING_EXPORT MCAuto convertToFloatArr() const; MEDCOUPLING_EXPORT void applyLin(T a, T b, int compoId); MEDCOUPLING_EXPORT void applyLin(T a, T b); @@ -315,11 +327,37 @@ namespace MEDCoupling MEDCOUPLING_EXPORT static typename Traits::ArrayType *Divide(const typename Traits::ArrayType *a1, const typename Traits::ArrayType *a2); MEDCOUPLING_EXPORT static typename Traits::ArrayType *Add(const typename Traits::ArrayType *a1, const typename Traits::ArrayType *a2); MEDCOUPLING_EXPORT static typename Traits::ArrayType *Multiply(const typename Traits::ArrayType *a1, const typename Traits::ArrayType *a2); + MEDCOUPLING_EXPORT static typename Traits::ArrayType *Meld(const typename Traits::ArrayType *a1, const typename Traits::ArrayType *a2); + MEDCOUPLING_EXPORT static typename Traits::ArrayType *Meld(const std::vector::ArrayType *>& arr); + MEDCOUPLING_EXPORT MCAuto findIdsGreaterOrEqualTo(T val) const; + MEDCOUPLING_EXPORT MCAuto findIdsGreaterThan(T val) const; + MEDCOUPLING_EXPORT MCAuto findIdsLowerOrEqualTo(T val) const; + MEDCOUPLING_EXPORT MCAuto findIdsLowerThan(T val) const; + MEDCOUPLING_EXPORT DataArrayInt32 *findIdsStrictlyNegative() const; + MEDCOUPLING_EXPORT typename Traits::ArrayType *fromNoInterlace() const; + MEDCOUPLING_EXPORT typename Traits::ArrayType *toNoInterlace() const; + MEDCOUPLING_EXPORT void meldWith(const typename Traits::ArrayType *other); + MEDCOUPLING_EXPORT typename Traits::ArrayType *duplicateEachTupleNTimes(int nbTimes) const; + MEDCOUPLING_EXPORT void aggregate(const typename Traits::ArrayType *other); + MEDCOUPLING_EXPORT void abs(); + MEDCOUPLING_EXPORT typename Traits::ArrayType *computeAbs() const; + MEDCOUPLING_EXPORT typename Traits::ArrayType *performCopyOrIncrRef(bool dCpy) const; + MEDCOUPLING_EXPORT typename Traits::ArrayType *sumPerTuple() const; + MEDCOUPLING_EXPORT void iota(T init=(T)0); + MEDCOUPLING_EXPORT void reprStream(std::ostream& stream) const; + MEDCOUPLING_EXPORT void reprZipStream(std::ostream& stream) const; + MEDCOUPLING_EXPORT void reprNotTooLongStream(std::ostream& stream) const; + MEDCOUPLING_EXPORT void reprWithoutNameStream(std::ostream& stream) const; + MEDCOUPLING_EXPORT void reprZipWithoutNameStream(std::ostream& stream) const; + MEDCOUPLING_EXPORT void reprNotTooLongWithoutNameStream(std::ostream& stream) const; + MEDCOUPLING_EXPORT std::string reprNotTooLong() const; + template + MCAuto< typename Traits::ArrayType > convertToOtherTypeOfArr() const; protected: static typename Traits::ArrayType *PerformCopyOrIncrRef(bool dCpy, const typename Traits::ArrayType& self); + template + MCAuto findIdsAdv(const OP& op) const; private: - template - MCAuto< typename Traits::ArrayType > convertToOtherTypeOfArr() const; template void somethingEqual(const typename Traits::ArrayType *other); }; @@ -329,7 +367,6 @@ namespace MEDCoupling { public: MEDCOUPLING_EXPORT bool isUniform(T val, T eps) const; - MEDCOUPLING_EXPORT void iota(T init=0.); }; } @@ -348,20 +385,13 @@ namespace MEDCoupling MEDCOUPLING_EXPORT DataArrayFloat *selectByTupleId(const int *new2OldBg, const int *new2OldEnd) const { return DataArrayTemplateFP::mySelectByTupleId(new2OldBg,new2OldEnd); } MEDCOUPLING_EXPORT DataArrayFloat *selectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const { return DataArrayTemplateFP::mySelectByTupleIdSafe(new2OldBg,new2OldEnd); } MEDCOUPLING_EXPORT DataArrayFloat *selectByTupleIdSafeSlice(int bg, int end2, int step) const { return DataArrayTemplateFP::mySelectByTupleIdSafeSlice(bg,end2,step); } - MEDCOUPLING_EXPORT void reprStream(std::ostream& stream) const; - MEDCOUPLING_EXPORT void reprZipStream(std::ostream& stream) const; - MEDCOUPLING_EXPORT void reprZipWithoutNameStream(std::ostream& stream) const; MEDCOUPLING_EXPORT void reprCppStream(const std::string& varName, std::ostream& stream) const; MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const; MEDCOUPLING_EXPORT void reprQuickOverviewData(std::ostream& stream, std::size_t maxNbOfByteInRepr) const; public:// non abstract but essential - MEDCOUPLING_EXPORT std::string reprNotTooLong() const; - MEDCOUPLING_EXPORT void reprNotTooLongStream(std::ostream& stream) const; - MEDCOUPLING_EXPORT void reprNotTooLongWithoutNameStream(std::ostream& stream) const; MEDCOUPLING_EXPORT bool isEqual(const DataArrayFloat& other, float prec) const; MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const DataArrayFloat& other, float prec, std::string& reason) const; MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const DataArrayFloat& other, float prec) const; - MEDCOUPLING_EXPORT DataArrayFloat *performCopyOrIncrRef(bool deepCopy) const; public: MEDCOUPLING_EXPORT DataArrayFloatIterator *iterator(); private: @@ -380,57 +410,38 @@ namespace MEDCoupling MEDCOUPLING_EXPORT double doubleValue() const; MEDCOUPLING_EXPORT DataArrayDouble *deepCopy() const; MEDCOUPLING_EXPORT DataArrayDouble *buildNewEmptyInstance() const { return DataArrayDouble::New(); } - MEDCOUPLING_EXPORT DataArrayDouble *performCopyOrIncrRef(bool deepCopy) const; - MEDCOUPLING_EXPORT void fillWithZero(); MEDCOUPLING_EXPORT void checkMonotonic(bool increasing, double eps) const; MEDCOUPLING_EXPORT bool isMonotonic(bool increasing, double eps) const; MEDCOUPLING_EXPORT std::string repr() const; MEDCOUPLING_EXPORT std::string reprZip() const; - MEDCOUPLING_EXPORT std::string reprNotTooLong() const; MEDCOUPLING_EXPORT void writeVTK(std::ostream& ofs, int indent, const std::string& nameInFile, DataArrayByte *byteArr) const; - MEDCOUPLING_EXPORT void reprStream(std::ostream& stream) const; - MEDCOUPLING_EXPORT void reprZipStream(std::ostream& stream) const; - MEDCOUPLING_EXPORT void reprNotTooLongStream(std::ostream& stream) const; - MEDCOUPLING_EXPORT void reprWithoutNameStream(std::ostream& stream) const; - MEDCOUPLING_EXPORT void reprZipWithoutNameStream(std::ostream& stream) const; - MEDCOUPLING_EXPORT void reprNotTooLongWithoutNameStream(std::ostream& stream) const; MEDCOUPLING_EXPORT void reprCppStream(const std::string& varName, std::ostream& stream) const; MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const; MEDCOUPLING_EXPORT void reprQuickOverviewData(std::ostream& stream, std::size_t maxNbOfByteInRepr) const; MEDCOUPLING_EXPORT bool isEqual(const DataArrayDouble& other, double prec) const; MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const DataArrayDouble& other, double prec, std::string& reason) const; MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const DataArrayDouble& other, double prec) const; - MEDCOUPLING_EXPORT DataArrayDouble *fromNoInterlace() const; - MEDCOUPLING_EXPORT DataArrayDouble *toNoInterlace() const; MEDCOUPLING_EXPORT DataArrayDouble *selectByTupleId(const int *new2OldBg, const int *new2OldEnd) const { return DataArrayTemplateFP::mySelectByTupleId(new2OldBg,new2OldEnd); } - MEDCOUPLING_EXPORT DataArrayDouble *selectByTupleId(const DataArrayInt& di) const { return DataArrayTemplateFP::mySelectByTupleId(di); } + MEDCOUPLING_EXPORT DataArrayDouble *selectByTupleId(const DataArrayInt32& di) const { return DataArrayTemplateFP::mySelectByTupleId(di); } MEDCOUPLING_EXPORT DataArrayDouble *selectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const { return DataArrayTemplateFP::mySelectByTupleIdSafe(new2OldBg,new2OldEnd); } MEDCOUPLING_EXPORT DataArrayDouble *keepSelectedComponents(const std::vector& compoIds) const { return DataArrayTemplateFP::myKeepSelectedComponents(compoIds); } MEDCOUPLING_EXPORT DataArrayDouble *selectByTupleIdSafeSlice(int bg, int end2, int step) const { return DataArrayTemplateFP::mySelectByTupleIdSafeSlice(bg,end2,step); } MEDCOUPLING_EXPORT DataArrayDouble *selectByTupleRanges(const std::vector >& ranges) const { return DataArrayTemplateFP::mySelectByTupleRanges(ranges); } - MEDCOUPLING_EXPORT void meldWith(const DataArrayDouble *other); - MEDCOUPLING_EXPORT bool areIncludedInMe(const DataArrayDouble *other, double prec, DataArrayInt *&tupleIds) const; - MEDCOUPLING_EXPORT void findCommonTuples(double prec, int limitTupleId, DataArrayInt *&comm, DataArrayInt *&commIndex) const; + MEDCOUPLING_EXPORT bool areIncludedInMe(const DataArrayDouble *other, double prec, DataArrayInt32 *&tupleIds) const; + MEDCOUPLING_EXPORT void findCommonTuples(double prec, int limitTupleId, DataArrayInt32 *&comm, DataArrayInt32 *&commIndex) const; MEDCOUPLING_EXPORT double minimalDistanceTo(const DataArrayDouble *other, int& thisTupleId, int& otherTupleId) const; - MEDCOUPLING_EXPORT DataArrayDouble *duplicateEachTupleNTimes(int nbTimes) const; MEDCOUPLING_EXPORT DataArrayDouble *getDifferentValues(double prec, int limitTupleId=-1) const; - MEDCOUPLING_EXPORT DataArrayInt *findClosestTupleId(const DataArrayDouble *other) const; - MEDCOUPLING_EXPORT DataArrayInt *computeNbOfInteractionsWith(const DataArrayDouble *otherBBoxFrmt, double eps) const; + MEDCOUPLING_EXPORT DataArrayInt32 *findClosestTupleId(const DataArrayDouble *other) const; + MEDCOUPLING_EXPORT DataArrayInt32 *computeNbOfInteractionsWith(const DataArrayDouble *otherBBoxFrmt, double eps) const; MEDCOUPLING_EXPORT void setSelectedComponents(const DataArrayDouble *a, const std::vector& compoIds); - MEDCOUPLING_EXPORT void getTuple(int tupleId, double *res) const { std::copy(_mem.getConstPointerLoc(tupleId*_info_on_compo.size()),_mem.getConstPointerLoc((tupleId+1)*_info_on_compo.size()),res); } - MEDCOUPLING_EXPORT static void SetArrayIn(DataArrayDouble *newArray, DataArrayDouble* &arrayToSet); MEDCOUPLING_EXPORT DataArrayDoubleIterator *iterator(); - template - void insertAtTheEnd(InputIterator first, InputIterator last); - MEDCOUPLING_EXPORT void aggregate(const DataArrayDouble *other); - MEDCOUPLING_EXPORT void writeOnPlace(std::size_t id, double element0, const double *others, int sizeOfOthers) { _mem.writeOnPlace(id,element0,others,sizeOfOthers); } MEDCOUPLING_EXPORT void checkNoNullValues() const; MEDCOUPLING_EXPORT void getMinMaxPerComponent(double *bounds) const; MEDCOUPLING_EXPORT DataArrayDouble *computeBBoxPerTuple(double epsilon=0.0) const; - MEDCOUPLING_EXPORT void computeTupleIdsNearTuples(const DataArrayDouble *other, double eps, DataArrayInt *& c, DataArrayInt *& cI) const; + MEDCOUPLING_EXPORT void computeTupleIdsNearTuples(const DataArrayDouble *other, double eps, DataArrayInt32 *& c, DataArrayInt32 *& cI) const; MEDCOUPLING_EXPORT void recenterForMaxPrecision(double eps); - MEDCOUPLING_EXPORT double getMaxValue2(DataArrayInt*& tupleIds) const; - MEDCOUPLING_EXPORT double getMinValue2(DataArrayInt*& tupleIds) const; + MEDCOUPLING_EXPORT double getMaxValue2(DataArrayInt32*& tupleIds) const; + MEDCOUPLING_EXPORT double getMinValue2(DataArrayInt32*& tupleIds) const; MEDCOUPLING_EXPORT int count(double value, double eps) const; MEDCOUPLING_EXPORT double getAverageValue() const; MEDCOUPLING_EXPORT double norm2() const; @@ -457,14 +468,12 @@ namespace MEDCoupling MEDCOUPLING_EXPORT DataArrayDouble *trace() const; MEDCOUPLING_EXPORT DataArrayDouble *deviator() const; MEDCOUPLING_EXPORT DataArrayDouble *magnitude() const; - MEDCOUPLING_EXPORT DataArrayDouble *sumPerTuple() const; MEDCOUPLING_EXPORT DataArrayDouble *maxPerTuple() const; - MEDCOUPLING_EXPORT DataArrayDouble *maxPerTupleWithCompoId(DataArrayInt* &compoIdOfMaxPerTuple) const; + MEDCOUPLING_EXPORT DataArrayDouble *maxPerTupleWithCompoId(DataArrayInt32* &compoIdOfMaxPerTuple) const; MEDCOUPLING_EXPORT DataArrayDouble *buildEuclidianDistanceDenseMatrix() const; MEDCOUPLING_EXPORT DataArrayDouble *buildEuclidianDistanceDenseMatrixWith(const DataArrayDouble *other) const; + MEDCOUPLING_EXPORT void asArcOfCircle(double center[2], double& radius, double& ang) const; MEDCOUPLING_EXPORT void sortPerTuple(bool asc); - MEDCOUPLING_EXPORT void abs(); - MEDCOUPLING_EXPORT DataArrayDouble *computeAbs() const; MEDCOUPLING_EXPORT void applyInv(double numerator); MEDCOUPLING_EXPORT void applyPow(double val); MEDCOUPLING_EXPORT void applyRPow(double val); @@ -477,12 +486,10 @@ namespace MEDCoupling MEDCOUPLING_EXPORT void applyFuncFast32(const std::string& func); MEDCOUPLING_EXPORT void applyFuncFast64(const std::string& func); MEDCOUPLING_EXPORT MCAuto symmetry3DPlane(const double point[3], const double normalVector[3]) const; - MEDCOUPLING_EXPORT DataArrayInt *findIdsInRange(double vmin, double vmax) const; - MEDCOUPLING_EXPORT DataArrayInt *findIdsNotInRange(double vmin, double vmax) const; + MEDCOUPLING_EXPORT DataArrayInt32 *findIdsInRange(double vmin, double vmax) const; + MEDCOUPLING_EXPORT DataArrayInt32 *findIdsNotInRange(double vmin, double vmax) const; MEDCOUPLING_EXPORT static DataArrayDouble *Aggregate(const DataArrayDouble *a1, const DataArrayDouble *a2); MEDCOUPLING_EXPORT static DataArrayDouble *Aggregate(const std::vector& arr); - MEDCOUPLING_EXPORT static DataArrayDouble *Meld(const DataArrayDouble *a1, const DataArrayDouble *a2); - MEDCOUPLING_EXPORT static DataArrayDouble *Meld(const std::vector& arr); MEDCOUPLING_EXPORT static DataArrayDouble *Dot(const DataArrayDouble *a1, const DataArrayDouble *a2); MEDCOUPLING_EXPORT static DataArrayDouble *CrossProduct(const DataArrayDouble *a1, const DataArrayDouble *a2); MEDCOUPLING_EXPORT static DataArrayDouble *Max(const DataArrayDouble *a1, const DataArrayDouble *a2); @@ -501,91 +508,98 @@ namespace MEDCoupling MEDCOUPLING_EXPORT void finishUnserialization(const std::vector& tinyInfoI, const std::vector& tinyInfoS); public: template - void findCommonTuplesAlg(const double *bbox, int nbNodes, int limitNodeId, double prec, DataArrayInt *c, DataArrayInt *cI) const; + void findCommonTuplesAlg(const double *bbox, int nbNodes, int limitNodeId, double prec, DataArrayInt32 *c, DataArrayInt32 *cI) const; template static void FindClosestTupleIdAlg(const BBTreePts& myTree, double dist, const double *pos, int nbOfTuples, const double *thisPt, int thisNbOfTuples, int *res); template static void FindTupleIdsNearTuplesAlg(const BBTreePts& myTree, const double *pos, int nbOfTuples, double eps, - DataArrayInt *c, DataArrayInt *cI); + DataArrayInt32 *c, DataArrayInt32 *cI); private: ~DataArrayDouble() { } DataArrayDouble() { } }; - class DataArrayIntIterator; - - class DataArrayInt : public DataArrayTemplateClassic + template + class DataArrayDiscrete : public DataArrayTemplateClassic { public: - MEDCOUPLING_EXPORT static DataArrayInt *New(); - MEDCOUPLING_EXPORT int intValue() const; - MEDCOUPLING_EXPORT int getHashCode() const; - MEDCOUPLING_EXPORT DataArrayInt *deepCopy() const; - MEDCOUPLING_EXPORT DataArrayInt *performCopyOrIncrRef(bool deepCopy) const; - MEDCOUPLING_EXPORT DataArrayInt *buildNewEmptyInstance() const { return DataArrayInt::New(); } - MEDCOUPLING_EXPORT bool isEqual(const DataArrayInt& other) const; - MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const DataArrayInt& other, std::string& reason) const; - MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const DataArrayInt& other) const; - MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStrAndOrder(const DataArrayInt& other) const; - MEDCOUPLING_EXPORT bool isFittingWith(const std::vector& v) const; - MEDCOUPLING_EXPORT void switchOnTupleEqualTo(int val, std::vector& vec) const; - MEDCOUPLING_EXPORT void switchOnTupleNotEqualTo(int val, std::vector& vec) const; - MEDCOUPLING_EXPORT DataArrayInt *buildPermutationArr(const DataArrayInt& other) const; - MEDCOUPLING_EXPORT DataArrayInt *indicesOfSubPart(const DataArrayInt& partOfThis) const; - MEDCOUPLING_EXPORT DataArrayInt *sumPerTuple() const; + MEDCOUPLING_EXPORT bool isEqual(const DataArrayDiscrete& other) const; + MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const DataArrayDiscrete& other, std::string& reason) const; + MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const DataArrayDiscrete& other) const; + MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStrAndOrder(const typename Traits::ArrayType& other) const; + MEDCOUPLING_EXPORT void switchOnTupleEqualTo(T val, std::vector& vec) const; + MEDCOUPLING_EXPORT void switchOnTupleNotEqualTo(T val, std::vector& vec) const; + MEDCOUPLING_EXPORT DataArrayIdType *buildPermutationArr(const DataArrayDiscrete& other) const; + MEDCOUPLING_EXPORT DataArrayIdType *indicesOfSubPart(const DataArrayDiscrete& partOfThis) const; MEDCOUPLING_EXPORT void checkMonotonic(bool increasing) const; MEDCOUPLING_EXPORT bool isMonotonic(bool increasing) const; MEDCOUPLING_EXPORT void checkStrictlyMonotonic(bool increasing) const; MEDCOUPLING_EXPORT bool isStrictlyMonotonic(bool increasing) const; - MEDCOUPLING_EXPORT void fillWithZero(); - MEDCOUPLING_EXPORT void iota(int init=0); + protected: + template + void switchOnTupleAlg(T val, std::vector& vec, ALG algo) const; + protected: + ~DataArrayDiscrete() { } + }; + + template + class DataArrayDiscreteSigned : public DataArrayDiscrete + { + public: + MEDCOUPLING_EXPORT bool isFittingWith(const std::vector& v) const; + protected: + ~DataArrayDiscreteSigned() { } + }; + + class DataArrayInt32Iterator; + + class DataArrayInt32 : public DataArrayDiscreteSigned + { + public: + MEDCOUPLING_EXPORT static DataArrayInt32 *New(); + MEDCOUPLING_EXPORT int intValue() const; + MEDCOUPLING_EXPORT int getHashCode() const; + MEDCOUPLING_EXPORT DataArrayInt32 *deepCopy() const;//ok + MEDCOUPLING_EXPORT DataArrayInt32 *buildNewEmptyInstance() const { return DataArrayInt32::New(); }//ok MEDCOUPLING_EXPORT std::string repr() const; MEDCOUPLING_EXPORT std::string reprZip() const; - MEDCOUPLING_EXPORT std::string reprNotTooLong() const; MEDCOUPLING_EXPORT void writeVTK(std::ostream& ofs, int indent, const std::string& type, const std::string& nameInFile, DataArrayByte *byteArr) const; - MEDCOUPLING_EXPORT void reprStream(std::ostream& stream) const; - MEDCOUPLING_EXPORT void reprZipStream(std::ostream& stream) const; - MEDCOUPLING_EXPORT void reprNotTooLongStream(std::ostream& stream) const; - MEDCOUPLING_EXPORT void reprWithoutNameStream(std::ostream& stream) const; - MEDCOUPLING_EXPORT void reprZipWithoutNameStream(std::ostream& stream) const; - MEDCOUPLING_EXPORT void reprNotTooLongWithoutNameStream(std::ostream& stream) const; MEDCOUPLING_EXPORT void reprCppStream(const std::string& varName, std::ostream& stream) const; MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const; MEDCOUPLING_EXPORT void reprQuickOverviewData(std::ostream& stream, std::size_t maxNbOfByteInRepr) const; MEDCOUPLING_EXPORT void transformWithIndArr(const int *indArrBg, const int *indArrEnd); - MEDCOUPLING_EXPORT DataArrayInt *transformWithIndArrR(const int *indArrBg, const int *indArrEnd) const; + MEDCOUPLING_EXPORT void transformWithIndArr(const MapKeyVal& m); + MEDCOUPLING_EXPORT DataArrayInt32 *transformWithIndArrR(const int *indArrBg, const int *indArrEnd) const; MEDCOUPLING_EXPORT void splitByValueRange(const int *arrBg, const int *arrEnd, - DataArrayInt *& castArr, DataArrayInt *& rankInsideCast, DataArrayInt *& castsPresent) const; + DataArrayInt32 *& castArr, DataArrayInt32 *& rankInsideCast, DataArrayInt32 *& castsPresent) const; MEDCOUPLING_EXPORT bool isRange(int& strt, int& sttoopp, int& stteepp) const; - MEDCOUPLING_EXPORT DataArrayInt *invertArrayO2N2N2O(int newNbOfElem) const; - MEDCOUPLING_EXPORT DataArrayInt *invertArrayN2O2O2N(int oldNbOfElem) const; - MEDCOUPLING_EXPORT DataArrayInt *invertArrayO2N2N2OBis(int newNbOfElem) const; - MEDCOUPLING_EXPORT DataArrayInt *fromNoInterlace() const; - MEDCOUPLING_EXPORT DataArrayInt *toNoInterlace() const; - MEDCOUPLING_EXPORT DataArrayInt *selectByTupleId(const int *new2OldBg, const int *new2OldEnd) const { return DataArrayTemplate::mySelectByTupleId(new2OldBg,new2OldEnd); } - MEDCOUPLING_EXPORT DataArrayInt *selectByTupleId(const DataArrayInt& di) const { return DataArrayTemplate::mySelectByTupleId(di); } - MEDCOUPLING_EXPORT DataArrayInt *selectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const { return DataArrayTemplate::mySelectByTupleIdSafe(new2OldBg,new2OldEnd); } - MEDCOUPLING_EXPORT DataArrayInt *keepSelectedComponents(const std::vector& compoIds) const { return DataArrayTemplate::myKeepSelectedComponents(compoIds); } - MEDCOUPLING_EXPORT DataArrayInt *selectByTupleIdSafeSlice(int bg, int end2, int step) const { return DataArrayTemplate::mySelectByTupleIdSafeSlice(bg,end2,step); } - MEDCOUPLING_EXPORT DataArrayInt *selectByTupleRanges(const std::vector >& ranges) const { return DataArrayTemplate::mySelectByTupleRanges(ranges); } - MEDCOUPLING_EXPORT DataArrayInt *checkAndPreparePermutation() const; - MEDCOUPLING_EXPORT static DataArrayInt *FindPermutationFromFirstToSecond(const DataArrayInt *ids1, const DataArrayInt *ids2); - MEDCOUPLING_EXPORT void changeSurjectiveFormat(int targetNb, DataArrayInt *&arr, DataArrayInt *&arrI) const; - MEDCOUPLING_EXPORT static DataArrayInt *ConvertIndexArrayToO2N(int nbOfOldTuples, const int *arr, const int *arrIBg, const int *arrIEnd, int &newNbOfTuples); - MEDCOUPLING_EXPORT DataArrayInt *buildPermArrPerLevel() const; + MEDCOUPLING_EXPORT DataArrayInt32 *invertArrayO2N2N2O(int newNbOfElem) const; + MEDCOUPLING_EXPORT DataArrayInt32 *invertArrayN2O2O2N(int oldNbOfElem) const; + MEDCOUPLING_EXPORT MCAuto< MapKeyVal > invertArrayN2O2O2NOptimized() const; + MEDCOUPLING_EXPORT DataArrayInt32 *invertArrayO2N2N2OBis(int newNbOfElem) const; + MEDCOUPLING_EXPORT DataArrayInt32 *selectByTupleId(const int *new2OldBg, const int *new2OldEnd) const { return DataArrayTemplate::mySelectByTupleId(new2OldBg,new2OldEnd); } + MEDCOUPLING_EXPORT DataArrayInt32 *selectByTupleId(const DataArrayInt32& di) const { return DataArrayTemplate::mySelectByTupleId(di); } + MEDCOUPLING_EXPORT DataArrayInt32 *selectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const { return DataArrayTemplate::mySelectByTupleIdSafe(new2OldBg,new2OldEnd); } + MEDCOUPLING_EXPORT DataArrayInt32 *keepSelectedComponents(const std::vector& compoIds) const { return DataArrayTemplate::myKeepSelectedComponents(compoIds); } + MEDCOUPLING_EXPORT DataArrayInt32 *selectByTupleIdSafeSlice(int bg, int end2, int step) const { return DataArrayTemplate::mySelectByTupleIdSafeSlice(bg,end2,step); } + MEDCOUPLING_EXPORT DataArrayInt32 *selectByTupleRanges(const std::vector >& ranges) const { return DataArrayTemplate::mySelectByTupleRanges(ranges); } + MEDCOUPLING_EXPORT DataArrayInt32 *checkAndPreparePermutation() const; + MEDCOUPLING_EXPORT static DataArrayInt32 *FindPermutationFromFirstToSecond(const DataArrayInt32 *ids1, const DataArrayInt32 *ids2); + MEDCOUPLING_EXPORT void changeSurjectiveFormat(int targetNb, DataArrayInt32 *&arr, DataArrayInt32 *&arrI) const; + MEDCOUPLING_EXPORT static DataArrayInt32 *ConvertIndexArrayToO2N(int nbOfOldTuples, const int *arr, const int *arrIBg, const int *arrIEnd, int &newNbOfTuples); + MEDCOUPLING_EXPORT DataArrayInt32 *buildPermArrPerLevel() const; MEDCOUPLING_EXPORT bool isIota(int sizeExpected) const; MEDCOUPLING_EXPORT bool isUniform(int val) const; + MEDCOUPLING_EXPORT int checkUniformAndGuess() const; MEDCOUPLING_EXPORT bool hasUniqueValues() const; - MEDCOUPLING_EXPORT void meldWith(const DataArrayInt *other); - MEDCOUPLING_EXPORT void setSelectedComponents(const DataArrayInt *a, const std::vector& compoIds); - MEDCOUPLING_EXPORT void getTuple(int tupleId, int *res) const { std::copy(_mem.getConstPointerLoc(tupleId*_info_on_compo.size()),_mem.getConstPointerLoc((tupleId+1)*_info_on_compo.size()),res); } - MEDCOUPLING_EXPORT static void SetArrayIn(DataArrayInt *newArray, DataArrayInt* &arrayToSet); - MEDCOUPLING_EXPORT DataArrayIntIterator *iterator(); - MEDCOUPLING_EXPORT DataArrayInt *findIdsEqual(int val) const; - MEDCOUPLING_EXPORT DataArrayInt *findIdsNotEqual(int val) const; - MEDCOUPLING_EXPORT DataArrayInt *findIdsEqualList(const int *valsBg, const int *valsEnd) const; - MEDCOUPLING_EXPORT DataArrayInt *findIdsNotEqualList(const int *valsBg, const int *valsEnd) const; - MEDCOUPLING_EXPORT DataArrayInt *findIdsEqualTuple(const int *tupleBg, const int *tupleEnd) const; + MEDCOUPLING_EXPORT void setSelectedComponents(const DataArrayInt32 *a, const std::vector& compoIds); + MEDCOUPLING_EXPORT DataArrayInt32Iterator *iterator(); + MEDCOUPLING_EXPORT DataArrayInt32 *findIdsEqual(int val) const; + MEDCOUPLING_EXPORT DataArrayInt32 *findIdsNotEqual(int val) const; + MEDCOUPLING_EXPORT DataArrayInt32 *findIdsEqualList(const int *valsBg, const int *valsEnd) const; + MEDCOUPLING_EXPORT DataArrayInt32 *findIdsNotEqualList(const int *valsBg, const int *valsEnd) const; + MEDCOUPLING_EXPORT DataArrayInt32 *findIdsEqualTuple(const int *tupleBg, const int *tupleEnd) const; + MEDCOUPLING_EXPORT MCAuto findIdForEach(const int *valsBg, const int *valsEnd) const; MEDCOUPLING_EXPORT int changeValue(int oldValue, int newValue); MEDCOUPLING_EXPORT int findIdFirstEqualTuple(const std::vector& tupl) const; MEDCOUPLING_EXPORT int findIdFirstEqual(int value) const; @@ -597,91 +611,79 @@ namespace MEDCoupling MEDCOUPLING_EXPORT int count(int value) const; MEDCOUPLING_EXPORT void accumulate(int *res) const; MEDCOUPLING_EXPORT int accumulate(int compId) const; - MEDCOUPLING_EXPORT DataArrayInt *accumulatePerChunck(const int *bgOfIndex, const int *endOfIndex) const; + MEDCOUPLING_EXPORT DataArrayInt32 *accumulatePerChunck(const int *bgOfIndex, const int *endOfIndex) const; MEDCOUPLING_EXPORT void getMinMaxValues(int& minValue, int& maxValue) const; - MEDCOUPLING_EXPORT void abs(); - MEDCOUPLING_EXPORT DataArrayInt *computeAbs() const; MEDCOUPLING_EXPORT void applyInv(int numerator); MEDCOUPLING_EXPORT void applyDivideBy(int val); MEDCOUPLING_EXPORT void applyModulus(int val); MEDCOUPLING_EXPORT void applyRModulus(int val); MEDCOUPLING_EXPORT void applyPow(int val); MEDCOUPLING_EXPORT void applyRPow(int val); - MEDCOUPLING_EXPORT DataArrayInt *findIdsInRange(int vmin, int vmax) const; - MEDCOUPLING_EXPORT DataArrayInt *findIdsNotInRange(int vmin, int vmax) const; - MEDCOUPLING_EXPORT DataArrayInt *findIdsStricltyNegative() const; + MEDCOUPLING_EXPORT DataArrayInt32 *findIdsInRange(int vmin, int vmax) const; + MEDCOUPLING_EXPORT DataArrayInt32 *findIdsNotInRange(int vmin, int vmax) const; MEDCOUPLING_EXPORT bool checkAllIdsInRange(int vmin, int vmax) const; - MEDCOUPLING_EXPORT MCAuto findIdsGreaterOrEqualTo(int val) const; - MEDCOUPLING_EXPORT MCAuto findIdsGreaterThan(int val) const; - MEDCOUPLING_EXPORT MCAuto findIdsLowerOrEqualTo(int val) const; - MEDCOUPLING_EXPORT MCAuto findIdsLowerThan(int val) const; - MEDCOUPLING_EXPORT static DataArrayInt *Aggregate(const DataArrayInt *a1, const DataArrayInt *a2, int offsetA2); - MEDCOUPLING_EXPORT static DataArrayInt *Aggregate(const std::vector& arr); - MEDCOUPLING_EXPORT static DataArrayInt *AggregateIndexes(const std::vector& arrs); - MEDCOUPLING_EXPORT static DataArrayInt *Meld(const DataArrayInt *a1, const DataArrayInt *a2); - MEDCOUPLING_EXPORT static DataArrayInt *Meld(const std::vector& arr); - MEDCOUPLING_EXPORT static DataArrayInt *MakePartition(const std::vector& groups, int newNb, std::vector< std::vector >& fidsOfGroups); - MEDCOUPLING_EXPORT static DataArrayInt *BuildUnion(const std::vector& arr); - MEDCOUPLING_EXPORT static DataArrayInt *BuildIntersection(const std::vector& arr); - MEDCOUPLING_EXPORT static DataArrayInt *BuildListOfSwitchedOn(const std::vector& v); - MEDCOUPLING_EXPORT static DataArrayInt *BuildListOfSwitchedOff(const std::vector& v); - MEDCOUPLING_EXPORT static void PutIntoToSkylineFrmt(const std::vector< std::vector >& v, DataArrayInt *& data, DataArrayInt *& dataIndex); - MEDCOUPLING_EXPORT DataArrayInt *buildComplement(int nbOfElement) const; - MEDCOUPLING_EXPORT DataArrayInt *buildSubstraction(const DataArrayInt *other) const; - MEDCOUPLING_EXPORT DataArrayInt *buildSubstractionOptimized(const DataArrayInt *other) const; - MEDCOUPLING_EXPORT DataArrayInt *buildUnion(const DataArrayInt *other) const; - MEDCOUPLING_EXPORT DataArrayInt *buildIntersection(const DataArrayInt *other) const; - MEDCOUPLING_EXPORT DataArrayInt *buildUnique() const; - MEDCOUPLING_EXPORT DataArrayInt *buildUniqueNotSorted() const; - MEDCOUPLING_EXPORT DataArrayInt *deltaShiftIndex() const; + MEDCOUPLING_EXPORT static DataArrayInt32 *Aggregate(const DataArrayInt32 *a1, const DataArrayInt32 *a2, int offsetA2); + MEDCOUPLING_EXPORT static DataArrayInt32 *Aggregate(const std::vector& arr); + MEDCOUPLING_EXPORT static DataArrayInt32 *AggregateIndexes(const std::vector& arrs); + MEDCOUPLING_EXPORT static DataArrayInt32 *MakePartition(const std::vector& groups, int newNb, std::vector< std::vector >& fidsOfGroups); + MEDCOUPLING_EXPORT static DataArrayInt32 *BuildUnion(const std::vector& arr); + MEDCOUPLING_EXPORT static DataArrayInt32 *BuildIntersection(const std::vector& arr); + MEDCOUPLING_EXPORT static DataArrayInt32 *BuildListOfSwitchedOn(const std::vector& v); + MEDCOUPLING_EXPORT static DataArrayInt32 *BuildListOfSwitchedOff(const std::vector& v); + MEDCOUPLING_EXPORT static void PutIntoToSkylineFrmt(const std::vector< std::vector >& v, DataArrayInt32 *& data, DataArrayInt32 *& dataIndex); + MEDCOUPLING_EXPORT DataArrayInt32 *buildComplement(int nbOfElement) const; + MEDCOUPLING_EXPORT DataArrayInt32 *buildSubstraction(const DataArrayInt32 *other) const; + MEDCOUPLING_EXPORT DataArrayInt32 *buildSubstractionOptimized(const DataArrayInt32 *other) const; + MEDCOUPLING_EXPORT DataArrayInt32 *buildUnion(const DataArrayInt32 *other) const; + MEDCOUPLING_EXPORT DataArrayInt32 *buildIntersection(const DataArrayInt32 *other) const; + MEDCOUPLING_EXPORT DataArrayInt32 *buildUnique() const; + MEDCOUPLING_EXPORT DataArrayInt32 *buildUniqueNotSorted() const; + MEDCOUPLING_EXPORT DataArrayInt32 *deltaShiftIndex() const; MEDCOUPLING_EXPORT void computeOffsets(); MEDCOUPLING_EXPORT void computeOffsetsFull(); - MEDCOUPLING_EXPORT void findIdsRangesInListOfIds(const DataArrayInt *listOfIds, DataArrayInt *& rangeIdsFetched, DataArrayInt *& idsInInputListThatFetch) const; - MEDCOUPLING_EXPORT DataArrayInt *buildExplicitArrByRanges(const DataArrayInt *offsets) const; - MEDCOUPLING_EXPORT DataArrayInt *buildExplicitArrOfSliceOnScaledArr(int begin, int stop, int step) const; - MEDCOUPLING_EXPORT DataArrayInt *findRangeIdForEachTuple(const DataArrayInt *ranges) const; - MEDCOUPLING_EXPORT DataArrayInt *findIdInRangeForEachTuple(const DataArrayInt *ranges) const; + MEDCOUPLING_EXPORT void findIdsRangesInListOfIds(const DataArrayInt32 *listOfIds, DataArrayInt32 *& rangeIdsFetched, DataArrayInt32 *& idsInInputListThatFetch) const; + MEDCOUPLING_EXPORT DataArrayInt32 *buildExplicitArrByRanges(const DataArrayInt32 *offsets) const; + MEDCOUPLING_EXPORT DataArrayInt32 *buildExplicitArrOfSliceOnScaledArr(int begin, int stop, int step) const; + MEDCOUPLING_EXPORT DataArrayInt32 *findRangeIdForEachTuple(const DataArrayInt32 *ranges) const; + MEDCOUPLING_EXPORT DataArrayInt32 *findIdInRangeForEachTuple(const DataArrayInt32 *ranges) const; MEDCOUPLING_EXPORT void sortEachPairToMakeALinkedList(); - MEDCOUPLING_EXPORT MCAuto fromLinkedListOfPairToList() const; - MEDCOUPLING_EXPORT DataArrayInt *duplicateEachTupleNTimes(int nbTimes) const; - MEDCOUPLING_EXPORT DataArrayInt *getDifferentValues() const; - MEDCOUPLING_EXPORT std::vector partitionByDifferentValues(std::vector& differentIds) const; + MEDCOUPLING_EXPORT MCAuto fromLinkedListOfPairToList() const; + MEDCOUPLING_EXPORT DataArrayInt32 *getDifferentValues() const; + MEDCOUPLING_EXPORT std::vector partitionByDifferentValues(std::vector& differentIds) const; MEDCOUPLING_EXPORT std::vector< std::pair > splitInBalancedSlices(int nbOfSlices) const; - template - void insertAtTheEnd(InputIterator first, InputIterator last); - MEDCOUPLING_EXPORT void aggregate(const DataArrayInt *other); - MEDCOUPLING_EXPORT void writeOnPlace(std::size_t id, int element0, const int *others, int sizeOfOthers) { _mem.writeOnPlace(id,element0,others,sizeOfOthers); } - MEDCOUPLING_EXPORT static DataArrayInt *Modulus(const DataArrayInt *a1, const DataArrayInt *a2); - MEDCOUPLING_EXPORT void modulusEqual(const DataArrayInt *other); - MEDCOUPLING_EXPORT static DataArrayInt *Pow(const DataArrayInt *a1, const DataArrayInt *a2); - MEDCOUPLING_EXPORT void powEqual(const DataArrayInt *other); + MEDCOUPLING_EXPORT static DataArrayInt32 *Modulus(const DataArrayInt32 *a1, const DataArrayInt32 *a2); + MEDCOUPLING_EXPORT void modulusEqual(const DataArrayInt32 *other); + MEDCOUPLING_EXPORT static DataArrayInt32 *Pow(const DataArrayInt32 *a1, const DataArrayInt32 *a2); + MEDCOUPLING_EXPORT void powEqual(const DataArrayInt32 *other); MEDCOUPLING_EXPORT MemArray& accessToMemArray() { return _mem; } MEDCOUPLING_EXPORT const MemArray& accessToMemArray() const { return _mem; } public: MEDCOUPLING_EXPORT static int *CheckAndPreparePermutation(const int *start, const int *end); - MEDCOUPLING_EXPORT static DataArrayInt *Range(int begin, int end, int step); + MEDCOUPLING_EXPORT static DataArrayInt32 *Range(int begin, int end, int step); public: MEDCOUPLING_EXPORT void getTinySerializationIntInformation(std::vector& tinyInfo) const; MEDCOUPLING_EXPORT void getTinySerializationStrInformation(std::vector& tinyInfo) const; MEDCOUPLING_EXPORT bool resizeForUnserialization(const std::vector& tinyInfoI); MEDCOUPLING_EXPORT void finishUnserialization(const std::vector& tinyInfoI, const std::vector& tinyInfoS); private: - template - MCAuto findIdsAdv(const OP& op) const; - private: - ~DataArrayInt() { } - DataArrayInt() { } + ~DataArrayInt32() { } + DataArrayInt32() { } }; + class DataArrayInt64 : public DataArrayDiscrete + { + }; + + template template - MCAuto DataArrayInt::findIdsAdv(const OP& op) const + MCAuto DataArrayTemplateClassic::findIdsAdv(const OP& op) const { - checkAllocated(); - if(getNumberOfComponents()!=1) + this->checkAllocated(); + if(this->getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("DataArrayInt::findIdsAdv : this must have exactly one component !"); - const int *cptr(getConstPointer()); + const T *cptr(this->begin()); MCAuto ret(DataArrayInt::New()); ret->alloc(0,1); - int nbOfTuples(getNumberOfTuples()); + int nbOfTuples(this->getNumberOfTuples()); for(int i=0;ipushBackSilent(i); @@ -696,7 +698,6 @@ namespace MEDCoupling MEDCOUPLING_EXPORT bool isEqual(const DataArrayChar& other) const; MEDCOUPLING_EXPORT virtual bool isEqualIfNotWhy(const DataArrayChar& other, std::string& reason) const; MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const DataArrayChar& other) const; - MEDCOUPLING_EXPORT void fillWithZero(); MEDCOUPLING_EXPORT std::string repr() const; MEDCOUPLING_EXPORT std::string reprZip() const; MEDCOUPLING_EXPORT DataArrayInt *convertToIntArr() const; @@ -708,7 +709,6 @@ namespace MEDCoupling MEDCOUPLING_EXPORT bool isUniform(char val) const; MEDCOUPLING_EXPORT void meldWith(const DataArrayChar *other); MEDCOUPLING_EXPORT DataArray *selectByTupleRanges(const std::vector >& ranges) const { return DataArrayTemplate::mySelectByTupleRanges(ranges); } - MEDCOUPLING_EXPORT void getTuple(int tupleId, char *res) const { std::copy(_mem.getConstPointerLoc(tupleId*_info_on_compo.size()),_mem.getConstPointerLoc((tupleId+1)*_info_on_compo.size()),res); } MEDCOUPLING_EXPORT DataArrayInt *findIdsEqual(char val) const; MEDCOUPLING_EXPORT DataArrayInt *findIdsNotEqual(char val) const; MEDCOUPLING_EXPORT int findIdSequence(const std::vector& vals) const; @@ -723,8 +723,6 @@ namespace MEDCoupling MEDCOUPLING_EXPORT static DataArrayChar *Aggregate(const std::vector& arr); MEDCOUPLING_EXPORT static DataArrayChar *Meld(const DataArrayChar *a1, const DataArrayChar *a2); MEDCOUPLING_EXPORT static DataArrayChar *Meld(const std::vector& arr); - template - void insertAtTheEnd(InputIterator first, InputIterator last); MEDCOUPLING_EXPORT MemArray& accessToMemArray() { return _mem; } MEDCOUPLING_EXPORT const MemArray& accessToMemArray() const { return _mem; } public: @@ -859,8 +857,6 @@ namespace MEDCoupling MEDCOUPLING_EXPORT DataArrayFloat *buildDAFloat(int nbOfTuples, int nbOfCompo) const; }; - class DataArrayIntTuple; - class DataArrayIntIterator : public DataArrayIterator { public: @@ -868,15 +864,17 @@ namespace MEDCoupling MEDCOUPLING_EXPORT ~DataArrayIntIterator() { } }; - class DataArrayIntTuple : public DataArrayTuple + class DataArrayInt32Tuple : public DataArrayTuple { public: - MEDCOUPLING_EXPORT DataArrayIntTuple(int *pt, int nbOfComp); + MEDCOUPLING_EXPORT DataArrayInt32Tuple(int *pt, int nbOfComp); MEDCOUPLING_EXPORT std::string repr() const; MEDCOUPLING_EXPORT int intValue() const; - MEDCOUPLING_EXPORT DataArrayInt *buildDAInt(int nbOfTuples, int nbOfCompo) const; + MEDCOUPLING_EXPORT DataArrayInt32 *buildDAInt(int nbOfTuples, int nbOfCompo) const; }; + typedef DataArrayInt32Tuple DataArrayIntTuple; + class DataArrayAsciiCharTuple; class DataArrayAsciiCharIterator @@ -957,50 +955,21 @@ namespace MEDCoupling pointer[_nb_of_elem++]=*first++; } } - - template - void DataArrayDouble::insertAtTheEnd(InputIterator first, InputIterator last) - { - int nbCompo(getNumberOfComponents()); - if(nbCompo==1) - _mem.insertAtTheEnd(first,last); - else if(nbCompo==0) - { - _info_on_compo.resize(1); - _mem.insertAtTheEnd(first,last); - } - else - throw INTERP_KERNEL::Exception("DataArrayDouble::insertAtTheEnd : not available for DataArrayDouble with number of components different than 1 !"); - } - - template - void DataArrayInt::insertAtTheEnd(InputIterator first, InputIterator last) - { - int nbCompo(getNumberOfComponents()); - if(nbCompo==1) - _mem.insertAtTheEnd(first,last); - else if(nbCompo==0) - { - _info_on_compo.resize(1); - _mem.insertAtTheEnd(first,last); - } - else - throw INTERP_KERNEL::Exception("DataArrayInt::insertAtTheEnd : not available for DataArrayInt with number of components different than 1 !"); - } + template template - void DataArrayChar::insertAtTheEnd(InputIterator first, InputIterator last) + void DataArrayTemplate::insertAtTheEnd(InputIterator first, InputIterator last) { - int nbCompo(getNumberOfComponents()); + int nbCompo(this->getNumberOfComponents()); if(nbCompo==1) - _mem.insertAtTheEnd(first,last); + this->_mem.insertAtTheEnd(first,last); else if(nbCompo==0) { - _info_on_compo.resize(1); - _mem.insertAtTheEnd(first,last); + this->_info_on_compo.resize(1); + this->_mem.insertAtTheEnd(first,last); } else - throw INTERP_KERNEL::Exception("DataArrayChar::insertAtTheEnd : not available for DataArrayChar with number of components different than 1 !"); + throw INTERP_KERNEL::Exception("DataArrayDouble::insertAtTheEnd : not available for DataArrayDouble with number of components different than 1 !"); } }