-// Copyright (C) 2007-2020 CEA/DEN, EDF R&D
+// Copyright (C) 2007-2024 CEA, EDF
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
#include <string>
#include <vector>
#include <iterator>
+#include <functional>
namespace MEDCoupling
{
// -- WARNING this enum must be synchronized with MEDCouplingCommon.i file ! --
class PartDefinition;
-
+
template<class T>
class MEDCouplingPointer
{
static mcIdType GetNumberOfItemGivenBES(mcIdType begin, mcIdType end, mcIdType step, const std::string& msg);
static mcIdType GetNumberOfItemGivenBESRelative(mcIdType begin, mcIdType end, mcIdType step, const std::string& msg);
static mcIdType GetPosOfItemGivenBESRelativeNoThrow(mcIdType value, mcIdType begin, mcIdType end, mcIdType step);
+ static std::vector<std::string> SplitStringInChuncks(const std::string st, std::size_t sz);
static std::string GetVarNameFromInfo(const std::string& info);
static std::string GetUnitFromInfo(const std::string& info);
static std::string BuildInfoFromVarAndUnit(const std::string& var, const std::string& unit);
T getIJ(std::size_t tupleId, std::size_t compoId) const { return _mem[tupleId*_info_on_compo.size()+compoId]; }
void setIJ(std::size_t tupleId, std::size_t compoId, T newVal) { _mem[tupleId*_info_on_compo.size()+compoId]=newVal; declareAsNew(); }
void setIJSilent(std::size_t tupleId, std::size_t compoId, T newVal) { _mem[tupleId*_info_on_compo.size()+compoId]=newVal; }
- T *getPointer() { return _mem.getPointer(); declareAsNew(); }
+ T *getPointer() { declareAsNew(); return getPointerSilent(); }
+ T *getPointerSilent() { return _mem.getPointer(); }
void pack() const;
bool isAllocated() const override;
void checkAllocated() const;
public:
MCAuto<DataArrayDouble> convertToDblArr() const;
MCAuto<DataArrayInt> convertToIntArr() const;
+ MCAuto<DataArrayInt64> convertToInt64Arr() const;
MCAuto<DataArrayFloat> convertToFloatArr() const;
void applyLin(T a, T b, std::size_t compoId);
void applyLin(T a, T b);
template<class FCT>
void somethingEqual(const typename Traits<T>::ArrayType *other);
};
-
+
template<class T>
class DataArrayTemplateFP : public DataArrayTemplateClassic<T>
{
DataArrayDouble *trace() const;
DataArrayDouble *deviator() const;
DataArrayDouble *magnitude() const;
+ DataArrayDouble *minPerTuple() const;
DataArrayDouble *maxPerTuple() const;
DataArrayDouble *maxPerTupleWithCompoId(DataArrayIdType* &compoIdOfMaxPerTuple) const;
DataArrayDouble *buildEuclidianDistanceDenseMatrix() const;
bool resizeForUnserialization(const std::vector<mcIdType>& tinyInfoI);
void finishUnserialization(const std::vector<mcIdType>& tinyInfoI, const std::vector<std::string>& tinyInfoS);
public:
- template<mcIdType SPACEDIM>
+ template<int SPACEDIM>
void findCommonTuplesAlg(const double *bbox, mcIdType nbNodes, mcIdType limitNodeId, double prec, DataArrayIdType *c, DataArrayIdType *cI) const;
- template<mcIdType SPACEDIM>
+ template<int SPACEDIM>
static void FindClosestTupleIdAlg(const BBTreePts<SPACEDIM,mcIdType>& myTree, double dist, const double *pos, mcIdType nbOfTuples, const double *thisPt, mcIdType thisNbOfTuples, mcIdType *res);
- template<mcIdType SPACEDIM>
+ template<int SPACEDIM>
static void FindTupleIdsNearTuplesAlg(const BBTreePts<SPACEDIM,mcIdType>& myTree, const double *pos, mcIdType nbOfTuples, double eps,
DataArrayIdType *c, DataArrayIdType *cI);
+ private:
+ DataArrayDouble *operatePerTuple(std::function<double(const double *bg, const double *endd)> func) const;
private:
~DataArrayDouble() { }
DataArrayDouble() { }
T checkUniformAndGuess() const;
bool hasUniqueValues() const;
void setSelectedComponents(const DataArrayType *a, const std::vector<std::size_t>& compoIds);
+ DataArrayIdType *locateComponentId(const DataArrayType *valToSearchIntoTuples, const DataArrayIdType *tupleIdHint) const;
DataArrayIdType *findIdsNotEqual(T val) const;
DataArrayIdType *findIdsEqualTuple(const T *tupleBg, const T *tupleEnd) const;
DataArrayIdType *findIdsEqualList(const T *valsBg, const T *valsEnd) const;
DataArrayIdType *findRangeIdForEachTuple(const DataArrayType *ranges) const;
DataArrayType *findIdInRangeForEachTuple(const DataArrayType *ranges) const;
void sortEachPairToMakeALinkedList();
+ void sortToHaveConsecutivePairs();
MCAuto<DataArrayType> fromLinkedListOfPairToList() const;
DataArrayType *getDifferentValues() const;
std::vector<DataArrayIdType *> partitionByDifferentValues(std::vector<T>& differentIds) const;
protected:
~DataArrayDiscrete() { }
};
-
+
template<class T>
class DataArrayDiscreteSigned : public DataArrayDiscrete<T>
{
DataArrayInt32 *deepCopy() const;
DataArrayInt32 *copySorted(bool asc=true) const override { return this->copySortedImpl(asc); }
DataArrayInt32 *buildNewEmptyInstance() const { return DataArrayInt32::New(); }
+ MCAuto<DataArrayInt64> convertToInt64Arr() const;
public:
DataArrayInt32 *selectByTupleId(const mcIdType *new2OldBg, const mcIdType *new2OldEnd) const { return this->mySelectByTupleId(new2OldBg,new2OldEnd); }
DataArrayInt32 *selectByTupleId(const DataArrayIdType& di) const { return this->mySelectByTupleId(di); }
DataArrayInt64 *deepCopy() const;
DataArrayInt64 *copySorted(bool asc=true) const override { return this->copySortedImpl(asc); }
DataArrayInt64 *buildNewEmptyInstance() const { return DataArrayInt64::New(); }//ok
+ MCAuto<DataArrayInt32> convertToInt32Arr() const;
public:
DataArrayInt64 *selectByTupleId(const mcIdType *new2OldBg, const mcIdType *new2OldEnd) const { return this->mySelectByTupleId(new2OldBg,new2OldEnd); }
DataArrayInt64 *selectByTupleId(const DataArrayIdType& di) const { return this->mySelectByTupleId(di); }
DataArrayChar *buildEmptySpecializedDAChar() const;
DataArrayByteIterator *iterator();
DataArrayByte *deepCopy() const;
- DataArrayByte *copySorted(bool asc=true) const override { return this->copySortedImpl(asc); }
+ DataArrayByte *copySorted(bool asc=true) const override { return this->copySortedImpl(asc); }
DataArrayByte *performCopyOrIncrRef(bool deepCopy) const;
DataArrayByte *buildNewEmptyInstance() const { return DataArrayByte::New(); }
char byteValue() const;
DataArrayChar *buildEmptySpecializedDAChar() const;
DataArrayAsciiCharIterator *iterator();
DataArrayAsciiChar *deepCopy() const;
- DataArrayAsciiChar *copySorted(bool asc=true) const override { throw INTERP_KERNEL::Exception("DataArrayAsciiChar::copySorted : not implemented for DataArrayByte"); }
+ DataArrayAsciiChar *copySorted(bool asc=true) const override { (void)asc;throw INTERP_KERNEL::Exception("DataArrayAsciiChar::copySorted : not implemented for DataArrayByte"); }
DataArrayAsciiChar *performCopyOrIncrRef(bool deepCopy) const;
DataArrayAsciiChar *buildNewEmptyInstance() const { return DataArrayAsciiChar::New(); }
char asciiCharValue() const;
float floatValue() const;
DataArrayFloat *buildDAFloat(std::size_t nbOfTuples, std::size_t nbOfCompo) const;
};
-
+
class MEDCOUPLING_EXPORT DataArrayInt32Iterator : public DataArrayIterator<Int32>
{
public:
char *_pt;
std::size_t _nb_of_compo;
};
-
+
class DataArrayByteTuple;
class MEDCOUPLING_EXPORT DataArrayByteIterator