]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
Bug with FindClosestTupleIdAlg fixed (preventing the threshold to be null) V9_6_0b1
authorAnida KHIZAR <anida.khizar@cea.fr>
Thu, 8 Oct 2020 15:21:48 +0000 (17:21 +0200)
committerabn <adrien.bruneton@cea.fr>
Thu, 15 Oct 2020 18:18:37 +0000 (20:18 +0200)
src/MEDCoupling/MEDCouplingMemArray.cxx
src/MEDCoupling_Swig/MEDCouplingBasicsTest4.py

index 3d6cc18f90e1bb68723d4362084c2b4c740add3c..01b9c0cc18e6d604092ac90ca3f0eb5ddaf55bb9 100755 (executable)
@@ -119,7 +119,7 @@ void DataArrayDouble::FindTupleIdsNearTuplesAlg(const BBTreePts<SPACEDIM,mcIdTyp
 template<mcIdType SPACEDIM>
 void DataArrayDouble::FindClosestTupleIdAlg(const BBTreePts<SPACEDIM,mcIdType>& myTree, double dist, const double *pos, mcIdType nbOfTuples, const double *thisPt, mcIdType thisNbOfTuples, mcIdType *res)
 {
-  double distOpt(dist);
+  double distOpt = std::max(dist, std::numeric_limits<double>::epsilon());
   const double *p(pos);
   mcIdType *r(res);
   for(mcIdType i=0;i<nbOfTuples;i++,p+=SPACEDIM,r++)
index 4580dcc00f5864b3898a9c8f1d598aa032ed1f3b..2a468afc60fddd7d17de48d55f32503bc4cd7472 100644 (file)
@@ -2623,7 +2623,17 @@ class MEDCouplingBasicsTest4(unittest.TestCase):
             ids3=ptsi.findClosestTupleId(d2i)
             idsExpected3=idsExpected2.deepCopy() ; idsExpected3.reverse()
             self.assertTrue(idsExpected3.isEqual(ids3))
+            
+            #
+            ones = [1.0]*nbPt
+            twos = [2.0]*nbPt
+            d3=DataArrayDouble.Meld( DataArrayDouble(ones), DataArrayDouble(twos) )
+            d4=DataArrayDouble.Meld( DataArrayDouble(ones), DataArrayDouble(ones) )
+            idsExpected4 = DataArrayInt([0]*nbPt)
+            ids4 = d3.findClosestTupleId(d4)
+            self.assertTrue(idsExpected.isEqual(ids))
             pass
+    
 
     def testSwig2DataArrayAsciiChar1(self):
         alpha=DataArrayInt(26) ; alpha.iota(ord("A"))