From: nds Date: Tue, 16 May 2017 10:11:38 +0000 (+0300) Subject: Issue #2155 Trim removes multi-rotation constraint, undo leads to wrong DOF X-Git-Tag: V_2.7.1~20 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=fe8cab988ae59927f68da8e184cce6767e052206;p=modules%2Fshaper.git Issue #2155 Trim removes multi-rotation constraint, undo leads to wrong DOF 3. set coincidence to attribute(not object) of touched feature. --- diff --git a/src/SketchPlugin/SketchPlugin_Trim.cpp b/src/SketchPlugin/SketchPlugin_Trim.cpp index 53a4ad23c..065444786 100644 --- a/src/SketchPlugin/SketchPlugin_Trim.cpp +++ b/src/SketchPlugin/SketchPlugin_Trim.cpp @@ -345,10 +345,29 @@ void SketchPlugin_Trim::execute() } } const std::list& anObjects = anInfo.second; + std::shared_ptr aPoint2D = sketch()->to2D(aPoint); for (std::list::const_iterator anObjectIt = anObjects.begin(); anObjectIt != anObjects.end(); anObjectIt++) { - createConstraintToObject(SketchPlugin_ConstraintCoincidence::ID(), aPointAttribute, - *anObjectIt); + ObjectPtr anObject = *anObjectIt; + // find an attribute on the point feature and if it is, append it into attribute list + // the case when the feature just touch the source feature, not intersect + FeaturePtr aRefFeature = ModelAPI_Feature::feature(anObject); + std::list > anAttributes = + aRefFeature->data()->attributes(GeomDataAPI_Point2D::typeId()); + bool aFoundAttribute = false; + for (std::list >::const_iterator + aPntAttrIt = anAttributes.begin(); aPntAttrIt != anAttributes.end(); aPntAttrIt++) { + std::shared_ptr anAttrPoint = + std::dynamic_pointer_cast(*aPntAttrIt); + if (anAttrPoint->pnt()->isEqual(aPoint2D)) { + createConstraint(SketchPlugin_ConstraintCoincidence::ID(), aPointAttribute, anAttrPoint); + aFoundAttribute = true; + break; + } + } + if (!aFoundAttribute) + createConstraintToObject(SketchPlugin_ConstraintCoincidence::ID(), aPointAttribute, + anObject); } }