From: Anthony Geay Date: Mon, 20 Jul 2015 15:16:58 +0000 (+0200) Subject: Correction of small bug on .__str__ on CurveLinearMesh with spaceDim != meshDim. X-Git-Tag: V7_7_0a1~8 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f426347c8004c0665583b15748630acd4f167450;p=modules%2Fmed.git Correction of small bug on .__str__ on CurveLinearMesh with spaceDim != meshDim. --- diff --git a/src/MEDCoupling/MEDCouplingCurveLinearMesh.cxx b/src/MEDCoupling/MEDCouplingCurveLinearMesh.cxx index c37e3b203..601ea910d 100644 --- a/src/MEDCoupling/MEDCouplingCurveLinearMesh.cxx +++ b/src/MEDCoupling/MEDCouplingCurveLinearMesh.cxx @@ -910,8 +910,16 @@ void MEDCouplingCurveLinearMesh::reprQuickOverview(std::ostream& stream) const { stream << std::endl << "No coordinates set !"; return ; } if(!coo->isAllocated()) { stream << std::endl << "Coordinates set but not allocated !"; return ; } - int nbOfCompo=coo->getNumberOfComponents(); - if(nbOfCompo!=(int)_structure.size()) + int nbOfCompo(coo->getNumberOfComponents()); + int nbOfCompoExp(-1); + try + { + nbOfCompoExp=getSpaceDimension(); + } + catch(INTERP_KERNEL::Exception& e) + { + } + if(nbOfCompo!=nbOfCompoExp) { stream << std::endl << "Coordinates set and allocated but mismatch number of components !"; return ; } stream << std::endl << "Coordinates ( number of tuples = " << coo->getNumberOfTuples() << " ) : "; coo->reprQuickOverviewData(stream,200); diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py index 98c6f9e0c..9fb203dfe 100644 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py @@ -16694,6 +16694,26 @@ class MEDCouplingBasicsTest(unittest.TestCase): self.assertEqual(indRef,list(graph.getIndexArray().getValues())); pass + def testSwig2MEDCouplingCurveLinearReprQuick1(self): + """Non regression test. Error in m.__str__ when m is a MEDCouplingCurveLinear with spaceDim != meshDim.""" + arr=DataArrayDouble(12) ; arr.iota() ; arr.rearrange(2) + m=MEDCouplingCurveLinearMesh() + m.setCoords(arr) + m.setNodeGridStructure([3,2]) + m.checkCoherency() + self.assertEqual(m.getMeshDimension(),2) + self.assertEqual(m.getSpaceDimension(),2) + self.assertTrue(not "mismatch" in m.__str__()) + self.assertTrue(not "mismatch" in m.__repr__()) + # + arr=DataArrayDouble(18) ; arr.iota() ; arr.rearrange(3) + m.setCoords(arr) + self.assertEqual(m.getMeshDimension(),2) + self.assertEqual(m.getSpaceDimension(),3) + self.assertTrue(not "mismatch" in m.__str__()) + self.assertTrue(not "mismatch" in m.__repr__())# bug was here ! + pass + pass if __name__ == '__main__':