From: ageay Date: Mon, 13 Dec 2010 14:02:09 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: MEDPartitioner_first_compilable_version~27 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a80fcbd881bc333e092fa69dec992afe7a15a12c;p=tools%2Fmedcoupling.git *** empty log message *** --- diff --git a/src/MEDCoupling/MEDCouplingMemArray.cxx b/src/MEDCoupling/MEDCouplingMemArray.cxx index c4bf7ff74..2b044363f 100644 --- a/src/MEDCoupling/MEDCouplingMemArray.cxx +++ b/src/MEDCoupling/MEDCouplingMemArray.cxx @@ -2089,6 +2089,28 @@ DataArrayInt *DataArrayInt::buildComplement(int nbOfElement) const throw(INTERP_ return ret; } +DataArrayInt *DataArrayInt::substract(const DataArrayInt *other) const throw(INTERP_KERNEL::Exception) +{ + checkAllocated(); + other->checkAllocated(); + if(getNumberOfComponents()!=1) + throw INTERP_KERNEL::Exception("DataArrayInt::substract : only single component allowed !"); + if(other->getNumberOfComponents()!=1) + throw INTERP_KERNEL::Exception("DataArrayInt::substract : only single component allowed for other type !"); + const int *pt=getConstPointer(); + int nbOfTuples=getNumberOfTuples(); + std::set s1(pt,pt+nbOfTuples); + pt=other->getConstPointer(); + nbOfTuples=other->getNumberOfTuples(); + std::set s2(pt,pt+nbOfTuples); + std::vector r; + std::set_difference(s1.begin(),s1.end(),s2.begin(),s2.end(),std::back_insert_iterator< std::vector >(r)); + DataArrayInt *ret=DataArrayInt::New(); + ret->alloc(r.size(),1); + std::copy(r.begin(),r.end(),ret->getPointer()); + return ret; +} + DataArrayInt *DataArrayInt::buildUnion(const DataArrayInt *other) const throw(INTERP_KERNEL::Exception) { checkAllocated(); diff --git a/src/MEDCoupling/MEDCouplingMemArray.hxx b/src/MEDCoupling/MEDCouplingMemArray.hxx index 0a43eb34e..c0eed999c 100644 --- a/src/MEDCoupling/MEDCouplingMemArray.hxx +++ b/src/MEDCoupling/MEDCouplingMemArray.hxx @@ -267,6 +267,7 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT static DataArrayInt *meld(const std::vector& a) throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT static DataArrayInt *makePartition(const std::vector& groups, int newNb, std::vector< std::vector >& fidsOfGroups); MEDCOUPLING_EXPORT DataArrayInt *buildComplement(int nbOfElement) const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT DataArrayInt *substract(const DataArrayInt *other) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT DataArrayInt *buildUnion(const DataArrayInt *other) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT DataArrayInt *buildIntersection(const DataArrayInt *other) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT DataArrayInt *deltaShiftIndex() const throw(INTERP_KERNEL::Exception); diff --git a/src/MEDCoupling_Swig/MEDCoupling.i b/src/MEDCoupling_Swig/MEDCoupling.i index 80e582071..cb00f5c13 100644 --- a/src/MEDCoupling_Swig/MEDCoupling.i +++ b/src/MEDCoupling_Swig/MEDCoupling.i @@ -115,6 +115,7 @@ using namespace INTERP_KERNEL; %newobject ParaMEDMEM::DataArrayInt::toNoInterlace; %newobject ParaMEDMEM::DataArrayInt::buildComplement; %newobject ParaMEDMEM::DataArrayInt::buildUnion; +%newobject ParaMEDMEM::DataArrayInt::substract; %newobject ParaMEDMEM::DataArrayInt::buildIntersection; %newobject ParaMEDMEM::DataArrayInt::deltaShiftIndex; %newobject ParaMEDMEM::DataArrayDouble::New;