From: Artem Zhidkov Date: Fri, 26 Jun 2020 20:09:42 +0000 (+0300) Subject: Task #3231: Sketcher Offset of a curve X-Git-Tag: V9_6_0a1~60^2~26 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e6347c189283cf93a7d445c2dde122ba5704a2da;p=modules%2Fshaper.git Task #3231: Sketcher Offset of a curve Improvements --- diff --git a/src/SketchPlugin/SketchPlugin_Offset.cpp b/src/SketchPlugin/SketchPlugin_Offset.cpp index fbbbf9a0d..30de8d22c 100644 --- a/src/SketchPlugin/SketchPlugin_Offset.cpp +++ b/src/SketchPlugin/SketchPlugin_Offset.cpp @@ -216,9 +216,11 @@ bool SketchPlugin_Offset::findWireOneWay (const FeaturePtr& theFirstEdge, for (; aPointsIt != anAllCoincPoints.end(); aPointsIt++) { AttributePtr aP = (*aPointsIt); FeaturePtr aCoincFeature = std::dynamic_pointer_cast(aP->owner()); + bool isInSet = (theEdgesSet.find(aCoincFeature) != theEdgesSet.end()); // Condition 0: not auxiliary - if (aCoincFeature->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID())->value()) continue; + if (!isInSet && aCoincFeature->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID())->value()) + continue; // Condition 1: not a point feature if (aCoincFeature->getKind() != SketchPlugin_Point::ID()) { @@ -226,11 +228,7 @@ bool SketchPlugin_Offset::findWireOneWay (const FeaturePtr& theFirstEdge, if (aCoincFeature != theEdge) { // Condition 3: it is in the set of interest. // Empty set means all sketch edges. - bool isInSet = true; - if (theEdgesSet.size()) { - isInSet = (theEdgesSet.find(aCoincFeature) != theEdgesSet.end()); - } - if (isInSet) { + if (isInSet || theEdgesSet.empty()) { // Condition 4: consider only features with two end points std::shared_ptr aP1, aP2; SketchPlugin_SegmentationTools::getFeaturePoints(aCoincFeature, aP1, aP2); @@ -450,6 +448,14 @@ static void findOrCreateFeatureByKind(SketchPlugin_Sketch* theSketch, FeaturePtr& theFeature, std::list& thePoolOfFeatures) { + if (theFeature) { + // check the feature type is the same as required + if (theFeature->getKind() != theFeatureKind) { + // return feature to the pool and try to find the most appropriate + thePoolOfFeatures.push_back(theFeature); + theFeature = FeaturePtr(); + } + } if (!theFeature) { // try to find appropriate feature in the pool for (std::list::iterator it = thePoolOfFeatures.begin(); diff --git a/src/SketchPlugin/SketchPlugin_Validators.cpp b/src/SketchPlugin/SketchPlugin_Validators.cpp index 50d14b6a4..883c0cbb1 100644 --- a/src/SketchPlugin/SketchPlugin_Validators.cpp +++ b/src/SketchPlugin/SketchPlugin_Validators.cpp @@ -36,6 +36,7 @@ #include "SketchPlugin_MacroArc.h" #include "SketchPlugin_MacroCircle.h" #include "SketchPlugin_MultiRotation.h" +#include "SketchPlugin_Offset.h" #include "SketchPlugin_Point.h" #include "SketchPlugin_Sketch.h" #include "SketchPlugin_Trim.h" @@ -535,20 +536,32 @@ bool SketchPlugin_CopyValidator::isValid(const AttributePtr& theAttribute, // B-splines are not supported in Copying features FeaturePtr aSelFeature = ModelAPI_Feature::feature(aSelObject); - if (aSelFeature && (aSelFeature->getKind() == SketchPlugin_BSpline::ID() || + if (aFeature->getKind() != SketchPlugin_Offset::ID() && + aSelFeature && (aSelFeature->getKind() == SketchPlugin_BSpline::ID() || aSelFeature->getKind() == SketchPlugin_BSplinePeriodic::ID())) { theError = "Not supported"; return false; } anObjIter = aCopiedObjects.begin(); - for (; anObjIter != aCopiedObjects.end(); anObjIter++) - if (aSelObject == *anObjIter) { + for (; anObjIter != aCopiedObjects.end(); anObjIter++) { + bool isFound = aSelObject == *anObjIter; + if (!isFound) { + // check in the results of the feature + FeaturePtr aFeature = std::dynamic_pointer_cast(*anObjIter); + const std::list& aResults = aFeature->results(); + for (std::list::const_iterator aResIt = aResults.begin(); + aResIt != aResults.end() && !isFound; ++aResIt) { + isFound = aSelObject == *aResIt; + } + } + if (isFound) { std::wstring aName = aSelObject.get() ? aSelObject->data()->name() : L""; theError = "The object %1 is a result of copy"; theError.arg(aName); return false; } + } } return true; } diff --git a/src/SketchPlugin/plugin-Sketch.xml b/src/SketchPlugin/plugin-Sketch.xml index 2295a3f5e..ef62acfca 100644 --- a/src/SketchPlugin/plugin-Sketch.xml +++ b/src/SketchPlugin/plugin-Sketch.xml @@ -1008,6 +1008,7 @@ shape_types="Edges" use_external="true" greed="true"> + getShape(ObjectPtr theObject) if (!aRes.get()) { FeaturePtr aFeature = std::dynamic_pointer_cast(theObject); if (aFeature.get()) - aRes = std::dynamic_pointer_cast(aFeature->firstResult()); + aRes = std::dynamic_pointer_cast(aFeature->lastResult()); } if (aRes.get() != NULL && aRes->data()->isValid()) { /// essential check as it is called in openGl thread