diff --git a/src/BRepOffsetAPI/BRepOffsetAPI_ThruSections.cxx b/src/BRepOffsetAPI/BRepOffsetAPI_ThruSections.cxx index 763a460d16..dd7eeee2e9 100644 --- a/src/BRepOffsetAPI/BRepOffsetAPI_ThruSections.cxx +++ b/src/BRepOffsetAPI/BRepOffsetAPI_ThruSections.cxx @@ -397,29 +397,30 @@ void BRepOffsetAPI_ThruSections::Build() Standard_Integer IndFirstSec = 1; if (Georges.IsDegeneratedFirstSection()) IndFirstSec = 2; - TopoDS_Shape aWorkingSection = WorkingSections(IndFirstSec); + TopoDS_Wire aWorkingSection = TopoDS::Wire(WorkingSections(IndFirstSec)); myNbEdgesInSection += aWorkingSection.NbChildren(); for (Standard_Integer ii = 1; ii <= myWires.Length(); ii++) { - TopExp_Explorer Explo(myWires(ii), TopAbs_EDGE); - for (; Explo.More(); Explo.Next()) + TopoDS_Iterator itw(myWires(ii)); + for (; itw.More(); itw.Next()) { - const TopoDS_Edge& anEdge = TopoDS::Edge(Explo.Current()); + const TopoDS_Edge& anEdge = TopoDS::Edge(itw.Value()); Standard_Integer aSign = 1; TopoDS_Vertex Vfirst, Vlast; TopExp::Vertices(anEdge, Vfirst, Vlast); TopTools_ListOfShape aNewEdges = Georges.GeneratedShapes(anEdge); TColStd_ListOfInteger IList; - aWorkingSection = WorkingSections(ii); + aWorkingSection = TopoDS::Wire(WorkingSections(ii)); Standard_Integer NbNewEdges = aNewEdges.Extent(); TopTools_ListIteratorOfListOfShape itl(aNewEdges); for (Standard_Integer kk = 1; itl.More(); itl.Next(),kk++) { const TopoDS_Edge& aNewEdge = TopoDS::Edge(itl.Value()); Standard_Integer inde = 1; - for (TopoDS_Iterator itw (aWorkingSection); itw.More(); itw.Next(), inde++) + BRepTools_WireExplorer wexp(aWorkingSection); + for (; wexp.More(); wexp.Next(), inde++) { - const TopoDS_Shape& aWorkingEdge = itw.Value(); + const TopoDS_Shape& aWorkingEdge = wexp.Current(); if (aWorkingEdge.IsSame(aNewEdge)) { aSign = (aWorkingEdge.Orientation() == TopAbs_FORWARD)? 1 : -1; @@ -1295,12 +1296,14 @@ BRepOffsetAPI_ThruSections::Generated(const TopoDS_Shape& S) Standard_Integer Eindex = myVertexIndex(S); Standard_Integer Vindex = (Eindex > 0)? 0 : 1; Eindex = Abs(Eindex); - const TopoDS_Shape& FirstSection = myWires(1); + const TopoDS_Wire& FirstSection = TopoDS::Wire(myWires(1)); TopoDS_Edge FirstEdge; - TopoDS_Iterator itw(FirstSection); - for (Standard_Integer inde = 1; itw.More(); itw.Next(),inde++) + TopoDS_Vertex FirstVertexOfFirstEdge; + BRepTools_WireExplorer wexp(FirstSection); + for (Standard_Integer inde = 1; wexp.More(); wexp.Next(),inde++) { - FirstEdge = TopoDS::Edge(itw.Value()); + FirstEdge = wexp.Current(); + FirstVertexOfFirstEdge = wexp.CurrentVertex(); if (inde == Eindex) break; } @@ -1330,7 +1333,20 @@ BRepOffsetAPI_ThruSections::Generated(const TopoDS_Shape& S) FirstEdgeInFace = Explo.Current(); TopoDS_Vertex VV [2]; TopExp::Vertices(FirstEdge, VV[0], VV[1]); - FirstVertex = VV[Vindex]; + if (Vindex == 0) + { + if (VV[0].IsSame(FirstVertexOfFirstEdge)) + FirstVertex = VV[0]; + else + FirstVertex = VV[1]; + } + else //Vindex == 1 + { + if (VV[0].IsSame(FirstVertexOfFirstEdge)) + FirstVertex = VV[1]; + else + FirstVertex = VV[0]; + } const TopTools_ListOfShape& Elist = VEmap.FindFromKey(FirstVertex); TopTools_ListIteratorOfListOfShape itl(Elist); TopAbs_Orientation anEdgeOr = (Vindex == 0)? TopAbs_REVERSED : TopAbs_FORWARD; diff --git a/tests/bugs/modalg_4/bug22646 b/tests/bugs/modalg_4/bug22646 index fde97b6fbd..345080a781 100755 --- a/tests/bugs/modalg_4/bug22646 +++ b/tests/bugs/modalg_4/bug22646 @@ -1,7 +1,3 @@ -puts "TODO OCC29653 All:exception" -puts "TODO OCC29653 All:\\*\\* Exception \\*\\*" -puts "TODO OCC29653 All:TEST INCOMPLETE" - puts "============" puts "OCC22646" puts "============" @@ -13,27 +9,59 @@ puts "" set BugNumber OCC22646 - restore [locate_data_file bug22646_source.brep] s1 restore [locate_data_file bug22646_scale_translate_xyz.brep] s2 restore [locate_data_file bug22646_scale_translate_yz.brep] s3 restore [locate_data_file bug22646_scale_translate_z.brep] s4 -vinit explode s1 explode s2 explode s3 explode s4 -vfit -donly s1_1 s2_1 thrusections res2 0 0 s1_1 s2_1 +savehistory hist + +foreach s {s1_1 s2_1} { + foreach type {v e} { + foreach ss [explode $s $type] { + if {[catch { generated g2 hist $ss } catch_res]} { + puts "Error: Unable to get generated shapes" + } + } + } +} -donly s1_1 s3_1 thrusections res3 0 0 s1_1 s3_1 +savehistory hist + +foreach s {s1_1 s3_1} { + foreach type {v e} { + foreach ss [explode $s $type] { + if {[catch { generated g3 hist $ss } catch_res]} { + puts "Error: Unable to get generated shapes" + } + } + } +} -donly s1_1 s4_1 thrusections res4 0 0 s1_1 s4_1 +savehistory hist +foreach s {s1_1 s4_1} { + foreach type {v e} { + foreach ss [explode $s $type] { + if {[catch { generated g4 hist $ss } catch_res]} { + puts "Error: Unable to get generated shapes" + } + } + } +} + +vinit +vsetdispmode 1 +vdisplay g2 +vdisplay g3 +vdisplay g4 +vfit checkview -screenshot -3d -path ${imagedir}/${test_image}.png - diff --git a/tests/bugs/modalg_7/bug30958 b/tests/bugs/modalg_7/bug30958 new file mode 100644 index 0000000000..3fc93eb548 --- /dev/null +++ b/tests/bugs/modalg_7/bug30958 @@ -0,0 +1,43 @@ +puts "==========================================================================================" +puts "OCC30958: BRepOffsetAPI_ThruSections operation raises an except-ion while building history" +puts "==========================================================================================" +puts "" + +restore [locate_data_file bug30958_CompWires.brep] ww +explode ww + +thrusections res 0 1 ww_1 ww_2 + +savehistory hist + +explode ww_1 + +generated r1 hist ww_1_1 +generated r2 hist ww_1_2 + +checkprops r1 -s 22.4404 +checkprops r2 -s 81.2396 + +explode ww_1 v + +generated rr1 hist ww_1_1 +generated rr2 hist ww_1_2 +generated rr3 hist ww_1_3 + +distmini dd ww_1_1 rr1 +regexp {([-0-9.+eE]+)} [dump dd_val] full dist +if { $dist > 1.e-7} { + puts "Error: wrong generated list of edges" +} + +distmini dd ww_1_2 rr2 +regexp {([-0-9.+eE]+)} [dump dd_val] full dist +if { $dist > 1.e-7} { + puts "Error: wrong generated list of edges" +} + +distmini dd ww_1_3 rr3 +regexp {([-0-9.+eE]+)} [dump dd_val] full dist +if { $dist > 1.e-7} { + puts "Error: wrong generated list of edges" +}