From c5ef577feb885e3daf07beb0e6af2d03236ff702 Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Mon, 25 Jul 2016 18:51:31 +0200 Subject: [PATCH] a useful method in DataArray --- src/MEDCoupling/MEDCouplingMemArray.cxx | 18 ++++++++++++++++++ src/MEDCoupling/MEDCouplingMemArray.hxx | 2 ++ src/MEDCoupling_Swig/MEDCouplingMemArray.i | 2 ++ 3 files changed, 22 insertions(+) diff --git a/src/MEDCoupling/MEDCouplingMemArray.cxx b/src/MEDCoupling/MEDCouplingMemArray.cxx index 8ccb92e54..9a41ce729 100644 --- a/src/MEDCoupling/MEDCouplingMemArray.cxx +++ b/src/MEDCoupling/MEDCouplingMemArray.cxx @@ -3061,6 +3061,15 @@ void DataArrayDouble::useExternalArrayWithRWAccess(const double *array, int nbOf declareAsNew(); } +void DataArrayDouble::aggregate(const DataArrayDouble *other) +{ + if(!other) + throw INTERP_KERNEL::Exception("DataArrayDouble::aggregate : null pointer !"); + if(getNumberOfComponents()!=other->getNumberOfComponents()) + throw INTERP_KERNEL::Exception("DataArrayDouble::aggregate : mismatch number of components !"); + _mem.insertAtTheEnd(other->begin(),other->end()); +} + /*! * Checks if 0.0 value is present in \a this array. If it is the case, an exception * is thrown. @@ -7159,6 +7168,15 @@ void DataArrayInt::useExternalArrayWithRWAccess(const int *array, int nbOfTuple, declareAsNew(); } +void DataArrayInt::aggregate(const DataArrayInt *other) +{ + if(!other) + throw INTERP_KERNEL::Exception("DataArrayInt::aggregate : null pointer !"); + if(getNumberOfComponents()!=other->getNumberOfComponents()) + throw INTERP_KERNEL::Exception("DataArrayInt::aggregate : mismatch number of components !"); + _mem.insertAtTheEnd(other->begin(),other->end()); +} + /*! * Returns a new DataArrayInt holding the same values as \a this array but differently * arranged in memory. If \a this array holds 2 components of 3 values: diff --git a/src/MEDCoupling/MEDCouplingMemArray.hxx b/src/MEDCoupling/MEDCouplingMemArray.hxx index 725d3d121..a4eb5f7cb 100644 --- a/src/MEDCoupling/MEDCouplingMemArray.hxx +++ b/src/MEDCoupling/MEDCouplingMemArray.hxx @@ -308,6 +308,7 @@ namespace MEDCoupling MEDCOUPLING_EXPORT void useExternalArrayWithRWAccess(const double *array, int nbOfTuple, int nbOfCompo); 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; @@ -626,6 +627,7 @@ namespace MEDCoupling MEDCOUPLING_EXPORT void useExternalArrayWithRWAccess(const int *array, int nbOfTuple, int nbOfCompo); 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 *Add(const DataArrayInt *a1, const DataArrayInt *a2); MEDCOUPLING_EXPORT void addEqual(const DataArrayInt *other); diff --git a/src/MEDCoupling_Swig/MEDCouplingMemArray.i b/src/MEDCoupling_Swig/MEDCouplingMemArray.i index 81516f01c..7beeb58a4 100644 --- a/src/MEDCoupling_Swig/MEDCouplingMemArray.i +++ b/src/MEDCoupling_Swig/MEDCouplingMemArray.i @@ -532,6 +532,7 @@ namespace MEDCoupling static DataArrayDouble *New(); double doubleValue() const throw(INTERP_KERNEL::Exception); bool empty() const throw(INTERP_KERNEL::Exception); + void aggregate(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception); DataArrayDouble *performCopyOrIncrRef(bool deepCopy) const throw(INTERP_KERNEL::Exception); void deepCopyFrom(const DataArrayDouble& other) throw(INTERP_KERNEL::Exception); void reserve(std::size_t nbOfElems) throw(INTERP_KERNEL::Exception); @@ -2587,6 +2588,7 @@ namespace MEDCoupling int intValue() const throw(INTERP_KERNEL::Exception); int getHashCode() const throw(INTERP_KERNEL::Exception); bool empty() const throw(INTERP_KERNEL::Exception); + void aggregate(const DataArrayInt *other) throw(INTERP_KERNEL::Exception); DataArrayInt *performCopyOrIncrRef(bool deepCopy) const throw(INTERP_KERNEL::Exception); void deepCopyFrom(const DataArrayInt& other) throw(INTERP_KERNEL::Exception); void reserve(std::size_t nbOfElems) throw(INTERP_KERNEL::Exception); -- 2.39.2