X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDCoupling%2FMEDCouplingSkyLineArray.cxx;h=3aaa468470c2c77838acafdafc4e05711bf52334;hb=2ae2dc6fcedbf241c7637284b3c7bde12aded04a;hp=8ab51c2d6ea945b57f465d962887232cc1f2b655;hpb=b607ffc713080a567fb90595118069ac18181e99;p=tools%2Fmedcoupling.git diff --git a/src/MEDCoupling/MEDCouplingSkyLineArray.cxx b/src/MEDCoupling/MEDCouplingSkyLineArray.cxx index 8ab51c2d6..3aaa46847 100755 --- a/src/MEDCoupling/MEDCouplingSkyLineArray.cxx +++ b/src/MEDCoupling/MEDCouplingSkyLineArray.cxx @@ -325,6 +325,36 @@ std::string MEDCouplingSkyLineArray::simpleRepr() const return oss.str(); } +/*! + * Returns 2 SkyLineArrays with same number of packs than \a this. + * Each pack in \a this is split in 2 parts using \a threshold parameter as cut point. + * \a left part contains ids in \a this pack strictly lower than \a threshold + * \a right part contains ids in \a this pack greater or equal to \a threshold + */ +void MEDCouplingSkyLineArray::thresholdPerPack(mcIdType threshold, MCAuto& left, MCAuto& right) const +{ + mcIdType nbPacks(this->getNumberOf()); + MCAuto lCount(DataArrayIdType::New()); lCount->alloc(nbPacks,1); lCount->fillWithZero(); + mcIdType *lCountPtr(lCount->getPointerSilent()); + const mcIdType *valuesPtr(this->_values->begin()),*indexPtr(this->_index->begin()); + for(mcIdType i = 0 ; i < nbPacks ; ++i, ++lCountPtr) + { + *lCountPtr = ToIdType(std::count_if(valuesPtr+indexPtr[i],valuesPtr+indexPtr[i+1],[threshold](mcIdType elt) { return elt sizeOfPacks(this->_index->deltaShiftIndex()); + sizeOfPacks->substractEqual(lCount); + mcIdType leftNbOfVal(lCount->accumulate(std::size_t(0))),rightNbOfVal(sizeOfPacks->accumulate(std::size_t(0))); + lCount->computeOffsetsFull(); sizeOfPacks->computeOffsetsFull(); + MCAuto leftValues(DataArrayIdType::New()); leftValues->alloc(leftNbOfVal,1); + MCAuto rightValues(DataArrayIdType::New()); rightValues->alloc(rightNbOfVal,1); + mcIdType *rvPtr(rightValues->getPointerSilent()),*lvPtr(leftValues->getPointerSilent()); + for(mcIdType i = 0 ; i < nbPacks ; ++i) + { + std::for_each(valuesPtr+indexPtr[i],valuesPtr+indexPtr[i+1],[threshold,&rvPtr,&lvPtr](mcIdType elt) { if(eltcheckAllocated(); @@ -451,7 +481,7 @@ const mcIdType * MEDCouplingSkyLineArray::getSimplePackSafePtr(const mcIdType ab * \param[in] superPackIndices the list of super-packs that should be inspected * \param[in] packBg the pack that the function is looking for in each of the provided super-pack * \param[in] packEnd the pack that the function is looking for in each of the provided super-pack - * \param[out] a vector of mcIdType, having the same size as superPackIndices and containing for each inspected super-pack + * \param[out] out a vector of mcIdType, having the same size as superPackIndices and containing for each inspected super-pack * the index of the first matching pack, or -1 if none found. */ void MEDCouplingSkyLineArray::findPackIds(const std::vector & superPackIndices,