diff --git a/src/Mod/Part/App/BRepOffsetAPI_MakeOffsetFix.cpp b/src/Mod/Part/App/BRepOffsetAPI_MakeOffsetFix.cpp index 81c8f19301..f6ab1e1120 100644 --- a/src/Mod/Part/App/BRepOffsetAPI_MakeOffsetFix.cpp +++ b/src/Mod/Part/App/BRepOffsetAPI_MakeOffsetFix.cpp @@ -102,6 +102,17 @@ void BRepOffsetAPI_MakeOffsetFix::Build() mkOffset.Build(); } +void BRepOffsetAPI_MakeOffsetFix::Init(const TopoDS_Face& Spine, const GeomAbs_JoinType Join, + const Standard_Boolean IsOpenResult) +{ + mkOffset.Init(Spine, Join, IsOpenResult); +} + +void BRepOffsetAPI_MakeOffsetFix::Init(const GeomAbs_JoinType Join, const Standard_Boolean IsOpenResult) +{ + mkOffset.Init(Join, IsOpenResult); +} + Standard_Boolean BRepOffsetAPI_MakeOffsetFix::IsDone() const { return mkOffset.IsDone(); diff --git a/src/Mod/Part/App/BRepOffsetAPI_MakeOffsetFix.h b/src/Mod/Part/App/BRepOffsetAPI_MakeOffsetFix.h index b09e1018b5..3e68d9dfc5 100644 --- a/src/Mod/Part/App/BRepOffsetAPI_MakeOffsetFix.h +++ b/src/Mod/Part/App/BRepOffsetAPI_MakeOffsetFix.h @@ -55,6 +55,19 @@ public: //! Builds the resulting shape (redefined from MakeShape). void Build(); + //! Initializes the algorithm to construct parallels to the spine Spine. + //! Join defines the type of parallel generated by the + //! salient vertices of the spine. + //! The default type is GeomAbs_Arc where the vertices generate + //! sections of a circle. + //! If join type is GeomAbs_Intersection, the edges that + //! intersect in a salient vertex generate the edges + //! prolonged until intersection. + void Init(const TopoDS_Face& Spine, const GeomAbs_JoinType Join = GeomAbs_Arc, const Standard_Boolean IsOpenResult = Standard_False); + + //! Initialize the evaluation of Offseting. + void Init(const GeomAbs_JoinType Join = GeomAbs_Arc, const Standard_Boolean IsOpenResult = Standard_False); + virtual Standard_Boolean IsDone() const; //! Returns a shape built by the shape construction algorithm. diff --git a/src/Mod/Part/App/ExtrusionHelper.cpp b/src/Mod/Part/App/ExtrusionHelper.cpp index 4529b1960d..2a67ce18d6 100644 --- a/src/Mod/Part/App/ExtrusionHelper.cpp +++ b/src/Mod/Part/App/ExtrusionHelper.cpp @@ -20,7 +20,6 @@ * * ***************************************************************************/ - #include "PreCompiled.h" #ifndef _PreComp_ # include @@ -40,12 +39,14 @@ # include #endif -#include "ExtrusionHelper.h" #include #include +#include "ExtrusionHelper.h" +#include "BRepOffsetAPI_MakeOffsetFix.h" #include "FeatureExtrusion.h" + using namespace Part; ExtrusionHelper::ExtrusionHelper() @@ -204,12 +205,12 @@ void ExtrusionHelper::makeDraft(const TopoDS_Shape& shape, createTaperedPrismOffset(TopoDS::Wire(singleWire), vecFwd, distanceFwd, numEdges, false, offsetWire); } else { - // there is an OCC bug with single-edge wires (circles), see inside createTaperedPrismOffset + // there is an OCC bug with single-edge wires (circles) if (numEdges > 1 || !isPartDesign) // inner wires must get the negated offset createTaperedPrismOffset(TopoDS::Wire(singleWire), vecFwd, -distanceFwd, numEdges, false, offsetWire); else - // these wires must not get the negated offset + // circles in isPartDesign must not get the negated offset createTaperedPrismOffset(TopoDS::Wire(singleWire), vecFwd, distanceFwd, numEdges, false, offsetWire); } if (offsetWire.IsNull()) @@ -427,22 +428,8 @@ void ExtrusionHelper::createTaperedPrismOffset(TopoDS_Wire sourceWire, TopoDS_Shape offsetShape; if (fabs(offset) > Precision::Confusion()) { TopLoc_Location edgeLocation; - if (numEdges == 1) { - // create a new wire from the input wire to determine its location - // to reset the location after the offset operation - BRepBuilderAPI_MakeWire mkWire; - TopExp_Explorer xp(sourceWire, TopAbs_EDGE); - while (xp.More()) { - TopoDS_Edge edge = TopoDS::Edge(xp.Current()); - edgeLocation = edge.Location(); - edge.Location(TopLoc_Location()); - mkWire.Add(edge); - xp.Next(); - } - movedSourceWire = mkWire.Wire(); - } // create the offset shape - BRepOffsetAPI_MakeOffset mkOffset; + BRepOffsetAPI_MakeOffsetFix mkOffset; mkOffset.Init(GeomAbs_Arc); mkOffset.Init(GeomAbs_Intersection); mkOffset.AddWire(movedSourceWire); @@ -456,12 +443,6 @@ void ExtrusionHelper::createTaperedPrismOffset(TopoDS_Wire sourceWire, if (!mkOffset.IsDone()) { Standard_Failure::Raise("Extrusion: Offset could not be created"); } - if (numEdges == 1) { - // we need to move the offset wire first back to its original position - offsetShape.Move(edgeLocation); - // now apply the translation - offsetShape = offsetShape.Moved(loc); - } } else { offsetShape = movedSourceWire;