From cc9f45917302c0bf560f5c0c708d0bd6c28e3655 Mon Sep 17 00:00:00 2001 From: jgv Date: Wed, 10 Feb 2016 14:37:31 +0300 Subject: [PATCH] 0027134: Offset algorithm produces an invalid shape from a cone Correction of test case for issue CR27134 --- src/BRepOffset/BRepOffset_MakeOffset.cxx | 36 +++++++++++++----------- tests/bugs/modalg_6/bug27134 | 28 ++++++++++++++++++ 2 files changed, 47 insertions(+), 17 deletions(-) create mode 100644 tests/bugs/modalg_6/bug27134 diff --git a/src/BRepOffset/BRepOffset_MakeOffset.cxx b/src/BRepOffset/BRepOffset_MakeOffset.cxx index 15ad0a7c55..5cb57c01c6 100644 --- a/src/BRepOffset/BRepOffset_MakeOffset.cxx +++ b/src/BRepOffset/BRepOffset_MakeOffset.cxx @@ -2667,7 +2667,7 @@ void BRepOffset_MakeOffset::CorrectConicalFaces() break; } } - NewEdges.Append(FirstEdge); + NewEdges.Append(FirstEdge.Oriented(TopAbs_FORWARD)); TopoDS_Vertex Vf1, CurVertex; TopExp::Vertices(FirstEdge, Vf1, CurVertex); itl.Initialize(EdgesOfWire); @@ -2678,7 +2678,7 @@ void BRepOffset_MakeOffset::CorrectConicalFaces() TopExp::Vertices(anEdge, V1, V2); if (V1.IsSame(CurVertex) || V2.IsSame(CurVertex)) { - NewEdges.Append(anEdge); + NewEdges.Append(anEdge.Oriented(TopAbs_FORWARD)); CurVertex = (V1.IsSame(CurVertex))? V2 : V1; EdgesOfWire.Remove(itl); } @@ -2696,30 +2696,32 @@ void BRepOffset_MakeOffset::CorrectConicalFaces() Vfirst = -M_PI/2.; Vlast = p2d1.Y(); } TopoDS_Face NewSphericalFace = BRepLib_MakeFace(aSphSurf, Ufirst, Ulast, Vfirst, Vlast, Precision::Confusion()); - TopoDS_Edge OldEdge; + TopoDS_Edge OldEdge, DegEdge; + for (Explo.Init(NewSphericalFace, TopAbs_EDGE); Explo.More(); Explo.Next()) + { + DegEdge = TopoDS::Edge(Explo.Current()); + if (BRep_Tool::Degenerated(DegEdge)) + break; + } + TopoDS_Vertex DegVertex = TopExp::FirstVertex(DegEdge); for (Explo.Init(NewSphericalFace, TopAbs_EDGE); Explo.More(); Explo.Next()) { OldEdge = TopoDS::Edge(Explo.Current()); - if (!BRep_Tool::Degenerated(OldEdge)) - { - BRepAdaptor_Curve2d BAc2d(OldEdge, NewSphericalFace); - p2d1 = BAc2d.Value(BAc2d.FirstParameter()); - p2d2 = BAc2d.Value(BAc2d.LastParameter()); - if (Abs(p2d1.X() - Ufirst) <= Precision::Confusion() && - Abs(p2d2.X() - Ulast) <= Precision::Confusion()) - break; - } + TopoDS_Vertex V1, V2; + TopExp::Vertices(OldEdge, V1, V2); + if (!V1.IsSame(DegVertex) && !V2.IsSame(DegVertex)) + break; } TopoDS_Vertex V1, V2; TopExp::Vertices(OldEdge, V1, V2); TopTools_ListOfShape LV1, LV2; - LV1.Append(Vf1); - LV2.Append(CurVertex); + LV1.Append(Vf1.Oriented(TopAbs_FORWARD)); + LV2.Append(CurVertex.Oriented(TopAbs_FORWARD)); BRepTools_Substitution theSubstitutor; - theSubstitutor.Substitute(V1, LV1); + theSubstitutor.Substitute(V1.Oriented(TopAbs_FORWARD), LV1); if (!V1.IsSame(V2)) - theSubstitutor.Substitute(V2, LV2); - theSubstitutor.Substitute(OldEdge, NewEdges); + theSubstitutor.Substitute(V2.Oriented(TopAbs_FORWARD), LV2); + theSubstitutor.Substitute(OldEdge.Oriented(TopAbs_FORWARD), NewEdges); theSubstitutor.Build(NewSphericalFace); if (theSubstitutor.IsCopied(NewSphericalFace)) { diff --git a/tests/bugs/modalg_6/bug27134 b/tests/bugs/modalg_6/bug27134 new file mode 100644 index 0000000000..9919684559 --- /dev/null +++ b/tests/bugs/modalg_6/bug27134 @@ -0,0 +1,28 @@ +puts "============" +puts "OCC27134" +puts "============" +puts "" +###################################################### +# Offset algorithm produces an invalid shape from a cone +###################################################### + +smallview + +set expected_MaxTolerance 1.02470e-007 +set tol_abs_MaxTolerance 1.e-08 +set tol_rel_MaxTolerance 1.e-08 + +restore [locate_data_file bug27134_cone.brep] a +explode a f +donly a_1 +offsetshape res a_1 10 +fit + +checknbshapes res -vertex 5 -edge 7 -wire 2 -face 2 -shell 1 -solid 0 -compsolid 0 -compound 0 -shape 17 + +checkshape res + +regexp {Tolerance +MAX=([-0-9.+eE]+)} [tolerance res] full MaxTolerance +checkreal "MaxTolerance" ${MaxTolerance} ${expected_MaxTolerance} ${tol_abs_MaxTolerance} ${tol_rel_MaxTolerance} + +checkview -screenshot -2d -path ${imagedir}/${test_image}.png