Salome HOME
Correction of small bug on .__str__ on CurveLinearMesh with spaceDim != meshDim.
authorAnthony Geay <anthony.geay@edf.fr>
Mon, 20 Jul 2015 15:16:58 +0000 (17:16 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Mon, 20 Jul 2015 15:16:58 +0000 (17:16 +0200)
src/MEDCoupling/MEDCouplingCurveLinearMesh.cxx
src/MEDCoupling_Swig/MEDCouplingBasicsTest.py

index c37e3b203724dc0037e3335c5d7c1ad1bc41a584..601ea910d68b166edbe29c422bd7f8389998f842 100644 (file)
@@ -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 ; }
     { 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);
     { 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);
index 98c6f9e0c8f757cc734d816ad1750ab58c42d74a..9fb203dfede780aba365f7b3127b5d864ce3f162 100644 (file)
@@ -16694,6 +16694,26 @@ class MEDCouplingBasicsTest(unittest.TestCase):
         self.assertEqual(indRef,list(graph.getIndexArray().getValues()));
         pass
 
         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__':
     pass
 
 if __name__ == '__main__':