From: geay Date: Wed, 11 Jun 2014 15:55:58 +0000 (+0200) Subject: Debug on limit cases when input part are empty. Correct bug of DeduceNumberOfEntities. X-Git-Tag: V7_5_0a1~37^2~14 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=57283153e15a406c207ed01edab147165b50f9a6;p=modules%2Fmed.git Debug on limit cases when input part are empty. Correct bug of DeduceNumberOfEntities. --- diff --git a/src/MEDCoupling/MEDCouplingIMesh.cxx b/src/MEDCoupling/MEDCouplingIMesh.cxx index 3821d60db..a61d4fab2 100644 --- a/src/MEDCoupling/MEDCouplingIMesh.cxx +++ b/src/MEDCoupling/MEDCouplingIMesh.cxx @@ -294,6 +294,8 @@ void MEDCouplingIMesh::CondenseFineToCoarse(const std::vector& coarseSt, co throw INTERP_KERNEL::Exception(oss.str().c_str()); } int nbTuplesFine(fineDA->getNumberOfTuples()); + if(nbOfTuplesInFineExp==0) + return ; if(nbTuplesFine%nbOfTuplesInFineExp!=0) throw INTERP_KERNEL::Exception("MEDCouplingIMesh::CondenseFineToCoarse : Invalid nb of tuples in fine DataArray regarding its structure !"); int fact(std::accumulate(facts.begin(),facts.end(),1,std::multiplies())); diff --git a/src/MEDCoupling/MEDCouplingStructuredMesh.cxx b/src/MEDCoupling/MEDCouplingStructuredMesh.cxx index ebc71739d..58ec89f01 100644 --- a/src/MEDCoupling/MEDCouplingStructuredMesh.cxx +++ b/src/MEDCoupling/MEDCouplingStructuredMesh.cxx @@ -748,7 +748,6 @@ DataArrayInt *MEDCouplingStructuredMesh::ComputeCornersGhost(const std::vector >& partCompactFormat) { int ret(1); - bool isFetched(false); std::size_t ii(0); for(std::vector< std::pair >::const_iterator it=partCompactFormat.begin();it!=partCompactFormat.end();it++,ii++) { @@ -758,13 +757,9 @@ int MEDCouplingStructuredMesh::DeduceNumberOfGivenRangeInCompactFrmt(const std:: std::ostringstream oss; oss << "MEDCouplingStructuredMesh::DeduceNumberOfGivenRangeInCompactFrmt : invalid input at dimension " << ii << " !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } - if(b-a>0) - { - isFetched=true; - ret*=(b-a); - } + ret*=(b-a); } - return isFetched?ret:0; + return ret; } int MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(const std::vector& st) diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py index 7e3a76964..914dfdb22 100644 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py @@ -13525,7 +13525,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): a,b=MEDCouplingStructuredMesh.IsPartStructured(d20,st) self.assertTrue(a) ; self.assertEqual(b,[(1,5),(0,3)]) self.assertEqual(12,MEDCouplingStructuredMesh.DeduceNumberOfGivenRangeInCompactFrmt(b)) - self.assertEqual(8,MEDCouplingStructuredMesh.DeduceNumberOfGivenRangeInCompactFrmt([(1,5),(1,3),(2,2)])) + self.assertEqual(0,MEDCouplingStructuredMesh.DeduceNumberOfGivenRangeInCompactFrmt([(1,5),(1,3),(2,2)])) self.assertEqual(0,MEDCouplingStructuredMesh.DeduceNumberOfGivenRangeInCompactFrmt([(5,5),(3,3),(2,2)])) self.assertEqual(36,MEDCouplingStructuredMesh.DeduceNumberOfGivenStructure([3,2,6])) self.assertEqual(126,MEDCouplingStructuredMesh.DeduceNumberOfGivenStructure((3,7,6)))