]> SALOME platform Git repositories - modules/med.git/commitdiff
Salome HOME
MED file mesh loading on demand.
authorageay <ageay>
Mon, 1 Jul 2013 08:39:58 +0000 (08:39 +0000)
committerageay <ageay>
Mon, 1 Jul 2013 08:39:58 +0000 (08:39 +0000)
src/MEDLoader/MEDFileMeshReadSelector.cxx
src/MEDLoader/Swig/MEDLoaderTest3.py

index 9aad4e952e8d40017ce813cc8236b58dfbd383ff..945d02b168aa1322972ac0366a543740bf3f5c9c 100644 (file)
@@ -22,7 +22,7 @@
 
 using namespace ParaMEDMEM;
 
-MEDFileMeshReadSelector::MEDFileMeshReadSelector():_code(0)
+MEDFileMeshReadSelector::MEDFileMeshReadSelector():_code(0xFFFFFFFF)
 {
 }
 
@@ -62,18 +62,38 @@ bool MEDFileMeshReadSelector::isNodeNameFieldReading() const
 
 void MEDFileMeshReadSelector::setCellFamilyFieldReading(bool b)
 {
+  unsigned int code(_code & 0xFFFFFFFE);
+  unsigned int b2=b?1:0;
+  //b2<<=0;
+  code+=b2;
+  _code=code;
 }
 
 void MEDFileMeshReadSelector::setNodeFamilyFieldReading(bool b)
 {
+  unsigned int code(_code & 0xFFFFFFFD);
+  unsigned int b2=b?1:0;
+  b2<<=1;
+  code+=b2;
+  _code=code;
 }
 
 void MEDFileMeshReadSelector::setCellNameFieldReading(bool b)
 {
+  unsigned int code(_code & 0xFFFFFFFB);
+  unsigned int b2=b?1:0;
+  b2<<=2;
+  code+=b2;
+  _code=code;
 }
 
 void MEDFileMeshReadSelector::setNodeNameFieldReading(bool b)
 {
+  unsigned int code(_code & 0xFFFFFFF7);
+  unsigned int b2=b?1:0;
+  b2<<=3;
+  code+=b2;
+  _code=code;
 }
 
 void MEDFileMeshReadSelector::reprAll(std::ostream& str) const
index e7a06d17a4929c6dcf1664885700bd06a155c45e..580dd906a1884e747ed4ba80a331e42d37fd2f7f 100644 (file)
@@ -2964,6 +2964,63 @@ class MEDLoaderTest(unittest.TestCase):
         ffs.loadArrays()
         self.assertEqual(ffs.getHeapMemorySize()-heap_memory_ref,20*70*8*2+70*8*2+50*8*2)
         pass
+
+    def testMEDFileMeshReadSelector1(self):
+        mrs=MEDFileMeshReadSelector()
+        self.assertTrue(mrs.isCellFamilyFieldReading() and mrs.isNodeFamilyFieldReading() and mrs.isCellNameFieldReading() and mrs.isNodeNameFieldReading())
+        #
+        mrs=MEDFileMeshReadSelector(0)
+        self.assertTrue(not mrs.isCellFamilyFieldReading() and not mrs.isNodeFamilyFieldReading() and not mrs.isCellNameFieldReading() and not mrs.isNodeNameFieldReading())
+        mrs=MEDFileMeshReadSelector(1)
+        self.assertTrue(mrs.isCellFamilyFieldReading() and not mrs.isNodeFamilyFieldReading() and not mrs.isCellNameFieldReading() and not mrs.isNodeNameFieldReading())
+        mrs=MEDFileMeshReadSelector(2)
+        self.assertTrue(not mrs.isCellFamilyFieldReading() and mrs.isNodeFamilyFieldReading() and not mrs.isCellNameFieldReading() and not mrs.isNodeNameFieldReading())
+        mrs=MEDFileMeshReadSelector(3)
+        self.assertTrue(mrs.isCellFamilyFieldReading() and mrs.isNodeFamilyFieldReading() and not mrs.isCellNameFieldReading() and not mrs.isNodeNameFieldReading())
+        mrs=MEDFileMeshReadSelector(4)
+        self.assertTrue(not mrs.isCellFamilyFieldReading() and not mrs.isNodeFamilyFieldReading() and mrs.isCellNameFieldReading() and not mrs.isNodeNameFieldReading())
+        mrs=MEDFileMeshReadSelector(5)
+        self.assertTrue(mrs.isCellFamilyFieldReading() and not mrs.isNodeFamilyFieldReading() and mrs.isCellNameFieldReading() and not mrs.isNodeNameFieldReading())
+        mrs=MEDFileMeshReadSelector(6)
+        self.assertTrue(not mrs.isCellFamilyFieldReading() and mrs.isNodeFamilyFieldReading() and mrs.isCellNameFieldReading() and not mrs.isNodeNameFieldReading())
+        mrs=MEDFileMeshReadSelector(7)
+        self.assertTrue(mrs.isCellFamilyFieldReading() and mrs.isNodeFamilyFieldReading() and mrs.isCellNameFieldReading() and not mrs.isNodeNameFieldReading())
+        mrs=MEDFileMeshReadSelector(8)
+        self.assertTrue(not mrs.isCellFamilyFieldReading() and not mrs.isNodeFamilyFieldReading() and not mrs.isCellNameFieldReading() and mrs.isNodeNameFieldReading())
+        mrs=MEDFileMeshReadSelector(9)
+        self.assertTrue(mrs.isCellFamilyFieldReading() and not mrs.isNodeFamilyFieldReading() and not mrs.isCellNameFieldReading() and mrs.isNodeNameFieldReading())
+        mrs=MEDFileMeshReadSelector(10)
+        self.assertTrue(not mrs.isCellFamilyFieldReading() and mrs.isNodeFamilyFieldReading() and not mrs.isCellNameFieldReading() and mrs.isNodeNameFieldReading())
+        mrs=MEDFileMeshReadSelector(11)
+        self.assertTrue(mrs.isCellFamilyFieldReading() and mrs.isNodeFamilyFieldReading() and not mrs.isCellNameFieldReading() and mrs.isNodeNameFieldReading())
+        mrs=MEDFileMeshReadSelector(12)
+        self.assertTrue(not mrs.isCellFamilyFieldReading() and not mrs.isNodeFamilyFieldReading() and mrs.isCellNameFieldReading() and mrs.isNodeNameFieldReading())
+        mrs=MEDFileMeshReadSelector(13)
+        self.assertTrue(mrs.isCellFamilyFieldReading() and not mrs.isNodeFamilyFieldReading() and mrs.isCellNameFieldReading() and mrs.isNodeNameFieldReading())
+        mrs=MEDFileMeshReadSelector(14)
+        self.assertTrue(not mrs.isCellFamilyFieldReading() and mrs.isNodeFamilyFieldReading() and mrs.isCellNameFieldReading() and mrs.isNodeNameFieldReading())
+        mrs=MEDFileMeshReadSelector(15)
+        self.assertTrue(mrs.isCellFamilyFieldReading() and mrs.isNodeFamilyFieldReading() and mrs.isCellNameFieldReading() and mrs.isNodeNameFieldReading())
+        #
+        mrs=MEDFileMeshReadSelector(15)
+        mrs.setCellFamilyFieldReading(False)
+        self.assertEqual(mrs.getCode(),14)
+        mrs.setCellFamilyFieldReading(True)
+        self.assertEqual(mrs.getCode(),15)
+        mrs.setNodeFamilyFieldReading(False)
+        self.assertEqual(mrs.getCode(),13)
+        mrs.setNodeFamilyFieldReading(True)
+        self.assertEqual(mrs.getCode(),15)
+        mrs.setCellNameFieldReading(False)
+        self.assertEqual(mrs.getCode(),11)
+        mrs.setCellNameFieldReading(True)
+        self.assertEqual(mrs.getCode(),15)
+        mrs.setNodeNameFieldReading(False)
+        self.assertEqual(mrs.getCode(),7)
+        mrs.setNodeNameFieldReading(True)
+        self.assertEqual(mrs.getCode(),15)
+        pass
+
     pass
 
 unittest.main()