From: ageay Date: Thu, 21 Jun 2012 12:07:24 +0000 (+0000) Subject: DataArrayInt::getIdsInRange X-Git-Tag: V6_main_FINAL~632 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3cd7ad78cdf445a84c646a82b693dadf63fb15f1;p=tools%2Fmedcoupling.git DataArrayInt::getIdsInRange --- diff --git a/src/MEDCoupling/MEDCouplingMemArray.cxx b/src/MEDCoupling/MEDCouplingMemArray.cxx index 48d19a1b1..4f96a053d 100644 --- a/src/MEDCoupling/MEDCouplingMemArray.cxx +++ b/src/MEDCoupling/MEDCouplingMemArray.cxx @@ -4752,6 +4752,31 @@ void DataArrayInt::applyModulus(int val) throw(INTERP_KERNEL::Exception) declareAsNew(); } +/*! + * This method works only on data array with one component. + * This method returns a newly allocated array storing stored ascendantly tuple ids in \b this so that + * this[*id] in [\b vmin,\b vmax) + * + * \param [in] vmin begin of range. This value is included in range. + * \param [out] vmax end of range. This value is \b not included in range. + * \return a newly allocated data array that the caller should deal with. + */ +DataArrayInt *DataArrayInt::getIdsInRange(int vmin, int vmax) const throw(INTERP_KERNEL::Exception) +{ + if(getNumberOfComponents()!=1) + throw INTERP_KERNEL::Exception("DataArrayInt::getIdsInRange : this must have exactly one component !"); + const int *cptr=getConstPointer(); + std::vector res; + int nbOfTuples=getNumberOfTuples(); + for(int i=0;i=vmin && *cptralloc((int)res.size(),1); + std::copy(res.begin(),res.end(),ret->getPointer()); + return ret; +} + /*! * This method applies the operation 'numerator%x' for each element 'x' in 'this'. * If there is a value in 'this' exactly equals or lower than 0. an exception is thrown. diff --git a/src/MEDCoupling/MEDCouplingMemArray.hxx b/src/MEDCoupling/MEDCouplingMemArray.hxx index 972c29e2c..18c83b07b 100644 --- a/src/MEDCoupling/MEDCouplingMemArray.hxx +++ b/src/MEDCoupling/MEDCouplingMemArray.hxx @@ -425,6 +425,7 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT void applyDivideBy(int val) throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void applyModulus(int val) throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void applyRModulus(int val) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT DataArrayInt *getIdsInRange(int vmin, int vmax) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT static DataArrayInt *Aggregate(const DataArrayInt *a1, const DataArrayInt *a2, int offsetA2); MEDCOUPLING_EXPORT static DataArrayInt *Aggregate(const std::vector& arr) throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT static DataArrayInt *Meld(const DataArrayInt *a1, const DataArrayInt *a2) throw(INTERP_KERNEL::Exception);