]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
Error in the python tests.
authorageay <ageay>
Mon, 16 Apr 2012 15:08:44 +0000 (15:08 +0000)
committerageay <ageay>
Mon, 16 Apr 2012 15:08:44 +0000 (15:08 +0000)
src/MEDCoupling/MEDCouplingCMesh.cxx
src/MEDCoupling_Swig/MEDCouplingBasicsTest.py

index b3d123a51bc48f44c99f1d4b23880921b8ad3a55..0178d4b3f19f230e0ce7dbe6bbcf15a00d459589 100644 (file)
@@ -718,10 +718,17 @@ int MEDCouplingCMesh::getCellContainingPoint(const double *pos, double eps) cons
       const double *d=getCoordsAt(i)->getConstPointer();
       int nbOfNodes=getCoordsAt(i)->getNbOfElems();
       double ref=pos[i];
-      const double *w=std::find_if(d,d+nbOfNodes,std::bind2nd(std::greater<double>(),ref));
+      const double *w=std::find_if(d,d+nbOfNodes,std::bind2nd(std::greater_equal<double>(),ref));
       int w2=(int)std::distance(d,w);
-      if(w2<nbOfNodes && w2!=0)
+      if(w2<nbOfNodes)
         {
+          if(w2==0)
+            {
+              if(ref>d[0]-eps)
+                w2=1;
+              else
+                return -1;
+            }
           ret+=coeff*(w2-1);
           coeff*=nbOfNodes-1;
         }
index d803173fa2b2bbb57f00847660bbfc91aed5f3dc..4f297fcaf2c71ab1ddea564deb4dc5978baf379a 100644 (file)
@@ -4285,11 +4285,11 @@ class MEDCouplingBasicsTest(unittest.TestCase):
         da.setValues(discX,4,1);
         m.setCoordsAt(0,da);
         m.checkCoherency();
-        self.assertEqual(0,m.getCellContainingPoint([2.4],12));
-        self.assertEqual(1,m.getCellContainingPoint([3.7],12));
-        self.assertEqual(2,m.getCellContainingPoint([5.9],12));
-        self.assertEqual(-1,m.getCellContainingPoint([10.3],12));
-        self.assertEqual(-1,m.getCellContainingPoint([1.3],12));
+        self.assertEqual(0,m.getCellContainingPoint([2.4],1e-12));
+        self.assertEqual(1,m.getCellContainingPoint([3.7],1e-12));
+        self.assertEqual(2,m.getCellContainingPoint([5.9],1e-12));
+        self.assertEqual(-1,m.getCellContainingPoint([10.3],1e-12));
+        self.assertEqual(-1,m.getCellContainingPoint([1.3],1e-12));
         #
         m2=m.buildUnstructured();
         m2.checkCoherency();