diff --git a/src/BRepExtrema/BRepExtrema_DistanceSS.cxx b/src/BRepExtrema/BRepExtrema_DistanceSS.cxx index e81108b794..c287d05ba3 100644 --- a/src/BRepExtrema/BRepExtrema_DistanceSS.cxx +++ b/src/BRepExtrema/BRepExtrema_DistanceSS.cxx @@ -468,7 +468,14 @@ static void PERFORM_C0(const TopoDS_Edge& S1, const TopoDS_Edge& S2, if (fabs(Dstmin - sqrt(Ext.SquareDistance(ii))) < Eps) { Pt = Ext.Point(ii); - if (TRI_SOLUTION(SeqSol2, Pt)) + // Pt - point on the curve pCurvOther/Eother, but + // if iE == 0 -> Eother correspond to edge S2 + // and to edge S1 in the opposite case. + // Therefore we should search Pt through previous solution points on Other curve (edge): + // if iE == 0 - on edge S2, namely through SeqSol2, + // else - on edge S1, namely through SeqSol1. + const bool triSolutionResult = (iE == 0) ? TRI_SOLUTION(SeqSol2, Pt) : TRI_SOLUTION(SeqSol1, Pt); + if (triSolutionResult) { // Check if the parameter does not correspond to a vertex const Standard_Real t = Ext.Parameter(ii); @@ -869,9 +876,19 @@ void BRepExtrema_DistanceSS::Perform (const TopoDS_Edge& theS1, if (!seqSol1.IsEmpty() && !seqSol2.IsEmpty()) { - theSeqSolShape1.Append(seqSol1); - theSeqSolShape2.Append(seqSol2); - myModif = Standard_True; + BRepExtrema_SeqOfSolution::iterator anIt1 = seqSol1.begin(); + BRepExtrema_SeqOfSolution::iterator anIt2 = seqSol2.begin(); + for (; anIt1 != seqSol1.end() && anIt2 != seqSol2.end(); anIt1++, anIt2++) + { + gp_Pnt Pt1 = anIt1->Point(); + gp_Pnt Pt2 = anIt2->Point(); + if (TRI_SOLUTION(theSeqSolShape1, Pt1) || TRI_SOLUTION(theSeqSolShape2, Pt2)) + { + theSeqSolShape1.Append(*anIt1); + theSeqSolShape2.Append(*anIt2); + myModif = Standard_True; + } + } } } diff --git a/tests/bugs/modalg_7/bug32934 b/tests/bugs/modalg_7/bug32934 new file mode 100644 index 0000000000..461317494c --- /dev/null +++ b/tests/bugs/modalg_7/bug32934 @@ -0,0 +1,25 @@ +puts "========" +puts "OCC32934" +puts "========" +puts "" +############################################################################################### +# BRepExtrema_DistShapeShape BRepExtrema_DistShapeShape returns two solutions instead of one. +############################################################################################### + +pload ALL +restore [locate_data_file bug32934.brep] edges +explode edges E + +distmini di edges_1 edges_2 +if { ([isdraw di2]) } { + puts "Error : result of distmini is wrong" +} else { + checknbshapes di -vertex 1 -edge 0 +} + +distmini dii edges_2 edges_1 +if { ([isdraw dii2]) } { + puts "Error : result of distmini is wrong" +} else { + checknbshapes dii -vertex 1 -edge 0 +}