From 2d5798c31afc83224da264864ae807b392860070 Mon Sep 17 00:00:00 2001 From: jfa Date: Mon, 29 Jun 2020 17:55:18 +0300 Subject: [PATCH] Task #3231: Sketcher Offset of a curve. Offset side definition by the first selected edge. --- src/SketchPlugin/SketchPlugin_Offset.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/SketchPlugin/SketchPlugin_Offset.cpp b/src/SketchPlugin/SketchPlugin_Offset.cpp index e434164ac..d03ebdd8f 100644 --- a/src/SketchPlugin/SketchPlugin_Offset.cpp +++ b/src/SketchPlugin/SketchPlugin_Offset.cpp @@ -166,9 +166,24 @@ void SketchPlugin_Offset::execute() std::shared_ptr aWireBuilder( new GeomAlgoAPI_WireBuilder(aTopoChain)); - // 5.d. Make offset for each wire + GeomShapePtr aWireShape = aWireBuilder->shape(); + GeomWirePtr aWire (new GeomAPI_Wire (aWireShape)); + + // Fix for a problem of offset side change with selection change. + // Wire direction is defined by the first selected edge of this wire. + if (!aWire->isClosed()) { + ListOfShape aModified; + // First selected edge of current chain + GeomShapePtr aFirstSel = aFeature->lastResult()->shape(); + aWireBuilder->modified(aFirstSel, aModified); + GeomShapePtr aModFS = aModified.front(); + if (aModFS->orientation() != aFirstSel->orientation()) + aValue = -aValue; + } + + // 5.d. Make offset for the wire std::shared_ptr anOffsetShape( - new GeomAlgoAPI_Offset(aPlane, aWireBuilder->shape(), aValue)); + new GeomAlgoAPI_Offset(aPlane, aWireShape, aValue)); std::shared_ptr aMakeList(new GeomAlgoAPI_MakeShapeList); aMakeList->appendAlgo(aWireBuilder); -- 2.39.2