From: Artem Zhidkov Date: Fri, 26 Jun 2020 11:50:00 +0000 (+0300) Subject: Task #3231: Sketcher Offset of a curve X-Git-Tag: V9_6_0a1~60^2~36 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=91777248bd99279a38c84000e444f121334f5d87;p=modules%2Fshaper.git Task #3231: Sketcher Offset of a curve Keep offset edges within the Offset feature in order of the offset wire. --- diff --git a/src/SketchPlugin/SketchPlugin_Offset.cpp b/src/SketchPlugin/SketchPlugin_Offset.cpp index 2d82f0153..cc5234943 100644 --- a/src/SketchPlugin/SketchPlugin_Offset.cpp +++ b/src/SketchPlugin/SketchPlugin_Offset.cpp @@ -55,6 +55,8 @@ #include #include #include +#include +#include #include #include @@ -297,6 +299,25 @@ static void setRefListValue(AttributeRefListPtr theList, int theListSize, theList->append(theValue); } +// Reorder shapes according to the wire's order +static void reorderShapes(ListOfShape& theShapes, GeomShapePtr theWire) +{ + std::set aShapes; + aShapes.insert(theShapes.begin(), theShapes.end()); + theShapes.clear(); + + GeomWirePtr aWire(new GeomAPI_Wire(theWire)); + GeomAPI_WireExplorer anExp(aWire); + for (; anExp.more(); anExp.next()) { + GeomShapePtr aCurEdge = anExp.current(); + auto aFound = aShapes.find(aCurEdge); + if (aFound != aShapes.end()) { + theShapes.push_back(aCurEdge); + aShapes.erase(aFound); + } + } +} + static void removeLastFromIndex(AttributeRefListPtr theList, int theListSize, int& theLastIndex) { if (theLastIndex < theListSize) { @@ -351,8 +372,12 @@ void SketchPlugin_Offset::addToSketch(const ListOfMakeShape& theOffsetAlgos) GeomShapePtr aBaseShape = aBaseFeature->lastResult()->shape(); ListOfShape aNewShapes; for (ListOfMakeShape::const_iterator anAlgoIt = theOffsetAlgos.begin(); - anAlgoIt != theOffsetAlgos.end() && aNewShapes.empty(); ++anAlgoIt) { + anAlgoIt != theOffsetAlgos.end(); ++anAlgoIt) { (*anAlgoIt)->generated(aBaseShape, aNewShapes); + if (!aNewShapes.empty()) { + reorderShapes(aNewShapes, (*anAlgoIt)->shape()); + break; + } } // store base feature @@ -647,6 +672,8 @@ bool SketchPlugin_Offset::findWires() } } + bool aWasBlocked = data()->blockSendAttributeUpdated(true); + // Gather chains of edges for (anEdgesIt = anEdgesList.begin(); anEdgesIt != anEdgesList.end(); anEdgesIt++) { FeaturePtr aFeature = ModelAPI_Feature::feature(*anEdgesIt); @@ -677,6 +704,7 @@ bool SketchPlugin_Offset::findWires() } // TODO: hilight selection in the viewer + data()->blockSendAttributeUpdated(aWasBlocked); return true; }