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

index 1b5a457a8d5c1b9b35fca8f05c431cb4cf4f7b52..70a24255132c6d08feb2a40417e80f4ef30a30ec 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..34b2a509b5ad9104f3ec3013ee5981c978e5c26d 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"))