]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Task #3231: Sketcher Offset of a curve. Offset side definition by the first selected...
authorjfa <jfa@opencascade.com>
Mon, 29 Jun 2020 14:55:18 +0000 (17:55 +0300)
committerjfa <jfa@opencascade.com>
Mon, 29 Jun 2020 14:55:18 +0000 (17:55 +0300)
src/SketchPlugin/SketchPlugin_Offset.cpp

index e434164accc59acff39f833ffb91a3c12a731867..d03ebdd8f1c51800cf95e6622222c09275b6a10f 100644 (file)
@@ -166,9 +166,24 @@ void SketchPlugin_Offset::execute()
       std::shared_ptr<GeomAlgoAPI_WireBuilder> 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<GeomAlgoAPI_Offset> anOffsetShape(
-          new GeomAlgoAPI_Offset(aPlane, aWireBuilder->shape(), aValue));
+          new GeomAlgoAPI_Offset(aPlane, aWireShape, aValue));
 
       std::shared_ptr<GeomAlgoAPI_MakeShapeList> aMakeList(new GeomAlgoAPI_MakeShapeList);
       aMakeList->appendAlgo(aWireBuilder);