From: abn Date: Mon, 9 Apr 2018 15:45:42 +0000 (+0200) Subject: Backport from 8.5: X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=841708949adc4d2fcadedb2bf1ca5d118ae240f8;p=tools%2Fmedcoupling.git Backport from 8.5: [43cbbcc0fc]: Bug fix in colinearize2D(): last seg not handled properly. [305e7a338]: Bug fix: Intersect2DMeshWith1DLine now correctly handling closed lines ... --- diff --git a/src/MEDCoupling/MEDCouplingUMesh.cxx b/src/MEDCoupling/MEDCouplingUMesh.cxx index 8c8f1a49f..d07cfce0d 100644 --- a/src/MEDCoupling/MEDCouplingUMesh.cxx +++ b/src/MEDCoupling/MEDCouplingUMesh.cxx @@ -9385,7 +9385,7 @@ void BuildMesh2DCutInternal2(const MEDCouplingUMesh *splitMesh1D, const std::vec const int *cSplitPtr(splitMesh1D->getNodalConnectivity()->begin()),*ciSplitPtr(splitMesh1D->getNodalConnectivityIndex()->begin()); for(ii=0;ii single output cell out0.resize(1); out1.resize(1); @@ -9679,7 +9679,7 @@ CellInfo& VectorOfCellInfo::get(int pos) * * \param [in] allEdges a list of pairs (beginNode, endNode). Linked with \a allEdgesPtr to get the equation of edge. */ -MEDCouplingUMesh *BuildMesh2DCutInternal(double eps, const MEDCouplingUMesh *splitMesh1D, const std::vector& allEdges, const std::vector< MEDCouplingAutoRefCountObjectPtr >& allEdgesPtr, int offset, +MEDCouplingUMesh *BuildMesh2DCutInternal(double eps, MEDCouplingUMesh *splitMesh1D, const std::vector& allEdges, const std::vector< MEDCouplingAutoRefCountObjectPtr >& allEdgesPtr, int offset, MEDCouplingAutoRefCountObjectPtr& idsLeftRight) { int nbCellsInSplitMesh1D(splitMesh1D->getNumberOfCells()); @@ -9699,6 +9699,33 @@ MEDCouplingUMesh *BuildMesh2DCutInternal(double eps, const MEDCouplingUMesh *spl idsLeftRight=DataArrayInt::New(); idsLeftRight->alloc(nbCellsInSplitMesh1D*2); idsLeftRight->fillWithValue(-2); idsLeftRight->rearrange(2); int *idsLeftRightPtr(idsLeftRight->getPointer()); VectorOfCellInfo pool(edge1Bis,edge1BisPtr); + + // Compute contiguous parts of splitMesh1D. We can not make the full assumption that segments are consecutive in the connectivity + // (even if the user correctly called orderConsecutiveCells1D()). Indeed the tool might be a closed line whose junction point is in + // splitMesh1D. There can be only one such a point, and if this happens this is necessarily at the start + // of the connectivity. + MEDCouplingAutoRefCountObjectPtr renumb(DataArrayInt::New()); + renumb->alloc(nbCellsInSplitMesh1D,1); + const int * renumbP(renumb->begin()); + + int i, first=cSplitPtr[1]; + // Follow 1D line backward as long as it is connected: + for (i=nbCellsInSplitMesh1D-1; cSplitPtr[ciSplitPtr[i]+2] == first; i--) + first=cSplitPtr[ciSplitPtr[i]+1]; + if (i < nbCellsInSplitMesh1D-1) + { + // Build circular permutation to shift consecutive edges together + renumb->iota(i+1); + renumb->applyModulus(nbCellsInSplitMesh1D); + splitMesh1D->renumberCells(renumbP, false); + cSplitPtr = splitMesh1D->getNodalConnectivity()->begin(); + ciSplitPtr = splitMesh1D->getNodalConnectivityIndex()->begin(); + } + else + renumb->iota(); + // + + for(int iStart=0;iStart >& intersectEdge1, int offset, MEDCouplingAutoRefCountObjectPtr& idsLeftRight) { @@ -11668,7 +11695,7 @@ void EnterTheResultOf2DCellEnd(const INTERP_KERNEL::Edge *e, int start, int stp, { if(stp-start>1) { - int tmpSrt(connBg[start]),tmpEnd(connBg[stp]); + int tmpSrt(connBg[start]),tmpEnd(connBg[stp % nbOfEdges]); int tmp2(0),tmp3(appendedCoords->getNumberOfTuples()/2); InternalAddPointOriented(e,-1,coords,tmpSrt,tmpEnd,*appendedCoords,tmp2); middles.push_back(tmp3+offset);