From e25185fff00ab370800b0af074313ca0c728731b Mon Sep 17 00:00:00 2001 From: emv Date: Mon, 25 Dec 2017 11:47:53 +0300 Subject: [PATCH] 0029400: Fuse of two edges creates self-interfered shape Avoid creation of the edges with too small valid range (not allowing to split the edge) and interfering vertices. Test case for the issue. --- src/BOPAlgo/BOPAlgo_PaveFiller_2.cxx | 31 +++++++++++++++++++++++----- tests/bugs/modalg_7/bug29400 | 21 +++++++++++++++++++ 2 files changed, 47 insertions(+), 5 deletions(-) create mode 100644 tests/bugs/modalg_7/bug29400 diff --git a/src/BOPAlgo/BOPAlgo_PaveFiller_2.cxx b/src/BOPAlgo/BOPAlgo_PaveFiller_2.cxx index cea0789dd3..3ba7b42492 100644 --- a/src/BOPAlgo/BOPAlgo_PaveFiller_2.cxx +++ b/src/BOPAlgo/BOPAlgo_PaveFiller_2.cxx @@ -392,21 +392,42 @@ void BOPAlgo_PaveFiller::SplitPaveBlocks(const TColStd_MapOfInteger& theMEdges, myDS->UpdatePaveBlockWithSDVertices(aPBN); FillShrunkData(aPBN); // - if (!aPBN->HasShrunkData()) { - // No valid range, unify vertices + Standard_Boolean bHasValidRange = aPBN->HasShrunkData(); + // Take into account that the edge could have really small valid range, + // so that the Pave Block cannot be further split. In this case, check if + // the vertices of the Pave Block do not interfere. And if they are, unify them. + Standard_Boolean bCheckDist = (bHasValidRange && !aPBN->IsSplittable()); + if (!bHasValidRange || bCheckDist) + { Standard_Integer nV1, nV2; aPBN->Indices(nV1, nV2); - if (nV1 != nV2) { + if (nV1 == nV2) + // Same vertices -> no valid range, no need to unify vertices + continue; + + // Decide whether to unify vertices or not + if (bCheckDist) + { + const TopoDS_Vertex& aV1 = TopoDS::Vertex(myDS->Shape(nV1)); + const TopoDS_Vertex& aV2 = TopoDS::Vertex(myDS->Shape(nV2)); + if (BOPTools_AlgoTools::ComputeVV(aV1, aV2, myFuzzyValue) == 0) + // vertices are interfering -> no valid range, unify vertices + bHasValidRange = Standard_False; + } + + if (!bHasValidRange) + { BOPDS_Pair aPair; aPair.SetIndices(nV1, nV2); - if (aMPairs.Add(aPair)) { + if (aMPairs.Add(aPair)) + { TColStd_ListOfInteger aLV; aLV.Append(nV1); aLV.Append(nV2); MakeSDVertices(aLV, theAddInterfs); } + continue; } - continue; } // // Update the list with new pave block diff --git a/tests/bugs/modalg_7/bug29400 b/tests/bugs/modalg_7/bug29400 new file mode 100644 index 0000000000..59ff3f00df --- /dev/null +++ b/tests/bugs/modalg_7/bug29400 @@ -0,0 +1,21 @@ +puts "========" +puts "OCC29400" +puts "========" +puts "" +################################################# +# Fuse of two edges creates self-interfered shape +################################################# + +restore [locate_data_file bug29400_edges.brep] le +bclearobjects +bcleartools +baddcompound le +bfillds +bbuild result + +checkshape result +checknbshapes result -vertex 3 -edge 2 +checkprops result -l 1.78839 +if {![regexp "OK" [bopcheck result]]} { + puts "Error: the result is self-interfered" +}