From eb84b539a5020dba946aa186be214b7c242adcf6 Mon Sep 17 00:00:00 2001 From: ageay Date: Fri, 19 Oct 2012 15:51:13 +0000 Subject: [PATCH] Preparation to generalization --- .../InterpKernelGeo2DComposedEdge.cxx | 2 + .../InterpKernelGeo2DQuadraticPolygon.cxx | 57 ++++++++++++++++++- .../InterpKernelGeo2DQuadraticPolygon.hxx | 4 +- src/MEDCoupling/MEDCouplingUMesh.cxx | 11 +++- 4 files changed, 71 insertions(+), 3 deletions(-) diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DComposedEdge.cxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DComposedEdge.cxx index ed800c1b8..cdf2ca336 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DComposedEdge.cxx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DComposedEdge.cxx @@ -256,6 +256,8 @@ void ComposedEdge::unApplyGlobalSimilarityExt(ComposedEdge& other, double xBary, (*iter)->unApplySimilarity(xBary,yBary,fact); for(std::list::iterator iter=_sub_edges.begin();iter!=_sub_edges.end();iter++) (*iter)->unApplySimilarity(xBary,yBary,fact); + for(std::list::iterator iter=other._sub_edges.begin();iter!=other._sub_edges.end();iter++) + (*iter)->unApplySimilarity(xBary,yBary,fact); } double ComposedEdge::normalizeExt(ComposedEdge *other, double& xBary, double& yBary) diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DQuadraticPolygon.cxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DQuadraticPolygon.cxx index 56a1a9284..69b6dacad 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DQuadraticPolygon.cxx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DQuadraticPolygon.cxx @@ -556,8 +556,10 @@ void QuadraticPolygon::appendCrudeData(const std::map /*! * This method make the hypothesis that 'this' and 'other' are splited at the minimum into edges that are fully IN, OUT or ON. * This method returns newly created polygons in 'conn' and 'connI' and the corresponding ids ('idThis','idOther') are stored respectively into 'nbThis' and 'nbOther'. + * @param [in,out] edgesThis, parameter that keep informed the caller abount the edges in this not shared by the result of intersection of \a this with \a other + * @param [in,out] edgesBoundaryOther, parameter that strores all edges in result of intersection that are not */ -void QuadraticPolygon::buildPartitionsAbs(QuadraticPolygon& other, const std::map& mapp, int idThis, int idOther, int offset, std::vector& addCoordsQuadratic, std::vector& conn, std::vector& connI, std::vector& nbThis, std::vector& nbOther) +void QuadraticPolygon::buildPartitionsAbs(QuadraticPolygon& other, std::set& edgesThis, std::set& edgesBoundaryOther, const std::map& mapp, int idThis, int idOther, int offset, std::vector& addCoordsQuadratic, std::vector& conn, std::vector& connI, std::vector& nbThis, std::vector& nbOther) { double xBaryBB, yBaryBB; double fact=normalizeExt(&other, xBaryBB, yBaryBB); @@ -567,6 +569,20 @@ void QuadraticPolygon::buildPartitionsAbs(QuadraticPolygon& other, const std::ma for(std::vector::iterator it=res.begin();it!=res.end();it++) { (*it)->appendCrudeData(mapp,xBaryBB,yBaryBB,fact,offset,addCoordsQuadratic,conn,connI); + INTERP_KERNEL::IteratorOnComposedEdge it1(*it); + for(it1.first();!it1.finished();it1.next()) + { + Edge *e=it1.current()->getPtr(); + if(edgesThis.find(e)!=edgesThis.end()) + edgesThis.erase(e); + else + { + if(edgesBoundaryOther.find(e)!=edgesBoundaryOther.end()) + edgesBoundaryOther.erase(e); + else + edgesBoundaryOther.insert(e); + } + } nbThis.push_back(idThis); nbOther.push_back(idOther); delete *it; @@ -1041,3 +1057,42 @@ std::list::iterator QuadraticPolygon::CheckInList(Node *n, s return iter; return iEnd; } + +void QuadraticPolygon::ComputeResidual(const std::set& notUsedInPol1, const std::set& edgesInPol2OnBoundary, int idThis, + std::vector& addCoordsQuadratic, std::vector& conn, std::vector& connI, std::vector& nb1) +{ + for(std::set::const_iterator it=edgesInPol2OnBoundary.begin();it!=edgesInPol2OnBoundary.end();it++) + { (*it)->initLocs(); (*it)->declareIn(); } + for(std::set::const_iterator it=notUsedInPol1.begin();it!=notUsedInPol1.end();it++) + { (*it)->initLocs(); (*it)->declareOn(); } + std::list pol2Zip; + std::list edgesInPol2OnBoundaryL(edgesInPol2OnBoundary.begin(),edgesInPol2OnBoundary.end()); + while(!edgesInPol2OnBoundaryL.empty()) + { + QuadraticPolygon *tmp1=new QuadraticPolygon; + Node *curN=0; + for(std::list::iterator it=edgesInPol2OnBoundaryL.begin();it!=edgesInPol2OnBoundaryL.end();it++) + { + if((*it)->getStartNode()->getLoc()==ON_1) + { curN=(*it)->getEndNode(); edgesInPol2OnBoundaryL.erase(it); tmp1->pushBack(new ElementaryEdge(*it,true)); break; } + if((*it)->getEndNode()->getLoc()==ON_1) + { curN=(*it)->getStartNode(); edgesInPol2OnBoundaryL.erase(it); tmp1->pushBack(new ElementaryEdge(*it,false)); break; } + } + // + while(curN->getLoc()!=ON_1 && !edgesInPol2OnBoundaryL.empty()) + { + for(std::list::iterator it=edgesInPol2OnBoundaryL.begin();it!=edgesInPol2OnBoundaryL.end();it++) + { + if((*it)->getStartNode()==curN) + { curN=(*it)->getEndNode(); edgesInPol2OnBoundaryL.erase(it); tmp1->pushBack(new ElementaryEdge(*it,true)); break; } + if((*it)->getEndNode()==curN) + { curN=(*it)->getStartNode(); edgesInPol2OnBoundaryL.erase(it); tmp1->pushBack(new ElementaryEdge(*it,false)); break; } + } + } + pol2Zip.push_back(tmp1); + } + //pol2.zipConsecutiveInSegments(); + //std::vector ret; + //if(!pol2Zip.empty()) + // closePolygons(pol2Zip,pol1,ret); +} diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DQuadraticPolygon.hxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DQuadraticPolygon.hxx index ef14efe90..2c9edcd34 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DQuadraticPolygon.hxx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DQuadraticPolygon.hxx @@ -68,7 +68,7 @@ namespace INTERP_KERNEL const int *descBg, const int *descEnd, const std::vector >& intersectEdges); void appendSubEdgeFromCrudeDataArray(Edge *baseEdge, std::size_t j, bool direct, int edgeId, const std::vector& subEdge, const std::map& mapp); void appendCrudeData(const std::map& mapp, double xBary, double yBary, double fact, int offset, std::vector& addCoordsQuadratic, std::vector& conn, std::vector& connI) const; - void buildPartitionsAbs(QuadraticPolygon& other, const std::map& mapp, int idThis, int idOther, int offset, + void buildPartitionsAbs(QuadraticPolygon& other, std::set& edgesThis, std::set& edgesBoundaryOther, const std::map& mapp, int idThis, int idOther, int offset, std::vector& addCoordsQuadratic, std::vector& conn, std::vector& connI, std::vector& nb1, std::vector& nb2); // double intersectWith(const QuadraticPolygon& other) const; @@ -82,6 +82,8 @@ namespace INTERP_KERNEL static void SplitPolygonsEachOther(QuadraticPolygon& pol1, QuadraticPolygon& pol2, int& nbOfSplits); std::vector buildIntersectionPolygons(const QuadraticPolygon& pol1, const QuadraticPolygon& pol2) const; bool amIAChanceToBeCompletedBy(const QuadraticPolygon& pol1Splitted, const QuadraticPolygon& pol2NotSplitted, bool& direction); + static void ComputeResidual(const std::set& notUsedInPol1, const std::set& edgesInPol2OnBoundary, int idThis, + std::vector& addCoordsQuadratic, std::vector& conn, std::vector& connI, std::vector& nb1); protected: std::list zipConsecutiveInSegments() const; void dumpInXfigFile(std::ostream& stream, int resolution, const Bounds& box) const; diff --git a/src/MEDCoupling/MEDCouplingUMesh.cxx b/src/MEDCoupling/MEDCouplingUMesh.cxx index 9f22565f4..e5c84bfc6 100644 --- a/src/MEDCoupling/MEDCouplingUMesh.cxx +++ b/src/MEDCoupling/MEDCouplingUMesh.cxx @@ -6707,6 +6707,13 @@ void MEDCouplingUMesh::BuildIntersecting2DCellsFromEdges(double eps, const MEDCo MEDCouplingUMeshBuildQPFromMesh3(coo1,offset1,coo2,offset2,addCoords,desc1+descIndx1[i],desc1+descIndx1[i+1],intesctEdges1,/* output */mapp,mappRev); pol1.buildFromCrudeDataArray(mappRev,cm.isQuadratic(),conn1+connI1[i]+1,coo1, desc1+descIndx1[i],desc1+descIndx1[i+1],intesctEdges1); + // + std::set edges1;// store all edges of pol1 that are NOT consumed by intersect cells. If any after iteration over candidates2 -> a part of pol1 should appear in result + std::set edgesBoundary2;// store all edges that are on boundary of (pol2 intersect pol1) minus edges on pol1. + INTERP_KERNEL::IteratorOnComposedEdge it1(&pol1); + for(it1.first();!it1.finished();it1.next()) + edges1.insert(it1.current()->getPtr()); + // std::vector pol2s(candidates2.size()); int ii=0; for(std::vector::const_iterator it2=candidates2.begin();it2!=candidates2.end();it2++,ii++) @@ -6723,10 +6730,12 @@ void MEDCouplingUMesh::BuildIntersecting2DCellsFromEdges(double eps, const MEDCo pol1.initLocations(); pol2s[ii].updateLocOfEdgeFromCrudeDataArray2(desc2+descIndx2[*it2],desc2+descIndx2[*it2+1],intesctEdges2,pol1,desc1+descIndx1[i],desc1+descIndx1[i+1],intesctEdges1,colinear2); //MEDCouplingUMeshAssignOnLoc(pol1,pol2,desc1+descIndx1[i],desc1+descIndx1[i+1],intesctEdges1,desc2+descIndx2[*it2],desc2+descIndx2[*it2+1],intesctEdges2,colinear2); - pol1.buildPartitionsAbs(pol2s[ii],mapp,i,*it2,offset3,addCoordsQuadratic,cr,crI,cNb1,cNb2); + pol1.buildPartitionsAbs(pol2s[ii],edges1,edgesBoundary2,mapp,i,*it2,offset3,addCoordsQuadratic,cr,crI,cNb1,cNb2); } for(std::map::const_iterator it=mappRev.begin();it!=mappRev.end();it++) (*it).second->decrRef(); + //if(!edges1.empty()) + // std::cerr << "Cell #" << i << " in mesh m1 not fully overlapped !" << std::endl; } } -- 2.39.2