From f24e2afa61732b9ebbfea98cbf343cf084f679ad Mon Sep 17 00:00:00 2001 From: ageay Date: Fri, 1 Jul 2011 11:06:24 +0000 Subject: [PATCH] *** empty log message *** --- src/MEDCoupling/MEDCouplingCMesh.cxx | 5 +- src/MEDCoupling/MEDCouplingCMesh.hxx | 2 +- src/MEDCoupling/MEDCouplingExtrudedMesh.cxx | 2 +- src/MEDCoupling/MEDCouplingExtrudedMesh.hxx | 2 +- src/MEDCoupling/MEDCouplingMesh.hxx | 2 +- src/MEDCoupling/MEDCouplingUMesh.cxx | 25 ++++-- src/MEDCoupling/MEDCouplingUMesh.hxx | 2 +- src/MEDCoupling/MEDCouplingUMeshDesc.cxx | 2 +- src/MEDCoupling/MEDCouplingUMeshDesc.hxx | 2 +- .../Test/MEDCouplingBasicsTest4.cxx | 65 +++++++++++---- src/MEDCoupling_Swig/MEDCoupling.i | 22 +++-- src/MEDCoupling_Swig/MEDCouplingBasicsTest.py | 82 +++++++++++++++---- 12 files changed, 155 insertions(+), 58 deletions(-) diff --git a/src/MEDCoupling/MEDCouplingCMesh.cxx b/src/MEDCoupling/MEDCouplingCMesh.cxx index 6e564d28d..d7a5a98a2 100644 --- a/src/MEDCoupling/MEDCouplingCMesh.cxx +++ b/src/MEDCoupling/MEDCouplingCMesh.cxx @@ -537,15 +537,16 @@ DataArrayInt *MEDCouplingCMesh::checkTypeConsistencyAndContig(const std::vector< /*! * See MEDCouplingUMesh::splitProfilePerType for more information */ -void MEDCouplingCMesh::splitProfilePerType(const DataArrayInt *profile, std::vector& code, std::vector& globIdsPerType, std::vector& idsPerType) const throw(INTERP_KERNEL::Exception) +void MEDCouplingCMesh::splitProfilePerType(const DataArrayInt *profile, std::vector& code, std::vector& idsInPflPerType, std::vector& globalIdsPerType, std::vector& idsPerType) const throw(INTERP_KERNEL::Exception) { int nbCells=getNumberOfCells(); code.resize(3); code[0]=(int)getTypeOfCell(0); code[1]=nbCells; code[2]=0; + idsInPflPerType.push_back(profile->deepCpy()); idsPerType.push_back(profile->deepCpy()); - globIdsPerType.push_back(profile->deepCpy()); + globalIdsPerType.push_back(profile->deepCpy()); } MEDCouplingUMesh *MEDCouplingCMesh::buildUnstructured() const throw(INTERP_KERNEL::Exception) diff --git a/src/MEDCoupling/MEDCouplingCMesh.hxx b/src/MEDCoupling/MEDCouplingCMesh.hxx index 45d81d1a0..f3e95b246 100644 --- a/src/MEDCoupling/MEDCouplingCMesh.hxx +++ b/src/MEDCoupling/MEDCouplingCMesh.hxx @@ -68,7 +68,7 @@ namespace ParaMEDMEM const DataArrayDouble *coordsZ=0); // tools DataArrayInt *checkTypeConsistencyAndContig(const std::vector& code, const std::vector& idsPerType) const throw(INTERP_KERNEL::Exception); - void splitProfilePerType(const DataArrayInt *profile, std::vector& code, std::vector& globIdsPerType, std::vector& idsPerType) const throw(INTERP_KERNEL::Exception); + void splitProfilePerType(const DataArrayInt *profile, std::vector& code, std::vector& idsInPflPerType, std::vector& globalIdsPerType, std::vector& idsPerType) const throw(INTERP_KERNEL::Exception); MEDCouplingUMesh *buildUnstructured() const throw(INTERP_KERNEL::Exception); MEDCouplingMesh *buildPart(const int *start, const int *end) const; MEDCouplingMesh *buildPartAndReduceNodes(const int *start, const int *end, DataArrayInt*& arr) const; diff --git a/src/MEDCoupling/MEDCouplingExtrudedMesh.cxx b/src/MEDCoupling/MEDCouplingExtrudedMesh.cxx index 8ecb61a38..44c92b67e 100644 --- a/src/MEDCoupling/MEDCouplingExtrudedMesh.cxx +++ b/src/MEDCoupling/MEDCouplingExtrudedMesh.cxx @@ -606,7 +606,7 @@ DataArrayInt *MEDCouplingExtrudedMesh::checkTypeConsistencyAndContig(const std:: throw INTERP_KERNEL::Exception("Not implemented yet !"); } -void MEDCouplingExtrudedMesh::splitProfilePerType(const DataArrayInt *profile, std::vector& code, std::vector& globIdsPerType, std::vector& idsPerType) const throw(INTERP_KERNEL::Exception) +void MEDCouplingExtrudedMesh::splitProfilePerType(const DataArrayInt *profile, std::vector& code, std::vector& idsInPflPerType, std::vector& globalIdsPerType, std::vector& idsPerType) const throw(INTERP_KERNEL::Exception) { throw INTERP_KERNEL::Exception("Not implemented yet !"); } diff --git a/src/MEDCoupling/MEDCouplingExtrudedMesh.hxx b/src/MEDCoupling/MEDCouplingExtrudedMesh.hxx index 692f813a5..b625bcc2c 100644 --- a/src/MEDCoupling/MEDCouplingExtrudedMesh.hxx +++ b/src/MEDCoupling/MEDCouplingExtrudedMesh.hxx @@ -81,7 +81,7 @@ namespace ParaMEDMEM void translate(const double *vector); void scale(const double *point, double factor); DataArrayInt *checkTypeConsistencyAndContig(const std::vector& code, const std::vector& idsPerType) const throw(INTERP_KERNEL::Exception); - void splitProfilePerType(const DataArrayInt *profile, std::vector& code, std::vector& globIdsPerType, std::vector& idsPerType) const throw(INTERP_KERNEL::Exception); + void splitProfilePerType(const DataArrayInt *profile, std::vector& code, std::vector& idsInPflPerType, std::vector& globalIdsPerType, std::vector& idsPerType) const throw(INTERP_KERNEL::Exception); MEDCouplingMesh *buildPart(const int *start, const int *end) const; MEDCouplingMesh *buildPartAndReduceNodes(const int *start, const int *end, DataArrayInt*& arr) const; DataArrayInt *simplexize(int policy) throw(INTERP_KERNEL::Exception); diff --git a/src/MEDCoupling/MEDCouplingMesh.hxx b/src/MEDCoupling/MEDCouplingMesh.hxx index 283d5fc39..35ac63006 100644 --- a/src/MEDCoupling/MEDCouplingMesh.hxx +++ b/src/MEDCoupling/MEDCouplingMesh.hxx @@ -90,7 +90,7 @@ namespace ParaMEDMEM virtual std::string advancedRepr() const = 0; // tools virtual DataArrayInt *checkTypeConsistencyAndContig(const std::vector& code, const std::vector& idsPerType) const throw(INTERP_KERNEL::Exception) = 0; - virtual void splitProfilePerType(const DataArrayInt *profile, std::vector& code, std::vector& globIdsPerType, std::vector& idsPerType) const throw(INTERP_KERNEL::Exception) = 0; + virtual void splitProfilePerType(const DataArrayInt *profile, std::vector& code, std::vector& idsInPflPerType, std::vector& globalIdsPerType, std::vector& idsPerType) const throw(INTERP_KERNEL::Exception) = 0; virtual void getBoundingBox(double *bbox) const = 0; virtual MEDCouplingFieldDouble *getMeasureField(bool isAbs) const = 0; virtual MEDCouplingFieldDouble *getMeasureFieldOnNode(bool isAbs) const = 0; diff --git a/src/MEDCoupling/MEDCouplingUMesh.cxx b/src/MEDCoupling/MEDCouplingUMesh.cxx index 307e376c3..f91c0fec4 100644 --- a/src/MEDCoupling/MEDCouplingUMesh.cxx +++ b/src/MEDCoupling/MEDCouplingUMesh.cxx @@ -3421,7 +3421,7 @@ DataArrayInt *MEDCouplingUMesh::checkTypeConsistencyAndContig(const std::vector< * This method has 1 input 'profile' and 2 outputs 'code' and 'idsPerType'. * @throw if 'profile' has not exactly one component. It throws too, if 'profile' contains some values not in [0,getNumberOfCells()) or if 'this' is not fully defined */ -void MEDCouplingUMesh::splitProfilePerType(const DataArrayInt *profile, std::vector& code, std::vector& globIdsPerType, std::vector& idsPerType) const throw(INTERP_KERNEL::Exception) +void MEDCouplingUMesh::splitProfilePerType(const DataArrayInt *profile, std::vector& code, std::vector& idsInPflPerType, std::vector& globalIdsPerType, std::vector& idsPerType) const throw(INTERP_KERNEL::Exception) { if(profile->getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::splitProfilePerType : input profile should have exactly one component !"); @@ -3451,13 +3451,16 @@ void MEDCouplingUMesh::splitProfilePerType(const DataArrayInt *profile, std::vec // int nbOfCastsFinal=castsPresent->getNumberOfTuples(); code.resize(3*nbOfCastsFinal); - std::vector< MEDCouplingAutoRefCountObjectPtr > globIdsPerType2; + std::vector< MEDCouplingAutoRefCountObjectPtr > idsInPflPerType2; + std::vector< MEDCouplingAutoRefCountObjectPtr > globalIdsPerType2; std::vector< MEDCouplingAutoRefCountObjectPtr > idsPerType2; for(int i=0;igetIJ(i,0); MEDCouplingAutoRefCountObjectPtr tmp3=castArr->getIdsEqual(castId); - globIdsPerType2.push_back(tmp3); + idsInPflPerType2.push_back(tmp3); + MEDCouplingAutoRefCountObjectPtr tmp5=profile->selectByTupleId(tmp3->getConstPointer(),tmp3->getConstPointer()+tmp3->getNumberOfTuples()); + globalIdsPerType2.push_back(tmp5); code[3*i]=(int)types[castId]; code[3*i+1]=tmp3->getNumberOfTuples(); MEDCouplingAutoRefCountObjectPtr tmp4=rankInsideCast->selectByTupleId(tmp3->getConstPointer(),tmp3->getConstPointer()+tmp3->getNumberOfTuples()); @@ -3472,13 +3475,21 @@ void MEDCouplingUMesh::splitProfilePerType(const DataArrayInt *profile, std::vec code[3*i+2]=-1; } } - int sz2=globIdsPerType2.size(); - globIdsPerType.resize(sz2); + int sz2=idsInPflPerType2.size(); + idsInPflPerType.resize(sz2); for(int i=0;iincrRef(); - globIdsPerType[i]=locDa; + idsInPflPerType[i]=locDa; + } + int sz3=globalIdsPerType2.size(); + globalIdsPerType.resize(sz2); + for(int i=0;iincrRef(); + globalIdsPerType[i]=locDa; } int sz=idsPerType2.size(); idsPerType.resize(sz); diff --git a/src/MEDCoupling/MEDCouplingUMesh.hxx b/src/MEDCoupling/MEDCouplingUMesh.hxx index 8aaa744f6..dc16ec63f 100644 --- a/src/MEDCoupling/MEDCouplingUMesh.hxx +++ b/src/MEDCoupling/MEDCouplingUMesh.hxx @@ -140,7 +140,7 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getSkewField() const throw(INTERP_KERNEL::Exception); //utilities for MED File RW MEDCOUPLING_EXPORT DataArrayInt *checkTypeConsistencyAndContig(const std::vector& code, const std::vector& idsPerType) const throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT void splitProfilePerType(const DataArrayInt *profile, std::vector& code, std::vector& globIdsPerType, std::vector& idsPerType) const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT void splitProfilePerType(const DataArrayInt *profile, std::vector& code, std::vector& idsInPflPerType, std::vector& globalIdsPerType, std::vector& idsPerType) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT MEDCouplingUMesh *emulateMEDMEMBDC(const MEDCouplingUMesh *nM1LevMesh, DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *&revDesc, DataArrayInt *&revDescIndx, DataArrayInt *& nM1LevMeshIds, DataArrayInt *&meshnM1Old2New) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT DataArrayInt *sortCellsInMEDFileFrmt() throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT bool checkConsecutiveCellTypes() const; diff --git a/src/MEDCoupling/MEDCouplingUMeshDesc.cxx b/src/MEDCoupling/MEDCouplingUMeshDesc.cxx index 1942ca1bc..8d73cc45a 100644 --- a/src/MEDCoupling/MEDCouplingUMeshDesc.cxx +++ b/src/MEDCoupling/MEDCouplingUMeshDesc.cxx @@ -194,7 +194,7 @@ DataArrayInt *MEDCouplingUMeshDesc::checkTypeConsistencyAndContig(const std::vec throw INTERP_KERNEL::Exception("Not implemented yet !"); } -void MEDCouplingUMeshDesc::splitProfilePerType(const DataArrayInt *profile, std::vector& code, std::vector& globIdsPerType, std::vector& idsPerType) const throw(INTERP_KERNEL::Exception) +void MEDCouplingUMeshDesc::splitProfilePerType(const DataArrayInt *profile, std::vector& code, std::vector& idsInPflPerType, std::vector& globalIdsPerType, std::vector& idsPerType) const throw(INTERP_KERNEL::Exception) { throw INTERP_KERNEL::Exception("Not implemented yet !"); } diff --git a/src/MEDCoupling/MEDCouplingUMeshDesc.hxx b/src/MEDCoupling/MEDCouplingUMeshDesc.hxx index 7a7aeaee6..3e5f77643 100644 --- a/src/MEDCoupling/MEDCouplingUMeshDesc.hxx +++ b/src/MEDCoupling/MEDCouplingUMeshDesc.hxx @@ -58,7 +58,7 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT void setConnectivity(DataArrayInt *descConn, DataArrayInt *descConnIndex, DataArrayInt *nodalFaceConn, DataArrayInt *nodalFaceConnIndx); //tools to overload MEDCOUPLING_EXPORT DataArrayInt *checkTypeConsistencyAndContig(const std::vector& code, const std::vector& idsPerType) const throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT void splitProfilePerType(const DataArrayInt *profile, std::vector& code, std::vector& globIdsPerType, std::vector& idsPerType) const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT void splitProfilePerType(const DataArrayInt *profile, std::vector& code, std::vector& idsInPflPerType, std::vector& globalIdsPerType, std::vector& idsPerType) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void getTinySerializationInformation(std::vector& tinyInfoD, std::vector& tinyInfo, std::vector& littleStrings) const; MEDCOUPLING_EXPORT bool isEmptyMesh(const std::vector& tinyInfo) const; MEDCOUPLING_EXPORT void resizeForUnserialization(const std::vector& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector& littleStrings) const; diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest4.cxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest4.cxx index b7d2ce94f..5ff36cba3 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest4.cxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest4.cxx @@ -1313,6 +1313,7 @@ void MEDCouplingBasicsTest::testUMeshSplitProfilePerType1() MEDCouplingUMesh *m=build2DTargetMesh_1(); m->renumberCells(val0,false); std::vector code; + std::vector idsInPflPerType; std::vector globIdsPerType; std::vector pfls; // @@ -1321,17 +1322,24 @@ void MEDCouplingBasicsTest::testUMeshSplitProfilePerType1() d->alloc(3,1); d->setName("sup"); std::copy(val1,val1+3,d->getPointer()); - m->splitProfilePerType(d,code,globIdsPerType,pfls); + m->splitProfilePerType(d,code,idsInPflPerType,globIdsPerType,pfls); CPPUNIT_ASSERT_EQUAL(6,(int)code.size()); - CPPUNIT_ASSERT_EQUAL(2,(int)globIdsPerType.size()); + CPPUNIT_ASSERT_EQUAL(2,(int)idsInPflPerType.size()); const int expected1[6]={3,1,0, 4,2,1}; for(int i=0;i<6;i++) CPPUNIT_ASSERT_EQUAL(expected1[i],code[i]); + CPPUNIT_ASSERT_EQUAL(1,idsInPflPerType[0]->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(0,idsInPflPerType[0]->getIJ(0,0)); + CPPUNIT_ASSERT_EQUAL(2,idsInPflPerType[1]->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(1,idsInPflPerType[1]->getIJ(0,0)); + CPPUNIT_ASSERT_EQUAL(2,idsInPflPerType[1]->getIJ(1,0)); + idsInPflPerType[0]->decrRef(); + idsInPflPerType[1]->decrRef(); CPPUNIT_ASSERT_EQUAL(1,globIdsPerType[0]->getNumberOfTuples()); CPPUNIT_ASSERT_EQUAL(0,globIdsPerType[0]->getIJ(0,0)); CPPUNIT_ASSERT_EQUAL(2,globIdsPerType[1]->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,globIdsPerType[1]->getIJ(0,0)); - CPPUNIT_ASSERT_EQUAL(2,globIdsPerType[1]->getIJ(1,0)); + CPPUNIT_ASSERT_EQUAL(2,globIdsPerType[1]->getIJ(0,0)); + CPPUNIT_ASSERT_EQUAL(3,globIdsPerType[1]->getIJ(1,0)); globIdsPerType[0]->decrRef(); globIdsPerType[1]->decrRef(); CPPUNIT_ASSERT_EQUAL(2,(int)pfls.size()); @@ -1345,6 +1353,7 @@ void MEDCouplingBasicsTest::testUMeshSplitProfilePerType1() pfls[0]->decrRef(); pfls[1]->decrRef(); d->decrRef(); + idsInPflPerType.clear(); globIdsPerType.clear(); pfls.clear(); code.clear(); @@ -1353,18 +1362,26 @@ void MEDCouplingBasicsTest::testUMeshSplitProfilePerType1() d=DataArrayInt::New(); d->alloc(4,1); std::copy(val2,val2+4,d->getPointer()); - m->splitProfilePerType(d,code,globIdsPerType,pfls); + m->splitProfilePerType(d,code,idsInPflPerType,globIdsPerType,pfls); CPPUNIT_ASSERT_EQUAL(6,(int)code.size()); - CPPUNIT_ASSERT_EQUAL(2,(int)globIdsPerType.size()); + CPPUNIT_ASSERT_EQUAL(2,(int)idsInPflPerType.size()); const int expected2[6]={3,1,0, 4,3,-1}; for(int i=0;i<6;i++) CPPUNIT_ASSERT_EQUAL(expected2[i],code[i]); + CPPUNIT_ASSERT_EQUAL(1,idsInPflPerType[0]->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(0,idsInPflPerType[0]->getIJ(0,0)); + CPPUNIT_ASSERT_EQUAL(3,idsInPflPerType[1]->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(1,idsInPflPerType[1]->getIJ(0,0)); + CPPUNIT_ASSERT_EQUAL(2,idsInPflPerType[1]->getIJ(1,0)); + CPPUNIT_ASSERT_EQUAL(3,idsInPflPerType[1]->getIJ(2,0)); + idsInPflPerType[0]->decrRef(); + idsInPflPerType[1]->decrRef(); CPPUNIT_ASSERT_EQUAL(1,globIdsPerType[0]->getNumberOfTuples()); CPPUNIT_ASSERT_EQUAL(0,globIdsPerType[0]->getIJ(0,0)); CPPUNIT_ASSERT_EQUAL(3,globIdsPerType[1]->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,globIdsPerType[1]->getIJ(0,0)); - CPPUNIT_ASSERT_EQUAL(2,globIdsPerType[1]->getIJ(1,0)); - CPPUNIT_ASSERT_EQUAL(3,globIdsPerType[1]->getIJ(2,0)); + CPPUNIT_ASSERT_EQUAL(2,globIdsPerType[1]->getIJ(0,0)); + CPPUNIT_ASSERT_EQUAL(3,globIdsPerType[1]->getIJ(1,0)); + CPPUNIT_ASSERT_EQUAL(4,globIdsPerType[1]->getIJ(2,0)); globIdsPerType[0]->decrRef(); globIdsPerType[1]->decrRef(); CPPUNIT_ASSERT_EQUAL(1,(int)pfls.size()); @@ -1372,6 +1389,7 @@ void MEDCouplingBasicsTest::testUMeshSplitProfilePerType1() CPPUNIT_ASSERT_EQUAL(0,pfls[0]->getIJ(0,0)); pfls[0]->decrRef(); d->decrRef(); + idsInPflPerType.clear(); globIdsPerType.clear(); pfls.clear(); code.clear(); @@ -1380,15 +1398,22 @@ void MEDCouplingBasicsTest::testUMeshSplitProfilePerType1() d=DataArrayInt::New(); d->alloc(3,1); std::copy(val3,val3+3,d->getPointer()); - m->splitProfilePerType(d,code,globIdsPerType,pfls); + m->splitProfilePerType(d,code,idsInPflPerType,globIdsPerType,pfls); CPPUNIT_ASSERT_EQUAL(6,(int)code.size()); - CPPUNIT_ASSERT_EQUAL(2,(int)globIdsPerType.size()); + CPPUNIT_ASSERT_EQUAL(2,(int)idsInPflPerType.size()); const int expected3[6]={3,2,0, 4,1,1}; for(int i=0;i<6;i++) CPPUNIT_ASSERT_EQUAL(expected3[i],code[i]); + CPPUNIT_ASSERT_EQUAL(2,idsInPflPerType[0]->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(0,idsInPflPerType[0]->getIJ(0,0)); + CPPUNIT_ASSERT_EQUAL(1,idsInPflPerType[0]->getIJ(1,0)); + CPPUNIT_ASSERT_EQUAL(1,idsInPflPerType[1]->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(2,idsInPflPerType[1]->getIJ(0,0)); + idsInPflPerType[0]->decrRef(); + idsInPflPerType[1]->decrRef(); CPPUNIT_ASSERT_EQUAL(2,globIdsPerType[0]->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(0,globIdsPerType[0]->getIJ(0,0)); - CPPUNIT_ASSERT_EQUAL(1,globIdsPerType[0]->getIJ(1,0)); + CPPUNIT_ASSERT_EQUAL(1,globIdsPerType[0]->getIJ(0,0)); + CPPUNIT_ASSERT_EQUAL(0,globIdsPerType[0]->getIJ(1,0)); CPPUNIT_ASSERT_EQUAL(1,globIdsPerType[1]->getNumberOfTuples()); CPPUNIT_ASSERT_EQUAL(2,globIdsPerType[1]->getIJ(0,0)); globIdsPerType[0]->decrRef(); @@ -1401,6 +1426,7 @@ void MEDCouplingBasicsTest::testUMeshSplitProfilePerType1() pfls[0]->decrRef(); pfls[1]->decrRef(); d->decrRef(); + idsInPflPerType.clear(); globIdsPerType.clear(); pfls.clear(); code.clear(); @@ -1409,15 +1435,19 @@ void MEDCouplingBasicsTest::testUMeshSplitProfilePerType1() d=DataArrayInt::New(); d->alloc(2,1); std::copy(val4,val4+2,d->getPointer()); - m->splitProfilePerType(d,code,globIdsPerType,pfls); + m->splitProfilePerType(d,code,idsInPflPerType,globIdsPerType,pfls); CPPUNIT_ASSERT_EQUAL(3,(int)code.size()); - CPPUNIT_ASSERT_EQUAL(1,(int)globIdsPerType.size()); + CPPUNIT_ASSERT_EQUAL(1,(int)idsInPflPerType.size()); const int expected4[3]={4,2,0}; for(int i=0;i<3;i++) CPPUNIT_ASSERT_EQUAL(expected4[i],code[i]); + CPPUNIT_ASSERT_EQUAL(2,idsInPflPerType[0]->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(0,idsInPflPerType[0]->getIJ(0,0)); + CPPUNIT_ASSERT_EQUAL(1,idsInPflPerType[0]->getIJ(1,0)); + idsInPflPerType[0]->decrRef(); CPPUNIT_ASSERT_EQUAL(2,globIdsPerType[0]->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(0,globIdsPerType[0]->getIJ(0,0)); - CPPUNIT_ASSERT_EQUAL(1,globIdsPerType[0]->getIJ(1,0)); + CPPUNIT_ASSERT_EQUAL(3,globIdsPerType[0]->getIJ(0,0)); + CPPUNIT_ASSERT_EQUAL(4,globIdsPerType[0]->getIJ(1,0)); globIdsPerType[0]->decrRef(); CPPUNIT_ASSERT_EQUAL(1,(int)pfls.size()); CPPUNIT_ASSERT_EQUAL(2,pfls[0]->getNumberOfTuples()); @@ -1425,6 +1455,7 @@ void MEDCouplingBasicsTest::testUMeshSplitProfilePerType1() CPPUNIT_ASSERT_EQUAL(2,pfls[0]->getIJ(1,0)); pfls[0]->decrRef(); d->decrRef(); + idsInPflPerType.clear(); globIdsPerType.clear(); pfls.clear(); code.clear(); diff --git a/src/MEDCoupling_Swig/MEDCoupling.i b/src/MEDCoupling_Swig/MEDCoupling.i index e6e37f2cd..81b252332 100644 --- a/src/MEDCoupling_Swig/MEDCoupling.i +++ b/src/MEDCoupling_Swig/MEDCoupling.i @@ -149,6 +149,7 @@ using namespace INTERP_KERNEL; %newobject ParaMEDMEM::DataArrayInt::buildSubstraction; %newobject ParaMEDMEM::DataArrayInt::buildIntersection; %newobject ParaMEDMEM::DataArrayInt::deltaShiftIndex; +%newobject ParaMEDMEM::DataArrayInt::buildExplicitArrByRanges; %newobject ParaMEDMEM::DataArrayInt::buildPermutationArr; %newobject ParaMEDMEM::DataArrayInt::buildPermArrPerLevel; %newobject ParaMEDMEM::DataArrayInt::__getitem__; @@ -568,20 +569,25 @@ namespace ParaMEDMEM PyObject *splitProfilePerType(const DataArrayInt *profile) const throw(INTERP_KERNEL::Exception) { std::vector code; + std::vector idsInPflPerType; std::vector globIdsPerType; std::vector idsPerType; - self->splitProfilePerType(profile,code,globIdsPerType,idsPerType); - PyObject *ret=PyTuple_New(3); + self->splitProfilePerType(profile,code,idsInPflPerType,globIdsPerType,idsPerType); + PyObject *ret=PyTuple_New(4); PyTuple_SetItem(ret,0,convertIntArrToPyList2(code)); - PyObject *ret1=PyList_New(globIdsPerType.size()); - for(std::size_t j=0;j