From: ageay Date: Fri, 30 Sep 2011 10:55:08 +0000 (+0000) Subject: Improvement of actual implementation of intersectWithAbs1D X-Git-Tag: V6_main_FINAL~939 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=de287404644d1e73754c29aa7035fcc645ac72fc;p=tools%2Fmedcoupling.git Improvement of actual implementation of intersectWithAbs1D --- diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DQuadraticPolygon.cxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DQuadraticPolygon.cxx index 4efc349d4..d66bdae4e 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DQuadraticPolygon.cxx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DQuadraticPolygon.cxx @@ -209,6 +209,7 @@ double QuadraticPolygon::intersectWithAbs(QuadraticPolygon& other) /*! * Warning This method is \b NOT const. 'this' and 'other' are modified after call of this method. + * 'other' is a QuadraticPolygon of \b non closed edges. */ double QuadraticPolygon::intersectWithAbs1D(QuadraticPolygon& other, bool& isColinear) { @@ -221,23 +222,28 @@ double QuadraticPolygon::intersectWithAbs1D(QuadraticPolygon& other, bool& isCol splitPolygonsEachOther(cpyOfThis, cpyOfOther, nbOfSplits); //At this point cpyOfThis and cpyOfOther have been splited at maximum edge so that in/out can been done. performLocatingOperation(cpyOfOther); - - std::list cpyOfOtherZip = cpyOfOther.zipConsecutiveInSegments(); - isColinear = false; - if (cpyOfOtherZip.size() == 1) - { - QuadraticPolygon& poly = *cpyOfOtherZip.front(); - if (poly.size() == 2 && poly.front()->isEqual(*poly.back())) - isColinear = true; - } - - for (std::list::iterator iter = cpyOfOtherZip.begin(); iter != cpyOfOtherZip.end(); iter++) + for(std::list::const_iterator it=cpyOfOther._sub_edges.begin();it!=cpyOfOther._sub_edges.end();it++) { - ret += fabs((*iter)->getPerimeter()); - delete *iter; + switch((*it)->getLoc()) + { + case FULL_IN_1: + { + ret += fabs((*it)->getPtr()->getCurveLength()); + break; + } + case FULL_ON_1: + { + isColinear=true; + ret += fabs((*it)->getPtr()->getCurveLength()); + break; + } + default: + { + } + } } - return ret * fact / 2.; + return ret * fact; } /*! diff --git a/src/INTERP_KERNEL/Geometric2DIntersector.hxx b/src/INTERP_KERNEL/Geometric2DIntersector.hxx index 4385e7046..f62625105 100644 --- a/src/INTERP_KERNEL/Geometric2DIntersector.hxx +++ b/src/INTERP_KERNEL/Geometric2DIntersector.hxx @@ -49,6 +49,7 @@ namespace INTERP_KERNEL double intersectGeoBary(const std::vector& targetCell, bool targetCellQuadratic, const double *sourceCell, std::vector& res); private: QuadraticPolygon *buildPolygonFrom(const std::vector& coords, NormalizedCellType type); + QuadraticPolygon *buildPolygonOfOneEdgeFrom(const std::vector& coords, NormalizedCellType type); QuadraticPolygon *buildPolygonAFrom(ConnType cell, int nbOfPoints, NormalizedCellType type); QuadraticPolygon *buildPolygonBFrom(ConnType cell, int nbOfPoints, NormalizedCellType type); }; diff --git a/src/INTERP_KERNEL/Geometric2DIntersector.txx b/src/INTERP_KERNEL/Geometric2DIntersector.txx index 7f12f5b63..d1fd6b09c 100644 --- a/src/INTERP_KERNEL/Geometric2DIntersector.txx +++ b/src/INTERP_KERNEL/Geometric2DIntersector.txx @@ -76,7 +76,7 @@ namespace INTERP_KERNEL NormalizedCellType tT=PlanarIntersector::_meshT.getTypeOfElement(icellT); NormalizedCellType tS=PlanarIntersector::_meshS.getTypeOfElement(icellS); QuadraticPolygon *p1=buildPolygonFrom(CoordsT,tT); - QuadraticPolygon *p2=buildPolygonFrom(CoordsS,tS); + QuadraticPolygon *p2=buildPolygonOfOneEdgeFrom(CoordsS,tS); double ret=p1->intersectWithAbs1D(*p2, isColinear); delete p1; delete p2; return ret; @@ -191,6 +191,32 @@ namespace INTERP_KERNEL return QuadraticPolygon::buildArcCirclePolygon(nodes); } + INTERSECTOR_TEMPLATE + QuadraticPolygon *GEO2D_INTERSECTOR::buildPolygonOfOneEdgeFrom(const std::vector& coords, NormalizedCellType type) + { + if(type==NORM_SEG2) + { + Node *node0=new Node(coords[0],coords[1]); + Node *node1=new Node(coords[SPACEDIM],coords[SPACEDIM+1]); + QuadraticPolygon *ret=new QuadraticPolygon; + ret->pushBack(new EdgeLin(node0,node1)); + node0->decrRef(); node1->decrRef(); + return ret; + } + else if(type==NORM_SEG3) + { + Node *nodeBg=new Node(coords[0],coords[1]); + Node *nodeEnd=new Node(coords[SPACEDIM],coords[SPACEDIM+1]); + Node *nodeMiddle=new Node(coords[2*SPACEDIM],coords[2*SPACEDIM+1]); + QuadraticPolygon *ret=new QuadraticPolygon; + ret->pushBack(new EdgeArcCircle(nodeBg,nodeMiddle,nodeEnd)); + nodeBg->decrRef(); nodeEnd->decrRef(); nodeMiddle->decrRef(); + return ret; + } + else + throw INTERP_KERNEL::Exception("buildPolygonOfOneEdgeFrom : trying to build such non close QuadraticPolygon with 1D type !"); + } + INTERSECTOR_TEMPLATE QuadraticPolygon *GEO2D_INTERSECTOR::buildPolygonAFrom(ConnType cell, int nbOfPoints, NormalizedCellType type) {