From: jfa Date: Mon, 29 Jun 2020 14:55:18 +0000 (+0300) Subject: Task #3231: Sketcher Offset of a curve. Offset side definition by the first selected... X-Git-Tag: V9_6_0a1~60^2~18 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2d5798c31afc83224da264864ae807b392860070;p=modules%2Fshaper.git Task #3231: Sketcher Offset of a curve. Offset side definition by the first selected edge. --- 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);