* renumbering. The underlying mesh is deeply copied and its cells are also permuted.
* The number of cells remains the same; for that the permutation array \a old2NewBg
* should not contain equal ids.
+ * ** Warning, this method modifies the mesh aggreagated by \a this (by performing a deep copy ) **.
+ *
* \param [in] old2NewBg - the permutation array in "Old to New" mode. Its length is
* to be equal to \a this->getMesh()->getNumberOfCells().
* \param [in] check - if \c true, \a old2NewBg is transformed to a new permutation
copyPartOfStringInfoFrom2(compIds,*other);
}
+/*!
+ * This method checks that all tuples in \a other are in \a this.
+ * If true, the output param \a tupleIds contains the tuples ids of \a this that correspond to tupes in \a this.
+ * For each i in [ 0 , other->getNumberOfTuples() ) tuple #i in \a other is equal ( regarding input precision \a prec ) to tuple tupleIds[i] in \a this.
+ *
+ * \param [in] other - the array having the same number of components than \a this.
+ * \param [out] tupleIds - the tuple ids containing the same number of tuples than \a other has.
+ * \sa DataArrayDouble::findCommonTuples
+ */
+bool DataArrayDouble::areIncludedInMe(const DataArrayDouble *other, double prec, DataArrayInt *&tupleIds) const throw(INTERP_KERNEL::Exception)
+{
+ if(!other)
+ throw INTERP_KERNEL::Exception("DataArrayDouble::areIncludedInMe : input array is NULL !");
+ checkAllocated(); other->checkAllocated();
+ if(getNumberOfComponents()!=other->getNumberOfComponents())
+ throw INTERP_KERNEL::Exception("DataArrayDouble::areIncludedInMe : the number of components does not match !");
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> a=DataArrayDouble::Aggregate(this,other);
+ DataArrayInt *c=0,*ci=0;
+ a->findCommonTuples(prec,getNumberOfTuples(),c,ci);
+ int newNbOfTuples=-1;
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=DataArrayInt::BuildOld2NewArrayFromSurjectiveFormat2(a->getNumberOfTuples(),c->begin(),ci->begin(),ci->end(),newNbOfTuples);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret1=ids->selectByTupleId2(getNumberOfTuples(),a->getNumberOfTuples(),1);
+ tupleIds=ret1.retn();
+ return newNbOfTuples==getNumberOfTuples();
+}
+
/*!
* Searches for tuples coincident within \a prec tolerance. Each tuple is considered
* as coordinates of a point in getNumberOfComponents()-dimensional space. The
* \ref cpp_mcdataarraydouble_findcommontuples "Here is a C++ example".
*
* \ref py_mcdataarraydouble_findcommontuples "Here is a Python example".
- * \sa DataArrayInt::BuildOld2NewArrayFromSurjectiveFormat2().
+ * \sa DataArrayInt::BuildOld2NewArrayFromSurjectiveFormat2(), DataArrayDouble::areIncludedInMe
*/
void DataArrayDouble::findCommonTuples(double prec, int limitTupleId, DataArrayInt *&comm, DataArrayInt *&commIndex) const throw(INTERP_KERNEL::Exception)
{
MEDCOUPLING_EXPORT DataArrayDouble *changeNbOfComponents(int newNbOfComp, double dftValue) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArray *keepSelectedComponents(const std::vector<int>& compoIds) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void meldWith(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT bool areIncludedInMe(const DataArrayDouble *other, double prec, DataArrayInt *&tupleIds) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void findCommonTuples(double prec, int limitTupleId, DataArrayInt *&comm, DataArrayInt *&commIndex) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT double minimalDistanceTo(const DataArrayDouble *other, int& thisTupleId, int& otherTupleId) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayDouble *duplicateEachTupleNTimes(int nbTimes) const throw(INTERP_KERNEL::Exception);
self.assertTrue(b is None)
pass
+ def testSwig2DADAreIncludedInMe1(self):
+ a=DataArrayDouble(30) ; a.iota() ; a.rearrange(3)
+ p=DataArrayInt([5,2,1,9])
+ b,c=a.areIncludedInMe(a[p],1e-12)
+ self.assertTrue(b)
+ self.assertTrue(c.isEqual(p))
+ d=a[p]
+ d.setIJ(3,1,28.1)
+ b,c=a.areIncludedInMe(d,1e-12)
+ self.assertTrue(not b)
+ self.assertTrue(c.isEqual(DataArrayInt([5,2,1,10])))
+ pass
+
def setUp(self):
pass
pass
return ret;
}
+ PyObject *areIncludedInMe(const DataArrayDouble *other, double prec) const throw(INTERP_KERNEL::Exception)
+ {
+ DataArrayInt *ret1=0;
+ bool ret0=self->areIncludedInMe(other,prec,ret1);
+ PyObject *ret=PyTuple_New(2);
+ PyObject *ret0Py=ret0?Py_True:Py_False;
+ Py_XINCREF(ret0Py);
+ PyTuple_SetItem(ret,0,ret0Py);
+ PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ return ret;
+ }
+
PyObject *__getitem__(PyObject *obj) throw(INTERP_KERNEL::Exception)
{
const char msg[]="Unexpected situation in DataArrayDouble::__getitem__ !";