Salome HOME
projects
/
tools
/
medcoupling.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Bug with FindClosestTupleIdAlg fixed (preventing the threshold to be null)
[tools/medcoupling.git]
/
src
/
MEDCoupling
/
MEDCouplingMemArray.txx
diff --git
a/src/MEDCoupling/MEDCouplingMemArray.txx
b/src/MEDCoupling/MEDCouplingMemArray.txx
index 373e9201b1e7ca1975973ea5c66e4a720d19d31a..a536810981ffd0428c786b6b4ac05e9437d19dcd 100755
(executable)
--- a/
src/MEDCoupling/MEDCouplingMemArray.txx
+++ b/
src/MEDCoupling/MEDCouplingMemArray.txx
@@
-593,7
+593,7
@@
namespace MEDCoupling
std::ostringstream oss; oss << "DataArray::GetSlice : sliceId (" << nbOfSlices << ") must be in [0 , nbOfSlices (" << nbOfSlices << ") ) !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
std::ostringstream oss; oss << "DataArray::GetSlice : sliceId (" << nbOfSlices << ") must be in [0 , nbOfSlices (" << nbOfSlices << ") ) !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
- mcIdType nbElems=DataArrayT
emplate
<T>::GetNumberOfItemGivenBESRelative(start,stop,step,"DataArray::GetSlice");
+ mcIdType nbElems=DataArrayT
ools
<T>::GetNumberOfItemGivenBESRelative(start,stop,step,"DataArray::GetSlice");
mcIdType minNbOfElemsPerSlice=nbElems/nbOfSlices;
startSlice=start+minNbOfElemsPerSlice*step*sliceId;
if(sliceId<nbOfSlices-1)
mcIdType minNbOfElemsPerSlice=nbElems/nbOfSlices;
startSlice=start+minNbOfElemsPerSlice*step*sliceId;
if(sliceId<nbOfSlices-1)
@@
-672,6
+672,20
@@
namespace MEDCoupling
std::copy(v.begin(),v.end(),pt);
return ret;
}
std::copy(v.begin(),v.end(),pt);
return ret;
}
+
+ /*!
+ * Returns a newly created array containing a copy of the input array defined by [ \a arrBegin, \a arrEnd )
+ */
+ template<class T>
+ MCAuto< typename Traits<T>::ArrayTypeCh > DataArrayTemplate<T>::NewFromArray(const T *arrBegin, const T *arrEnd)
+ {
+ using DataArrayT = typename Traits<T>::ArrayTypeCh;
+ MCAuto< DataArrayT > ret(DataArrayT::New());
+ std::size_t nbElts(std::distance(arrBegin,arrEnd));
+ ret->alloc(nbElts,1);
+ std::copy(arrBegin,arrEnd,ret->getPointer());
+ return ret;
+ }
template<class T>
std::vector< MCAuto< typename Traits<T>::ArrayTypeCh > > DataArrayTemplate<T>::explodeComponents() const
template<class T>
std::vector< MCAuto< typename Traits<T>::ArrayTypeCh > > DataArrayTemplate<T>::explodeComponents() const
@@
-1059,8
+1073,6
@@
namespace MEDCoupling
* For more info on renumbering see \ref numbering.
* \param [in] new2Old - C array of length equal to \a this->getNumberOfTuples()
* giving a previous position of i-th new value.
* For more info on renumbering see \ref numbering.
* \param [in] new2Old - C array of length equal to \a this->getNumberOfTuples()
* giving a previous position of i-th new value.
- * \return DataArrayDouble * - the new instance of DataArrayDouble that the caller
- * is to delete using decrRef() as it is no more needed.
*/
template<class T>
void DataArrayTemplate<T>::renumberInPlaceR(const mcIdType *new2Old)
*/
template<class T>
void DataArrayTemplate<T>::renumberInPlaceR(const mcIdType *new2Old)
@@
-1087,10
+1099,12
@@
namespace MEDCoupling
}
/*!
}
/*!
- * Sorts values of the array.
+ * Sorts values of the array. \b Warning, this method is not const, it alterates \a this content.
+ *
* \param [in] asc - \a true means ascending order, \a false, descending.
* \throw If \a this is not allocated.
* \throw If \a this->getNumberOfComponents() != 1.
* \param [in] asc - \a true means ascending order, \a false, descending.
* \throw If \a this is not allocated.
* \throw If \a this->getNumberOfComponents() != 1.
+ * \sa copySorted
*/
template<class T>
void DataArrayTemplate<T>::sort(bool asc)
*/
template<class T>
void DataArrayTemplate<T>::sort(bool asc)
@@
-1105,6
+1119,23
@@
namespace MEDCoupling
declareAsNew();
}
declareAsNew();
}
+ /*!
+ * Sorts values of the array and put the result in a newly allocated returned array.
+ * This method does not alterate \a this content.
+ *
+ * \param [in] asc - \a true means ascending order, \a false, descending.
+ * \throw If \a this is not allocated.
+ * \throw If \a this->getNumberOfComponents() != 1.
+ * \sa sort
+ */
+ template<class T>
+ typename Traits<T>::ArrayTypeCh *DataArrayTemplate<T>::copySortedImpl(bool asc) const
+ {
+ MCAuto<typename Traits<T>::ArrayTypeCh> ret(static_cast<typename Traits<T>::ArrayTypeCh *>(this->deepCopy()));
+ ret->sort(asc);
+ return ret.retn();
+ }
+
/*!
* Returns a copy of \a this array with values permuted as required by \a old2New array.
* The values are permuted so that \c new[ \a old2New[ i ]] = \c old[ i ].
/*!
* Returns a copy of \a this array with values permuted as required by \a old2New array.
* The values are permuted so that \c new[ \a old2New[ i ]] = \c old[ i ].
@@
-1321,7
+1352,7
@@
namespace MEDCoupling
* Changes the number of components within \a this array so that its raw data **does
* not** change, instead splitting this data into tuples changes.
* \warning This method erases all (name and unit) component info set before!
* Changes the number of components within \a this array so that its raw data **does
* not** change, instead splitting this data into tuples changes.
* \warning This method erases all (name and unit) component info set before!
- * \param [in] newNbOfComp - number of components for \a this array to have.
+ * \param [in] newNbOfComp
o
- number of components for \a this array to have.
* \throw If \a this is not allocated
* \throw If getNbOfElems() % \a newNbOfCompo != 0.
* \throw If \a newNbOfCompo is lower than 1.
* \throw If \a this is not allocated
* \throw If getNbOfElems() % \a newNbOfCompo != 0.
* \throw If \a newNbOfCompo is lower than 1.
@@
-1436,7
+1467,7
@@
namespace MEDCoupling
std::size_t newNbOfCompo=compoIds.size();
std::size_t oldNbOfCompo=getNumberOfComponents();
for(std::vector<std::size_t>::const_iterator it=compoIds.begin();it!=compoIds.end();it++)
std::size_t newNbOfCompo=compoIds.size();
std::size_t oldNbOfCompo=getNumberOfComponents();
for(std::vector<std::size_t>::const_iterator it=compoIds.begin();it!=compoIds.end();it++)
- if((*it)
<0 || (*it)>=oldNbOfCompo
)
+ if((*it)
>=oldNbOfCompo) // (*it) >= 0 (it is a size_t
)
{
std::ostringstream oss; oss << Traits<T>::ArrayTypeName << "::keepSelectedComponents : invalid requested component : " << *it << " whereas it should be in [0," << oldNbOfCompo << ") !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
{
std::ostringstream oss; oss << Traits<T>::ArrayTypeName << "::keepSelectedComponents : invalid requested component : " << *it << " whereas it should be in [0," << oldNbOfCompo << ") !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
@@
-3634,19
+3665,6
@@
struct NotInRange
return new typename Traits<T>::ArrayType;
}
return new typename Traits<T>::ArrayType;
}
- /*!
- * Returns a newly created array containing a copy of the input array defined by [ \a arrBegin, \a arrEnd )
- */
- template<class T>
- MCAuto< typename Traits<T>::ArrayType > DataArrayDiscrete<T>::NewFromArray(const T *arrBegin, const T *arrEnd)
- {
- MCAuto< typename Traits<T>::ArrayType > ret(DataArrayDiscrete<T>::New());
- std::size_t nbElts(std::distance(arrBegin,arrEnd));
- ret->alloc(nbElts,1);
- std::copy(arrBegin,arrEnd,ret->getPointer());
- return ret;
- }
-
/*!
* Checks if values of \a this and another DataArrayInt are equal. For more info see
* \ref MEDCouplingArrayBasicsCompare.
/*!
* Checks if values of \a this and another DataArrayInt are equal. For more info see
* \ref MEDCouplingArrayBasicsCompare.
@@
-4443,7
+4461,7
@@
struct NotInRange
* from values of \a this array, which is supposed to contain a renumbering map in
* "New to Old" mode. The result array contains a renumbering map in "Old to New" mode.
* To know how to use the renumbering maps see \ref numbering.
* from values of \a this array, which is supposed to contain a renumbering map in
* "New to Old" mode. The result array contains a renumbering map in "Old to New" mode.
* To know how to use the renumbering maps see \ref numbering.
- * \param [in]
new
NbOfElem - the number of tuples in the result array.
+ * \param [in]
old
NbOfElem - the number of tuples in the result array.
* \return DataArrayInt * - the new instance of DataArrayInt.
* The caller is to delete this result array using decrRef() as it is no more
* needed.
* \return DataArrayInt * - the new instance of DataArrayInt.
* The caller is to delete this result array using decrRef() as it is no more
* needed.
@@
-4513,7
+4531,6
@@
struct NotInRange
* from values of \a this array, which is supposed to contain a renumbering map in
* "New to Old" mode. The result array contains a renumbering map in "Old to New" mode.
* To know how to use the renumbering maps see \ref numbering.
* from values of \a this array, which is supposed to contain a renumbering map in
* "New to Old" mode. The result array contains a renumbering map in "Old to New" mode.
* To know how to use the renumbering maps see \ref numbering.
- * \param [in] newNbOfElem - the number of tuples in the result array.
* \return MapII - the new instance of Map.
*
* \if ENABLE_EXAMPLES
* \return MapII - the new instance of Map.
*
* \if ENABLE_EXAMPLES
@@
-5235,7
+5252,7
@@
struct NotInRange
const T *ptr=this->getConstPointer();
mcIdType nbTuple(this->getNumberOfTuples());
std::size_t nbComps(this->getNumberOfComponents());
const T *ptr=this->getConstPointer();
mcIdType nbTuple(this->getNumberOfTuples());
std::size_t nbComps(this->getNumberOfComponents());
- if(compId
<0 || compId>=nbComps
)
+ if(compId
>=nbComps) // compId >= 0 (it is a size_t
)
throw INTERP_KERNEL::Exception("DataArrayInt::accumulate : Invalid compId specified : No such nb of components !");
T ret=0;
for(mcIdType i=0;i<nbTuple;i++)
throw INTERP_KERNEL::Exception("DataArrayInt::accumulate : Invalid compId specified : No such nb of components !");
T ret=0;
for(mcIdType i=0;i<nbTuple;i++)
@@
-5715,8
+5732,8
@@
struct NotInRange
* - \a this : [0, 1, 1, 2, 2, 3, 4, 4, 5, 5, 5, 11]
* - \a return is : [0, 1, 3, 5, 6, 8, 11, 12]
*
* - \a this : [0, 1, 1, 2, 2, 3, 4, 4, 5, 5, 5, 11]
* - \a return is : [0, 1, 3, 5, 6, 8, 11, 12]
*
- * \return a newly allocated array containing the indexed array
of
- * \throw if \a this is not allocated or if \a this has not exactly one component
or if number of tuples is equal to 0
.
+ * \return a newly allocated array containing the indexed array
format of groups by same consecutive value.
+ * \throw if \a this is not allocated or if \a this has not exactly one component.
* \sa DataArrayInt::buildUnique, MEDCouplingSkyLineArray::groupPacks
*/
template <class T>
* \sa DataArrayInt::buildUnique, MEDCouplingSkyLineArray::groupPacks
*/
template <class T>
@@
-5725,11
+5742,8
@@
struct NotInRange
this->checkAllocated();
if(this->getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("DataArrayInt::indexOfSameConsecutiveValueGroups : only single component allowed !");
this->checkAllocated();
if(this->getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("DataArrayInt::indexOfSameConsecutiveValueGroups : only single component allowed !");
- if(this->getNumberOfTuples()==0)
- throw INTERP_KERNEL::Exception("DataArrayInt::indexOfSameConsecutiveValueGroups : number of tuples must be > 0 !");
const T *pt(this->begin());
const T *const ptEnd(this->end()) , * const ptBg(this->begin());
const T *pt(this->begin());
const T *const ptEnd(this->end()) , * const ptBg(this->begin());
- const T *oldPt(pt);
// first find nb of different values in this
std::size_t nbOfTuplesOut(0);
while( pt != ptEnd )
// first find nb of different values in this
std::size_t nbOfTuplesOut(0);
while( pt != ptEnd )
@@
-7198,7
+7212,7
@@
struct NotInRange
*
* \param [in] idsOfSelectStart begin of set of ids of the input extraction (included)
* \param [in] idsOfSelectStop end of set of ids of the input extraction (excluded)
*
* \param [in] idsOfSelectStart begin of set of ids of the input extraction (included)
* \param [in] idsOfSelectStop end of set of ids of the input extraction (excluded)
- * \param [in] idsOfSelectStep
+ * \param [in] idsOfSelectStep
step of set of ids of the input extraction
* \param [in] arrIn arr origin array from which the extraction will be done.
* \param [in] arrIndxIn is the input index array allowing to walk into \b arrIn
* \param [out] arrOut the resulting array
* \param [in] arrIn arr origin array from which the extraction will be done.
* \param [in] arrIndxIn is the input index array allowing to walk into \b arrIn
* \param [out] arrOut the resulting array