diff --git a/src/BRepFill/BRepFill_PipeShell.cxx b/src/BRepFill/BRepFill_PipeShell.cxx index 01abed3e4e..a86bcc0b2f 100644 --- a/src/BRepFill/BRepFill_PipeShell.cxx +++ b/src/BRepFill/BRepFill_PipeShell.cxx @@ -1409,6 +1409,73 @@ void BRepFill_PipeShell::BuildHistory(const BRepFill_Sweep& theSweep) inde++; } } + + //For subshapes of spine + const Handle(TopTools_HArray2OfShape)& aFaces = theSweep.SubShape(); + const Handle(TopTools_HArray2OfShape)& aVEdges = theSweep.Sections(); + + BRepTools_WireExplorer wexp(mySpine); + inde = 0; + Standard_Boolean ToExit = Standard_False; + for (;;) + { + if (!wexp.More()) + ToExit = Standard_True; + + inde++; + + if (!ToExit) + { + const TopoDS_Edge& anEdgeOfSpine = wexp.Current(); + TopoDS_Shell aShell; + BB.MakeShell(aShell); + for (Standard_Integer i = 1; i <= aFaces->UpperRow(); i++) + { + const TopoDS_Shape& aFace = aFaces->Value(i, inde); + if (aFace.ShapeType() == TopAbs_FACE) + BB.Add(aShell, aFace); + } + + TopTools_ListOfShape ListShell; + ListShell.Append(aShell); + myGenMap.Bind(anEdgeOfSpine, ListShell); + } + + const TopoDS_Vertex& aVertexOfSpine = wexp.CurrentVertex(); + TopTools_ListOfShape ListVshapes; + for (Standard_Integer i = 1; i <= aVEdges->UpperRow(); i++) + { + const TopoDS_Shape& aVshape = aVEdges->Value(i, inde); + if (aVshape.ShapeType() == TopAbs_EDGE || + aVshape.ShapeType() == TopAbs_FACE) + ListVshapes.Append(aVshape); + else + { + TopoDS_Iterator itvshape(aVshape); + for (; itvshape.More(); itvshape.Next()) + { + const TopoDS_Shape& aSubshape = itvshape.Value(); + if (aSubshape.ShapeType() == TopAbs_EDGE || + aSubshape.ShapeType() == TopAbs_FACE) + ListVshapes.Append(aSubshape); + else + { + //it is wire + for (itw.Initialize(aSubshape); itw.More(); itw.Next()) + ListVshapes.Append(itw.Value()); + } + } + } + } + + myGenMap.Bind(aVertexOfSpine, ListVshapes); + + if (ToExit) + break; + + if (wexp.More()) + wexp.Next(); + } } diff --git a/src/BRepFill/BRepFill_PipeShell.hxx b/src/BRepFill/BRepFill_PipeShell.hxx index 33195cf44e..6fda81f52a 100644 --- a/src/BRepFill/BRepFill_PipeShell.hxx +++ b/src/BRepFill/BRepFill_PipeShell.hxx @@ -192,6 +192,12 @@ public: theProfiles.Append(mySeq(i).OriginalShape()); } + //! Returns the spine + const TopoDS_Wire& Spine() + { + return mySpine; + } + //! Returns the list of shapes generated from the //! shape . Standard_EXPORT void Generated (const TopoDS_Shape& S, TopTools_ListOfShape& L); diff --git a/src/BRepFill/BRepFill_Sweep.cxx b/src/BRepFill/BRepFill_Sweep.cxx index 03fb5a311e..578ad6cfe7 100644 --- a/src/BRepFill/BRepFill_Sweep.cxx +++ b/src/BRepFill/BRepFill_Sweep.cxx @@ -2941,9 +2941,10 @@ void BRepFill_Sweep::Build(TopTools_MapOfShape& ReversedEdges, // Management of looping ends if ( (NbTrous>0) && (myLoc->IsClosed()) && (Trous->Value(NbTrous) == NbPath+1) ) { - Translate(myVEdges, NbPath+1, Bounds, 1); - Translate(myVEdges, 1, Bounds, 2); + Translate(myVEdges, NbPath+1, Bounds, 1); + Translate(myVEdges, 1, Bounds, 2); PerformCorner(1, Transition, Bounds); + Translate(myVEdges, 1, myVEdges, NbPath+1); } // Construction of the shell @@ -3041,7 +3042,8 @@ void BRepFill_Sweep::Build(TopTools_MapOfShape& ReversedEdges, for (jj = myUEdges->LowerCol(); jj <= myUEdges->UpperCol(); jj++) { TopoDS_Edge anEdge = TopoDS::Edge(myUEdges->Value(ii, jj)); - if (anEdge.IsNull()) + if (anEdge.IsNull() || + BRep_Tool::Degenerated(anEdge)) continue; TopoDS_Face Face1, Face2; Standard_Integer i1 = ii-1, i2 = ii; @@ -3266,10 +3268,27 @@ TopoDS_Shape BRepFill_Sweep::Tape(const Standard_Integer Index) const BRepFill_TrimShellCorner aTrim(aFaces, Transition, AxeOfBisPlane); aTrim.AddBounds(Bounds); aTrim.AddUEdges(aUEdges); + aTrim.AddVEdges(myVEdges, Index); aTrim.Perform(); if (aTrim.IsDone()) { + TopTools_ListOfShape listmodif; + for (ii = 1; ii <= mySec->NbLaw(); ii++) + { + listmodif.Clear(); + aTrim.Modified(myVEdges->Value(ii, Index), listmodif); + + if (listmodif.IsEmpty()) + { + TopoDS_Edge NullEdge; + myVEdges->SetValue(ii, Index, NullEdge); + } + else + myVEdges->SetValue(ii, Index, listmodif.First()); + } + + listmodif.Clear(); Standard_Integer iit = 0; for(iit = 0; iit < 2; iit++) { @@ -3356,8 +3375,15 @@ TopoDS_Shape BRepFill_Sweep::Tape(const Standard_Integer Index) const if (B) { myAuxShape.Append(FF); - myVEdges->ChangeValue(ii, I2) = FF; BRep_Builder BB; + TopoDS_Shape aVshape = myVEdges->Value(ii, I2); + TopoDS_Compound aCompound; + BB.MakeCompound(aCompound); + if (!aVshape.IsNull()) + BB.Add(aCompound, aVshape); + BB.Add(aCompound, FF); + myVEdges->ChangeValue(ii, I2) = aCompound; + BB.Add(myTapes->ChangeValue(ii), FF); HasFilling = Standard_True; } diff --git a/src/BRepFill/BRepFill_TrimShellCorner.cxx b/src/BRepFill/BRepFill_TrimShellCorner.cxx index 64f6908cf0..eca1216813 100644 --- a/src/BRepFill/BRepFill_TrimShellCorner.cxx +++ b/src/BRepFill/BRepFill_TrimShellCorner.cxx @@ -91,6 +91,11 @@ static Standard_Boolean SplitUEdges(const Handle(TopTools_HArray2OfShape)& t const BOPDS_PDS& theDS, TopTools_DataMapOfShapeListOfShape& theHistMap); +static void StoreVedgeInHistMap(const Handle(TopTools_HArray1OfShape)& theVEdges, + const Standard_Integer theIndex, + const TopoDS_Shape& theNewVedge, + TopTools_DataMapOfShapeListOfShape& theHistMap); + static void FindFreeVertices(const TopoDS_Shape& theShape, const TopTools_MapOfShape& theVerticesToAvoid, TopTools_ListOfShape& theListOfVertex); @@ -229,6 +234,19 @@ void BRepFill_TrimShellCorner::AddUEdges(const Handle(TopTools_HArray2OfShape)& myUEdges->ChangeArray2() = theUEdges->Array2(); } +// =========================================================================================== +// function: AddVEdges +// purpose: +// =========================================================================================== +void BRepFill_TrimShellCorner::AddVEdges(const Handle(TopTools_HArray2OfShape)& theVEdges, + const Standard_Integer theIndex) +{ + myVEdges = new TopTools_HArray1OfShape(theVEdges->LowerRow(), theVEdges->UpperRow()); + + for (Standard_Integer i = theVEdges->LowerRow(); i <= theVEdges->UpperRow(); i++) + myVEdges->SetValue(i, theVEdges->Value(i, theIndex)); +} + // =========================================================================================== // function: Perform // purpose: @@ -479,9 +497,12 @@ BRepFill_TrimShellCorner::MakeFacesNonSec(const Standard_Integer aMapV.Add(aV); aBB.Add(aComp, aUE); } + if(bHasNewEdge) { aBB.Add(aComp, aNewEdge); + StoreVedgeInHistMap(myVEdges, theIndex, aNewEdge, myHistMap); } + TopTools_ListOfShape alonevertices; FindFreeVertices(aComp, aMapV, alonevertices); @@ -686,6 +707,8 @@ BRepFill_TrimShellCorner::MakeFacesSec(const Standard_Integer for (; explo.More(); explo.Next()) BB.Add( aComp, explo.Current() ); aSecEdges = aComp; + + StoreVedgeInHistMap(myVEdges, theIndex, SecWire, myHistMap); } TopTools_ListOfShape aCommonVertices; @@ -1123,6 +1146,22 @@ Standard_Boolean SplitUEdges(const Handle(TopTools_HArray2OfShape)& theUEdge return Standard_True; } +// ------------------------------------------------------------------------------------------ +// static function: StoreVedgeInHistMap +// purpose: +// ------------------------------------------------------------------------------------------ +void StoreVedgeInHistMap(const Handle(TopTools_HArray1OfShape)& theVEdges, + const Standard_Integer theIndex, + const TopoDS_Shape& theNewVshape, + TopTools_DataMapOfShapeListOfShape& theHistMap) +{ + //Replace default value in the map (v-iso edge of face) + //by intersection of two consecutive faces + const TopoDS_Shape& aVEdge = theVEdges->Value(theIndex); + + theHistMap.Bound(aVEdge, TopTools_ListOfShape())->Append(theNewVshape); +} + // ------------------------------------------------------------------------------------------ // static function: FindFreeVertices // purpose: diff --git a/src/BRepFill/BRepFill_TrimShellCorner.hxx b/src/BRepFill/BRepFill_TrimShellCorner.hxx index a134916e8b..df78dfef0b 100644 --- a/src/BRepFill/BRepFill_TrimShellCorner.hxx +++ b/src/BRepFill/BRepFill_TrimShellCorner.hxx @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -55,6 +56,9 @@ public: Standard_EXPORT void AddUEdges (const Handle(TopTools_HArray2OfShape)& theUEdges); + Standard_EXPORT void AddVEdges (const Handle(TopTools_HArray2OfShape)& theVEdges, + const Standard_Integer theIndex); + Standard_EXPORT void Perform(); Standard_EXPORT Standard_Boolean IsDone() const; @@ -99,6 +103,7 @@ private: TopoDS_Shape myShape2; Handle(TopTools_HArray2OfShape) myBounds; Handle(TopTools_HArray2OfShape) myUEdges; + Handle(TopTools_HArray1OfShape) myVEdges; Handle(TopTools_HArray2OfShape) myFaces; Standard_Boolean myDone; Standard_Boolean myHasSection; diff --git a/src/BRepOffsetAPI/BRepOffsetAPI_MakePipeShell.hxx b/src/BRepOffsetAPI/BRepOffsetAPI_MakePipeShell.hxx index 4c01e25192..305160de80 100644 --- a/src/BRepOffsetAPI/BRepOffsetAPI_MakePipeShell.hxx +++ b/src/BRepOffsetAPI/BRepOffsetAPI_MakePipeShell.hxx @@ -267,7 +267,11 @@ public: myPipe->Profiles(theProfiles); } - + //! Returns the spine + const TopoDS_Wire& Spine() + { + return myPipe->Spine(); + } protected: diff --git a/src/BRepTest/BRepTest_SweepCommands.cxx b/src/BRepTest/BRepTest_SweepCommands.cxx index 0b2da73a4e..76c92c593e 100644 --- a/src/BRepTest/BRepTest_SweepCommands.cxx +++ b/src/BRepTest/BRepTest_SweepCommands.cxx @@ -779,9 +779,11 @@ static Standard_Integer buildsweep(Draw_Interpretor& di, // Save history of sweep if (BRepTest_Objects::IsHistoryNeeded()) { - TopTools_ListOfShape aProfiles; - Sweep->Profiles(aProfiles); - BRepTest_Objects::SetHistory(aProfiles, *Sweep); + TopTools_ListOfShape aList; + Sweep->Profiles(aList); + TopoDS_Shape aSpine = Sweep->Spine(); + aList.Append(aSpine); + BRepTest_Objects::SetHistory(aList, *Sweep); } } diff --git a/tests/bugs/modalg_7/bug28949_1 b/tests/bugs/modalg_7/bug28949_1 new file mode 100644 index 0000000000..e56a1af04a --- /dev/null +++ b/tests/bugs/modalg_7/bug28949_1 @@ -0,0 +1,40 @@ +puts "============" +puts "OCC28949" +puts "============" +puts "" +############################################################################## +# BRepOffsetAPI_MakePipe Generated() method produces no result for spine edges +############################################################################## + + +restore [locate_data_file OCC1477-1.brep] sp +restore [locate_data_file OCC1477-2.brep] pr + +mksweep sp +addsweep pr +buildsweep q -R + +explode sp + +savehistory sweep_hist + +generated r1 sweep_hist sp_1 +generated r2 sweep_hist sp_2 +generated r3 sweep_hist sp_3 + +checkprops r1 -s 80000 +checkprops r2 -s 463014 +checkprops r3 -s 449490 + +explode sp v + +generated r1 sweep_hist sp_1 +generated r2 sweep_hist sp_2 +generated r3 sweep_hist sp_3 +generated r4 sweep_hist sp_4 + +checkprops r1 -l 800 +checkprops r2 -l 800 +checknbshapes r3 -edge 11 -face 3 +checkprops r3 -s 30911.3 +checkprops r4 -l 800 diff --git a/tests/bugs/modalg_7/bug28949_2 b/tests/bugs/modalg_7/bug28949_2 new file mode 100644 index 0000000000..acbd1ebf14 --- /dev/null +++ b/tests/bugs/modalg_7/bug28949_2 @@ -0,0 +1,45 @@ +puts "============" +puts "OCC28949" +puts "============" +puts "" +############################################################################## +# BRepOffsetAPI_MakePipe Generated() method produces no result for spine edges +############################################################################## + +restore [locate_data_file OCC1477_3dPolyline_c0.brep] sp +restore [locate_data_file OCC1477_profile1_polygon.brep] pr + +mksweep sp +addsweep pr -R +buildsweep q -R -S + +explode sp + +savehistory sweep_hist + +generated r1 sweep_hist sp_1 +generated r2 sweep_hist sp_2 +generated r3 sweep_hist sp_3 +generated r4 sweep_hist sp_4 + +checkprops r1 -s 6513.47 +checkprops r2 -s 6407.12 +checkprops r3 -s 4372.71 +checkprops r4 -s 6440.77 + +explode sp v + +generated r1 sweep_hist sp_1 +generated r2 sweep_hist sp_2 +generated r3 sweep_hist sp_3 +generated r4 sweep_hist sp_4 +generated r5 sweep_hist sp_5 + +checkprops r1 -l 47.3598 +checknbshapes r2 -edge 14 -face 3 +checkprops r2 -s 222.763 +checknbshapes r3 -edge 16 -face 4 +checkprops r3 -s 167.055 +checknbshapes r4 -edge 14 -face 3 +checkprops r4 -s 250.747 +checkprops r5 -l 47.3598 diff --git a/tests/bugs/modalg_7/bug28949_3 b/tests/bugs/modalg_7/bug28949_3 new file mode 100644 index 0000000000..c63f3f70c3 --- /dev/null +++ b/tests/bugs/modalg_7/bug28949_3 @@ -0,0 +1,37 @@ +puts "============" +puts "OCC28949" +puts "============" +puts "" +############################################################################## +# BRepOffsetAPI_MakePipe Generated() method produces no result for spine edges +############################################################################## + +restore [locate_data_file OCC1477_bsplinewire_c0.brep] sp +restore [locate_data_file OCC1477_profile1_circle.brep] pr +wire pr pr + +mksweep sp +addsweep pr -T -R +buildsweep q -R -S + +explode sp + +savehistory sweep_hist + +generated r1 sweep_hist sp_1 +generated r2 sweep_hist sp_2 + +checkprops r1 -s 24223.6 +checkprops r2 -s 11608.3 + +explode sp v + +generated r1 sweep_hist sp_1 +generated r2 sweep_hist sp_2 +generated r3 sweep_hist sp_3 + +checkprops r1 -l 51.1582 +checknbshapes r2 -edge 5 -face 1 +checkprops r2 -s 477.306 +checkprops r3 -l 51.1582 + diff --git a/tests/bugs/modalg_7/bug28949_4 b/tests/bugs/modalg_7/bug28949_4 new file mode 100644 index 0000000000..8d9034a476 --- /dev/null +++ b/tests/bugs/modalg_7/bug28949_4 @@ -0,0 +1,55 @@ +puts "============" +puts "OCC28949" +puts "============" +puts "" +############################################################################## +# BRepOffsetAPI_MakePipe Generated() method produces no result for spine edges +############################################################################## + +restore [locate_data_file OCC1477_closedPolyline.brep] sp +restore [locate_data_file OCC1477_profile1_circle.brep] pr +wire pr pr + +mksweep sp +addsweep pr -R +buildsweep q -R + +explode sp + +savehistory sweep_hist + +generated r1 sweep_hist sp_1 +generated r2 sweep_hist sp_2 +generated r3 sweep_hist sp_3 +generated r4 sweep_hist sp_4 +generated r5 sweep_hist sp_5 +generated r6 sweep_hist sp_6 + +checkprops r1 -s 7645.09 +checkprops r2 -s 12192.6 +checkprops r3 -s 11847.7 +checkprops r4 -s 17355.4 +checkprops r5 -s 3025.54 +checkprops r6 -s 4247.15 + +explode sp v + +generated r1 sweep_hist sp_1 +generated r2 sweep_hist sp_2 +generated r3 sweep_hist sp_3 +generated r4 sweep_hist sp_4 +generated r5 sweep_hist sp_5 +generated r6 sweep_hist sp_6 + +checknbshapes r1 -edge 8 -face 2 +checkprops r1 -s 67.4609 +checknbshapes r2 -edge 6 -face 1 +checkprops r2 -s 186.721 +checknbshapes r3 -edge 6 -face 1 +checkprops r3 -s 162.193 +checknbshapes r4 -edge 6 -face 1 +checkprops r4 -s 247.276 +checknbshapes r5 -edge 6 -face 1 +checkprops r5 -s 55.0804 +checknbshapes r6 -edge 6 -face 1 +checkprops r6 -s 249.259 diff --git a/tests/bugs/modalg_7/bug28949_5 b/tests/bugs/modalg_7/bug28949_5 new file mode 100644 index 0000000000..d45a1b5c65 --- /dev/null +++ b/tests/bugs/modalg_7/bug28949_5 @@ -0,0 +1,55 @@ +puts "============" +puts "OCC28949" +puts "============" +puts "" +############################################################################## +# BRepOffsetAPI_MakePipe Generated() method produces no result for spine edges +############################################################################## + +restore [locate_data_file OCC1477_closedPolyline.brep] sp +restore [locate_data_file OCC1477_profile1_polygon.brep] pr +wire pr pr + +mksweep sp +addsweep pr -R +buildsweep q -R + +explode sp + +savehistory sweep_hist + +generated r1 sweep_hist sp_1 +generated r2 sweep_hist sp_2 +generated r3 sweep_hist sp_3 +generated r4 sweep_hist sp_4 +generated r5 sweep_hist sp_5 +generated r6 sweep_hist sp_6 + +checkprops r1 -s 7095.68 +checkprops r2 -s 11312.8 +checkprops r3 -s 11001.6 +checkprops r4 -s 16092.4 +checkprops r5 -s 2826.84 +checkprops r6 -s 3958.56 + +explode sp v + +generated r1 sweep_hist sp_1 +generated r2 sweep_hist sp_2 +generated r3 sweep_hist sp_3 +generated r4 sweep_hist sp_4 +generated r5 sweep_hist sp_5 +generated r6 sweep_hist sp_6 + +checknbshapes r1 -edge 14 -face 3 +checkprops r1 -s 54.0987 +checknbshapes r2 -edge 16 -face 4 +checkprops r2 -s 149.736 +checknbshapes r3 -edge 16 -face 4 +checkprops r3 -s 130.067 +checknbshapes r4 -edge 16 -face 4 +checkprops r4 -s 198.297 +checknbshapes r5 -edge 16 -face 4 +checkprops r5 -s 44.1704 +checknbshapes r6 -edge 16 -face 4 +checkprops r6 -s 199.887 diff --git a/tests/bugs/modalg_7/bug28949_6 b/tests/bugs/modalg_7/bug28949_6 new file mode 100644 index 0000000000..378565d80d --- /dev/null +++ b/tests/bugs/modalg_7/bug28949_6 @@ -0,0 +1,55 @@ +puts "============" +puts "OCC28949" +puts "============" +puts "" +############################################################################## +# BRepOffsetAPI_MakePipe Generated() method produces no result for spine edges +############################################################################## + + +polyline sp 0 0 0 10 0 0 10 0 10 10 10 10 0 10 10 0 10 0 0 0 0 +polyline pr 0 -2 -2 0 2 -2 0 2 2 0 -2 2 0 -2 -2 + +mksweep sp +addsweep pr +buildsweep q -R + +explode sp + +savehistory sweep_hist + +generated r1 sweep_hist sp_1 +generated r2 sweep_hist sp_2 +generated r3 sweep_hist sp_3 +generated r4 sweep_hist sp_4 +generated r5 sweep_hist sp_5 +generated r6 sweep_hist sp_6 + +checkprops r1 -s 136 +checkprops r2 -s 136 +checkprops r3 -s 136 +checkprops r4 -s 136 +checkprops r5 -s 136 +checkprops r6 -s 136 + +explode sp v + +generated r1 sweep_hist sp_1 +generated r2 sweep_hist sp_2 +generated r3 sweep_hist sp_3 +generated r4 sweep_hist sp_4 +generated r5 sweep_hist sp_5 +generated r6 sweep_hist sp_6 + +checknbshapes r1 -edge 11 -face 3 +checkprops r1 -s 18.8496 +checknbshapes r2 -edge 11 -face 3 +checkprops r2 -s 18.8496 +checknbshapes r3 -edge 11 -face 3 +checkprops r3 -s 18.8496 +checknbshapes r4 -edge 11 -face 3 +checkprops r4 -s 18.8496 +checknbshapes r5 -edge 11 -face 3 +checkprops r5 -s 18.8496 +checknbshapes r6 -edge 11 -face 3 +checkprops r6 -s 18.8496 diff --git a/tests/bugs/modalg_7/bug28949_7 b/tests/bugs/modalg_7/bug28949_7 new file mode 100644 index 0000000000..b264774f5a --- /dev/null +++ b/tests/bugs/modalg_7/bug28949_7 @@ -0,0 +1,52 @@ +puts "============" +puts "OCC28949" +puts "============" +puts "" +############################################################################## +# BRepOffsetAPI_MakePipe Generated() method produces no result for spine edges +############################################################################## + +restore [locate_data_file bug29204_sweep_spine.brep] sp +restore [locate_data_file bug29204_sweep_profile.brep] pr + +mksweep sp +addsweep pr +buildsweep q -C -S + +explode sp + +savehistory sweep_hist + +generated r1 sweep_hist sp_1 +generated r2 sweep_hist sp_2 +generated r3 sweep_hist sp_3 +generated r4 sweep_hist sp_4 +generated r5 sweep_hist sp_5 +generated r6 sweep_hist sp_6 +generated r7 sweep_hist sp_7 + +checknbshapes r1 -face 4 +checknbshapes r2 -face 4 +checknbshapes r3 -face 4 +checknbshapes r4 -face 4 +checknbshapes r5 -face 4 +checknbshapes r6 -face 4 +checknbshapes r7 -face 4 + +explode sp v + +generated r1 sweep_hist sp_1 +generated r2 sweep_hist sp_2 +generated r3 sweep_hist sp_3 +generated r4 sweep_hist sp_4 +generated r5 sweep_hist sp_5 +generated r6 sweep_hist sp_6 +generated r7 sweep_hist sp_7 + +checkprops r1 -l 147.629 +checkprops r2 -l 160.296 +checkprops r3 -l 160.296 +checkprops r4 -l 147.629 +checkprops r5 -l 147.629 +checkprops r6 -l 180.945 +checkprops r7 -l 180.945