From: eap Date: Mon, 25 May 2015 18:33:47 +0000 (+0300) Subject: 0022875: test MEDCouplingSkyLineArray X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c99c981a5cb641ab17664cbca9517098a1ccf50c;p=tools%2Fmedcoupling.git 0022875: test MEDCouplingSkyLineArray --- diff --git a/src/MEDCoupling/MEDCouplingSkyLineArray.cxx b/src/MEDCoupling/MEDCouplingSkyLineArray.cxx index 518bda8a1..9719cb04d 100644 --- a/src/MEDCoupling/MEDCouplingSkyLineArray.cxx +++ b/src/MEDCoupling/MEDCouplingSkyLineArray.cxx @@ -36,10 +36,9 @@ MEDCouplingSkyLineArray::~MEDCouplingSkyLineArray() { } -MEDCouplingSkyLineArray::MEDCouplingSkyLineArray(const MEDCouplingAutoRefCountObjectPtr& index, const MEDCouplingAutoRefCountObjectPtr& value) +MEDCouplingSkyLineArray::MEDCouplingSkyLineArray(DataArrayInt* index, DataArrayInt* value) { - _index=index; - _value=value; + set( index, value ); } MEDCouplingSkyLineArray::MEDCouplingSkyLineArray( const std::vector& index, @@ -49,3 +48,23 @@ MEDCouplingSkyLineArray::MEDCouplingSkyLineArray( const std::vector& 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; +} diff --git a/src/MEDCoupling/MEDCouplingSkyLineArray.hxx b/src/MEDCoupling/MEDCouplingSkyLineArray.hxx index 79264036f..06826f803 100644 --- a/src/MEDCoupling/MEDCouplingSkyLineArray.hxx +++ b/src/MEDCoupling/MEDCouplingSkyLineArray.hxx @@ -37,20 +37,18 @@ namespace ParaMEDMEM MEDCouplingSkyLineArray(); MEDCouplingSkyLineArray( const MEDCouplingSkyLineArray &myArray ); MEDCouplingSkyLineArray( const std::vector& index, const std::vector& value ); - MEDCouplingSkyLineArray( const MEDCouplingAutoRefCountObjectPtr& index, - const MEDCouplingAutoRefCountObjectPtr& value ); + MEDCouplingSkyLineArray( DataArrayInt* index, DataArrayInt* value ); ~MEDCouplingSkyLineArray(); - void set( const MEDCouplingAutoRefCountObjectPtr& index, - const MEDCouplingAutoRefCountObjectPtr& 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 getIndexArray() const { return _index; } - MEDCouplingAutoRefCountObjectPtr getValueArray() const { return _value; } + DataArrayInt* getIndexArray() const; + DataArrayInt* getValueArray() const; }; } # endif diff --git a/src/MEDCoupling/MEDCouplingUMesh.cxx b/src/MEDCoupling/MEDCouplingUMesh.cxx index 674d4182d..7d9e5426e 100644 --- a/src/MEDCoupling/MEDCouplingUMesh.cxx +++ b/src/MEDCoupling/MEDCouplingUMesh.cxx @@ -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" diff --git a/src/MEDCoupling/MEDCouplingUMesh.hxx b/src/MEDCoupling/MEDCouplingUMesh.hxx index 16079ddf1..55bc28918 100644 --- a/src/MEDCoupling/MEDCouplingUMesh.hxx +++ b/src/MEDCoupling/MEDCouplingUMesh.hxx @@ -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 { diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py index c6bc0d7d0..775beac94 100644 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py @@ -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__': diff --git a/src/MEDCoupling_Swig/MEDCouplingCommon.i b/src/MEDCoupling_Swig/MEDCouplingCommon.i index 74ef456fa..0ec663c78 100644 --- a/src/MEDCoupling_Swig/MEDCouplingCommon.i +++ b/src/MEDCoupling_Swig/MEDCouplingCommon.i @@ -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& index, const MEDCouplingAutoRefCountObjectPtr& value ) throw(INTERP_KERNEL::Exception); - ~MEDCouplingSkyLineArray() throw(INTERP_KERNEL::Exception); + MEDCouplingSkyLineArray(); + MEDCouplingSkyLineArray( const MEDCouplingSkyLineArray &myArray ); + MEDCouplingSkyLineArray( DataArrayInt* index, DataArrayInt* value ); + MEDCouplingSkyLineArray( const std::vector& index, const std::vector& 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; }; } diff --git a/src/MEDLoader/Swig/MEDLoaderTest3.py b/src/MEDLoader/Swig/MEDLoaderTest3.py index bacd07422..dfa62dc91 100644 --- a/src/MEDLoader/Swig/MEDLoaderTest3.py +++ b/src/MEDLoader/Swig/MEDLoaderTest3.py @@ -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() diff --git a/src/MEDPartitioner/MEDPARTITIONER_MeshCollection.cxx b/src/MEDPartitioner/MEDPARTITIONER_MeshCollection.cxx index bfc02aa66..d4dbaa2c5 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_MeshCollection.cxx +++ b/src/MEDPartitioner/MEDPARTITIONER_MeshCollection.cxx @@ -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 ids12 = corrArray->getValueArray(); - MEDCouplingAutoRefCountObjectPtr ids1, ids2; + const DataArrayInt* ids12 = corrArray->getValueArray(); + MEDCouplingAutoRefCountObjectPtr 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 ids12 = corrArray->getValueArray(); - MEDCouplingAutoRefCountObjectPtr ids1, ids2; + const DataArrayInt *ids12 = corrArray->getValueArray(); + MEDCouplingAutoRefCountObjectPtr 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 ); } } }