From: ageay Date: Fri, 12 Apr 2013 10:09:43 +0000 (+0000) Subject: Bug correction of DataArrayDouble::computeTupleIdsNearTuples and MEDCouplingPointSet... X-Git-Tag: V6_main_FINAL~152 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f9c7edaa14c7e67997be8a2ff33b90f88ae51118;p=tools%2Fmedcoupling.git Bug correction of DataArrayDouble::computeTupleIdsNearTuples and MEDCouplingPointSet::getNodeIdsNearPoints --- diff --git a/src/INTERP_KERNEL/BBTreePts.txx b/src/INTERP_KERNEL/BBTreePts.txx index e6eb029f1..fdb1e2ae6 100644 --- a/src/INTERP_KERNEL/BBTreePts.txx +++ b/src/INTERP_KERNEL/BBTreePts.txx @@ -188,8 +188,7 @@ public: const double* const bb_ptr=_pts+_elems[i]*dim; bool intersects = true; for(int idim=0;idim_epsilon) - intersects=false; + intersects=intersects && (std::abs(bb_ptr[idim]-xx[idim])<=_epsilon); if(intersects) elems.push_back(_elems[i]); } diff --git a/src/MEDCoupling/MEDCouplingMemArray.cxx b/src/MEDCoupling/MEDCouplingMemArray.cxx index 9ad55aaef..48f5750b1 100644 --- a/src/MEDCoupling/MEDCouplingMemArray.cxx +++ b/src/MEDCoupling/MEDCouplingMemArray.cxx @@ -69,7 +69,7 @@ void DataArrayDouble::findCommonTuplesAlg(const double *bbox, int nbNodes, int l } template -void DataArrayDouble::FindTupleIdsNearTuplesAlg(const BBTree& myTree, const double *pos, int nbOfTuples, double eps, +void DataArrayDouble::FindTupleIdsNearTuplesAlg(const BBTreePts& myTree, const double *pos, int nbOfTuples, double eps, DataArrayInt *c, DataArrayInt *cI) { for(int i=0;i bbox=computeBBoxPerTuple(eps); other->checkAllocated(); int nbOfCompo=getNumberOfComponents(); int otherNbOfCompo=other->getNumberOfComponents(); @@ -2796,19 +2795,19 @@ void DataArrayDouble::computeTupleIdsNearTuples(const DataArrayDouble *other, do { case 3: { - BBTree<3,int> myTree(bbox->getConstPointer(),0,0,getNumberOfTuples(),eps/10); + BBTreePts<3,int> myTree(begin(),0,0,getNumberOfTuples(),eps); FindTupleIdsNearTuplesAlg<3>(myTree,other->getConstPointer(),nbOfTuplesOther,eps,cArr,cIArr); break; } case 2: { - BBTree<2,int> myTree(bbox->getConstPointer(),0,0,getNumberOfTuples(),eps/10); + BBTreePts<2,int> myTree(begin(),0,0,getNumberOfTuples(),eps); FindTupleIdsNearTuplesAlg<2>(myTree,other->getConstPointer(),nbOfTuplesOther,eps,cArr,cIArr); break; } case 1: { - BBTree<1,int> myTree(bbox->getConstPointer(),0,0,getNumberOfTuples(),eps/10); + BBTreePts<1,int> myTree(begin(),0,0,getNumberOfTuples(),eps); FindTupleIdsNearTuplesAlg<1>(myTree,other->getConstPointer(),nbOfTuplesOther,eps,cArr,cIArr); break; } diff --git a/src/MEDCoupling/MEDCouplingMemArray.hxx b/src/MEDCoupling/MEDCouplingMemArray.hxx index 1ad1b6b1d..70999714e 100644 --- a/src/MEDCoupling/MEDCouplingMemArray.hxx +++ b/src/MEDCoupling/MEDCouplingMemArray.hxx @@ -333,7 +333,7 @@ namespace ParaMEDMEM template static void FindClosestTupleIdAlg(const BBTreePts& myTree, double dist, const double *pos, int nbOfTuples, const double *thisPt, int thisNbOfTuples, int *res); template - static void FindTupleIdsNearTuplesAlg(const BBTree& myTree, const double *pos, int nbOfTuples, double eps, + static void FindTupleIdsNearTuplesAlg(const BBTreePts& myTree, const double *pos, int nbOfTuples, double eps, DataArrayInt *c, DataArrayInt *cI); private: ~DataArrayDouble() { } diff --git a/src/MEDCoupling/MEDCouplingPointSet.cxx b/src/MEDCoupling/MEDCouplingPointSet.cxx index 7cad8e079..0e73b71d3 100644 --- a/src/MEDCoupling/MEDCouplingPointSet.cxx +++ b/src/MEDCoupling/MEDCouplingPointSet.cxx @@ -303,7 +303,7 @@ void MEDCouplingPointSet::findCommonNodes(double prec, int limitNodeId, DataArra * \param [in] pos - pointer to coordinates of the point. This array is expected to * be of length \a this->getSpaceDimension() at least, else the * behavior is not warranted. - * \param [in] eps - the lowest distance between a point and a node at which the node is + * \param [in] eps - the lowest distance between a point and a node (using infinite norm) at which the node is * not returned by this method. * \return DataArrayInt * - a new instance of DataArrayInt holding ids of nodes * close to the point. The caller is to delete this @@ -328,7 +328,7 @@ DataArrayInt *MEDCouplingPointSet::getNodeIdsNearPoint(const double *pos, double * behavior is not warranted. * \param [in] nbOfPoints - number of points whose coordinates are given by \a pos * parameter. - * \param [in] eps - the lowest distance between a point and a node at which the node is + * \param [in] eps - the lowest distance between (using infinite norm) a point and a node at which the node is * not returned by this method. * \param [out] c - array returning ids of nodes located closer than \a eps to the * given points. The caller diff --git a/src/MEDCoupling_Swig/MEDCouplingExamplesTest.py b/src/MEDCoupling_Swig/MEDCouplingExamplesTest.py index 37c6f3776..99d74dd64 100644 --- a/src/MEDCoupling_Swig/MEDCouplingExamplesTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingExamplesTest.py @@ -989,7 +989,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): 0.2,-0.3, # 1 0.3,-0.302, # 2 1.1,0.0, # 3 - 0.3,-0.303];# 4 + 0.3,-0.30299999999999];# 4 coordsArr=DataArrayDouble.New(); coordsArr.setValues(coords,5,2); mesh=MEDCouplingUMesh.New(); @@ -1023,7 +1023,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): 1.1, 0.002] # ~ nodes #3, #4 and #5 ids,idsIndex=mesh.getNodeIdsNearPoints(points,3,0.003); assert ids.getValues() == [1, 3, 4, 5] - print idsIndex.getValues() + assert idsIndex.getValues() == [0, 1, 1, 4] #! [PySnippet_MEDCouplingPointSet_getNodeIdsNearPoints_2] return @@ -1069,7 +1069,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): dv.alloc( 6, 1 ) dv.iota(7) dv.rearrange( 2 ) - print dv.getTuple( 1 ) + assert dv.getTuple( 1 ) == [9,10] #! [Snippet_DataArrayInt_getTuple_1] #! [Snippet_DataArrayInt_getTuple_2] for tpl in dv: