]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
Bug with FindClosestTupleIdAlg fixed (preventing the threshold to be null) akr/BugFix2
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 13:17:06 +0000 (15:17 +0200)
src/MEDCoupling/MEDCouplingMemArray.cxx
src/MEDCoupling_Swig/MEDCouplingBasicsTest4.py

index 3d6cc18f90e1bb68723d4362084c2b4c740add3c..bcd7a7079a21553a1fd70df739af0dc83416c749 100755 (executable)
@@ -119,7 +119,8 @@ 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());
+  //double distOpt(dist);
   const double *p(pos);
   mcIdType *r(res);
   for(mcIdType i=0;i<nbOfTuples;i++,p+=SPACEDIM,r++)
index 4580dcc00f5864b3898a9c8f1d598aa032ed1f3b..88bb65c3511d05083524ea3b7e8d0f21e52b67d0 100644 (file)
@@ -2622,8 +2622,19 @@ class MEDCouplingBasicsTest4(unittest.TestCase):
             #
             ids3=ptsi.findClosestTupleId(d2i)
             idsExpected3=idsExpected2.deepCopy() ; idsExpected3.reverse()
-            self.assertTrue(idsExpected3.isEqual(ids3))
+            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"))