From 992876e98fb97d08ae284ce0722468b40f97926f Mon Sep 17 00:00:00 2001 From: akaftasev Date: Mon, 17 Aug 2020 18:44:19 +0300 Subject: [PATCH] 0030795: BRepOffsetAPI_MakePipeShell: hangs on the attached model and produces infinite rails Added new condition to catch bad shape --- src/BRepFill/BRepFill_Sweep.cxx | 64 ++++++++++++++++++++------------- src/BRepFill/BRepFill_Sweep.hxx | 2 +- tests/bugs/modalg_7/bug30787 | 3 -- tests/bugs/modalg_7/bug30795 | 11 ++++++ tests/pipe/standard/G1 | 22 ++++++++++++ tests/pipe/standard/G2 | 20 +++++++++++ tests/pipe/standard/G3 | 20 +++++++++++ tests/pipe/standard/G4 | 22 ++++++++++++ tests/pipe/standard/G5 | 22 ++++++++++++ tests/pipe/standard/G6 | 20 +++++++++++ 10 files changed, 177 insertions(+), 29 deletions(-) create mode 100644 tests/bugs/modalg_7/bug30795 create mode 100644 tests/pipe/standard/G1 create mode 100644 tests/pipe/standard/G2 create mode 100644 tests/pipe/standard/G3 create mode 100644 tests/pipe/standard/G4 create mode 100644 tests/pipe/standard/G5 create mode 100644 tests/pipe/standard/G6 diff --git a/src/BRepFill/BRepFill_Sweep.cxx b/src/BRepFill/BRepFill_Sweep.cxx index 61fb51c77e..e00cf0aa70 100644 --- a/src/BRepFill/BRepFill_Sweep.cxx +++ b/src/BRepFill/BRepFill_Sweep.cxx @@ -2923,38 +2923,46 @@ void BRepFill_Sweep::Build(TopTools_MapOfShape& ReversedEdges, Standard_Real Extend = 0.0; if (NbTrous==1) Extend = EvalExtrapol(1, Transition); isDone = BuildShell(Transition, - 1, NbPath+1, + 1, NbPath+1, ReversedEdges, Tapes, Rails, - Extend, Extend); + Extend, Extend); } else { // This is done piece by piece Standard_Integer IFirst = 1, ILast; for (ii=1, isDone=Standard_True; - ii<=NbPart && isDone; ii++) { - if (ii > NbTrous) ILast = NbPath+1; - else ILast = Trous->Value(ii); - isDone = BuildShell(Transition, - IFirst, ILast, + ii<=NbPart && isDone; ii++) { + if (ii > NbTrous) ILast = NbPath+1; + else ILast = Trous->Value(ii); + isDone = BuildShell(Transition, + IFirst, ILast, ReversedEdges, Tapes, Rails, - EvalExtrapol(IFirst, Transition), - EvalExtrapol(ILast, Transition)); - if (IFirst>1) { - Translate(myVEdges, IFirst, Bounds, 2); - PerformCorner(IFirst, - Transition, Bounds); - } - IFirst = ILast; - Translate(myVEdges, IFirst, Bounds, 1); + EvalExtrapol(IFirst, Transition), + EvalExtrapol(ILast, Transition)); + if (IFirst>1) { + Translate(myVEdges, IFirst, Bounds, 2); + if (!PerformCorner(IFirst, + Transition, Bounds)) + { + isDone = Standard_False; + return; + } + } + IFirst = ILast; + Translate(myVEdges, IFirst, Bounds, 1); } } // Management of looping ends if ( (NbTrous>0) && (myLoc->IsClosed()) && - (Trous->Value(NbTrous) == NbPath+1) ) { + (Trous->Value(NbTrous) == NbPath+1) ) { Translate(myVEdges, NbPath+1, Bounds, 1); Translate(myVEdges, 1, Bounds, 2); - PerformCorner(1, Transition, Bounds); + if (!PerformCorner(1, Transition, Bounds)) + { + isDone = Standard_False; + return; + } Translate(myVEdges, 1, myVEdges, NbPath+1); } @@ -3175,12 +3183,14 @@ TopoDS_Shape BRepFill_Sweep::Tape(const Standard_Integer Index) const //function : PerformCorner //purpose : Trim and/or loop a corner //====================================================================== - void BRepFill_Sweep::PerformCorner(const Standard_Integer Index, - const BRepFill_TransitionStyle Transition, - const Handle(TopTools_HArray2OfShape)& Bounds) + Standard_Boolean BRepFill_Sweep::PerformCorner(const Standard_Integer Index, + const BRepFill_TransitionStyle Transition, + const Handle(TopTools_HArray2OfShape)& Bounds) { - if (Transition == BRepFill_Modified) return; // Do nothing. + if (Transition == BRepFill_Modified) return Standard_True; // Do nothing. + + const Standard_Real anAngularTol = 0.025; BRepFill_TransitionStyle TheTransition = Transition; Standard_Boolean isTangent=Standard_False; @@ -3226,11 +3236,15 @@ TopoDS_Shape BRepFill_Sweep::Tape(const Standard_Integer Index) const #ifdef OCCT_DEBUG std::cout << "BRepFill_Sweep::PerformCorner : This is not a corner !" << std::endl; #endif - return; + return Standard_True; } Sortant = t2 - t1; } + if (T1.Angle(T2) >= M_PI - anAngularTol) + { + return Standard_False; + } if ((TheTransition == BRepFill_Right) && (T1.Angle(T2) > myAngMax) ) { TheTransition = BRepFill_Round; @@ -3336,7 +3350,7 @@ TopoDS_Shape BRepFill_Sweep::Tape(const Standard_Integer Index) const #ifdef OCCT_DEBUG std::cout << "Fail of TrimCorner" << std::endl; #endif - return; // Nothing is touched + return Standard_True; // Nothing is touched } if (mySec->IsUClosed()) @@ -3416,7 +3430,7 @@ TopoDS_Shape BRepFill_Sweep::Tape(const Standard_Integer Index) const #endif } } - + return Standard_True; /* #if DRAW if (Affich) { diff --git a/src/BRepFill/BRepFill_Sweep.hxx b/src/BRepFill/BRepFill_Sweep.hxx index 72b1897959..30a02c20eb 100644 --- a/src/BRepFill/BRepFill_Sweep.hxx +++ b/src/BRepFill/BRepFill_Sweep.hxx @@ -124,7 +124,7 @@ protected: Standard_EXPORT Standard_Boolean BuildShell (const BRepFill_TransitionStyle Transition, const Standard_Integer Vf, const Standard_Integer Vl, TopTools_MapOfShape& ReversedEdges, BRepFill_DataMapOfShapeHArray2OfShape& Tapes, BRepFill_DataMapOfShapeHArray2OfShape& Rails, const Standard_Real ExtendFirst = 0.0, const Standard_Real ExtendLast = 0.0); - Standard_EXPORT void PerformCorner (const Standard_Integer Index, const BRepFill_TransitionStyle Transition, const Handle(TopTools_HArray2OfShape)& Bounds); + Standard_EXPORT Standard_Boolean PerformCorner (const Standard_Integer Index, const BRepFill_TransitionStyle Transition, const Handle(TopTools_HArray2OfShape)& Bounds); Standard_EXPORT Standard_Real EvalExtrapol (const Standard_Integer Index, const BRepFill_TransitionStyle Transition) const; diff --git a/tests/bugs/modalg_7/bug30787 b/tests/bugs/modalg_7/bug30787 index 6014d096bf..5afc0e861b 100644 --- a/tests/bugs/modalg_7/bug30787 +++ b/tests/bugs/modalg_7/bug30787 @@ -1,6 +1,3 @@ -puts "TODO OCC30808 ALL: An exception was caught" -puts "TODO OCC30808 ALL:TEST INCOMPLETE" - puts "========" puts "0030787: BRepOffsetAPI_MakePipeShell: hangs on the attached model" puts "========" diff --git a/tests/bugs/modalg_7/bug30795 b/tests/bugs/modalg_7/bug30795 new file mode 100644 index 0000000000..7278e37e05 --- /dev/null +++ b/tests/bugs/modalg_7/bug30795 @@ -0,0 +1,11 @@ +puts "========" +puts "0030795: BRepOffsetAPI_MakePipeShell: hangs on the attached model and produces infinite rails" +puts "========" +puts "" + +restore [locate_data_file bug30795.brep] a +explode a + +mksweep a_1 +addsweep a_2 +buildsweep result -C -S \ No newline at end of file diff --git a/tests/pipe/standard/G1 b/tests/pipe/standard/G1 new file mode 100644 index 0000000000..9ef26d0fd8 --- /dev/null +++ b/tests/pipe/standard/G1 @@ -0,0 +1,22 @@ +circle c1 0 10 0 10 +circle c2 0 9 0 9.1 +circle c3 10 10 0 0 10 0 0.05 + +mkedge e1 c1 +mkedge e2 c2 +mkedge profile c3 + +bclearobjects +baddobjects e1 e2 +bfillds +bbuild result + +explode result e +wire path result_1 result_3 result_4 result_6 +wire profile profile + +mksweep path +addsweep profile +buildsweep result -C -R + +checkprops result -s 32.412 \ No newline at end of file diff --git a/tests/pipe/standard/G2 b/tests/pipe/standard/G2 new file mode 100644 index 0000000000..5230097162 --- /dev/null +++ b/tests/pipe/standard/G2 @@ -0,0 +1,20 @@ +circle c1 0 10 0 10 +circle c2 0 9 0 9.01 +circle c3 10 10 0 0 10 0 0.05 + +mkedge e1 c1 +mkedge e2 c2 +mkedge profile c3 + +bclearobjects +baddobjects e1 e2 +bfillds +bbuild result + +explode result e +wire path result_1 result_3 result_4 result_6 +wire profile profile + +mksweep path +addsweep profile +buildsweep result -C -R \ No newline at end of file diff --git a/tests/pipe/standard/G3 b/tests/pipe/standard/G3 new file mode 100644 index 0000000000..f4956becb7 --- /dev/null +++ b/tests/pipe/standard/G3 @@ -0,0 +1,20 @@ +circle c1 0 10 0 10 +circle c2 0 9 0 9.001 +circle c3 10 10 0 0 10 0 0.05 + +mkedge e1 c1 +mkedge e2 c2 +mkedge profile c3 + +bclearobjects +baddobjects e1 e2 +bfillds +bbuild result + +explode result e +wire path result_1 result_3 result_4 result_6 +wire profile profile + +mksweep path +addsweep profile +buildsweep result -C -R \ No newline at end of file diff --git a/tests/pipe/standard/G4 b/tests/pipe/standard/G4 new file mode 100644 index 0000000000..5705659aef --- /dev/null +++ b/tests/pipe/standard/G4 @@ -0,0 +1,22 @@ +circle c1 0 10 0 10 +circle c2 0 -9 0 9.1 +circle c3 10 10 0 0 10 0 0.05 + +mkedge e1 c1 +mkedge e2 c2 +mkedge profile c3 + +bclearobjects +baddobjects e1 e2 +bfillds +bbuild result + +explode result e +wire path result_1 result_3 result_4 result_6 +wire profile profile + +mksweep path +addsweep profile +buildsweep result -C -R + +checkprops result -s 36.5019 \ No newline at end of file diff --git a/tests/pipe/standard/G5 b/tests/pipe/standard/G5 new file mode 100644 index 0000000000..7bd366798d --- /dev/null +++ b/tests/pipe/standard/G5 @@ -0,0 +1,22 @@ +circle c1 0 10 0 10 +circle c2 0 -9 0 9.01 +circle c3 10 10 0 0 10 0 0.05 + +mkedge e1 c1 +mkedge e2 c2 +mkedge profile c3 + +bclearobjects +baddobjects e1 e2 +bfillds +bbuild result + +explode result e +wire path result_1 result_3 result_4 result_6 +wire profile profile + +mksweep path +addsweep profile +buildsweep result -C -R + +checkprops result -s 37.4358 diff --git a/tests/pipe/standard/G6 b/tests/pipe/standard/G6 new file mode 100644 index 0000000000..2f450add32 --- /dev/null +++ b/tests/pipe/standard/G6 @@ -0,0 +1,20 @@ +circle c1 0 10 0 10 +circle c2 0 -9 0 9.001 +circle c3 10 10 0 0 10 0 0.05 + +mkedge e1 c1 +mkedge e2 c2 +mkedge profile c3 + +bclearobjects +baddobjects e1 e2 +bfillds +bbuild result + +explode result e +wire path result_1 result_3 result_4 result_6 +wire profile profile + +mksweep path +addsweep profile +buildsweep result -C -R