From: ageay Date: Mon, 16 Apr 2012 15:08:44 +0000 (+0000) Subject: Error in the python tests. X-Git-Tag: TRIPOLI_323~62 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=048622b3f0983944848579f4ba7a6927137389c6;p=tools%2Fmedcoupling.git Error in the python tests. --- diff --git a/src/MEDCoupling/MEDCouplingCMesh.cxx b/src/MEDCoupling/MEDCouplingCMesh.cxx index b3d123a51..0178d4b3f 100644 --- a/src/MEDCoupling/MEDCouplingCMesh.cxx +++ b/src/MEDCoupling/MEDCouplingCMesh.cxx @@ -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(),ref)); + const double *w=std::find_if(d,d+nbOfNodes,std::bind2nd(std::greater_equal(),ref)); int w2=(int)std::distance(d,w); - if(w2d[0]-eps) + w2=1; + else + return -1; + } ret+=coeff*(w2-1); coeff*=nbOfNodes-1; } diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py index d803173fa..4f297fcaf 100644 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py @@ -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();