diff --git a/src/ShapeUpgrade/ShapeUpgrade_UnifySameDomain.cxx b/src/ShapeUpgrade/ShapeUpgrade_UnifySameDomain.cxx index 4a30612dc6..48d75e2b86 100644 --- a/src/ShapeUpgrade/ShapeUpgrade_UnifySameDomain.cxx +++ b/src/ShapeUpgrade/ShapeUpgrade_UnifySameDomain.cxx @@ -849,12 +849,20 @@ static Standard_Boolean IsMergingPossible(const TopoDS_Edge& edge1, const TopoDS if (theLineDirectionOk && t2 == GeomAbs_Line) { + // Check that the accumulated deflection does not exceed the linear tolerance Standard_Real aLast = (edge2.Orientation() == TopAbs_FORWARD) ? ade2.LastParameter() : ade2.FirstParameter(); gp_Vec aCurV(theFirstPoint, ade2.Value(aLast)); Standard_Real aDD = theDirectionVec.CrossSquareMagnitude(aCurV); if (aDD > theLinTol*theLinTol) return Standard_False; + + // Check that the accumulated angle does not exceed the angular tolerance. + // For symmetry, check the angle between vectors of: + // - first edge and resulting curve, and + // - the last edge and resulting curve. + if (theDirectionVec.Angle(aCurV) > theAngTol || Diff2.Angle(aCurV) > theAngTol) + return Standard_False; } return Standard_True; diff --git a/tests/bugs/modalg_7/bug29845 b/tests/bugs/modalg_7/bug29845 new file mode 100644 index 0000000000..e598d20a7b --- /dev/null +++ b/tests/bugs/modalg_7/bug29845 @@ -0,0 +1,21 @@ +puts "========" +puts "OCC29845:UnifySameDomain does not account the accumulated angle when unifying edges" +puts "========" +puts "" + +brestore [locate_data_file bug29845_wire.brep] w + +# set the linear deflection very high, so the unification +# will be controlled by the angular deflection only. +# with the angular deflection of 5 degrees the resulting +# wire should preserve all the features of the original wire + +unifysamedom result w -t 10000 -a 5 +checkshape result +checknbshapes result -vertex 77 -edge 77 +checkprops result -l 2805.11 + +smallview +X+Z +don result +fit +checkview -screenshot -2d -path ${imagedir}/${test_image}.png