From f127a007a7ab9b148ddf98b6848b1dfb8ef733db Mon Sep 17 00:00:00 2001 From: mpv Date: Fri, 24 Mar 2017 17:56:24 +0300 Subject: [PATCH] Fix for the issue #2052 : correct update of selection of the whole sketch if the number of faces is reduced. --- src/Model/Model_ResultConstruction.cpp | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/Model/Model_ResultConstruction.cpp b/src/Model/Model_ResultConstruction.cpp index a9781e1f4..f41b2ba3d 100644 --- a/src/Model/Model_ResultConstruction.cpp +++ b/src/Model/Model_ResultConstruction.cpp @@ -452,11 +452,33 @@ bool Model_ResultConstruction::update(const int theIndex, bool aRes = true; Handle(TDataStd_IntPackedMap) anIndices; if (aLab.FindAttribute(TDataStd_IntPackedMap::GetID(), anIndices)) { + NCollection_Map aFaces; // collect faces, updated in the tree TColStd_MapIteratorOfPackedMapOfInteger anIndexIter(anIndices->GetMap()); + Handle(TColStd_HPackedMapOfInteger) aNewPackedMap = + new TColStd_HPackedMapOfInteger; // with only faces that are ok + // iterate to find existing faces, updated for(; anIndexIter.More(); anIndexIter.Next()) { - if (!update(anIndexIter.Key(), theExtDoc, theModified)) - aRes = false; + if (update(anIndexIter.Key(), theExtDoc, theModified)) { + GeomShapePtr aFace = shape(anIndexIter.Key(), theExtDoc); + if (!aFaces.Contains(aFace->impl())) { + aNewPackedMap->ChangeMap().Add(anIndexIter.Key()); + aFaces.Add(aFace->impl()); + } + } + } + // then iterate all existing faces to find new faces + int aCurrentFacesNum = facesNum(); + for(int a = 0; a < aCurrentFacesNum; a++) { + GeomShapePtr aFace = face(a); + if (!aFaces.Contains(aFace->impl())) { + // add this one + int aNewFaceIndex = select(aFace, theExtDoc, -1); + if (aNewFaceIndex > 0) { + aNewPackedMap->ChangeMap().Add(aNewFaceIndex); + } + } } + anIndices->ChangeMap(aNewPackedMap); } return aRes; } else { -- 2.30.2