X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDCoupling%2FMEDCouplingVoronoi.cxx;h=12807437dad38c6d93be14d39c999d30d8fe98c4;hb=ac1df6b0ba8b337555fb39610c89f678d889580d;hp=7e7efbcfdee1a7452e96a622859172d529b8f191;hpb=98f7ba20f9cf8c460c43e3ffd2eacc4ec473a9cb;p=tools%2Fmedcoupling.git diff --git a/src/MEDCoupling/MEDCouplingVoronoi.cxx b/src/MEDCoupling/MEDCouplingVoronoi.cxx index 7e7efbcfd..12807437d 100644 --- a/src/MEDCoupling/MEDCouplingVoronoi.cxx +++ b/src/MEDCoupling/MEDCouplingVoronoi.cxx @@ -150,6 +150,40 @@ MCAuto MergeVorCells(const std::vector< MCAuto SimplifyPolygon(const MEDCouplingUMesh *m, double eps) +{ + if(m->getNumberOfCells()!=1) + throw INTERP_KERNEL::Exception("SimplifyPolygon : internal error !"); + const int *conn(m->getNodalConnectivity()->begin()),*conni(m->getNodalConnectivityIndex()->begin()); + int nbPtsInPolygon(conni[1]-conni[0]-1); + const double *coo(m->getCoords()->begin()); + std::vector resConn; + for(int i=0;ieps) + resConn.push_back(current); + } + MCAuto ret(MEDCouplingUMesh::New("",2)); + ret->setCoords(m->getCoords()); + ret->allocateCells(); + ret->insertNextCell(INTERP_KERNEL::NORM_POLYGON,resConn.size(),&resConn[0]); + return ret; +} + MCAuto MergeVorCells3D(const std::vector< MCAuto >& vcs, double eps) { std::size_t sz(vcs.size()); @@ -199,6 +233,7 @@ MCAuto MergeVorCells3D(const std::vector< MCAutogetNodalConnectivity()->begin()),*ciPtr(tmp2->getNodalConnectivityIndex()->begin()); conn.insert(conn.end(),cPtr+1,cPtr+ciPtr[1]); } @@ -405,7 +440,7 @@ MCAuto MEDCoupling::Voronizer2D::doIt(const MEDCouplingUMesh * newCoords=a->getCoords()->selectByTupleId(tmp->begin(),tmp->end()); } const double *cPtr(newCoords->begin()); - for(int i=0;igetNumberOfTuples();i++,cPtr+=2) + for(int j=0;jgetNumberOfTuples();j++,cPtr+=2) { std::set zeCandidates; { @@ -413,9 +448,9 @@ MCAuto MEDCoupling::Voronizer2D::doIt(const MEDCouplingUMesh * vorTess->getCellsContainingPoint(cPtr,eps,zeCandidatesTmp); zeCandidates.insert(zeCandidatesTmp.begin(),zeCandidatesTmp.end()); } - std::set tmp,newElementsToDo; - std::set_difference(zeCandidates.begin(),zeCandidates.end(),elemsDone.begin(),elemsDone.end(),std::inserter(tmp,tmp.begin())); - std::set_union(elemsToDo.begin(),elemsToDo.end(),tmp.begin(),tmp.end(),std::inserter(newElementsToDo,newElementsToDo.begin())); + std::set tmp2,newElementsToDo; + std::set_difference(zeCandidates.begin(),zeCandidates.end(),elemsDone.begin(),elemsDone.end(),std::inserter(tmp2,tmp2.begin())); + std::set_union(elemsToDo.begin(),elemsToDo.end(),tmp2.begin(),tmp2.end(),std::inserter(newElementsToDo,newElementsToDo.begin())); elemsToDo=newElementsToDo; } newVorCells.push_back(newVorCell); @@ -474,15 +509,9 @@ MCAuto MEDCoupling::Voronizer3D::doIt(const MEDCouplingUMesh * vorTess->getCellsContainingPoint(pt,eps,polygsToIterOn); if(polygsToIterOn.size()<1) throw INTERP_KERNEL::Exception("Voronoize3D : presence of a point outside the given cell !"); - std::set elemsToDo(polygsToIterOn.begin(),polygsToIterOn.end()),elemsDone; - std::size_t ii(0); std::vector< MCAuto > newVorCells; - MCAuto d(DataArrayInt::New()),dI(DataArrayInt::New()),rd(DataArrayInt::New()),rdI(DataArrayInt::New()); - MCAuto faces(vorTess->buildDescendingConnectivity(d,dI,rd,rdI)); - // - while(!elemsToDo.empty()) + for(int poly=0;polygetNumberOfCells();poly++) { - int poly(*elemsToDo.begin()); elemsToDo.erase(elemsToDo.begin()); elemsDone.insert(poly); const double *seed(pts+3*poly); MCAuto tile(l0[poly]); tile->zipCoords(); @@ -500,44 +529,8 @@ MCAuto MEDCoupling::Voronizer3D::doIt(const MEDCouplingUMesh * newVorCell->zipCoords(); MCAuto modifiedCell(cells->buildPartOfMySelfSlice(0,1,1,true)); modifiedCell->zipCoords(); - l0[poly]=modifiedCell; - if(std::find(polygsToIterOn.begin(),polygsToIterOn.end(),poly)!=polygsToIterOn.end())// we iterate on a polyhedron containg the point to add pt -> add cells sharing faces with just computed newVorCell - { - MCAuto faces2; - { - MCAuto d2(DataArrayInt::New()),d2I(DataArrayInt::New()),rd2(DataArrayInt::New()),rd2I(DataArrayInt::New()); - faces2=newVorCell->buildDescendingConnectivity(d2,d2I,rd2,rd2I); - } - MCAuto faces3(faces2->buildPartOfMySelfSlice(1,faces2->getNumberOfCells(),1,true));// suppress internal face - MCAuto facesOfCurSplitPol(faces->buildPartOfMySelf(d->begin()+dI->getIJ(poly,0),d->begin()+dI->getIJ(poly+1,0),true)); - // intersection between the out faces of newVorCell and the neighbor faces of poly polyhedron -> candidates - MEDCouplingNormalizedUnstructuredMesh<3,2> source_mesh_wrapper(facesOfCurSplitPol); - MEDCouplingNormalizedUnstructuredMesh<3,2> target_mesh_wrapper(faces3); - INTERP_KERNEL::Interpolation3DSurf interpolation; - interpolation.setMinDotBtwPlane3DSurfIntersect(eps2); - interpolation.setMaxDistance3DSurfIntersect(eps); - interpolation.setPrecision(1e-12); - std::vector > matrix; - interpolation.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,matrix,"P0P0"); - std::set zeCandidates; - for(std::vector >::const_iterator it2=matrix.begin();it2!=matrix.end();it2++) - for(std::map::const_iterator it3=(*it2).begin();it3!=(*it2).end();it3++) - { - int faceIdInVorTess(d->getIJ(dI->getIJ(poly,0)+(*it3).first,0)); - for(const int *it4=rd->begin()+rdI->getIJ(faceIdInVorTess,0);it4!=rd->begin()+rdI->getIJ(faceIdInVorTess+1,0);it4++) - { - if(*it4!=poly) - zeCandidates.insert(*it4); - } - } - std::set tmp,newElementsToDo; - std::set_difference(zeCandidates.begin(),zeCandidates.end(),elemsDone.begin(),elemsDone.end(),std::inserter(tmp,tmp.begin())); - std::set_union(elemsToDo.begin(),elemsToDo.end(),tmp.begin(),tmp.end(),std::inserter(newElementsToDo,newElementsToDo.begin())); - elemsToDo=newElementsToDo; - } - // newVorCells.push_back(newVorCell); - ii++; + l0[poly]=modifiedCell; } l0.push_back(MergeVorCells3D(newVorCells,eps)); }