From 0c9b84f825ee72f107b7e5acd7641cc9f505fe3f Mon Sep 17 00:00:00 2001 From: ageay Date: Wed, 29 Jun 2011 10:39:18 +0000 Subject: [PATCH] *** empty log message *** --- src/MEDCoupling/MEDCouplingCMesh.cxx | 13 ++ src/MEDCoupling/MEDCouplingCMesh.hxx | 1 + src/MEDCoupling/MEDCouplingExtrudedMesh.cxx | 5 + src/MEDCoupling/MEDCouplingExtrudedMesh.hxx | 1 + src/MEDCoupling/MEDCouplingMemArray.cxx | 66 ++++++++++ src/MEDCoupling/MEDCouplingMemArray.hxx | 2 + src/MEDCoupling/MEDCouplingMesh.hxx | 1 + src/MEDCoupling/MEDCouplingUMesh.cxx | 66 +++++++++- src/MEDCoupling/MEDCouplingUMesh.hxx | 1 + src/MEDCoupling/MEDCouplingUMeshDesc.cxx | 5 + src/MEDCoupling/MEDCouplingUMeshDesc.hxx | 1 + .../Test/MEDCouplingBasicsTest.hxx | 4 + .../Test/MEDCouplingBasicsTest4.cxx | 123 ++++++++++++++++++ 13 files changed, 288 insertions(+), 1 deletion(-) diff --git a/src/MEDCoupling/MEDCouplingCMesh.cxx b/src/MEDCoupling/MEDCouplingCMesh.cxx index 14791e509..f60cd6015 100644 --- a/src/MEDCoupling/MEDCouplingCMesh.cxx +++ b/src/MEDCoupling/MEDCouplingCMesh.cxx @@ -534,6 +534,19 @@ DataArrayInt *MEDCouplingCMesh::checkTypeConsistencyAndContig(const std::vector< return 0; } +/*! + * See MEDCouplingUMesh::splitProfilePerType for more information + */ +void MEDCouplingCMesh::splitProfilePerType(const DataArrayInt *profile, std::vector& code, 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; + idsPerType.push_back(profile->deepCpy()); +} + MEDCouplingUMesh *MEDCouplingCMesh::buildUnstructured() const throw(INTERP_KERNEL::Exception) { int spaceDim=getSpaceDimension(); diff --git a/src/MEDCoupling/MEDCouplingCMesh.hxx b/src/MEDCoupling/MEDCouplingCMesh.hxx index 1864a9fb2..c18554e85 100644 --- a/src/MEDCoupling/MEDCouplingCMesh.hxx +++ b/src/MEDCoupling/MEDCouplingCMesh.hxx @@ -68,6 +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& 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 1615957cc..105577dbe 100644 --- a/src/MEDCoupling/MEDCouplingExtrudedMesh.cxx +++ b/src/MEDCoupling/MEDCouplingExtrudedMesh.cxx @@ -606,6 +606,11 @@ DataArrayInt *MEDCouplingExtrudedMesh::checkTypeConsistencyAndContig(const std:: throw INTERP_KERNEL::Exception("Not implemented yet !"); } +void MEDCouplingExtrudedMesh::splitProfilePerType(const DataArrayInt *profile, std::vector& code, std::vector& idsPerType) const throw(INTERP_KERNEL::Exception) +{ + throw INTERP_KERNEL::Exception("Not implemented yet !"); +} + MEDCouplingMesh *MEDCouplingExtrudedMesh::buildPart(const int *start, const int *end) const { // not implemented yet ! diff --git a/src/MEDCoupling/MEDCouplingExtrudedMesh.hxx b/src/MEDCoupling/MEDCouplingExtrudedMesh.hxx index 926ded6b4..65e08e7e3 100644 --- a/src/MEDCoupling/MEDCouplingExtrudedMesh.hxx +++ b/src/MEDCoupling/MEDCouplingExtrudedMesh.hxx @@ -81,6 +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& 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/MEDCouplingMemArray.cxx b/src/MEDCoupling/MEDCouplingMemArray.cxx index e9d9b6d8f..aba8e7a37 100644 --- a/src/MEDCoupling/MEDCouplingMemArray.cxx +++ b/src/MEDCoupling/MEDCouplingMemArray.cxx @@ -2165,6 +2165,72 @@ void DataArrayInt::transformWithIndArr(const int *indArrBg, const int *indArrEnd declareAsNew(); } +/*! + * 'this' should be allocated and with numberOfComponents set to one. If not an exception will be thrown. + * This method takes as input an array defined by ['arrBg','arrEnd'). The size of the array (std::distance(arrBg,arrEnd)) is equal to the number of cast + 1. + * The values contained in ['arrBg','arrEnd') should be sorted ascendently. No check of this will be done. If not the result is not waranted. + * For each cast j the value range that defines the cast is equal to [arrBg[j],arrBg[j+1]). + * This method returns three arrays (to be managed by the caller). + * This method is typically usefull for entity number spliting by types for example. + * Example : If 'this' contains [6,5,0,3,2,7,8,1,4] and if ['arrBg','arrEnd') contains [0,4,9] then the output of this method will be : + * - 'castArr' : [1,1,0,0,0,1,1,0,1] + * - 'rankInsideCast' : [2,1,0,3,2,3,4,1,0] + * - 'return' : [0,1] + * + * @param castArr is a returned param has the same number of tuples than 'this' and number of components set to one. In case of sucess, this param contains for each tuple in 'this' in which cast it holds. + * @param rankInsideCast is an another returned param has the same number of tuples than 'this' and number of components set to one too. In case of sucess, this param contains for each tuple its rank inside its cast. + * @param castsPresent the casts that 'this' contains. + * @throw if a value in 'this' is greater or equal to the last value of ['arrBg','arrEnd') + */ +void DataArrayInt::splitByValueRange(const int *arrBg, const int *arrEnd, + DataArrayInt *& castArr, DataArrayInt *& rankInsideCast, DataArrayInt *& castsPresent) const throw(INTERP_KERNEL::Exception) +{ + if(getNumberOfComponents()!=1) + throw INTERP_KERNEL::Exception("Call splitByValueRange method on DataArrayInt with only one component, you can call 'rearrange' method before !"); + int nbOfTuples=getNumberOfTuples(); + std::size_t nbOfCast=std::distance(arrBg,arrEnd); + if(nbOfCast<2) + throw INTERP_KERNEL::Exception("DataArrayInt::splitByValueRange : The input array giving the cast range values should be of size >=2 !"); + nbOfCast--; + const int *work=getConstPointer(); + typedef std::reverse_iterator rintstart; + rintstart bg(arrEnd);//OK no problem because size of 'arr' is greater of equal 2 + rintstart end(arrBg); + MEDCouplingAutoRefCountObjectPtr ret1=DataArrayInt::New(); + MEDCouplingAutoRefCountObjectPtr ret2=DataArrayInt::New(); + MEDCouplingAutoRefCountObjectPtr ret3=DataArrayInt::New(); + ret1->alloc(nbOfTuples,1); + ret2->alloc(nbOfTuples,1); + int *ret1Ptr=ret1->getPointer(); + int *ret2Ptr=ret2->getPointer(); + std::set castsDetected; + for(int i=0;i(), work[i])); + std::size_t pos=std::distance(bg,res); + std::size_t pos2=nbOfCast-pos; + if(pos2alloc((int)castsDetected.size(),1); + std::copy(castsDetected.begin(),castsDetected.end(),ret3->getPointer()); + ret1->incrRef(); + castArr=ret1; + ret2->incrRef(); + rankInsideCast=ret2; + ret3->incrRef(); + castsPresent=ret3; +} + DataArrayInt *DataArrayInt::transformWithIndArrR(const int *indArrBg, const int *indArrEnd) const throw(INTERP_KERNEL::Exception) { if(getNumberOfComponents()!=1) diff --git a/src/MEDCoupling/MEDCouplingMemArray.hxx b/src/MEDCoupling/MEDCouplingMemArray.hxx index b2439f1c2..1fedd0fa3 100644 --- a/src/MEDCoupling/MEDCouplingMemArray.hxx +++ b/src/MEDCoupling/MEDCouplingMemArray.hxx @@ -273,6 +273,8 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT void reprZipWithoutNameStream(std::ostream& stream) const; MEDCOUPLING_EXPORT void transformWithIndArr(const int *indArrBg, const int *indArrEnd) throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT DataArrayInt *transformWithIndArrR(const int *indArrBg, const int *indArrEnd) const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT void splitByValueRange(const int *arrBg, const int *arrEnd, + DataArrayInt *& castArr, DataArrayInt *& rankInsideCast, DataArrayInt *& castsPresent) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT DataArrayInt *invertArrayO2N2N2O(int newNbOfElem) const; MEDCOUPLING_EXPORT DataArrayInt *invertArrayN2O2O2N(int oldNbOfElem) const; //!alloc or useArray should have been called before. diff --git a/src/MEDCoupling/MEDCouplingMesh.hxx b/src/MEDCoupling/MEDCouplingMesh.hxx index 182dce853..11193f773 100644 --- a/src/MEDCoupling/MEDCouplingMesh.hxx +++ b/src/MEDCoupling/MEDCouplingMesh.hxx @@ -90,6 +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& 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 61c6f4627..19c8de91b 100644 --- a/src/MEDCoupling/MEDCouplingUMesh.cxx +++ b/src/MEDCoupling/MEDCouplingUMesh.cxx @@ -3415,6 +3415,70 @@ DataArrayInt *MEDCouplingUMesh::checkTypeConsistencyAndContig(const std::vector< return ret; } +/*! + * This method makes the hypothesis that 'this' is sorted by type. If not an exception will be thrown. + * This method is the opposite of MEDCouplingUMesh::checkTypeConsistencyAndContig method. Given a list of cells in 'profile' it returns a list of profiles sorted by geo type. + * 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& idsPerType) const throw(INTERP_KERNEL::Exception) +{ + if(profile->getNumberOfComponents()!=1) + throw INTERP_KERNEL::Exception("MEDCouplingUMesh::splitProfilePerType : input profile should have exactly one component !"); + checkConnectivityFullyDefined(); + const int *conn=_nodal_connec->getConstPointer(); + const int *connI=_nodal_connec_index->getConstPointer(); + int nbOfCells=getNumberOfCells(); + std::vector types; + std::vector typeRangeVals(1); + for(const int *i=connI;i!=connI+nbOfCells;) + { + INTERP_KERNEL::NormalizedCellType curType=(INTERP_KERNEL::NormalizedCellType)conn[*i]; + if(std::find(types.begin(),types.end(),curType)!=types.end()) + { + throw INTERP_KERNEL::Exception("MEDCouplingUMesh::splitProfilePerType : current mesh is not sorted by type !"); + } + types.push_back(curType); + i=std::find_if(i+1,connI+nbOfCells,ParaMEDMEMImpl::ConnReader(conn,(int)curType)); + typeRangeVals.push_back(std::distance(connI,i)); + } + // + DataArrayInt *castArr=0,*rankInsideCast=0,*castsPresent=0; + profile->splitByValueRange(&typeRangeVals[0],&typeRangeVals[0]+typeRangeVals.size(),castArr,rankInsideCast,castsPresent); + MEDCouplingAutoRefCountObjectPtr tmp0=castArr; + MEDCouplingAutoRefCountObjectPtr tmp1=rankInsideCast; + MEDCouplingAutoRefCountObjectPtr tmp2=castsPresent; + // + int nbOfCastsFinal=castsPresent->getNumberOfTuples(); + code.resize(3*nbOfCastsFinal); + std::vector< MEDCouplingAutoRefCountObjectPtr > idsPerType2; + for(int i=0;igetIJ(i,0); + MEDCouplingAutoRefCountObjectPtr tmp3=castArr->getIdsEqual(castId); + code[3*i]=(int)types[castId]; + code[3*i+1]=tmp3->getNumberOfTuples(); + MEDCouplingAutoRefCountObjectPtr tmp4=rankInsideCast->selectByTupleId(tmp3->getConstPointer(),tmp3->getConstPointer()+tmp3->getNumberOfTuples()); + if(tmp4->getNumberOfTuples()!=typeRangeVals[castId+1]-typeRangeVals[castId] || !tmp4->isIdentity()) + { + idsPerType2.push_back(tmp4); + code[3*i+2]=(int)idsPerType2.size()-1; + } + else + { + code[3*i+2]=-1; + } + } + int sz=idsPerType2.size(); + idsPerType.resize(sz); + for(int i=0;iincrRef(); + idsPerType[i]=locDa; + } +} + /*! * This method is here too emulate the MEDMEM behaviour on BDC (buildDescendingConnectivity). Hoping this method becomes deprecated very soon. * This method make the assumption that 'this' and 'nM1LevMesh' mesh lyies on same coords (same pointer) as MED and MEDMEM does. @@ -3490,7 +3554,7 @@ bool MEDCouplingUMesh::checkConsecutiveCellTypes() const { INTERP_KERNEL::NormalizedCellType curType=(INTERP_KERNEL::NormalizedCellType)conn[*i]; if(types.find(curType)!=types.end()) - return false; + return false; types.insert(curType); i=std::find_if(i+1,connI+nbOfCells,ParaMEDMEMImpl::ConnReader(conn,(int)curType)); } diff --git a/src/MEDCoupling/MEDCouplingUMesh.hxx b/src/MEDCoupling/MEDCouplingUMesh.hxx index 96fc0a6fd..a63b38665 100644 --- a/src/MEDCoupling/MEDCouplingUMesh.hxx +++ b/src/MEDCoupling/MEDCouplingUMesh.hxx @@ -140,6 +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& 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 9406b0766..872b793e5 100644 --- a/src/MEDCoupling/MEDCouplingUMeshDesc.cxx +++ b/src/MEDCoupling/MEDCouplingUMeshDesc.cxx @@ -194,6 +194,11 @@ DataArrayInt *MEDCouplingUMeshDesc::checkTypeConsistencyAndContig(const std::vec throw INTERP_KERNEL::Exception("Not implemented yet !"); } +void MEDCouplingUMeshDesc::splitProfilePerType(const DataArrayInt *profile, std::vector& code, std::vector& idsPerType) const throw(INTERP_KERNEL::Exception) +{ + throw INTERP_KERNEL::Exception("Not implemented yet !"); +} + void MEDCouplingUMeshDesc::getTinySerializationInformation(std::vector& tinyInfoD, std::vector& tinyInfo, std::vector& littleStrings) const { MEDCouplingPointSet::getTinySerializationInformation(tinyInfoD,tinyInfo,littleStrings); diff --git a/src/MEDCoupling/MEDCouplingUMeshDesc.hxx b/src/MEDCoupling/MEDCouplingUMeshDesc.hxx index 98867717b..86dcf63aa 100644 --- a/src/MEDCoupling/MEDCouplingUMeshDesc.hxx +++ b/src/MEDCoupling/MEDCouplingUMeshDesc.hxx @@ -58,6 +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& 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/MEDCouplingBasicsTest.hxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest.hxx index 6fbe69a54..8add2d0d3 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest.hxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest.hxx @@ -223,6 +223,8 @@ namespace ParaMEDMEM CPPUNIT_TEST( testSortCellsInMEDFileFrmt1 ); CPPUNIT_TEST( testBuildPartAndReduceNodes1 ); CPPUNIT_TEST( testDAITransformWithIndArrR1 ); + CPPUNIT_TEST( testDAISplitByValueRange1 ); + CPPUNIT_TEST( testUMeshSplitProfilePerType1 ); //MEDCouplingBasicsTestInterp.cxx CPPUNIT_TEST( test2DInterpP0P0_1 ); CPPUNIT_TEST( test2DInterpP0P0PL_1 ); @@ -472,6 +474,8 @@ namespace ParaMEDMEM void testSortCellsInMEDFileFrmt1(); void testBuildPartAndReduceNodes1(); void testDAITransformWithIndArrR1(); + void testDAISplitByValueRange1(); + void testUMeshSplitProfilePerType1(); //MEDCouplingBasicsTestInterp.cxx void test2DInterpP0P0_1(); void test2DInterpP0P0PL_1(); diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest4.cxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest4.cxx index cdd00270e..8fc38677a 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest4.cxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest4.cxx @@ -1270,3 +1270,126 @@ void MEDCouplingBasicsTest::testDAITransformWithIndArrR1() d->decrRef(); d1->decrRef(); } + +void MEDCouplingBasicsTest::testDAISplitByValueRange1() +{ + const int val1[9]={6,5,0,3,2,7,8,1,4}; + const int val2[3]={0,4,9}; + DataArrayInt *d=DataArrayInt::New(); + d->alloc(9,1); + std::copy(val1,val1+9,d->getPointer()); + DataArrayInt *e=0,*f=0,*g=0; + d->splitByValueRange(val2,val2+3,e,f,g); + CPPUNIT_ASSERT_EQUAL(9,e->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(1,e->getNumberOfComponents()); + CPPUNIT_ASSERT_EQUAL(9,f->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(1,f->getNumberOfComponents()); + CPPUNIT_ASSERT_EQUAL(2,g->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(1,g->getNumberOfComponents()); + // + const int expected1[9]={1,1,0,0,0,1,1,0,1}; + const int expected2[9]={2,1,0,3,2,3,4,1,0}; + for(int i=0;i<9;i++) + { + CPPUNIT_ASSERT_EQUAL(expected1[i],e->getIJ(i,0)); + CPPUNIT_ASSERT_EQUAL(expected2[i],f->getIJ(i,0)); + } + CPPUNIT_ASSERT_EQUAL(0,g->getIJ(0,0)); + CPPUNIT_ASSERT_EQUAL(1,g->getIJ(1,0)); + // + e->decrRef(); + f->decrRef(); + g->decrRef(); + // + d->setIJ(6,0,9); + CPPUNIT_ASSERT_THROW(d->splitByValueRange(val2,val2+3,e,f,g),INTERP_KERNEL::Exception); + // + d->decrRef(); +} + +void MEDCouplingBasicsTest::testUMeshSplitProfilePerType1() +{ + const int val0[5]={2,0,1,3,4}; + MEDCouplingUMesh *m=build2DTargetMesh_1(); + m->renumberCells(val0,false); + std::vector code; + std::vector pfls; + // + const int val1[3]={0,2,3}; + DataArrayInt *d=DataArrayInt::New(); + d->alloc(3,1); + std::copy(val1,val1+3,d->getPointer()); + m->splitProfilePerType(d,code,pfls); + CPPUNIT_ASSERT_EQUAL(6,(int)code.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(2,(int)pfls.size()); + CPPUNIT_ASSERT_EQUAL(1,pfls[0]->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(0,pfls[0]->getIJ(0,0)); + CPPUNIT_ASSERT_EQUAL(2,pfls[1]->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(0,pfls[1]->getIJ(0,0)); + CPPUNIT_ASSERT_EQUAL(1,pfls[1]->getIJ(1,0)); + pfls[0]->decrRef(); + pfls[1]->decrRef(); + d->decrRef(); + pfls.clear(); + code.clear(); + // + const int val2[4]={0,2,3,4};// all quad4 are selected here ! So no profile for Quads + d=DataArrayInt::New(); + d->alloc(4,1); + std::copy(val2,val2+4,d->getPointer()); + m->splitProfilePerType(d,code,pfls); + CPPUNIT_ASSERT_EQUAL(6,(int)code.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,(int)pfls.size()); + CPPUNIT_ASSERT_EQUAL(1,pfls[0]->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(0,pfls[0]->getIJ(0,0)); + pfls[0]->decrRef(); + d->decrRef(); + pfls.clear(); + code.clear(); + // + const int val3[3]={1,0,2};// all tri3 are selected here but not in the same order ! Profile requested for Tri3 + d=DataArrayInt::New(); + d->alloc(3,1); + std::copy(val3,val3+3,d->getPointer()); + m->splitProfilePerType(d,code,pfls); + CPPUNIT_ASSERT_EQUAL(6,(int)code.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,(int)pfls.size()); + CPPUNIT_ASSERT_EQUAL(2,pfls[0]->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(1,pfls[0]->getIJ(0,0)); + CPPUNIT_ASSERT_EQUAL(0,pfls[0]->getIJ(1,0)); + CPPUNIT_ASSERT_EQUAL(0,pfls[1]->getIJ(0,0)); + pfls[0]->decrRef(); + pfls[1]->decrRef(); + d->decrRef(); + pfls.clear(); + code.clear(); + // + const int val4[2]={3,4};// all tri3 are selected here but not in the same order ! Profile requested for Tri3 + d=DataArrayInt::New(); + d->alloc(2,1); + std::copy(val4,val4+2,d->getPointer()); + m->splitProfilePerType(d,code,pfls); + CPPUNIT_ASSERT_EQUAL(3,(int)code.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(1,(int)pfls.size()); + CPPUNIT_ASSERT_EQUAL(2,pfls[0]->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(1,pfls[0]->getIJ(0,0)); + CPPUNIT_ASSERT_EQUAL(2,pfls[0]->getIJ(1,0)); + pfls[0]->decrRef(); + d->decrRef(); + pfls.clear(); + code.clear(); + // + m->decrRef(); +} -- 2.39.2