]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
0022875: test MEDCouplingSkyLineArray
authoreap <eap@opencascade.com>
Mon, 25 May 2015 18:33:47 +0000 (21:33 +0300)
committereap <eap@opencascade.com>
Mon, 25 May 2015 18:33:47 +0000 (21:33 +0300)
src/MEDCoupling/MEDCouplingSkyLineArray.cxx
src/MEDCoupling/MEDCouplingSkyLineArray.hxx
src/MEDCoupling/MEDCouplingUMesh.cxx
src/MEDCoupling/MEDCouplingUMesh.hxx
src/MEDCoupling_Swig/MEDCouplingBasicsTest.py
src/MEDCoupling_Swig/MEDCouplingCommon.i
src/MEDLoader/Swig/MEDLoaderTest3.py
src/MEDPartitioner/MEDPARTITIONER_MeshCollection.cxx

index 518bda8a1264f818f5c24d20753e0fff6ae1edad..9719cb04dbcef9f570b1e57b5d9c6162f84f59b1 100644 (file)
@@ -36,10 +36,9 @@ MEDCouplingSkyLineArray::~MEDCouplingSkyLineArray()
 {
 }
 
-MEDCouplingSkyLineArray::MEDCouplingSkyLineArray(const MEDCouplingAutoRefCountObjectPtr<DataArrayInt>& index, const MEDCouplingAutoRefCountObjectPtr<DataArrayInt>& value)
+MEDCouplingSkyLineArray::MEDCouplingSkyLineArray(DataArrayInt* index, DataArrayInt* value)
 {
-  _index=index;
-  _value=value;
+  set( index, value );
 }
 
 MEDCouplingSkyLineArray::MEDCouplingSkyLineArray( const std::vector<int>& index,
@@ -49,3 +48,23 @@ MEDCouplingSkyLineArray::MEDCouplingSkyLineArray( const std::vector<int>& index,
   _index->insertAtTheEnd( index.begin(), index.end() );
   _value->insertAtTheEnd( value.begin(), value.end() );
 }
+
+void MEDCouplingSkyLineArray::set( DataArrayInt* index, DataArrayInt* value )
+{
+  _index=index;
+  _value=value;
+  if ( (DataArrayInt*)_index ) _index->incrRef();
+  else                         _index = DataArrayInt::New();
+  if ( (DataArrayInt*)_value ) _value->incrRef();
+  else                         _value = DataArrayInt::New();
+}
+
+DataArrayInt* MEDCouplingSkyLineArray::getIndexArray() const
+{
+  return ((MEDCouplingSkyLineArray*)this)->_index;
+}
+
+DataArrayInt* MEDCouplingSkyLineArray::getValueArray() const
+{
+  return ((MEDCouplingSkyLineArray*)this)->_value;
+}
index 79264036f29dac1e2d1f77ec361a0602a190770e..06826f803d3a56e5ce2f3168b724571c9f97e235 100644 (file)
@@ -37,20 +37,18 @@ namespace ParaMEDMEM
     MEDCouplingSkyLineArray();
     MEDCouplingSkyLineArray( const MEDCouplingSkyLineArray &myArray );
     MEDCouplingSkyLineArray( const std::vector<int>& index, const std::vector<int>& value );
-    MEDCouplingSkyLineArray( const MEDCouplingAutoRefCountObjectPtr<DataArrayInt>& index,
-                             const MEDCouplingAutoRefCountObjectPtr<DataArrayInt>& value );
+    MEDCouplingSkyLineArray( DataArrayInt* index, DataArrayInt* value );
     ~MEDCouplingSkyLineArray();
 
-    void set( const MEDCouplingAutoRefCountObjectPtr<DataArrayInt>& index,
-              const MEDCouplingAutoRefCountObjectPtr<DataArrayInt>& value );
+    void set( DataArrayInt* index, DataArrayInt* value );
 
     int getNumberOf() const { return _index->getNbOfElems()-1; }
     int getLength()   const { return _value->getNbOfElems(); }
     const int* getIndex() const { return _index->begin(); }
     const int* getValue() const { return _value->begin(); }
 
-    MEDCouplingAutoRefCountObjectPtr<DataArrayInt> getIndexArray() const { return _index; }
-    MEDCouplingAutoRefCountObjectPtr<DataArrayInt> getValueArray() const { return _value; }
+    DataArrayInt* getIndexArray() const;
+    DataArrayInt* getValueArray() const;
   };
 }
 # endif
index 674d4182d7b452030ba09a4f8f957905c44f2feb..7d9e5426e70a1c077c47fec0e171e8a259471b0a 100644 (file)
@@ -22,6 +22,7 @@
 #include "MEDCoupling1GTUMesh.hxx"
 #include "MEDCouplingMemArray.txx"
 #include "MEDCouplingFieldDouble.hxx"
+#include "MEDCouplingSkyLineArray.hxx"
 #include "CellModel.hxx"
 #include "VolSurfUser.txx"
 #include "InterpolationUtils.hxx"
index 16079ddf1ae7051d1d862002c195e9ce1d333879..55bc28918e019008ec8290218ec81825d02b2182 100644 (file)
@@ -24,7 +24,6 @@
 #include "MEDCoupling.hxx"
 #include "MEDCouplingPointSet.hxx"
 #include "MEDCouplingMemArray.hxx"
-#include "MEDCouplingSkyLineArray.hxx"
 
 #include "CellModel.hxx"
 
@@ -36,6 +35,7 @@ namespace ParaMEDMEM
   class MEDCouplingUMeshCellIterator;
   class MEDCoupling1SGTUMesh;
   class MEDCoupling1GTUMesh;
+  class MEDCouplingSkyLineArray;
 
   class MEDCouplingUMesh : public MEDCouplingPointSet
   {
index c6bc0d7d085687dc7978453e9ae27eca387c7171..775beac94121a98e95d660537ae3f1ed9dea5fc5 100644 (file)
@@ -16429,6 +16429,33 @@ class MEDCouplingBasicsTest(unittest.TestCase):
         m2.zipCoords()
         self.assertTrue(m2.areAllNodesFetched())
         pass
+
+    def testMEDCouplingSkyLineArray(self):
+        index = DataArrayInt([ 0, 3, 5, 6, 6 ])
+        value = DataArrayInt([ 1, 2, 3, 2, 3, 3 ])
+
+        sla0 = MEDCouplingSkyLineArray()
+        self.assertEqual( -1, sla0.getNumberOf() )
+        self.assertEqual( 0,  sla0.getLength() )
+        sla0.set( index, value )
+        self.assertTrue( index.isEqual( sla0.getIndexArray() ))
+        self.assertTrue( value.isEqual( sla0.getValueArray() ))
+        self.assertEqual( 4, sla0.getNumberOf() )
+        self.assertEqual( 6, sla0.getLength() )
+
+        sla1 = MEDCouplingSkyLineArray( index, value )
+        self.assertTrue( index.isEqual( sla1.getIndexArray() ))
+        self.assertTrue( value.isEqual( sla1.getValueArray() ))
+        self.assertEqual( 4, sla1.getNumberOf() )
+        self.assertEqual( 6, sla1.getLength() )
+
+        sla2 = MEDCouplingSkyLineArray( sla1 )
+        self.assertTrue( index.isEqual( sla2.getIndexArray() ))
+        self.assertTrue( value.isEqual( sla2.getValueArray() ))
+        self.assertEqual( 4, sla2.getNumberOf() )
+        self.assertEqual( 6, sla2.getLength() )
+        pass
+
     pass
 
 if __name__ == '__main__':
index 74ef456facc664ee5778bf777a3d6dcbee1ad422..0ec663c78f6f0e7b2590d04a422eb66f0b283d28 100644 (file)
@@ -1143,13 +1143,16 @@ namespace ParaMEDMEM
   class MEDCouplingSkyLineArray
   {
   public:
-    MEDCouplingSkyLineArray() throw(INTERP_KERNEL::Exception);
-    MEDCouplingSkyLineArray( const MEDCouplingSkyLineArray &myArray ) throw(INTERP_KERNEL::Exception);
-    MEDCouplingSkyLineArray( const MEDCouplingAutoRefCountObjectPtr<DataArrayInt>& index, const MEDCouplingAutoRefCountObjectPtr<DataArrayInt>& value ) throw(INTERP_KERNEL::Exception);
-    ~MEDCouplingSkyLineArray() throw(INTERP_KERNEL::Exception);
+    MEDCouplingSkyLineArray();
+    MEDCouplingSkyLineArray( const MEDCouplingSkyLineArray &myArray );
+    MEDCouplingSkyLineArray( DataArrayInt* index, DataArrayInt* value );
+    MEDCouplingSkyLineArray( const std::vector<int>& index, const std::vector<int>& value );
   
-    int getNumberOf() const throw(INTERP_KERNEL::Exception);
-    int getLength() const throw(INTERP_KERNEL::Exception);
+    void set( DataArrayInt* index, DataArrayInt* value );
+    int getNumberOf() const;
+    int getLength() const;
+    DataArrayInt* getIndexArray() const;
+    DataArrayInt* getValueArray() const;
   };
 }
 
index bacd07422f3efd60c11dfb3eeb0895a5fb9a954b..dfa62dc918a030332424b91f187efca3d5a36e29 100644 (file)
@@ -4267,21 +4267,6 @@ class MEDLoaderTest(unittest.TestCase):
         self.assertTrue( jointR2.isEqual( two_joint ))
         pass
 
-    def testMEDFileJoint3(self):
-        # fileNameRd="splitted_blade1.med"
-        # fileNameWr="Pyfile90.med"
-        # coo=DataArrayDouble([(0,0,0),(1,0,0),(2,0,0)])
-        # coo.setInfoOnComponents(["x [cm]","y [cm]","z [cm]"])
-        # mm=MEDFileUMesh()
-        # mm.setCoords(coo)
-        # mm.setName("Fuse_1_1")
-        # mm.setDescription("un maillage")
-        # mm.write(fileNameWr,2)
-        # joints=MEDFileJoints(fileNameRd,mm.getName())
-        # joints.write(fileNameWr,0)
-        #mm=MEDFileMesh.New(fileNameWr)
-        #self.assertEqual(mm.getName(),"maa1")
-        pass
     pass
 
 unittest.main()
index bfc02aa66b7de4f1e4df519a202c7b976ce82559..d4dbaa2c5011b33a982a027ca30f47263dce4197 100644 (file)
@@ -1095,8 +1095,8 @@ void MEDPARTITIONER::MeshCollection::buildConnectZones( const NodeMapping& nodeM
 
       // separate ids of two domains
       const ParaMEDMEM::MEDCouplingSkyLineArray *corrArray = cz->getEntityCorresp( 0, 0 );
-      MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids12 = corrArray->getValueArray();
-      MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids1, ids2;
+      const DataArrayInt* ids12 = corrArray->getValueArray();
+      MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids1, ids2, ids12Sorted;
       ids1 = ids12->selectByTupleId2( 0, corrArray->getLength()+1, 2 );
       ids2 = ids12->selectByTupleId2( 1, corrArray->getLength()+1, 2 );
 
@@ -1116,15 +1116,15 @@ void MEDPARTITIONER::MeshCollection::buildConnectZones( const NodeMapping& nodeM
 
       if ( types1.size() == 1 && types2.size() == 1 ) // split not needed, only sort
         {
-          ids12 = sortCorrespondences( ids1, ids2 );
+          ids12Sorted = sortCorrespondences( ids1, ids2 );
           cz->setEntityCorresp( *types1.begin(), *types2.begin(),
-                                ids12->begin(), ids12->getNbOfElems() / 2 );
+                                ids12Sorted->begin(), ids12Sorted->getNbOfElems() / 2 );
 
           if ( cz21 )// set 2->1 correspondence
           {
-            ids12 = sortCorrespondences( ids2, ids1 );
+            ids12Sorted = sortCorrespondences( ids2, ids1 );
             cz21->setEntityCorresp( *types2.begin(), *types1.begin(),
-                                    ids12->begin(), ids12->getNbOfElems() / 2 );
+                                    ids12Sorted->begin(), ids12Sorted->getNbOfElems() / 2 );
           }
         }
       else // split and sort
@@ -1156,14 +1156,16 @@ void MEDPARTITIONER::MeshCollection::buildConnectZones( const NodeMapping& nodeM
                 ids1->pushBackValsSilent( p1, p1+ids.first.size() );
                 ids2->desallocate();
                 ids2->pushBackValsSilent( p2, p2+ids.first.size() );
-                ids12 = sortCorrespondences( ids1, ids2 );
+                ids12Sorted = sortCorrespondences( ids1, ids2 );
 
-                cz->setEntityCorresp( t1, t2, ids12->begin(), ids12->getNbOfElems() / 2 );
+                cz->setEntityCorresp( t1, t2,
+                                      ids12Sorted->begin(), ids12Sorted->getNbOfElems() / 2 );
 
                 if ( cz21 )// set 2->1 correspondence
                   {
-                    ids12 = sortCorrespondences( ids2, ids1 );
-                    cz21->setEntityCorresp( t2, t1, ids12->begin(), ids12->getNbOfElems() / 2 );
+                    ids12Sorted = sortCorrespondences( ids2, ids1 );
+                    cz21->setEntityCorresp( t2, t1,
+                                            ids12Sorted->begin(), ids12Sorted->getNbOfElems() / 2 );
                     break;
                   }
               }
@@ -1199,18 +1201,18 @@ void MEDPARTITIONER::MeshCollection::buildConnectZones( const NodeMapping& nodeM
 
       // separate ids of two domains
       const ParaMEDMEM::MEDCouplingSkyLineArray *corrArray = cz->getNodeCorresp();
-      MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids12 = corrArray->getValueArray();
-      MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids1, ids2;
+      const DataArrayInt *ids12 = corrArray->getValueArray();
+      MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids1, ids2, ids12Sorted;
       ids1 = ids12->selectByTupleId2( 0, corrArray->getLength()+1, 2 );
       ids2 = ids12->selectByTupleId2( 1, corrArray->getLength()+1, 2 );
 
-      ids12 = sortCorrespondences( ids1, ids2, removeEqual );
-      cz->setNodeCorresp( ids12->begin(), ids12->getNbOfElems() / 2 );
+      ids12Sorted = sortCorrespondences( ids1, ids2, removeEqual );
+      cz->setNodeCorresp( ids12Sorted->begin(), ids12Sorted->getNbOfElems() / 2 );
 
       if ( cz21 )// set 2->1 correspondence
         {
-          ids12 = sortCorrespondences( ids2, ids1, false );
-          cz->setNodeCorresp( ids12->begin(), ids12->getNbOfElems() / 2 );
+          ids12Sorted = sortCorrespondences( ids2, ids1, false );
+          cz->setNodeCorresp( ids12Sorted->begin(), ids12Sorted->getNbOfElems() / 2 );
         }
     }
 }