[Part] extend BRepOffsetAPI_MakeOffsetFix and use it for padding
BRepOffsetAPI_MakeOffsetFix provides already a workaround for an OCC bug. To use it for Pad/pocket, only the Init feature has to be added we take the same implementation like it if for BRepOffsetAPI_MakeOffset
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <BRepAlgoAPI_Cut.hxx>
|
||||
@@ -40,12 +39,14 @@
|
||||
# include <TopoDS.hxx>
|
||||
#endif
|
||||
|
||||
#include "ExtrusionHelper.h"
|
||||
#include <Base/Console.h>
|
||||
#include <Base/Exception.h>
|
||||
|
||||
#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;
|
||||
|
||||
Reference in New Issue
Block a user