From: ageay Date: Wed, 15 Dec 2010 15:18:30 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: RELIQUAT_6x_15112010~9 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3f9ec946744a73649b093417e99c0214f7f330c3;p=tools%2Fmedcoupling.git *** empty log message *** --- diff --git a/src/MEDCoupling/MEDCouplingMemArray.cxx b/src/MEDCoupling/MEDCouplingMemArray.cxx index 8c94de8b4..48c6d39e6 100644 --- a/src/MEDCoupling/MEDCouplingMemArray.cxx +++ b/src/MEDCoupling/MEDCouplingMemArray.cxx @@ -484,6 +484,24 @@ DataArrayDouble *DataArrayDouble::changeNbOfComponents(int newNbOfComp, double d return ret; } +/*! + * Contrary to DataArrayDouble::changeNbOfComponents method this method is \b not const. The content + * This method \b do \b not change the content of data but changes the splitting of this data seen by the caller. + * This method makes the assumption that 'this' is already allocated. If not an exception will be thrown. + * This method checks that getNbOfElems()%newNbOfCompo==0. If not an exception will be throw ! + * This method erases all components info set before call ! + */ +void DataArrayDouble::morphToNewNbOfComponents(int newNbOfCompo) throw(INTERP_KERNEL::Exception) +{ + checkAllocated(); + int nbOfElems=getNbOfElems(); + if(nbOfElems%newNbOfCompo!=0) + throw INTERP_KERNEL::Exception("DataArrayDouble::morphToNewNbOfComponents : nbOfElems%newNbOfCompo!=0 !"); + _info_on_compo.clear(); + _info_on_compo.resize(newNbOfCompo); + declareAsNew(); +} + DataArrayDouble *DataArrayDouble::keepSelectedComponents(const std::vector& compoIds) const throw(INTERP_KERNEL::Exception) { checkAllocated(); @@ -1819,6 +1837,24 @@ DataArrayInt *DataArrayInt::substr(int tupleIdBg, int tupleIdEnd) const throw(IN return ret; } +/*! + * Contrary to DataArrayInt::changeNbOfComponents method this method is \b not const. The content + * This method \b do \b not change the content of data but changes the splitting of this data seen by the caller. + * This method makes the assumption that 'this' is already allocated. If not an exception will be thrown. + * This method checks that getNbOfElems()%newNbOfCompo==0. If not an exception will be throw ! + * This method erases all components info set before call ! + */ +void DataArrayInt::morphToNewNbOfComponents(int newNbOfCompo) throw(INTERP_KERNEL::Exception) +{ + checkAllocated(); + int nbOfElems=getNbOfElems(); + if(nbOfElems%newNbOfCompo!=0) + throw INTERP_KERNEL::Exception("DataArrayInt::morphToNewNbOfComponents : nbOfElems%newNbOfCompo!=0 !"); + _info_on_compo.clear(); + _info_on_compo.resize(newNbOfCompo); + declareAsNew(); +} + /*! * This method builds a new instance of DataArrayInt (to deal with) that is reduction or an extension of 'this'. * if 'newNbOfComp' < this->getNumberOfComponents() a reduction is done and for each tuple 'newNbOfComp' first components are kept. diff --git a/src/MEDCoupling/MEDCouplingMemArray.hxx b/src/MEDCoupling/MEDCouplingMemArray.hxx index 354f73253..7ef03d8c3 100644 --- a/src/MEDCoupling/MEDCouplingMemArray.hxx +++ b/src/MEDCoupling/MEDCouplingMemArray.hxx @@ -146,6 +146,7 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT DataArrayDouble *selectByTupleId(const int *new2OldBg, const int *new2OldEnd) const; MEDCOUPLING_EXPORT DataArrayDouble *selectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT DataArrayDouble *substr(int tupleIdBg, int tupleIdEnd=-1) const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT void morphToNewNbOfComponents(int newNbOfCompo) throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT DataArrayDouble *changeNbOfComponents(int newNbOfComp, double dftValue) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT DataArrayDouble *keepSelectedComponents(const std::vector& compoIds) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void meldWith(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception); @@ -249,6 +250,7 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT bool isIdentity() const; MEDCOUPLING_EXPORT bool isUniform(int val) const; MEDCOUPLING_EXPORT DataArrayInt *substr(int tupleIdBg, int tupleIdEnd=-1) const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT void morphToNewNbOfComponents(int newNbOfCompo) throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT DataArrayInt *changeNbOfComponents(int newNbOfComp, int dftValue) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT DataArrayInt *keepSelectedComponents(const std::vector& compoIds) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void meldWith(const DataArrayInt *other) throw(INTERP_KERNEL::Exception);