+ // Fill history to be used by GetInPlace functionality
+ TopTools_IndexedMapOfShape aResIndices;
+ TopExp::MapShapes(aShape, aResIndices);
+
+ // Map: source_shape/images of source_shape in Result
+ const TopTools_IndexedDataMapOfShapeListOfShape& aMR = PS.ImagesResult();
+
+ // history for all argument shapes
+ // be sure to use aCopyMap
+ TDF_LabelSequence aLabelSeq;
+ aFunction->GetDependency(aLabelSeq);
+ Standard_Integer nbArg = aLabelSeq.Length();
+
+ for (Standard_Integer iarg = 1; iarg <= nbArg; iarg++) {
+
+ TDF_Label anArgumentRefLabel = aLabelSeq.Value(iarg);
+
+ Handle(GEOM_Object) anArgumentObject = GEOM_Object::GetReferencedObject(anArgumentRefLabel);
+ TopoDS_Shape anArgumentShape = anArgumentObject->GetValue();
+
+ TopTools_IndexedMapOfShape anArgumentIndices;
+ TopExp::MapShapes(anArgumentShape, anArgumentIndices);
+ Standard_Integer nbArgumentEntities = anArgumentIndices.Extent();
+
+ // Find corresponding label in history
+ TDF_Label anArgumentHistoryLabel =
+ aFunction->GetArgumentHistoryEntry(anArgumentRefLabel, Standard_True);
+
+ for (Standard_Integer ie = 1; ie <= nbArgumentEntities; ie++) {
+ TopoDS_Shape anEntity = anArgumentIndices.FindKey(ie);
+ // be sure to use aCopyMap here
+ if (aCopyMap.IsBound(anEntity))
+ anEntity = aCopyMap.Find(anEntity);
+ //
+ if (!aMR.Contains(anEntity)) continue;
+
+ const TopTools_ListOfShape& aModified = aMR.FindFromKey(anEntity);
+ Standard_Integer nbModified = aModified.Extent();
+
+ if (nbModified > 0) { // Mantis issue 0021182
+ int ih = 1;
+ TopTools_ListIteratorOfListOfShape itM (aModified);
+ for (; itM.More() && nbModified > 0; itM.Next(), ++ih) {
+ if (!aResIndices.Contains(itM.Value())) {
+ nbModified = 0;
+ }
+ }
+ }
+ if (nbModified > 0) {
+ TDF_Label aWhatHistoryLabel = anArgumentHistoryLabel.FindChild(ie, Standard_True);
+ Handle(TDataStd_IntegerArray) anAttr =
+ TDataStd_IntegerArray::Set(aWhatHistoryLabel, 1, nbModified);
+
+ int ih = 1;
+ TopTools_ListIteratorOfListOfShape itM (aModified);
+ for (; itM.More(); itM.Next(), ++ih) {
+ int id = aResIndices.FindIndex(itM.Value());
+ anAttr->SetValue(ih, id);
+ }
+ }
+ }
+ }
+