From f017f920d29ab90d9ca7e9aeb9c9396b7aeacc86 Mon Sep 17 00:00:00 2001 From: ageay Date: Wed, 9 Nov 2011 16:14:14 +0000 Subject: [PATCH] Correction of bug. --- .../Geometric2D/InterpKernelGeo2DEdge.hxx | 2 +- .../InterpKernelGeo2DEdgeArcCircle.cxx | 2 +- .../InterpKernelGeo2DEdgeArcCircle.hxx | 2 +- .../Geometric2D/InterpKernelGeo2DEdgeLin.cxx | 2 +- .../Geometric2D/InterpKernelGeo2DEdgeLin.hxx | 2 +- .../InterpKernelGeo2DElementaryEdge.cxx | 2 +- .../InterpKernelGeo2DElementaryEdge.hxx | 2 +- .../Geometric2D/InterpKernelGeo2DNode.cxx | 7 ++-- .../Geometric2D/InterpKernelGeo2DNode.hxx | 4 +- .../InterpKernelGeo2DQuadraticPolygon.cxx | 14 +++---- src/MEDCoupling/MEDCouplingUMesh.cxx | 37 ++++++++++--------- 11 files changed, 40 insertions(+), 36 deletions(-) diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdge.hxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdge.hxx index 0c539f596..16c7c5e79 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdge.hxx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdge.hxx @@ -260,7 +260,7 @@ namespace INTERP_KERNEL virtual void fillGlobalInfoAbs(bool direction, const std::map& mapThis, const std::map& mapOther, int offset1, int offset2, double fact, double baryX, double baryY, std::vector& edgesThis, std::vector& addCoo, std::map mapAddCoo) const = 0; virtual void fillGlobalInfoAbs2(const std::map& mapThis, const std::map& mapOther, int offset1, int offset2, double fact, double baryX, double baryY, - std::vector& edgesOther, std::vector& addCoo, std::map mapAddCoo) const = 0; + std::vector& edgesOther, std::vector& addCoo, std::map& mapAddCoo) const = 0; virtual void sortIdsAbs(const std::vector& addNodes, const std::map& mapp1, const std::map& mapp2, std::vector& edgesThis) = 0; protected: Edge():_cnt(1),_loc(FULL_UNKNOWN),_start(0),_end(0) { } diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdgeArcCircle.cxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdgeArcCircle.cxx index fc978933b..06e2d053b 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdgeArcCircle.cxx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdgeArcCircle.cxx @@ -714,7 +714,7 @@ void EdgeArcCircle::fillGlobalInfoAbs(bool direction, const std::map& mapThis, const std::map& mapOther, int offset1, int offset2, double fact, double baryX, double baryY, - std::vector& edgesOther, std::vector& addCoo, std::map mapAddCoo) const + std::vector& edgesOther, std::vector& addCoo, std::map& mapAddCoo) const { _start->fillGlobalInfoAbs2(mapThis,mapOther,offset1,offset2,fact,baryX,baryY,addCoo,mapAddCoo,edgesOther); _end->fillGlobalInfoAbs2(mapThis,mapOther,offset1,offset2,fact,baryX,baryY,addCoo,mapAddCoo,edgesOther); diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdgeArcCircle.hxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdgeArcCircle.hxx index 5d2e80f5f..e7397c71a 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdgeArcCircle.hxx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdgeArcCircle.hxx @@ -114,7 +114,7 @@ namespace INTERP_KERNEL void fillGlobalInfoAbs(bool direction, const std::map& mapThis, const std::map& mapOther, int offset1, int offset2, double fact, double baryX, double baryY, std::vector& edgesThis, std::vector& addCoo, std::map mapAddCoo) const; void fillGlobalInfoAbs2(const std::map& mapThis, const std::map& mapOther, int offset1, int offset2, double fact, double baryX, double baryY, - std::vector& edgesOther, std::vector& addCoo, std::map mapAddCoo) const; + std::vector& edgesOther, std::vector& addCoo, std::map& mapAddCoo) const; void sortIdsAbs(const std::vector& addNodes, const std::map& mapp1, const std::map& mapp2, std::vector& edgesThis); protected: //!Value between -2Pi and 2Pi diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdgeLin.cxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdgeLin.cxx index e31aa3cc5..0b883b3b8 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdgeLin.cxx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdgeLin.cxx @@ -313,7 +313,7 @@ void EdgeLin::fillGlobalInfoAbs(bool direction, const std::map& mapThis, const std::map& mapOther, int offset1, int offset2, double fact, double baryX, double baryY, - std::vector& edgesOther, std::vector& addCoo, std::map mapAddCoo) const + std::vector& edgesOther, std::vector& addCoo, std::map& mapAddCoo) const { _start->fillGlobalInfoAbs2(mapThis,mapOther,offset1,offset2,fact,baryX,baryY,addCoo,mapAddCoo,edgesOther); _end->fillGlobalInfoAbs2(mapThis,mapOther,offset1,offset2,fact,baryX,baryY,addCoo,mapAddCoo,edgesOther); diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdgeLin.hxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdgeLin.hxx index 1c7e901dd..715ac0328 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdgeLin.hxx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdgeLin.hxx @@ -77,7 +77,7 @@ namespace INTERP_KERNEL void fillGlobalInfoAbs(bool direction, const std::map& mapThis, const std::map& mapOther, int offset1, int offset2, double fact, double baryX, double baryY, std::vector& edgesThis, std::vector& addCoo, std::map mapAddCoo) const; void fillGlobalInfoAbs2(const std::map& mapThis, const std::map& mapOther, int offset1, int offset2, double fact, double baryX, double baryY, - std::vector& edgesOther, std::vector& addCoo, std::map mapAddCoo) const; + std::vector& edgesOther, std::vector& addCoo, std::map& mapAddCoo) const; void sortIdsAbs(const std::vector& addNodes, const std::map& mapp1, const std::map& mapp2, std::vector& edgesThis); }; } diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DElementaryEdge.cxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DElementaryEdge.cxx index ff5a98a4f..0294997f2 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DElementaryEdge.cxx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DElementaryEdge.cxx @@ -215,7 +215,7 @@ void ElementaryEdge::fillGlobalInfoAbs(const std::map * unsorted because the "other" mesh is not subdivided yet. */ void ElementaryEdge::fillGlobalInfoAbs2(const std::map& mapThis, const std::map& mapOther, int offset1, int offset2, double fact, double baryX, double baryY, - std::vector& edgesOther, std::vector& addCoo, std::map mapAddCoo) const + std::vector& edgesOther, std::vector& addCoo, std::map& mapAddCoo) const { _ptr->fillGlobalInfoAbs2(mapThis,mapOther,offset1,offset2,fact,baryX,baryY,edgesOther,addCoo,mapAddCoo); } diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DElementaryEdge.hxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DElementaryEdge.hxx index 5a23a6d96..7c0fb77dc 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DElementaryEdge.hxx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DElementaryEdge.hxx @@ -69,7 +69,7 @@ namespace INTERP_KERNEL void fillGlobalInfoAbs(const std::map& mapThis, const std::map& mapOther, int offset1, int offset2, double fact, double baryX, double baryY, std::vector& edgesThis, std::vector& addCoo, std::map mapAddCoo) const; void fillGlobalInfoAbs2(const std::map& mapThis, const std::map& mapOther, int offset1, int offset2, double fact, double baryX, double baryY, - std::vector& edgesOther, std::vector& addCoo, std::map mapAddCoo) const; + std::vector& edgesOther, std::vector& addCoo, std::map& mapAddCoo) const; static ElementaryEdge *BuildEdgeFromCrudeDataArray(bool isQuad, bool direction, INTERP_KERNEL::Node *start, INTERP_KERNEL::Node *end); private: bool _direction; diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DNode.cxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DNode.cxx index 7e336ade2..a62faf266 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DNode.cxx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DNode.cxx @@ -135,7 +135,7 @@ void Node::applySimilarity(double xBary, double yBary, double dimChar) * Called by QuadraticPolygon::splitAbs method. */ void Node::fillGlobalInfoAbs(const std::map& mapThis, const std::map& mapOther, int offset1, int offset2, double fact, double baryX, double baryY, - std::vector& addCoo, std::map mapAddCoo, int *nodeId) const + std::vector& addCoo, std::map& mapAddCoo, int *nodeId) const { std::map::const_iterator it=mapThis.find(const_cast(this)); if(it!=mapThis.end()) @@ -157,7 +157,8 @@ void Node::fillGlobalInfoAbs(const std::map& mapThis, } int id=addCoo.size()/2; addCoo.push_back(fact*_coords[0]+baryX); - addCoo.push_back(fact*_coords[0]+baryX); + addCoo.push_back(fact*_coords[1]+baryY); + *nodeId=offset2+id; mapAddCoo[const_cast(this)]=offset2+id; } @@ -165,7 +166,7 @@ void Node::fillGlobalInfoAbs(const std::map& mapThis, * Called by QuadraticPolygon::splitAbs method. */ void Node::fillGlobalInfoAbs2(const std::map& mapThis, const std::map& mapOther, int offset1, int offset2, double fact, double baryX, double baryY, - std::vector& addCoo, std::map mapAddCoo, std::vector& pointsOther) const + std::vector& addCoo, std::map& mapAddCoo, std::vector& pointsOther) const { int tmp; std::size_t sz1=addCoo.size(); diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DNode.hxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DNode.hxx index c8ed49e8b..f7585596c 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DNode.hxx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DNode.hxx @@ -86,9 +86,9 @@ namespace INTERP_KERNEL static double distanceBtw2PtSq(const double *a, const double *b) { return (a[0]-b[0])*(a[0]-b[0])+(a[1]-b[1])*(a[1]-b[1]); } // void fillGlobalInfoAbs(const std::map& mapThis, const std::map& mapOther, int offset1, int offset2, double fact, double baryX, double baryY, - std::vector& addCoo, std::map mapAddCoo, int *nodeId) const; + std::vector& addCoo, std::map& mapAddCoo, int *nodeId) const; void fillGlobalInfoAbs2(const std::map& mapThis, const std::map& mapOther, int offset1, int offset2, double fact, double baryX, double baryY, - std::vector& addCoo, std::map mapAddCoo, std::vector& pointsOther) const; + std::vector& addCoo, std::map& mapAddCoo, std::vector& pointsOther) const; protected: ~Node(); protected: diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DQuadraticPolygon.cxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DQuadraticPolygon.cxx index 845e9fc5d..b3a04d0d4 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DQuadraticPolygon.cxx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DQuadraticPolygon.cxx @@ -235,7 +235,7 @@ void QuadraticPolygon::splitAbs(QuadraticPolygon& other, const std::mapgetPtr(),curE3->getDirection())); curE3->getPtr()->incrRef(); IteratorOnComposedEdge it2(&otherTmp); - for(it2.first();it2.finished();it2.next()) + for(it2.first();!it2.finished();it2.next()) { ElementaryEdge* curE2=it2.current(); if(!curE2->isThereStartPoint()) @@ -297,11 +297,11 @@ void QuadraticPolygon::buildFromCrudeDataArray(const std::map0; int edgeId=abs(descBg[i])-1; const std::vector& subEdge=intersectEdges[edgeId]; - int nbOfSubEdges=subEdge.size()-1; + int nbOfSubEdges=subEdge.size()/2; for(int j=0;j& mapp, std::vector& conn, std::vector& connI) { int nbOfNodesInPg=0,i=0; + conn.push_back(5); for(std::list::const_iterator it=_sub_edges.begin();it!=_sub_edges.end();it++,i++) { Node *tmp=0; @@ -326,7 +327,7 @@ void QuadraticPolygon::appendCrudeData(const std::map conn.push_back((*it).second); nbOfNodesInPg++; } - connI.push_back(connI.back()+nbOfNodesInPg); + connI.push_back(connI.back()+nbOfNodesInPg+1); } /*! @@ -339,8 +340,7 @@ void QuadraticPolygon::buildPartitionsAbs(QuadraticPolygon& other, const std::ma normalizeExt(&other, xBaryBB, yBaryBB); //Locate 'this' relative to 'other' other.performLocatingOperation(*this); - dumpInXfigFileWithOther(other,"tony.fig"); - std::vector res=other.buildIntersectionPolygons(*this,other); + std::vector res=buildIntersectionPolygons(other,*this); for(std::vector::iterator it=res.begin();it!=res.end();it++) { (*it)->appendCrudeData(mapp,conn,connI); diff --git a/src/MEDCoupling/MEDCouplingUMesh.cxx b/src/MEDCoupling/MEDCouplingUMesh.cxx index 907ef66b3..aaf569e10 100644 --- a/src/MEDCoupling/MEDCouplingUMesh.cxx +++ b/src/MEDCoupling/MEDCouplingUMesh.cxx @@ -2575,18 +2575,21 @@ namespace ParaMEDMEM int eltId2=abs(*desc2)-1; for(std::vector::const_iterator it2=intesctEdges2[eltId2].begin();it2!=intesctEdges2[eltId2].end();it2++) { - std::map::const_iterator it=mappRev.find(*it2); + int curNodeId2=*it2; + std::map::const_iterator it=mappRev.find(curNodeId2); if(it==mappRev.end()) { - INTERP_KERNEL::Node *node=MEDCouplingUMeshBuildQPNode(*it2,coo1,offset1,coo2,offset2,addCoo); - mapp[node]=*it2; - mappRev[*it2]=node; + INTERP_KERNEL::Node *node=MEDCouplingUMeshBuildQPNode(curNodeId2,coo1,offset1,coo2,offset2,addCoo); + mapp[node]=curNodeId2; + mappRev[curNodeId2]=node; } } } // pol1.buildFromCrudeDataArray(mappRev,isQuad1,desc1Bg,desc1End,intesctEdges1); pol2.buildFromCrudeDataArray(mappRev,isQuad2,desc2Bg,desc2End,intesctEdges2); + for(std::map::const_iterator it=mappRev.begin();it!=mappRev.end();it++) + (*it).second->decrRef(); } } @@ -4777,7 +4780,6 @@ std::string MEDCouplingUMesh::getVTKDataSetType() const throw(INTERP_KERNEL::Exc MEDCouplingUMesh *MEDCouplingUMesh::Intersect2DMeshes(const MEDCouplingUMesh *m1, const MEDCouplingUMesh *m2, double eps, DataArrayInt *&cellNb1, DataArrayInt *&cellNb2) throw(INTERP_KERNEL::Exception) { - throw INTERP_KERNEL::Exception("MEDCouplingUMesh::Intersect2DMeshes : functionnality not finished yet ! Will come soon !"); std::vector< std::vector > intersectEdge1, subDiv2; MEDCouplingUMesh *m1Desc=0,*m2Desc=0; DataArrayInt *desc1=0,*descIndx1=0,*revDesc1=0,*revDescIndx1=0,*desc2=0,*descIndx2=0,*revDesc2=0,*revDescIndx2=0; @@ -4795,8 +4797,7 @@ MEDCouplingUMesh *MEDCouplingUMesh::Intersect2DMeshes(const MEDCouplingUMesh *m1 std::vector cNb1,cNb2; BuildIntersecting2DCellsFromEdges(eps,m1,b1,desc1->getConstPointer(),descIndx1->getConstPointer(),intersectEdge1,m2,b2,desc2->getConstPointer(),descIndx2->getConstPointer(),intersectEdge2,addCoo, /* outputs -> */cr,crI,cNb1,cNb2); -#if 0 - //tony + // MEDCouplingAutoRefCountObjectPtr addCooDa=DataArrayDouble::New(); addCooDa->alloc(addCoo.size()/2,2); std::copy(addCoo.begin(),addCoo.end(),addCooDa->getPointer()); @@ -4810,11 +4811,8 @@ MEDCouplingUMesh *MEDCouplingUMesh::Intersect2DMeshes(const MEDCouplingUMesh *m1 MEDCouplingAutoRefCountObjectPtr c2=DataArrayInt::New(); c2->alloc(cNb2.size(),1); std::copy(cNb2.begin(),cNb2.end(),c2->getPointer()); cellNb2=c2; ret->setConnectivity(conn,connI,true); ret->setCoords(coo); - ret->incrRef(); c1->incrRef(); c2->incrRef(); + ret->incrRef(); c1->incrRef(); c2->incrRef(); desc1->decrRef(); descIndx1->decrRef(); desc2->decrRef(); descIndx2->decrRef(); return ret; -#endif - desc1->decrRef(); descIndx1->decrRef(); desc2->decrRef(); descIndx2->decrRef(); - return 0; } /// @endcond @@ -4867,6 +4865,8 @@ void MEDCouplingUMesh::IntersectDescending2DMeshes(const MEDCouplingUMesh *m1, c desc2=DataArrayInt::New(); descIndx2=DataArrayInt::New(); revDesc2=DataArrayInt::New(); revDescIndx2=DataArrayInt::New(); m1Desc=m1->buildDescendingConnectivity2(desc1,descIndx1,revDesc1,revDescIndx1); m2Desc=m2->buildDescendingConnectivity2(desc2,descIndx2,revDesc2,revDescIndx2); + const int *c1=m1Desc->getNodalConnectivity()->getConstPointer(); + const int *ci1=m1Desc->getNodalConnectivityIndex()->getConstPointer(); std::vector bbox1,bbox2; m1Desc->getBoundingBoxForBBTree(bbox1); m2Desc->getBoundingBoxForBBTree(bbox2); @@ -4886,11 +4886,14 @@ void MEDCouplingUMesh::IntersectDescending2DMeshes(const MEDCouplingUMesh *m1, c { std::map map1,map2; INTERP_KERNEL::QuadraticPolygon *pol2=MEDCouplingUMeshBuildQPFromMesh(m2Desc,candidates2,map2); + candidates1[0]=i; INTERP_KERNEL::QuadraticPolygon *pol1=MEDCouplingUMeshBuildQPFromMesh(m1Desc,candidates1,map1); pol1->splitAbs(*pol2,map1,map2,offset1,offset2,candidates2,intersectEdge1[i],subDiv2,addCoo); delete pol2; delete pol1; } + else + intersectEdge1[i].insert(intersectEdge1[i].end(),c1+ci1[i]+1,c1+ci1[i+1]); } } @@ -4899,7 +4902,7 @@ void MEDCouplingUMesh::IntersectDescending2DMeshes(const MEDCouplingUMesh *m1, c * This method has 4 inputs : * - a mesh 'm1' with meshDim==1 and a SpaceDim==2 * - a mesh 'm2' with meshDim==1 and a SpaceDim==2 - * - subDiv of size 'm->getNumberOfCells()' that lists for each seg cell in 'm' the splitting node ids in randomly sorted. + * - subDiv of size 'm2->getNumberOfCells()' that lists for each seg cell in 'm' the splitting node ids in randomly sorted. * The aim of this method is to sort the splitting nodes, if any, and to put in 'intersectEdge' output paramter based on edges of mesh 'm2' * @param m1 is expected to be a mesh of meshDimension equal to 1 and spaceDim equal to 2. No check of that is performed by this method. Only present for its coords in case of 'subDiv' shares some nodes of 'm1' * @param m2 is expected to be a mesh of meshDimension equal to 1 and spaceDim equal to 2. No check of that is performed by this method. @@ -4907,13 +4910,13 @@ void MEDCouplingUMesh::IntersectDescending2DMeshes(const MEDCouplingUMesh *m1, c */ void MEDCouplingUMesh::BuildIntersectEdges(const MEDCouplingUMesh *m1, const MEDCouplingUMesh *m2, const std::vector& addCoo, const std::vector< std::vector >& subDiv, std::vector< std::vector >& intersectEdge) throw(INTERP_KERNEL::Exception) { - int offset1=m1->getNumberOfCells(); + int offset1=m1->getNumberOfNodes(); int ncell=m2->getNumberOfCells(); const int *c=m2->getNodalConnectivity()->getConstPointer(); const int *cI=m2->getNodalConnectivityIndex()->getConstPointer(); const double *coo=m2->getCoords()->getConstPointer(); const double *cooBis=m1->getCoords()->getConstPointer(); - int offset2=offset1+ncell; + int offset2=offset1+m2->getNumberOfNodes(); intersectEdge.resize(ncell); for(int i=0;i::const_iterator it=mapp2.begin();it!=mapp2.end();it++) (*it).second->decrRef(); std::vector addNodes(divs.size()); std::map mapp3; - for(std::size_t j=0;j