From: ageay Date: Fri, 1 Feb 2013 15:24:04 +0000 (+0000) Subject: End of redesign of partitionBySpreadZone X-Git-Tag: V6_main_FINAL~399 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=784ef4dc977c91ffd8cbcbb146b2c626feb389f2;p=tools%2Fmedcoupling.git End of redesign of partitionBySpreadZone --- diff --git a/src/MEDCoupling/MEDCouplingUMesh.cxx b/src/MEDCoupling/MEDCouplingUMesh.cxx index 911add3d3..951812609 100644 --- a/src/MEDCoupling/MEDCouplingUMesh.cxx +++ b/src/MEDCoupling/MEDCouplingUMesh.cxx @@ -7628,41 +7628,86 @@ void MEDCouplingUMesh::SetPartOfIndexedArraysSameIdx(const int *idsOfSelectBg, c * \param [in] arrIn arr origin array from which the extraction will be done. * \param [in] arrIndxIn is the input index array allowing to walk into \b arrIn * \return a newly allocated DataArray that stores all ids fetched by the gradually spread process. + * \sa MEDCouplingUMesh::ComputeSpreadZoneGraduallyFromSeed, MEDCouplingUMesh::partitionBySpreadZone */ DataArrayInt *MEDCouplingUMesh::ComputeSpreadZoneGradually(const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn) throw(INTERP_KERNEL::Exception) { - if(!arrIn || !arrIndxIn) - throw INTERP_KERNEL::Exception("MEDCouplingUMesh::ExtractFromIndexedArrays : input pointer is NULL !"); + int seed=0,nbOfDepthPeelingPerformed=0; + return ComputeSpreadZoneGraduallyFromSeed(&seed,&seed+1,arrIn,arrIndxIn,-1,nbOfDepthPeelingPerformed); +} + +/*! + * This method works on a pair input (\b arrIn, \b arrIndxIn) where \b arr indexes is in \b arrIndxIn. + * This method expects that these two input arrays come from the output of MEDCouplingUMesh::computeNeighborsOfCells method. + * This method start from id 0 that will be contained in output DataArrayInt. It searches then all neighbors of id0 regarding arrIn[arrIndxIn[0]:arrIndxIn[0+1]]. + * Then it is repeated recursively until either all ids are fetched or no more ids are reachable step by step. + * A negative value in \b arrIn means that it is ignored. + * This method is usefull to see if a mesh is contiguous regarding its connectivity. If it is not the case the size of returned array is different from arrIndxIn->getNumberOfTuples()-1. + * \param [in] seedBg the begin pointer (included) of an array containing the seed of the search zone + * \param [in] seedEnd the end pointer (not included) of an array containing the seed of the search zone + * \param [in] arrIn arr origin array from which the extraction will be done. + * \param [in] arrIndxIn is the input index array allowing to walk into \b arrIn + * \param [in] nbOfDepthPeeling the max number of peels requested in search. By default -1, that is to say, no limit. + * \param [out] nbOfDepthPeelingPerformed the number of peels effectively performed. May be different from \a nbOfDepthPeeling + * \return a newly allocated DataArray that stores all ids fetched by the gradually spread process. + * \sa MEDCouplingUMesh::partitionBySpreadZone + */ +DataArrayInt *MEDCouplingUMesh::ComputeSpreadZoneGraduallyFromSeed(const int *seedBg, const int *seedEnd, const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn, int nbOfDepthPeeling, int& nbOfDepthPeelingPerformed) throw(INTERP_KERNEL::Exception) +{ + nbOfDepthPeelingPerformed=0; + if(!arrIndxIn) + throw INTERP_KERNEL::Exception("MEDCouplingUMesh::ComputeSpreadZoneGraduallyFromSeed : arrIndxIn input pointer is NULL !"); int nbOfTuples=arrIndxIn->getNumberOfTuples()-1; if(nbOfTuples<=0) { DataArrayInt *ret=DataArrayInt::New(); ret->alloc(0,1); return ret; } - const int *arrInPtr=arrIn->getConstPointer(); - const int *arrIndxPtr=arrIndxIn->getConstPointer(); - MEDCouplingAutoRefCountObjectPtr arro=DataArrayInt::New(); - arro->alloc(nbOfTuples,1); - arro->fillWithValue(-1); arro->setIJ(0,0,1); - int *arroPtr=arro->getPointer(); - std::set s; s.insert(0); - while(!s.empty()) + // + std::vector fetched(nbOfTuples,false); + return ComputeSpreadZoneGraduallyFromSeedAlg(fetched,seedBg,seedEnd,arrIn,arrIndxIn,nbOfDepthPeeling,nbOfDepthPeelingPerformed); +} + +DataArrayInt *MEDCouplingUMesh::ComputeSpreadZoneGraduallyFromSeedAlg(std::vector& fetched, const int *seedBg, const int *seedEnd, const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn, int nbOfDepthPeeling, int& nbOfDepthPeelingPerformed) throw(INTERP_KERNEL::Exception) +{ + nbOfDepthPeelingPerformed=0; + if(!seedBg || !seedEnd || !arrIn || !arrIndxIn) + throw INTERP_KERNEL::Exception("MEDCouplingUMesh::ComputeSpreadZoneGraduallyFromSeedAlg : some input pointer is NULL !"); + int nbOfTuples=arrIndxIn->getNumberOfTuples()-1; + std::vector fetched2(nbOfTuples,false); + int i=0; + for(const int *seedElt=seedBg;seedElt!=seedEnd;seedElt++,i++) { - std::set s2; - for(std::set::const_iterator it=s.begin();it!=s.end();it++) - { - for(const int *work=arrInPtr+arrIndxPtr[*it];work!=arrInPtr+arrIndxPtr[*it+1];work++) - { - if(*work>=0 && arroPtr[*work]<0) - { - arroPtr[*work]=1; - s2.insert(*work); - } - } - } - s=s2; + if(*seedElt>=0 && *seedEltgetIdsEqual(1); + const int *arrInPtr=arrIn->getConstPointer(); + const int *arrIndxPtr=arrIndxIn->getConstPointer(); + int targetNbOfDepthPeeling=nbOfDepthPeeling!=-1?nbOfDepthPeeling:std::numeric_limits::max(); + std::vector idsToFetch1(seedBg,seedEnd); + std::vector idsToFetch2; + std::vector *idsToFetch=&idsToFetch1; + std::vector *idsToFetchOther=&idsToFetch2; + while(!idsToFetch->empty() && nbOfDepthPeelingPerformed::const_iterator it=idsToFetch->begin();it!=idsToFetch->end();it++) + for(const int *it2=arrInPtr+arrIndxPtr[*it];it2!=arrInPtr+arrIndxPtr[*it+1];it2++) + if(!fetched[*it2]) + { fetched[*it2]=true; fetched2[*it2]=true; idsToFetchOther->push_back(*it2); } + std::swap(idsToFetch,idsToFetchOther); + idsToFetchOther->clear(); + nbOfDepthPeelingPerformed++; + } + int lgth=(int)std::count(fetched2.begin(),fetched2.end(),true); + i=0; + MEDCouplingAutoRefCountObjectPtr ret=DataArrayInt::New(); ret->alloc(lgth,1); + int *retPtr=ret->getPointer(); + for(std::vector::const_iterator it=fetched2.begin();it!=fetched2.end();it++,i++) + if(*it) + *retPtr++=i; + return ret.retn(); } /*! @@ -7831,6 +7876,28 @@ MEDCouplingUMesh *MEDCouplingUMesh::buildSpreadZonesWithPoly() const throw(INTER */ std::vector MEDCouplingUMesh::partitionBySpreadZone() const throw(INTERP_KERNEL::Exception) { + //#if 0 + int nbOfCellsCur=getNumberOfCells(); + std::vector ret; + if(nbOfCellsCur<=0) + return ret; + DataArrayInt *neigh=0,*neighI=0; + computeNeighborsOfCells(neigh,neighI); + MEDCouplingAutoRefCountObjectPtr neighAuto(neigh),neighIAuto(neighI); + std::vector fetchedCells(nbOfCellsCur,false); + std::vector< MEDCouplingAutoRefCountObjectPtr > ret2; + int seed=0; + while(seed >::iterator it=ret2.begin();it!=ret2.end();it++) + ret.push_back((*it).retn()); + return ret; + //#endif +#if 0 int nbOfCellsCur=getNumberOfCells(); DataArrayInt *neigh=0,*neighI=0; computeNeighborsOfCells(neigh,neighI); @@ -7858,6 +7925,7 @@ std::vector MEDCouplingUMesh::partitionBySpreadZone() const thro for(std::vector::const_iterator it=ret.begin();it!=ret.end();it++) (*it)->incrRef(); return ret; +#endif } /*! diff --git a/src/MEDCoupling/MEDCouplingUMesh.hxx b/src/MEDCoupling/MEDCouplingUMesh.hxx index c36681d6f..71a215a7b 100644 --- a/src/MEDCoupling/MEDCouplingUMesh.hxx +++ b/src/MEDCoupling/MEDCouplingUMesh.hxx @@ -244,6 +244,7 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT static void SetPartOfIndexedArraysSameIdx2(int start, int end, int step, DataArrayInt *arrInOut, const DataArrayInt *arrIndxIn, const DataArrayInt *srcArr, const DataArrayInt *srcArrIndex) throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT static DataArrayInt *ComputeSpreadZoneGradually(const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT static DataArrayInt *ComputeSpreadZoneGraduallyFromSeed(const int *seedBg, const int *seedEnd, const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn, int nbOfDepthPeeling, int& nbOfDepthPeelingPerformed) throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT static void FindCommonCellsAlg(int compType, int startCellId, const DataArrayInt *nodal, const DataArrayInt *nodalI, const DataArrayInt *revNodal, const DataArrayInt *revNodalI, DataArrayInt *& commonCellsArr, DataArrayInt *& commonCellsIArr) throw(INTERP_KERNEL::Exception); private: @@ -278,6 +279,7 @@ namespace ParaMEDMEM DataArrayInt *buildUnionOf3DMesh() const throw(INTERP_KERNEL::Exception); void distanceToPoint3DSurfAlg(const double *pt, const DataArrayInt *cellIds, double& ret0, int& cellId) const throw(INTERP_KERNEL::Exception); void distanceToPoint2DCurveAlg(const double *pt, const DataArrayInt *cellIds, double& ret0, int& cellId) const throw(INTERP_KERNEL::Exception); + static DataArrayInt *ComputeSpreadZoneGraduallyFromSeedAlg(std::vector& fetched, const int *seedBg, const int *seedEnd, const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn, int nbOfDepthPeeling, int& nbOfDepthPeelingPerformed) throw(INTERP_KERNEL::Exception); static void FillInCompact3DMode(int spaceDim, int nbOfNodesInCell, const int *conn, const double *coo, double *zipFrmt) throw(INTERP_KERNEL::Exception); static void AppendExtrudedCell(const int *connBg, const int *connEnd, int nbOfNodesPerLev, bool isQuad, std::vector& ret); static void IntersectDescending2DMeshes(const MEDCouplingUMesh *m1, const MEDCouplingUMesh *m2, double eps, diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py index e2ddd4d45..df8b4cb79 100644 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py @@ -10934,6 +10934,16 @@ class MEDCouplingBasicsTest(unittest.TestCase): self.assertTrue(zones[1].isEqual(DataArrayInt([1,2]))) self.assertTrue(zones[2].isEqual(DataArrayInt([3,4]))) self.assertTrue(zones[3].isEqual(DataArrayInt([5]))) + # + n,ni=m.computeNeighborsOfCells() + a,b=MEDCouplingUMesh.ComputeSpreadZoneGraduallyFromSeed(0,n,ni) + self.assertEqual(13,b) ; self.assertEqual(125,len(a)) ; self.assertTrue(a.isIdentity()) + a,b=MEDCouplingUMesh.ComputeSpreadZoneGraduallyFromSeed([1],n,ni) + self.assertEqual(12,b) ; self.assertEqual(125,len(a)) ; self.assertTrue(a.isIdentity()) + a,b=MEDCouplingUMesh.ComputeSpreadZoneGraduallyFromSeed((2,),n,ni) + self.assertEqual(11,b) ; self.assertEqual(125,len(a)) ; self.assertTrue(a.isIdentity()) + a,b=MEDCouplingUMesh.ComputeSpreadZoneGraduallyFromSeed(DataArrayInt([3]),n,ni) + self.assertEqual(12,b) ; self.assertEqual(125,len(a)) ; self.assertTrue(a.isIdentity()) pass def setUp(self): diff --git a/src/MEDCoupling_Swig/MEDCouplingCommon.i b/src/MEDCoupling_Swig/MEDCouplingCommon.i index ff44fd30b..e44382a71 100644 --- a/src/MEDCoupling_Swig/MEDCouplingCommon.i +++ b/src/MEDCoupling_Swig/MEDCouplingCommon.i @@ -281,6 +281,7 @@ using namespace INTERP_KERNEL; %newobject ParaMEDMEM::MEDCouplingUMesh::MergeUMeshes; %newobject ParaMEDMEM::MEDCouplingUMesh::MergeUMeshesOnSameCoords; %newobject ParaMEDMEM::MEDCouplingUMesh::ComputeSpreadZoneGradually; +%newobject ParaMEDMEM::MEDCouplingUMesh::ComputeSpreadZoneGraduallyFromSeed; %newobject ParaMEDMEM::MEDCouplingUMesh::buildNewNumberingFromCommNodesFrmt; %newobject ParaMEDMEM::MEDCouplingUMesh::rearrange2ConsecutiveCellTypes; %newobject ParaMEDMEM::MEDCouplingUMesh::sortCellsInMEDFileFrmt; @@ -717,55 +718,44 @@ namespace ParaMEDMEM PyObject *buildPart(PyObject *li) const throw(INTERP_KERNEL::Exception) { - void *da=0; - int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 ); - if (!SWIG_IsOK(res1)) - { - int size; - INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); - MEDCouplingMesh *ret=self->buildPart(tmp,((const int *)tmp)+size); - return convertMesh(ret, SWIG_POINTER_OWN | 0 ); - } - else - { - DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da); - if(!da2) - throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !"); - da2->checkAllocated(); - MEDCouplingMesh *ret=self->buildPart(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems()); - ret->setName(da2->getName().c_str()); - return convertMesh(ret, SWIG_POINTER_OWN | 0 ); + int szArr,sw,iTypppArr; + std::vector stdvecTyyppArr; + const int *tmp=convertObjToPossibleCpp1_Safe(li,sw,szArr,iTypppArr,stdvecTyyppArr); + MEDCouplingMesh *ret=self->buildPart(tmp,tmp+szArr); + if(sw==3)//DataArrayInt + { + void *argp; SWIG_ConvertPtr(li,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayInt,0|0); + DataArrayInt *argpt=reinterpret_cast< ParaMEDMEM::DataArrayInt * >(argp); + std::string name=argpt->getName(); + if(!name.empty()) + ret->setName(name.c_str()); } + return convertMesh(ret, SWIG_POINTER_OWN | 0 ); } - PyObject *buildPartAndReduceNodes(PyObject *li) const throw(INTERP_KERNEL::Exception) - { - void *da=0; - DataArrayInt *arr=0; - MEDCouplingMesh *ret=0; - int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 ); - if (!SWIG_IsOK(res1)) - { - int size; - INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); - ret=self->buildPartAndReduceNodes(tmp,((const int *)tmp)+size,arr); - } - else - { - DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da); - if(!da2) - throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !"); - da2->checkAllocated(); - ret=self->buildPartAndReduceNodes(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems(),arr); - ret->setName(da2->getName().c_str()); + PyObject *buildPartAndReduceNodes(PyObject *li) const throw(INTERP_KERNEL::Exception) + { + int szArr,sw,iTypppArr; + std::vector stdvecTyyppArr; + DataArrayInt *arr=0; + const int *tmp=convertObjToPossibleCpp1_Safe(li,sw,szArr,iTypppArr,stdvecTyyppArr); + MEDCouplingMesh *ret=self->buildPartAndReduceNodes(tmp,tmp+szArr,arr); + if(sw==3)//DataArrayInt + { + void *argp; SWIG_ConvertPtr(li,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayInt,0|0); + DataArrayInt *argpt=reinterpret_cast< ParaMEDMEM::DataArrayInt * >(argp); + std::string name=argpt->getName(); + if(!name.empty()) + ret->setName(name.c_str()); } - PyObject *res = PyList_New(2); - PyObject *obj0=convertMesh(ret, SWIG_POINTER_OWN | 0 ); - PyObject *obj1=SWIG_NewPointerObj(SWIG_as_voidptr(arr),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ); - PyList_SetItem(res,0,obj0); - PyList_SetItem(res,1,obj1); - return res; - } + // + PyObject *res = PyList_New(2); + PyObject *obj0=convertMesh(ret, SWIG_POINTER_OWN | 0 ); + PyObject *obj1=SWIG_NewPointerObj(SWIG_as_voidptr(arr),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ); + PyList_SetItem(res,0,obj0); + PyList_SetItem(res,1,obj1); + return res; + } PyObject *getDistributionOfTypes() const throw(INTERP_KERNEL::Exception) { @@ -1021,111 +1011,74 @@ namespace ParaMEDMEM ret1->incrRef(); return SWIG_NewPointerObj((void*)ret1,SWIGTYPE_p_ParaMEDMEM__DataArrayDouble,SWIG_POINTER_OWN | 0); } + PyObject *buildPartOfMySelf(PyObject *li, bool keepCoords=true) const throw(INTERP_KERNEL::Exception) { - void *da=0; - int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 ); - if (!SWIG_IsOK(res1)) - { - int size; - INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); - MEDCouplingPointSet *ret=self->buildPartOfMySelf(tmp,((const int *)tmp)+size,keepCoords); - return convertMesh(ret, SWIG_POINTER_OWN | 0 ); - } - else - { - DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da); - if(!da2) - throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !"); - da2->checkAllocated(); - MEDCouplingPointSet *ret=self->buildPartOfMySelf(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems(),keepCoords); - ret->setName(da2->getName().c_str()); - return convertMesh(ret, SWIG_POINTER_OWN | 0 ); + int szArr,sw,iTypppArr; + std::vector stdvecTyyppArr; + const int *tmp=convertObjToPossibleCpp1_Safe(li,sw,szArr,iTypppArr,stdvecTyyppArr); + MEDCouplingPointSet *ret=self->buildPartOfMySelf(tmp,tmp+szArr,keepCoords); + if(sw==3)//DataArrayInt + { + void *argp; SWIG_ConvertPtr(li,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayInt,0|0); + DataArrayInt *argpt=reinterpret_cast< ParaMEDMEM::DataArrayInt * >(argp); + std::string name=argpt->getName(); + if(!name.empty()) + ret->setName(name.c_str()); } + return convertMesh(ret, SWIG_POINTER_OWN | 0 ); } + PyObject *buildPartOfMySelfNode(PyObject *li, bool fullyIn) const throw(INTERP_KERNEL::Exception) { - void *da=0; - int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 ); - if (!SWIG_IsOK(res1)) - { - int size; - INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); - MEDCouplingPointSet *ret=self->buildPartOfMySelfNode(tmp,((const int *)tmp)+size,fullyIn); - return convertMesh(ret, SWIG_POINTER_OWN | 0 ); - } - else - { - DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da); - if(!da2) - throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !"); - da2->checkAllocated(); - MEDCouplingPointSet *ret=self->buildPartOfMySelfNode(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems(),fullyIn); - ret->setName(da2->getName().c_str()); - return convertMesh(ret, SWIG_POINTER_OWN | 0 ); + int szArr,sw,iTypppArr; + std::vector stdvecTyyppArr; + const int *tmp=convertObjToPossibleCpp1_Safe(li,sw,szArr,iTypppArr,stdvecTyyppArr); + MEDCouplingPointSet *ret=self->buildPartOfMySelfNode(tmp,tmp+szArr,fullyIn); + if(sw==3)//DataArrayInt + { + void *argp; SWIG_ConvertPtr(li,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayInt,0|0); + DataArrayInt *argpt=reinterpret_cast< ParaMEDMEM::DataArrayInt * >(argp); + std::string name=argpt->getName(); + if(!name.empty()) + ret->setName(name.c_str()); } + return convertMesh(ret, SWIG_POINTER_OWN | 0 ); } + PyObject *buildFacePartOfMySelfNode(PyObject *li, bool fullyIn) const throw(INTERP_KERNEL::Exception) { - void *da=0; - int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 ); - if (!SWIG_IsOK(res1)) - { - int size; - INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); - MEDCouplingPointSet *ret=self->buildFacePartOfMySelfNode(tmp,((const int *)tmp)+size,fullyIn); - return convertMesh(ret, SWIG_POINTER_OWN | 0 ); - } - else - { - DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da); - if(!da2) - throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !"); - da2->checkAllocated(); - MEDCouplingPointSet *ret=self->buildFacePartOfMySelfNode(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems(),fullyIn); - ret->setName(da2->getName().c_str()); - return convertMesh(ret, SWIG_POINTER_OWN | 0 ); + int szArr,sw,iTypppArr; + std::vector stdvecTyyppArr; + const int *tmp=convertObjToPossibleCpp1_Safe(li,sw,szArr,iTypppArr,stdvecTyyppArr); + MEDCouplingPointSet *ret=self->buildFacePartOfMySelfNode(tmp,tmp+szArr,fullyIn); + if(sw==3)//DataArrayInt + { + void *argp; SWIG_ConvertPtr(li,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayInt,0|0); + DataArrayInt *argpt=reinterpret_cast< ParaMEDMEM::DataArrayInt * >(argp); + std::string name=argpt->getName(); + if(!name.empty()) + ret->setName(name.c_str()); } + return convertMesh(ret, SWIG_POINTER_OWN | 0 ); } void renumberNodes(PyObject *li, int newNbOfNodes) throw(INTERP_KERNEL::Exception) { - void *da=0; - int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 ); - if (!SWIG_IsOK(res1)) - { - int size; - INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); - self->renumberNodes(tmp,newNbOfNodes); - } - else - { - DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da); - if(!da2) - throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !"); - da2->checkAllocated(); - self->renumberNodes(da2->getConstPointer(),newNbOfNodes); - } + int szArr,sw,iTypppArr; + std::vector stdvecTyyppArr; + const int *tmp=convertObjToPossibleCpp1_Safe(li,sw,szArr,iTypppArr,stdvecTyyppArr); + self->renumberNodes(tmp,newNbOfNodes); } + void renumberNodes2(PyObject *li, int newNbOfNodes) throw(INTERP_KERNEL::Exception) { - void *da=0; - int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 ); - if (!SWIG_IsOK(res1)) - { - int size; - INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); - self->renumberNodes2(tmp,newNbOfNodes); - } - else - { - DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da); - if(!da2) - throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !"); - da2->checkAllocated(); - self->renumberNodes2(da2->getConstPointer(),newNbOfNodes); - } + int szArr,sw,iTypppArr; + std::vector stdvecTyyppArr; + const int *tmp=convertObjToPossibleCpp1_Safe(li,sw,szArr,iTypppArr,stdvecTyyppArr); + self->renumberNodes2(tmp,newNbOfNodes); } + PyObject *findNodesOnLine(PyObject *pt, PyObject *vec, double eps) const throw(INTERP_KERNEL::Exception) { int spaceDim=self->getSpaceDimension(); @@ -1202,33 +1155,15 @@ namespace ParaMEDMEM { DataArrayInt *c=0,*cI=0; int spaceDim=self->getSpaceDimension(); - void *da=0; - int res1=SWIG_ConvertPtr(pt,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, 0 | 0 ); - if (!SWIG_IsOK(res1)) - { - int size; - INTERP_KERNEL::AutoPtr tmp=convertPyToNewDblArr2(pt,&size); - int nbOfPoints=size/spaceDim; - if(size%spaceDim!=0) - { - throw INTERP_KERNEL::Exception("MEDCouplingPointSet::getCellsContainingPoints : Invalid list length ! Must be a multiple of self.getSpaceDimension() !"); - } - self->getNodeIdsNearPoints(tmp,nbOfPoints,eps,c,cI); - } - else - { - DataArrayDouble *da2=reinterpret_cast< DataArrayDouble * >(da); - if(!da2) - throw INTERP_KERNEL::Exception("MEDCouplingPointSet::getCellsContainingPoints : Not null DataArrayDouble instance expected !"); - da2->checkAllocated(); - int size=da2->getNumberOfTuples(); - int nbOfCompo=da2->getNumberOfComponents(); - if(nbOfCompo!=spaceDim) - { - throw INTERP_KERNEL::Exception("MEDCouplingPointSet::getCellsContainingPoints : Invalid DataArrayDouble nb of components ! Expected same as self.getSpaceDimension() !"); - } - self->getNodeIdsNearPoints(da2->getConstPointer(),size,eps,c,cI); - } + double val; + DataArrayDouble *a; + DataArrayDoubleTuple *aa; + std::vector bb; + int sw; + int nbOfTuples=-1; + const double *ptPtr=convertObjToPossibleCpp5_Safe2(pt,sw,val,a,aa,bb,"Python wrap of MEDCouplingUMesh::getNodeIdsNearPoints",spaceDim,true,nbOfTuples); + self->getNodeIdsNearPoints(ptPtr,nbOfTuples,eps,c,cI); + // PyObject *ret=PyTuple_New(2); PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(c),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(cI),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); @@ -1710,6 +1645,19 @@ namespace ParaMEDMEM PyList_SetItem(res,i,PyInt_FromLong(*iL)); return res; } + + static PyObject *ComputeSpreadZoneGraduallyFromSeed(PyObject *seed, const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn, int nbOfDepthPeeling=-1) throw(INTERP_KERNEL::Exception) + { + int szArr,sw,iTypppArr; + std::vector stdvecTyyppArr; + const int *seedPtr=convertObjToPossibleCpp1_Safe(seed,sw,szArr,iTypppArr,stdvecTyyppArr); + int nbOfDepthPeelingPerformed=0; + DataArrayInt *ret0=MEDCouplingUMesh::ComputeSpreadZoneGraduallyFromSeed(seedPtr,seedPtr+szArr,arrIn,arrIndxIn,nbOfDepthPeeling,nbOfDepthPeelingPerformed); + PyObject *res=PyTuple_New(2); + PyTuple_SetItem(res,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(res,1,PyInt_FromLong(nbOfDepthPeelingPerformed)); + return res; + } PyObject *findCommonCells(int compType, int startCellId=0) const throw(INTERP_KERNEL::Exception) {