From: mpv Date: Thu, 26 May 2016 10:43:25 +0000 (+0300) Subject: Fix for the issue #1512: even BOP result is modification of only one argument, the... X-Git-Tag: V_2.3.1~53 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=62221ac9f2fa519c7e0f45372d7fffdd4c555f3b;p=modules%2Fshaper.git Fix for the issue #1512: even BOP result is modification of only one argument, the shapes history must be searched in all features that produce this shape (if not found in the selected result). --- diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index 54840e4bc..88f8bc6cb 100755 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -1287,6 +1287,32 @@ FeaturePtr Model_Document::lastFeature() return FeaturePtr(); } +static Handle(TNaming_NamedShape) searchForOriginalShape(TopoDS_Shape theShape, TDF_Label aMain) { + Handle(TNaming_NamedShape) aResult; + while(!theShape.IsNull()) { // searching for the very initial shape that produces this one + TopoDS_Shape aShape = theShape; + theShape.Nullify(); + for(TNaming_SameShapeIterator anIter(aShape, aMain); anIter.More(); anIter.Next()) { + TDF_Label aNSLab = anIter.Label(); + Handle(TNaming_NamedShape) aNS; + if (aNSLab.FindAttribute(TNaming_NamedShape::GetID(), aNS)) { + for(TNaming_Iterator aShapesIter(aNS); aShapesIter.More(); aShapesIter.Next()) { + if (aShapesIter.Evolution() == TNaming_SELECTED || aShapesIter.Evolution() == TNaming_DELETE) + continue; // don't use the selection evolution + if (aShapesIter.NewShape().IsSame(aShape)) { // found the original shape + aResult = aNS; + if (aResult->Evolution() == TNaming_MODIFY) + theShape = aShapesIter.OldShape(); + if (!theShape.IsNull()) // otherwise may me searching for another item of this shape with longer history + break; + } + } + } + } + } + return aResult; +} + std::shared_ptr Model_Document::producedByFeature( std::shared_ptr theResult, const std::shared_ptr& theShape) @@ -1359,34 +1385,24 @@ std::shared_ptr Model_Document::producedByFeature( } } if (aCandidatInThis.IsNull()) { - if (aCandidatContainer.IsNull()) - return FeaturePtr(); - // with the lower priority use the higher level shape that contains aShape - aCandidatInThis = aCandidatContainer; - anOldShape = aShapeContainer; - } - - while(!anOldShape.IsNull()) { // searching for the very initial shape that produces this one - aShape = anOldShape; - anOldShape.Nullify(); - for(TNaming_SameShapeIterator anIter(aShape, myDoc->Main()); anIter.More(); anIter.Next()) { - TDF_Label aNSLab = anIter.Label(); - Handle(TNaming_NamedShape) aNS; - if (aNSLab.FindAttribute(TNaming_NamedShape::GetID(), aNS)) { - for(TNaming_Iterator aShapesIter(aNS); aShapesIter.More(); aShapesIter.Next()) { - if (aShapesIter.Evolution() == TNaming_SELECTED || aShapesIter.Evolution() == TNaming_DELETE) - continue; // don't use the selection evolution - if (aShapesIter.NewShape().IsSame(aShape)) { // found the original shape - aCandidatInThis = aNS; - if (aCandidatInThis->Evolution() == TNaming_MODIFY) - anOldShape = aShapesIter.OldShape(); - if (!anOldShape.IsNull()) // otherwise may me searching for another item of this shape with longer history - break; - } - } - } + // to fix 1512: searching for original shape of this shape if modification of it is not in this result + aCandidatInThis = searchForOriginalShape(aShape, myDoc->Main()); + if (aCandidatInThis.IsNull()) { + if (aCandidatContainer.IsNull()) + return FeaturePtr(); + // with the lower priority use the higher level shape that contains aShape + aCandidatInThis = aCandidatContainer; + anOldShape = aShapeContainer; + } else { + // to stop the searching by the following searchForOriginalShape + anOldShape.Nullify(); } } + + Handle(TNaming_NamedShape) aNS = searchForOriginalShape(anOldShape, myDoc->Main()); + if (!aNS.IsNull()) + aCandidatInThis = aNS; + FeaturePtr aResult; TDF_Label aResultLab = aCandidatInThis->Label(); while(aResultLab.Depth() > 3)